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_CAPTURE_FILE([input])
20 for strip in "" "-s"; do
22 '') sed 's/^-//' < expout-base > expout ;; # (
23 -s) sed '/^-/d' < expout-base > expout ;;
25 AT_CHECK([segment-test $1 $strip input], [0], [expout])
26 AT_CHECK([segment-test -1 $strip $1 input], [0], [expout])
27 AT_CHECK([segment-test -0 $strip $1 input])
28 AT_CHECK([segment-test -01 $strip $1 input])
31 AT_SETUP([identifiers])
32 AT_KEYWORDS([segment])
38 grève@<00A0>@Ângstrom@<00A0>@poté
40 @efg @ @@. @#@ !@ @&t@
46 AT_DATA([expout-base], [dnl
97 identifier #12345 space
117 PSPP_CHECK_SEGMENT([-i])
120 AT_SETUP([identifiers that end in '.'])
121 AT_KEYWORDS([segment])
122 AT_DATA([input], [dnl
134 QRSTUV./* end of line comment */
135 qrstuv. /* end of line comment */
136 QrStUv./* end of line comment */ @&t@
137 wxyz./* unterminated end of line comment
138 WXYZ. /* unterminated end of line comment
139 WxYz./* unterminated end of line comment @&t@
141 AT_DATA([expout-base], [dnl
142 identifier abcd. space
147 identifier ABCD. space
152 identifier aBcD. space
184 start_command . space
193 comment /*_end_of_line_comment_*/
198 comment /*_end_of_line_comment_*/
203 comment /*_end_of_line_comment_*/ space
208 comment /*_unterminated_end_of_line_comment
213 comment /*_unterminated_end_of_line_comment
218 comment /*_unterminated_end_of_line_comment_
223 PSPP_CHECK_SEGMENT([-i])
226 AT_SETUP([reserved words])
227 AT_KEYWORDS([segment])
228 AT_DATA([input], [dnl
229 and or not eq ge gt le lt ne all by to with
230 AND OR NOT EQ GE GT LE LT NE ALL BY TO WITH
231 andx orx notx eqx gex gtx lex ltx nex allx byx tox withx
234 AT_DATA([expout-base], [dnl
235 reserved_word and space
236 reserved_word or space
237 reserved_word not space
238 reserved_word eq space
239 reserved_word ge space
240 reserved_word gt space
241 reserved_word le space
242 reserved_word lt space
243 reserved_word ne space
244 reserved_word all space
245 reserved_word by space
246 reserved_word to space
250 reserved_word AND space
251 reserved_word OR space
252 reserved_word NOT space
253 reserved_word EQ space
254 reserved_word GE space
255 reserved_word GT space
256 reserved_word LE space
257 reserved_word LT space
258 reserved_word NE space
259 reserved_word ALL space
260 reserved_word BY space
261 reserved_word TO space
265 identifier andx space
267 identifier notx space
274 identifier allx space
280 identifier and. space
287 PSPP_CHECK_SEGMENT([-i])
290 AT_SETUP([punctuation])
291 AT_KEYWORDS([segment])
292 AT_DATA([input], [dnl
293 ~ & | = >= > <= < ~= <> ( ) , - + * / [[ ]] **
294 ~&|=>=><=<~=<>(),-+*/[[]]**
297 AT_DATA([expout-base], [dnl
355 PSPP_CHECK_SEGMENT([-i])
359 AT_KEYWORDS([segment])
360 AT_DATA([input], [dnl
362 123. /* comment 1 */ /* comment 2 */
364 5e1 6E-1 7e+1 6E+01 6e-03
365 .3E1 .4e-1 .5E+1 .6e+01 .7E-03
366 1.23e1 45.6E-1 78.9e+1 99.9E+01 11.2e-03
369 AT_DATA([expout-base], [dnl
380 comment /*_comment_1_*/ space
381 comment /*_comment_2_*/
409 number 99.9E+01 space
413 start_command . space
414 expected_exponent 1e space
416 expected_exponent 1e+ space
417 expected_exponent 1e- space
424 PSPP_CHECK_SEGMENT([-i])
428 AT_KEYWORDS([segment])
429 AT_DATA([input], [dnl
431 'Don''t' "Can't" 'Won''t'
432 """quoted""" '"quoted"'
435 "missing double quote
439 + /* comment */ 'string continuation'
440 + /* also a punctuator on blank line
443 AT_DATA([expout-base], [dnl
444 quoted_string 'x' space
445 quoted_string "y" space
449 quoted_string 'Don''t' space
450 quoted_string "Can't" space
451 quoted_string 'Won''t'
454 quoted_string """quoted""" space
455 quoted_string '"quoted"'
458 quoted_string '' space
462 expected_quote 'missing_end_quote
465 expected_quote "missing_double_quote
468 hex_string x"4142" space
472 unicode_string u'fffd' space
473 unicode_string U"041"
476 start_command + space
482 comment /*_comment_*/ space
483 quoted_string 'string_continuation'
487 comment /*_also_a_punctuator_on_blank_line
490 start_command - space
491 quoted_string 'new_command'
496 PSPP_CHECK_SEGMENT([-i])
499 AT_SETUP([@%:@! construct])
500 AT_KEYWORDS([segment])
501 AT_DATA([input], [dnl
506 AT_DATA([expout-base], [dnl
507 shbang #!_/usr/bin/pspp
510 identifier title space
511 unquoted_string my_title
527 PSPP_CHECK_SEGMENT([-i])
530 AT_SETUP([* and COMMENT commands])
531 AT_KEYWORDS([segment])
532 AT_DATA([input], [dnl
533 * Comment commands "don't
534 have to contain valid tokens.
536 ** Check ambiguity with ** token.
539 comment keyword works too.
541 com is ambiguous with COMPUTE.
543 * Comment need not start at left margin.
545 * Comment ends with blank line
550 AT_DATA([expout-base], [dnl
551 comment_command *_Comment_commands_"don't
554 comment_command have_to_contain_valid_tokens
561 comment_command **_Check_ambiguity_with_**_token
565 comment_command ****************
572 comment_command comment_keyword_works_too
576 comment_command COMM_also
582 identifier ambiguous space
583 reserved_word with space
592 comment_command *_Comment_need_not_start_at_left_margin
599 comment_command *_Comment_ends_with_blank_line
605 identifier next space
615 PSPP_CHECK_SEGMENT([-i])
618 AT_SETUP([DOCUMENT command])
619 AT_KEYWORDS([segment])
620 AT_DATA([input], [dnl
628 isn't parsed as tokens
632 AT_DATA([expout-base], [dnl
634 document DOCUMENT_one_line.
641 newline \n (DOCUMENT)
644 newline \n (DOCUMENT)
647 newline \n (DOCUMENT)
649 document ____________line.
656 newline \n (DOCUMENT)
658 document first.paragraph
659 newline \n (DOCUMENT)
661 document isn't_parsed_as_tokens
662 newline \n (DOCUMENT)
665 newline \n (DOCUMENT)
667 document second_paragraph.
674 PSPP_CHECK_SEGMENT([-i])
677 AT_SETUP([TITLE, SUBTITLE, FILE LABEL commands])
678 AT_KEYWORDS([segment])
679 AT_DATA([input], [dnl
680 title/**/'Quoted string title'.
682 "Quoted string on second line".
683 sub "Quoted string subtitle"
686 TITL /* Not a */ quoted string title.
687 SUBT Not a quoted string /* subtitle
689 FIL label isn't quoted.
693 /**/ lab not quoted here either
696 AT_DATA([expout-base], [dnl
699 quoted_string 'Quoted_string_title'
707 quoted_string "Quoted_string_on_second_line"
712 quoted_string "Quoted_string_subtitle"
721 identifier TITL space
722 unquoted_string /*_Not_a_*/_quoted_string_title
726 identifier SUBT space
727 unquoted_string Not_a_quoted_string_/*_subtitle
734 identifier label space
735 unquoted_string isn't_quoted
744 quoted_string 'is_quoted'
748 identifier FILE space
755 unquoted_string not_quoted_here_either
763 PSPP_CHECK_SEGMENT([-i])
766 AT_SETUP([BEGIN DATA command])
767 AT_KEYWORDS([segment])
768 AT_DATA([input], [dnl
793 AT_DATA([expout-base], [dnl
794 identifier begin space
807 identifier begin space
833 inline_data 5_6_7_/*_x
839 inline_data end__data
870 identifier begin space
871 identifier data space
876 identifier begin space
877 identifier data space
882 reserved_word not space
888 PSPP_CHECK_SEGMENT([-i])
891 AT_SETUP([DO REPEAT command])
892 AT_KEYWORDS([segment])
893 AT_DATA([input], [dnl
896 do repeat a=1 thru 5.
900 end /* x */ /* y */ repeat print.
908 AT_DATA([expout-base], [dnl
910 identifier repeat space
925 newline \n (DO REPEAT)
927 do_repeat_command __do_repeat_a=1_thru_5.
928 newline \n (DO REPEAT)
930 do_repeat_command another_command.
931 newline \n (DO REPEAT)
933 do_repeat_command second_command
934 newline \n (DO REPEAT)
936 do_repeat_command +_third_command.
937 newline \n (DO REPEAT)
939 do_repeat_command end_/*_x_*/_/*_y_*/_repeat_print.
940 newline \n (DO REPEAT)
953 identifier repeat space
958 newline \n (DO REPEAT)
960 do_repeat_command __inner_command.
961 newline \n (DO REPEAT)
970 PSPP_CHECK_SEGMENT([-i])
973 AT_SETUP([DO REPEAT command in batch mode])
974 AT_KEYWORDS([segment])
975 AT_DATA([input], [dnl
982 end /* x */ /* y */ repeat print
991 AT_DATA([expout-base], [dnl
993 identifier repeat space
1010 do_repeat_command do_repeat_a=1_thru_5
1011 newline \n (DO REPEAT)
1013 do_repeat_command another_command
1014 newline \n (DO REPEAT)
1016 do_repeat_command second_command
1017 newline \n (DO REPEAT)
1019 do_repeat_command +_third_command
1020 newline \n (DO REPEAT)
1022 do_repeat_command end_/*_x_*/_/*_y_*/_repeat_print
1023 newline \n (DO REPEAT)
1036 identifier repeat space
1043 newline \n (DO REPEAT)
1045 do_repeat_command __inner_command
1046 newline \n (DO REPEAT)
1048 identifier end space
1054 PSPP_CHECK_SEGMENT([-b])
1057 AT_SETUP([DEFINE command - simple])
1058 AT_KEYWORDS([segment])
1059 AT_DATA([input], [dnl
1064 AT_DATA([expout-base], [dnl
1065 identifier define space
1071 macro_body var1_var2_var3
1080 PSPP_CHECK_SEGMENT([-i])
1083 AT_SETUP([DEFINE command - empty])
1084 AT_KEYWORDS([segment])
1085 AT_DATA([input], [dnl
1089 AT_DATA([expout-base], [dnl
1090 identifier define space
1102 PSPP_CHECK_SEGMENT([-i])
1105 AT_SETUP([DEFINE command - arguments])
1106 AT_KEYWORDS([segment])
1107 AT_DATA([input], [dnl
1108 define !macro1(a(), b(), c())
1111 AT_DATA([expout-base], [dnl
1112 identifier define space
1135 PSPP_CHECK_SEGMENT([-i])
1138 AT_SETUP([DEFINE command - multiline arguments])
1139 AT_KEYWORDS([segment])
1140 AT_DATA([input], [dnl
1148 AT_DATA([expout-base], [dnl
1149 identifier define space
1183 PSPP_CHECK_SEGMENT([-i])
1186 AT_SETUP([DEFINE command - arguments start on second line])
1187 AT_KEYWORDS([segment])
1188 AT_DATA([input], [dnl
1196 AT_DATA([expout-base], [dnl
1197 identifier define space
1212 macro_body content_1
1215 macro_body content_2
1224 PSPP_CHECK_SEGMENT([-i])
1227 AT_SETUP([DEFINE command - early end of command 1])
1228 AT_KEYWORDS([segment])
1229 AT_DATA([input], [dnl
1233 AT_DATA([expout-base], [dnl
1234 identifier define space
1239 identifier data space
1240 identifier list space
1249 PSPP_CHECK_SEGMENT([-i])
1252 AT_SETUP([DEFINE command - early end of command 2])
1253 AT_KEYWORDS([segment])
1254 AT_DATA([input], [dnl
1259 AT_DATA([expout-base], [dnl
1260 identifier define space
1268 identifier data space
1269 identifier list space
1278 PSPP_CHECK_SEGMENT([-i])
1281 AT_SETUP([DEFINE command - early end of command 3])
1282 AT_KEYWORDS([segment])
1283 AT_DATA([input], [dnl
1288 AT_DATA([expout-base], [dnl
1289 identifier define space
1299 identifier data space
1300 identifier list space
1309 PSPP_CHECK_SEGMENT([-i])
1312 AT_SETUP([DEFINE command - early end of command 4])
1313 AT_KEYWORDS([segment])
1314 AT_DATA([input], [dnl
1315 dnl Notice the command terminator at the end of the DEFINE command,
1316 dnl which should not be there and ends it early.
1320 AT_DATA([expout-base], [dnl
1321 identifier define space
1326 identifier data space
1327 identifier list space
1336 PSPP_CHECK_SEGMENT([-i])
1339 AT_SETUP([DEFINE command - missing !ENDDEFINE])
1340 AT_KEYWORDS([segment])
1341 AT_DATA([input], [dnl
1346 AT_DATA([expout-base], [dnl
1347 identifier define space
1353 macro_body content_line_1
1356 macro_body content_line_2
1357 -newline \n (DEFINE)
1361 PSPP_CHECK_SEGMENT([-i])
1364 AT_SETUP([batch mode])
1365 AT_KEYWORDS([segment])
1366 AT_DATA([input], [dnl
1368 another line of first command
1375 AT_DATA([expout-base], [dnl
1376 identifier first space
1381 identifier another space
1382 identifier line space
1384 identifier first space
1390 identifier second space
1395 identifier third space
1402 identifier fourth space
1408 identifier fifth space
1415 PSPP_CHECK_SEGMENT([-b])
1418 AT_SETUP([auto mode])
1419 AT_KEYWORDS([segment])
1420 AT_DATA([input], [dnl
1422 another line of command
1425 another line of second command
1435 AT_DATA([expout-base], [dnl
1440 identifier another space
1441 identifier line space
1453 identifier another space
1457 identifier another space
1458 identifier line space
1460 identifier second space
1465 identifier data space
1466 identifier list space
1473 identifier aggregate
1477 identifier print space
1482 identifier twostep space
1492 identifier fourth space
1498 identifier fifth space
1505 PSPP_CHECK_SEGMENT([-a])