java: style: fix coding style

* data/skeletons/java.m4: Indent by two.
* data/skeletons/lalr1.java (yynnts_): Remove.
(yyfinal_, yyntokens_, yylast_, yyempty_): Rename as...
(YYFINAL_, YYNTOKENS_, YYLAST_, YYEMPTY_): these, they are constants.
This commit is contained in:
Akim Demaille
2020-04-06 13:44:06 +02:00
parent e657f04b62
commit 0f6ab8e692
2 changed files with 26 additions and 27 deletions

View File

@@ -181,8 +181,8 @@ m4_define([b4_declare_symbol_enum],
} }
private static final SymbolKind[] values_ = { private static final SymbolKind[] values_ = {
]m4_map_args_sep([b4_symbol_kind(], [)], [, ]m4_map_args_sep([b4_symbol_kind(], [)], [,
], b4_symbol_numbers)[ ], b4_symbol_numbers)[
}; };
static final SymbolKind get (int code) { static final SymbolKind get (int code) {

View File

@@ -54,7 +54,7 @@ b4_use_push_for_pull_if([
# or as class instance variable when doing push parsing. # or as class instance variable when doing push parsing.
m4_define([b4_define_state],[[ m4_define([b4_define_state],[[
/* Lookahead and lookahead in internal form. */ /* Lookahead and lookahead in internal form. */
int yychar = yyempty_; int yychar = YYEMPTY_;
SymbolKind yytoken = SymbolKind.YYSYMBOL_YYEMPTY; SymbolKind yytoken = SymbolKind.YYSYMBOL_YYEMPTY;
/* State. */ /* State. */
@@ -223,7 +223,7 @@ import java.text.MessageFormat;
[custom], [[ [custom], [[
void yyreportSyntaxError (][Context yyctx); void yyreportSyntaxError (][Context yyctx);
]])[ ]])[
} }
]b4_lexer_if([[ ]b4_lexer_if([[
private class YYLexer implements Lexer { private class YYLexer implements Lexer {
@@ -385,8 +385,8 @@ import java.text.MessageFormat;
public final ]b4_location_type[ locationAt (int i) { public final ]b4_location_type[ locationAt (int i) {
return locStack[height - i]; return locStack[height - i];
} }
]])[
]])[public final ]b4_yystype[ valueAt (int i) { public final ]b4_yystype[ valueAt (int i) {
return valueStack[height - i]; return valueStack[height - i];
} }
@@ -458,11 +458,11 @@ import java.text.MessageFormat;
*/ */
private int yyLRGotoState (int yystate, int yysym) private int yyLRGotoState (int yystate, int yysym)
{ {
int yyr = yypgoto_[yysym - yyntokens_] + yystate; int yyr = yypgoto_[yysym - YYNTOKENS_] + yystate;
if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate) if (0 <= yyr && yyr <= YYLAST_ && yycheck_[yyr] == yystate)
return yytable_[yyr]; return yytable_[yyr];
else else
return yydefgoto_[yysym - yyntokens_]; return yydefgoto_[yysym - YYNTOKENS_];
} }
private int yyaction (int yyn, YYStack yystack, int yylen)]b4_maybe_throws([b4_throws])[ private int yyaction (int yyn, YYStack yystack, int yylen)]b4_maybe_throws([b4_throws])[
@@ -503,7 +503,7 @@ import java.text.MessageFormat;
]b4_yystype[ yyvaluep]dnl ]b4_yystype[ yyvaluep]dnl
b4_locations_if([, Object yylocationp])[) b4_locations_if([, Object yylocationp])[)
{ {
yycdebug (s + (yykind.getCode () < yyntokens_ ? " token " : " nterm ") yycdebug (s + (yykind.getCode () < YYNTOKENS_ ? " token " : " nterm ")
+ yysymbolName (yykind) + " ("]b4_locations_if([ + yysymbolName (yykind) + " ("]b4_locations_if([
+ yylocationp + ": "])[ + yylocationp + ": "])[
+ (yyvaluep == null ? "(null)" : yyvaluep.toString ()) + ")"); + (yyvaluep == null ? "(null)" : yyvaluep.toString ()) + ")");
@@ -573,7 +573,7 @@ b4_dollar_popdef[]dnl
yystack.print (yyDebugStream);]])[ yystack.print (yyDebugStream);]])[
/* Accept? */ /* Accept? */
if (yystate == yyfinal_) if (yystate == YYFINAL_)
]b4_push_if([{label = YYACCEPT; break;}], ]b4_push_if([{label = YYACCEPT; break;}],
[return true;])[ [return true;])[
@@ -588,7 +588,7 @@ b4_dollar_popdef[]dnl
case YYGETTOKEN:])[ case YYGETTOKEN:])[
/* Read a lookahead token. */ /* Read a lookahead token. */
if (yychar == yyempty_) if (yychar == YYEMPTY_)
{ {
]b4_push_if([[ ]b4_push_if([[
if (!push_token_consumed) if (!push_token_consumed)
@@ -614,7 +614,7 @@ b4_dollar_popdef[]dnl
/* If the proper action on seeing token YYTOKEN is to reduce or to /* If the proper action on seeing token YYTOKEN is to reduce or to
detect an error, take that action. */ detect an error, take that action. */
yyn += yytoken.getCode (); yyn += yytoken.getCode ();
if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken.getCode ()) if (yyn < 0 || YYLAST_ < yyn || yycheck_[yyn] != yytoken.getCode ())
label = YYDEFAULT; label = YYDEFAULT;
/* <= 0 means reduce or error. */ /* <= 0 means reduce or error. */
@@ -636,7 +636,7 @@ b4_dollar_popdef[]dnl
yylval]b4_locations_if([, yylloc])[); yylval]b4_locations_if([, yylloc])[);
]])[ ]])[
/* Discard the token being shifted. */ /* Discard the token being shifted. */
yychar = yyempty_; yychar = YYEMPTY_;
/* Count tokens shifted since error; after three, turn off error /* Count tokens shifted since error; after three, turn off error
status. */ status. */
@@ -677,7 +677,7 @@ b4_dollar_popdef[]dnl
if (yyerrstatus_ == 0) if (yyerrstatus_ == 0)
{ {
++yynerrs; ++yynerrs;
if (yychar == yyempty_) if (yychar == YYEMPTY_)
yytoken = SymbolKind.YYSYMBOL_YYEMPTY; yytoken = SymbolKind.YYSYMBOL_YYEMPTY;
yyreportSyntaxError (new Context (yystack, yytoken]b4_locations_if([[, yylloc]])[)); yyreportSyntaxError (new Context (yystack, yytoken]b4_locations_if([[, yylloc]])[));
} }
@@ -696,7 +696,7 @@ b4_dollar_popdef[]dnl
]b4_push_if([{label = YYABORT; break;}], [return false;])[ ]b4_push_if([{label = YYABORT; break;}], [return false;])[
} }
else else
yychar = yyempty_; yychar = YYEMPTY_;
} }
/* Else will try to reuse lookahead token after shifting the error /* Else will try to reuse lookahead token after shifting the error
@@ -729,7 +729,7 @@ b4_dollar_popdef[]dnl
if (!yyPactValueIsDefault (yyn)) if (!yyPactValueIsDefault (yyn))
{ {
yyn += SymbolKind.YYSYMBOL_YYERROR.getCode (); yyn += SymbolKind.YYSYMBOL_YYERROR.getCode ();
if (0 <= yyn && yyn <= yylast_ if (0 <= yyn && yyn <= YYLAST_
&& yycheck_[yyn] == SymbolKind.YYSYMBOL_YYERROR.getCode ()) && yycheck_[yyn] == SymbolKind.YYSYMBOL_YYERROR.getCode ())
{ {
yyn = yytable_[yyn]; yyn = yytable_[yyn];
@@ -791,7 +791,7 @@ b4_dollar_popdef[]dnl
public void push_parse_initialize () public void push_parse_initialize ()
{ {
/* Lookahead and lookahead in internal form. */ /* Lookahead and lookahead in internal form. */
this.yychar = yyempty_; this.yychar = YYEMPTY_;
this.yytoken = SymbolKind.YYSYMBOL_YYEMPTY; this.yytoken = SymbolKind.YYSYMBOL_YYEMPTY;
/* State. */ /* State. */
@@ -881,7 +881,7 @@ b4_dollar_popdef[]dnl
/** /**
* Value returned by getToken when there is no token. * Value returned by getToken when there is no token.
*/ */
public static final int EMPTY = ]b4_parser_class[.yyempty_; public static final int EMPTY = ]b4_parser_class[.YYEMPTY_;
private SymbolKind yytoken;]b4_locations_if([[ private SymbolKind yytoken;]b4_locations_if([[
public ]b4_location_type[ getLocation () public ]b4_location_type[ getLocation ()
@@ -890,7 +890,7 @@ b4_dollar_popdef[]dnl
} }
private ]b4_location_type[ yylocation;]])[ private ]b4_location_type[ yylocation;]])[
static final int NTOKENS = ]b4_parser_class[.yyntokens_; static final int NTOKENS = ]b4_parser_class[.YYNTOKENS_;
/* Put in YYARG at most YYARGN of the expected tokens given the /* Put in YYARG at most YYARGN of the expected tokens given the
current YYCTX, and return the number of tokens stored in YYARG. If current YYCTX, and return the number of tokens stored in YYARG. If
@@ -913,7 +913,7 @@ b4_dollar_popdef[]dnl
actions. */ actions. */
int yyxbegin = yyn < 0 ? -yyn : 0; int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */ /* Stay within bounds of both yycheck and yytname. */
int yychecklim = yylast_ - yyn + 1; int yychecklim = YYLAST_ - yyn + 1;
int yyxend = yychecklim < NTOKENS ? yychecklim : NTOKENS; int yyxend = yychecklim < NTOKENS ? yychecklim : NTOKENS;
for (int yyx = yyxbegin; yyx < yyxend; ++yyx) for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck_[yyx + yyn] == yyx && yyx != SymbolKind.YYSYMBOL_YYERROR.getCode () if (yycheck_[yyx + yyn] == yyx && yyx != SymbolKind.YYSYMBOL_YYERROR.getCode ()
@@ -1075,7 +1075,7 @@ b4_dollar_popdef[]dnl
} }
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at \a yyntokens_, nonterminals. */ First, the terminals, then, starting at \a YYNTOKENS_, nonterminals. */
]b4_typed_parser_table_define([String], [tname], [b4_tname])[ ]b4_typed_parser_table_define([String], [tname], [b4_tname])[
/* The user-facing name of the symbol whose (internal) number is /* The user-facing name of the symbol whose (internal) number is
@@ -1142,11 +1142,10 @@ b4_dollar_popdef[]dnl
]b4_integral_parser_table_define([translate_table], [b4_translate])[ ]b4_integral_parser_table_define([translate_table], [b4_translate])[
]])[ ]])[
private static final int yylast_ = ]b4_last[; private static final int YYLAST_ = ]b4_last[;
private static final int yynnts_ = ]b4_nterms_number[; private static final int YYEMPTY_ = -2;
private static final int yyempty_ = -2; private static final int YYFINAL_ = ]b4_final_state_number[;
private static final int yyfinal_ = ]b4_final_state_number[; private static final int YYNTOKENS_ = ]b4_tokens_number[;
private static final int yyntokens_ = ]b4_tokens_number[;
]b4_percent_code_get[ ]b4_percent_code_get[
} }