mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
d: improvements on symbol kinds
public enum SymbolKind
{
S_YYEMPTY = -2, /* No symbol. */
S_YYEOF = 0, /* $end */
S_YYERROR = 1, /* error */
S_YYUNDEF = 2, /* $undefined */
S_EQ = 3, /* "=" */
* data/skeletons/d.m4 (api.symbol.prefix): Default to S_.
Output the symbol kind definitions with a comment.
This commit is contained in:
@@ -148,11 +148,9 @@ private static immutable b4_int_type_for([$2])[[]] yy$1_ =
|
|||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
## -------------------------- ##
|
## ------------- ##
|
||||||
## (External) token numbers. ##
|
## Token kinds. ##
|
||||||
## -------------------------- ##
|
## ------------- ##
|
||||||
|
|
||||||
b4_percent_define_default([[api.symbol.prefix]], [[YYSYMBOL_]])
|
|
||||||
|
|
||||||
# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
|
# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
|
||||||
# ---------------------------------------
|
# ---------------------------------------
|
||||||
@@ -165,7 +163,7 @@ m4_define([b4_token_enum],
|
|||||||
# --------------
|
# --------------
|
||||||
# Output the definition of the tokens as enums.
|
# Output the definition of the tokens as enums.
|
||||||
m4_define([b4_token_enums],
|
m4_define([b4_token_enums],
|
||||||
[/* Tokens. */
|
[/* Token kinds. */
|
||||||
public enum YYTokenType {
|
public enum YYTokenType {
|
||||||
|
|
||||||
/** Token returned by the scanner to signal the end of its input. */
|
/** Token returned by the scanner to signal the end of its input. */
|
||||||
@@ -174,19 +172,24 @@ b4_symbol_foreach([b4_token_enum])
|
|||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
## --------------------------- ##
|
|
||||||
## (Internal) symbol numbers. ##
|
|
||||||
## --------------------------- ##
|
## -------------- ##
|
||||||
|
## Symbol kinds. ##
|
||||||
|
## -------------- ##
|
||||||
|
|
||||||
|
b4_percent_define_default([[api.symbol.prefix]], [[S_]])
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_enum(SYMBOL-NUM)
|
# b4_symbol_enum(SYMBOL-NUM)
|
||||||
# --------------------------
|
# --------------------------
|
||||||
# Output the definition of this symbol as an enum.
|
# Output the definition of this symbol as an enum.
|
||||||
m4_define([b4_symbol_enum],
|
m4_define([b4_symbol_enum],
|
||||||
[m4_ifval(b4_symbol([$1], [kind]),
|
[m4_format([ %-30s %s],
|
||||||
[m4_format([[%s = %s]],
|
m4_format([[%s = %s,]],
|
||||||
b4_symbol([$1], [kind]),
|
b4_symbol([$1], [kind]),
|
||||||
b4_symbol([$1], [number]))])])
|
[$1]),
|
||||||
|
[b4_symbol_tag_comment([$1])])])
|
||||||
|
|
||||||
|
|
||||||
# b4_declare_symbol_enum
|
# b4_declare_symbol_enum
|
||||||
@@ -195,14 +198,12 @@ m4_define([b4_symbol_enum],
|
|||||||
# Defining YYEMPTY here is important: it forces the compiler
|
# Defining YYEMPTY here is important: it forces the compiler
|
||||||
# to use a signed type, which matters for yytoken.
|
# to use a signed type, which matters for yytoken.
|
||||||
m4_define([b4_declare_symbol_enum],
|
m4_define([b4_declare_symbol_enum],
|
||||||
[[ /* Symbol type. */
|
[[ /* Symbol kinds. */
|
||||||
public enum SymbolKind
|
public enum SymbolKind
|
||||||
{
|
{
|
||||||
]m4_join([,
|
]b4_symbol_kind([-2])[ = -2, /* No symbol. */
|
||||||
],
|
]b4_symbol_foreach([b4_symbol_enum])dnl
|
||||||
]b4_symbol_kind([-2])[ = -2,
|
[ };
|
||||||
b4_symbol_map([b4_symbol_enum]))[
|
|
||||||
};
|
|
||||||
]])])
|
]])])
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user