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 scanning])
18 m4_define([PSPP_CHECK_SCAN],
19 [sed 's/^-//' < expout-base > expout
20 AT_CHECK([scan-test $1 input], [0], [expout])
22 sed '/^-/d' < expout-base > expout
23 AT_CHECK([scan-test -s $1 input], [0], [expout])])
25 AT_SETUP([identifiers])
28 a aB i5 $x @efg @@. !abcd #.# .x _z.
30 QRSTUV./* end of line comment */
31 QrStUv./* end of line comment */ @&t@
32 WXYZ. /* unterminated end of line comment
33 �. /* U+FFFD is not valid in an identifier
35 AT_DATA([expout-base], [dnl
88 AT_SETUP([reserved words])
91 and or not eq ge gt le lt ne all by to with
92 AND OR NOT EQ GE GT LE LT NE ALL BY TO WITH
93 andx orx notx eqx gex gtx lex ltx nex allx byx tox withx
96 AT_DATA([expout-base], [dnl
182 PSPP_CHECK_SCAN([-i])
185 AT_SETUP([punctuation])
187 AT_DATA([input], [dnl
188 ~ & | = >= > <= < ~= <> ( ) , - + * / [[ ]] **
189 ~&|=>=><=<~=<>(),-+*/[[]]**
192 AT_DATA([expout-base], [dnl
274 PSPP_CHECK_SCAN([-i])
279 AT_DATA([input], [dnl
281 123. /* comment 1 */ /* comment 2 */
283 5e1 6E-1 7e+1 6E+01 6e-03
284 .3E1 .4e-1 .5E+1 .6e+01 .7E-03
285 1.23e1 45.6E-1 78.9e+1 99.9E+01 11.2e-03
288 AT_DATA([expout-base], [dnl
349 EXPECTED_EXPONENT "1e"
353 EXPECTED_EXPONENT "1e+"
355 EXPECTED_EXPONENT "1e-"
359 PSPP_CHECK_SCAN([-i])
364 AT_DATA([input], [dnl
366 'Don''t' "Can't" 'Won''t'
367 """quoted""" '"quoted"'
370 "missing double quote
373 'a' /* abc */ + "b" /*
374 + 'c' +/* */"d"/* */+'e'
376 + /* special case: + in column 0 would ordinarily start a new command
393 "abc"+U"FFFD"+u'3048'+"xyz"
395 AT_DATA([expout-base], [dnl
454 PSPP_CHECK_SCAN([-i])
457 AT_SETUP([@%:@! construct])
459 AT_DATA([input], [dnl
463 AT_DATA([expout-base], [dnl
478 PSPP_CHECK_SCAN([-i])
481 AT_SETUP([* and COMMENT commands])
483 AT_DATA([input], [dnl
484 * Comment commands "don't
485 have to contain valid tokens.
487 ** Check ambiguity with ** token.
490 comment keyword works too.
492 com is ambiguous with COMPUTE.
494 * Comment need not start at left margin.
496 * Comment ends with blank line
501 AT_DATA([expout-base], [dnl
555 PSPP_CHECK_SCAN([-i])
558 AT_SETUP([DOCUMENT command])
560 AT_DATA([input], [dnl
568 isn't parsed as tokens
572 AT_DATA([expout-base], [dnl
574 STRING "DOCUMENT one line."
592 STRING "first.paragraph"
594 STRING "isn't parsed as tokens"
598 STRING "second paragraph."
604 PSPP_CHECK_SCAN([-i])
607 AT_SETUP([TITLE, SUBTITLE, FILE LABEL commands])
609 AT_DATA([input], [dnl
610 title/**/'Quoted string title'.
612 "Quoted string on second line".
613 sub "Quoted string subtitle"
616 TITL /* Not a */ quoted string title.
617 SUBT Not a quoted string /* subtitle
619 FIL label isn't quoted.
623 /**/ lab not quoted here either
626 AT_DATA([expout-base], [dnl
629 STRING "Quoted string title"
636 STRING "Quoted string on second line"
641 STRING "Quoted string subtitle"
650 STRING "/* Not a */ quoted string title"
655 STRING "Not a quoted string /* subtitle"
663 STRING "isn't quoted"
682 STRING "not quoted here either"
688 PSPP_CHECK_SCAN([-i])
691 AT_SETUP([BEGIN DATA command])
693 AT_DATA([input], [dnl
706 AT_DATA([expout-base], [dnl
745 PSPP_CHECK_SCAN([-i])
748 AT_SETUP([DO REPEAT command])
750 AT_DATA([input], [dnl
753 do repeat a=1 thru 5.
757 end /* x */ /* y */ repeat print.
761 AT_DATA([expout-base], [dnl
784 STRING " do repeat a=1 thru 5."
786 STRING "another command."
788 STRING "second command"
790 STRING "+ third command."
792 STRING "end /* x */ /* y */ repeat print."
802 PSPP_CHECK_SCAN([-i])
805 AT_SETUP([DO REPEAT command in batch mode])
807 AT_DATA([input], [dnl
814 end /* x */ /* y */ repeat print
823 AT_DATA([expout-base], [dnl
846 STRING "do repeat a=1 thru 5"
848 STRING "another command"
850 STRING "second command"
852 STRING "+ third command"
854 STRING "end /* x */ /* y */ repeat print"
873 STRING " inner command"
881 PSPP_CHECK_SCAN([-b])
884 AT_SETUP([DEFINE command - simple])
886 AT_DATA([input], [dnl
891 AT_DATA([expout-base], [dnl
898 STRING "var1 var2 var3"
900 MACRO_ID "!enddefine"
905 PSPP_CHECK_SCAN([-i])
908 AT_SETUP([DEFINE command - empty])
910 AT_DATA([input], [dnl
914 AT_DATA([expout-base], [dnl
921 MACRO_ID "!enddefine"
926 PSPP_CHECK_SCAN([-i])
929 AT_SETUP([DEFINE command - arguments])
931 AT_DATA([input], [dnl
932 define !macro1(a(), b(), c())
935 AT_DATA([expout-base], [dnl
955 MACRO_ID "!enddefine"
960 PSPP_CHECK_SCAN([-i])
963 AT_SETUP([DEFINE command - multiline arguments])
965 AT_DATA([input], [dnl
973 AT_DATA([expout-base], [dnl
999 MACRO_ID "!enddefine"
1004 PSPP_CHECK_SCAN([-i])
1007 AT_SETUP([DEFINE command - arguments start on second line])
1009 AT_DATA([input], [dnl
1017 AT_DATA([expout-base], [dnl
1035 MACRO_ID "!enddefine"
1040 PSPP_CHECK_SCAN([-i])
1043 AT_SETUP([DEFINE command - early end of command 1])
1045 AT_DATA([input], [dnl
1049 AT_DATA([expout-base], [dnl
1067 PSPP_CHECK_SCAN([-i])
1070 AT_SETUP([DEFINE command - early end of command 2])
1072 AT_DATA([input], [dnl
1077 AT_DATA([expout-base], [dnl
1097 PSPP_CHECK_SCAN([-i])
1100 AT_SETUP([DEFINE command - early end of command 3])
1102 AT_DATA([input], [dnl
1107 AT_DATA([expout-base], [dnl
1129 PSPP_CHECK_SCAN([-i])
1132 AT_SETUP([DEFINE command - missing !ENDDEFINE])
1134 AT_DATA([input], [dnl
1139 AT_DATA([expout-base], [dnl
1147 STRING "content line 1"
1149 STRING "content line 2"
1153 PSPP_CHECK_SCAN([-i])
1156 AT_SETUP([batch mode])
1158 AT_DATA([input], [dnl
1160 another line of first command
1167 AT_DATA([expout-base], [dnl
1209 PSPP_CHECK_SCAN([-b])