mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
d, java: rename SymbolType as SymbolKind
See https://lists.gnu.org/r/bison-patches/2020-04/msg00031.html. * data/skeletons/d.m4, data/skeletons/lalr1.d, * data/skeletons/java.m4, data/skeletons/lalr1.java (SymbolType): Rename as... (SymbolKind): this. Adjust dependencies.
This commit is contained in:
@@ -194,7 +194,7 @@ m4_define([b4_symbol_enum],
|
||||
# to use a signed type, which matters for yytoken.
|
||||
m4_define([b4_declare_symbol_enum],
|
||||
[[ /* Symbol type. */
|
||||
public enum SymbolType
|
||||
public enum SymbolKind
|
||||
{
|
||||
]m4_join([,
|
||||
],
|
||||
|
||||
@@ -167,7 +167,7 @@ m4_define([b4_symbol_enum],
|
||||
# ----------------------
|
||||
# The definition of the symbol internal numbers as an enum.
|
||||
m4_define([b4_declare_symbol_enum],
|
||||
[[ public enum SymbolType
|
||||
[[ public enum SymbolKind
|
||||
{
|
||||
]m4_join([,
|
||||
],
|
||||
@@ -176,16 +176,16 @@ m4_define([b4_declare_symbol_enum],
|
||||
|
||||
private final int code_;
|
||||
|
||||
SymbolType (int n) {
|
||||
SymbolKind (int n) {
|
||||
this.code_ = n;
|
||||
}
|
||||
|
||||
private static final SymbolType[] values_ = {
|
||||
private static final SymbolKind[] values_ = {
|
||||
]m4_map_args_sep([b4_symbol_sid(], [)], [,
|
||||
], b4_symbol_numbers)[
|
||||
};
|
||||
|
||||
static final SymbolType get (int code) {
|
||||
static final SymbolKind get (int code) {
|
||||
return values_[code];
|
||||
}
|
||||
|
||||
|
||||
@@ -343,7 +343,7 @@ b4_user_union_members
|
||||
|
||||
]b4_parse_trace_if([[
|
||||
import std.conv : to;
|
||||
yy_symbol_print ("-> $$ =", to!SymbolType (yyr1_[yyn]), yyval]b4_locations_if([, yyloc])[);]])[
|
||||
yy_symbol_print ("-> $$ =", to!SymbolKind (yyr1_[yyn]), yyval]b4_locations_if([, yyloc])[);]])[
|
||||
|
||||
yystack.pop (yylen);
|
||||
yylen = 0;
|
||||
@@ -401,7 +401,7 @@ b4_user_union_members
|
||||
| Print this symbol on YYOUTPUT. |
|
||||
`--------------------------------*/
|
||||
|
||||
private final void yy_symbol_print (string s, SymbolType yytype,
|
||||
private final void yy_symbol_print (string s, SymbolKind yytype,
|
||||
ref ]b4_yystype[ yyvaluep]dnl
|
||||
b4_locations_if([, ref ]b4_location_type[ yylocationp])[)
|
||||
{
|
||||
@@ -430,7 +430,7 @@ b4_locations_if([, ref ]b4_location_type[ yylocationp])[)
|
||||
{
|
||||
/// Lookahead and lookahead in internal form.
|
||||
int yychar = yyempty_;
|
||||
SymbolType yytoken = SymbolType.YYSYMBOL_YYEMPTY;
|
||||
SymbolKind yytoken = SymbolKind.YYSYMBOL_YYEMPTY;
|
||||
|
||||
/* State. */
|
||||
int yyn = 0;
|
||||
@@ -574,7 +574,7 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
{
|
||||
++yynerrs_;
|
||||
if (yychar == yyempty_)
|
||||
yytoken = SymbolType.YYSYMBOL_YYEMPTY;
|
||||
yytoken = SymbolKind.YYSYMBOL_YYEMPTY;
|
||||
yyerror (]b4_locations_if([yylloc, ])[yysyntax_error (yystate, yytoken));
|
||||
}
|
||||
|
||||
@@ -623,8 +623,8 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
yyn = yypact_[yystate];
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
{
|
||||
yyn += SymbolType.YYSYMBOL_YYERROR;
|
||||
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == SymbolType.YYSYMBOL_YYERROR)
|
||||
yyn += SymbolKind.YYSYMBOL_YYERROR;
|
||||
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == SymbolKind.YYSYMBOL_YYERROR)
|
||||
{
|
||||
yyn = yytable_[yyn];
|
||||
if (0 < yyn)
|
||||
@@ -652,7 +652,7 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
|
||||
/* Shift the error token. */]b4_parse_trace_if([[
|
||||
import std.conv : to;
|
||||
yy_symbol_print ("Shifting", to!SymbolType (yystos_[yyn]), yylval]b4_locations_if([, yyloc])[);]])[
|
||||
yy_symbol_print ("Shifting", to!SymbolKind (yystos_[yyn]), yylval]b4_locations_if([, yyloc])[);]])[
|
||||
yystate = yyn;
|
||||
yystack.push (yyn, yylval]b4_locations_if([, yyloc])[);
|
||||
label = YYNEWSTATE;
|
||||
@@ -678,7 +678,7 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
}
|
||||
|
||||
// Generate an error message.
|
||||
private final string yysyntax_error (int yystate, SymbolType tok)
|
||||
private final string yysyntax_error (int yystate, SymbolKind tok)
|
||||
{]b4_parse_error_case([verbose], [[
|
||||
/* There are many possibilities here to consider:
|
||||
- Assume YYFAIL is not used. It's too flawed to consider.
|
||||
@@ -711,7 +711,7 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
will still contain any token that will not be accepted due
|
||||
to an error action in a later state.
|
||||
*/
|
||||
if (tok != SymbolType.YYSYMBOL_YYEMPTY)
|
||||
if (tok != SymbolKind.YYSYMBOL_YYEMPTY)
|
||||
{
|
||||
// FIXME: This method of building the message is not compatible
|
||||
// with internationalization.
|
||||
@@ -730,14 +730,14 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
|
||||
int count = 0;
|
||||
for (int x = yyxbegin; x < yyxend; ++x)
|
||||
if (yycheck_[x + yyn] == x && x != SymbolType.YYSYMBOL_YYERROR
|
||||
if (yycheck_[x + yyn] == x && x != SymbolKind.YYSYMBOL_YYERROR
|
||||
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
||||
++count;
|
||||
if (count < 5)
|
||||
{
|
||||
count = 0;
|
||||
for (int x = yyxbegin; x < yyxend; ++x)
|
||||
if (yycheck_[x + yyn] == x && x != SymbolType.YYSYMBOL_YYERROR
|
||||
if (yycheck_[x + yyn] == x && x != SymbolKind.YYSYMBOL_YYERROR
|
||||
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
|
||||
{
|
||||
res ~= count++ == 0 ? ", expecting " : " or ";
|
||||
@@ -809,17 +809,17 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
import std.conv : to;
|
||||
for (int yyi = 0; yyi < yynrhs; yyi++)
|
||||
yy_symbol_print (format(" $%d =", yyi + 1),
|
||||
to!SymbolType (yystos_[yystack.stateAt(yynrhs - (yyi + 1))]),
|
||||
to!SymbolKind (yystos_[yystack.stateAt(yynrhs - (yyi + 1))]),
|
||||
]b4_rhs_value(yynrhs, yyi + 1)b4_locations_if([,
|
||||
b4_rhs_location(yynrhs, yyi + 1)])[);
|
||||
}
|
||||
]])[
|
||||
|
||||
private static SymbolType yytranslate_ (int t)
|
||||
private static SymbolKind yytranslate_ (int t)
|
||||
{
|
||||
]b4_api_token_raw_if(
|
||||
[[ import std.conv : to;
|
||||
return to!SymbolType (t);]],
|
||||
return to!SymbolKind (t);]],
|
||||
[[ /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
||||
immutable ]b4_int_type_for([b4_translate])[[] translate_table =
|
||||
@{
|
||||
@@ -829,14 +829,14 @@ m4_popdef([b4_at_dollar])])dnl
|
||||
immutable int user_token_number_max_ = ]b4_user_token_number_max[;
|
||||
|
||||
if (t <= 0)
|
||||
return SymbolType.YYSYMBOL_YYEOF;
|
||||
return SymbolKind.YYSYMBOL_YYEOF;
|
||||
else if (t <= user_token_number_max_)
|
||||
{
|
||||
import std.conv : to;
|
||||
return to!SymbolType (translate_table[t]);
|
||||
return to!SymbolKind (translate_table[t]);
|
||||
}
|
||||
else
|
||||
return SymbolType.YYSYMBOL_YYUNDEF;]])[
|
||||
return SymbolKind.YYSYMBOL_YYUNDEF;]])[
|
||||
}
|
||||
|
||||
private static immutable int yylast_ = ]b4_last[;
|
||||
|
||||
@@ -55,7 +55,7 @@ b4_use_push_for_pull_if([
|
||||
m4_define([b4_define_state],[[
|
||||
/* Lookahead and lookahead in internal form. */
|
||||
int yychar = yyempty_;
|
||||
SymbolType yytoken = SymbolType.YYSYMBOL_YYEMPTY;
|
||||
SymbolKind yytoken = SymbolKind.YYSYMBOL_YYEMPTY;
|
||||
|
||||
/* State. */
|
||||
int yyn = 0;
|
||||
@@ -484,7 +484,7 @@ import java.text.MessageFormat;
|
||||
default: break;
|
||||
}]b4_parse_trace_if([[
|
||||
|
||||
yySymbolPrint ("-> $$ =", SymbolType.get (yyr1_[yyn]), yyval]b4_locations_if([, yyloc])[);]])[
|
||||
yySymbolPrint ("-> $$ =", SymbolKind.get (yyr1_[yyn]), yyval]b4_locations_if([, yyloc])[);]])[
|
||||
|
||||
yystack.pop (yylen);
|
||||
yylen = 0;
|
||||
@@ -499,7 +499,7 @@ import java.text.MessageFormat;
|
||||
| Print this symbol on YYOUTPUT. |
|
||||
`--------------------------------*/
|
||||
|
||||
private void yySymbolPrint (String s, SymbolType yytype,
|
||||
private void yySymbolPrint (String s, SymbolKind yytype,
|
||||
]b4_yystype[ yyvaluep]dnl
|
||||
b4_locations_if([, Object yylocationp])[)
|
||||
{
|
||||
@@ -678,7 +678,7 @@ b4_dollar_popdef[]dnl
|
||||
{
|
||||
++yynerrs;
|
||||
if (yychar == yyempty_)
|
||||
yytoken = SymbolType.YYSYMBOL_YYEMPTY;
|
||||
yytoken = SymbolKind.YYSYMBOL_YYEMPTY;
|
||||
yyreportSyntaxError (new Context (yystack, yytoken]b4_locations_if([[, yylloc]])[));
|
||||
}
|
||||
|
||||
@@ -728,9 +728,9 @@ b4_dollar_popdef[]dnl
|
||||
yyn = yypact_[yystate];
|
||||
if (!yyPactValueIsDefault (yyn))
|
||||
{
|
||||
yyn += SymbolType.YYSYMBOL_YYERROR.getCode ();
|
||||
yyn += SymbolKind.YYSYMBOL_YYERROR.getCode ();
|
||||
if (0 <= yyn && yyn <= yylast_
|
||||
&& yycheck_[yyn] == SymbolType.YYSYMBOL_YYERROR.getCode ())
|
||||
&& yycheck_[yyn] == SymbolKind.YYSYMBOL_YYERROR.getCode ())
|
||||
{
|
||||
yyn = yytable_[yyn];
|
||||
if (0 < yyn)
|
||||
@@ -763,7 +763,7 @@ b4_dollar_popdef[]dnl
|
||||
yystack.pop (2);]])[
|
||||
|
||||
/* Shift the error token. */]b4_parse_trace_if([[
|
||||
yySymbolPrint ("Shifting", SymbolType.get (yystos_[yyn]),
|
||||
yySymbolPrint ("Shifting", SymbolKind.get (yystos_[yyn]),
|
||||
yylval]b4_locations_if([, yyloc])[);]])[
|
||||
|
||||
yystate = yyn;
|
||||
@@ -792,7 +792,7 @@ b4_dollar_popdef[]dnl
|
||||
{
|
||||
/* Lookahead and lookahead in internal form. */
|
||||
this.yychar = yyempty_;
|
||||
this.yytoken = SymbolType.YYSYMBOL_YYEMPTY;
|
||||
this.yytoken = SymbolKind.YYSYMBOL_YYEMPTY;
|
||||
|
||||
/* State. */
|
||||
this.yyn = 0;
|
||||
@@ -864,7 +864,7 @@ b4_dollar_popdef[]dnl
|
||||
*/
|
||||
public static final class Context
|
||||
{
|
||||
Context (YYStack stack, SymbolType token]b4_locations_if([[, ]b4_location_type[ loc]])[)
|
||||
Context (YYStack stack, SymbolKind token]b4_locations_if([[, ]b4_location_type[ loc]])[)
|
||||
{
|
||||
yystack = stack;
|
||||
yytoken = token;]b4_locations_if([[
|
||||
@@ -873,7 +873,7 @@ b4_dollar_popdef[]dnl
|
||||
|
||||
private YYStack yystack;
|
||||
|
||||
public SymbolType getToken ()
|
||||
public SymbolKind getToken ()
|
||||
{
|
||||
return yytoken;
|
||||
}
|
||||
@@ -883,7 +883,7 @@ b4_dollar_popdef[]dnl
|
||||
*/
|
||||
public static final int EMPTY = ]b4_parser_class[.yyempty_;
|
||||
|
||||
private SymbolType yytoken;]b4_locations_if([[
|
||||
private SymbolKind yytoken;]b4_locations_if([[
|
||||
public ]b4_location_type[ getLocation ()
|
||||
{
|
||||
return yylocation;
|
||||
@@ -896,12 +896,12 @@ b4_dollar_popdef[]dnl
|
||||
current YYCTX, and return the number of tokens stored in YYARG. If
|
||||
YYARG is null, return the number of expected tokens (guaranteed to
|
||||
be less than YYNTOKENS). */
|
||||
int yyexpectedTokens (SymbolType yyarg[], int yyargn)
|
||||
int yyexpectedTokens (SymbolKind yyarg[], int yyargn)
|
||||
{
|
||||
return yyexpectedTokens (yyarg, 0, yyargn);
|
||||
}
|
||||
|
||||
int yyexpectedTokens (SymbolType yyarg[], int yyoffset, int yyargn)
|
||||
int yyexpectedTokens (SymbolKind yyarg[], int yyoffset, int yyargn)
|
||||
{
|
||||
int yycount = yyoffset;
|
||||
int yyn = yypact_[this.yystack.stateAt (0)];
|
||||
@@ -916,7 +916,7 @@ b4_dollar_popdef[]dnl
|
||||
int yychecklim = yylast_ - yyn + 1;
|
||||
int yyxend = yychecklim < NTOKENS ? yychecklim : NTOKENS;
|
||||
for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
|
||||
if (yycheck_[yyx + yyn] == yyx && yyx != SymbolType.YYSYMBOL_YYERROR.getCode ()
|
||||
if (yycheck_[yyx + yyn] == yyx && yyx != SymbolKind.YYSYMBOL_YYERROR.getCode ()
|
||||
&& !yyTableValueIsError (yytable_[yyx + yyn]))
|
||||
{
|
||||
if (yyarg == null)
|
||||
@@ -924,7 +924,7 @@ b4_dollar_popdef[]dnl
|
||||
else if (yycount == yyargn)
|
||||
return 0; // FIXME: this is incorrect.
|
||||
else
|
||||
yyarg[yycount++] = SymbolType.get (yyx);
|
||||
yyarg[yycount++] = SymbolKind.get (yyx);
|
||||
}
|
||||
}
|
||||
return yycount - yyoffset;
|
||||
@@ -932,7 +932,7 @@ b4_dollar_popdef[]dnl
|
||||
|
||||
/* The user-facing name of the symbol whose (internal) number is
|
||||
YYSYMBOL. No bounds checking. */
|
||||
static String yysymbolName (SymbolType yysymbol)
|
||||
static String yysymbolName (SymbolKind yysymbol)
|
||||
{
|
||||
return ]b4_parser_class[.yysymbolName (yysymbol);
|
||||
}
|
||||
@@ -940,7 +940,7 @@ b4_dollar_popdef[]dnl
|
||||
|
||||
]b4_parse_error_bmatch(
|
||||
[detailed\|verbose], [[
|
||||
private int yysyntaxErrorArguments (Context yyctx, SymbolType[] yyarg, int yyargn)
|
||||
private int yysyntaxErrorArguments (Context yyctx, SymbolKind[] yyarg, int yyargn)
|
||||
{
|
||||
/* There are many possibilities here to consider:
|
||||
- If this state is a consistent state with a default action,
|
||||
@@ -969,7 +969,7 @@ b4_dollar_popdef[]dnl
|
||||
to an error action in a later state.
|
||||
*/
|
||||
int yycount = 0;
|
||||
if (yyctx.getToken () != SymbolType.YYSYMBOL_YYEMPTY)
|
||||
if (yyctx.getToken () != SymbolKind.YYSYMBOL_YYEMPTY)
|
||||
{
|
||||
yyarg[yycount++] = yyctx.getToken ();
|
||||
yycount += yyctx.yyexpectedTokens (yyarg, 1, yyargn);
|
||||
@@ -989,7 +989,7 @@ b4_dollar_popdef[]dnl
|
||||
if (yyErrorVerbose)
|
||||
{
|
||||
final int argmax = 5;
|
||||
SymbolType[] yyarg = new SymbolType[argmax];
|
||||
SymbolKind[] yyarg = new SymbolKind[argmax];
|
||||
int yycount = yysyntaxErrorArguments (yyctx, yyarg, argmax);
|
||||
String[] yystr = new String[yycount];
|
||||
for (int yyi = 0; yyi < yycount; ++yyi)
|
||||
@@ -1080,7 +1080,7 @@ b4_dollar_popdef[]dnl
|
||||
|
||||
/* The user-facing name of the symbol whose (internal) number is
|
||||
YYSYMBOL. No bounds checking. */
|
||||
static String yysymbolName (SymbolType yysymbol)
|
||||
static String yysymbolName (SymbolKind yysymbol)
|
||||
{
|
||||
return yytnamerr_ (yytname_[yysymbol.getCode ()]);
|
||||
}
|
||||
@@ -1088,7 +1088,7 @@ b4_dollar_popdef[]dnl
|
||||
[custom\|detailed],
|
||||
[[ /* The user-facing name of the symbol whose (internal) number is
|
||||
YYSYMBOL. No bounds checking. */
|
||||
static String yysymbolName (SymbolType yysymbol)
|
||||
static String yysymbolName (SymbolKind yysymbol)
|
||||
{
|
||||
String[] yy_sname =
|
||||
{
|
||||
@@ -1117,27 +1117,27 @@ b4_dollar_popdef[]dnl
|
||||
/* The symbols being reduced. */
|
||||
for (int yyi = 0; yyi < yynrhs; yyi++)
|
||||
yySymbolPrint (" $" + (yyi + 1) + " =",
|
||||
SymbolType.get (yystos_[yystack.stateAt (yynrhs - (yyi + 1))]),
|
||||
SymbolKind.get (yystos_[yystack.stateAt (yynrhs - (yyi + 1))]),
|
||||
]b4_rhs_data(yynrhs, yyi + 1)b4_locations_if([,
|
||||
b4_rhs_location(yynrhs, yyi + 1)])[);
|
||||
}]])[
|
||||
|
||||
/* YYTRANSLATE_(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
|
||||
as returned by yylex, with out-of-bounds checking. */
|
||||
private static final SymbolType yytranslate_ (int t)
|
||||
private static final SymbolKind yytranslate_ (int t)
|
||||
]b4_api_token_raw_if(dnl
|
||||
[[ {
|
||||
return SymbolType.get (t);
|
||||
return SymbolKind.get (t);
|
||||
}
|
||||
]],
|
||||
[[ {
|
||||
int user_token_number_max_ = ]b4_user_token_number_max[;
|
||||
if (t <= 0)
|
||||
return SymbolType.YYSYMBOL_YYEOF;
|
||||
return SymbolKind.YYSYMBOL_YYEOF;
|
||||
else if (t <= user_token_number_max_)
|
||||
return SymbolType.get (yytranslate_table_[t]);
|
||||
return SymbolKind.get (yytranslate_table_[t]);
|
||||
else
|
||||
return SymbolType.YYSYMBOL_YYUNDEF;
|
||||
return SymbolKind.YYSYMBOL_YYUNDEF;
|
||||
}
|
||||
]b4_integral_parser_table_define([translate_table], [b4_translate])[
|
||||
]])[
|
||||
|
||||
Reference in New Issue
Block a user