mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 18:23:03 +00:00
yysymbol_type_t: always assign an enumerator
Currently we define enumerators only for symbols that have an identifier. That rules out tokens such as '+', and nonterminals such as foo-bar and foo.bar. As a consequence we are taking chances: the compiler might compile yysymbol_type_t as too small an integral type for some symbol codes. * data/skeletons/bison.m4 (b4_symbol_sid): Forge a unique symbol identifier for symbols that don't have an ID.
This commit is contained in:
@@ -407,8 +407,10 @@ m4_define([_b4_symbol],
|
|||||||
|
|
||||||
# b4_symbol_sid(NUM)
|
# b4_symbol_sid(NUM)
|
||||||
# ------------------
|
# ------------------
|
||||||
# Build the symbol ID based for this symbol. Return empty
|
# Build the symbol ID based for this symbol. It must always exist,
|
||||||
# if that would produce an invalid symbol.
|
# otherwise some symbols might not be represented in the enum, which
|
||||||
|
# might be compiled into too small a type to contain all the symbol
|
||||||
|
# numbers.
|
||||||
m4_define([b4_symbol_sid],
|
m4_define([b4_symbol_sid],
|
||||||
[m4_case([$1],
|
[m4_case([$1],
|
||||||
[-2], [[YYSYMBOL_YYEMPTY]],
|
[-2], [[YYSYMBOL_YYEMPTY]],
|
||||||
@@ -417,8 +419,9 @@ m4_define([b4_symbol_sid],
|
|||||||
[$accept], [[YYSYMBOL_YYACCEPT]],
|
[$accept], [[YYSYMBOL_YYACCEPT]],
|
||||||
[error], [[YYSYMBOL_YYERROR]],
|
[error], [[YYSYMBOL_YYERROR]],
|
||||||
[$undefined], [[YYSYMBOL_YYUNDEF]],
|
[$undefined], [[YYSYMBOL_YYUNDEF]],
|
||||||
[m4_quote(b4_symbol_if([$1], [has_id],
|
[b4_symbol_if([$1], [has_id],
|
||||||
[[YYSYMBOL_]]m4_quote(_b4_symbol([$1], [id]))))])])])
|
[[YYSYMBOL_]]m4_quote(_b4_symbol([$1], [id])),
|
||||||
|
[[YYSYMBOL_$1_][]m4_bpatsubst(m4_quote(_b4_symbol([$1], [tag])), [[^a-zA-Z_0-9]], [_])])])])])
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol(NUM, FIELD)
|
# b4_symbol(NUM, FIELD)
|
||||||
|
|||||||
Reference in New Issue
Block a user