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])
358 AT_SETUP([positive numbers])
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])
427 AT_SETUP([negative numbers])
428 AT_KEYWORDS([segment])
429 AT_DATA([input], [dnl
431 -123. /* comment 1 */ /* comment 2 */
432 -.1 -0.1 -00.1 -00.10
433 -5e1 -6E-1 -7e+1 -6E+01 -6e-03
434 -.3E1 -.4e-1 -.5E+1 -.6e+01 -.7E-03
435 -1.23e1 -45.6E-1 -78.9e+1 -99.9E+01 -11.2e-03
437 -. -1e -e1 -1e+ -1e- -1.
439 AT_DATA([expout-base], [dnl
451 comment /*_comment_1_*/ space
452 comment /*_comment_2_*/
476 number -45.6E-1 space
477 number -78.9e+1 space
478 number -99.9E+01 space
489 expected_exponent -1e space
492 expected_exponent -1e+ space
493 expected_exponent -1e- space
500 PSPP_CHECK_SEGMENT([-i])
505 AT_KEYWORDS([segment])
506 AT_DATA([input], [dnl
508 'Don''t' "Can't" 'Won''t'
509 """quoted""" '"quoted"'
512 "missing double quote
516 + /* comment */ 'string continuation'
517 + /* also a punctuator on blank line
520 AT_DATA([expout-base], [dnl
521 quoted_string 'x' space
522 quoted_string "y" space
526 quoted_string 'Don''t' space
527 quoted_string "Can't" space
528 quoted_string 'Won''t'
531 quoted_string """quoted""" space
532 quoted_string '"quoted"'
535 quoted_string '' space
539 expected_quote 'missing_end_quote
542 expected_quote "missing_double_quote
545 hex_string x"4142" space
549 unicode_string u'fffd' space
550 unicode_string U"041"
553 start_command + space
559 comment /*_comment_*/ space
560 quoted_string 'string_continuation'
564 comment /*_also_a_punctuator_on_blank_line
567 start_command - space
568 quoted_string 'new_command'
573 PSPP_CHECK_SEGMENT([-i])
576 AT_SETUP([@%:@! construct])
577 AT_KEYWORDS([segment])
578 AT_DATA([input], [dnl
583 AT_DATA([expout-base], [dnl
584 shbang #!_/usr/bin/pspp
587 identifier title space
605 PSPP_CHECK_SEGMENT([-i])
608 AT_SETUP([* and COMMENT commands])
609 AT_KEYWORDS([segment])
610 AT_DATA([input], [dnl
611 * Comment commands "don't
612 have to contain valid tokens.
614 ** Check ambiguity with ** token.
617 comment keyword works too.
619 com is ambiguous with COMPUTE.
621 * Comment need not start at left margin.
623 * Comment ends with blank line
628 AT_DATA([expout-base], [dnl
629 comment_command *_Comment_commands_"don't
632 comment_command have_to_contain_valid_tokens
639 comment_command **_Check_ambiguity_with_**_token
643 comment_command ****************
650 comment_command comment_keyword_works_too
654 comment_command COMM_also
660 identifier ambiguous space
661 reserved_word with space
670 comment_command *_Comment_need_not_start_at_left_margin
677 comment_command *_Comment_ends_with_blank_line
683 identifier next space
693 PSPP_CHECK_SEGMENT([-i])
696 AT_SETUP([DOCUMENT command])
697 AT_KEYWORDS([segment])
698 AT_DATA([input], [dnl
706 isn't parsed as tokens
710 AT_DATA([expout-base], [dnl
712 document DOCUMENT_one_line.
719 newline \n (DOCUMENT)
722 newline \n (DOCUMENT)
725 newline \n (DOCUMENT)
727 document ____________line.
734 newline \n (DOCUMENT)
736 document first.paragraph
737 newline \n (DOCUMENT)
739 document isn't_parsed_as_tokens
740 newline \n (DOCUMENT)
743 newline \n (DOCUMENT)
745 document second_paragraph.
752 PSPP_CHECK_SEGMENT([-i])
755 AT_SETUP([FILE LABEL command])
756 AT_KEYWORDS([segment])
757 AT_DATA([input], [dnl
758 FIL label isn't quoted.
762 /**/ lab not quoted here either
765 AT_DATA([expout-base], [dnl
767 identifier label space
768 unquoted_string isn't_quoted
777 quoted_string 'is_quoted'
781 identifier FILE space
788 unquoted_string not_quoted_here_either
796 PSPP_CHECK_SEGMENT([-i])
799 AT_SETUP([BEGIN DATA command])
800 AT_KEYWORDS([segment])
801 AT_DATA([input], [dnl
826 AT_DATA([expout-base], [dnl
827 identifier begin space
840 identifier begin space
866 inline_data 5_6_7_/*_x
872 inline_data end__data
903 identifier begin space
904 identifier data space
909 identifier begin space
910 identifier data space
915 reserved_word not space
921 PSPP_CHECK_SEGMENT([-i])
924 AT_SETUP([DO REPEAT command])
925 AT_KEYWORDS([segment])
926 AT_DATA([input], [dnl
929 do repeat a=1 thru 5.
933 end /* x */ /* y */ repeat print.
941 AT_DATA([expout-base], [dnl
943 identifier repeat space
958 newline \n (DO REPEAT)
960 do_repeat_command __do_repeat_a=1_thru_5.
961 newline \n (DO REPEAT)
963 do_repeat_command another_command.
964 newline \n (DO REPEAT)
966 do_repeat_command second_command
967 newline \n (DO REPEAT)
969 do_repeat_command +_third_command.
970 newline \n (DO REPEAT)
972 do_repeat_command end_/*_x_*/_/*_y_*/_repeat_print.
973 newline \n (DO REPEAT)
986 identifier repeat space
991 newline \n (DO REPEAT)
993 do_repeat_command __inner_command.
994 newline \n (DO REPEAT)
1003 PSPP_CHECK_SEGMENT([-i])
1006 AT_SETUP([DO REPEAT command in batch mode])
1007 AT_KEYWORDS([segment])
1008 AT_DATA([input], [dnl
1011 do repeat a=1 thru 5
1015 end /* x */ /* y */ repeat print
1024 AT_DATA([expout-base], [dnl
1026 identifier repeat space
1043 do_repeat_command do_repeat_a=1_thru_5
1044 newline \n (DO REPEAT)
1046 do_repeat_command another_command
1047 newline \n (DO REPEAT)
1049 do_repeat_command second_command
1050 newline \n (DO REPEAT)
1052 do_repeat_command +_third_command
1053 newline \n (DO REPEAT)
1055 do_repeat_command end_/*_x_*/_/*_y_*/_repeat_print
1056 newline \n (DO REPEAT)
1069 identifier repeat space
1076 newline \n (DO REPEAT)
1078 do_repeat_command __inner_command
1079 newline \n (DO REPEAT)
1081 identifier end space
1087 PSPP_CHECK_SEGMENT([-b])
1090 AT_SETUP([DEFINE command - simple])
1091 AT_KEYWORDS([segment])
1092 AT_DATA([input], [dnl
1094 var1 var2 var3 "!enddefine"
1097 AT_DATA([expout-base], [dnl
1098 identifier define space
1105 macro_body var1_var2_var3_"!enddefine"
1114 PSPP_CHECK_SEGMENT([-i])
1117 AT_SETUP([DEFINE command - no newline after parentheses])
1118 AT_KEYWORDS([segment])
1119 AT_DATA([input], [dnl
1120 define !macro1() var1 var2 var3 /* !enddefine
1123 AT_DATA([expout-base], [dnl
1124 identifier define space
1128 macro_body _var1_var2_var3_/*_!enddefine
1137 PSPP_CHECK_SEGMENT([-i])
1140 AT_SETUP([DEFINE command - no newline before !ENDDEFINE])
1141 AT_KEYWORDS([segment ENDDEFINE])
1142 AT_DATA([input], [dnl
1144 var1 var2 var3!enddefine.
1146 AT_DATA([expout-base], [dnl
1147 identifier define space
1154 macro_body var1_var2_var3
1161 PSPP_CHECK_SEGMENT([-i])
1164 AT_SETUP([DEFINE command - all on one line])
1165 AT_KEYWORDS([segment])
1166 AT_DATA([input], [dnl
1167 define !macro1()var1 var2 var3!enddefine.
1169 AT_DATA([expout-base], [dnl
1170 identifier define space
1174 macro_body var1_var2_var3
1181 PSPP_CHECK_SEGMENT([-i])
1184 AT_SETUP([DEFINE command - empty])
1185 AT_KEYWORDS([segment])
1186 AT_DATA([input], [dnl
1190 AT_DATA([expout-base], [dnl
1191 identifier define space
1204 PSPP_CHECK_SEGMENT([-i])
1207 AT_SETUP([DEFINE command - blank lines])
1208 AT_KEYWORDS([segment])
1209 AT_DATA([input], [dnl
1215 AT_DATA([expout-base], [dnl
1216 identifier define space
1235 PSPP_CHECK_SEGMENT([-i])
1238 AT_SETUP([DEFINE command - arguments])
1239 AT_KEYWORDS([segment])
1240 AT_DATA([input], [dnl
1241 define !macro1(a(), b(), c())
1244 AT_DATA([expout-base], [dnl
1245 identifier define space
1269 PSPP_CHECK_SEGMENT([-i])
1272 AT_SETUP([DEFINE command - multiline arguments])
1273 AT_KEYWORDS([segment])
1274 AT_DATA([input], [dnl
1282 AT_DATA([expout-base], [dnl
1283 identifier define space
1318 PSPP_CHECK_SEGMENT([-i])
1321 AT_SETUP([DEFINE command - arguments start on second line])
1322 AT_KEYWORDS([segment])
1323 AT_DATA([input], [dnl
1331 AT_DATA([expout-base], [dnl
1332 identifier define space
1348 macro_body content_1
1351 macro_body content_2
1360 PSPP_CHECK_SEGMENT([-i])
1363 AT_SETUP([DEFINE command - early end of command 1])
1364 AT_KEYWORDS([segment])
1365 AT_DATA([input], [dnl
1369 AT_DATA([expout-base], [dnl
1370 identifier define space
1375 identifier data space
1376 identifier list space
1385 PSPP_CHECK_SEGMENT([-i])
1388 AT_SETUP([DEFINE command - early end of command 2])
1389 AT_KEYWORDS([segment])
1390 AT_DATA([input], [dnl
1395 AT_DATA([expout-base], [dnl
1396 identifier define space
1404 identifier data space
1405 identifier list space
1414 PSPP_CHECK_SEGMENT([-i])
1417 AT_SETUP([DEFINE command - early end of command 3])
1418 AT_KEYWORDS([segment])
1419 AT_DATA([input], [dnl
1424 AT_DATA([expout-base], [dnl
1425 identifier define space
1435 identifier data space
1436 identifier list space
1445 PSPP_CHECK_SEGMENT([-i])
1448 AT_SETUP([DEFINE command - early end of command 4])
1449 AT_KEYWORDS([segment])
1450 AT_DATA([input], [dnl
1451 dnl Notice the command terminator at the end of the DEFINE command,
1452 dnl which should not be there and ends it early.
1456 AT_DATA([expout-base], [dnl
1457 identifier define space
1462 identifier data space
1463 identifier list space
1472 PSPP_CHECK_SEGMENT([-i])
1475 AT_SETUP([DEFINE command - missing !ENDDEFINE])
1476 AT_KEYWORDS([segment])
1477 AT_DATA([input], [dnl
1482 AT_DATA([expout-base], [dnl
1483 identifier define space
1490 macro_body content_line_1
1493 macro_body content_line_2
1494 -newline \n (DEFINE)
1498 PSPP_CHECK_SEGMENT([-i])
1501 AT_SETUP([batch mode])
1502 AT_KEYWORDS([segment])
1503 AT_DATA([input], [dnl
1505 another line of first command
1512 AT_DATA([expout-base], [dnl
1513 identifier first space
1518 identifier another space
1519 identifier line space
1521 identifier first space
1527 identifier second space
1532 identifier third space
1539 identifier fourth space
1545 identifier fifth space
1552 PSPP_CHECK_SEGMENT([-b])
1555 AT_SETUP([auto mode])
1556 AT_KEYWORDS([segment])
1557 AT_DATA([input], [dnl
1559 another line of command
1562 another line of second command
1572 AT_DATA([expout-base], [dnl
1577 identifier another space
1578 identifier line space
1590 identifier another space
1594 identifier another space
1595 identifier line space
1597 identifier second space
1602 identifier data space
1603 identifier list space
1610 identifier aggregate
1614 identifier print space
1619 identifier twostep space
1629 identifier fourth space
1635 identifier fifth space
1642 PSPP_CHECK_SEGMENT([-a])