segment-test: Make debugging easier for some kinds of test failures.
[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 newline         \n (later)
341
342 punct           %    space
343 punct           :    space
344 punct           ;    space
345 punct           ?    space
346 punct           \_    space
347 punct           `    space
348 punct           {    space
349 punct           }    space
350 punct           ~
351 -newline         \n (later)
352 -
353 end
354 ])
355 PSPP_CHECK_SEGMENT([-i])
356 AT_CLEANUP
357 \f
358 AT_SETUP([numbers])
359 AT_KEYWORDS([segment])
360 AT_DATA([input], [dnl
361 0 1 01 001. 1.
362 123. /* comment 1 */ /* comment 2 */
363 .1 0.1 00.1 00.10
364 5e1 6E-1 7e+1 6E+01 6e-03
365 .3E1 .4e-1 .5E+1 .6e+01 .7E-03
366 1.23e1 45.6E-1 78.9e+1 99.9E+01 11.2e-03
367 . 1e e1 1e+ 1e- 1.
368 ])
369 AT_DATA([expout-base], [dnl
370 number          0    space
371 number          1    space
372 number          01    space
373 number          001.    space
374 number          1
375 end_command     .
376 newline         \n (first)
377
378 number          123
379 end_command     .    space
380 comment         /*_comment_1_*/    space
381 comment         /*_comment_2_*/
382 newline         \n (first)
383
384 start_command   .
385 number          1    space
386 number          0.1    space
387 number          00.1    space
388 number          00.10
389 newline         \n (later)
390
391 number          5e1    space
392 number          6E-1    space
393 number          7e+1    space
394 number          6E+01    space
395 number          6e-03
396 newline         \n (later)
397
398 start_command   .
399 number          3E1    space
400 number          .4e-1    space
401 number          .5E+1    space
402 number          .6e+01    space
403 number          .7E-03
404 newline         \n (later)
405
406 number          1.23e1    space
407 number          45.6E-1    space
408 number          78.9e+1    space
409 number          99.9E+01    space
410 number          11.2e-03
411 newline         \n (later)
412
413 start_command   .    space
414 expected_exponent 1e    space
415 identifier      e1    space
416 expected_exponent 1e+    space
417 expected_exponent 1e-    space
418 number          1
419 end_command     .
420 -newline         \n (first)
421 -
422 end
423 ])
424 PSPP_CHECK_SEGMENT([-i])
425 AT_CLEANUP
426 \f
427 AT_SETUP([strings])
428 AT_KEYWORDS([segment])
429 AT_DATA([input], [dnl
430 'x' "y" 'abc'
431 'Don''t' "Can't" 'Won''t'
432 """quoted""" '"quoted"'
433 '' ""
434 'missing end quote
435 "missing double quote
436 x"4142" X'5152'
437 u'fffd' U"041"
438 + new command
439 + /* comment */ 'string continuation'
440 + /* also a punctuator on blank line
441 - 'new command'
442 ])
443 AT_DATA([expout-base], [dnl
444 quoted_string   'x'    space
445 quoted_string   "y"    space
446 quoted_string   'abc'
447 newline         \n (later)
448
449 quoted_string   'Don''t'    space
450 quoted_string   "Can't"    space
451 quoted_string   'Won''t'
452 newline         \n (later)
453
454 quoted_string   """quoted"""    space
455 quoted_string   '"quoted"'
456 newline         \n (later)
457
458 quoted_string   ''    space
459 quoted_string   ""
460 newline         \n (later)
461
462 expected_quote  'missing_end_quote
463 newline         \n (later)
464
465 expected_quote  "missing_double_quote
466 newline         \n (later)
467
468 hex_string      x"4142"    space
469 hex_string      X'5152'
470 newline         \n (later)
471
472 unicode_string  u'fffd'    space
473 unicode_string  U"041"
474 newline         \n (later)
475
476 start_command   +    space
477 identifier      new    space
478 identifier      command
479 newline         \n (later)
480
481 punct           +    space
482 comment         /*_comment_*/    space
483 quoted_string   'string_continuation'
484 newline         \n (later)
485
486 punct           +    space
487 comment         /*_also_a_punctuator_on_blank_line
488 newline         \n (later)
489
490 start_command   -    space
491 quoted_string   'new_command'
492 -newline         \n (later)
493 -
494 end
495 ])
496 PSPP_CHECK_SEGMENT([-i])
497 AT_CLEANUP
498 \f
499 AT_SETUP([@%:@! construct])
500 AT_KEYWORDS([segment])
501 AT_DATA([input], [dnl
502 #! /usr/bin/pspp
503 title my title.
504 #! /usr/bin/pspp
505 ])
506 AT_DATA([expout-base], [dnl
507 shbang          #!_/usr/bin/pspp
508 newline         \n (first)
509
510 identifier      title    space
511 unquoted_string my_title
512 end_command     .
513 newline         \n (first)
514
515 identifier      #
516 macro_id        !    space
517 punct           /
518 identifier      usr
519 punct           /
520 identifier      bin
521 punct           /
522 identifier      pspp
523 -newline         \n (later)
524 -
525 end
526 ])
527 PSPP_CHECK_SEGMENT([-i])
528 AT_CLEANUP
529 \f
530 AT_SETUP([* and COMMENT commands])
531 AT_KEYWORDS([segment])
532 AT_DATA([input], [dnl
533 * Comment commands "don't
534 have to contain valid tokens.
535
536 ** Check ambiguity with ** token.
537 ****************.
538
539 comment keyword works too.
540 COMM also.
541 com is ambiguous with COMPUTE.
542
543    * Comment need not start at left margin.
544
545 * Comment ends with blank line
546
547 next command.
548
549 ])
550 AT_DATA([expout-base], [dnl
551 comment_command *_Comment_commands_"don't
552 newline         \n (COMMENT)
553
554 comment_command have_to_contain_valid_tokens
555 end_command     .
556 newline         \n (first)
557
558 separate_commands
559 newline         \n (first)
560
561 comment_command **_Check_ambiguity_with_**_token
562 end_command     .
563 newline         \n (first)
564
565 comment_command ****************
566 end_command     .
567 newline         \n (first)
568
569 separate_commands
570 newline         \n (first)
571
572 comment_command comment_keyword_works_too
573 end_command     .
574 newline         \n (first)
575
576 comment_command COMM_also
577 end_command     .
578 newline         \n (first)
579
580 identifier      com    space
581 identifier      is    space
582 identifier      ambiguous    space
583 reserved_word   with    space
584 identifier      COMPUTE
585 end_command     .
586 newline         \n (first)
587
588 separate_commands
589 newline         \n (first)
590
591 spaces          ___
592 comment_command *_Comment_need_not_start_at_left_margin
593 end_command     .
594 newline         \n (first)
595
596 separate_commands
597 newline         \n (first)
598
599 comment_command *_Comment_ends_with_blank_line
600 newline         \n (COMMENT)
601
602 separate_commands
603 newline         \n (first)
604
605 identifier      next    space
606 identifier      command
607 end_command     .
608 newline         \n (first)
609
610 -separate_commands
611 -newline         \n (first)
612 -
613 end
614 ])
615 PSPP_CHECK_SEGMENT([-i])
616 AT_CLEANUP
617 \f
618 AT_SETUP([DOCUMENT command])
619 AT_KEYWORDS([segment])
620 AT_DATA([input], [dnl
621 DOCUMENT one line.
622 DOC more
623     than
624         one
625             line.
626 docu
627 first.paragraph
628 isn't parsed as tokens
629
630 second paragraph.
631 ])
632 AT_DATA([expout-base], [dnl
633 start_document
634 document        DOCUMENT_one_line.
635 end_command
636 separate_commands
637 newline         \n (first)
638
639 start_document
640 document        DOC_more
641 newline         \n (DOCUMENT)
642
643 document        ____than
644 newline         \n (DOCUMENT)
645
646 document        ________one
647 newline         \n (DOCUMENT)
648
649 document        ____________line.
650 end_command
651 separate_commands
652 newline         \n (first)
653
654 start_document
655 document        docu
656 newline         \n (DOCUMENT)
657
658 document        first.paragraph
659 newline         \n (DOCUMENT)
660
661 document        isn't_parsed_as_tokens
662 newline         \n (DOCUMENT)
663
664 document
665 newline         \n (DOCUMENT)
666
667 document        second_paragraph.
668 -end_command
669 -separate_commands
670 -newline         \n (first)
671 -
672 end
673 ])
674 PSPP_CHECK_SEGMENT([-i])
675 AT_CLEANUP
676 \f
677 AT_SETUP([TITLE, SUBTITLE, FILE LABEL commands])
678 AT_KEYWORDS([segment])
679 AT_DATA([input], [dnl
680 title/**/'Quoted string title'.
681 tit /*
682 "Quoted string on second line".
683 sub "Quoted string subtitle"
684  .
685
686 TITL /* Not a */ quoted string title.
687 SUBT Not a quoted string /* subtitle
688
689 FIL label isn't quoted.
690 FILE
691   lab 'is quoted'.
692 FILE /*
693 /**/  lab not quoted here either
694
695 ])
696 AT_DATA([expout-base], [dnl
697 identifier      title
698 comment         /**/
699 quoted_string   'Quoted_string_title'
700 end_command     .
701 newline         \n (first)
702
703 identifier      tit    space
704 comment         /*
705 newline         \n (later)
706
707 quoted_string   "Quoted_string_on_second_line"
708 end_command     .
709 newline         \n (first)
710
711 identifier      sub    space
712 quoted_string   "Quoted_string_subtitle"
713 newline         \n (later)
714     space
715 end_command     .
716 newline         \n (first)
717
718 separate_commands
719 newline         \n (first)
720
721 identifier      TITL    space
722 unquoted_string /*_Not_a_*/_quoted_string_title
723 end_command     .
724 newline         \n (first)
725
726 identifier      SUBT    space
727 unquoted_string Not_a_quoted_string_/*_subtitle
728 newline         \n (later)
729
730 separate_commands
731 newline         \n (first)
732
733 identifier      FIL    space
734 identifier      label    space
735 unquoted_string isn't_quoted
736 end_command     .
737 newline         \n (first)
738
739 identifier      FILE
740 newline         \n (later)
741
742 spaces          __
743 identifier      lab    space
744 quoted_string   'is_quoted'
745 end_command     .
746 newline         \n (first)
747
748 identifier      FILE    space
749 comment         /*
750 newline         \n (later)
751
752 comment         /**/
753 spaces          __
754 identifier      lab    space
755 unquoted_string not_quoted_here_either
756 newline         \n (later)
757
758 -separate_commands
759 -newline         \n (first)
760 -
761 end
762 ])
763 PSPP_CHECK_SEGMENT([-i])
764 AT_CLEANUP
765 \f
766 AT_SETUP([BEGIN DATA command])
767 AT_KEYWORDS([segment])
768 AT_DATA([input], [dnl
769 begin data.
770 end data.
771
772 begin data. /*
773 123
774 xxx
775 end data.
776
777 BEG /**/ DAT /*
778 5 6 7 /* x
779
780 end  data
781 end data
782 .
783
784 begin
785  data.
786 data
787 end data.
788
789 begin data "xxx".
790 begin data 123.
791 not data
792 ])
793 AT_DATA([expout-base], [dnl
794 identifier      begin    space
795 identifier      data
796 end_command     .
797 newline         \n (data)
798
799 identifier      end    space
800 identifier      data
801 end_command     .
802 newline         \n (first)
803
804 separate_commands
805 newline         \n (first)
806
807 identifier      begin    space
808 identifier      data
809 end_command     .    space
810 comment         /*
811 newline         \n (data)
812
813 inline_data     123
814 newline         \n (data)
815
816 inline_data     xxx
817 newline         \n (data)
818
819 identifier      end    space
820 identifier      data
821 end_command     .
822 newline         \n (first)
823
824 separate_commands
825 newline         \n (first)
826
827 identifier      BEG    space
828 comment         /**/    space
829 identifier      DAT    space
830 comment         /*
831 newline         \n (data)
832
833 inline_data     5_6_7_/*_x
834 newline         \n (data)
835
836 inline_data
837 newline         \n (data)
838
839 inline_data     end__data
840 newline         \n (data)
841
842 identifier      end    space
843 identifier      data
844 newline         \n (later)
845
846 start_command   .
847 newline         \n (first)
848
849 separate_commands
850 newline         \n (first)
851
852 identifier      begin
853 newline         \n (later)
854     space
855 identifier      data
856 end_command     .
857 newline         \n (data)
858
859 inline_data     data
860 newline         \n (data)
861
862 identifier      end    space
863 identifier      data
864 end_command     .
865 newline         \n (first)
866
867 separate_commands
868 newline         \n (first)
869
870 identifier      begin    space
871 identifier      data    space
872 quoted_string   "xxx"
873 end_command     .
874 newline         \n (first)
875
876 identifier      begin    space
877 identifier      data    space
878 number          123
879 end_command     .
880 newline         \n (first)
881
882 reserved_word   not    space
883 identifier      data
884 -newline         \n (later)
885 -
886 end
887 ])
888 PSPP_CHECK_SEGMENT([-i])
889 AT_CLEANUP
890 \f
891 AT_SETUP([DO REPEAT command])
892 AT_KEYWORDS([segment])
893 AT_DATA([input], [dnl
894 do repeat x=a b c
895           y=d e f.
896   do repeat a=1 thru 5.
897 another command.
898 second command
899 + third command.
900 end /* x */ /* y */ repeat print.
901 end
902  repeat.
903 do
904   repeat #a=1.
905   inner command.
906 end repeat.
907 ])
908 AT_DATA([expout-base], [dnl
909 identifier      do    space
910 identifier      repeat    space
911 identifier      x
912 punct           =
913 identifier      a    space
914 identifier      b    space
915 identifier      c
916 newline         \n (later)
917
918 spaces          __________
919 identifier      y
920 punct           =
921 identifier      d    space
922 identifier      e    space
923 identifier      f
924 end_command     .
925 newline         \n (DO REPEAT)
926
927 do_repeat_command __do_repeat_a=1_thru_5.
928 newline         \n (DO REPEAT)
929
930 do_repeat_command another_command.
931 newline         \n (DO REPEAT)
932
933 do_repeat_command second_command
934 newline         \n (DO REPEAT)
935
936 do_repeat_command +_third_command.
937 newline         \n (DO REPEAT)
938
939 do_repeat_command end_/*_x_*/_/*_y_*/_repeat_print.
940 newline         \n (DO REPEAT)
941
942 identifier      end
943 newline         \n (later)
944     space
945 identifier      repeat
946 end_command     .
947 newline         \n (first)
948
949 identifier      do
950 newline         \n (later)
951
952 spaces          __
953 identifier      repeat    space
954 identifier      #a
955 punct           =
956 number          1
957 end_command     .
958 newline         \n (DO REPEAT)
959
960 do_repeat_command __inner_command.
961 newline         \n (DO REPEAT)
962
963 identifier      end    space
964 identifier      repeat
965 end_command     .
966 -newline         \n (first)
967 -
968 end
969 ])
970 PSPP_CHECK_SEGMENT([-i])
971 AT_CLEANUP
972 \f
973 AT_SETUP([DO REPEAT command in batch mode])
974 AT_KEYWORDS([segment])
975 AT_DATA([input], [dnl
976 do repeat x=a b c
977           y=d e f
978 do repeat a=1 thru 5
979 another command
980 second command
981 + third command
982 end /* x */ /* y */ repeat print
983 end
984  repeat
985 do
986   repeat #a=1
987
988   inner command
989 end repeat
990 ])
991 AT_DATA([expout-base], [dnl
992 identifier      do    space
993 identifier      repeat    space
994 identifier      x
995 punct           =
996 identifier      a    space
997 identifier      b    space
998 identifier      c
999 newline         \n (later)
1000
1001 spaces          __________
1002 identifier      y
1003 punct           =
1004 identifier      d    space
1005 identifier      e    space
1006 identifier      f
1007 newline         \n (later)
1008
1009 start_command
1010 do_repeat_command do_repeat_a=1_thru_5
1011 newline         \n (DO REPEAT)
1012
1013 do_repeat_command another_command
1014 newline         \n (DO REPEAT)
1015
1016 do_repeat_command second_command
1017 newline         \n (DO REPEAT)
1018
1019 do_repeat_command +_third_command
1020 newline         \n (DO REPEAT)
1021
1022 do_repeat_command end_/*_x_*/_/*_y_*/_repeat_print
1023 newline         \n (DO REPEAT)
1024
1025 identifier      end
1026 newline         \n (later)
1027     space
1028 identifier      repeat
1029 newline         \n (later)
1030
1031 start_command
1032 identifier      do
1033 newline         \n (later)
1034
1035 spaces          __
1036 identifier      repeat    space
1037 identifier      #a
1038 punct           =
1039 number          1
1040 newline         \n (later)
1041
1042 separate_commands
1043 newline         \n (DO REPEAT)
1044
1045 do_repeat_command __inner_command
1046 newline         \n (DO REPEAT)
1047
1048 identifier      end    space
1049 identifier      repeat
1050 -newline         \n (later)
1051 -
1052 end
1053 ])
1054 PSPP_CHECK_SEGMENT([-b])
1055 AT_CLEANUP
1056 \f
1057 AT_SETUP([DEFINE command - simple])
1058 AT_KEYWORDS([segment])
1059 AT_DATA([input], [dnl
1060 define !macro1()
1061 var1 var2 var3
1062 !enddefine.
1063 ])
1064 AT_DATA([expout-base], [dnl
1065 identifier      define    space
1066 macro_id        !macro1
1067 punct           (
1068 punct           )
1069 newline         \n (DEFINE)
1070
1071 macro_body      var1_var2_var3
1072 newline         \n (DEFINE)
1073
1074 macro_id        !enddefine
1075 end_command     .
1076 -newline         \n (first)
1077 -
1078 end
1079 ])
1080 PSPP_CHECK_SEGMENT([-i])
1081 AT_CLEANUP
1082 \f
1083 AT_SETUP([DEFINE command - empty])
1084 AT_KEYWORDS([segment])
1085 AT_DATA([input], [dnl
1086 define !macro1()
1087 !enddefine.
1088 ])
1089 AT_DATA([expout-base], [dnl
1090 identifier      define    space
1091 macro_id        !macro1
1092 punct           (
1093 punct           )
1094 newline         \n (DEFINE)
1095
1096 macro_id        !enddefine
1097 end_command     .
1098 -newline         \n (first)
1099 -
1100 end
1101 ])
1102 PSPP_CHECK_SEGMENT([-i])
1103 AT_CLEANUP
1104 \f
1105 AT_SETUP([DEFINE command - arguments])
1106 AT_KEYWORDS([segment])
1107 AT_DATA([input], [dnl
1108 define !macro1(a(), b(), c())
1109 !enddefine.
1110 ])
1111 AT_DATA([expout-base], [dnl
1112 identifier      define    space
1113 macro_id        !macro1
1114 punct           (
1115 identifier      a
1116 punct           (
1117 punct           )
1118 punct           ,    space
1119 identifier      b
1120 punct           (
1121 punct           )
1122 punct           ,    space
1123 identifier      c
1124 punct           (
1125 punct           )
1126 punct           )
1127 newline         \n (DEFINE)
1128
1129 macro_id        !enddefine
1130 end_command     .
1131 -newline         \n (first)
1132 -
1133 end
1134 ])
1135 PSPP_CHECK_SEGMENT([-i])
1136 AT_CLEANUP
1137 \f
1138 AT_SETUP([DEFINE command - multiline arguments])
1139 AT_KEYWORDS([segment])
1140 AT_DATA([input], [dnl
1141 define !macro1(
1142   a(), b(
1143   ),
1144   c()
1145 )
1146 !enddefine.
1147 ])
1148 AT_DATA([expout-base], [dnl
1149 identifier      define    space
1150 macro_id        !macro1
1151 punct           (
1152 newline         \n (later)
1153
1154 spaces          __
1155 identifier      a
1156 punct           (
1157 punct           )
1158 punct           ,    space
1159 identifier      b
1160 punct           (
1161 newline         \n (later)
1162
1163 spaces          __
1164 punct           )
1165 punct           ,
1166 newline         \n (later)
1167
1168 spaces          __
1169 identifier      c
1170 punct           (
1171 punct           )
1172 newline         \n (later)
1173
1174 punct           )
1175 newline         \n (DEFINE)
1176
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 - arguments start on second line])
1187 AT_KEYWORDS([segment])
1188 AT_DATA([input], [dnl
1189 define !macro1
1190 (x,y,z
1191 )
1192 content 1
1193 content 2
1194 !enddefine.
1195 ])
1196 AT_DATA([expout-base], [dnl
1197 identifier      define    space
1198 macro_id        !macro1
1199 newline         \n (later)
1200
1201 punct           (
1202 identifier      x
1203 punct           ,
1204 identifier      y
1205 punct           ,
1206 identifier      z
1207 newline         \n (later)
1208
1209 punct           )
1210 newline         \n (DEFINE)
1211
1212 macro_body      content_1
1213 newline         \n (DEFINE)
1214
1215 macro_body      content_2
1216 newline         \n (DEFINE)
1217
1218 macro_id        !enddefine
1219 end_command     .
1220 -newline         \n (first)
1221 -
1222 end
1223 ])
1224 PSPP_CHECK_SEGMENT([-i])
1225 AT_CLEANUP
1226 \f
1227 AT_SETUP([DEFINE command - early end of command 1])
1228 AT_KEYWORDS([segment])
1229 AT_DATA([input], [dnl
1230 define !macro1.
1231 data list /x 1.
1232 ])
1233 AT_DATA([expout-base], [dnl
1234 identifier      define    space
1235 macro_id        !macro1
1236 end_command     .
1237 newline         \n (first)
1238
1239 identifier      data    space
1240 identifier      list    space
1241 punct           /
1242 identifier      x    space
1243 number          1
1244 end_command     .
1245 -newline         \n (first)
1246 -
1247 end
1248 ])
1249 PSPP_CHECK_SEGMENT([-i])
1250 AT_CLEANUP
1251 \f
1252 AT_SETUP([DEFINE command - early end of command 2])
1253 AT_KEYWORDS([segment])
1254 AT_DATA([input], [dnl
1255 define !macro1
1256 x.
1257 data list /x 1.
1258 ])
1259 AT_DATA([expout-base], [dnl
1260 identifier      define    space
1261 macro_id        !macro1
1262 newline         \n (later)
1263
1264 identifier      x
1265 end_command     .
1266 newline         \n (first)
1267
1268 identifier      data    space
1269 identifier      list    space
1270 punct           /
1271 identifier      x    space
1272 number          1
1273 end_command     .
1274 -newline         \n (first)
1275 -
1276 end
1277 ])
1278 PSPP_CHECK_SEGMENT([-i])
1279 AT_CLEANUP
1280 \f
1281 AT_SETUP([DEFINE command - early end of command 3])
1282 AT_KEYWORDS([segment])
1283 AT_DATA([input], [dnl
1284 define !macro1(.
1285 x.
1286 data list /x 1.
1287 ])
1288 AT_DATA([expout-base], [dnl
1289 identifier      define    space
1290 macro_id        !macro1
1291 punct           (
1292 end_command     .
1293 newline         \n (first)
1294
1295 identifier      x
1296 end_command     .
1297 newline         \n (first)
1298
1299 identifier      data    space
1300 identifier      list    space
1301 punct           /
1302 identifier      x    space
1303 number          1
1304 end_command     .
1305 -newline         \n (first)
1306 -
1307 end
1308 ])
1309 PSPP_CHECK_SEGMENT([-i])
1310 AT_CLEANUP
1311 \f
1312 AT_SETUP([DEFINE command - early end of command 4])
1313 AT_KEYWORDS([segment])
1314 AT_DATA([input], [dnl
1315 dnl Notice the command terminator at the end of the DEFINE command,
1316 dnl which should not be there and ends it early.
1317 define !macro1.
1318 data list /x 1.
1319 ])
1320 AT_DATA([expout-base], [dnl
1321 identifier      define    space
1322 macro_id        !macro1
1323 end_command     .
1324 newline         \n (first)
1325
1326 identifier      data    space
1327 identifier      list    space
1328 punct           /
1329 identifier      x    space
1330 number          1
1331 end_command     .
1332 -newline         \n (first)
1333 -
1334 end
1335 ])
1336 PSPP_CHECK_SEGMENT([-i])
1337 AT_CLEANUP
1338 \f
1339 AT_SETUP([DEFINE command - missing !ENDDEFINE])
1340 AT_KEYWORDS([segment])
1341 AT_DATA([input], [dnl
1342 define !macro1()
1343 content line 1
1344 content line 2
1345 ])
1346 AT_DATA([expout-base], [dnl
1347 identifier      define    space
1348 macro_id        !macro1
1349 punct           (
1350 punct           )
1351 newline         \n (DEFINE)
1352
1353 macro_body      content_line_1
1354 newline         \n (DEFINE)
1355
1356 macro_body      content_line_2
1357 -newline         \n (DEFINE)
1358 -
1359 end
1360 ])
1361 PSPP_CHECK_SEGMENT([-i])
1362 AT_CLEANUP
1363 \f
1364 AT_SETUP([batch mode])
1365 AT_KEYWORDS([segment])
1366 AT_DATA([input], [dnl
1367 first command
1368      another line of first command
1369 +  second command
1370 third command
1371
1372 fourth command.
1373    fifth command.
1374 ])
1375 AT_DATA([expout-base], [dnl
1376 identifier      first    space
1377 identifier      command
1378 newline         \n (later)
1379
1380 spaces          _____
1381 identifier      another    space
1382 identifier      line    space
1383 identifier      of    space
1384 identifier      first    space
1385 identifier      command
1386 newline         \n (later)
1387
1388 start_command   +
1389 spaces          __
1390 identifier      second    space
1391 identifier      command
1392 newline         \n (later)
1393
1394 start_command
1395 identifier      third    space
1396 identifier      command
1397 newline         \n (later)
1398
1399 separate_commands
1400 newline         \n (first)
1401
1402 identifier      fourth    space
1403 identifier      command
1404 end_command     .
1405 newline         \n (first)
1406
1407 spaces          ___
1408 identifier      fifth    space
1409 identifier      command
1410 end_command     .
1411 -newline         \n (first)
1412 -
1413 end
1414 ])
1415 PSPP_CHECK_SEGMENT([-b])
1416 AT_CLEANUP
1417 \f
1418 AT_SETUP([auto mode])
1419 AT_KEYWORDS([segment])
1420 AT_DATA([input], [dnl
1421 command
1422      another line of command
1423 2sls
1424 +  another command
1425 another line of second command
1426 data list /x 1
1427 aggregate.
1428 print eject.
1429 twostep cluster
1430
1431
1432 fourth command.
1433    fifth command.
1434 ])
1435 AT_DATA([expout-base], [dnl
1436 identifier      command
1437 newline         \n (later)
1438
1439 spaces          _____
1440 identifier      another    space
1441 identifier      line    space
1442 identifier      of    space
1443 identifier      command
1444 newline         \n (later)
1445
1446 start_command
1447 number          2
1448 identifier      sls
1449 newline         \n (later)
1450
1451 start_command   +
1452 spaces          __
1453 identifier      another    space
1454 identifier      command
1455 newline         \n (later)
1456
1457 identifier      another    space
1458 identifier      line    space
1459 identifier      of    space
1460 identifier      second    space
1461 identifier      command
1462 newline         \n (later)
1463
1464 start_command
1465 identifier      data    space
1466 identifier      list    space
1467 punct           /
1468 identifier      x    space
1469 number          1
1470 newline         \n (later)
1471
1472 start_command
1473 identifier      aggregate
1474 end_command     .
1475 newline         \n (first)
1476
1477 identifier      print    space
1478 identifier      eject
1479 end_command     .
1480 newline         \n (first)
1481
1482 identifier      twostep    space
1483 identifier      cluster
1484 newline         \n (later)
1485
1486 separate_commands
1487 newline         \n (first)
1488
1489 separate_commands
1490 newline         \n (first)
1491
1492 identifier      fourth    space
1493 identifier      command
1494 end_command     .
1495 newline         \n (first)
1496
1497 spaces          ___
1498 identifier      fifth    space
1499 identifier      command
1500 end_command     .
1501 -newline         \n (first)
1502 -
1503 end
1504 ])
1505 PSPP_CHECK_SEGMENT([-a])
1506 AT_CLEANUP