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 [AT_CHECK([segment-test $1 input], [0], [expout])
20 AT_CHECK([segment-test -1 $1 input], [0], [expout])
21 AT_CHECK([segment-test -0 $1 input])
22 AT_CHECK([segment-test -01 $1 input])])
24 AT_SETUP([identifiers])
25 AT_KEYWORDS([segment])
31 grève@<00A0>@Ângstrom@<00A0>@poté
39 AT_DATA([expout], [dnl
84 identifier #12345 space
104 PSPP_CHECK_SEGMENT([-i])
107 AT_SETUP([identifiers that end in '.'])
108 AT_KEYWORDS([segment])
109 AT_DATA([input], [dnl
121 QRSTUV./* end of line comment */
122 qrstuv. /* end of line comment */
123 QrStUv./* end of line comment */ @&t@
124 wxyz./* unterminated end of line comment
125 WXYZ. /* unterminated end of line comment
126 WxYz./* unterminated end of line comment @&t@
128 AT_DATA([expout], [dnl
129 identifier abcd. space
134 identifier ABCD. space
139 identifier aBcD. space
171 start_command . space
180 comment /*_end_of_line_comment_*/
185 comment /*_end_of_line_comment_*/
190 comment /*_end_of_line_comment_*/ space
195 comment /*_unterminated_end_of_line_comment
200 comment /*_unterminated_end_of_line_comment
205 comment /*_unterminated_end_of_line_comment_
210 PSPP_CHECK_SEGMENT([-i])
213 AT_SETUP([reserved words])
214 AT_KEYWORDS([segment])
215 AT_DATA([input], [dnl
216 and or not eq ge gt le lt ne all by to with
217 AND OR NOT EQ GE GT LE LT NE ALL BY TO WITH
218 andx orx notx eqx gex gtx lex ltx nex allx byx tox withx
221 AT_DATA([expout], [dnl
222 reserved_word and space
223 reserved_word or space
224 reserved_word not space
225 reserved_word eq space
226 reserved_word ge space
227 reserved_word gt space
228 reserved_word le space
229 reserved_word lt space
230 reserved_word ne space
231 reserved_word all space
232 reserved_word by space
233 reserved_word to space
237 reserved_word AND space
238 reserved_word OR space
239 reserved_word NOT space
240 reserved_word EQ space
241 reserved_word GE space
242 reserved_word GT space
243 reserved_word LE space
244 reserved_word LT space
245 reserved_word NE space
246 reserved_word ALL space
247 reserved_word BY space
248 reserved_word TO space
252 identifier andx space
254 identifier notx space
261 identifier allx space
267 identifier and. space
274 PSPP_CHECK_SEGMENT([-i])
277 AT_SETUP([punctuation])
278 AT_KEYWORDS([segment])
279 AT_DATA([input], [dnl
280 ~ & | = >= > <= < ~= <> ( ) , - + * / [[ ]] **
281 ~&|=>=><=<~=<>(),-+*/[[]]**
283 AT_DATA([expout], [dnl
330 PSPP_CHECK_SEGMENT([-i])
334 AT_KEYWORDS([segment])
335 AT_DATA([input], [dnl
337 123. /* comment 1 */ /* comment 2 */
339 5e1 6E-1 7e+1 6E+01 6e-03
340 .3E1 .4e-1 .5E+1 .6e+01 .7E-03
341 1.23e1 45.6E-1 78.9e+1 99.9E+01 11.2e-03
344 AT_DATA([expout], [dnl
355 comment /*_comment_1_*/ space
356 comment /*_comment_2_*/
384 number 99.9E+01 space
388 start_command . space
389 expected_exponent 1e space
391 expected_exponent 1e+ space
392 expected_exponent 1e-
397 PSPP_CHECK_SEGMENT([-i])
401 AT_KEYWORDS([segment])
402 AT_DATA([input], [dnl
404 'Don''t' "Can't" 'Won''t'
405 """quoted""" '"quoted"'
408 "missing double quote
412 + /* comment */ 'string continuation'
413 + /* also a punctuator on blank line
416 AT_DATA([expout], [dnl
417 quoted_string 'x' space
418 quoted_string "y" space
422 quoted_string 'Don''t' space
423 quoted_string "Can't" space
424 quoted_string 'Won''t'
427 quoted_string """quoted""" space
428 quoted_string '"quoted"'
431 quoted_string '' space
435 expected_quote 'missing_end_quote
438 expected_quote "missing_double_quote
441 hex_string x"4142" space
445 unicode_string u'fffd' space
446 unicode_string U"041"
449 start_command + space
455 comment /*_comment_*/ space
456 quoted_string 'string_continuation'
460 comment /*_also_a_punctuator_on_blank_line
463 start_command - space
464 quoted_string 'new_command'
469 PSPP_CHECK_SEGMENT([-i])
472 AT_SETUP([@%:@! construct])
473 AT_KEYWORDS([segment])
474 AT_DATA([input], [dnl
479 AT_DATA([expout], [dnl
480 shbang #!_/usr/bin/pspp
483 identifier title space
484 unquoted_string my_title
489 unexpected_char ! space
500 PSPP_CHECK_SEGMENT([-i])
503 AT_SETUP([* and COMMENT commands])
504 AT_KEYWORDS([segment])
505 AT_DATA([input], [dnl
506 * Comment commands "don't
507 have to contain valid tokens.
509 ** Check ambiguity with ** token.
512 comment keyword works too.
514 com is ambiguous with COMPUTE.
516 * Comment need not start at left margin.
518 * Comment ends with blank line
523 AT_DATA([expout], [dnl
524 comment_command *_Comment_commands_"don't
527 comment_command have_to_contain_valid_tokens
534 comment_command **_Check_ambiguity_with_**_token
538 comment_command ****************
545 comment_command comment_keyword_works_too
549 comment_command COMM_also
555 identifier ambiguous space
556 reserved_word with space
565 comment_command *_Comment_need_not_start_at_left_margin
572 comment_command *_Comment_ends_with_blank_line
578 identifier next space
588 PSPP_CHECK_SEGMENT([-i])
591 AT_SETUP([DOCUMENT command])
592 AT_KEYWORDS([segment])
593 AT_DATA([input], [dnl
601 isn't parsed as tokens
605 AT_DATA([expout], [dnl
607 document DOCUMENT_one_line.
614 newline \n (DOCUMENT)
617 newline \n (DOCUMENT)
620 newline \n (DOCUMENT)
622 document ____________line.
629 newline \n (DOCUMENT)
631 document first.paragraph
632 newline \n (DOCUMENT)
634 document isn't_parsed_as_tokens
635 newline \n (DOCUMENT)
638 newline \n (DOCUMENT)
640 document second_paragraph.
647 PSPP_CHECK_SEGMENT([-i])
650 AT_SETUP([TITLE, SUBTITLE, FILE LABEL commands])
651 AT_KEYWORDS([segment])
652 AT_DATA([input], [dnl
653 title/**/'Quoted string title'.
655 "Quoted string on second line".
656 sub "Quoted string subtitle"
659 TITL /* Not a */ quoted string title.
660 SUBT Not a quoted string /* subtitle
662 FIL label isn't quoted.
666 /**/ lab not quoted here either
669 AT_DATA([expout], [dnl
672 quoted_string 'Quoted_string_title'
680 quoted_string "Quoted_string_on_second_line"
685 quoted_string "Quoted_string_subtitle"
694 identifier TITL space
695 unquoted_string /*_Not_a_*/_quoted_string_title
699 identifier SUBT space
700 unquoted_string Not_a_quoted_string_/*_subtitle
707 identifier label space
708 unquoted_string isn't_quoted
717 quoted_string 'is_quoted'
721 identifier FILE space
728 unquoted_string not_quoted_here_either
736 PSPP_CHECK_SEGMENT([-i])
739 AT_SETUP([BEGIN DATA command])
740 AT_KEYWORDS([segment])
741 AT_DATA([input], [dnl
766 AT_DATA([expout], [dnl
767 identifier begin space
780 identifier begin space
806 inline_data 5_6_7_/*_x
812 inline_data end__data
843 identifier begin space
844 identifier data space
849 identifier begin space
850 identifier data space
855 reserved_word not space
861 PSPP_CHECK_SEGMENT([-i])
864 AT_SETUP([DO REPEAT command])
865 AT_KEYWORDS([segment])
866 AT_DATA([input], [dnl
869 do repeat a=1 thru 5.
873 end /* x */ /* y */ repeat print.
881 AT_DATA([expout], [dnl
883 identifier repeat space
898 newline \n (DO REPEAT)
900 do_repeat_command __do_repeat_a=1_thru_5.
901 newline \n (DO REPEAT)
903 do_repeat_command another_command.
904 newline \n (DO REPEAT)
906 do_repeat_command second_command
907 newline \n (DO REPEAT)
909 do_repeat_command +_third_command.
910 newline \n (DO REPEAT)
912 do_repeat_command end_/*_x_*/_/*_y_*/_repeat_print.
913 newline \n (DO REPEAT)
926 identifier repeat space
931 newline \n (DO REPEAT)
933 do_repeat_command __inner_command.
934 newline \n (DO REPEAT)
943 PSPP_CHECK_SEGMENT([-i])
946 AT_SETUP([batch mode])
947 AT_KEYWORDS([segment])
948 AT_DATA([input], [dnl
950 another line of first command
957 AT_DATA([expout], [dnl
958 identifier first space
963 identifier another space
964 identifier line space
966 identifier first space
972 identifier second space
977 identifier third space
984 identifier fourth space
990 identifier fifth space
997 PSPP_CHECK_SEGMENT([-b])
1000 AT_SETUP([auto mode])
1001 AT_KEYWORDS([segment])
1002 AT_DATA([input], [dnl
1004 another line of command
1007 another line of second command
1017 AT_DATA([expout], [dnl
1022 identifier another space
1023 identifier line space
1035 identifier another space
1039 identifier another space
1040 identifier line space
1042 identifier second space
1047 identifier data space
1048 identifier list space
1055 identifier aggregate
1059 identifier print space
1064 identifier twostep space
1074 identifier fourth space
1080 identifier fifth space
1087 PSPP_CHECK_SEGMENT([-a])