mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
tokens: properly define the YYEOF token kind
Currently EOF is handled in an adhoc way, with a #define YYEOF 0 in the implementation file. As a result, the user has to define her own EOF token if she wants to use it, which is a pity. Give the $end token a visible kind name, YYEOF. Except that in C, where enums are not scoped, we would have collisions between all the definitions of YYEOFs in the header files, so in C, make it <api.PREFIX>EOF. * data/skeletons/c.m4 (YYEOF): Override its name to avoid collisions. Unless the user already gave it a different name. * data/skeletons/glr.c (YYEOF): Remove. Use ]b4_symbol(0, [id])[ instead. Add support for "pre_epilogue", for glr.cc. * data/skeletons/glr.cc: Remove dead code (never emitted #undefs). * data/skeletons/yacc.c * src/parse-gram.c * src/reader.c * src/symtab.c * tests/actions.at * tests/input.at
This commit is contained in:
@@ -1303,6 +1303,15 @@ AT_CLEANUP
|
||||
|
||||
AT_SETUP([Default %printer and %destructor for user-defined end token])
|
||||
|
||||
# Enable declaration of default %printer/%destructor. Make the parser
|
||||
# use these for all user-declared grammar symbols for which the user
|
||||
# does not declare a specific %printer/%destructor. Thus, the parser
|
||||
# uses it for token 0 if the user declares it but not if Bison
|
||||
# generates it as $end. Discussed starting at
|
||||
# <http://lists.gnu.org/r/bison-patches/2006-02/msg00064.html>,
|
||||
# <http://lists.gnu.org/r/bison-patches/2006-06/msg00091.html>, and
|
||||
# <http://lists.gnu.org/r/bison-patches/2006-07/msg00019.html>.
|
||||
|
||||
# AT_TEST(TYPED)
|
||||
# --------------
|
||||
m4_pushdef([AT_TEST],
|
||||
|
||||
@@ -344,6 +344,7 @@ exp:
|
||||
int main (void)
|
||||
{
|
||||
assert (YYERRCODE == 123);
|
||||
assert (YYTRANSLATE (YYEOF) == YYSYMBOL_YYEOF);
|
||||
assert (YYTRANSLATE (YYERRCODE) == YYSYMBOL_YYERROR);
|
||||
assert (YYTRANSLATE (YYUNDEF) == YYSYMBOL_YYUNDEF);
|
||||
return 0;
|
||||
@@ -430,7 +431,7 @@ exp:;
|
||||
AT_BISON_CHECK([-Wno-other -S./dump-symbols.m4 input.y])
|
||||
AT_CHECK([cat symbols.csv], [],
|
||||
[[number, class, tag, id, user_number, type,
|
||||
0, Token, $end, , 0, ,
|
||||
0, Token, $end, YYEOF, 0, ,
|
||||
1, Token, error, YYERRCODE, 256, ,
|
||||
2, Token, $undefined, YYUNDEF, 257, ,
|
||||
3, Token, 'a', , 97, ,
|
||||
|
||||
Reference in New Issue
Block a user