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 nGeneral 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/>.
19 AT_SETUP([simple macro expansion])
20 AT_DATA([define.sps], [dnl
28 "a" "b" "c" 'a' 'b' 'c'.
34 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
39 "a" "b" "c" 'a' 'b' 'c'.
44 AT_SETUP([macro expansion - one !TOKENS(1) positional argument])
46 AT_DATA([define.sps], [dnl
47 DEFINE !t1(!positional=!tokens(1)) t1 (!1) !ENDDEFINE.
53 AT_CAPTURE_FILE([define.sps])
54 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
61 note: unexpanded token "b"
65 AT_SETUP([macro expansion with positional arguments])
66 AT_DATA([define.sps], [dnl
67 DEFINE !title(!positional !tokens(1)) !1 !ENDDEFINE.
68 DEFINE !t1(!positional !tokens(1)) t1 (!1) !ENDDEFINE.
69 DEFINE !t2(!positional !tokens(2)) t2 (!1) !ENDDEFINE.
71 DEFINE !ce(!positional=!charend('/')) ce (!1) !ENDDEFINE.
72 DEFINE !ce2(!positional=!charend('(')
73 /!positional !charend(')'))
77 DEFINE !e(!positional !enclose('{','}')) e (!1) !ENDDEFINE.
79 DEFINE !cmd(!positional !cmdend) cmd(!1) !ENDDEFINE.
80 DEFINE !cmd2(!positional !cmdend
81 /!positional !tokens(1))
85 DEFINE !p(!positional !tokens(1)
86 /!positional !tokens(1)
87 /!positional !tokens(1))
92 !title "!TOKENS(1) argument."
97 !title "!TOKENS(2) argument."
101 !title "!CHAREND argument."
107 !title "Two !CHAREND arguments."
111 !title "!ENCLOSE argument."
116 !title "!CMDEND argument."
121 !title "Three !TOKENS(1) arguments."
125 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
126 "!TOKENS(1) argument."
134 note: unexpanded token "b"
136 "!TOKENS(2) argument."
142 note: unexpanded token "d"
154 "Two !CHAREND arguments."
174 note: unexpanded token "7"
176 "Three !TOKENS(1) arguments."
180 p(1, -2, -3) (1 -2 -3)
184 AT_SETUP([macro call missing positional !TOKENS arguments])
185 AT_KEYWORDS([TOKENS])
186 AT_DATA([define.sps], [dnl
187 DEFINE !p(!positional !tokens(1) !default(x)
188 /!positional !tokens(1) !default(y)
189 /!positional !tokens(1) !default(z))
198 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
209 AT_SETUP([macro call incomplete positional !TOKENS arguments])
210 AT_KEYWORDS([TOKENS])
211 AT_DATA([define.sps], [dnl
212 DEFINE !p(!positional !tokens(2) !default(x)
213 /!positional !tokens(2) !default(y)
214 /!positional !tokens(2) !default(z))
218 !p a1 a2 b1 b2 c1 c2.
226 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
227 (a1 a2, b1 b2, c1 c2)
229 define.sps:8.18: error: DEBUG EXPAND: Reached end of command expecting 1 more
230 token in argument !3 to macro !p.
236 define.sps:10.12: error: DEBUG EXPAND: Reached end of command expecting 1 more
237 token in argument !2 to macro !p.
243 define.sps:12.6: error: DEBUG EXPAND: Reached end of command expecting 1 more
244 token in argument !1 to macro !p.
252 AT_SETUP([macro call empty positional !CHAREND arguments])
253 AT_KEYWORDS([CHAREND])
254 AT_DATA([define.sps], [dnl
255 DEFINE !p(!positional !charend(',') !default(x)
256 /!positional !charend(';') !default(y)
257 /!positional !charend(':') !default(z))
270 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
289 AT_SETUP([macro call missing positional !CHAREND arguments])
290 AT_DATA([define.sps], [dnl
291 DEFINE !p(!positional !charend(',') !default(x)
292 /!positional !charend(';') !default(y)
293 /!positional !charend(':') !default(z))
308 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
327 AT_SETUP([macro call incomplete positional !CHAREND arguments])
328 AT_KEYWORDS([CHAREND])
329 AT_DATA([define.sps], [dnl
330 DEFINE !p(!positional !charend(',') !default(x)
331 /!positional !charend(';') !default(y)
332 /!positional !charend(':') !default(z))
344 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
347 define.sps:8.9: error: DEBUG EXPAND: Reached end of command expecting ":" in
348 argument !3 to macro !p.
354 define.sps:10.7: error: DEBUG EXPAND: Reached end of command expecting ";" in
355 argument !2 to macro !p.
361 define.sps:12.5: error: DEBUG EXPAND: Reached end of command expecting "," in
362 argument !1 to macro !p.
370 AT_SETUP([macro call missing positional !ENCLOSE arguments])
371 AT_KEYWORDS([ENCLOSE])
372 AT_DATA([define.sps], [dnl
373 DEFINE !p(!positional !enclose('(',')') !default(x)
374 /!positional !enclose('<','>') !default(y)
375 /!positional !enclose('{','}') !default(z))
384 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
395 AT_SETUP([macro call incomplete positional !ENCLOSE arguments])
396 AT_KEYWORDS([ENCLOSE])
397 AT_DATA([define.sps], [dnl
398 DEFINE !p(!positional !enclose('(',')') !default(x)
399 /!positional !enclose('<','>') !default(y)
400 /!positional !enclose('{','}') !default(z))
415 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
418 define.sps:8.12: error: DEBUG EXPAND: Reached end of command expecting "}" in
419 argument !3 to macro !p.
423 define.sps:9.11: error: DEBUG EXPAND: Reached end of command expecting "}" in
424 argument !3 to macro !p.
430 define.sps:11.9: error: DEBUG EXPAND: Reached end of command expecting ">" in
431 argument !2 to macro !p.
435 define.sps:12.8: error: DEBUG EXPAND: Reached end of command expecting ">" in
436 argument !2 to macro !p.
442 define.sps:14.6: error: DEBUG EXPAND: Reached end of command expecting ")" in
443 argument !1 to macro !p.
447 define.sps:15.5: error: DEBUG EXPAND: Reached end of command expecting ")" in
448 argument !1 to macro !p.
456 AT_SETUP([keyword macro argument name with ! prefix])
457 AT_DATA([define.sps], [dnl
458 DEFINE !macro(!x !TOKENS(1).
460 AT_CHECK([pspp -O format=csv define.sps], [1], [dnl
461 "define.sps:1.15-1.16: error: DEFINE: Syntax error at `!x': Keyword macro parameter must be named in definition without ""!"" prefix."
465 AT_SETUP([reserved macro keyword argument name])
466 AT_DATA([define.sps], [dnl
467 DEFINE !macro(if=!TOKENS(1).
469 AT_CHECK([pspp -O format=csv define.sps], [1], [dnl
470 "define.sps:1.15-1.16: error: DEFINE: Syntax error at `if': Cannot use macro keyword ""if"" as an argument name."
474 AT_SETUP([macro expansion - one !TOKENS(1) keyword argument])
475 AT_KEYWORDS([TOKENS])
476 AT_DATA([define.sps], [dnl
477 DEFINE !k(arg1 = !TOKENS(1)) k(!arg1) !ENDDEFINE.
483 AT_CAPTURE_FILE([define.sps])
484 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
489 note: unexpanded token "y"
495 AT_SETUP([macro expansion - one !TOKENS(1) keyword argument - negative])
496 AT_KEYWORDS([TOKENS])
497 AT_DATA([define.sps], [dnl
498 DEFINE !k(arg1 !TOKENS(1)) k(!arg1) !ENDDEFINE.
503 AT_CAPTURE_FILE([define.sps])
504 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
505 define.sps:3.8: error: DEBUG EXPAND: Found `.' while expecting `=' reading
506 argument !arg1 to macro !k.
510 define.sps:4.9: error: DEBUG EXPAND: Reached end of command expecting 1 more
511 token in argument !arg1 to macro !k.
517 AT_SETUP([macro expansion - !CHAREND keyword arguments])
518 AT_KEYWORDS([CHAREND])
519 AT_DATA([define.sps], [dnl
520 DEFINE !k(arg1 = !CHAREND('/')
521 /arg2 = !CHAREND('/'))
530 AT_CAPTURE_FILE([define.sps])
531 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
542 AT_SETUP([macro expansion - !CHAREND keyword arguments - negative])
543 AT_KEYWORDS([CHAREND])
544 AT_DATA([define.sps], [dnl
545 DEFINE !k(arg1 = !CHAREND('/')
546 /arg2 = !CHAREND('/'))
555 AT_CAPTURE_FILE([define.sps])
556 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
557 define.sps:6.8: error: DEBUG EXPAND: Found `.' while expecting `=' reading
558 argument !arg1 to macro !k.
562 define.sps:7.9: error: DEBUG EXPAND: Reached end of command expecting "/" in
563 argument !arg1 to macro !k.
567 define.sps:8.10: error: DEBUG EXPAND: Reached end of command expecting "/" in
568 argument !arg1 to macro !k.
572 define.sps:9.18: error: DEBUG EXPAND: Reached end of command expecting "/" in
573 argument !arg2 to macro !k.
579 AT_SETUP([macro expansion - !ENCLOSE keyword arguments])
580 AT_KEYWORDS([ENCLOSE])
581 AT_DATA([define.sps], [dnl
582 DEFINE !k(arg1 = !ENCLOSE('(',')')
583 /arg2 = !ENCLOSE('{','}'))
587 !k arg1=(x) arg2={y}.
592 AT_CAPTURE_FILE([define.sps])
593 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
604 AT_SETUP([macro expansion - !ENCLOSE keyword arguments - negative])
605 AT_KEYWORDS([ENCLOSE])
606 AT_DATA([define.sps], [dnl
607 DEFINE !k(arg1 = !ENCLOSE('(',')')
608 /arg2 = !ENCLOSE('{','}'))
621 AT_CAPTURE_FILE([define.sps])
622 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
623 define.sps:6.8: error: DEBUG EXPAND: Found `.' while expecting `=' reading
624 argument !arg1 to macro !k.
628 define.sps:7.9: error: DEBUG EXPAND: Found `.' while expecting `@{:@' reading
629 argument !arg1 to macro !k.
633 define.sps:8.9: error: DEBUG EXPAND: Found `x' while expecting `@{:@' reading
634 argument !arg1 to macro !k.
638 note: unexpanded token "x"
640 define.sps:9.11: error: DEBUG EXPAND: Reached end of command expecting "@:}@" in
641 argument !arg1 to macro !k.
645 define.sps:10.17: error: DEBUG EXPAND: Found `.' while expecting `=' reading
646 argument !arg2 to macro !k.
650 define.sps:11.18: error: DEBUG EXPAND: Found `.' while expecting `{' reading
651 argument !arg2 to macro !k.
655 define.sps:12.18: error: DEBUG EXPAND: Found `y' while expecting `{' reading
656 argument !arg2 to macro !k.
660 note: unexpanded token "y"
662 define.sps:13.18: error: DEBUG EXPAND: Found `@{:@' while expecting `{' reading
663 argument !arg2 to macro !k.
667 note: unexpanded token "@{:@"
669 note: unexpanded token "y"
673 dnl Keep this test in sync with the examples for !BLANKS in the manual.
674 AT_SETUP([macro expansion - !BLANKS])
675 AT_KEYWORDS([BLANKS])
676 AT_DATA([define.sps], [dnl
690 AT_CAPTURE_FILE([define.sps])
691 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
703 dnl Keep this test in sync with the examples for !CONCAT in the manual.
704 AT_SETUP([macro expansion - !CONCAT])
705 AT_KEYWORDS([CONCAT])
706 AT_DATA([define.sps], [dnl
720 AT_CAPTURE_FILE([define.sps])
721 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
733 dnl Keep this test in sync with the examples for !EVAL in the manual.
734 AT_SETUP([macro expansion - !EVAL])
736 AT_DATA([define.sps], [dnl
737 DEFINE !vars() a b c !ENDDEFINE.
743 !QUOTE(!EVAL(!vars)).
746 DEFINE !e2(!positional !enclose('(',')'))
756 AT_CAPTURE_FILE([define.sps])
757 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
770 dnl Keep this test in sync with the examples for !HEAD in the manual.
771 AT_SETUP([macro expansion - !HEAD])
773 AT_DATA([define.sps], [dnl
783 AT_CAPTURE_FILE([define.sps])
784 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
792 dnl Keep this test in sync with the examples for !TAIL in the manual.
793 AT_SETUP([macro expansion - !TAIL])
795 AT_DATA([define.sps], [dnl
805 AT_CAPTURE_FILE([define.sps])
806 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
814 dnl Keep this test in sync with the examples for !INDEX in the manual.
815 AT_SETUP([macro expansion - !INDEX])
817 AT_DATA([define.sps], [dnl
821 !INDEX(banana, apple).
822 !INDEX("banana", nan).
823 !INDEX("banana", "nan").
824 !INDEX(!UNQUOTE("banana"), !UNQUOTE("nan")).
829 AT_CAPTURE_FILE([define.sps])
830 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
840 dnl Keep this test in sync with the examples for !LENGTH in the manual.
841 AT_SETUP([macro expansion - !LENGTH])
842 AT_KEYWORDS([LENGTH])
843 AT_DATA([define.sps], [dnl
852 !LENGTH(!UNQUOTE("xyzzy")).
853 !LENGTH(!UNQUOTE("xy""zzy")).
856 DEFINE !la(!positional !enclose('(',')'))
864 AT_CAPTURE_FILE([define.sps])
865 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
883 dnl Keep this test in sync with the examples for !NULL in the manual.
884 AT_SETUP([macro expansion - !NULL])
886 AT_DATA([define.sps], [dnl
894 AT_CAPTURE_FILE([define.sps])
895 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
901 dnl Keep this test in sync with the examples for !QUOTE and !UNQUOTE in the manual.
902 AT_SETUP([macro expansion - !QUOTE and !UNQUOTE])
903 AT_KEYWORDS([QUOTE UNQUOTE])
904 AT_DATA([define.sps], [dnl
905 DEFINE !q(!POS !CMDEND)
918 !QUOTE(!UNQUOTE(123.0)).
919 !QUOTE(!UNQUOTE( 123 )).
920 !QUOTE(!UNQUOTE('a b c')).
921 !QUOTE(!UNQUOTE("a b c")).
922 !QUOTE(!UNQUOTE(!1)).
927 AT_CAPTURE_FILE([define.sps])
928 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
949 dnl Keep this test in sync with the examples for !SUBSTR in the manual.
950 AT_SETUP([macro expansion - !SUBSTR])
951 AT_KEYWORDS([SUBSTR])
952 AT_DATA([define.sps], [dnl
955 !SUBSTR(banana, 3, 3).
956 !SUBSTR("banana", 1, 3).
957 !SUBSTR(!UNQUOTE("banana"), 3).
958 !SUBSTR("banana", 3, 3).
959 !SUBSTR(banana, 3, 0).
960 !SUBSTR(banana, 3, 10).
961 !SUBSTR(banana, 10, 3).
966 AT_CAPTURE_FILE([define.sps])
967 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
968 define.sps:1-10: At `"ba' in the expansion of `!s',dnl "
970 define.sps:12.1-12.2: error: DEBUG EXPAND: Unterminated string constant.
983 dnl Keep this test in sync with the examples for !UPCASE in the manual.
984 AT_SETUP([macro expansion - !UPCASE])
985 AT_KEYWORDS([UPCASE])
986 AT_DATA([define.sps], [dnl
996 AT_CAPTURE_FILE([define.sps])
997 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1005 dnl !* is implemented separately inside and outside function arguments
1006 dnl so this test makes sure to include both.
1007 AT_SETUP([macro expansion - !*])
1008 AT_DATA([define.sps], [dnl
1009 DEFINE !m(!POSITIONAL !TOKENS(1)
1010 /!POSITIONAL !TOKENS(1))
1021 AT_CAPTURE_FILE([define.sps])
1022 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1023 123 b / 5 / 3 b / '123 b'.
1025 2 3 / 3 / 3 / '2 3'.
1027 '' 'b' / 6 / 'b' / ''''' ''b'''.
1031 AT_SETUP([macro maximum nesting level (MNEST)])
1032 AT_KEYWORDS([MNEST])
1033 AT_DATA([define.sps], [dnl
1039 AT_CHECK([pspp -O format=csv define.sps], [1], [dnl
1040 "define.sps:1-3: In the expansion of `!macro',
1041 define.sps:1-3: inside the expansion of `!macro',
1042 define.sps:1-3: inside the expansion of `!macro',
1043 define.sps:1-3: inside the expansion of `!macro',
1044 define.sps:1-3: inside the expansion of `!macro',
1045 define.sps:1-3: inside the expansion of `!macro',
1046 define.sps:1-3: inside the expansion of `!macro',
1047 define.sps:1-3: inside the expansion of `!macro',
1048 define.sps:1-3: inside the expansion of `!macro',
1049 define.sps:1-3: inside the expansion of `!macro',
1050 define.sps:1-3: inside the expansion of `!macro',
1051 define.sps:1-3: inside the expansion of `!macro',
1052 define.sps:1-3: inside the expansion of `!macro',
1053 define.sps:1-3: inside the expansion of `!macro',
1054 define.sps:1-3: inside the expansion of `!macro',
1055 define.sps:1-3: inside the expansion of `!macro',
1056 define.sps:1-3: inside the expansion of `!macro',
1057 define.sps:1-3: inside the expansion of `!macro',
1058 define.sps:1-3: inside the expansion of `!macro',
1059 define.sps:1-3: inside the expansion of `!macro',
1060 define.sps:1-3: inside the expansion of `!macro',
1061 define.sps:1-3: inside the expansion of `!macro',
1062 define.sps:1-3: inside the expansion of `!macro',
1063 define.sps:1-3: inside the expansion of `!macro',
1064 define.sps:1-3: inside the expansion of `!macro',
1065 define.sps:1-3: inside the expansion of `!macro',
1066 define.sps:1-3: inside the expansion of `!macro',
1067 define.sps:1-3: inside the expansion of `!macro',
1068 define.sps:1-3: inside the expansion of `!macro',
1069 define.sps:1-3: inside the expansion of `!macro',
1070 define.sps:1-3: inside the expansion of `!macro',
1071 define.sps:1-3: inside the expansion of `!macro',
1072 define.sps:1-3: inside the expansion of `!macro',
1073 define.sps:1-3: inside the expansion of `!macro',
1074 define.sps:1-3: inside the expansion of `!macro',
1075 define.sps:1-3: inside the expansion of `!macro',
1076 define.sps:1-3: inside the expansion of `!macro',
1077 define.sps:1-3: inside the expansion of `!macro',
1078 define.sps:1-3: inside the expansion of `!macro',
1079 define.sps:1-3: inside the expansion of `!macro',
1080 define.sps:1-3: inside the expansion of `!macro',
1081 define.sps:1-3: inside the expansion of `!macro',
1082 define.sps:1-3: inside the expansion of `!macro',
1083 define.sps:1-3: inside the expansion of `!macro',
1084 define.sps:1-3: inside the expansion of `!macro',
1085 define.sps:1-3: inside the expansion of `!macro',
1086 define.sps:1-3: inside the expansion of `!macro',
1087 define.sps:1-3: inside the expansion of `!macro',
1088 define.sps:1-3: inside the expansion of `!macro',
1089 define.sps:1-3: inside the expansion of `!macro',
1090 define.sps:1-3: inside the expansion of `!macro',
1091 define.sps:4.1-4.6: error: DEFINE: Maximum nesting level 50 exceeded. (Use SET MNEST to change the limit.)"
1093 define.sps:4.1-4.6: error: Syntax error at `!macro' (in expansion of `!macro'): expecting command name.
1097 AT_SETUP([macro !IF condition])
1100 '!eq !ne !lt !gt !le !ge' \
1104 AS_BOX([$operators])
1105 cat > define.sps <<EOF
1106 DEFINE !test(!positional !tokens(1))
1107 !if (!1 $1 1) !then true !else false !ifend
1108 !if (!1 $2 1) !then true !else false !ifend
1109 !if (!1 $3 1) !then true !else false !ifend
1110 !if (!1 $4 1) !then true !else false !ifend
1111 !if (!1 $5 1) !then true !else false !ifend
1112 !if (!1 $6 1) !then true !else false !ifend.
1121 AT_CAPTURE_FILE([define.sps])
1122 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1123 false true true false true false.
1125 true false false false true true.
1127 false true false true false true.
1129 true false false false true true.
1131 false true false true false true.
1136 AT_SETUP([macro !IF condition -- case sensitivity])
1139 '!eq !ne !lt !gt !le !ge' \
1143 AS_BOX([$operators])
1144 cat > define.sps <<EOF
1145 DEFINE !test(!positional !tokens(1))
1146 !if (!1 $1 a) !then true !else false !ifend
1147 !if (!1 $1 A) !then true !else false !ifend
1148 !if (!1 $2 a) !then true !else false !ifend
1149 !if (!1 $2 A) !then true !else false !ifend
1150 !if (!1 $3 a) !then true !else false !ifend
1151 !if (!1 $3 A) !then true !else false !ifend
1152 !if (!1 $4 a) !then true !else false !ifend
1153 !if (!1 $4 A) !then true !else false !ifend
1154 !if (!1 $5 a) !then true !else false !ifend
1155 !if (!1 $5 A) !then true !else false !ifend
1156 !if (!1 $6 a) !then true !else false !ifend
1157 !if (!1 $6 A) !then true !else false !ifend
1158 !if (!1 $1 !null) !then true !else false !ifend
1159 !if (!1 $2 !null) !then true !else false !ifend.
1167 AT_CAPTURE_FILE([define.sps])
1168 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1169 true false false true false false false true true false true true false true.
1171 false true true false true false false false true true false true false true.
1173 false false true true false false true true false false true true false true.
1175 false false true true true false false true true false false true false true.
1180 AT_SETUP([macro !IF condition -- logical operators])
1187 AS_BOX([$operators])
1188 cat > define.sps <<EOF
1189 DEFINE !test_binary(!positional !tokens(1)/!positional !tokens(1))
1190 !if !1 $1 !2 !then true !else false !ifend
1191 !if !1 $2 !2 !then true !else false !ifend.
1194 DEFINE !test_unary(!positional !tokens(1))
1195 !if $3 !1 !then true !else false !ifend.
1199 ((not A) and B) or C
1202 DEFINE !test_prec(!pos !tokens(1)/!pos !tokens(1)/!pos !tokens(1))
1203 !if $3 !1 $1 !2 $2 !3 !then true !else false !ifend
1204 !if $3 (!1 $1 !2) $2 !3 !then true !else false !ifend
1205 !if $3 !1 $1 (!2 $2 !3) !then true !else false !ifend
1215 !test_prec 0 0 0 !test_prec 0 0 1 !test_prec 0 1 0 !test_prec 0 1 1.
1216 !test_prec 1 0 0 !test_prec 1 0 1 !test_prec 1 1 0 !test_prec 1 1 1.
1218 AT_CAPTURE_FILE([define.sps])
1219 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1245 AT_SETUP([macro !LET])
1247 AT_DATA([define.sps], [dnl
1248 DEFINE !macro(!POS !CMDEND)
1249 !LET !v1 = !CONCAT('x',!1,'y')
1250 !LET !v2 = !QUOTE(!v1)
1251 !LET !v3 = (!LENGTH(!1) = 1)
1252 !LET !v4 = (!SUBSTR(!1, 3) = !NULL)
1263 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1281 AT_SETUP([macro indexed !DO])
1282 AT_KEYWORDS([index do])
1283 AT_DATA([define.sps], [dnl
1284 DEFINE !title(!POS !TOKENS(1)) !1. !ENDDEFINE.
1286 DEFINE !for(!POS !TOKENS(1) / !POS !TOKENS(1))
1287 !DO !var = !1 !TO !2 !var !DOEND.
1290 DEFINE !forby(!POS !TOKENS(1) / !POS !TOKENS(1) / !POS !TOKENS(1))
1291 !DO !var = !1 !TO !2 !BY !3 !var !DOEND.
1295 !title "increasing".
1302 !title "decreasing".
1309 !title "non-integer".
1312 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1343 AT_SETUP([macro !DO invalid variable names])
1344 AT_KEYWORDS([index do])
1345 AT_DATA([define.sps], [dnl
1346 DEFINE !for(x=!TOKENS(1) / y=!TOKENS(1))
1347 !DO !x = !x !TO !y !var !DOEND.
1350 DEFINE !for2(x=!TOKENS(1) / y=!TOKENS(1))
1351 !DO !noexpand = !x !TO !y !var !DOEND.
1358 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1359 define.sps:1-3: At `!x' in the expansion of `!for',
1360 define.sps:10.1-10.12: error: DEBUG EXPAND: Cannot use argument name or macro
1361 keyword as !DO variable.
1363 !DO 1 = 1 !TO 5 !var !DOEND.
1365 define.sps:5-7: At `!noexpand' in the expansion of `!for2',
1366 define.sps:11.1-11.13: error: DEBUG EXPAND: Cannot use argument name or macro
1367 keyword as !DO variable.
1369 !DO !noexpand = 1 !TO 5 !var !DOEND.
1373 AT_SETUP([macro indexed !DO reaches MITERATE])
1374 AT_KEYWORDS([index do])
1375 AT_DATA([define.sps], [dnl
1376 DEFINE !title(!POS !TOKENS(1)) !1. !ENDDEFINE.
1378 DEFINE !for(!POS !TOKENS(1) / !POS !TOKENS(1))
1379 !DO !var = !1 !TO !2 !var !DOEND.
1382 DEFINE !forby(!POS !TOKENS(1) / !POS !TOKENS(1) / !POS !TOKENS(1))
1383 !DO !var = !1 !TO !2 !BY !3 !var !DOEND.
1388 !title "increasing".
1395 !title "decreasing".
1402 !title "non-integer".
1405 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1408 In the expansion of `!DO',
1409 define.sps:3-5: inside the expansion of `!for',
1410 define.sps:14.1-14.8: error: DEBUG EXPAND: Numerical !DO loop exceeded maximum
1411 number of iterations 3. (Use SET MITERATE to change the limit.)
1415 In the expansion of `!DO',
1416 define.sps:7-9: inside the expansion of `!forby',
1417 define.sps:15.1-15.12: error: DEBUG EXPAND: Numerical !DO loop exceeded maximum
1418 number of iterations 3. (Use SET MITERATE to change the limit.)
1434 In the expansion of `!DO',
1435 define.sps:7-9: inside the expansion of `!forby',
1436 define.sps:23.1-23.13: error: DEBUG EXPAND: Numerical !DO loop exceeded maximum
1437 number of iterations 3. (Use SET MITERATE to change the limit.)
1451 AT_SETUP([!BREAK with macro indexed !DO])
1452 AT_KEYWORDS([index do break])
1453 AT_DATA([define.sps], [dnl
1454 DEFINE !title(!POS !TOKENS(1)) !1. !ENDDEFINE.
1456 DEFINE !for(!POS !TOKENS(1) / !POS !TOKENS(1) / !POS !TOKENS(1))
1457 !DO !var = !1 !TO !2
1473 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1478 AT_SETUP([macro list !DO])
1479 AT_KEYWORDS([index do])
1480 AT_DATA([define.sps], [dnl
1481 DEFINE !for(!POS !CMDEND)
1482 (!DO !i !IN (!1) (!i) !DOEND).
1487 !for 'foo bar baz quux'.
1490 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1493 ( (foo) (bar) (baz) (quux) ).
1499 AT_SETUP([macro list !DO reaches MITERATE])
1500 AT_KEYWORDS([index do])
1501 AT_DATA([define.sps], [dnl
1502 DEFINE !for(!POS !CMDEND)
1503 (!DO !i !IN (!1) (!i) !DOEND).
1509 !for 'foo bar baz quux'.
1512 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1513 In the expansion of `!DO',
1514 define.sps:1-3: inside the expansion of `!for',
1515 define.sps:7.1-7.10: error: DEBUG EXPAND: !DO loop over list exceeded maximum
1516 number of iterations 2. (Use SET MITERATE to change the limit.)
1520 In the expansion of `!DO',
1521 define.sps:1-3: inside the expansion of `!for',
1522 define.sps:8.1-8.23: error: DEBUG EXPAND: !DO loop over list exceeded maximum
1523 number of iterations 2. (Use SET MITERATE to change the limit.)
1531 AT_SETUP([!BREAK with macro list !DO])
1532 AT_KEYWORDS([index break do])
1533 AT_DATA([define.sps], [dnl
1534 DEFINE !for(!POS !TOKENS(1) / !POS !CMDEND)
1550 !for baz 'foo bar baz quux'.
1553 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1556 ( (foo), (bar), (baz)x).
1562 AT_SETUP([macro !LET])
1563 AT_DATA([define.sps], [dnl
1564 DEFINE !macro(!pos !enclose('(',')'))
1575 AT_CHECK([pspp --testing-mode define.sps -O format=csv], [0], [dnl
1582 AT_SETUP([macro !LET invalid variable names])
1583 AT_DATA([define.sps], [dnl
1584 DEFINE !macro(x=!tokens(1))
1596 AT_CHECK([pspp --testing-mode define.sps -O format=csv], [1], [dnl
1597 "define.sps:1-3: At `!x' in the expansion of `!macro',
1598 define.sps:10.1-10.10: error: DEBUG EXPAND: Cannot use argument name or macro keyword ""!x"" as !LET variable."
1602 "define.sps:5-7: At `!do' in the expansion of `!macro2',
1603 define.sps:11.1-11.7: error: DEBUG EXPAND: Cannot use argument name or macro keyword ""!do"" as !LET variable."
1605 "define.sps:5-7: At `=' in the expansion of `!macro2',
1606 define.sps:11.1-11.7: error: DEBUG EXPAND: Expected macro variable name following !DO."
1612 AT_SETUP([BEGIN DATA inside a macro])
1613 AT_DATA([define.sps], [dnl
1615 DATA LIST NOTABLE /x 1.
1626 AT_CHECK([pspp define.sps -O format=csv], [0], [dnl
1635 AT_SETUP([TITLE and SUBTITLE with macros])
1636 AT_KEYWORDS([macro])
1637 for command in TITLE SUBTITLE; do
1638 cat >title.sps <<EOF
1639 DEFINE !paste(!POS !TOKENS(1) / !POS !TOKENS(1))
1642 $command prefix !paste foo bar suffix.
1646 title.sps:5: note: SHOW: $command is prefix foobar suffix.
1648 AT_CHECK([pspp -O format=csv title.sps], [0], [expout])
1652 AT_SETUP([error message within macro expansion])
1653 AT_DATA([define.sps], [dnl
1654 DEFINE !vars(!POS !TOKENS(1)) a b C !ENDDEFINE.
1655 DATA LIST NOTABLE /a b 1-2.
1656 COMPUTE x = !vars x.
1658 AT_CHECK([pspp -O format=csv define.sps], [1], [dnl
1659 define.sps:3.13-3.19: error: COMPUTE: Syntax error at `b' (in expansion of `!vars x'): expecting end of command.
1663 dnl A macro with keyword arguments needs a token of lookahead
1664 dnl to find out whether another keyword is present. Test that
1665 dnl this special case works OK.
1666 AT_SETUP([macro calls in each others' lookahead])
1667 AT_DATA([define.sps], [dnl
1668 DEFINE !k(x=!DEFAULT(0) !TOKENS(1)/y=!DEFAULT(0) !TOKENS(1))
1678 AT_CHECK([pspp -O format=csv define.sps --testing-mode], [0], [dnl
1690 AT_SETUP([bad token in macro body])
1691 AT_DATA([define.sps], [dnl
1696 AT_CHECK([pspp define.sps], [1], [dnl
1697 define.sps:3: error: DEFINE: String of hex digits has 3 characters, which is
1698 not a multiple of 2.
1702 AT_SETUP([macro name overlaps with macro function name])
1703 dnl !len is short for macro function !LENGTH. PSPP used to
1704 dnl reject the following with "`(' expected following !LENGTH".
1705 dnl Now PSPP only consider macro functions when the name is
1706 dnl followed by '('.
1707 AT_DATA([define.sps], [dnl
1708 DEFINE !len() 5 !ENDDEFINE.
1709 DEFINE !x() !eval(!len) !ENDDEFINE.
1713 AT_CHECK([pspp -O format=csv define.sps --testing-mode], [0], [dnl
1718 AT_SETUP([generic macro function syntax errors])
1719 AT_DATA([define.sps], [dnl
1722 DEFINE !c() !SUBSTR(1x) !ENDDEFINE.
1723 DEFINE !d() !SUBSTR(1 !ENDDEFINE.
1724 DEFINE !narg_blanks() !BLANKS() !ENDDEFINE.
1725 DEFINE !narg_concat() !CONCAT() !ENDDEFINE.
1726 DEFINE !narg_eval() !EVAL() !ENDDEFINE.
1727 DEFINE !narg_head() !HEAD() !ENDDEFINE.
1728 DEFINE !narg_index() !INDEX() !ENDDEFINE.
1729 DEFINE !narg_length() !LENGTH() !ENDDEFINE.
1730 DEFINE !narg_null() !NULL() !ENDDEFINE.
1731 DEFINE !narg_quote() !QUOTE() !ENDDEFINE.
1732 DEFINE !narg_substr() !SUBSTR() !ENDDEFINE.
1733 DEFINE !narg_tail() !TAIL() !ENDDEFINE.
1734 DEFINE !narg_unquote() !UNQUOTE() !ENDDEFINE.
1735 DEFINE !narg_upcase() !UPCASE() !ENDDEFINE.
1755 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1756 define.sps:3: At `x' in the expansion of `!c',
1757 define.sps:20.1-20.2: error: DEBUG EXPAND: `,' or `@:}@' expected in call to macro
1762 define.sps:4: In the expansion of `!d',
1763 define.sps:21.1-21.2: error: DEBUG EXPAND: Missing `@:}@' in call to macro
1768 define.sps:5: In the expansion of `!narg_blanks',
1769 define.sps:22.1-22.12: error: DEBUG EXPAND: Macro function !BLANKS takes one
1774 define.sps:6: In the expansion of `!narg_concat',
1775 define.sps:23.1-23.12: error: DEBUG EXPAND: Macro function !CONCAT needs at
1780 define.sps:7: In the expansion of `!narg_eval',
1781 define.sps:24.1-24.10: error: DEBUG EXPAND: Macro function !EVAL takes one
1786 define.sps:8: In the expansion of `!narg_head',
1787 define.sps:25.1-25.10: error: DEBUG EXPAND: Macro function !HEAD takes one
1792 define.sps:9: In the expansion of `!narg_index',
1793 define.sps:26.1-26.11: error: DEBUG EXPAND: Macro function !INDEX takes two
1798 define.sps:10: In the expansion of `!narg_length',
1799 define.sps:27.1-27.12: error: DEBUG EXPAND: Macro function !LENGTH takes one
1806 define.sps:12: In the expansion of `!narg_quote',
1807 define.sps:29.1-29.11: error: DEBUG EXPAND: Macro function !QUOTE takes one
1812 define.sps:13: In the expansion of `!narg_substr',
1813 define.sps:30.1-30.12: error: DEBUG EXPAND: Macro function !SUBSTR takes two or
1814 three arguments (not 0).
1818 define.sps:14: In the expansion of `!narg_tail',
1819 define.sps:31.1-31.10: error: DEBUG EXPAND: Macro function !TAIL takes one
1824 define.sps:15: In the expansion of `!narg_unquote',
1825 define.sps:32.1-32.13: error: DEBUG EXPAND: Macro function !UNQUOTE takes one
1830 define.sps:16: In the expansion of `!narg_upcase',
1831 define.sps:33.1-33.12: error: DEBUG EXPAND: Macro function !UPCASE takes one
1838 AT_SETUP([specific macro function syntax errors])
1839 AT_DATA([define.sps], [dnl
1840 DEFINE !a() !BLANKS(x). !ENDDEFINE.
1841 DEFINE !b() !SUBSTR(x, y). !ENDDEFINE.
1842 DEFINE !c() !SUBSTR(x, 1, z). !ENDDEFINE.
1848 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1849 define.sps:1: In the expansion of `!a',
1850 define.sps:5.1-5.2: error: DEBUG EXPAND: Argument to !BLANKS must be non-
1851 negative integer (not "x").
1855 define.sps:2: In the expansion of `!b',
1856 define.sps:6.1-6.2: error: DEBUG EXPAND: Second argument of !SUBSTR must be
1857 positive integer (not "y").
1861 define.sps:3: In the expansion of `!c',
1862 define.sps:7.1-7.2: error: DEBUG EXPAND: Third argument of !SUBSTR must be non-
1863 negative integer (not "z").
1869 AT_SETUP([macro expression errors])
1870 AT_DATA([define.sps], [dnl
1871 DEFINE !a() !LET !x = (1. !ENDDEFINE dnl )
1873 DEFINE !b() !DO !x = x. !ENDDEFINE.
1874 DEFINE !c() !LET !x = (). !ENDDEFINE.
1880 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1881 define.sps:1-2: At `.' in the expansion of `!a',
1882 define.sps:5.1-5.2: error: DEBUG EXPAND: Expecting ')' in macro expression.
1886 At `x' in the expansion of `!DO',
1887 define.sps:2: inside the expansion of `!b',
1888 define.sps:6.1-6.2: error: DEBUG EXPAND: Macro expression must evaluate to a
1893 define.sps:3: At `)' in the expansion of `!c',
1894 define.sps:7.1-7.2: error: DEBUG EXPAND: Expecting literal or function
1895 invocation in macro expression.
1901 AT_SETUP([macro !IF errors])
1903 AT_DATA([define.sps], [dnl
1904 DEFINE !a() !IF 1 !ENDDEFINE.
1905 DEFINE !b() !IF 1 !THEN !ENDDEFINE.
1906 DEFINE !c() !IF 1 !THEN !ELSE !ENDDEFINE.
1912 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1913 define.sps:1: In the expansion of `!a',
1914 define.sps:5.1-5.2: error: DEBUG EXPAND: !THEN expected in macro !IF construct.
1918 define.sps:2: In the expansion of `!b',
1919 define.sps:6.1-6.2: error: DEBUG EXPAND: !ELSE or !IFEND expected in macro !IF
1924 define.sps:3: In the expansion of `!c',
1925 define.sps:7.1-7.2: error: DEBUG EXPAND: !IFEND expected in macro !IF
1932 AT_SETUP([macro !LET errors])
1934 AT_DATA([define.sps], [dnl
1935 DEFINE !a() !LET !ENDDEFINE.
1936 DEFINE !b() !LET 0 !ENDDEFINE.
1937 DEFINE !c() !LET !x !ENDDEFINE.
1938 DEFINE !d() !LET !x y !ENDDEFINE.
1945 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1946 define.sps:1: In the expansion of `!a',
1947 define.sps:6.1-6.2: error: DEBUG EXPAND: Expected macro variable name following
1952 define.sps:2: At `0' in the expansion of `!b',
1953 define.sps:7.1-7.2: error: DEBUG EXPAND: Expected macro variable name following
1958 define.sps:3: In the expansion of `!c',
1959 define.sps:8.1-8.2: error: DEBUG EXPAND: Expected `=' following !LET.
1963 define.sps:4: At `y' in the expansion of `!d',
1964 define.sps:9.1-9.2: error: DEBUG EXPAND: Expected `=' following !LET.
1970 AT_SETUP([macro !DO errors])
1972 AT_DATA([define.sps], [dnl
1973 DEFINE !a() !DO !ENDDEFINE.
1974 DEFINE !b() !DO 0 !ENDDEFINE.
1975 DEFINE !c() !DO !x !ENDDEFINE.
1976 DEFINE !d() !DO !x !in (x) !ENDDEFINE.
1977 DEFINE !e() !DO !x = x. !ENDDEFINE.
1978 DEFINE !f() !DO !x = 5 x !ENDDEFINE.
1979 DEFINE !g() !DO !x = 5 !TO 6 !BY 0 !ENDDEFINE.
1980 DEFINE !h() !DO !x !ENDDEFINE.
1981 DEFINE !i() !DO !x 0 !ENDDEFINE.
1982 DEFINE !j() !BREAK !ENDDEFINE.
1995 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1996 define.sps:1: In the expansion of `!a',
1997 define.sps:12.1-12.2: error: DEBUG EXPAND: Expected macro variable name
2002 define.sps:2: At `0' in the expansion of `!b',
2003 define.sps:13.1-13.2: error: DEBUG EXPAND: Expected macro variable name
2008 define.sps:3: In the expansion of `!c',
2009 define.sps:14.1-14.2: error: DEBUG EXPAND: Expected `=' or !IN in !DO loop.
2013 In the expansion of `!DO',
2014 define.sps:4: inside the expansion of `!d',
2015 define.sps:15.1-15.2: error: DEBUG EXPAND: Missing !DOEND.
2019 At `x' in the expansion of `!DO',
2020 define.sps:5: inside the expansion of `!e',
2021 define.sps:16.1-16.2: error: DEBUG EXPAND: Macro expression must evaluate to a
2026 At `x' in the expansion of `!DO',
2027 define.sps:6: inside the expansion of `!f',
2028 define.sps:17.1-17.2: error: DEBUG EXPAND: Expected !TO in numerical !DO loop.
2032 In the expansion of `!DO',
2033 define.sps:7: inside the expansion of `!g',
2034 define.sps:18.1-18.2: error: DEBUG EXPAND: !BY value cannot be zero.
2036 !DO !x = 5 !TO 6 !BY 0
2038 define.sps:8: In the expansion of `!h',
2039 define.sps:19.1-19.2: error: DEBUG EXPAND: Expected `=' or !IN in !DO loop.
2043 define.sps:9: At `0' in the expansion of `!i',
2044 define.sps:20.1-20.2: error: DEBUG EXPAND: Expected `=' or !IN in !DO loop.
2048 define.sps:10: At `!BREAK' in the expansion of `!j',
2049 define.sps:21.1-21.2: error: DEBUG EXPAND: !BREAK outside !DO.
2054 AT_SETUP([macros in comments])
2055 AT_KEYWORDS([macro])
2056 AT_DATA([define.sps], [dnl
2057 DEFINE !macro() x y z !ENDDEFINE.
2063 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
2068 AT_SETUP([DEFINE syntax errors])
2069 AT_KEYWORDS([macro])
2070 AT_DATA([define.sps], [dnl
2071 DEFINE !macro(!POSITIONAL !CHAREND('x y')) !ENDDEFINE.
2072 DEFINE !macro(a=!TOKENS(1)/!POSITIONAL !TOKENS(1)) !ENDDEFINE.
2073 DEFINE !macro(!a=!TOKENS(1)) !ENDDEFINE.
2074 DEFINE !macro(do=!TOKENS(1)) !ENDDEFINE.
2075 DEFINE 0() !ENDDEFINE.
2076 DEFINE x y () !ENDDEFINE.
2077 DEFINE !macro(1) !ENDDEFINE.
2078 DEFINE !macro(x 2) !ENDDEFINE.
2079 DEFINE !macro(x=!DEFAULT 3) !ENDDEFINE.
2080 DEFINE !macro(x=!TOKENS 4) !ENDDEFINE.
2081 DEFINE !macro(x=!TOKENS(x)) !ENDDEFINE.
2082 DEFINE !macro(x=!TOKENS(1 5)) !ENDDEFINE.
2083 DEFINE !macro(x=!ENCLOSE 6) !ENDDEFINE.
2084 DEFINE !macro(x=!ENCLOSE('x' y)) !ENDDEFINE.
2085 DEFINE !macro(x=!ENCLOSE('x',y)) !ENDDEFINE.
2086 DEFINE !macro(x=!ENCLOSE('x','y' z)) !ENDDEFINE.
2087 DEFINE !macro(x=!CHAREND 7) !ENDDEFINE.
2088 DEFINE !macro(x=!CHAREND(8)) !ENDDEFINE.
2089 DEFINE !macro(x=!CHAREND('x' 9)) !ENDDEFINE.
2090 DEFINE !macro(x=!WTF) !ENDDEFINE.
2091 DEFINE !macro(x=!TOKENS(1) x) !ENDDEFINE.
2092 DEFINE !macro(x=!DEFAULT() !DEFAULT()) !ENDDEFINE.
2093 DEFINE !macro(x=!TOKENS(1) !CMDEND) !ENDDEFINE.
2096 AT_CHECK([pspp define.sps], [1], [dnl
2097 define.sps:1.36-1.40: error: DEFINE: Syntax error at `'x y'': String must
2098 contain exactly one token.
2100 define.sps:2.40-2.46: error: DEFINE: Syntax error at `!TOKENS': Positional
2101 parameters must precede keyword parameters.
2103 define.sps:3.15-3.16: error: DEFINE: Syntax error at `!a': Keyword macro
2104 parameter must be named in definition without "!" prefix.
2106 define.sps:4.15-4.16: error: DEFINE: Syntax error at `do': Cannot use macro
2107 keyword "do" as an argument name.
2109 define.sps:5.8: error: DEFINE: Syntax error at `0': expecting identifier.
2111 define.sps:6.10: error: DEFINE: Syntax error at `y': expecting `@{:@'.
2113 define.sps:7.15: error: DEFINE: Syntax error at `1': expecting identifier.
2115 define.sps:8.17: error: DEFINE: Syntax error at `2': expecting !TOKENS, !
2116 CHAREND, !ENCLOSE, or !CMDEND.
2118 define.sps:9.26: error: DEFINE: Syntax error at `3': expecting `@{:@'.
2120 define.sps:10.25: error: DEFINE: Syntax error at `4': expecting `('.
2122 define.sps:11.25: error: DEFINE: Syntax error at `x': Expected positive integer
2125 define.sps:12.27: error: DEFINE: Syntax error at `5': expecting `)'.
2127 define.sps:13.26: error: DEFINE: Syntax error at `6': expecting `('.
2129 define.sps:14.30: error: DEFINE: Syntax error at `y': expecting `,'.
2131 define.sps:15.30: error: DEFINE: Syntax error at `y': expecting string.
2133 define.sps:16.34: error: DEFINE: Syntax error at `z': expecting `)'.
2135 define.sps:17.26: error: DEFINE: Syntax error at `7': expecting `('.
2137 define.sps:18.26: error: DEFINE: Syntax error at `8': expecting string.
2139 define.sps:19.30: error: DEFINE: Syntax error at `9': expecting `)'.
2141 define.sps:20.17-20.20: error: DEFINE: Syntax error at `!WTF': expecting !
2142 TOKENS, !CHAREND, !ENCLOSE, or !CMDEND.
2144 define.sps:21.28: error: DEFINE: Syntax error at `x': expecting `/'.
2146 define.sps:22.36: error: DEFINE: Syntax error at `(': !DEFAULT is allowed only
2149 define.sps:23.35: error: DEFINE: Syntax error at `)': Only one of !TOKENS, !
2150 CHAREND, !ENCLOSE, or !CMDEND is allowed.
2152 define.sps:25.1: error: DEFINE: Syntax error at end of command: Expecting macro
2157 AT_SETUP([macro expansion with token merging])
2158 AT_DATA([define.sps], [dnl
2159 DEFINE !foo() "foo" !ENDDEFINE.
2160 DEFINE !bar() "bar" !ENDDEFINE.
2161 DEFINE !plus() + !ENDDEFINE.
2162 DEFINE !minus() - !ENDDEFINE.
2163 DEFINE !one() 1 !ENDDEFINE.
2170 ECHO !foo !plus !bar.
2171 ECHO "two" "strings".
2173 N OF CASES !minus 1.
2175 N OF CASES !minus !one.
2177 AT_CHECK([pspp define.sps], [1], [dnl
2194 define.sps:13.12-13.20: error: ECHO: Syntax error at `"strings"': expecting end
2197 define.sps:14.12-14.17: error: N OF CASES: Syntax error at `-/**/1': Expected
2198 positive integer for N OF CASES.
2200 define.sps:15.12-15.19: error: N OF CASES: Syntax error at `!minus 1': Expected
2201 positive integer for N OF CASES.
2203 define.sps:16.12-16.17: error: N OF CASES: Syntax error at `- !one': Expected
2204 positive integer for N OF CASES.
2206 define.sps:17.12-17.22: error: N OF CASES: Syntax error at `!minus !one':
2207 Expected positive integer for N OF CASES.
2211 AT_SETUP([one macro calls another])
2212 AT_DATA([define.sps], [dnl
2213 DEFINE !a(!pos !enclose('(',')')) [[!1]] !ENDDEFINE.
2214 DEFINE !b(!pos !enclose('{','}')) !a(x !1 z) !ENDDEFINE.
2215 DEFINE !c(!pos !enclose('{','}')) !let !tmp=!quote(!concat('<',!1,'>')) !a(!tmp) !ENDDEFINE.
2220 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl