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
899 STRING "var1 var2 var3"
901 MACRO_ID "!enddefine"
906 PSPP_CHECK_SCAN([-i])
909 AT_SETUP([DEFINE command - no newline after parentheses])
911 AT_DATA([input], [dnl
912 define !macro1() var1 var2 var3
915 AT_DATA([expout-base], [dnl
921 STRING " var1 var2 var3"
923 MACRO_ID "!enddefine"
928 PSPP_CHECK_SCAN([-i])
931 AT_SETUP([DEFINE command - no newline before !ENDDEFINE])
932 AT_KEYWORDS([scan ENDDEFINE])
933 AT_DATA([input], [dnl
935 var1 var2 var3!enddefine.
937 AT_DATA([expout-base], [dnl
945 STRING "var1 var2 var3"
946 MACRO_ID "!enddefine"
951 PSPP_CHECK_SCAN([-i])
954 AT_SETUP([DEFINE command - all on one line])
956 AT_DATA([input], [dnl
957 define !macro1()var1 var2 var3!enddefine.
959 AT_DATA([expout-base], [dnl
965 STRING "var1 var2 var3"
966 MACRO_ID "!enddefine"
971 PSPP_CHECK_SCAN([-i])
974 AT_SETUP([DEFINE command - empty])
976 AT_DATA([input], [dnl
980 AT_DATA([expout-base], [dnl
988 MACRO_ID "!enddefine"
993 PSPP_CHECK_SCAN([-i])
996 AT_SETUP([DEFINE command - arguments])
998 AT_DATA([input], [dnl
999 define !macro1(a(), b(), c())
1002 AT_DATA([expout-base], [dnl
1023 MACRO_ID "!enddefine"
1028 PSPP_CHECK_SCAN([-i])
1031 AT_SETUP([DEFINE command - multiline arguments])
1033 AT_DATA([input], [dnl
1041 AT_DATA([expout-base], [dnl
1068 MACRO_ID "!enddefine"
1073 PSPP_CHECK_SCAN([-i])
1076 AT_SETUP([DEFINE command - arguments start on second line])
1078 AT_DATA([input], [dnl
1086 AT_DATA([expout-base], [dnl
1105 MACRO_ID "!enddefine"
1110 PSPP_CHECK_SCAN([-i])
1113 AT_SETUP([DEFINE command - early end of command 1])
1115 AT_DATA([input], [dnl
1119 AT_DATA([expout-base], [dnl
1137 PSPP_CHECK_SCAN([-i])
1140 AT_SETUP([DEFINE command - early end of command 2])
1142 AT_DATA([input], [dnl
1147 AT_DATA([expout-base], [dnl
1167 PSPP_CHECK_SCAN([-i])
1170 AT_SETUP([DEFINE command - early end of command 3])
1172 AT_DATA([input], [dnl
1177 AT_DATA([expout-base], [dnl
1199 PSPP_CHECK_SCAN([-i])
1202 AT_SETUP([DEFINE command - early end of command 4])
1203 AT_KEYWORDS([segment])
1204 AT_DATA([input], [dnl
1205 dnl Notice the command terminator at the end of the DEFINE command,
1206 dnl which should not be there and ends it early.
1210 AT_DATA([expout-base], [dnl
1228 PSPP_CHECK_SCAN([-i])
1231 AT_SETUP([DEFINE command - missing !ENDDEFINE])
1233 AT_DATA([input], [dnl
1238 AT_DATA([expout-base], [dnl
1246 STRING "content line 1"
1248 STRING "content line 2"
1252 PSPP_CHECK_SCAN([-i])
1255 AT_SETUP([batch mode])
1257 AT_DATA([input], [dnl
1259 another line of first command
1266 AT_DATA([expout-base], [dnl
1308 PSPP_CHECK_SCAN([-b])