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 ~&|=>=><=<~=<>(),-+*/[[]]**
295 AT_DATA([expout-base], [dnl
342 PSPP_CHECK_SEGMENT([-i])
346 AT_KEYWORDS([segment])
347 AT_DATA([input], [dnl
349 123. /* comment 1 */ /* comment 2 */
351 5e1 6E-1 7e+1 6E+01 6e-03
352 .3E1 .4e-1 .5E+1 .6e+01 .7E-03
353 1.23e1 45.6E-1 78.9e+1 99.9E+01 11.2e-03
356 AT_DATA([expout-base], [dnl
367 comment /*_comment_1_*/ space
368 comment /*_comment_2_*/
396 number 99.9E+01 space
400 start_command . space
401 expected_exponent 1e space
403 expected_exponent 1e+ space
404 expected_exponent 1e- space
411 PSPP_CHECK_SEGMENT([-i])
415 AT_KEYWORDS([segment])
416 AT_DATA([input], [dnl
418 'Don''t' "Can't" 'Won''t'
419 """quoted""" '"quoted"'
422 "missing double quote
426 + /* comment */ 'string continuation'
427 + /* also a punctuator on blank line
430 AT_DATA([expout-base], [dnl
431 quoted_string 'x' space
432 quoted_string "y" space
436 quoted_string 'Don''t' space
437 quoted_string "Can't" space
438 quoted_string 'Won''t'
441 quoted_string """quoted""" space
442 quoted_string '"quoted"'
445 quoted_string '' space
449 expected_quote 'missing_end_quote
452 expected_quote "missing_double_quote
455 hex_string x"4142" space
459 unicode_string u'fffd' space
460 unicode_string U"041"
463 start_command + space
469 comment /*_comment_*/ space
470 quoted_string 'string_continuation'
474 comment /*_also_a_punctuator_on_blank_line
477 start_command - space
478 quoted_string 'new_command'
483 PSPP_CHECK_SEGMENT([-i])
486 AT_SETUP([@%:@! construct])
487 AT_KEYWORDS([segment])
488 AT_DATA([input], [dnl
493 AT_DATA([expout-base], [dnl
494 shbang #!_/usr/bin/pspp
497 identifier title space
498 unquoted_string my_title
514 PSPP_CHECK_SEGMENT([-i])
517 AT_SETUP([* and COMMENT commands])
518 AT_KEYWORDS([segment])
519 AT_DATA([input], [dnl
520 * Comment commands "don't
521 have to contain valid tokens.
523 ** Check ambiguity with ** token.
526 comment keyword works too.
528 com is ambiguous with COMPUTE.
530 * Comment need not start at left margin.
532 * Comment ends with blank line
537 AT_DATA([expout-base], [dnl
538 comment_command *_Comment_commands_"don't
541 comment_command have_to_contain_valid_tokens
548 comment_command **_Check_ambiguity_with_**_token
552 comment_command ****************
559 comment_command comment_keyword_works_too
563 comment_command COMM_also
569 identifier ambiguous space
570 reserved_word with space
579 comment_command *_Comment_need_not_start_at_left_margin
586 comment_command *_Comment_ends_with_blank_line
592 identifier next space
602 PSPP_CHECK_SEGMENT([-i])
605 AT_SETUP([DOCUMENT command])
606 AT_KEYWORDS([segment])
607 AT_DATA([input], [dnl
615 isn't parsed as tokens
619 AT_DATA([expout-base], [dnl
621 document DOCUMENT_one_line.
628 newline \n (DOCUMENT)
631 newline \n (DOCUMENT)
634 newline \n (DOCUMENT)
636 document ____________line.
643 newline \n (DOCUMENT)
645 document first.paragraph
646 newline \n (DOCUMENT)
648 document isn't_parsed_as_tokens
649 newline \n (DOCUMENT)
652 newline \n (DOCUMENT)
654 document second_paragraph.
661 PSPP_CHECK_SEGMENT([-i])
664 AT_SETUP([TITLE, SUBTITLE, FILE LABEL commands])
665 AT_KEYWORDS([segment])
666 AT_DATA([input], [dnl
667 title/**/'Quoted string title'.
669 "Quoted string on second line".
670 sub "Quoted string subtitle"
673 TITL /* Not a */ quoted string title.
674 SUBT Not a quoted string /* subtitle
676 FIL label isn't quoted.
680 /**/ lab not quoted here either
683 AT_DATA([expout-base], [dnl
686 quoted_string 'Quoted_string_title'
694 quoted_string "Quoted_string_on_second_line"
699 quoted_string "Quoted_string_subtitle"
708 identifier TITL space
709 unquoted_string /*_Not_a_*/_quoted_string_title
713 identifier SUBT space
714 unquoted_string Not_a_quoted_string_/*_subtitle
721 identifier label space
722 unquoted_string isn't_quoted
731 quoted_string 'is_quoted'
735 identifier FILE space
742 unquoted_string not_quoted_here_either
750 PSPP_CHECK_SEGMENT([-i])
753 AT_SETUP([BEGIN DATA command])
754 AT_KEYWORDS([segment])
755 AT_DATA([input], [dnl
780 AT_DATA([expout-base], [dnl
781 identifier begin space
794 identifier begin space
820 inline_data 5_6_7_/*_x
826 inline_data end__data
857 identifier begin space
858 identifier data space
863 identifier begin space
864 identifier data space
869 reserved_word not space
875 PSPP_CHECK_SEGMENT([-i])
878 AT_SETUP([DO REPEAT command])
879 AT_KEYWORDS([segment])
880 AT_DATA([input], [dnl
883 do repeat a=1 thru 5.
887 end /* x */ /* y */ repeat print.
895 AT_DATA([expout-base], [dnl
897 identifier repeat space
912 newline \n (DO REPEAT)
914 do_repeat_command __do_repeat_a=1_thru_5.
915 newline \n (DO REPEAT)
917 do_repeat_command another_command.
918 newline \n (DO REPEAT)
920 do_repeat_command second_command
921 newline \n (DO REPEAT)
923 do_repeat_command +_third_command.
924 newline \n (DO REPEAT)
926 do_repeat_command end_/*_x_*/_/*_y_*/_repeat_print.
927 newline \n (DO REPEAT)
940 identifier repeat space
945 newline \n (DO REPEAT)
947 do_repeat_command __inner_command.
948 newline \n (DO REPEAT)
957 PSPP_CHECK_SEGMENT([-i])
960 AT_SETUP([DO REPEAT command in batch mode])
961 AT_KEYWORDS([segment])
962 AT_DATA([input], [dnl
969 end /* x */ /* y */ repeat print
978 AT_DATA([expout-base], [dnl
980 identifier repeat space
997 do_repeat_command do_repeat_a=1_thru_5
998 newline \n (DO REPEAT)
1000 do_repeat_command another_command
1001 newline \n (DO REPEAT)
1003 do_repeat_command second_command
1004 newline \n (DO REPEAT)
1006 do_repeat_command +_third_command
1007 newline \n (DO REPEAT)
1009 do_repeat_command end_/*_x_*/_/*_y_*/_repeat_print
1010 newline \n (DO REPEAT)
1023 identifier repeat space
1030 newline \n (DO REPEAT)
1032 do_repeat_command __inner_command
1033 newline \n (DO REPEAT)
1035 identifier end space
1041 PSPP_CHECK_SEGMENT([-b])
1044 AT_SETUP([batch mode])
1045 AT_KEYWORDS([segment])
1046 AT_DATA([input], [dnl
1048 another line of first command
1055 AT_DATA([expout-base], [dnl
1056 identifier first space
1061 identifier another space
1062 identifier line space
1064 identifier first space
1070 identifier second space
1075 identifier third space
1082 identifier fourth space
1088 identifier fifth space
1095 PSPP_CHECK_SEGMENT([-b])
1098 AT_SETUP([auto mode])
1099 AT_KEYWORDS([segment])
1100 AT_DATA([input], [dnl
1102 another line of command
1105 another line of second command
1115 AT_DATA([expout-base], [dnl
1120 identifier another space
1121 identifier line space
1133 identifier another space
1137 identifier another space
1138 identifier line space
1140 identifier second space
1145 identifier data space
1146 identifier list space
1153 identifier aggregate
1157 identifier print space
1162 identifier twostep space
1172 identifier fourth space
1178 identifier fifth space
1185 PSPP_CHECK_SEGMENT([-a])