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é
45 AT_DATA([expout-base], [dnl
90 identifier #12345 space
110 PSPP_CHECK_SEGMENT([-i])
113 AT_SETUP([identifiers that end in '.'])
114 AT_KEYWORDS([segment])
115 AT_DATA([input], [dnl
127 QRSTUV./* end of line comment */
128 qrstuv. /* end of line comment */
129 QrStUv./* end of line comment */ @&t@
130 wxyz./* unterminated end of line comment
131 WXYZ. /* unterminated end of line comment
132 WxYz./* unterminated end of line comment @&t@
134 AT_DATA([expout-base], [dnl
135 identifier abcd. space
140 identifier ABCD. space
145 identifier aBcD. space
177 start_command . space
186 comment /*_end_of_line_comment_*/
191 comment /*_end_of_line_comment_*/
196 comment /*_end_of_line_comment_*/ space
201 comment /*_unterminated_end_of_line_comment
206 comment /*_unterminated_end_of_line_comment
211 comment /*_unterminated_end_of_line_comment_
216 PSPP_CHECK_SEGMENT([-i])
219 AT_SETUP([reserved words])
220 AT_KEYWORDS([segment])
221 AT_DATA([input], [dnl
222 and or not eq ge gt le lt ne all by to with
223 AND OR NOT EQ GE GT LE LT NE ALL BY TO WITH
224 andx orx notx eqx gex gtx lex ltx nex allx byx tox withx
227 AT_DATA([expout-base], [dnl
228 reserved_word and space
229 reserved_word or space
230 reserved_word not space
231 reserved_word eq space
232 reserved_word ge space
233 reserved_word gt space
234 reserved_word le space
235 reserved_word lt space
236 reserved_word ne space
237 reserved_word all space
238 reserved_word by space
239 reserved_word to space
243 reserved_word AND space
244 reserved_word OR space
245 reserved_word NOT space
246 reserved_word EQ space
247 reserved_word GE space
248 reserved_word GT space
249 reserved_word LE space
250 reserved_word LT space
251 reserved_word NE space
252 reserved_word ALL space
253 reserved_word BY space
254 reserved_word TO space
258 identifier andx space
260 identifier notx space
267 identifier allx space
273 identifier and. space
280 PSPP_CHECK_SEGMENT([-i])
283 AT_SETUP([punctuation])
284 AT_KEYWORDS([segment])
285 AT_DATA([input], [dnl
286 ~ & | = >= > <= < ~= <> ( ) , - + * / [[ ]] **
287 ~&|=>=><=<~=<>(),-+*/[[]]**
289 AT_DATA([expout-base], [dnl
336 PSPP_CHECK_SEGMENT([-i])
340 AT_KEYWORDS([segment])
341 AT_DATA([input], [dnl
343 123. /* comment 1 */ /* comment 2 */
345 5e1 6E-1 7e+1 6E+01 6e-03
346 .3E1 .4e-1 .5E+1 .6e+01 .7E-03
347 1.23e1 45.6E-1 78.9e+1 99.9E+01 11.2e-03
350 AT_DATA([expout-base], [dnl
361 comment /*_comment_1_*/ space
362 comment /*_comment_2_*/
390 number 99.9E+01 space
394 start_command . space
395 expected_exponent 1e space
397 expected_exponent 1e+ space
398 expected_exponent 1e-
403 PSPP_CHECK_SEGMENT([-i])
407 AT_KEYWORDS([segment])
408 AT_DATA([input], [dnl
410 'Don''t' "Can't" 'Won''t'
411 """quoted""" '"quoted"'
414 "missing double quote
418 + /* comment */ 'string continuation'
419 + /* also a punctuator on blank line
422 AT_DATA([expout-base], [dnl
423 quoted_string 'x' space
424 quoted_string "y" space
428 quoted_string 'Don''t' space
429 quoted_string "Can't" space
430 quoted_string 'Won''t'
433 quoted_string """quoted""" space
434 quoted_string '"quoted"'
437 quoted_string '' space
441 expected_quote 'missing_end_quote
444 expected_quote "missing_double_quote
447 hex_string x"4142" space
451 unicode_string u'fffd' space
452 unicode_string U"041"
455 start_command + space
461 comment /*_comment_*/ space
462 quoted_string 'string_continuation'
466 comment /*_also_a_punctuator_on_blank_line
469 start_command - space
470 quoted_string 'new_command'
475 PSPP_CHECK_SEGMENT([-i])
478 AT_SETUP([@%:@! construct])
479 AT_KEYWORDS([segment])
480 AT_DATA([input], [dnl
485 AT_DATA([expout-base], [dnl
486 shbang #!_/usr/bin/pspp
489 identifier title space
490 unquoted_string my_title
495 unexpected_char ! space
506 PSPP_CHECK_SEGMENT([-i])
509 AT_SETUP([* and COMMENT commands])
510 AT_KEYWORDS([segment])
511 AT_DATA([input], [dnl
512 * Comment commands "don't
513 have to contain valid tokens.
515 ** Check ambiguity with ** token.
518 comment keyword works too.
520 com is ambiguous with COMPUTE.
522 * Comment need not start at left margin.
524 * Comment ends with blank line
529 AT_DATA([expout-base], [dnl
530 comment_command *_Comment_commands_"don't
533 comment_command have_to_contain_valid_tokens
540 comment_command **_Check_ambiguity_with_**_token
544 comment_command ****************
551 comment_command comment_keyword_works_too
555 comment_command COMM_also
561 identifier ambiguous space
562 reserved_word with space
571 comment_command *_Comment_need_not_start_at_left_margin
578 comment_command *_Comment_ends_with_blank_line
584 identifier next space
594 PSPP_CHECK_SEGMENT([-i])
597 AT_SETUP([DOCUMENT command])
598 AT_KEYWORDS([segment])
599 AT_DATA([input], [dnl
607 isn't parsed as tokens
611 AT_DATA([expout-base], [dnl
613 document DOCUMENT_one_line.
620 newline \n (DOCUMENT)
623 newline \n (DOCUMENT)
626 newline \n (DOCUMENT)
628 document ____________line.
635 newline \n (DOCUMENT)
637 document first.paragraph
638 newline \n (DOCUMENT)
640 document isn't_parsed_as_tokens
641 newline \n (DOCUMENT)
644 newline \n (DOCUMENT)
646 document second_paragraph.
653 PSPP_CHECK_SEGMENT([-i])
656 AT_SETUP([TITLE, SUBTITLE, FILE LABEL commands])
657 AT_KEYWORDS([segment])
658 AT_DATA([input], [dnl
659 title/**/'Quoted string title'.
661 "Quoted string on second line".
662 sub "Quoted string subtitle"
665 TITL /* Not a */ quoted string title.
666 SUBT Not a quoted string /* subtitle
668 FIL label isn't quoted.
672 /**/ lab not quoted here either
675 AT_DATA([expout-base], [dnl
678 quoted_string 'Quoted_string_title'
686 quoted_string "Quoted_string_on_second_line"
691 quoted_string "Quoted_string_subtitle"
700 identifier TITL space
701 unquoted_string /*_Not_a_*/_quoted_string_title
705 identifier SUBT space
706 unquoted_string Not_a_quoted_string_/*_subtitle
713 identifier label space
714 unquoted_string isn't_quoted
723 quoted_string 'is_quoted'
727 identifier FILE space
734 unquoted_string not_quoted_here_either
742 PSPP_CHECK_SEGMENT([-i])
745 AT_SETUP([BEGIN DATA command])
746 AT_KEYWORDS([segment])
747 AT_DATA([input], [dnl
772 AT_DATA([expout-base], [dnl
773 identifier begin space
786 identifier begin space
812 inline_data 5_6_7_/*_x
818 inline_data end__data
849 identifier begin space
850 identifier data space
855 identifier begin space
856 identifier data space
861 reserved_word not space
867 PSPP_CHECK_SEGMENT([-i])
870 AT_SETUP([DO REPEAT command])
871 AT_KEYWORDS([segment])
872 AT_DATA([input], [dnl
875 do repeat a=1 thru 5.
879 end /* x */ /* y */ repeat print.
887 AT_DATA([expout-base], [dnl
889 identifier repeat space
904 newline \n (DO REPEAT)
906 do_repeat_command __do_repeat_a=1_thru_5.
907 newline \n (DO REPEAT)
909 do_repeat_command another_command.
910 newline \n (DO REPEAT)
912 do_repeat_command second_command
913 newline \n (DO REPEAT)
915 do_repeat_command +_third_command.
916 newline \n (DO REPEAT)
918 do_repeat_command end_/*_x_*/_/*_y_*/_repeat_print.
919 newline \n (DO REPEAT)
932 identifier repeat space
937 newline \n (DO REPEAT)
939 do_repeat_command __inner_command.
940 newline \n (DO REPEAT)
949 PSPP_CHECK_SEGMENT([-i])
952 AT_SETUP([batch mode])
953 AT_KEYWORDS([segment])
954 AT_DATA([input], [dnl
956 another line of first command
963 AT_DATA([expout-base], [dnl
964 identifier first space
969 identifier another space
970 identifier line space
972 identifier first space
978 identifier second space
983 identifier third space
990 identifier fourth space
996 identifier fifth space
1003 PSPP_CHECK_SEGMENT([-b])
1006 AT_SETUP([auto mode])
1007 AT_KEYWORDS([segment])
1008 AT_DATA([input], [dnl
1010 another line of command
1013 another line of second command
1023 AT_DATA([expout-base], [dnl
1028 identifier another space
1029 identifier line space
1041 identifier another space
1045 identifier another space
1046 identifier line space
1048 identifier second space
1053 identifier data space
1054 identifier list space
1061 identifier aggregate
1065 identifier print space
1070 identifier twostep space
1080 identifier fourth space
1086 identifier fifth space
1093 PSPP_CHECK_SEGMENT([-a])