mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-04-25 02:59:38 +00:00
tokens: properly define the "error" token kind
There are people out there that do use YYERRCODE (the token kind of the error token). See for instance https://github.com/borbolla-automation/SPC_Machines/blob/3812012bb782bfdfe7b325950a35cd337925fcad/unixODBC-2.3.2/Drivers/nn/yylex.c. Currently, YYERRCODE is defined by yacc.c in an adhoc way as a #define in the *.c file only. It belongs with the other token kinds. YYERRCODE is not a nice name, it does not fit in our naming scheme. YYERROR would be more logical, but it collides with the YYERROR macro. Shall we keep the same name in all the skeletons? Besides, to avoid collisions in C, we need to apply the api prefix: YYERRCODE is actually <PREFIX>ERRCODE. This is not needed in the other languages. * data/skeletons/bison.m4 (b4_symbol_token_kind): New. Map the error token to "YYERRCODE". * data/skeletons/yacc.c (YYERRCODE): Don't define it, it's handled by... * src/output.c (prepare_symbol_definitions): this. * tests/input.at (Redefining the error token): Check it.
This commit is contained in:
+1
-1
@@ -550,7 +550,7 @@ prepare_symbol_definitions (void)
|
||||
|
||||
SET_KEY ("is_token");
|
||||
MUSCLE_INSERT_INT (key,
|
||||
i < ntokens && sym != errtoken && sym != undeftoken);
|
||||
i < ntokens && sym != undeftoken);
|
||||
|
||||
SET_KEY ("number");
|
||||
MUSCLE_INSERT_INT (key, sym->content->number);
|
||||
|
||||
@@ -927,9 +927,6 @@ enum { YYENOMEM = -2 };
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* Error token external number. */
|
||||
#define YYERRCODE 256
|
||||
|
||||
|
||||
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
||||
If N is 0, then set CURRENT to the empty location which ends
|
||||
|
||||
@@ -78,6 +78,7 @@ extern int gram_debug;
|
||||
enum gram_tokentype
|
||||
{
|
||||
GRAM_EOF = 0, /* "end of file" */
|
||||
GRAM_ERRCODE = 1, /* error */
|
||||
STRING = 3, /* "string" */
|
||||
TSTRING = 4, /* "translatable string" */
|
||||
PERCENT_TOKEN = 5, /* "%token" */
|
||||
|
||||
Reference in New Issue
Block a user