1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
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.
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.
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/>.
17 AT_BANNER([syntax segmentation])
18 m4_define([PSPP_CHECK_SEGMENT],
19 [for strip in "" "-s"; do
21 '') sed 's/^-//' < expout-base > expout ;; # (
22 -s) sed '/^-/d' < expout-base > expout ;;
24 AT_CHECK([segment-test $1 $strip input], [0], [expout])
25 AT_CHECK([segment-test -1 $strip $1 input], [0], [expout])
26 AT_CHECK([segment-test -0 $strip $1 input])
27 AT_CHECK([segment-test -01 $strip $1 input])
30 AT_SETUP([identifiers])
31 AT_KEYWORDS([segment])
37 grève@<00A0>@Ângstrom@<00A0>@poté
39 @efg @ @@. @#@ !@ @&t@
45 AT_DATA([expout-base], [dnl
96 identifier #12345 space
116 PSPP_CHECK_SEGMENT([-i])
119 AT_SETUP([identifiers that end in '.'])
120 AT_KEYWORDS([segment])
121 AT_DATA([input], [dnl
133 QRSTUV./* end of line comment */
134 qrstuv. /* end of line comment */
135 QrStUv./* end of line comment */ @&t@
136 wxyz./* unterminated end of line comment
137 WXYZ. /* unterminated end of line comment
138 WxYz./* unterminated end of line comment @&t@
140 AT_DATA([expout-base], [dnl
141 identifier abcd. space
146 identifier ABCD. space
151 identifier aBcD. space
183 start_command . space
192 comment /*_end_of_line_comment_*/
197 comment /*_end_of_line_comment_*/
202 comment /*_end_of_line_comment_*/ space
207 comment /*_unterminated_end_of_line_comment
212 comment /*_unterminated_end_of_line_comment
217 comment /*_unterminated_end_of_line_comment_
222 PSPP_CHECK_SEGMENT([-i])
225 AT_SETUP([reserved words])
226 AT_KEYWORDS([segment])
227 AT_DATA([input], [dnl
228 and or not eq ge gt le lt ne all by to with
229 AND OR NOT EQ GE GT LE LT NE ALL BY TO WITH
230 andx orx notx eqx gex gtx lex ltx nex allx byx tox withx
233 AT_DATA([expout-base], [dnl
234 reserved_word and space
235 reserved_word or space
236 reserved_word not space
237 reserved_word eq space
238 reserved_word ge space
239 reserved_word gt space
240 reserved_word le space
241 reserved_word lt space
242 reserved_word ne space
243 reserved_word all space
244 reserved_word by space
245 reserved_word to space
249 reserved_word AND space
250 reserved_word OR space
251 reserved_word NOT space
252 reserved_word EQ space
253 reserved_word GE space
254 reserved_word GT space
255 reserved_word LE space
256 reserved_word LT space
257 reserved_word NE space
258 reserved_word ALL space
259 reserved_word BY space
260 reserved_word TO space
264 identifier andx space
266 identifier notx space
273 identifier allx space
279 identifier and. space
286 PSPP_CHECK_SEGMENT([-i])
289 AT_SETUP([punctuation])
290 AT_KEYWORDS([segment])
291 AT_DATA([input], [dnl
292 ~ & | = >= > <= < ~= <> ( ) , - + * / [[ ]] **
293 ~&|=>=><=<~=<>(),-+*/[[]]**
296 AT_DATA([expout-base], [dnl
354 PSPP_CHECK_SEGMENT([-i])
358 AT_KEYWORDS([segment])
359 AT_DATA([input], [dnl
361 123. /* comment 1 */ /* comment 2 */
363 5e1 6E-1 7e+1 6E+01 6e-03
364 .3E1 .4e-1 .5E+1 .6e+01 .7E-03
365 1.23e1 45.6E-1 78.9e+1 99.9E+01 11.2e-03
368 AT_DATA([expout-base], [dnl
379 comment /*_comment_1_*/ space
380 comment /*_comment_2_*/
408 number 99.9E+01 space
412 start_command . space
413 expected_exponent 1e space
415 expected_exponent 1e+ space
416 expected_exponent 1e- space
423 PSPP_CHECK_SEGMENT([-i])
427 AT_KEYWORDS([segment])
428 AT_DATA([input], [dnl
430 'Don''t' "Can't" 'Won''t'
431 """quoted""" '"quoted"'
434 "missing double quote
438 + /* comment */ 'string continuation'
439 + /* also a punctuator on blank line
442 AT_DATA([expout-base], [dnl
443 quoted_string 'x' space
444 quoted_string "y" space
448 quoted_string 'Don''t' space
449 quoted_string "Can't" space
450 quoted_string 'Won''t'
453 quoted_string """quoted""" space
454 quoted_string '"quoted"'
457 quoted_string '' space
461 expected_quote 'missing_end_quote
464 expected_quote "missing_double_quote
467 hex_string x"4142" space
471 unicode_string u'fffd' space
472 unicode_string U"041"
475 start_command + space
481 comment /*_comment_*/ space
482 quoted_string 'string_continuation'
486 comment /*_also_a_punctuator_on_blank_line
489 start_command - space
490 quoted_string 'new_command'
495 PSPP_CHECK_SEGMENT([-i])
498 AT_SETUP([@%:@! construct])
499 AT_KEYWORDS([segment])
500 AT_DATA([input], [dnl
505 AT_DATA([expout-base], [dnl
506 shbang #!_/usr/bin/pspp
509 identifier title space
510 unquoted_string my_title
526 PSPP_CHECK_SEGMENT([-i])
529 AT_SETUP([* and COMMENT commands])
530 AT_KEYWORDS([segment])
531 AT_DATA([input], [dnl
532 * Comment commands "don't
533 have to contain valid tokens.
535 ** Check ambiguity with ** token.
538 comment keyword works too.
540 com is ambiguous with COMPUTE.
542 * Comment need not start at left margin.
544 * Comment ends with blank line
549 AT_DATA([expout-base], [dnl
550 comment_command *_Comment_commands_"don't
553 comment_command have_to_contain_valid_tokens
560 comment_command **_Check_ambiguity_with_**_token
564 comment_command ****************
571 comment_command comment_keyword_works_too
575 comment_command COMM_also
581 identifier ambiguous space
582 reserved_word with space
591 comment_command *_Comment_need_not_start_at_left_margin
598 comment_command *_Comment_ends_with_blank_line
604 identifier next space
614 PSPP_CHECK_SEGMENT([-i])
617 AT_SETUP([DOCUMENT command])
618 AT_KEYWORDS([segment])
619 AT_DATA([input], [dnl
627 isn't parsed as tokens
631 AT_DATA([expout-base], [dnl
633 document DOCUMENT_one_line.
640 newline \n (DOCUMENT)
643 newline \n (DOCUMENT)
646 newline \n (DOCUMENT)
648 document ____________line.
655 newline \n (DOCUMENT)
657 document first.paragraph
658 newline \n (DOCUMENT)
660 document isn't_parsed_as_tokens
661 newline \n (DOCUMENT)
664 newline \n (DOCUMENT)
666 document second_paragraph.
673 PSPP_CHECK_SEGMENT([-i])
676 AT_SETUP([TITLE, SUBTITLE, FILE LABEL commands])
677 AT_KEYWORDS([segment])
678 AT_DATA([input], [dnl
679 title/**/'Quoted string title'.
681 "Quoted string on second line".
682 sub "Quoted string subtitle"
685 TITL /* Not a */ quoted string title.
686 SUBT Not a quoted string /* subtitle
688 FIL label isn't quoted.
692 /**/ lab not quoted here either
695 AT_DATA([expout-base], [dnl
698 quoted_string 'Quoted_string_title'
706 quoted_string "Quoted_string_on_second_line"
711 quoted_string "Quoted_string_subtitle"
720 identifier TITL space
721 unquoted_string /*_Not_a_*/_quoted_string_title
725 identifier SUBT space
726 unquoted_string Not_a_quoted_string_/*_subtitle
733 identifier label space
734 unquoted_string isn't_quoted
743 quoted_string 'is_quoted'
747 identifier FILE space
754 unquoted_string not_quoted_here_either
762 PSPP_CHECK_SEGMENT([-i])
765 AT_SETUP([BEGIN DATA command])
766 AT_KEYWORDS([segment])
767 AT_DATA([input], [dnl
792 AT_DATA([expout-base], [dnl
793 identifier begin space
806 identifier begin space
832 inline_data 5_6_7_/*_x
838 inline_data end__data
869 identifier begin space
870 identifier data space
875 identifier begin space
876 identifier data space
881 reserved_word not space
887 PSPP_CHECK_SEGMENT([-i])
890 AT_SETUP([DO REPEAT command])
891 AT_KEYWORDS([segment])
892 AT_DATA([input], [dnl
895 do repeat a=1 thru 5.
899 end /* x */ /* y */ repeat print.
907 AT_DATA([expout-base], [dnl
909 identifier repeat space
924 newline \n (DO REPEAT)
926 do_repeat_command __do_repeat_a=1_thru_5.
927 newline \n (DO REPEAT)
929 do_repeat_command another_command.
930 newline \n (DO REPEAT)
932 do_repeat_command second_command
933 newline \n (DO REPEAT)
935 do_repeat_command +_third_command.
936 newline \n (DO REPEAT)
938 do_repeat_command end_/*_x_*/_/*_y_*/_repeat_print.
939 newline \n (DO REPEAT)
952 identifier repeat space
957 newline \n (DO REPEAT)
959 do_repeat_command __inner_command.
960 newline \n (DO REPEAT)
969 PSPP_CHECK_SEGMENT([-i])
972 AT_SETUP([DO REPEAT command in batch mode])
973 AT_KEYWORDS([segment])
974 AT_DATA([input], [dnl
981 end /* x */ /* y */ repeat print
990 AT_DATA([expout-base], [dnl
992 identifier repeat space
1009 do_repeat_command do_repeat_a=1_thru_5
1010 newline \n (DO REPEAT)
1012 do_repeat_command another_command
1013 newline \n (DO REPEAT)
1015 do_repeat_command second_command
1016 newline \n (DO REPEAT)
1018 do_repeat_command +_third_command
1019 newline \n (DO REPEAT)
1021 do_repeat_command end_/*_x_*/_/*_y_*/_repeat_print
1022 newline \n (DO REPEAT)
1035 identifier repeat space
1042 newline \n (DO REPEAT)
1044 do_repeat_command __inner_command
1045 newline \n (DO REPEAT)
1047 identifier end space
1053 PSPP_CHECK_SEGMENT([-b])
1056 AT_SETUP([batch mode])
1057 AT_KEYWORDS([segment])
1058 AT_DATA([input], [dnl
1060 another line of first command
1067 AT_DATA([expout-base], [dnl
1068 identifier first space
1073 identifier another space
1074 identifier line space
1076 identifier first space
1082 identifier second space
1087 identifier third space
1094 identifier fourth space
1100 identifier fifth space
1107 PSPP_CHECK_SEGMENT([-b])
1110 AT_SETUP([auto mode])
1111 AT_KEYWORDS([segment])
1112 AT_DATA([input], [dnl
1114 another line of command
1117 another line of second command
1127 AT_DATA([expout-base], [dnl
1132 identifier another space
1133 identifier line space
1145 identifier another space
1149 identifier another space
1150 identifier line space
1152 identifier second space
1157 identifier data space
1158 identifier list space
1165 identifier aggregate
1169 identifier print space
1174 identifier twostep space
1184 identifier fourth space
1190 identifier fifth space
1197 PSPP_CHECK_SEGMENT([-a])