]> git.saurik.com Git - bison.git/blobdiff - tests/regression.at
Pass the token type to yysyntax_error.
[bison.git] / tests / regression.at
index a3e7d4f79851fd8ae0a51001376b9b3a966cd671..cf6534607d17b590f32a101967f4a44a9a7c999f 100644 (file)
@@ -1,6 +1,6 @@
 # Bison Regressions.                               -*- Autotest -*-
 
-# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software
+# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software
 # Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
@@ -393,8 +393,7 @@ input.y:3.14: invalid character: `}'
 input.y:4.1: invalid character: `%'
 input.y:4.2: invalid character: `&'
 input.y:5.1-17: invalid directive: `%a-does-not-exist'
-input.y:6.1: invalid character: `%'
-input.y:6.2: invalid character: `-'
+input.y:6.1-2: invalid directive: `%-'
 input.y:7.1-8.0: missing `%}' at end of file
 input.y:7.1-8.0: syntax error, unexpected %{...%}
 ]])
@@ -444,6 +443,7 @@ int yylex (void);
 %token C_TOKEN 'c'
 %token 'd' D_TOKEN
 %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
+%token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
 %%
 exp: "a" "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!";
 %%
@@ -469,10 +469,22 @@ main (void)
 }
 ]])
 
-AT_BISON_CHECK([-o input.c input.y])
+# Checking the warning message guarantees that the trigraph "??!" isn't
+# unnecessarily escaped here even though it would need to be if encoded in a
+# C-string literal.  Also notice that unnecessary escaping, such as "\?", from
+# the user specification is eliminated.
+AT_BISON_CHECK([-o input.c input.y], [[0]], [[]],
+[[input.y:22.8-14: warning: symbol SPECIAL redeclared
+input.y:22.8-63: warning: symbol `"\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!"' used more than once as a literal string
+]])
 AT_COMPILE([input])
+
+# Checking the error message here guarantees that yytname, which does contain
+# C-string literals, does have the trigraph escaped correctly.  Thus, the
+# symbol name reported by the parser is exactly the same as that reported by
+# Bison itself.
 AT_DATA([experr],
-[[syntax error, unexpected "\\'?\"\a\b\f\n\r\t\v\001\201\001\201?\?!", expecting a
+[[syntax error, unexpected "\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!", expecting a
 ]])
 AT_PARSER_CHECK([./input], 1, [], [experr])
 AT_CLEANUP
@@ -926,11 +938,7 @@ m4_define([AT_CHECK_DANCER],
 AT_BISON_OPTION_PUSHDEFS([$1])
 _AT_DATA_DANCER_Y([$1])
 AT_BISON_CHECK([-o dancer.c dancer.y])
-AT_LALR1_CC_IF(
-  [AT_BISON_CHECK([-o dancer.cc dancer.y])
-   AT_COMPILE_CXX([dancer])],
-  [AT_BISON_CHECK([-o dancer.c dancer.y])
-   AT_COMPILE([dancer])])
+AT_FULL_COMPILE([dancer])
 AT_PARSER_CHECK([./dancer], 1, [],
 [syntax error, unexpected ':'
 ])
@@ -1026,11 +1034,7 @@ m4_define([AT_CHECK_EXPECT2],
 AT_BISON_OPTION_PUSHDEFS([$1])
 _AT_DATA_EXPECT2_Y([$1])
 AT_BISON_CHECK([-o expect2.c expect2.y])
-AT_LALR1_CC_IF(
-  [AT_BISON_CHECK([-o expect2.cc expect2.y])
-   AT_COMPILE_CXX([expect2])],
-  [AT_BISON_CHECK([-o expect2.c expect2.y])
-   AT_COMPILE([expect2])])
+AT_FULL_COMPILE([expect2])
 AT_PARSER_CHECK([./expect2], 1, [],
 [syntax error, unexpected '+', expecting A or B
 ])
@@ -1188,7 +1192,7 @@ AT_CLEANUP
 ## Token number in precedence declaration.  ##
 ## ---------------------------------------- ##
 
-AT_SETUP([[Token number in precedence declaration.]])
+AT_SETUP([[Token number in precedence declaration]])
 
 # POSIX says token numbers can be declared in %left, %right, and %nonassoc, but
 # we lost this in Bison 1.50.
@@ -1242,3 +1246,25 @@ AT_COMPILE([[input]])
 AT_PARSER_CHECK([[./input]])
 
 AT_CLEANUP
+
+
+
+## --------------------------- ##
+## parse-gram.y: LALR = IELR.  ##
+## --------------------------- ##
+
+# If parse-gram.y's LALR and IELR parser tables ever begin to differ, we
+# need to fix parse-gram.y or start using IELR.
+
+AT_SETUP([[parse-gram.y: LALR = IELR]])
+
+# Avoid differences in synclines by telling bison that the output files
+# have the same name.
+[cp $abs_top_srcdir/src/parse-gram.y input.y]
+AT_BISON_CHECK([[-o input.c -Dlr.type=lalr input.y]])
+[mv input.c lalr.c]
+AT_BISON_CHECK([[-o input.c -Dlr.type=ielr input.y]])
+[mv input.c ielr.c]
+AT_CHECK([[diff -u lalr.c ielr.c]])
+
+AT_CLEANUP