8936ae98df86ad01da05a192400ed2d67ad18ca3
[pspp] / tests / language / lexer / segment.at
1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
3 dnl
4 dnl This program is free software: you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation, either version 3 of the License, or
7 dnl (at your option) any later version.
8 dnl
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl GNU General Public License for more details.
13 dnl
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 dnl
17 AT_BANNER([syntax segmentation])
18 m4_define([PSPP_CHECK_SEGMENT],
19   [AT_CAPTURE_FILE([input])
20    for strip in "" "-s"; do
21      case $strip in # (
22         '') sed 's/^-//' < expout-base > expout ;; # (
23         -s) sed '/^-/d' < expout-base > expout ;;
24      esac
25      AT_CHECK([segment-test $1 $strip input], [0], [expout])
26      AT_CHECK([segment-test -1 $strip $1 input], [0], [expout])
27      AT_CHECK([segment-test -0 $strip $1 input])
28      AT_CHECK([segment-test -01 $strip $1 input])
29    done])
30 \f
31 AT_SETUP([identifiers])
32 AT_KEYWORDS([segment])
33 AT_DATA([input], [dnl
34 a ab abc abcd !abcd
35 A AB ABC ABCD !ABCD
36 aB aBC aBcD !aBcD
37 $x $y $z !$z
38 grève@<00A0>@Ângstrom@<00A0>@poté
39 #a #b #c ## #d !#d
40 @efg @ @@. @#@ !@ @&t@
41 ## # #12345 #.#
42 f@#_.#6
43 GhIjK
44 .x 1y _z
45 ])
46 AT_DATA([expout-base], [dnl
47 identifier      a    space
48 identifier      ab    space
49 identifier      abc    space
50 identifier      abcd    space
51 macro_id        !abcd
52 newline         \n (later)
53
54 identifier      A    space
55 identifier      AB    space
56 identifier      ABC    space
57 identifier      ABCD    space
58 macro_id        !ABCD
59 newline         \n (later)
60
61 identifier      aB    space
62 identifier      aBC    space
63 identifier      aBcD    space
64 macro_id        !aBcD
65 newline         \n (later)
66
67 identifier      $x    space
68 identifier      $y    space
69 identifier      $z    space
70 macro_id        !$z
71 newline         \n (later)
72
73 identifier      grève
74 spaces          <U+00A0>
75 identifier      Ângstrom
76 spaces          <U+00A0>
77 identifier      poté
78 newline         \n (later)
79
80 identifier      #a    space
81 identifier      #b    space
82 identifier      #c    space
83 identifier      ##    space
84 identifier      #d    space
85 macro_id        !#d
86 newline         \n (later)
87
88 identifier      @efg    space
89 identifier      @    space
90 identifier      @@.    space
91 identifier      @#@    space
92 macro_id        !@    space
93 newline         \n (later)
94
95 identifier      ##    space
96 identifier      #    space
97 identifier      #12345    space
98 identifier      #.#
99 newline         \n (later)
100
101 identifier      f@#\_.#6
102 newline         \n (later)
103
104 identifier      GhIjK
105 newline         \n (later)
106
107 start_command   .
108 identifier      x    space
109 number          1
110 identifier      y    space
111 punct           \_
112 identifier      z
113 -newline         \n (later)
114 -
115 end
116 ])
117 PSPP_CHECK_SEGMENT([-i])
118 AT_CLEANUP
119 \f
120 AT_SETUP([identifiers that end in '.'])
121 AT_KEYWORDS([segment])
122 AT_DATA([input], [dnl
123 abcd. abcd.
124 ABCD. ABCD.
125 aBcD. aBcD. @&t@
126 $y. $z. あいうえお.
127 #c. #d..
128 @@. @@....
129 #.#.
130 #abcd.
131 .
132 . @&t@
133 LMNOP. @&t@
134 QRSTUV./* end of line comment */
135 qrstuv. /* end of line comment */
136 QrStUv./* end of line comment */ @&t@
137 wxyz./* unterminated end of line comment
138 WXYZ. /* unterminated end of line comment
139 WxYz./* unterminated end of line comment @&t@
140 ])
141 AT_DATA([expout-base], [dnl
142 identifier      abcd.    space
143 identifier      abcd
144 end_command     .
145 newline         \n (first)
146
147 identifier      ABCD.    space
148 identifier      ABCD
149 end_command     .
150 newline         \n (first)
151
152 identifier      aBcD.    space
153 identifier      aBcD
154 end_command     .    space
155 newline         \n (first)
156
157 identifier      $y.    space
158 identifier      $z.    space
159 identifier      あいうえお
160 end_command     .
161 newline         \n (first)
162
163 identifier      #c.    space
164 identifier      #d.
165 end_command     .
166 newline         \n (first)
167
168 identifier      @@.    space
169 identifier      @@...
170 end_command     .
171 newline         \n (first)
172
173 identifier      #.#
174 end_command     .
175 newline         \n (first)
176
177 identifier      #abcd
178 end_command     .
179 newline         \n (first)
180
181 start_command   .
182 newline         \n (first)
183
184 start_command   .    space
185 newline         \n (first)
186
187 identifier      LMNOP
188 end_command     .    space
189 newline         \n (first)
190
191 identifier      QRSTUV
192 end_command     .
193 comment         /*_end_of_line_comment_*/
194 newline         \n (first)
195
196 identifier      qrstuv
197 end_command     .    space
198 comment         /*_end_of_line_comment_*/
199 newline         \n (first)
200
201 identifier      QrStUv
202 end_command     .
203 comment         /*_end_of_line_comment_*/    space
204 newline         \n (first)
205
206 identifier      wxyz
207 end_command     .
208 comment         /*_unterminated_end_of_line_comment
209 newline         \n (first)
210
211 identifier      WXYZ
212 end_command     .    space
213 comment         /*_unterminated_end_of_line_comment
214 newline         \n (first)
215
216 identifier      WxYz
217 end_command     .
218 comment         /*_unterminated_end_of_line_comment_
219 -newline         \n (first)
220 -
221 end
222 ])
223 PSPP_CHECK_SEGMENT([-i])
224 AT_CLEANUP
225 \f
226 AT_SETUP([reserved words])
227 AT_KEYWORDS([segment])
228 AT_DATA([input], [dnl
229 and or not eq ge gt le lt ne all by to with
230 AND OR NOT EQ GE GT LE LT NE ALL BY TO WITH
231 andx orx notx eqx gex gtx lex ltx nex allx byx tox withx
232 and. with.
233 ])
234 AT_DATA([expout-base], [dnl
235 reserved_word   and    space
236 reserved_word   or    space
237 reserved_word   not    space
238 reserved_word   eq    space
239 reserved_word   ge    space
240 reserved_word   gt    space
241 reserved_word   le    space
242 reserved_word   lt    space
243 reserved_word   ne    space
244 reserved_word   all    space
245 reserved_word   by    space
246 reserved_word   to    space
247 reserved_word   with
248 newline         \n (later)
249
250 reserved_word   AND    space
251 reserved_word   OR    space
252 reserved_word   NOT    space
253 reserved_word   EQ    space
254 reserved_word   GE    space
255 reserved_word   GT    space
256 reserved_word   LE    space
257 reserved_word   LT    space
258 reserved_word   NE    space
259 reserved_word   ALL    space
260 reserved_word   BY    space
261 reserved_word   TO    space
262 reserved_word   WITH
263 newline         \n (later)
264
265 identifier      andx    space
266 identifier      orx    space
267 identifier      notx    space
268 identifier      eqx    space
269 identifier      gex    space
270 identifier      gtx    space
271 identifier      lex    space
272 identifier      ltx    space
273 identifier      nex    space
274 identifier      allx    space
275 identifier      byx    space
276 identifier      tox    space
277 identifier      withx
278 newline         \n (later)
279
280 identifier      and.    space
281 reserved_word   with
282 end_command     .
283 -newline         \n (first)
284 -
285 end
286 ])
287 PSPP_CHECK_SEGMENT([-i])
288 AT_CLEANUP
289 \f
290 AT_SETUP([punctuation])
291 AT_KEYWORDS([segment])
292 AT_DATA([input], [dnl
293 ~ & | = >= > <= < ~= <> ( ) , - + * / [[ ]] **
294 ~&|=>=><=<~=<>(),-+*/[[]]**!*
295 % : ; ? _ ` { } ~ !*
296 ])
297 AT_DATA([expout-base], [dnl
298 punct           ~    space
299 punct           &    space
300 punct           |    space
301 punct           =    space
302 punct           >=    space
303 punct           >    space
304 punct           <=    space
305 punct           <    space
306 punct           ~=    space
307 punct           <>    space
308 punct           (    space
309 punct           )    space
310 punct           ,    space
311 punct           -    space
312 punct           +    space
313 punct           *    space
314 punct           /    space
315 punct           [[    space
316 punct           ]]    space
317 punct           **
318 newline         \n (later)
319
320 punct           ~
321 punct           &
322 punct           |
323 punct           =
324 punct           >=
325 punct           >
326 punct           <=
327 punct           <
328 punct           ~=
329 punct           <>
330 punct           (
331 punct           )
332 punct           ,
333 punct           -
334 punct           +
335 punct           *
336 punct           /
337 punct           [[
338 punct           ]]
339 punct           **
340 macro_id        !*
341 newline         \n (later)
342
343 punct           %    space
344 punct           :    space
345 punct           ;    space
346 punct           ?    space
347 punct           \_    space
348 punct           `    space
349 punct           {    space
350 punct           }    space
351 punct           ~    space
352 macro_id        !*
353 -newline         \n (later)
354 -
355 end
356 ])
357 PSPP_CHECK_SEGMENT([-i])
358 AT_CLEANUP
359 \f
360 AT_SETUP([positive numbers])
361 AT_KEYWORDS([segment])
362 AT_DATA([input], [dnl
363 0 1 01 001. 1.
364 123. /* comment 1 */ /* comment 2 */
365 .1 0.1 00.1 00.10
366 5e1 6E-1 7e+1 6E+01 6e-03
367 .3E1 .4e-1 .5E+1 .6e+01 .7E-03
368 1.23e1 45.6E-1 78.9e+1 99.9E+01 11.2e-03
369 . 1e e1 1e+ 1e- 1.
370 ])
371 AT_DATA([expout-base], [dnl
372 number          0    space
373 number          1    space
374 number          01    space
375 number          001.    space
376 number          1
377 end_command     .
378 newline         \n (first)
379
380 number          123
381 end_command     .    space
382 comment         /*_comment_1_*/    space
383 comment         /*_comment_2_*/
384 newline         \n (first)
385
386 start_command   .
387 number          1    space
388 number          0.1    space
389 number          00.1    space
390 number          00.10
391 newline         \n (later)
392
393 number          5e1    space
394 number          6E-1    space
395 number          7e+1    space
396 number          6E+01    space
397 number          6e-03
398 newline         \n (later)
399
400 start_command   .
401 number          3E1    space
402 number          .4e-1    space
403 number          .5E+1    space
404 number          .6e+01    space
405 number          .7E-03
406 newline         \n (later)
407
408 number          1.23e1    space
409 number          45.6E-1    space
410 number          78.9e+1    space
411 number          99.9E+01    space
412 number          11.2e-03
413 newline         \n (later)
414
415 start_command   .    space
416 expected_exponent 1e    space
417 identifier      e1    space
418 expected_exponent 1e+    space
419 expected_exponent 1e-    space
420 number          1
421 end_command     .
422 -newline         \n (first)
423 -
424 end
425 ])
426 PSPP_CHECK_SEGMENT([-i])
427 AT_CLEANUP
428 \f
429 AT_SETUP([negative numbers])
430 AT_KEYWORDS([segment])
431 AT_DATA([input], [dnl
432  -0 -1 -01 -001. -1.
433  -123. /* comment 1 */ /* comment 2 */
434  -.1 -0.1 -00.1 -00.10
435  -5e1 -6E-1 -7e+1 -6E+01 -6e-03
436  -.3E1 -.4e-1 -.5E+1 -.6e+01 -.7E-03
437  -1.23e1 -45.6E-1 -78.9e+1 -99.9E+01 -11.2e-03
438  -/**/1
439  -. -1e -e1 -1e+ -1e- -1.
440 ])
441 AT_DATA([expout-base], [dnl
442 spaces          _
443 number          -0    space
444 number          -1    space
445 number          -01    space
446 number          -001.    space
447 number          -1
448 end_command     .
449 newline         \n (first)
450     space
451 number          -123
452 end_command     .    space
453 comment         /*_comment_1_*/    space
454 comment         /*_comment_2_*/
455 newline         \n (first)
456     space
457 number          -.1    space
458 number          -0.1    space
459 number          -00.1    space
460 number          -00.10
461 newline         \n (later)
462     space
463 number          -5e1    space
464 number          -6E-1    space
465 number          -7e+1    space
466 number          -6E+01    space
467 number          -6e-03
468 newline         \n (later)
469     space
470 number          -.3E1    space
471 number          -.4e-1    space
472 number          -.5E+1    space
473 number          -.6e+01    space
474 number          -.7E-03
475 newline         \n (later)
476     space
477 number          -1.23e1    space
478 number          -45.6E-1    space
479 number          -78.9e+1    space
480 number          -99.9E+01    space
481 number          -11.2e-03
482 newline         \n (later)
483     space
484 punct           -
485 comment         /**/
486 number          1
487 newline         \n (later)
488     space
489 punct           -
490 punct           .    space
491 expected_exponent -1e    space
492 punct           -
493 identifier      e1    space
494 expected_exponent -1e+    space
495 expected_exponent -1e-    space
496 number          -1
497 end_command     .
498 -newline         \n (first)
499 -
500 end
501 ])
502 PSPP_CHECK_SEGMENT([-i])
503 AT_CLEANUP
504
505 \f
506 AT_SETUP([strings])
507 AT_KEYWORDS([segment])
508 AT_DATA([input], [dnl
509 'x' "y" 'abc'
510 'Don''t' "Can't" 'Won''t'
511 """quoted""" '"quoted"'
512 '' ""
513 'missing end quote
514 "missing double quote
515 x"4142" X'5152'
516 u'fffd' U"041"
517 + new command
518 + /* comment */ 'string continuation'
519 + /* also a punctuator on blank line
520 - 'new command'
521 ])
522 AT_DATA([expout-base], [dnl
523 quoted_string   'x'    space
524 quoted_string   "y"    space
525 quoted_string   'abc'
526 newline         \n (later)
527
528 quoted_string   'Don''t'    space
529 quoted_string   "Can't"    space
530 quoted_string   'Won''t'
531 newline         \n (later)
532
533 quoted_string   """quoted"""    space
534 quoted_string   '"quoted"'
535 newline         \n (later)
536
537 quoted_string   ''    space
538 quoted_string   ""
539 newline         \n (later)
540
541 expected_quote  'missing_end_quote
542 newline         \n (later)
543
544 expected_quote  "missing_double_quote
545 newline         \n (later)
546
547 hex_string      x"4142"    space
548 hex_string      X'5152'
549 newline         \n (later)
550
551 unicode_string  u'fffd'    space
552 unicode_string  U"041"
553 newline         \n (later)
554
555 start_command   +    space
556 identifier      new    space
557 identifier      command
558 newline         \n (later)
559
560 punct           +    space
561 comment         /*_comment_*/    space
562 quoted_string   'string_continuation'
563 newline         \n (later)
564
565 punct           +    space
566 comment         /*_also_a_punctuator_on_blank_line
567 newline         \n (later)
568
569 start_command   -    space
570 quoted_string   'new_command'
571 -newline         \n (later)
572 -
573 end
574 ])
575 PSPP_CHECK_SEGMENT([-i])
576 AT_CLEANUP
577 \f
578 AT_SETUP([@%:@! construct])
579 AT_KEYWORDS([segment])
580 AT_DATA([input], [dnl
581 #! /usr/bin/pspp
582 title my title.
583 #! /usr/bin/pspp
584 ])
585 AT_DATA([expout-base], [dnl
586 shbang          #!_/usr/bin/pspp
587 newline         \n (first)
588
589 identifier      title    space
590 identifier      my    space
591 identifier      title
592 end_command     .
593 newline         \n (first)
594
595 identifier      #
596 macro_id        !    space
597 punct           /
598 identifier      usr
599 punct           /
600 identifier      bin
601 punct           /
602 identifier      pspp
603 -newline         \n (later)
604 -
605 end
606 ])
607 PSPP_CHECK_SEGMENT([-i])
608 AT_CLEANUP
609 \f
610 AT_SETUP([* and COMMENT commands])
611 AT_KEYWORDS([segment])
612 AT_DATA([input], [dnl
613 * Comment commands "don't
614 have to contain valid tokens.
615
616 ** Check ambiguity with ** token.
617 ****************.
618
619 comment keyword works too.
620 COMM also.
621 com is ambiguous with COMPUTE.
622
623    * Comment need not start at left margin.
624
625 * Comment ends with blank line
626
627 next command.
628
629 ])
630 AT_DATA([expout-base], [dnl
631 comment_command *_Comment_commands_"don't
632 newline         \n (COMMENT)
633
634 comment_command have_to_contain_valid_tokens
635 end_command     .
636 newline         \n (first)
637
638 separate_commands
639 newline         \n (first)
640
641 comment_command **_Check_ambiguity_with_**_token
642 end_command     .
643 newline         \n (first)
644
645 comment_command ****************
646 end_command     .
647 newline         \n (first)
648
649 separate_commands
650 newline         \n (first)
651
652 comment_command comment_keyword_works_too
653 end_command     .
654 newline         \n (first)
655
656 comment_command COMM_also
657 end_command     .
658 newline         \n (first)
659
660 identifier      com    space
661 identifier      is    space
662 identifier      ambiguous    space
663 reserved_word   with    space
664 identifier      COMPUTE
665 end_command     .
666 newline         \n (first)
667
668 separate_commands
669 newline         \n (first)
670
671 spaces          ___
672 comment_command *_Comment_need_not_start_at_left_margin
673 end_command     .
674 newline         \n (first)
675
676 separate_commands
677 newline         \n (first)
678
679 comment_command *_Comment_ends_with_blank_line
680 newline         \n (COMMENT)
681
682 separate_commands
683 newline         \n (first)
684
685 identifier      next    space
686 identifier      command
687 end_command     .
688 newline         \n (first)
689
690 -separate_commands
691 -newline         \n (first)
692 -
693 end
694 ])
695 PSPP_CHECK_SEGMENT([-i])
696 AT_CLEANUP
697 \f
698 AT_SETUP([DOCUMENT command])
699 AT_KEYWORDS([segment])
700 AT_DATA([input], [dnl
701 DOCUMENT one line.
702 DOC more
703     than
704         one
705             line.
706 docu
707 first.paragraph
708 isn't parsed as tokens
709
710 second paragraph.
711 ])
712 AT_DATA([expout-base], [dnl
713 start_document
714 document        DOCUMENT_one_line.
715 end_command
716 separate_commands
717 newline         \n (first)
718
719 start_document
720 document        DOC_more
721 newline         \n (DOCUMENT)
722
723 document        ____than
724 newline         \n (DOCUMENT)
725
726 document        ________one
727 newline         \n (DOCUMENT)
728
729 document        ____________line.
730 end_command
731 separate_commands
732 newline         \n (first)
733
734 start_document
735 document        docu
736 newline         \n (DOCUMENT)
737
738 document        first.paragraph
739 newline         \n (DOCUMENT)
740
741 document        isn't_parsed_as_tokens
742 newline         \n (DOCUMENT)
743
744 document
745 newline         \n (DOCUMENT)
746
747 document        second_paragraph.
748 -end_command
749 -separate_commands
750 -newline         \n (first)
751 -
752 end
753 ])
754 PSPP_CHECK_SEGMENT([-i])
755 AT_CLEANUP
756 \f
757 AT_SETUP([FILE LABEL command])
758 AT_KEYWORDS([segment])
759 AT_DATA([input], [dnl
760 FIL label isn't quoted.
761 FILE
762   lab 'is quoted'.
763 FILE /*
764 /**/  lab not quoted here either
765
766 ])
767 AT_DATA([expout-base], [dnl
768 identifier      FIL    space
769 identifier      label    space
770 unquoted_string isn't_quoted
771 end_command     .
772 newline         \n (first)
773
774 identifier      FILE
775 newline         \n (later)
776
777 spaces          __
778 identifier      lab    space
779 quoted_string   'is_quoted'
780 end_command     .
781 newline         \n (first)
782
783 identifier      FILE    space
784 comment         /*
785 newline         \n (later)
786
787 comment         /**/
788 spaces          __
789 identifier      lab    space
790 unquoted_string not_quoted_here_either
791 newline         \n (later)
792
793 -separate_commands
794 -newline         \n (first)
795 -
796 end
797 ])
798 PSPP_CHECK_SEGMENT([-i])
799 AT_CLEANUP
800 \f
801 AT_SETUP([BEGIN DATA command])
802 AT_KEYWORDS([segment])
803 AT_DATA([input], [dnl
804 begin data.
805 end data.
806
807 begin data. /*
808 123
809 xxx
810 end data.
811
812 BEG /**/ DAT /*
813 5 6 7 /* x
814
815 end  data
816 end data
817 .
818
819 begin
820  data.
821 data
822 end data.
823
824 begin data "xxx".
825 begin data 123.
826 not data
827 ])
828 AT_DATA([expout-base], [dnl
829 identifier      begin    space
830 identifier      data
831 end_command     .
832 newline         \n (data)
833
834 identifier      end    space
835 identifier      data
836 end_command     .
837 newline         \n (first)
838
839 separate_commands
840 newline         \n (first)
841
842 identifier      begin    space
843 identifier      data
844 end_command     .    space
845 comment         /*
846 newline         \n (data)
847
848 inline_data     123
849 newline         \n (data)
850
851 inline_data     xxx
852 newline         \n (data)
853
854 identifier      end    space
855 identifier      data
856 end_command     .
857 newline         \n (first)
858
859 separate_commands
860 newline         \n (first)
861
862 identifier      BEG    space
863 comment         /**/    space
864 identifier      DAT    space
865 comment         /*
866 newline         \n (data)
867
868 inline_data     5_6_7_/*_x
869 newline         \n (data)
870
871 inline_data
872 newline         \n (data)
873
874 inline_data     end__data
875 newline         \n (data)
876
877 identifier      end    space
878 identifier      data
879 newline         \n (later)
880
881 start_command   .
882 newline         \n (first)
883
884 separate_commands
885 newline         \n (first)
886
887 identifier      begin
888 newline         \n (later)
889     space
890 identifier      data
891 end_command     .
892 newline         \n (data)
893
894 inline_data     data
895 newline         \n (data)
896
897 identifier      end    space
898 identifier      data
899 end_command     .
900 newline         \n (first)
901
902 separate_commands
903 newline         \n (first)
904
905 identifier      begin    space
906 identifier      data    space
907 quoted_string   "xxx"
908 end_command     .
909 newline         \n (first)
910
911 identifier      begin    space
912 identifier      data    space
913 number          123
914 end_command     .
915 newline         \n (first)
916
917 reserved_word   not    space
918 identifier      data
919 -newline         \n (later)
920 -
921 end
922 ])
923 PSPP_CHECK_SEGMENT([-i])
924 AT_CLEANUP
925 \f
926 AT_SETUP([DO REPEAT command])
927 AT_KEYWORDS([segment])
928 AT_DATA([input], [dnl
929 do repeat x=a b c
930           y=d e f.
931   do repeat a=1 thru 5.
932 another command.
933 second command
934 + third command.
935 end /* x */ /* y */ repeat print.
936 end
937  repeat.
938 do
939   repeat #a=1.
940   inner command.
941 end repeat.
942 ])
943 AT_DATA([expout-base], [dnl
944 identifier      do    space
945 identifier      repeat    space
946 identifier      x
947 punct           =
948 identifier      a    space
949 identifier      b    space
950 identifier      c
951 newline         \n (later)
952
953 spaces          __________
954 identifier      y
955 punct           =
956 identifier      d    space
957 identifier      e    space
958 identifier      f
959 end_command     .
960 newline         \n (DO REPEAT)
961
962 do_repeat_command __do_repeat_a=1_thru_5.
963 newline         \n (DO REPEAT)
964
965 do_repeat_command another_command.
966 newline         \n (DO REPEAT)
967
968 do_repeat_command second_command
969 newline         \n (DO REPEAT)
970
971 do_repeat_command +_third_command.
972 newline         \n (DO REPEAT)
973
974 do_repeat_command end_/*_x_*/_/*_y_*/_repeat_print.
975 newline         \n (DO REPEAT)
976
977 identifier      end
978 newline         \n (later)
979     space
980 identifier      repeat
981 end_command     .
982 newline         \n (first)
983
984 identifier      do
985 newline         \n (later)
986
987 spaces          __
988 identifier      repeat    space
989 identifier      #a
990 punct           =
991 number          1
992 end_command     .
993 newline         \n (DO REPEAT)
994
995 do_repeat_command __inner_command.
996 newline         \n (DO REPEAT)
997
998 identifier      end    space
999 identifier      repeat
1000 end_command     .
1001 -newline         \n (first)
1002 -
1003 end
1004 ])
1005 PSPP_CHECK_SEGMENT([-i])
1006 AT_CLEANUP
1007 \f
1008 AT_SETUP([DO REPEAT command in batch mode])
1009 AT_KEYWORDS([segment])
1010 AT_DATA([input], [dnl
1011 do repeat x=a b c
1012           y=d e f
1013 do repeat a=1 thru 5
1014 another command
1015 second command
1016 + third command
1017 end /* x */ /* y */ repeat print
1018 end
1019  repeat
1020 do
1021   repeat #a=1
1022
1023   inner command
1024 end repeat
1025 ])
1026 AT_DATA([expout-base], [dnl
1027 identifier      do    space
1028 identifier      repeat    space
1029 identifier      x
1030 punct           =
1031 identifier      a    space
1032 identifier      b    space
1033 identifier      c
1034 newline         \n (later)
1035
1036 spaces          __________
1037 identifier      y
1038 punct           =
1039 identifier      d    space
1040 identifier      e    space
1041 identifier      f
1042 newline         \n (later)
1043
1044 start_command
1045 do_repeat_command do_repeat_a=1_thru_5
1046 newline         \n (DO REPEAT)
1047
1048 do_repeat_command another_command
1049 newline         \n (DO REPEAT)
1050
1051 do_repeat_command second_command
1052 newline         \n (DO REPEAT)
1053
1054 do_repeat_command +_third_command
1055 newline         \n (DO REPEAT)
1056
1057 do_repeat_command end_/*_x_*/_/*_y_*/_repeat_print
1058 newline         \n (DO REPEAT)
1059
1060 identifier      end
1061 newline         \n (later)
1062     space
1063 identifier      repeat
1064 newline         \n (later)
1065
1066 start_command
1067 identifier      do
1068 newline         \n (later)
1069
1070 spaces          __
1071 identifier      repeat    space
1072 identifier      #a
1073 punct           =
1074 number          1
1075 newline         \n (later)
1076
1077 separate_commands
1078 newline         \n (DO REPEAT)
1079
1080 do_repeat_command __inner_command
1081 newline         \n (DO REPEAT)
1082
1083 identifier      end    space
1084 identifier      repeat
1085 -newline         \n (later)
1086 -
1087 end
1088 ])
1089 PSPP_CHECK_SEGMENT([-b])
1090 AT_CLEANUP
1091 \f
1092 AT_SETUP([DEFINE command - simple])
1093 AT_KEYWORDS([segment])
1094 AT_DATA([input], [dnl
1095 define !macro1()
1096 var1 var2 var3 "!enddefine"
1097 !enddefine.
1098 ])
1099 AT_DATA([expout-base], [dnl
1100 identifier      define    space
1101 macro_id        !macro1
1102 punct           (
1103 punct           )
1104 spaces
1105 newline         \n (DEFINE)
1106
1107 macro_body      var1_var2_var3_"!enddefine"
1108 newline         \n (DEFINE)
1109
1110 macro_id        !enddefine
1111 end_command     .
1112 -newline         \n (first)
1113 -
1114 end
1115 ])
1116 PSPP_CHECK_SEGMENT([-i])
1117 AT_CLEANUP
1118 \f
1119 AT_SETUP([DEFINE command - no newline after parentheses])
1120 AT_KEYWORDS([segment])
1121 AT_DATA([input], [dnl
1122 define !macro1() var1 var2 var3 /* !enddefine
1123 !enddefine.
1124 ])
1125 AT_DATA([expout-base], [dnl
1126 identifier      define    space
1127 macro_id        !macro1
1128 punct           (
1129 punct           )
1130 macro_body      _var1_var2_var3_/*_!enddefine
1131 newline         \n (DEFINE)
1132
1133 macro_id        !enddefine
1134 end_command     .
1135 -newline         \n (first)
1136 -
1137 end
1138 ])
1139 PSPP_CHECK_SEGMENT([-i])
1140 AT_CLEANUP
1141 \f
1142 AT_SETUP([DEFINE command - no newline before !ENDDEFINE])
1143 AT_KEYWORDS([segment ENDDEFINE])
1144 AT_DATA([input], [dnl
1145 define !macro1()
1146 var1 var2 var3!enddefine.
1147 ])
1148 AT_DATA([expout-base], [dnl
1149 identifier      define    space
1150 macro_id        !macro1
1151 punct           (
1152 punct           )
1153 spaces
1154 newline         \n (DEFINE)
1155
1156 macro_body      var1_var2_var3
1157 macro_id        !enddefine
1158 end_command     .
1159 -newline         \n (first)
1160 -
1161 end
1162 ])
1163 PSPP_CHECK_SEGMENT([-i])
1164 AT_CLEANUP
1165 \f
1166 AT_SETUP([DEFINE command - all on one line])
1167 AT_KEYWORDS([segment])
1168 AT_DATA([input], [dnl
1169 define !macro1()var1 var2 var3!enddefine.
1170 ])
1171 AT_DATA([expout-base], [dnl
1172 identifier      define    space
1173 macro_id        !macro1
1174 punct           (
1175 punct           )
1176 macro_body      var1_var2_var3
1177 macro_id        !enddefine
1178 end_command     .
1179 -newline         \n (first)
1180 -
1181 end
1182 ])
1183 PSPP_CHECK_SEGMENT([-i])
1184 AT_CLEANUP
1185 \f
1186 AT_SETUP([DEFINE command - empty])
1187 AT_KEYWORDS([segment])
1188 AT_DATA([input], [dnl
1189 define !macro1()
1190 !enddefine.
1191 ])
1192 AT_DATA([expout-base], [dnl
1193 identifier      define    space
1194 macro_id        !macro1
1195 punct           (
1196 punct           )
1197 spaces
1198 newline         \n (DEFINE)
1199
1200 macro_id        !enddefine
1201 end_command     .
1202 -newline         \n (first)
1203 -
1204 end
1205 ])
1206 PSPP_CHECK_SEGMENT([-i])
1207 AT_CLEANUP
1208 \f
1209 AT_SETUP([DEFINE command - blank lines])
1210 AT_KEYWORDS([segment])
1211 AT_DATA([input], [dnl
1212 define !macro1()
1213
1214
1215 !enddefine.
1216 ])
1217 AT_DATA([expout-base], [dnl
1218 identifier      define    space
1219 macro_id        !macro1
1220 punct           (
1221 punct           )
1222 spaces
1223 newline         \n (DEFINE)
1224
1225 macro_body
1226 newline         \n (DEFINE)
1227
1228 macro_body
1229 newline         \n (DEFINE)
1230
1231 macro_id        !enddefine
1232 end_command     .
1233 -newline         \n (first)
1234 -
1235 end
1236 ])
1237 PSPP_CHECK_SEGMENT([-i])
1238 AT_CLEANUP
1239 \f
1240 AT_SETUP([DEFINE command - arguments])
1241 AT_KEYWORDS([segment])
1242 AT_DATA([input], [dnl
1243 define !macro1(a(), b(), c())
1244 !enddefine.
1245 ])
1246 AT_DATA([expout-base], [dnl
1247 identifier      define    space
1248 macro_id        !macro1
1249 punct           (
1250 identifier      a
1251 punct           (
1252 punct           )
1253 punct           ,    space
1254 identifier      b
1255 punct           (
1256 punct           )
1257 punct           ,    space
1258 identifier      c
1259 punct           (
1260 punct           )
1261 punct           )
1262 spaces
1263 newline         \n (DEFINE)
1264
1265 macro_id        !enddefine
1266 end_command     .
1267 -newline         \n (first)
1268 -
1269 end
1270 ])
1271 PSPP_CHECK_SEGMENT([-i])
1272 AT_CLEANUP
1273 \f
1274 AT_SETUP([DEFINE command - multiline arguments])
1275 AT_KEYWORDS([segment])
1276 AT_DATA([input], [dnl
1277 define !macro1(
1278   a(), b(
1279   ),
1280   c()
1281 )
1282 !enddefine.
1283 ])
1284 AT_DATA([expout-base], [dnl
1285 identifier      define    space
1286 macro_id        !macro1
1287 punct           (
1288 newline         \n (later)
1289
1290 spaces          __
1291 identifier      a
1292 punct           (
1293 punct           )
1294 punct           ,    space
1295 identifier      b
1296 punct           (
1297 newline         \n (later)
1298
1299 spaces          __
1300 punct           )
1301 punct           ,
1302 newline         \n (later)
1303
1304 spaces          __
1305 identifier      c
1306 punct           (
1307 punct           )
1308 newline         \n (later)
1309
1310 punct           )
1311 spaces
1312 newline         \n (DEFINE)
1313
1314 macro_id        !enddefine
1315 end_command     .
1316 -newline         \n (first)
1317 -
1318 end
1319 ])
1320 PSPP_CHECK_SEGMENT([-i])
1321 AT_CLEANUP
1322 \f
1323 AT_SETUP([DEFINE command - arguments start on second line])
1324 AT_KEYWORDS([segment])
1325 AT_DATA([input], [dnl
1326 define !macro1
1327 (x,y,z
1328 )
1329 content 1
1330 content 2
1331 !enddefine.
1332 ])
1333 AT_DATA([expout-base], [dnl
1334 identifier      define    space
1335 macro_id        !macro1
1336 newline         \n (later)
1337
1338 punct           (
1339 identifier      x
1340 punct           ,
1341 identifier      y
1342 punct           ,
1343 identifier      z
1344 newline         \n (later)
1345
1346 punct           )
1347 spaces
1348 newline         \n (DEFINE)
1349
1350 macro_body      content_1
1351 newline         \n (DEFINE)
1352
1353 macro_body      content_2
1354 newline         \n (DEFINE)
1355
1356 macro_id        !enddefine
1357 end_command     .
1358 -newline         \n (first)
1359 -
1360 end
1361 ])
1362 PSPP_CHECK_SEGMENT([-i])
1363 AT_CLEANUP
1364 \f
1365 AT_SETUP([DEFINE command - early end of command 1])
1366 AT_KEYWORDS([segment])
1367 AT_DATA([input], [dnl
1368 define !macro1.
1369 data list /x 1.
1370 ])
1371 AT_DATA([expout-base], [dnl
1372 identifier      define    space
1373 macro_id        !macro1
1374 end_command     .
1375 newline         \n (first)
1376
1377 identifier      data    space
1378 identifier      list    space
1379 punct           /
1380 identifier      x    space
1381 number          1
1382 end_command     .
1383 -newline         \n (first)
1384 -
1385 end
1386 ])
1387 PSPP_CHECK_SEGMENT([-i])
1388 AT_CLEANUP
1389 \f
1390 AT_SETUP([DEFINE command - early end of command 2])
1391 AT_KEYWORDS([segment])
1392 AT_DATA([input], [dnl
1393 define !macro1
1394 x.
1395 data list /x 1.
1396 ])
1397 AT_DATA([expout-base], [dnl
1398 identifier      define    space
1399 macro_id        !macro1
1400 newline         \n (later)
1401
1402 identifier      x
1403 end_command     .
1404 newline         \n (first)
1405
1406 identifier      data    space
1407 identifier      list    space
1408 punct           /
1409 identifier      x    space
1410 number          1
1411 end_command     .
1412 -newline         \n (first)
1413 -
1414 end
1415 ])
1416 PSPP_CHECK_SEGMENT([-i])
1417 AT_CLEANUP
1418 \f
1419 AT_SETUP([DEFINE command - early end of command 3])
1420 AT_KEYWORDS([segment])
1421 AT_DATA([input], [dnl
1422 define !macro1(.
1423 x.
1424 data list /x 1.
1425 ])
1426 AT_DATA([expout-base], [dnl
1427 identifier      define    space
1428 macro_id        !macro1
1429 punct           (
1430 end_command     .
1431 newline         \n (first)
1432
1433 identifier      x
1434 end_command     .
1435 newline         \n (first)
1436
1437 identifier      data    space
1438 identifier      list    space
1439 punct           /
1440 identifier      x    space
1441 number          1
1442 end_command     .
1443 -newline         \n (first)
1444 -
1445 end
1446 ])
1447 PSPP_CHECK_SEGMENT([-i])
1448 AT_CLEANUP
1449 \f
1450 AT_SETUP([DEFINE command - early end of command 4])
1451 AT_KEYWORDS([segment])
1452 AT_DATA([input], [dnl
1453 dnl Notice the command terminator at the end of the DEFINE command,
1454 dnl which should not be there and ends it early.
1455 define !macro1.
1456 data list /x 1.
1457 ])
1458 AT_DATA([expout-base], [dnl
1459 identifier      define    space
1460 macro_id        !macro1
1461 end_command     .
1462 newline         \n (first)
1463
1464 identifier      data    space
1465 identifier      list    space
1466 punct           /
1467 identifier      x    space
1468 number          1
1469 end_command     .
1470 -newline         \n (first)
1471 -
1472 end
1473 ])
1474 PSPP_CHECK_SEGMENT([-i])
1475 AT_CLEANUP
1476 \f
1477 AT_SETUP([DEFINE command - missing !ENDDEFINE])
1478 AT_KEYWORDS([segment])
1479 AT_DATA([input], [dnl
1480 define !macro1()
1481 content line 1
1482 content line 2
1483 ])
1484 AT_DATA([expout-base], [dnl
1485 identifier      define    space
1486 macro_id        !macro1
1487 punct           (
1488 punct           )
1489 spaces
1490 newline         \n (DEFINE)
1491
1492 macro_body      content_line_1
1493 newline         \n (DEFINE)
1494
1495 macro_body      content_line_2
1496 -newline         \n (DEFINE)
1497 -
1498 end
1499 ])
1500 PSPP_CHECK_SEGMENT([-i])
1501 AT_CLEANUP
1502 \f
1503 AT_SETUP([batch mode])
1504 AT_KEYWORDS([segment])
1505 AT_DATA([input], [dnl
1506 first command
1507      another line of first command
1508 +  second command
1509 third command
1510
1511 fourth command.
1512    fifth command.
1513 ])
1514 AT_DATA([expout-base], [dnl
1515 identifier      first    space
1516 identifier      command
1517 newline         \n (later)
1518
1519 spaces          _____
1520 identifier      another    space
1521 identifier      line    space
1522 identifier      of    space
1523 identifier      first    space
1524 identifier      command
1525 newline         \n (later)
1526
1527 start_command   +
1528 spaces          __
1529 identifier      second    space
1530 identifier      command
1531 newline         \n (later)
1532
1533 start_command
1534 identifier      third    space
1535 identifier      command
1536 newline         \n (later)
1537
1538 separate_commands
1539 newline         \n (first)
1540
1541 identifier      fourth    space
1542 identifier      command
1543 end_command     .
1544 newline         \n (first)
1545
1546 spaces          ___
1547 identifier      fifth    space
1548 identifier      command
1549 end_command     .
1550 -newline         \n (first)
1551 -
1552 end
1553 ])
1554 PSPP_CHECK_SEGMENT([-b])
1555 AT_CLEANUP
1556 \f
1557 AT_SETUP([auto mode])
1558 AT_KEYWORDS([segment])
1559 AT_DATA([input], [dnl
1560 command
1561      another line of command
1562 2sls
1563 +  another command
1564 another line of second command
1565 data list /x 1
1566 aggregate.
1567 print eject.
1568 twostep cluster
1569
1570
1571 fourth command.
1572    fifth command.
1573 ])
1574 AT_DATA([expout-base], [dnl
1575 identifier      command
1576 newline         \n (later)
1577
1578 spaces          _____
1579 identifier      another    space
1580 identifier      line    space
1581 identifier      of    space
1582 identifier      command
1583 newline         \n (later)
1584
1585 start_command
1586 number          2
1587 identifier      sls
1588 newline         \n (later)
1589
1590 start_command   +
1591 spaces          __
1592 identifier      another    space
1593 identifier      command
1594 newline         \n (later)
1595
1596 identifier      another    space
1597 identifier      line    space
1598 identifier      of    space
1599 identifier      second    space
1600 identifier      command
1601 newline         \n (later)
1602
1603 start_command
1604 identifier      data    space
1605 identifier      list    space
1606 punct           /
1607 identifier      x    space
1608 number          1
1609 newline         \n (later)
1610
1611 start_command
1612 identifier      aggregate
1613 end_command     .
1614 newline         \n (first)
1615
1616 identifier      print    space
1617 identifier      eject
1618 end_command     .
1619 newline         \n (first)
1620
1621 identifier      twostep    space
1622 identifier      cluster
1623 newline         \n (later)
1624
1625 separate_commands
1626 newline         \n (first)
1627
1628 separate_commands
1629 newline         \n (first)
1630
1631 identifier      fourth    space
1632 identifier      command
1633 end_command     .
1634 newline         \n (first)
1635
1636 spaces          ___
1637 identifier      fifth    space
1638 identifier      command
1639 end_command     .
1640 -newline         \n (first)
1641 -
1642 end
1643 ])
1644 PSPP_CHECK_SEGMENT([-a])
1645 AT_CLEANUP