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([redefining a macro])
45 AT_DATA([define.sps], [dnl
46 DEFINE !macro() 0 !ENDDEFINE.
47 DEFINE !macro() 1 !ENDDEFINE.
51 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
56 AT_SETUP([macro expansion - one !TOKENS(1) positional argument])
58 AT_DATA([define.sps], [dnl
59 DEFINE !t1(!positional=!tokens(1)) t1 (!1) !ENDDEFINE.
65 AT_CAPTURE_FILE([define.sps])
66 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
73 note: unexpanded token "b"
77 AT_SETUP([macro expansion with positional arguments])
78 AT_DATA([define.sps], [dnl
79 DEFINE !title(!positional !tokens(1)) !1 !ENDDEFINE.
80 DEFINE !t1(!positional !tokens(1)) t1 (!1) !ENDDEFINE.
81 DEFINE !t2(!positional !tokens(2)) t2 (!1) !ENDDEFINE.
83 DEFINE !ce(!positional=!charend('/')) ce (!1) !ENDDEFINE.
84 DEFINE !ce2(!positional=!charend('(')
85 /!positional !charend(')'))
89 DEFINE !e(!positional !enclose('{','}')) e (!1) !ENDDEFINE.
91 DEFINE !cmd(!positional !cmdend) cmd(!1) !ENDDEFINE.
92 DEFINE !cmd2(!positional !cmdend
93 /!positional !tokens(1))
97 DEFINE !p(!positional !tokens(1)
98 /!positional !tokens(1)
99 /!positional !tokens(1))
104 !title "!TOKENS(1) argument."
109 !title "!TOKENS(2) argument."
113 !title "!CHAREND argument."
119 !title "Two !CHAREND arguments."
123 !title "!ENCLOSE argument."
128 !title "!CMDEND argument."
133 !title "Three !TOKENS(1) arguments."
137 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
138 "!TOKENS(1) argument."
146 note: unexpanded token "b"
148 "!TOKENS(2) argument."
154 note: unexpanded token "d"
166 "Two !CHAREND arguments."
186 note: unexpanded token "7"
188 "Three !TOKENS(1) arguments."
192 p(1, -2, -3) (1 -2 -3)
196 AT_SETUP([macro call missing positional !TOKENS arguments])
197 AT_KEYWORDS([TOKENS])
198 AT_DATA([define.sps], [dnl
199 DEFINE !p(!positional !tokens(1) !default(x)
200 /!positional !tokens(1) !default(y)
201 /!positional !tokens(1) !default(z))
210 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
221 AT_SETUP([macro call incomplete positional !TOKENS arguments])
222 AT_KEYWORDS([TOKENS])
223 AT_DATA([define.sps], [dnl
224 DEFINE !p(!positional !tokens(2) !default(x)
225 /!positional !tokens(2) !default(y)
226 /!positional !tokens(2) !default(z))
230 !p a1 a2 b1 b2 c1 c2.
238 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
239 (a1 a2, b1 b2, c1 c2)
241 define.sps:8.18: error: DEBUG EXPAND: Reached end of command expecting 1 more
242 token in argument !3 to macro !p.
243 8 | !p a1 a2 b1 b2 c1.
250 define.sps:10.12: error: DEBUG EXPAND: Reached end of command expecting 1 more
251 token in argument !2 to macro !p.
259 define.sps:12.6: error: DEBUG EXPAND: Reached end of command expecting 1 more
260 token in argument !1 to macro !p.
270 AT_SETUP([macro call empty positional !CHAREND arguments])
271 AT_KEYWORDS([CHAREND])
272 AT_DATA([define.sps], [dnl
273 DEFINE !p(!positional !charend(',') !default(x)
274 /!positional !charend(';') !default(y)
275 /!positional !charend(':') !default(z))
288 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
307 AT_SETUP([macro call missing positional !CHAREND arguments])
308 AT_DATA([define.sps], [dnl
309 DEFINE !p(!positional !charend(',') !default(x)
310 /!positional !charend(';') !default(y)
311 /!positional !charend(':') !default(z))
326 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
345 AT_SETUP([macro call incomplete positional !CHAREND arguments])
346 AT_KEYWORDS([CHAREND])
347 AT_DATA([define.sps], [dnl
348 DEFINE !p(!positional !charend(',') !default(x)
349 /!positional !charend(';') !default(y)
350 /!positional !charend(':') !default(z))
362 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
365 define.sps:8.9: error: DEBUG EXPAND: Reached end of command expecting ":" in
366 argument !3 to macro !p.
374 define.sps:10.7: error: DEBUG EXPAND: Reached end of command expecting ";" in
375 argument !2 to macro !p.
383 define.sps:12.5: error: DEBUG EXPAND: Reached end of command expecting "," in
384 argument !1 to macro !p.
394 AT_SETUP([macro call missing positional !ENCLOSE arguments])
395 AT_KEYWORDS([ENCLOSE])
396 AT_DATA([define.sps], [dnl
397 DEFINE !p(!positional !enclose('(',')') !default(x)
398 /!positional !enclose('<','>') !default(y)
399 /!positional !enclose('{','}') !default(z))
408 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
419 AT_SETUP([macro call incomplete positional !ENCLOSE arguments])
420 AT_KEYWORDS([ENCLOSE])
421 AT_DATA([define.sps], [dnl
422 DEFINE !p(!positional !enclose('(',')') !default(x)
423 /!positional !enclose('<','>') !default(y)
424 /!positional !enclose('{','}') !default(z))
439 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
442 define.sps:8.12: error: DEBUG EXPAND: Reached end of command expecting "}" in
443 argument !3 to macro !p.
449 define.sps:9.11: error: DEBUG EXPAND: Reached end of command expecting "}" in
450 argument !3 to macro !p.
458 define.sps:11.9: error: DEBUG EXPAND: Reached end of command expecting ">" in
459 argument !2 to macro !p.
465 define.sps:12.8: error: DEBUG EXPAND: Reached end of command expecting ">" in
466 argument !2 to macro !p.
474 define.sps:14.6: error: DEBUG EXPAND: Reached end of command expecting ")" in
475 argument !1 to macro !p.
481 define.sps:15.5: error: DEBUG EXPAND: Reached end of command expecting ")" in
482 argument !1 to macro !p.
492 AT_SETUP([keyword macro argument name with ! prefix])
493 AT_DATA([define.sps], [dnl
494 DEFINE !macro(!x !TOKENS(1).
496 AT_CHECK([pspp -O format=csv define.sps], [1], [dnl
497 "define.sps:1.15-1.16: error: DEFINE: Keyword macro parameter must be named in definition without ""!"" prefix.
498 1 | DEFINE !macro@{:@!x !TOKENS(1).
503 AT_SETUP([reserved macro keyword argument name])
504 AT_DATA([define.sps], [dnl
505 DEFINE !macro(if=!TOKENS(1).
507 AT_CHECK([pspp -O format=csv define.sps], [1], [dnl
508 "define.sps:1.15-1.16: error: DEFINE: Cannot use macro keyword ""if"" as an argument name.
509 1 | DEFINE !macro@{:@if=!TOKENS(1).
514 AT_SETUP([macro expansion - one !TOKENS(1) keyword argument])
515 AT_KEYWORDS([TOKENS])
516 AT_DATA([define.sps], [dnl
517 DEFINE !k(arg1 = !TOKENS(1)) k(!arg1) !ENDDEFINE.
523 AT_CAPTURE_FILE([define.sps])
524 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
529 note: unexpanded token "y"
535 AT_SETUP([macro expansion - one !TOKENS(1) keyword argument - negative])
536 AT_KEYWORDS([TOKENS])
537 AT_DATA([define.sps], [dnl
538 DEFINE !k(arg1 !TOKENS(1)) k(!arg1) !ENDDEFINE.
543 AT_CAPTURE_FILE([define.sps])
544 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
545 define.sps:3.8: error: DEBUG EXPAND: Found `.' while expecting `=' reading
546 argument !arg1 to macro !k.
552 define.sps:4.9: error: DEBUG EXPAND: Reached end of command expecting 1 more
553 token in argument !arg1 to macro !k.
561 AT_SETUP([macro expansion - !CHAREND keyword arguments])
562 AT_KEYWORDS([CHAREND])
563 AT_DATA([define.sps], [dnl
564 DEFINE !k(arg1 = !CHAREND('/')
565 /arg2 = !CHAREND('/'))
574 AT_CAPTURE_FILE([define.sps])
575 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
586 AT_SETUP([macro expansion - !CHAREND keyword arguments - negative])
587 AT_KEYWORDS([CHAREND])
588 AT_DATA([define.sps], [dnl
589 DEFINE !k(arg1 = !CHAREND('/')
590 /arg2 = !CHAREND('/'))
599 AT_CAPTURE_FILE([define.sps])
600 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
601 define.sps:6.8: error: DEBUG EXPAND: Found `.' while expecting `=' reading
602 argument !arg1 to macro !k.
608 define.sps:7.9: error: DEBUG EXPAND: Reached end of command expecting "/" in
609 argument !arg1 to macro !k.
615 define.sps:8.10: error: DEBUG EXPAND: Reached end of command expecting "/" in
616 argument !arg1 to macro !k.
622 define.sps:9.18: error: DEBUG EXPAND: Reached end of command expecting "/" in
623 argument !arg2 to macro !k.
624 9 | !k arg1=x/ arg2=y.
631 AT_SETUP([macro expansion - !ENCLOSE keyword arguments])
632 AT_KEYWORDS([ENCLOSE])
633 AT_DATA([define.sps], [dnl
634 DEFINE !k(arg1 = !ENCLOSE('(',')')
635 /arg2 = !ENCLOSE('{','}'))
639 !k arg1=(x) arg2={y}.
644 AT_CAPTURE_FILE([define.sps])
645 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
656 AT_SETUP([macro expansion - !ENCLOSE keyword arguments - negative])
657 AT_KEYWORDS([ENCLOSE])
658 AT_DATA([define.sps], [dnl
659 DEFINE !k(arg1 = !ENCLOSE('(',')')
660 /arg2 = !ENCLOSE('{','}'))
673 AT_CAPTURE_FILE([define.sps])
674 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
675 define.sps:6.8: error: DEBUG EXPAND: Found `.' while expecting `=' reading
676 argument !arg1 to macro !k.
682 define.sps:7.9: error: DEBUG EXPAND: Found `.' while expecting `@{:@' reading
683 argument !arg1 to macro !k.
689 define.sps:8.9: error: DEBUG EXPAND: Found `x' while expecting `@{:@' reading
690 argument !arg1 to macro !k.
696 note: unexpanded token "x"
698 define.sps:9.11: error: DEBUG EXPAND: Reached end of command expecting "@:}@" in
699 argument !arg1 to macro !k.
705 define.sps:10.17: error: DEBUG EXPAND: Found `.' while expecting `=' reading
706 argument !arg2 to macro !k.
707 10 | !k arg1=(x) arg2.
712 define.sps:11.18: error: DEBUG EXPAND: Found `.' while expecting `{' reading
713 argument !arg2 to macro !k.
714 11 | !k arg1=(x) arg2=.
719 define.sps:12.18: error: DEBUG EXPAND: Found `y' while expecting `{' reading
720 argument !arg2 to macro !k.
721 12 | !k arg1=(x) arg2=y.
726 note: unexpanded token "y"
728 define.sps:13.18: error: DEBUG EXPAND: Found `@{:@' while expecting `{' reading
729 argument !arg2 to macro !k.
730 13 | !k arg1=(x) arg2=@{:@y.
735 note: unexpanded token "@{:@"
737 note: unexpanded token "y"
741 dnl Keep this test in sync with the examples for !BLANKS in the manual.
742 AT_SETUP([macro expansion - !BLANKS])
743 AT_KEYWORDS([BLANKS])
744 AT_DATA([define.sps], [dnl
758 AT_CAPTURE_FILE([define.sps])
759 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
771 dnl Keep this test in sync with the examples for !CONCAT in the manual.
772 AT_SETUP([macro expansion - !CONCAT])
773 AT_KEYWORDS([CONCAT])
774 AT_DATA([define.sps], [dnl
788 AT_CAPTURE_FILE([define.sps])
789 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
801 dnl Keep this test in sync with the examples for !EVAL in the manual.
802 AT_SETUP([macro expansion - !EVAL])
804 AT_DATA([define.sps], [dnl
805 DEFINE !vars() a b c !ENDDEFINE.
811 !QUOTE(!EVAL(!vars)).
814 DEFINE !e2(!positional !enclose('(',')'))
824 AT_CAPTURE_FILE([define.sps])
825 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
838 dnl Keep this test in sync with the examples for !HEAD in the manual.
839 AT_SETUP([macro expansion - !HEAD])
841 AT_DATA([define.sps], [dnl
851 AT_CAPTURE_FILE([define.sps])
852 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
860 dnl Keep this test in sync with the examples for !TAIL in the manual.
861 AT_SETUP([macro expansion - !TAIL])
863 AT_DATA([define.sps], [dnl
873 AT_CAPTURE_FILE([define.sps])
874 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
882 dnl Keep this test in sync with the examples for !INDEX in the manual.
883 AT_SETUP([macro expansion - !INDEX])
885 AT_DATA([define.sps], [dnl
889 !INDEX(banana, apple).
890 !INDEX("banana", nan).
891 !INDEX("banana", "nan").
892 !INDEX(!UNQUOTE("banana"), !UNQUOTE("nan")).
897 AT_CAPTURE_FILE([define.sps])
898 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
908 dnl Keep this test in sync with the examples for !LENGTH in the manual.
909 AT_SETUP([macro expansion - !LENGTH])
910 AT_KEYWORDS([LENGTH])
911 AT_DATA([define.sps], [dnl
920 !LENGTH(!UNQUOTE("xyzzy")).
921 !LENGTH(!UNQUOTE("xy""zzy")).
924 DEFINE !la(!positional !enclose('(',')'))
932 AT_CAPTURE_FILE([define.sps])
933 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
951 dnl Keep this test in sync with the examples for !NULL in the manual.
952 AT_SETUP([macro expansion - !NULL])
954 AT_DATA([define.sps], [dnl
962 AT_CAPTURE_FILE([define.sps])
963 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
969 dnl Keep this test in sync with the examples for !QUOTE and !UNQUOTE in the manual.
970 AT_SETUP([macro expansion - !QUOTE and !UNQUOTE])
971 AT_KEYWORDS([QUOTE UNQUOTE])
972 AT_DATA([define.sps], [dnl
973 DEFINE !q(!POS !CMDEND)
986 !QUOTE(!UNQUOTE(123.0)).
987 !QUOTE(!UNQUOTE( 123 )).
988 !QUOTE(!UNQUOTE('a b c')).
989 !QUOTE(!UNQUOTE("a b c")).
990 !QUOTE(!UNQUOTE(!1)).
995 AT_CAPTURE_FILE([define.sps])
996 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1017 dnl Keep this test in sync with the examples for !SUBSTR in the manual.
1018 AT_SETUP([macro expansion - !SUBSTR])
1019 AT_KEYWORDS([SUBSTR])
1020 AT_DATA([define.sps], [dnl
1023 !SUBSTR(banana, 3, 3).
1024 !SUBSTR("banana", 1, 3).
1025 !SUBSTR(!UNQUOTE("banana"), 3).
1026 !SUBSTR("banana", 3, 3).
1027 !SUBSTR(banana, 3, 0).
1028 !SUBSTR(banana, 3, 10).
1029 !SUBSTR(banana, 10, 3).
1034 AT_CAPTURE_FILE([define.sps])
1035 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1036 define.sps:1-10: At `"ba' in the expansion of `!s',dnl "
1038 define.sps:12.1-12.2: error: DEBUG EXPAND: Unterminated string constant.
1053 dnl Keep this test in sync with the examples for !UPCASE in the manual.
1054 AT_SETUP([macro expansion - !UPCASE])
1055 AT_KEYWORDS([UPCASE])
1056 AT_DATA([define.sps], [dnl
1066 AT_CAPTURE_FILE([define.sps])
1067 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1075 dnl !* is implemented separately inside and outside function arguments
1076 dnl so this test makes sure to include both.
1077 AT_SETUP([macro expansion - !*])
1078 AT_DATA([define.sps], [dnl
1079 DEFINE !m(!POSITIONAL !TOKENS(1)
1080 /!POSITIONAL !TOKENS(1))
1091 AT_CAPTURE_FILE([define.sps])
1092 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1093 123 b / 5 / 3 b / '123 b'.
1095 2 3 / 3 / 3 / '2 3'.
1097 '' 'b' / 6 / 'b' / ''''' ''b'''.
1101 AT_SETUP([macro maximum nesting level (MNEST)])
1102 AT_KEYWORDS([MNEST])
1103 AT_DATA([define.sps], [dnl
1109 AT_CHECK([pspp -O format=csv define.sps], [1], [dnl
1110 "define.sps:1-3: In the expansion of `!macro',
1111 define.sps:1-3: inside the expansion of `!macro',
1112 define.sps:1-3: inside the expansion of `!macro',
1113 define.sps:1-3: inside the expansion of `!macro',
1114 define.sps:1-3: inside the expansion of `!macro',
1115 define.sps:1-3: inside the expansion of `!macro',
1116 define.sps:1-3: inside the expansion of `!macro',
1117 define.sps:1-3: inside the expansion of `!macro',
1118 define.sps:1-3: inside the expansion of `!macro',
1119 define.sps:1-3: inside the expansion of `!macro',
1120 define.sps:1-3: inside the expansion of `!macro',
1121 define.sps:1-3: inside the expansion of `!macro',
1122 define.sps:1-3: inside the expansion of `!macro',
1123 define.sps:1-3: inside the expansion of `!macro',
1124 define.sps:1-3: inside the expansion of `!macro',
1125 define.sps:1-3: inside the expansion of `!macro',
1126 define.sps:1-3: inside the expansion of `!macro',
1127 define.sps:1-3: inside the expansion of `!macro',
1128 define.sps:1-3: inside the expansion of `!macro',
1129 define.sps:1-3: inside the expansion of `!macro',
1130 define.sps:1-3: inside the expansion of `!macro',
1131 define.sps:1-3: inside the expansion of `!macro',
1132 define.sps:1-3: inside the expansion of `!macro',
1133 define.sps:1-3: inside the expansion of `!macro',
1134 define.sps:1-3: inside the expansion of `!macro',
1135 define.sps:1-3: inside the expansion of `!macro',
1136 define.sps:1-3: inside the expansion of `!macro',
1137 define.sps:1-3: inside the expansion of `!macro',
1138 define.sps:1-3: inside the expansion of `!macro',
1139 define.sps:1-3: inside the expansion of `!macro',
1140 define.sps:1-3: inside the expansion of `!macro',
1141 define.sps:1-3: inside the expansion of `!macro',
1142 define.sps:1-3: inside the expansion of `!macro',
1143 define.sps:1-3: inside the expansion of `!macro',
1144 define.sps:1-3: inside the expansion of `!macro',
1145 define.sps:1-3: inside the expansion of `!macro',
1146 define.sps:1-3: inside the expansion of `!macro',
1147 define.sps:1-3: inside the expansion of `!macro',
1148 define.sps:1-3: inside the expansion of `!macro',
1149 define.sps:1-3: inside the expansion of `!macro',
1150 define.sps:1-3: inside the expansion of `!macro',
1151 define.sps:1-3: inside the expansion of `!macro',
1152 define.sps:1-3: inside the expansion of `!macro',
1153 define.sps:1-3: inside the expansion of `!macro',
1154 define.sps:1-3: inside the expansion of `!macro',
1155 define.sps:1-3: inside the expansion of `!macro',
1156 define.sps:1-3: inside the expansion of `!macro',
1157 define.sps:1-3: inside the expansion of `!macro',
1158 define.sps:1-3: inside the expansion of `!macro',
1159 define.sps:1-3: inside the expansion of `!macro',
1160 define.sps:1-3: inside the expansion of `!macro',
1161 define.sps:4.1-4.6: error: DEFINE: Maximum nesting level 50 exceeded. (Use SET MNEST to change the limit.)
1165 "define.sps:4.1-4.6: error: In syntax expanded from `!macro': Syntax error expecting command name.
1171 AT_SETUP([macro !IF condition])
1174 '!eq !ne !lt !gt !le !ge' \
1178 AS_BOX([$operators])
1179 cat > define.sps <<EOF
1180 DEFINE !test(!positional !tokens(1))
1181 !if (!1 $1 1) !then true !else false !ifend
1182 !if (!1 $2 1) !then true !else false !ifend
1183 !if (!1 $3 1) !then true !else false !ifend
1184 !if (!1 $4 1) !then true !else false !ifend
1185 !if (!1 $5 1) !then true !else false !ifend
1186 !if (!1 $6 1) !then true !else false !ifend.
1195 AT_CAPTURE_FILE([define.sps])
1196 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1197 false true true false true false.
1199 true false false false true true.
1201 false true false true false true.
1203 true false false false true true.
1205 false true false true false true.
1210 AT_SETUP([macro !IF condition -- case sensitivity])
1213 '!eq !ne !lt !gt !le !ge' \
1217 AS_BOX([$operators])
1218 cat > define.sps <<EOF
1219 DEFINE !test(!positional !tokens(1))
1220 !if (!1 $1 a) !then true !else false !ifend
1221 !if (!1 $1 A) !then true !else false !ifend
1222 !if (!1 $2 a) !then true !else false !ifend
1223 !if (!1 $2 A) !then true !else false !ifend
1224 !if (!1 $3 a) !then true !else false !ifend
1225 !if (!1 $3 A) !then true !else false !ifend
1226 !if (!1 $4 a) !then true !else false !ifend
1227 !if (!1 $4 A) !then true !else false !ifend
1228 !if (!1 $5 a) !then true !else false !ifend
1229 !if (!1 $5 A) !then true !else false !ifend
1230 !if (!1 $6 a) !then true !else false !ifend
1231 !if (!1 $6 A) !then true !else false !ifend
1232 !if (!1 $1 !null) !then true !else false !ifend
1233 !if (!1 $2 !null) !then true !else false !ifend.
1241 AT_CAPTURE_FILE([define.sps])
1242 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1243 true false false true false false false true true false true true false true.
1245 false true true false true false false false true true false true false true.
1247 false false true true false false true true false false true true false true.
1249 false false true true true false false true true false false true false true.
1254 AT_SETUP([macro !IF condition -- logical operators])
1261 AS_BOX([$operators])
1262 cat > define.sps <<EOF
1263 DEFINE !test_binary(!positional !tokens(1)/!positional !tokens(1))
1264 !if !1 $1 !2 !then true !else false !ifend
1265 !if !1 $2 !2 !then true !else false !ifend.
1268 DEFINE !test_unary(!positional !tokens(1))
1269 !if $3 !1 !then true !else false !ifend.
1273 ((not A) and B) or C
1276 DEFINE !test_prec(!pos !tokens(1)/!pos !tokens(1)/!pos !tokens(1))
1277 !if $3 !1 $1 !2 $2 !3 !then true !else false !ifend
1278 !if $3 (!1 $1 !2) $2 !3 !then true !else false !ifend
1279 !if $3 !1 $1 (!2 $2 !3) !then true !else false !ifend
1289 !test_prec 0 0 0 !test_prec 0 0 1 !test_prec 0 1 0 !test_prec 0 1 1.
1290 !test_prec 1 0 0 !test_prec 1 0 1 !test_prec 1 1 0 !test_prec 1 1 1.
1292 AT_CAPTURE_FILE([define.sps])
1293 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1319 AT_SETUP([macro !LET])
1321 AT_DATA([define.sps], [dnl
1322 DEFINE !macro(!POS !CMDEND)
1323 !LET !v1 = !CONCAT('x',!1,'y')
1324 !LET !v2 = !QUOTE(!v1)
1325 !LET !v3 = (!LENGTH(!1) = 1)
1326 !LET !v4 = (!SUBSTR(!1, 3) = !NULL)
1337 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1355 AT_SETUP([macro indexed !DO])
1356 AT_KEYWORDS([index do])
1357 AT_DATA([define.sps], [dnl
1358 DEFINE !title(!POS !TOKENS(1)) !1. !ENDDEFINE.
1360 DEFINE !for(!POS !TOKENS(1) / !POS !TOKENS(1))
1361 !DO !var = !1 !TO !2 !var !DOEND.
1364 DEFINE !forby(!POS !TOKENS(1) / !POS !TOKENS(1) / !POS !TOKENS(1))
1365 !DO !var = !1 !TO !2 !BY !3 !var !DOEND.
1369 !title "increasing".
1376 !title "decreasing".
1383 !title "non-integer".
1386 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1417 AT_SETUP([macro !DO invalid variable names])
1418 AT_KEYWORDS([index do])
1419 AT_DATA([define.sps], [dnl
1420 DEFINE !for(x=!TOKENS(1) / y=!TOKENS(1))
1421 !DO !x = !x !TO !y !var !DOEND.
1424 DEFINE !for2(x=!TOKENS(1) / y=!TOKENS(1))
1425 !DO !noexpand = !x !TO !y !var !DOEND.
1432 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1433 define.sps:1-3: At `!x' in the expansion of `!for',
1434 define.sps:10.1-10.12: error: DEBUG EXPAND: Cannot use argument name or macro
1435 keyword as !DO variable.
1439 !DO 1 = 1 !TO 5 !var !DOEND.
1441 define.sps:5-7: At `!noexpand' in the expansion of `!for2',
1442 define.sps:11.1-11.13: error: DEBUG EXPAND: Cannot use argument name or macro
1443 keyword as !DO variable.
1447 !DO !noexpand = 1 !TO 5 !var !DOEND.
1451 AT_SETUP([macro indexed !DO reaches MITERATE])
1452 AT_KEYWORDS([index do])
1453 AT_DATA([define.sps], [dnl
1454 DEFINE !title(!POS !TOKENS(1)) !1. !ENDDEFINE.
1456 DEFINE !for(!POS !TOKENS(1) / !POS !TOKENS(1))
1457 !DO !var = !1 !TO !2 !var !DOEND.
1460 DEFINE !forby(!POS !TOKENS(1) / !POS !TOKENS(1) / !POS !TOKENS(1))
1461 !DO !var = !1 !TO !2 !BY !3 !var !DOEND.
1466 !title "increasing".
1473 !title "decreasing".
1480 !title "non-integer".
1483 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1486 In the expansion of `!DO',
1487 define.sps:3-5: inside the expansion of `!for',
1488 define.sps:14.1-14.8: error: DEBUG EXPAND: Numerical !DO loop exceeded maximum
1489 number of iterations 3. (Use SET MITERATE to change the limit.)
1495 In the expansion of `!DO',
1496 define.sps:7-9: inside the expansion of `!forby',
1497 define.sps:15.1-15.12: error: DEBUG EXPAND: Numerical !DO loop exceeded maximum
1498 number of iterations 3. (Use SET MITERATE to change the limit.)
1516 In the expansion of `!DO',
1517 define.sps:7-9: inside the expansion of `!forby',
1518 define.sps:23.1-23.13: error: DEBUG EXPAND: Numerical !DO loop exceeded maximum
1519 number of iterations 3. (Use SET MITERATE to change the limit.)
1535 AT_SETUP([!BREAK with macro indexed !DO])
1536 AT_KEYWORDS([index do break])
1537 AT_DATA([define.sps], [dnl
1538 DEFINE !title(!POS !TOKENS(1)) !1. !ENDDEFINE.
1540 DEFINE !for(!POS !TOKENS(1) / !POS !TOKENS(1) / !POS !TOKENS(1))
1541 !DO !var = !1 !TO !2
1557 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1562 AT_SETUP([macro list !DO])
1563 AT_KEYWORDS([index do])
1564 AT_DATA([define.sps], [dnl
1565 DEFINE !for(!POS !CMDEND)
1566 (!DO !i !IN (!1) (!i) !DOEND).
1571 !for 'foo bar baz quux'.
1574 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1577 ( (foo) (bar) (baz) (quux) ).
1583 AT_SETUP([macro list !DO reaches MITERATE])
1584 AT_KEYWORDS([index do])
1585 AT_DATA([define.sps], [dnl
1586 DEFINE !for(!POS !CMDEND)
1587 (!DO !i !IN (!1) (!i) !DOEND).
1593 !for 'foo bar baz quux'.
1596 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1597 In the expansion of `!DO',
1598 define.sps:1-3: inside the expansion of `!for',
1599 define.sps:7.1-7.10: error: DEBUG EXPAND: !DO loop over list exceeded maximum
1600 number of iterations 2. (Use SET MITERATE to change the limit.)
1606 In the expansion of `!DO',
1607 define.sps:1-3: inside the expansion of `!for',
1608 define.sps:8.1-8.23: error: DEBUG EXPAND: !DO loop over list exceeded maximum
1609 number of iterations 2. (Use SET MITERATE to change the limit.)
1610 8 | !for 'foo bar baz quux'.
1611 | ^~~~~~~~~~~~~~~~~~~~~~~
1619 AT_SETUP([!BREAK with macro list !DO])
1620 AT_KEYWORDS([index break do])
1621 AT_DATA([define.sps], [dnl
1622 DEFINE !for(!POS !TOKENS(1) / !POS !CMDEND)
1638 !for baz 'foo bar baz quux'.
1641 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
1644 ( (foo), (bar), (baz)x).
1650 AT_SETUP([macro !LET])
1651 AT_DATA([define.sps], [dnl
1652 DEFINE !macro(!pos !enclose('(',')'))
1663 AT_CHECK([pspp --testing-mode define.sps -O format=csv], [0], [dnl
1670 AT_SETUP([macro !LET invalid variable names])
1671 AT_DATA([define.sps], [dnl
1672 DEFINE !macro(x=!tokens(1))
1684 AT_CHECK([pspp --testing-mode define.sps -O format=csv], [1], [dnl
1685 "define.sps:1-3: At `!x' in the expansion of `!macro',
1686 define.sps:10.1-10.10: error: DEBUG EXPAND: Cannot use argument name or macro keyword ""!x"" as !LET variable.
1692 "define.sps:5-7: At `!do' in the expansion of `!macro2',
1693 define.sps:11.1-11.7: error: DEBUG EXPAND: Cannot use argument name or macro keyword ""!do"" as !LET variable.
1697 "define.sps:5-7: At `=' in the expansion of `!macro2',
1698 define.sps:11.1-11.7: error: DEBUG EXPAND: Expected macro variable name following !DO.
1706 AT_SETUP([BEGIN DATA inside a macro])
1707 AT_DATA([define.sps], [dnl
1709 DATA LIST NOTABLE /x 1.
1720 AT_CHECK([pspp define.sps -O format=csv], [0], [dnl
1729 AT_SETUP([TITLE and SUBTITLE with macros])
1730 AT_KEYWORDS([macro])
1731 for command in TITLE SUBTITLE; do
1732 cat >title.sps <<EOF
1733 DEFINE !paste(!POS !TOKENS(1) / !POS !TOKENS(1))
1736 $command prefix !paste foo bar suffix.
1740 title.sps:5: note: SHOW: $command is prefix foobar suffix.
1742 AT_CHECK([pspp -O format=csv title.sps], [0], [expout])
1746 AT_SETUP([error message within macro expansion])
1747 AT_DATA([define.sps], [dnl
1748 DEFINE !vars(!POS !TOKENS(1)) a b C !ENDDEFINE.
1749 DATA LIST NOTABLE /a b 1-2.
1750 COMPUTE x = !vars x.
1752 AT_CHECK([pspp -O format=csv define.sps], [1], [dnl
1753 "define.sps:3.13-3.19: error: COMPUTE: In syntax expanded from `!vars x': Syntax error expecting end of command.
1754 3 | COMPUTE x = !vars x.
1759 dnl A macro with keyword arguments needs a token of lookahead
1760 dnl to find out whether another keyword is present. Test that
1761 dnl this special case works OK.
1762 AT_SETUP([macro calls in each others' lookahead])
1763 AT_DATA([define.sps], [dnl
1764 DEFINE !k(x=!DEFAULT(0) !TOKENS(1)/y=!DEFAULT(0) !TOKENS(1))
1774 AT_CHECK([pspp -O format=csv define.sps --testing-mode], [0], [dnl
1786 AT_SETUP([bad token in macro body])
1787 AT_DATA([define.sps], [dnl
1792 AT_CHECK([pspp define.sps], [1], [dnl
1793 define.sps:3: error: DEFINE: String of hex digits has 3 characters, which is
1794 not a multiple of 2.
1798 AT_SETUP([macro name overlaps with macro function name])
1799 dnl !len is short for macro function !LENGTH. PSPP used to
1800 dnl reject the following with "`(' expected following !LENGTH".
1801 dnl Now PSPP only consider macro functions when the name is
1802 dnl followed by '('.
1803 AT_DATA([define.sps], [dnl
1804 DEFINE !len() 5 !ENDDEFINE.
1805 DEFINE !x() !eval(!len) !ENDDEFINE.
1809 AT_CHECK([pspp -O format=csv define.sps --testing-mode], [0], [dnl
1814 AT_SETUP([generic macro function syntax errors])
1815 AT_DATA([define.sps], [dnl
1818 DEFINE !c() !SUBSTR(1x) !ENDDEFINE.
1819 DEFINE !d() !SUBSTR(1 !ENDDEFINE.
1820 DEFINE !narg_blanks() !BLANKS() !ENDDEFINE.
1821 DEFINE !narg_concat() !CONCAT() !ENDDEFINE.
1822 DEFINE !narg_eval() !EVAL() !ENDDEFINE.
1823 DEFINE !narg_head() !HEAD() !ENDDEFINE.
1824 DEFINE !narg_index() !INDEX() !ENDDEFINE.
1825 DEFINE !narg_length() !LENGTH() !ENDDEFINE.
1826 DEFINE !narg_null() !NULL() !ENDDEFINE.
1827 DEFINE !narg_quote() !QUOTE() !ENDDEFINE.
1828 DEFINE !narg_substr() !SUBSTR() !ENDDEFINE.
1829 DEFINE !narg_tail() !TAIL() !ENDDEFINE.
1830 DEFINE !narg_unquote() !UNQUOTE() !ENDDEFINE.
1831 DEFINE !narg_upcase() !UPCASE() !ENDDEFINE.
1851 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1852 define.sps:3: At `x' in the expansion of `!c',
1853 define.sps:20.1-20.2: error: DEBUG EXPAND: `,' or `@:}@' expected in call to macro
1860 define.sps:4: In the expansion of `!d',
1861 define.sps:21.1-21.2: error: DEBUG EXPAND: Missing `@:}@' in call to macro
1868 define.sps:5: In the expansion of `!narg_blanks',
1869 define.sps:22.1-22.12: error: DEBUG EXPAND: Macro function !BLANKS takes one
1876 define.sps:6: In the expansion of `!narg_concat',
1877 define.sps:23.1-23.12: error: DEBUG EXPAND: Macro function !CONCAT needs at
1884 define.sps:7: In the expansion of `!narg_eval',
1885 define.sps:24.1-24.10: error: DEBUG EXPAND: Macro function !EVAL takes one
1892 define.sps:8: In the expansion of `!narg_head',
1893 define.sps:25.1-25.10: error: DEBUG EXPAND: Macro function !HEAD takes one
1900 define.sps:9: In the expansion of `!narg_index',
1901 define.sps:26.1-26.11: error: DEBUG EXPAND: Macro function !INDEX takes two
1908 define.sps:10: In the expansion of `!narg_length',
1909 define.sps:27.1-27.12: error: DEBUG EXPAND: Macro function !LENGTH takes one
1918 define.sps:12: In the expansion of `!narg_quote',
1919 define.sps:29.1-29.11: error: DEBUG EXPAND: Macro function !QUOTE takes one
1926 define.sps:13: In the expansion of `!narg_substr',
1927 define.sps:30.1-30.12: error: DEBUG EXPAND: Macro function !SUBSTR takes two or
1928 three arguments (not 0).
1934 define.sps:14: In the expansion of `!narg_tail',
1935 define.sps:31.1-31.10: error: DEBUG EXPAND: Macro function !TAIL takes one
1942 define.sps:15: In the expansion of `!narg_unquote',
1943 define.sps:32.1-32.13: error: DEBUG EXPAND: Macro function !UNQUOTE takes one
1950 define.sps:16: In the expansion of `!narg_upcase',
1951 define.sps:33.1-33.12: error: DEBUG EXPAND: Macro function !UPCASE takes one
1960 AT_SETUP([specific macro function syntax errors])
1961 AT_DATA([define.sps], [dnl
1962 DEFINE !a() !BLANKS(x). !ENDDEFINE.
1963 DEFINE !b() !SUBSTR(x, y). !ENDDEFINE.
1964 DEFINE !c() !SUBSTR(x, 1, z). !ENDDEFINE.
1970 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
1971 define.sps:1: In the expansion of `!a',
1972 define.sps:5.1-5.2: error: DEBUG EXPAND: Argument to !BLANKS must be non-
1973 negative integer (not "x").
1979 define.sps:2: In the expansion of `!b',
1980 define.sps:6.1-6.2: error: DEBUG EXPAND: Second argument of !SUBSTR must be
1981 positive integer (not "y").
1987 define.sps:3: In the expansion of `!c',
1988 define.sps:7.1-7.2: error: DEBUG EXPAND: Third argument of !SUBSTR must be non-
1989 negative integer (not "z").
1997 AT_SETUP([macro expression errors])
1998 AT_DATA([define.sps], [dnl
1999 DEFINE !a() !LET !x = (1. !ENDDEFINE dnl )
2001 DEFINE !b() !DO !x = x. !ENDDEFINE.
2002 DEFINE !c() !LET !x = (). !ENDDEFINE.
2008 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
2009 define.sps:1-2: At `.' in the expansion of `!a',
2010 define.sps:5.1-5.2: error: DEBUG EXPAND: Expecting ')' in macro expression.
2016 At `x' in the expansion of `!DO',
2017 define.sps:2: inside the expansion of `!b',
2018 define.sps:6.1-6.2: error: DEBUG EXPAND: Macro expression must evaluate to a
2025 define.sps:3: At `)' in the expansion of `!c',
2026 define.sps:7.1-7.2: error: DEBUG EXPAND: Expecting literal or function
2027 invocation in macro expression.
2035 AT_SETUP([macro !IF errors])
2037 AT_DATA([define.sps], [dnl
2038 DEFINE !a() !IF 1 !ENDDEFINE.
2039 DEFINE !b() !IF 1 !THEN !ENDDEFINE.
2040 DEFINE !c() !IF 1 !THEN !ELSE !ENDDEFINE.
2046 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
2047 define.sps:1: In the expansion of `!a',
2048 define.sps:5.1-5.2: error: DEBUG EXPAND: !THEN expected in macro !IF construct.
2054 define.sps:2: In the expansion of `!b',
2055 define.sps:6.1-6.2: error: DEBUG EXPAND: !ELSE or !IFEND expected in macro !IF
2062 define.sps:3: In the expansion of `!c',
2063 define.sps:7.1-7.2: error: DEBUG EXPAND: !IFEND expected in macro !IF
2072 AT_SETUP([macro !LET errors])
2074 AT_DATA([define.sps], [dnl
2075 DEFINE !a() !LET !ENDDEFINE.
2076 DEFINE !b() !LET 0 !ENDDEFINE.
2077 DEFINE !c() !LET !x !ENDDEFINE.
2078 DEFINE !d() !LET !x y !ENDDEFINE.
2085 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
2086 define.sps:1: In the expansion of `!a',
2087 define.sps:6.1-6.2: error: DEBUG EXPAND: Expected macro variable name following
2094 define.sps:2: At `0' in the expansion of `!b',
2095 define.sps:7.1-7.2: error: DEBUG EXPAND: Expected macro variable name following
2102 define.sps:3: In the expansion of `!c',
2103 define.sps:8.1-8.2: error: DEBUG EXPAND: Expected `=' following !LET.
2109 define.sps:4: At `y' in the expansion of `!d',
2110 define.sps:9.1-9.2: error: DEBUG EXPAND: Expected `=' following !LET.
2118 AT_SETUP([macro !DO errors])
2120 AT_DATA([define.sps], [dnl
2121 DEFINE !a() !DO !ENDDEFINE.
2122 DEFINE !b() !DO 0 !ENDDEFINE.
2123 DEFINE !c() !DO !x !ENDDEFINE.
2124 DEFINE !d() !DO !x !in (x) !ENDDEFINE.
2125 DEFINE !e() !DO !x = x. !ENDDEFINE.
2126 DEFINE !f() !DO !x = 5 x !ENDDEFINE.
2127 DEFINE !g() !DO !x = 5 !TO 6 !BY 0 !ENDDEFINE.
2128 DEFINE !h() !DO !x !ENDDEFINE.
2129 DEFINE !i() !DO !x 0 !ENDDEFINE.
2130 DEFINE !j() !BREAK !ENDDEFINE.
2143 AT_CHECK([pspp --testing-mode define.sps], [1], [dnl
2144 define.sps:1: In the expansion of `!a',
2145 define.sps:12.1-12.2: error: DEBUG EXPAND: Expected macro variable name
2152 define.sps:2: At `0' in the expansion of `!b',
2153 define.sps:13.1-13.2: error: DEBUG EXPAND: Expected macro variable name
2160 define.sps:3: In the expansion of `!c',
2161 define.sps:14.1-14.2: error: DEBUG EXPAND: Expected `=' or !IN in !DO loop.
2167 In the expansion of `!DO',
2168 define.sps:4: inside the expansion of `!d',
2169 define.sps:15.1-15.2: error: DEBUG EXPAND: Missing !DOEND.
2175 At `x' in the expansion of `!DO',
2176 define.sps:5: inside the expansion of `!e',
2177 define.sps:16.1-16.2: error: DEBUG EXPAND: Macro expression must evaluate to a
2184 At `x' in the expansion of `!DO',
2185 define.sps:6: inside the expansion of `!f',
2186 define.sps:17.1-17.2: error: DEBUG EXPAND: Expected !TO in numerical !DO loop.
2192 In the expansion of `!DO',
2193 define.sps:7: inside the expansion of `!g',
2194 define.sps:18.1-18.2: error: DEBUG EXPAND: !BY value cannot be zero.
2198 !DO !x = 5 !TO 6 !BY 0
2200 define.sps:8: In the expansion of `!h',
2201 define.sps:19.1-19.2: error: DEBUG EXPAND: Expected `=' or !IN in !DO loop.
2207 define.sps:9: At `0' in the expansion of `!i',
2208 define.sps:20.1-20.2: error: DEBUG EXPAND: Expected `=' or !IN in !DO loop.
2214 define.sps:10: At `!BREAK' in the expansion of `!j',
2215 define.sps:21.1-21.2: error: DEBUG EXPAND: !BREAK outside !DO.
2222 AT_SETUP([macros in comments])
2223 AT_KEYWORDS([macro])
2224 AT_DATA([define.sps], [dnl
2225 DEFINE !macro() x y z !ENDDEFINE.
2231 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl
2236 AT_SETUP([DEFINE syntax errors])
2237 AT_KEYWORDS([macro])
2238 AT_DATA([define.sps], [dnl
2239 DEFINE !macro(!POSITIONAL !CHAREND('x y')) !ENDDEFINE.
2240 DEFINE !macro(a=!TOKENS(1)/!POSITIONAL !TOKENS(1)) !ENDDEFINE.
2241 DEFINE !macro(!a=!TOKENS(1)) !ENDDEFINE.
2242 DEFINE !macro(do=!TOKENS(1)) !ENDDEFINE.
2243 DEFINE 0() !ENDDEFINE.
2244 DEFINE x y () !ENDDEFINE.
2245 DEFINE !macro(1) !ENDDEFINE.
2246 DEFINE !macro(x 2) !ENDDEFINE.
2247 DEFINE !macro(x=!DEFAULT 3) !ENDDEFINE.
2248 DEFINE !macro(x=!TOKENS 4) !ENDDEFINE.
2249 DEFINE !macro(x=!TOKENS(x)) !ENDDEFINE.
2250 DEFINE !macro(x=!TOKENS(1 5)) !ENDDEFINE.
2251 DEFINE !macro(x=!ENCLOSE 6) !ENDDEFINE.
2252 DEFINE !macro(x=!ENCLOSE('x' y)) !ENDDEFINE.
2253 DEFINE !macro(x=!ENCLOSE('x',y)) !ENDDEFINE.
2254 DEFINE !macro(x=!ENCLOSE('x','y' z)) !ENDDEFINE.
2255 DEFINE !macro(x=!CHAREND 7) !ENDDEFINE.
2256 DEFINE !macro(x=!CHAREND(8)) !ENDDEFINE.
2257 DEFINE !macro(x=!CHAREND('x' 9)) !ENDDEFINE.
2258 DEFINE !macro(x=!WTF) !ENDDEFINE.
2259 DEFINE !macro(x=!TOKENS(1) x) !ENDDEFINE.
2260 DEFINE !macro(x=!DEFAULT() !DEFAULT()) !ENDDEFINE.
2261 DEFINE !macro(x=!TOKENS(1) !CMDEND) !ENDDEFINE.
2264 AT_CHECK([pspp define.sps], [1], [dnl
2265 define.sps:1.36-1.40: error: DEFINE: String must contain exactly one token.
2266 1 | DEFINE !macro(!POSITIONAL !CHAREND('x y')) !ENDDEFINE.
2269 define.sps:2.28-2.38: error: DEFINE: Positional parameters must precede keyword
2271 2 | DEFINE !macro(a=!TOKENS(1)/!POSITIONAL !TOKENS(1)) !ENDDEFINE.
2274 define.sps:2.15: note: DEFINE: Here is a previous keyword parameter.
2275 2 | DEFINE !macro(a=!TOKENS(1)/!POSITIONAL !TOKENS(1)) !ENDDEFINE.
2278 define.sps:3.15-3.16: error: DEFINE: Keyword macro parameter must be named in
2279 definition without "!" prefix.
2280 3 | DEFINE !macro(!a=!TOKENS(1)) !ENDDEFINE.
2283 define.sps:4.15-4.16: error: DEFINE: Cannot use macro keyword "do" as an
2285 4 | DEFINE !macro(do=!TOKENS(1)) !ENDDEFINE.
2288 define.sps:5.8: error: DEFINE: Syntax error expecting identifier.
2289 5 | DEFINE 0() !ENDDEFINE.
2292 define.sps:6.10: error: DEFINE: Syntax error expecting `@{:@'.
2293 6 | DEFINE x y () !ENDDEFINE.
2296 define.sps:7.15: error: DEFINE: Syntax error expecting identifier.
2297 7 | DEFINE !macro(1) !ENDDEFINE.
2300 define.sps:8.17: error: DEFINE: Syntax error expecting !TOKENS, !CHAREND, !
2301 ENCLOSE, or !CMDEND.
2302 8 | DEFINE !macro(x 2) !ENDDEFINE.
2305 define.sps:9.26: error: DEFINE: Syntax error expecting `@{:@'.
2306 9 | DEFINE !macro(x=!DEFAULT 3) !ENDDEFINE.
2309 define.sps:10.25: error: DEFINE: Syntax error expecting `@{:@'.
2310 10 | DEFINE !macro(x=!TOKENS 4) !ENDDEFINE.
2313 define.sps:11.25: error: DEFINE: Syntax error expecting positive integer for !
2315 11 | DEFINE !macro(x=!TOKENS(x)) !ENDDEFINE.
2318 define.sps:12.27: error: DEFINE: Syntax error expecting `@:}@'.
2319 12 | DEFINE !macro(x=!TOKENS(1 5)) !ENDDEFINE.
2322 define.sps:13.26: error: DEFINE: Syntax error expecting `@{:@'.
2323 13 | DEFINE !macro(x=!ENCLOSE 6) !ENDDEFINE.
2326 define.sps:14.30: error: DEFINE: Syntax error expecting `,'.
2327 14 | DEFINE !macro(x=!ENCLOSE('x' y)) !ENDDEFINE.
2330 define.sps:15.30: error: DEFINE: Syntax error expecting string.
2331 15 | DEFINE !macro(x=!ENCLOSE('x',y)) !ENDDEFINE.
2334 define.sps:16.34: error: DEFINE: Syntax error expecting `@:}@'.
2335 16 | DEFINE !macro(x=!ENCLOSE('x','y' z)) !ENDDEFINE.
2338 define.sps:17.26: error: DEFINE: Syntax error expecting `@{:@'.
2339 17 | DEFINE !macro(x=!CHAREND 7) !ENDDEFINE.
2342 define.sps:18.26: error: DEFINE: Syntax error expecting string.
2343 18 | DEFINE !macro(x=!CHAREND(8)) !ENDDEFINE.
2346 define.sps:19.30: error: DEFINE: Syntax error expecting `@:}@'.
2347 19 | DEFINE !macro(x=!CHAREND('x' 9)) !ENDDEFINE.
2350 define.sps:20.17-20.20: error: DEFINE: Syntax error expecting !TOKENS, !
2351 CHAREND, !ENCLOSE, or !CMDEND.
2352 20 | DEFINE !macro(x=!WTF) !ENDDEFINE.
2355 define.sps:21.28: error: DEFINE: Syntax error expecting `/'.
2356 21 | DEFINE !macro(x=!TOKENS(1) x) !ENDDEFINE.
2359 define.sps:22.28-22.35: error: DEFINE: !DEFAULT is allowed only once per
2361 22 | DEFINE !macro(x=!DEFAULT() !DEFAULT()) !ENDDEFINE.
2364 define.sps:23.28-23.34: error: DEFINE: Only one of !TOKENS, !CHAREND, !ENCLOSE,
2365 or !CMDEND is allowed.
2366 23 | DEFINE !macro(x=!TOKENS(1) !CMDEND) !ENDDEFINE.
2369 define.sps:25.1: error: DEFINE: Syntax error expecting macro body or !
2376 AT_SETUP([macro expansion with token merging])
2377 AT_DATA([define.sps], [dnl
2378 DEFINE !foo() "foo" !ENDDEFINE.
2379 DEFINE !bar() "bar" !ENDDEFINE.
2380 DEFINE !plus() + !ENDDEFINE.
2381 DEFINE !minus() - !ENDDEFINE.
2382 DEFINE !one() 1 !ENDDEFINE.
2389 ECHO !foo !plus !bar.
2390 ECHO "two" "strings".
2392 N OF CASES !minus 1.
2394 N OF CASES !minus !one.
2396 AT_CHECK([pspp define.sps], [1], [dnl
2413 define.sps:13.12-13.20: error: ECHO: Syntax error expecting end of command.
2414 13 | ECHO "two" "strings".
2417 define.sps:14.12-14.17: error: N OF CASES: Syntax error expecting positive
2418 integer for N OF CASES.
2419 14 | N OF CASES -/**/1.
2422 define.sps:15.12-15.19: error: N OF CASES: Syntax error expecting positive
2423 integer for N OF CASES.
2424 15 | N OF CASES !minus 1.
2427 define.sps:16.12-16.17: error: N OF CASES: Syntax error expecting positive
2428 integer for N OF CASES.
2429 16 | N OF CASES - !one.
2432 define.sps:17.12-17.22: error: N OF CASES: Syntax error expecting positive
2433 integer for N OF CASES.
2434 17 | N OF CASES !minus !one.
2439 AT_SETUP([one macro calls another])
2440 AT_DATA([define.sps], [dnl
2441 DEFINE !a(!pos !enclose('(',')')) [[!1]] !ENDDEFINE.
2442 DEFINE !b(!pos !enclose('{','}')) !a(x !1 z) !ENDDEFINE.
2443 DEFINE !c(!pos !enclose('{','}')) !let !tmp=!quote(!concat('<',!1,'>')) !a(!tmp) !ENDDEFINE.
2448 AT_CHECK([pspp --testing-mode define.sps], [0], [dnl