mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-04-24 02:29:43 +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:
+14
-2
@@ -405,6 +405,14 @@ m4_define([_b4_symbol],
|
||||
[__b4_symbol([$1], [$2])])])
|
||||
|
||||
|
||||
# b4_symbol_token_kind(NUM)
|
||||
# -------------------------
|
||||
# The token kind of this symbol.
|
||||
m4_define([b4_symbol_token_kind],
|
||||
[b4_percent_define_get([api.token.prefix])dnl
|
||||
_b4_symbol([$1], [id])])
|
||||
|
||||
|
||||
# b4_symbol_kind(NUM)
|
||||
# -------------------
|
||||
# Build the name of the kind of this symbol. It must always exist,
|
||||
@@ -432,8 +440,7 @@ m4_case([$1],
|
||||
# If FIELD = id, prepend the token prefix.
|
||||
m4_define([b4_symbol],
|
||||
[m4_case([$2],
|
||||
[id], [m4_do([b4_percent_define_get([api.token.prefix])],
|
||||
[_b4_symbol([$1], [id])])],
|
||||
[id], [b4_symbol_token_kind([$1])],
|
||||
[kind], [b4_symbol_kind([$1])],
|
||||
[_b4_symbol($@)])])
|
||||
|
||||
@@ -449,6 +456,10 @@ m4_define([b4_symbol_if],
|
||||
[m4_fatal([$0: field $2 of $1 is not a Boolean:] b4_symbol([$1], [$2]))])])
|
||||
|
||||
|
||||
# Give the error token a better name.
|
||||
m4_define([b4_symbol(1, id)], [b4_api_PREFIX[][ERRCODE]])
|
||||
|
||||
|
||||
# b4_symbol_tag_comment(SYMBOL-NUM)
|
||||
# ---------------------------------
|
||||
# Issue a comment giving the tag of symbol NUM.
|
||||
@@ -534,6 +545,7 @@ m4_define([b4_token_visible_if],
|
||||
[b4_symbol_if([$1], [has_id], [$2], [$3])],
|
||||
[$3])])
|
||||
|
||||
|
||||
# b4_token_has_definition(NUM)
|
||||
# ----------------------------
|
||||
# 1 if NUM is visible, nothing otherwise.
|
||||
|
||||
@@ -743,9 +743,6 @@ enum { YYENOMEM = -2 };
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* Error token external number. */
|
||||
#define YYERRCODE ]b4_symbol(1, user_number)[
|
||||
|
||||
]b4_locations_if([[
|
||||
]b4_yylloc_default_define[
|
||||
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
|
||||
|
||||
Reference in New Issue
Block a user