]> git.saurik.com Git - bison.git/blobdiff - tests/input.at
symtab: refactoring
[bison.git] / tests / input.at
index 884985568c9d0cce3219fdc105ed6a88de1349a3..200fa076fa00fed03ac6daaa101c6075b5046333 100644 (file)
@@ -69,10 +69,9 @@ AT_CLEANUP
 
 
 # _AT_UNUSED_VALUES_DECLARATIONS()
-# --------------------------------------------
+# --------------------------------
 # Generate the token, type, and destructor
 # declarations for the unused values tests.
-
 m4_define([_AT_UNUSED_VALUES_DECLARATIONS],
 [[[%token <integer> INT;
 %type <integer> a b c d e f g h i j k l;
@@ -80,15 +79,11 @@ m4_define([_AT_UNUSED_VALUES_DECLARATIONS],
 
 
 # AT_CHECK_UNUSED_VALUES(DECLARATIONS_AFTER, CHECK_MIDRULE_VALUES)
-# ------------------------------------------------------------------
-# Generate a grammar to test unused values,
-# compile it, run it.  If DECLARATIONS_AFTER
-# is set, then the token, type, and destructor
-# declarations are generated after the rules
-# rather than before.  If CHECK_MIDRULE_VALUES
-# is set, then --warnings=midrule-values is
-# set.
-
+# ----------------------------------------------------------------
+# Generate a grammar to test unused values, compile it, run it.  If
+# DECLARATIONS_AFTER is set, then the token, type, and destructor
+# declarations are generated after the rules rather than before.  If
+# CHECK_MIDRULE_VALUES is set, then --warnings=midrule-values is set.
 m4_define([AT_CHECK_UNUSED_VALUES],
 [AT_DATA([input.y],
 m4_ifval($1, [
@@ -276,6 +271,28 @@ input.y:5.10-24: previous declaration
 
 AT_CLEANUP
 
+## ----------------------------------------------------- ##
+## Undeclared symbols used for a printer or destructor.  ##
+## ----------------------------------------------------- ##
+
+AT_SETUP([Undeclared symbols used for a printer or destructor])
+
+AT_DATA([[input.y]],
+[[%printer {} foo baz
+%destructor {} bar
+
+%%
+exp: bar;
+]])
+
+AT_BISON_CHECK([input.y], [1], [],
+[[input.y:2.16-18: symbol bar is used, but is not defined as a token and has no rules
+input.y:1.17-19: warning: symbol baz is used, but is not defined as a token and has no rules
+input.y:1.13-15: warning: symbol foo is used, but is not defined as a token and has no rules
+]])
+
+AT_CLEANUP
+
 
 ## ---------------------------------------- ##
 ## Unused values with default %destructor.  ##
@@ -391,7 +408,7 @@ AT_CLEANUP
 
 AT_SETUP([Torturing the Scanner])
 
-
+AT_BISON_OPTION_PUSHDEFS
 AT_DATA([input.y], [])
 AT_BISON_CHECK([input.y], [1], [],
 [[input.y:1.1: syntax error, unexpected end of file
@@ -501,7 +518,7 @@ value_as_yystype (value val)
   res.ival = val;
   return res;
 }
-
+]AT_YYERROR_DEFINE[
 static int
 yylex (void)
 {
@@ -514,12 +531,6 @@ yylex (void)
   yylval = value_as_yystype (input[toknum]);
   return input[toknum++];
 }
-
-static void
-yyerror (const char *msg)
-{
-  fprintf (stderr, "%s\n", msg);
-}
 ]])
 
 # Pacify Emacs'font-lock-mode: "
@@ -536,6 +547,7 @@ main (void)
   return yyparse ();
 }
 ]])
+AT_BISON_OPTION_POPDEFS
 
 AT_BISON_CHECK([-d -v -o input.c input.y])
 AT_COMPILE([input.o], [-c input.c])
@@ -600,8 +612,8 @@ AT_CHECK_REQUIRE(100.0, 63)
 
 AT_SETUP([String aliases for character tokens])
 
-# Bison once thought a character token and its alias were different symbols
-# with the same user token number.
+# Bison once thought a character token and its alias were different
+# symbols with the same user token number.
 
 AT_DATA_GRAMMAR([input.y],
 [[%token 'a' "a"
@@ -725,10 +737,10 @@ AT_CLEANUP
 
 AT_SETUP([Unclosed constructs])
 
-# Bison's scan-gram.l once forgot to STRING_FINISH some unclosed constructs, so
-# they were prepended to whatever it STRING_GROW'ed next.  It also threw them
-# away rather than returning them to the parser.  The effect was confusing
-# subsequent error messages.
+# Bison's scan-gram.l once forgot to STRING_FINISH some unclosed
+# constructs, so they were prepended to whatever it STRING_GROW'ed
+# next.  It also threw them away rather than returning them to the
+# parser.  The effect was confusing subsequent error messages.
 
 AT_DATA([input.y],
 [[%token A "a
@@ -770,8 +782,8 @@ AT_CLEANUP
 
 AT_SETUP([%start after first rule])
 
-# Bison once complained that a %start after the first rule was a redeclaration
-# of the start symbol.
+# Bison once complained that a %start after the first rule was a
+# redeclaration of the start symbol.
 
 AT_DATA([input.y],
 [[%%
@@ -1088,6 +1100,17 @@ AT_BISON_CHECK([[input.y]], [1], [],
 [[input.y:1.9-34: invalid value for %define Boolean variable 'lr.keep-unreachable-states'
 ]])
 
+AT_DATA([[input.y]],
+[[%define namespace "foo"
+%define api.namespace "foo"
+%%
+start: ;
+]])
+AT_BISON_CHECK([[input.y]], [1], [],
+[[input.y:2.9-21: %define variable 'api.namespace' redefined
+input.y:1.9-17: previous definition
+]])
+
 AT_DATA([[input.y]],
 [[%define foo_bar "baz"
 %%
@@ -1146,14 +1169,14 @@ m4_define([AT_CHECK_NAMESPACE_ERROR],
 AT_DATA([[input.y]],
 [[%language "C++"
 %defines
-%define namespace "]$1["
+%define api.namespace "]$1["
 %%
 start: ;
 ]])
 
 AT_BISON_CHECK([[input.y]], [1], [],
 [m4_foreach([b4_arg], m4_dquote(m4_shift($@)),
-[[input.y:3.9-17: ]b4_arg[
+[[input.y:3.9-21: ]b4_arg[
 ]])])
 ])