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
1072 macro_body var1_var2_var3
1081 PSPP_CHECK_SEGMENT([-i])
1084 AT_SETUP([DEFINE command - no newline after parentheses])
1085 AT_KEYWORDS([segment])
1086 AT_DATA([input], [dnl
1087 define !macro1() var1 var2 var3
1090 AT_DATA([expout-base], [dnl
1091 identifier define space
1095 macro_body _var1_var2_var3
1104 PSPP_CHECK_SEGMENT([-i])
1107 AT_SETUP([DEFINE command - no newline before !ENDDEFINE])
1108 AT_KEYWORDS([segment ENDDEFINE])
1109 AT_DATA([input], [dnl
1111 var1 var2 var3!enddefine.
1113 AT_DATA([expout-base], [dnl
1114 identifier define space
1121 macro_body var1_var2_var3
1128 PSPP_CHECK_SEGMENT([-i])
1131 AT_SETUP([DEFINE command - all on one line])
1132 AT_KEYWORDS([segment])
1133 AT_DATA([input], [dnl
1134 define !macro1()var1 var2 var3!enddefine.
1136 AT_DATA([expout-base], [dnl
1137 identifier define space
1141 macro_body var1_var2_var3
1148 PSPP_CHECK_SEGMENT([-i])
1151 AT_SETUP([DEFINE command - empty])
1152 AT_KEYWORDS([segment])
1153 AT_DATA([input], [dnl
1157 AT_DATA([expout-base], [dnl
1158 identifier define space
1171 PSPP_CHECK_SEGMENT([-i])
1174 AT_SETUP([DEFINE command - blank lines])
1175 AT_KEYWORDS([segment])
1176 AT_DATA([input], [dnl
1182 AT_DATA([expout-base], [dnl
1183 identifier define space
1202 PSPP_CHECK_SEGMENT([-i])
1205 AT_SETUP([DEFINE command - arguments])
1206 AT_KEYWORDS([segment])
1207 AT_DATA([input], [dnl
1208 define !macro1(a(), b(), c())
1211 AT_DATA([expout-base], [dnl
1212 identifier define space
1236 PSPP_CHECK_SEGMENT([-i])
1239 AT_SETUP([DEFINE command - multiline arguments])
1240 AT_KEYWORDS([segment])
1241 AT_DATA([input], [dnl
1249 AT_DATA([expout-base], [dnl
1250 identifier define space
1285 PSPP_CHECK_SEGMENT([-i])
1288 AT_SETUP([DEFINE command - arguments start on second line])
1289 AT_KEYWORDS([segment])
1290 AT_DATA([input], [dnl
1298 AT_DATA([expout-base], [dnl
1299 identifier define space
1315 macro_body content_1
1318 macro_body content_2
1327 PSPP_CHECK_SEGMENT([-i])
1330 AT_SETUP([DEFINE command - early end of command 1])
1331 AT_KEYWORDS([segment])
1332 AT_DATA([input], [dnl
1336 AT_DATA([expout-base], [dnl
1337 identifier define space
1342 identifier data space
1343 identifier list space
1352 PSPP_CHECK_SEGMENT([-i])
1355 AT_SETUP([DEFINE command - early end of command 2])
1356 AT_KEYWORDS([segment])
1357 AT_DATA([input], [dnl
1362 AT_DATA([expout-base], [dnl
1363 identifier define space
1371 identifier data space
1372 identifier list space
1381 PSPP_CHECK_SEGMENT([-i])
1384 AT_SETUP([DEFINE command - early end of command 3])
1385 AT_KEYWORDS([segment])
1386 AT_DATA([input], [dnl
1391 AT_DATA([expout-base], [dnl
1392 identifier define space
1402 identifier data space
1403 identifier list space
1412 PSPP_CHECK_SEGMENT([-i])
1415 AT_SETUP([DEFINE command - early end of command 4])
1416 AT_KEYWORDS([segment])
1417 AT_DATA([input], [dnl
1418 dnl Notice the command terminator at the end of the DEFINE command,
1419 dnl which should not be there and ends it early.
1423 AT_DATA([expout-base], [dnl
1424 identifier define space
1429 identifier data space
1430 identifier list space
1439 PSPP_CHECK_SEGMENT([-i])
1442 AT_SETUP([DEFINE command - missing !ENDDEFINE])
1443 AT_KEYWORDS([segment])
1444 AT_DATA([input], [dnl
1449 AT_DATA([expout-base], [dnl
1450 identifier define space
1457 macro_body content_line_1
1460 macro_body content_line_2
1461 -newline \n (DEFINE)
1465 PSPP_CHECK_SEGMENT([-i])
1468 AT_SETUP([batch mode])
1469 AT_KEYWORDS([segment])
1470 AT_DATA([input], [dnl
1472 another line of first command
1479 AT_DATA([expout-base], [dnl
1480 identifier first space
1485 identifier another space
1486 identifier line space
1488 identifier first space
1494 identifier second space
1499 identifier third space
1506 identifier fourth space
1512 identifier fifth space
1519 PSPP_CHECK_SEGMENT([-b])
1522 AT_SETUP([auto mode])
1523 AT_KEYWORDS([segment])
1524 AT_DATA([input], [dnl
1526 another line of command
1529 another line of second command
1539 AT_DATA([expout-base], [dnl
1544 identifier another space
1545 identifier line space
1557 identifier another space
1561 identifier another space
1562 identifier line space
1564 identifier second space
1569 identifier data space
1570 identifier list space
1577 identifier aggregate
1581 identifier print space
1586 identifier twostep space
1596 identifier fourth space
1602 identifier fifth space
1609 PSPP_CHECK_SEGMENT([-a])