style: java: more style fixes

* data/skeletons/lalr1.java, tests/java.at: Avoid space before paren.
And use braces as is customary in the Java.
This commit is contained in:
Akim Demaille
2020-11-01 15:40:49 +01:00
parent 042b916c0e
commit 787052f074
2 changed files with 51 additions and 60 deletions

View File

@@ -78,13 +78,13 @@ m4_define([b4_define_state],
/* Semantic value of the lookahead. */ /* Semantic value of the lookahead. */
]b4_yystype[ yylval = null; ]b4_yystype[ yylval = null;
]])[ ]])
## ------------- ## ## ------------- ##
## Parser File. ## ## Parser File. ##
## ------------- ## ## ------------- ##
]b4_output_begin([b4_parser_file_name])[ b4_output_begin([b4_parser_file_name])[
]b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java], ]b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
[2007-2015, 2018-2020])[ [2007-2015, 2018-2020])[
]b4_disclaimer[ ]b4_disclaimer[
@@ -234,7 +234,7 @@ import java.text.MessageFormat;
* *
* @@param ctx The context of the error. * @@param ctx The context of the error.
*/ */
void reportSyntaxError (][Context ctx); void reportSyntaxError(Context ctx);
]])[ ]])[
} }
@@ -255,7 +255,7 @@ import java.text.MessageFormat;
/** /**
* Instantiates the Bison-generated parser. * Instantiates the Bison-generated parser.
*/ */
public ]b4_parser_class (b4_parse_param_decl([b4_lex_param_decl])[)]b4_maybe_throws([b4_init_throws])[ public ]b4_parser_class[(]b4_parse_param_decl([b4_lex_param_decl])[)]b4_maybe_throws([b4_init_throws])[
{ {
]b4_percent_code_get([[init]])[ ]b4_percent_code_get([[init]])[
this.yylexer = new YYLexer (]b4_lex_param_call[); this.yylexer = new YYLexer (]b4_lex_param_call[);
@@ -464,8 +464,7 @@ import java.text.MessageFormat;
* @@param yystate the current state * @@param yystate the current state
* @@param yysym the nonterminal to push on the stack * @@param yysym the nonterminal to push on the stack
*/ */
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];
@@ -881,8 +880,7 @@ b4_dollar_popdef[]dnl
* Information needed to get the list of expected tokens and to forge * Information needed to get the list of expected tokens and to forge
* a syntax error diagnostic. * a syntax error diagnostic.
*/ */
public static final class Context public static final class Context {
{
Context (YYStack stack, SymbolKind token]b4_locations_if([[, ]b4_location_type[ loc]])[) Context (YYStack stack, SymbolKind token]b4_locations_if([[, ]b4_location_type[ loc]])[)
{ {
yystack = stack; yystack = stack;
@@ -896,8 +894,7 @@ b4_dollar_popdef[]dnl
/** /**
* The symbol kind of the lookahead token. * The symbol kind of the lookahead token.
*/ */
public final SymbolKind getToken () public final SymbolKind getToken() {
{
return yytoken; return yytoken;
} }
@@ -906,8 +903,7 @@ b4_dollar_popdef[]dnl
/** /**
* The location of the lookahead. * The location of the lookahead.
*/ */
public final ]b4_location_type[ getLocation () public final ]b4_location_type[ getLocation() {
{
return yylocation; return yylocation;
} }
@@ -920,13 +916,11 @@ b4_dollar_popdef[]dnl
* YYARG is null, return the number of expected tokens (guaranteed to * YYARG is null, return the number of expected tokens (guaranteed to
* be less than YYNTOKENS). * be less than YYNTOKENS).
*/ */
int getExpectedTokens (SymbolKind yyarg[], int yyargn) int getExpectedTokens(SymbolKind yyarg[], int yyargn) {
{
return getExpectedTokens (yyarg, 0, yyargn); return getExpectedTokens (yyarg, 0, yyargn);
} }
int getExpectedTokens (SymbolKind yyarg[], int yyoffset, int yyargn) int getExpectedTokens(SymbolKind yyarg[], int yyoffset, int yyargn) {
{
int yycount = yyoffset; int yycount = yyoffset;
int yyn = yypact_[this.yystack.stateAt(0)]; int yyn = yypact_[this.yystack.stateAt(0)];
if (!yyPactValueIsDefault(yyn)) if (!yyPactValueIsDefault(yyn))
@@ -959,8 +953,7 @@ b4_dollar_popdef[]dnl
]b4_parse_error_bmatch( ]b4_parse_error_bmatch(
[detailed\|verbose], [[ [detailed\|verbose], [[
private int yysyntaxErrorArguments (Context yyctx, SymbolKind[] yyarg, int yyargn) private int yysyntaxErrorArguments(Context yyctx, SymbolKind[] yyarg, int yyargn) {
{
/* There are many possibilities here to consider: /* There are many possibilities here to consider:
- If this state is a consistent state with a default action, - If this state is a consistent state with a default action,
then the only way this function was invoked is if the then the only way this function was invoked is if the
@@ -1038,8 +1031,7 @@ b4_dollar_popdef[]dnl
* Whether the given <code>yypact_</code> value indicates a defaulted state. * Whether the given <code>yypact_</code> value indicates a defaulted state.
* @@param yyvalue the value to check * @@param yyvalue the value to check
*/ */
private static boolean yyPactValueIsDefault (int yyvalue) private static boolean yyPactValueIsDefault(int yyvalue) {
{
return yyvalue == yypact_ninf_; return yyvalue == yypact_ninf_;
} }
@@ -1048,8 +1040,7 @@ b4_dollar_popdef[]dnl
* value indicates a syntax error. * value indicates a syntax error.
* @@param yyvalue the value to check * @@param yyvalue the value to check
*/ */
private static boolean yyTableValueIsError (int yyvalue) private static boolean yyTableValueIsError(int yyvalue) {
{
return yyvalue == yytable_ninf_; return yyvalue == yytable_ninf_;
} }