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/>.
16 dnl AT_BANNER([syntax segmentation])
17 m4_define([PSPP_CHECK_SEGMENT],
18 [AT_CHECK([segment-test $1 input], [0], [expout])
19 AT_CHECK([segment-test -1 $1 input], [0], [expout])
20 AT_CHECK([segment-test -0 $1 input])
21 AT_CHECK([segment-test -01 $1 input])])
23 AT_SETUP([identifiers])
24 AT_KEYWORDS([segment])
30 grève@<00A0>@Ângstrom@<00A0>@poté
38 AT_DATA([expout], [dnl
83 identifier #12345 space
103 PSPP_CHECK_SEGMENT([-i])
106 AT_SETUP([identifiers that end in '.'])
107 AT_KEYWORDS([segment])
108 AT_DATA([input], [dnl
120 QRSTUV./* end of line comment */
121 qrstuv. /* end of line comment */
122 QrStUv./* end of line comment */ @&t@
123 wxyz./* unterminated end of line comment
124 WXYZ. /* unterminated end of line comment
125 WxYz./* unterminated end of line comment @&t@
127 AT_DATA([expout], [dnl
128 identifier abcd. space
133 identifier ABCD. space
138 identifier aBcD. space
170 start_command . space
179 comment /*_end_of_line_comment_*/
184 comment /*_end_of_line_comment_*/
189 comment /*_end_of_line_comment_*/ space
194 comment /*_unterminated_end_of_line_comment
199 comment /*_unterminated_end_of_line_comment
204 comment /*_unterminated_end_of_line_comment_
209 PSPP_CHECK_SEGMENT([-i])
212 AT_SETUP([reserved words])
213 AT_KEYWORDS([segment])
214 AT_DATA([input], [dnl
215 and or not eq ge gt le lt ne all by to with
216 AND OR NOT EQ GE GT LE LT NE ALL BY TO WITH
217 andx orx notx eqx gex gtx lex ltx nex allx byx tox withx
220 AT_DATA([expout], [dnl
221 reserved_word and space
222 reserved_word or space
223 reserved_word not space
224 reserved_word eq space
225 reserved_word ge space
226 reserved_word gt space
227 reserved_word le space
228 reserved_word lt space
229 reserved_word ne space
230 reserved_word all space
231 reserved_word by space
232 reserved_word to space
236 reserved_word AND space
237 reserved_word OR space
238 reserved_word NOT space
239 reserved_word EQ space
240 reserved_word GE space
241 reserved_word GT space
242 reserved_word LE space
243 reserved_word LT space
244 reserved_word NE space
245 reserved_word ALL space
246 reserved_word BY space
247 reserved_word TO space
251 identifier andx space
253 identifier notx space
260 identifier allx space
266 identifier and. space
273 PSPP_CHECK_SEGMENT([-i])
276 AT_SETUP([punctuation])
277 AT_KEYWORDS([segment])
278 AT_DATA([input], [dnl
279 ~ & | = >= > <= < ~= <> ( ) , - + * / [[ ]] **
280 ~&|=>=><=<~=<>(),-+*/[[]]**
282 AT_DATA([expout], [dnl
329 PSPP_CHECK_SEGMENT([-i])
333 AT_KEYWORDS([segment])
334 AT_DATA([input], [dnl
336 123. /* comment 1 */ /* comment 2 */
338 5e1 6E-1 7e+1 6E+01 6e-03
339 .3E1 .4e-1 .5E+1 .6e+01 .7E-03
340 1.23e1 45.6E-1 78.9e+1 99.9E+01 11.2e-03
343 AT_DATA([expout], [dnl
354 comment /*_comment_1_*/ space
355 comment /*_comment_2_*/
383 number 99.9E+01 space
387 start_command . space
388 expected_exponent 1e space
390 expected_exponent 1e+ space
391 expected_exponent 1e-
396 PSPP_CHECK_SEGMENT([-i])
400 AT_KEYWORDS([segment])
401 AT_DATA([input], [dnl
403 'Don''t' "Can't" 'Won''t'
404 """quoted""" '"quoted"'
407 "missing double quote
411 + /* comment */ 'string continuation'
412 + /* also a punctuator on blank line
415 AT_DATA([expout], [dnl
416 quoted_string 'x' space
417 quoted_string "y" space
421 quoted_string 'Don''t' space
422 quoted_string "Can't" space
423 quoted_string 'Won''t'
426 quoted_string """quoted""" space
427 quoted_string '"quoted"'
430 quoted_string '' space
434 expected_quote 'missing_end_quote
437 expected_quote "missing_double_quote
440 hex_string x"4142" space
444 unicode_string u'fffd' space
445 unicode_string U"041"
448 start_command + space
454 comment /*_comment_*/ space
455 quoted_string 'string_continuation'
459 comment /*_also_a_punctuator_on_blank_line
462 start_command - space
463 quoted_string 'new_command'
468 PSPP_CHECK_SEGMENT([-i])
471 AT_SETUP([@%:@! construct])
472 AT_KEYWORDS([segment])
473 AT_DATA([input], [dnl
478 AT_DATA([expout], [dnl
479 shbang #!_/usr/bin/pspp
482 identifier title space
483 unquoted_string my_title
488 unexpected_char ! space
499 PSPP_CHECK_SEGMENT([-i])
502 AT_SETUP([* and COMMENT commands])
503 AT_KEYWORDS([segment])
504 AT_DATA([input], [dnl
505 * Comment commands "don't
506 have to contain valid tokens.
508 ** Check ambiguity with ** token.
511 comment keyword works too.
513 com is ambiguous with COMPUTE.
515 * Comment need not start at left margin.
517 * Comment ends with blank line
522 AT_DATA([expout], [dnl
523 comment_command *_Comment_commands_"don't
526 comment_command have_to_contain_valid_tokens
533 comment_command **_Check_ambiguity_with_**_token
537 comment_command ****************
544 comment_command comment_keyword_works_too
548 comment_command COMM_also
554 identifier ambiguous space
555 reserved_word with space
564 comment_command *_Comment_need_not_start_at_left_margin
571 comment_command *_Comment_ends_with_blank_line
577 identifier next space
587 PSPP_CHECK_SEGMENT([-i])
590 AT_SETUP([DOCUMENT command])
591 AT_KEYWORDS([segment])
592 AT_DATA([input], [dnl
600 isn't parsed as tokens
604 AT_DATA([expout], [dnl
606 document DOCUMENT_one_line.
613 newline \n (DOCUMENT)
616 newline \n (DOCUMENT)
619 newline \n (DOCUMENT)
621 document ____________line.
628 newline \n (DOCUMENT)
630 document first.paragraph
631 newline \n (DOCUMENT)
633 document isn't_parsed_as_tokens
634 newline \n (DOCUMENT)
637 newline \n (DOCUMENT)
639 document second_paragraph.
646 PSPP_CHECK_SEGMENT([-i])
649 AT_SETUP([TITLE, SUBTITLE, FILE LABEL commands])
650 AT_KEYWORDS([segment])
651 AT_DATA([input], [dnl
652 title/**/'Quoted string title'.
654 "Quoted string on second line".
655 sub "Quoted string subtitle"
658 TITL /* Not a */ quoted string title.
659 SUBT Not a quoted string /* subtitle
661 FIL label isn't quoted.
665 /**/ lab not quoted here either
668 AT_DATA([expout], [dnl
671 quoted_string 'Quoted_string_title'
679 quoted_string "Quoted_string_on_second_line"
684 quoted_string "Quoted_string_subtitle"
693 identifier TITL space
694 unquoted_string /*_Not_a_*/_quoted_string_title
698 identifier SUBT space
699 unquoted_string Not_a_quoted_string_/*_subtitle
706 identifier label space
707 unquoted_string isn't_quoted
716 quoted_string 'is_quoted'
720 identifier FILE space
727 unquoted_string not_quoted_here_either
735 PSPP_CHECK_SEGMENT([-i])
738 AT_SETUP([BEGIN DATA command])
739 AT_KEYWORDS([segment])
740 AT_DATA([input], [dnl
765 AT_DATA([expout], [dnl
766 identifier begin space
779 identifier begin space
805 inline_data 5_6_7_/*_x
811 inline_data end__data
842 identifier begin space
843 identifier data space
848 identifier begin space
849 identifier data space
854 reserved_word not space
860 PSPP_CHECK_SEGMENT([-i])
863 AT_SETUP([DO REPEAT command])
864 AT_KEYWORDS([segment])
865 AT_DATA([input], [dnl
868 do repeat a=1 thru 5.
872 end /* x */ /* y */ repeat print.
880 AT_DATA([expout], [dnl
882 identifier repeat space
897 newline \n (DO REPEAT)
899 do_repeat_command __do_repeat_a=1_thru_5.
900 newline \n (DO REPEAT)
902 do_repeat_command another_command.
903 newline \n (DO REPEAT)
905 do_repeat_command second_command
906 newline \n (DO REPEAT)
908 do_repeat_command +_third_command.
909 newline \n (DO REPEAT)
911 do_repeat_command end_/*_x_*/_/*_y_*/_repeat_print.
912 newline \n (DO REPEAT)
925 identifier repeat space
930 newline \n (DO REPEAT)
932 do_repeat_command __inner_command.
933 newline \n (DO REPEAT)
942 PSPP_CHECK_SEGMENT([-i])
945 AT_SETUP([batch mode])
946 AT_KEYWORDS([segment])
947 AT_DATA([input], [dnl
949 another line of first command
956 AT_DATA([expout], [dnl
957 identifier first space
962 identifier another space
963 identifier line space
965 identifier first space
971 identifier second space
976 identifier third space
983 identifier fourth space
989 identifier fifth space
996 PSPP_CHECK_SEGMENT([-b])
999 AT_SETUP([auto mode])
1000 AT_KEYWORDS([segment])
1001 AT_DATA([input], [dnl
1003 another line of command
1006 another line of second command
1016 AT_DATA([expout], [dnl
1021 identifier another space
1022 identifier line space
1034 identifier another space
1038 identifier another space
1039 identifier line space
1041 identifier second space
1046 identifier data space
1047 identifier list space
1054 identifier aggregate
1058 identifier print space
1063 identifier twostep space
1073 identifier fourth space
1079 identifier fifth space
1086 PSPP_CHECK_SEGMENT([-a])