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:
@@ -716,7 +716,6 @@ enum { YYENOMEM = -2 };
|
||||
#define yyerrok (yyerrstatus = 0)
|
||||
#define yyclearin (yychar = YYEMPTY)
|
||||
#define YYEMPTY (-2)
|
||||
#define YYEOF 0
|
||||
|
||||
#define YYACCEPT goto yyacceptlab
|
||||
#define YYABORT goto yyabortlab
|
||||
@@ -1760,9 +1759,9 @@ yyread_pushed_token:]])[
|
||||
yychar = ]b4_lex[;]])[
|
||||
}
|
||||
|
||||
if (yychar <= YYEOF)
|
||||
if (yychar <= ]b4_symbol(0, [id])[)
|
||||
{
|
||||
yychar = YYEOF;
|
||||
yychar = ]b4_symbol(0, [id])[;
|
||||
yytoken = ]b4_symbol_prefix[YYEOF;
|
||||
YYDPRINTF ((stderr, "Now at end of input.\n"));
|
||||
}
|
||||
@@ -1957,10 +1956,10 @@ yyerrlab:
|
||||
/* If just tried and failed to reuse lookahead token after an
|
||||
error, discard it. */
|
||||
|
||||
if (yychar <= YYEOF)
|
||||
if (yychar <= ]b4_symbol(0, [id])[)
|
||||
{
|
||||
/* Return failure if at end of input. */
|
||||
if (yychar == YYEOF)
|
||||
if (yychar == ]b4_symbol(0, [id])[)
|
||||
YYABORT;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user