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