mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-20 01:33:03 +00:00
d: use the SymbolType enum for symbol kinds
* data/skeletons/d.m4 (b4_symbol_enum, b4_declare_symbol_enum): New. * data/skeletons/lalr1.d: Use them. Use SymbolType, SymbolType.YYSYMBOL_YYEMPTY etc. where appropriate. (undef_token_, token_number_type, yy_error_token_): Remove.
This commit is contained in:
@@ -148,9 +148,9 @@ private static immutable b4_int_type_for([$2])[[]] yy$1_ =
|
||||
])
|
||||
|
||||
|
||||
## ------------------------- ##
|
||||
## Assigning token numbers. ##
|
||||
## ------------------------- ##
|
||||
## -------------------------- ##
|
||||
## (External) token numbers. ##
|
||||
## -------------------------- ##
|
||||
|
||||
# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
|
||||
# ---------------------------------------
|
||||
@@ -159,8 +159,8 @@ m4_define([b4_token_enum],
|
||||
[b4_token_format([ %s = %s,
|
||||
], [$1])])
|
||||
|
||||
# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||
# -----------------------------------------------------
|
||||
# b4_token_enums
|
||||
# --------------
|
||||
# Output the definition of the tokens as enums.
|
||||
m4_define([b4_token_enums],
|
||||
[/* Tokens. */
|
||||
@@ -172,6 +172,39 @@ b4_symbol_foreach([b4_token_enum])
|
||||
}
|
||||
])
|
||||
|
||||
## --------------------------- ##
|
||||
## (Internal) symbol numbers. ##
|
||||
## --------------------------- ##
|
||||
|
||||
|
||||
# b4_symbol_enum(SYMBOL-NUM)
|
||||
# --------------------------
|
||||
# Output the definition of this symbol as an enum.
|
||||
m4_define([b4_symbol_enum],
|
||||
[m4_ifval(b4_symbol([$1], [sid]),
|
||||
[m4_format([[%s = %s]],
|
||||
b4_symbol([$1], [sid]),
|
||||
b4_symbol([$1], [number]))])])
|
||||
|
||||
|
||||
# b4_declare_symbol_enum
|
||||
# ----------------------
|
||||
# The definition of the symbol internal numbers as an enum.
|
||||
# Defining YYEMPTY here is important: it forces the compiler
|
||||
# to use a signed type, which matters for yytoken.
|
||||
m4_define([b4_declare_symbol_enum],
|
||||
[[ /* Symbol type. */
|
||||
public enum SymbolType
|
||||
{
|
||||
]m4_join([,
|
||||
],
|
||||
]b4_symbol_sid([-2])[ = -2,
|
||||
b4_symbol_map([b4_symbol_enum]))[
|
||||
};
|
||||
]])])
|
||||
|
||||
|
||||
|
||||
# b4-case(ID, CODE)
|
||||
# -----------------
|
||||
m4_define([b4_case], [ case $1:
|
||||
|
||||
Reference in New Issue
Block a user