DEFINE: Equals sign is optional for both positional and keyword parameters.
authorBen Pfaff <blp@cs.stanford.edu>
Tue, 20 Jul 2021 14:53:59 +0000 (07:53 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Tue, 20 Jul 2021 14:53:59 +0000 (07:53 -0700)
Thanks to Frans Houweling for reporting this bug.

src/language/control/define.c
tests/language/control/define.at

index cda4c71fa6c92a2ed7d0357975ef99cf1bf8f790..48dda4c7afb0331afa63113d9cc0fc5e36ae7a08 100644 (file)
@@ -160,10 +160,8 @@ cmd_define (struct lexer *lexer, struct dataset *ds UNUSED)
           p->positional = false;
           p->name = xasprintf ("!%s", lex_tokcstr (lexer));
           lex_get (lexer);
-
-          if (!lex_force_match (lexer, T_EQUALS))
-            goto error;
         }
+      lex_match (lexer, T_EQUALS);
 
       bool saw_default = false;
       bool saw_arg_type = false;
index 26df856673a189ca3c9cb9f6094b8f9d40191e67..9e1483ad82dab175ec3f339d221d58a18732f8c1 100644 (file)
@@ -44,7 +44,7 @@ AT_CLEANUP
 AT_SETUP([macro expansion - one !TOKENS(1) positional argument])
 AT_KEYWORDS([TOKENS])
 AT_DATA([define.sps], [dnl
-DEFINE !t1(!positional !tokens(1)) t1 (!1) !ENDDEFINE.
+DEFINE !t1(!positional=!tokens(1)) t1 (!1) !ENDDEFINE.
 DEBUG EXPAND.
 !t1 a.
 !t1 b.
@@ -68,8 +68,8 @@ DEFINE !title(!positional !tokens(1)) !1 !ENDDEFINE.
 DEFINE !t1(!positional !tokens(1)) t1 (!1) !ENDDEFINE.
 DEFINE !t2(!positional !tokens(2)) t2 (!1) !ENDDEFINE.
 
-DEFINE !ce(!positional !charend('/')) ce (!1) !ENDDEFINE.
-DEFINE !ce2(!positional !charend('(')
+DEFINE !ce(!positional=!charend('/')) ce (!1) !ENDDEFINE.
+DEFINE !ce2(!positional=!charend('(')
            /!positional !charend(')'))
 ce2 (!1, !2)
 !ENDDEFINE.
@@ -275,7 +275,7 @@ AT_CLEANUP
 
 AT_SETUP([keyword macro argument name with ! prefix])
 AT_DATA([define.sps], [dnl
-DEFINE !macro(!x=!TOKENS(1).
+DEFINE !macro(!x !TOKENS(1).
 ])
 AT_CHECK([pspp -O format=csv define.sps], [1], [dnl
 "define.sps:1.15-1.16: error: DEFINE: Syntax error at `!x': Keyword macro parameter must be named in definition without ""!"" prefix."
@@ -315,7 +315,7 @@ AT_CLEANUP
 AT_SETUP([macro expansion - one !TOKENS(1) keyword argument - negative])
 AT_KEYWORDS([TOKENS])
 AT_DATA([define.sps], [dnl
-DEFINE !k(arg1 !TOKENS(1)) k(!arg1) !ENDDEFINE.
+DEFINE !k(arg1 !TOKENS(1)) k(!arg1) !ENDDEFINE.
 DEBUG EXPAND.
 !k arg1.
 !k arg1=.
@@ -1964,7 +1964,8 @@ define.sps:6.10: error: DEFINE: Syntax error at `y': expecting `@{:@'.
 
 define.sps:7.15: error: DEFINE: Syntax error at `1': expecting identifier.
 
-define.sps:8.17: error: DEFINE: Syntax error at `2': expecting `='.
+define.sps:8.17: error: DEFINE: Syntax error at `2': expecting !TOKENS, !
+CHAREND, !ENCLOSE, or !CMDEND.
 
 define.sps:9.26: error: DEFINE: Syntax error at `3': expecting `@{:@'.