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
528 PSPP_CHECK_SEGMENT([-i])
531 AT_SETUP([* and COMMENT commands])
532 AT_KEYWORDS([segment])
533 AT_DATA([input], [dnl
534 * Comment commands "don't
535 have to contain valid tokens.
537 ** Check ambiguity with ** token.
540 comment keyword works too.
542 com is ambiguous with COMPUTE.
544 * Comment need not start at left margin.
546 * Comment ends with blank line
551 AT_DATA([expout-base], [dnl
552 comment_command *_Comment_commands_"don't
555 comment_command have_to_contain_valid_tokens
562 comment_command **_Check_ambiguity_with_**_token
566 comment_command ****************
573 comment_command comment_keyword_works_too
577 comment_command COMM_also
583 identifier ambiguous space
584 reserved_word with space
593 comment_command *_Comment_need_not_start_at_left_margin
600 comment_command *_Comment_ends_with_blank_line
606 identifier next space
616 PSPP_CHECK_SEGMENT([-i])
619 AT_SETUP([DOCUMENT command])
620 AT_KEYWORDS([segment])
621 AT_DATA([input], [dnl
629 isn't parsed as tokens
633 AT_DATA([expout-base], [dnl
635 document DOCUMENT_one_line.
642 newline \n (DOCUMENT)
645 newline \n (DOCUMENT)
648 newline \n (DOCUMENT)
650 document ____________line.
657 newline \n (DOCUMENT)
659 document first.paragraph
660 newline \n (DOCUMENT)
662 document isn't_parsed_as_tokens
663 newline \n (DOCUMENT)
666 newline \n (DOCUMENT)
668 document second_paragraph.
675 PSPP_CHECK_SEGMENT([-i])
678 AT_SETUP([FILE LABEL command])
679 AT_KEYWORDS([segment])
680 AT_DATA([input], [dnl
681 FIL label isn't quoted.
685 /**/ lab not quoted here either
688 AT_DATA([expout-base], [dnl
690 identifier label space
691 unquoted_string isn't_quoted
700 quoted_string 'is_quoted'
704 identifier FILE space
711 unquoted_string not_quoted_here_either
719 PSPP_CHECK_SEGMENT([-i])
722 AT_SETUP([BEGIN DATA command])
723 AT_KEYWORDS([segment])
724 AT_DATA([input], [dnl
749 AT_DATA([expout-base], [dnl
750 identifier begin space
763 identifier begin space
789 inline_data 5_6_7_/*_x
795 inline_data end__data
826 identifier begin space
827 identifier data space
832 identifier begin space
833 identifier data space
838 reserved_word not space
844 PSPP_CHECK_SEGMENT([-i])
847 AT_SETUP([DO REPEAT command])
848 AT_KEYWORDS([segment])
849 AT_DATA([input], [dnl
852 do repeat a=1 thru 5.
856 end /* x */ /* y */ repeat print.
864 AT_DATA([expout-base], [dnl
866 identifier repeat space
881 newline \n (DO REPEAT)
883 do_repeat_command __do_repeat_a=1_thru_5.
884 newline \n (DO REPEAT)
886 do_repeat_command another_command.
887 newline \n (DO REPEAT)
889 do_repeat_command second_command
890 newline \n (DO REPEAT)
892 do_repeat_command +_third_command.
893 newline \n (DO REPEAT)
895 do_repeat_command end_/*_x_*/_/*_y_*/_repeat_print.
896 newline \n (DO REPEAT)
909 identifier repeat space
914 newline \n (DO REPEAT)
916 do_repeat_command __inner_command.
917 newline \n (DO REPEAT)
926 PSPP_CHECK_SEGMENT([-i])
929 AT_SETUP([DO REPEAT command in batch mode])
930 AT_KEYWORDS([segment])
931 AT_DATA([input], [dnl
938 end /* x */ /* y */ repeat print
947 AT_DATA([expout-base], [dnl
949 identifier repeat space
966 do_repeat_command do_repeat_a=1_thru_5
967 newline \n (DO REPEAT)
969 do_repeat_command another_command
970 newline \n (DO REPEAT)
972 do_repeat_command second_command
973 newline \n (DO REPEAT)
975 do_repeat_command +_third_command
976 newline \n (DO REPEAT)
978 do_repeat_command end_/*_x_*/_/*_y_*/_repeat_print
979 newline \n (DO REPEAT)
992 identifier repeat space
999 newline \n (DO REPEAT)
1001 do_repeat_command __inner_command
1002 newline \n (DO REPEAT)
1004 identifier end space
1010 PSPP_CHECK_SEGMENT([-b])
1013 AT_SETUP([DEFINE command - simple])
1014 AT_KEYWORDS([segment])
1015 AT_DATA([input], [dnl
1020 AT_DATA([expout-base], [dnl
1021 identifier define space
1028 macro_body var1_var2_var3
1037 PSPP_CHECK_SEGMENT([-i])
1040 AT_SETUP([DEFINE command - no newline after parentheses])
1041 AT_KEYWORDS([segment])
1042 AT_DATA([input], [dnl
1043 define !macro1() var1 var2 var3
1046 AT_DATA([expout-base], [dnl
1047 identifier define space
1051 macro_body _var1_var2_var3
1060 PSPP_CHECK_SEGMENT([-i])
1063 AT_SETUP([DEFINE command - no newline before !ENDDEFINE])
1064 AT_KEYWORDS([segment ENDDEFINE])
1065 AT_DATA([input], [dnl
1067 var1 var2 var3!enddefine.
1069 AT_DATA([expout-base], [dnl
1070 identifier define space
1077 macro_body var1_var2_var3
1084 PSPP_CHECK_SEGMENT([-i])
1087 AT_SETUP([DEFINE command - all on one line])
1088 AT_KEYWORDS([segment])
1089 AT_DATA([input], [dnl
1090 define !macro1()var1 var2 var3!enddefine.
1092 AT_DATA([expout-base], [dnl
1093 identifier define space
1097 macro_body var1_var2_var3
1104 PSPP_CHECK_SEGMENT([-i])
1107 AT_SETUP([DEFINE command - empty])
1108 AT_KEYWORDS([segment])
1109 AT_DATA([input], [dnl
1113 AT_DATA([expout-base], [dnl
1114 identifier define space
1127 PSPP_CHECK_SEGMENT([-i])
1130 AT_SETUP([DEFINE command - blank lines])
1131 AT_KEYWORDS([segment])
1132 AT_DATA([input], [dnl
1138 AT_DATA([expout-base], [dnl
1139 identifier define space
1158 PSPP_CHECK_SEGMENT([-i])
1161 AT_SETUP([DEFINE command - arguments])
1162 AT_KEYWORDS([segment])
1163 AT_DATA([input], [dnl
1164 define !macro1(a(), b(), c())
1167 AT_DATA([expout-base], [dnl
1168 identifier define space
1192 PSPP_CHECK_SEGMENT([-i])
1195 AT_SETUP([DEFINE command - multiline arguments])
1196 AT_KEYWORDS([segment])
1197 AT_DATA([input], [dnl
1205 AT_DATA([expout-base], [dnl
1206 identifier define space
1241 PSPP_CHECK_SEGMENT([-i])
1244 AT_SETUP([DEFINE command - arguments start on second line])
1245 AT_KEYWORDS([segment])
1246 AT_DATA([input], [dnl
1254 AT_DATA([expout-base], [dnl
1255 identifier define space
1271 macro_body content_1
1274 macro_body content_2
1283 PSPP_CHECK_SEGMENT([-i])
1286 AT_SETUP([DEFINE command - early end of command 1])
1287 AT_KEYWORDS([segment])
1288 AT_DATA([input], [dnl
1292 AT_DATA([expout-base], [dnl
1293 identifier define space
1298 identifier data space
1299 identifier list space
1308 PSPP_CHECK_SEGMENT([-i])
1311 AT_SETUP([DEFINE command - early end of command 2])
1312 AT_KEYWORDS([segment])
1313 AT_DATA([input], [dnl
1318 AT_DATA([expout-base], [dnl
1319 identifier define space
1327 identifier data space
1328 identifier list space
1337 PSPP_CHECK_SEGMENT([-i])
1340 AT_SETUP([DEFINE command - early end of command 3])
1341 AT_KEYWORDS([segment])
1342 AT_DATA([input], [dnl
1347 AT_DATA([expout-base], [dnl
1348 identifier define space
1358 identifier data space
1359 identifier list space
1368 PSPP_CHECK_SEGMENT([-i])
1371 AT_SETUP([DEFINE command - early end of command 4])
1372 AT_KEYWORDS([segment])
1373 AT_DATA([input], [dnl
1374 dnl Notice the command terminator at the end of the DEFINE command,
1375 dnl which should not be there and ends it early.
1379 AT_DATA([expout-base], [dnl
1380 identifier define space
1385 identifier data space
1386 identifier list space
1395 PSPP_CHECK_SEGMENT([-i])
1398 AT_SETUP([DEFINE command - missing !ENDDEFINE])
1399 AT_KEYWORDS([segment])
1400 AT_DATA([input], [dnl
1405 AT_DATA([expout-base], [dnl
1406 identifier define space
1413 macro_body content_line_1
1416 macro_body content_line_2
1417 -newline \n (DEFINE)
1421 PSPP_CHECK_SEGMENT([-i])
1424 AT_SETUP([batch mode])
1425 AT_KEYWORDS([segment])
1426 AT_DATA([input], [dnl
1428 another line of first command
1435 AT_DATA([expout-base], [dnl
1436 identifier first space
1441 identifier another space
1442 identifier line space
1444 identifier first space
1450 identifier second space
1455 identifier third space
1462 identifier fourth space
1468 identifier fifth space
1475 PSPP_CHECK_SEGMENT([-b])
1478 AT_SETUP([auto mode])
1479 AT_KEYWORDS([segment])
1480 AT_DATA([input], [dnl
1482 another line of command
1485 another line of second command
1495 AT_DATA([expout-base], [dnl
1500 identifier another space
1501 identifier line space
1513 identifier another space
1517 identifier another space
1518 identifier line space
1520 identifier second space
1525 identifier data space
1526 identifier list space
1533 identifier aggregate
1537 identifier print space
1542 identifier twostep space
1552 identifier fourth space
1558 identifier fifth space
1565 PSPP_CHECK_SEGMENT([-a])