]> git.saurik.com Git - bison.git/blobdiff - tests/input.at
muscle: factor conditionals on defined %define variables
[bison.git] / tests / input.at
index 322bbe8775b00ceeaf11010c7381597e5e54fb1b..3dfed32d9e8a6fd4804a6ac5d58c83d792a3a784 100644 (file)
@@ -1274,6 +1274,45 @@ special-char-@:>@.y:3.7: error: %code qualifier 'q' is not used
 AT_CLEANUP
 
 
+## ---------------- ##
+## Multiple %code.  ##
+## ---------------- ##
+
+AT_SETUP([Multiple %code])
+
+# Make sure that repeated arguments to %code are separated by
+# end-of-lines.  At some point, a missing eol would leave synclines
+# appended to the previous value.  Here, we use CPP directive to
+# introduce dependency on the absence/presence of the eol.
+AT_BISON_OPTION_PUSHDEFS
+
+AT_DATA([input.y],
+[[%code {#include <assert.h>}
+%code {#define A B}
+%code {#define B C}
+%code {#define C D}
+%code {#define D 42}
+%code {
+  ]AT_YYERROR_DECLARE[
+  ]AT_YYLEX_DECLARE[
+}
+%%
+start: %empty;
+%%
+]AT_YYERROR_DEFINE[
+]AT_YYLEX_DEFINE[
+int main (void)
+{
+  assert (A == 42);
+  return 0;
+}
+]])
+AT_FULL_COMPILE([input])
+AT_PARSER_CHECK([./input])
+
+AT_BISON_OPTION_POPDEFS
+AT_CLEANUP()
+
 ## ---------------- ##
 ## %define errors.  ##
 ## ---------------- ##
@@ -1395,6 +1434,31 @@ AT_BISON_CHECK([[Input.y]], [1], [],
 
 AT_CLEANUP
 
+## ------------------------ ##
+## %define code variables.  ##
+## ------------------------ ##
+
+AT_SETUP([["%define" code variables]])
+
+m4_pushdef([AT_TEST],
+[AT_DATA([input.y],
+[[%define api.token.prefix ]$1[
+%%
+start: %empty;
+]])
+
+AT_BISON_CHECK([[input.y]], [0], [],
+[[input.y:1.9-24: warning: %define variable 'api.token.prefix' requires '{...}' values [-Wdeprecated]
+]])
+])
+
+AT_TEST(["abc"])
+AT_TEST([abcde])
+m4_popdef([AT_TEST])
+
+AT_CLEANUP
+
+
 ## ------------------------ ##
 ## %define enum variables.  ##
 ## ------------------------ ##