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- space
405 PSPP_CHECK_SEGMENT([-i])
409 AT_KEYWORDS([segment])
410 AT_DATA([input], [dnl
412 'Don''t' "Can't" 'Won''t'
413 """quoted""" '"quoted"'
416 "missing double quote
420 + /* comment */ 'string continuation'
421 + /* also a punctuator on blank line
424 AT_DATA([expout-base], [dnl
425 quoted_string 'x' space
426 quoted_string "y" space
430 quoted_string 'Don''t' space
431 quoted_string "Can't" space
432 quoted_string 'Won''t'
435 quoted_string """quoted""" space
436 quoted_string '"quoted"'
439 quoted_string '' space
443 expected_quote 'missing_end_quote
446 expected_quote "missing_double_quote
449 hex_string x"4142" space
453 unicode_string u'fffd' space
454 unicode_string U"041"
457 start_command + space
463 comment /*_comment_*/ space
464 quoted_string 'string_continuation'
468 comment /*_also_a_punctuator_on_blank_line
471 start_command - space
472 quoted_string 'new_command'
477 PSPP_CHECK_SEGMENT([-i])
480 AT_SETUP([@%:@! construct])
481 AT_KEYWORDS([segment])
482 AT_DATA([input], [dnl
487 AT_DATA([expout-base], [dnl
488 shbang #!_/usr/bin/pspp
491 identifier title space
492 unquoted_string my_title
497 unexpected_char ! space
508 PSPP_CHECK_SEGMENT([-i])
511 AT_SETUP([* and COMMENT commands])
512 AT_KEYWORDS([segment])
513 AT_DATA([input], [dnl
514 * Comment commands "don't
515 have to contain valid tokens.
517 ** Check ambiguity with ** token.
520 comment keyword works too.
522 com is ambiguous with COMPUTE.
524 * Comment need not start at left margin.
526 * Comment ends with blank line
531 AT_DATA([expout-base], [dnl
532 comment_command *_Comment_commands_"don't
535 comment_command have_to_contain_valid_tokens
542 comment_command **_Check_ambiguity_with_**_token
546 comment_command ****************
553 comment_command comment_keyword_works_too
557 comment_command COMM_also
563 identifier ambiguous space
564 reserved_word with space
573 comment_command *_Comment_need_not_start_at_left_margin
580 comment_command *_Comment_ends_with_blank_line
586 identifier next space
596 PSPP_CHECK_SEGMENT([-i])
599 AT_SETUP([DOCUMENT command])
600 AT_KEYWORDS([segment])
601 AT_DATA([input], [dnl
609 isn't parsed as tokens
613 AT_DATA([expout-base], [dnl
615 document DOCUMENT_one_line.
622 newline \n (DOCUMENT)
625 newline \n (DOCUMENT)
628 newline \n (DOCUMENT)
630 document ____________line.
637 newline \n (DOCUMENT)
639 document first.paragraph
640 newline \n (DOCUMENT)
642 document isn't_parsed_as_tokens
643 newline \n (DOCUMENT)
646 newline \n (DOCUMENT)
648 document second_paragraph.
655 PSPP_CHECK_SEGMENT([-i])
658 AT_SETUP([TITLE, SUBTITLE, FILE LABEL commands])
659 AT_KEYWORDS([segment])
660 AT_DATA([input], [dnl
661 title/**/'Quoted string title'.
663 "Quoted string on second line".
664 sub "Quoted string subtitle"
667 TITL /* Not a */ quoted string title.
668 SUBT Not a quoted string /* subtitle
670 FIL label isn't quoted.
674 /**/ lab not quoted here either
677 AT_DATA([expout-base], [dnl
680 quoted_string 'Quoted_string_title'
688 quoted_string "Quoted_string_on_second_line"
693 quoted_string "Quoted_string_subtitle"
702 identifier TITL space
703 unquoted_string /*_Not_a_*/_quoted_string_title
707 identifier SUBT space
708 unquoted_string Not_a_quoted_string_/*_subtitle
715 identifier label space
716 unquoted_string isn't_quoted
725 quoted_string 'is_quoted'
729 identifier FILE space
736 unquoted_string not_quoted_here_either
744 PSPP_CHECK_SEGMENT([-i])
747 AT_SETUP([BEGIN DATA command])
748 AT_KEYWORDS([segment])
749 AT_DATA([input], [dnl
774 AT_DATA([expout-base], [dnl
775 identifier begin space
788 identifier begin space
814 inline_data 5_6_7_/*_x
820 inline_data end__data
851 identifier begin space
852 identifier data space
857 identifier begin space
858 identifier data space
863 reserved_word not space
869 PSPP_CHECK_SEGMENT([-i])
872 AT_SETUP([DO REPEAT command])
873 AT_KEYWORDS([segment])
874 AT_DATA([input], [dnl
877 do repeat a=1 thru 5.
881 end /* x */ /* y */ repeat print.
889 AT_DATA([expout-base], [dnl
891 identifier repeat space
906 newline \n (DO REPEAT)
908 do_repeat_command __do_repeat_a=1_thru_5.
909 newline \n (DO REPEAT)
911 do_repeat_command another_command.
912 newline \n (DO REPEAT)
914 do_repeat_command second_command
915 newline \n (DO REPEAT)
917 do_repeat_command +_third_command.
918 newline \n (DO REPEAT)
920 do_repeat_command end_/*_x_*/_/*_y_*/_repeat_print.
921 newline \n (DO REPEAT)
934 identifier repeat space
939 newline \n (DO REPEAT)
941 do_repeat_command __inner_command.
942 newline \n (DO REPEAT)
951 PSPP_CHECK_SEGMENT([-i])
954 AT_SETUP([DO REPEAT command in batch mode])
955 AT_KEYWORDS([segment])
956 AT_DATA([input], [dnl
963 end /* x */ /* y */ repeat print
972 AT_DATA([expout-base], [dnl
974 identifier repeat space
991 do_repeat_command do_repeat_a=1_thru_5
992 newline \n (DO REPEAT)
994 do_repeat_command another_command
995 newline \n (DO REPEAT)
997 do_repeat_command second_command
998 newline \n (DO REPEAT)
1000 do_repeat_command +_third_command
1001 newline \n (DO REPEAT)
1003 do_repeat_command end_/*_x_*/_/*_y_*/_repeat_print
1004 newline \n (DO REPEAT)
1017 identifier repeat space
1024 newline \n (DO REPEAT)
1026 do_repeat_command __inner_command
1027 newline \n (DO REPEAT)
1029 identifier end space
1035 PSPP_CHECK_SEGMENT([-b])
1038 AT_SETUP([batch mode])
1039 AT_KEYWORDS([segment])
1040 AT_DATA([input], [dnl
1042 another line of first command
1049 AT_DATA([expout-base], [dnl
1050 identifier first space
1055 identifier another space
1056 identifier line space
1058 identifier first space
1064 identifier second space
1069 identifier third space
1076 identifier fourth space
1082 identifier fifth space
1089 PSPP_CHECK_SEGMENT([-b])
1092 AT_SETUP([auto mode])
1093 AT_KEYWORDS([segment])
1094 AT_DATA([input], [dnl
1096 another line of command
1099 another line of second command
1109 AT_DATA([expout-base], [dnl
1114 identifier another space
1115 identifier line space
1127 identifier another space
1131 identifier another space
1132 identifier line space
1134 identifier second space
1139 identifier data space
1140 identifier list space
1147 identifier aggregate
1151 identifier print space
1156 identifier twostep space
1166 identifier fourth space
1172 identifier fifth space
1179 PSPP_CHECK_SEGMENT([-a])