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 ~&|=>=><=<~=<>(),-+*/[[]]**
191 AT_DATA([expout-base], [dnl
255 PSPP_CHECK_SCAN([-i])
260 AT_DATA([input], [dnl
262 123. /* comment 1 */ /* comment 2 */
264 5e1 6E-1 7e+1 6E+01 6e-03
265 .3E1 .4e-1 .5E+1 .6e+01 .7E-03
266 1.23e1 45.6E-1 78.9e+1 99.9E+01 11.2e-03
269 AT_DATA([expout-base], [dnl
330 EXPECTED_EXPONENT "1e"
334 EXPECTED_EXPONENT "1e+"
336 EXPECTED_EXPONENT "1e-"
340 PSPP_CHECK_SCAN([-i])
345 AT_DATA([input], [dnl
347 'Don''t' "Can't" 'Won''t'
348 """quoted""" '"quoted"'
351 "missing double quote
354 'a' /* abc */ + "b" /*
355 + 'c' +/* */"d"/* */+'e'
357 + /* special case: + in column 0 would ordinarily start a new command
374 "abc"+U"FFFD"+u'3048'+"xyz"
376 AT_DATA([expout-base], [dnl
435 PSPP_CHECK_SCAN([-i])
438 AT_SETUP([@%:@! construct])
440 AT_DATA([input], [dnl
444 AT_DATA([expout-base], [dnl
459 PSPP_CHECK_SCAN([-i])
462 AT_SETUP([* and COMMENT commands])
464 AT_DATA([input], [dnl
465 * Comment commands "don't
466 have to contain valid tokens.
468 ** Check ambiguity with ** token.
471 comment keyword works too.
473 com is ambiguous with COMPUTE.
475 * Comment need not start at left margin.
477 * Comment ends with blank line
482 AT_DATA([expout-base], [dnl
536 PSPP_CHECK_SCAN([-i])
539 AT_SETUP([DOCUMENT command])
541 AT_DATA([input], [dnl
549 isn't parsed as tokens
553 AT_DATA([expout-base], [dnl
555 STRING "DOCUMENT one line."
573 STRING "first.paragraph"
575 STRING "isn't parsed as tokens"
579 STRING "second paragraph."
585 PSPP_CHECK_SCAN([-i])
588 AT_SETUP([TITLE, SUBTITLE, FILE LABEL commands])
590 AT_DATA([input], [dnl
591 title/**/'Quoted string title'.
593 "Quoted string on second line".
594 sub "Quoted string subtitle"
597 TITL /* Not a */ quoted string title.
598 SUBT Not a quoted string /* subtitle
600 FIL label isn't quoted.
604 /**/ lab not quoted here either
607 AT_DATA([expout-base], [dnl
610 STRING "Quoted string title"
617 STRING "Quoted string on second line"
622 STRING "Quoted string subtitle"
631 STRING "/* Not a */ quoted string title"
636 STRING "Not a quoted string /* subtitle"
644 STRING "isn't quoted"
663 STRING "not quoted here either"
669 PSPP_CHECK_SCAN([-i])
672 AT_SETUP([BEGIN DATA command])
674 AT_DATA([input], [dnl
687 AT_DATA([expout-base], [dnl
726 PSPP_CHECK_SCAN([-i])
729 AT_SETUP([DO REPEAT command])
731 AT_DATA([input], [dnl
734 do repeat a=1 thru 5.
738 end /* x */ /* y */ repeat print.
742 AT_DATA([expout-base], [dnl
765 STRING " do repeat a=1 thru 5."
767 STRING "another command."
769 STRING "second command"
771 STRING "+ third command."
773 STRING "end /* x */ /* y */ repeat print."
783 PSPP_CHECK_SCAN([-i])
786 AT_SETUP([DO REPEAT command in batch mode])
788 AT_DATA([input], [dnl
795 end /* x */ /* y */ repeat print
804 AT_DATA([expout-base], [dnl
827 STRING "do repeat a=1 thru 5"
829 STRING "another command"
831 STRING "second command"
833 STRING "+ third command"
835 STRING "end /* x */ /* y */ repeat print"
854 STRING " inner command"
862 PSPP_CHECK_SCAN([-b])
865 AT_SETUP([batch mode])
867 AT_DATA([input], [dnl
869 another line of first command
876 AT_DATA([expout-base], [dnl
918 PSPP_CHECK_SCAN([-b])