java: make yysyntaxErrorArguments a private detail

* data/skeletons/lalr1.java (yysyntaxErrorArguments): Move it from the
context, to the parser object.
Generate only for detailed and verbose error messages.
* tests/local.at (AT_YYERROR_DEFINE(java)): Use yyexpectedTokens
instead.
This commit is contained in:
Akim Demaille
2020-03-26 08:35:50 +01:00
parent ee56b6e0f2
commit b7045aa706
2 changed files with 59 additions and 49 deletions

View File

@@ -972,17 +972,24 @@ m4_define([AT_YYERROR_DEFINE(java)],
]AT_ERROR_CUSTOM_IF([[
public void yyreportSyntaxError (Calc.Context ctx)
{
int[] arg = new int[ctx.NTOKENS];
int n = ctx.yysyntaxErrorArguments (arg, ctx.NTOKENS);
System.err.print (]AT_LOCATION_IF([[ctx.getLocation () + ": "]]
+ )["syntax error on token @<:@" + ctx.yysymbolName (arg[0]) + "@:>@");
if (1 < n)
{
System.err.print (" (expected:");
for (int i = 1; i < n; ++i)
System.err.print (" @<:@" + ctx.yysymbolName (arg[i]) + "@:>@");
System.err.print (")");
}
+ )["syntax error");
{
int token = ctx.getToken ();
if (token != ctx.EMPTY)
System.err.print (" on token @<:@" + ctx.yysymbolName (token) + "@:>@");
}
{
int[] arg = new int[ctx.NTOKENS];
int n = ctx.yyexpectedTokens (arg, ctx.NTOKENS);
if (0 < n)
{
System.err.print (" (expected:");
for (int i = 0; i < n; ++i)
System.err.print (" @<:@" + ctx.yysymbolName (arg[i]) + "@:>@");
System.err.print (")");
}
}
System.err.println ("");
}
]])