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 ~&|=>=><=<~=<>(),-+*/[[]]**
296 AT_DATA([expout-base], [dnl
354 PSPP_CHECK_SEGMENT([-i])
358 AT_KEYWORDS([segment])
359 AT_DATA([input], [dnl
361 123. /* comment 1 */ /* comment 2 */
363 5e1 6E-1 7e+1 6E+01 6e-03
364 .3E1 .4e-1 .5E+1 .6e+01 .7E-03
365 1.23e1 45.6E-1 78.9e+1 99.9E+01 11.2e-03
368 AT_DATA([expout-base], [dnl
379 comment /*_comment_1_*/ space
380 comment /*_comment_2_*/
408 number 99.9E+01 space
412 start_command . space
413 expected_exponent 1e space
415 expected_exponent 1e+ space
416 expected_exponent 1e- space
423 PSPP_CHECK_SEGMENT([-i])
427 AT_KEYWORDS([segment])
428 AT_DATA([input], [dnl
430 'Don''t' "Can't" 'Won''t'
431 """quoted""" '"quoted"'
434 "missing double quote
438 + /* comment */ 'string continuation'
439 + /* also a punctuator on blank line
442 AT_DATA([expout-base], [dnl
443 quoted_string 'x' space
444 quoted_string "y" space
448 quoted_string 'Don''t' space
449 quoted_string "Can't" space
450 quoted_string 'Won''t'
453 quoted_string """quoted""" space
454 quoted_string '"quoted"'
457 quoted_string '' space
461 expected_quote 'missing_end_quote
464 expected_quote "missing_double_quote
467 hex_string x"4142" space
471 unicode_string u'fffd' space
472 unicode_string U"041"
475 start_command + space
481 comment /*_comment_*/ space
482 quoted_string 'string_continuation'
486 comment /*_also_a_punctuator_on_blank_line
489 start_command - space
490 quoted_string 'new_command'
495 PSPP_CHECK_SEGMENT([-i])
498 AT_SETUP([@%:@! construct])
499 AT_KEYWORDS([segment])
500 AT_DATA([input], [dnl
505 AT_DATA([expout-base], [dnl
506 shbang #!_/usr/bin/pspp
509 identifier title space
510 unquoted_string my_title
526 PSPP_CHECK_SEGMENT([-i])
529 AT_SETUP([* and COMMENT commands])
530 AT_KEYWORDS([segment])
531 AT_DATA([input], [dnl
532 * Comment commands "don't
533 have to contain valid tokens.
535 ** Check ambiguity with ** token.
538 comment keyword works too.
540 com is ambiguous with COMPUTE.
542 * Comment need not start at left margin.
544 * Comment ends with blank line
549 AT_DATA([expout-base], [dnl
550 comment_command *_Comment_commands_"don't
553 comment_command have_to_contain_valid_tokens
560 comment_command **_Check_ambiguity_with_**_token
564 comment_command ****************
571 comment_command comment_keyword_works_too
575 comment_command COMM_also
581 identifier ambiguous space
582 reserved_word with space
591 comment_command *_Comment_need_not_start_at_left_margin
598 comment_command *_Comment_ends_with_blank_line
604 identifier next space
614 PSPP_CHECK_SEGMENT([-i])
617 AT_SETUP([DOCUMENT command])
618 AT_KEYWORDS([segment])
619 AT_DATA([input], [dnl
627 isn't parsed as tokens
631 AT_DATA([expout-base], [dnl
633 document DOCUMENT_one_line.
640 newline \n (DOCUMENT)
643 newline \n (DOCUMENT)
646 newline \n (DOCUMENT)
648 document ____________line.
655 newline \n (DOCUMENT)
657 document first.paragraph
658 newline \n (DOCUMENT)
660 document isn't_parsed_as_tokens
661 newline \n (DOCUMENT)
664 newline \n (DOCUMENT)
666 document second_paragraph.
673 PSPP_CHECK_SEGMENT([-i])
676 AT_SETUP([TITLE, SUBTITLE, FILE LABEL commands])
677 AT_KEYWORDS([segment])
678 AT_DATA([input], [dnl
679 title/**/'Quoted string title'.
681 "Quoted string on second line".
682 sub "Quoted string subtitle"
685 TITL /* Not a */ quoted string title.
686 SUBT Not a quoted string /* subtitle
688 FIL label isn't quoted.
692 /**/ lab not quoted here either
695 AT_DATA([expout-base], [dnl
698 quoted_string 'Quoted_string_title'
706 quoted_string "Quoted_string_on_second_line"
711 quoted_string "Quoted_string_subtitle"
720 identifier TITL space
721 unquoted_string /*_Not_a_*/_quoted_string_title
725 identifier SUBT space
726 unquoted_string Not_a_quoted_string_/*_subtitle
733 identifier label space
734 unquoted_string isn't_quoted
743 quoted_string 'is_quoted'
747 identifier FILE space
754 unquoted_string not_quoted_here_either
762 PSPP_CHECK_SEGMENT([-i])
765 AT_SETUP([BEGIN DATA command])
766 AT_KEYWORDS([segment])
767 AT_DATA([input], [dnl
792 AT_DATA([expout-base], [dnl
793 identifier begin space
806 identifier begin space
832 inline_data 5_6_7_/*_x
838 inline_data end__data
869 identifier begin space
870 identifier data space
875 identifier begin space
876 identifier data space
881 reserved_word not space
887 PSPP_CHECK_SEGMENT([-i])
890 AT_SETUP([DO REPEAT command])
891 AT_KEYWORDS([segment])
892 AT_DATA([input], [dnl
895 do repeat a=1 thru 5.
899 end /* x */ /* y */ repeat print.
907 AT_DATA([expout-base], [dnl
909 identifier repeat space
924 newline \n (DO REPEAT)
926 do_repeat_command __do_repeat_a=1_thru_5.
927 newline \n (DO REPEAT)
929 do_repeat_command another_command.
930 newline \n (DO REPEAT)
932 do_repeat_command second_command
933 newline \n (DO REPEAT)
935 do_repeat_command +_third_command.
936 newline \n (DO REPEAT)
938 do_repeat_command end_/*_x_*/_/*_y_*/_repeat_print.
939 newline \n (DO REPEAT)
952 identifier repeat space
957 newline \n (DO REPEAT)
959 do_repeat_command __inner_command.
960 newline \n (DO REPEAT)
969 PSPP_CHECK_SEGMENT([-i])
972 AT_SETUP([DO REPEAT command in batch mode])
973 AT_KEYWORDS([segment])
974 AT_DATA([input], [dnl
981 end /* x */ /* y */ repeat print
990 AT_DATA([expout-base], [dnl
992 identifier repeat space
1009 do_repeat_command do_repeat_a=1_thru_5
1010 newline \n (DO REPEAT)
1012 do_repeat_command another_command
1013 newline \n (DO REPEAT)
1015 do_repeat_command second_command
1016 newline \n (DO REPEAT)
1018 do_repeat_command +_third_command
1019 newline \n (DO REPEAT)
1021 do_repeat_command end_/*_x_*/_/*_y_*/_repeat_print
1022 newline \n (DO REPEAT)
1035 identifier repeat space
1042 newline \n (DO REPEAT)
1044 do_repeat_command __inner_command
1045 newline \n (DO REPEAT)
1047 identifier end space
1053 PSPP_CHECK_SEGMENT([-b])
1056 AT_SETUP([DEFINE command - simple])
1057 AT_KEYWORDS([segment])
1058 AT_DATA([input], [dnl
1063 AT_DATA([expout-base], [dnl
1064 identifier define space
1070 macro_body var1_var2_var3
1079 PSPP_CHECK_SEGMENT([-i])
1082 AT_SETUP([DEFINE command - empty])
1083 AT_KEYWORDS([segment])
1084 AT_DATA([input], [dnl
1088 AT_DATA([expout-base], [dnl
1089 identifier define space
1101 PSPP_CHECK_SEGMENT([-i])
1104 AT_SETUP([DEFINE command - arguments])
1105 AT_KEYWORDS([segment])
1106 AT_DATA([input], [dnl
1107 define !macro1(a(), b(), c())
1110 AT_DATA([expout-base], [dnl
1111 identifier define space
1134 PSPP_CHECK_SEGMENT([-i])
1137 AT_SETUP([DEFINE command - multiline arguments])
1138 AT_KEYWORDS([segment])
1139 AT_DATA([input], [dnl
1147 AT_DATA([expout-base], [dnl
1148 identifier define space
1182 PSPP_CHECK_SEGMENT([-i])
1185 AT_SETUP([DEFINE command - arguments start on second line])
1186 AT_KEYWORDS([segment])
1187 AT_DATA([input], [dnl
1195 AT_DATA([expout-base], [dnl
1196 identifier define space
1211 macro_body content_1
1214 macro_body content_2
1223 PSPP_CHECK_SEGMENT([-i])
1226 AT_SETUP([DEFINE command - early end of command 1])
1227 AT_KEYWORDS([segment])
1228 AT_DATA([input], [dnl
1232 AT_DATA([expout-base], [dnl
1233 identifier define space
1238 identifier data space
1239 identifier list space
1248 PSPP_CHECK_SEGMENT([-i])
1251 AT_SETUP([DEFINE command - early end of command 2])
1252 AT_KEYWORDS([segment])
1253 AT_DATA([input], [dnl
1258 AT_DATA([expout-base], [dnl
1259 identifier define space
1267 identifier data space
1268 identifier list space
1277 PSPP_CHECK_SEGMENT([-i])
1280 AT_SETUP([DEFINE command - early end of command 3])
1281 AT_KEYWORDS([segment])
1282 AT_DATA([input], [dnl
1287 AT_DATA([expout-base], [dnl
1288 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 4])
1312 AT_KEYWORDS([segment])
1313 AT_DATA([input], [dnl
1314 dnl Notice the command terminator at the end of the DEFINE command,
1315 dnl which should not be there and ends it early.
1319 AT_DATA([expout-base], [dnl
1320 identifier define space
1325 identifier data space
1326 identifier list space
1335 PSPP_CHECK_SEGMENT([-i])
1338 AT_SETUP([DEFINE command - missing !ENDDEFINE])
1339 AT_KEYWORDS([segment])
1340 AT_DATA([input], [dnl
1345 AT_DATA([expout-base], [dnl
1346 identifier define space
1352 macro_body content_line_1
1355 macro_body content_line_2
1356 -newline \n (DEFINE)
1360 PSPP_CHECK_SEGMENT([-i])
1363 AT_SETUP([batch mode])
1364 AT_KEYWORDS([segment])
1365 AT_DATA([input], [dnl
1367 another line of first command
1374 AT_DATA([expout-base], [dnl
1375 identifier first space
1380 identifier another space
1381 identifier line space
1383 identifier first space
1389 identifier second space
1394 identifier third space
1401 identifier fourth space
1407 identifier fifth space
1414 PSPP_CHECK_SEGMENT([-b])
1417 AT_SETUP([auto mode])
1418 AT_KEYWORDS([segment])
1419 AT_DATA([input], [dnl
1421 another line of command
1424 another line of second command
1434 AT_DATA([expout-base], [dnl
1439 identifier another space
1440 identifier line space
1452 identifier another space
1456 identifier another space
1457 identifier line space
1459 identifier second space
1464 identifier data space
1465 identifier list space
1472 identifier aggregate
1476 identifier print space
1481 identifier twostep space
1491 identifier fourth space
1497 identifier fifth space
1504 PSPP_CHECK_SEGMENT([-a])