examples: don't use yysyntax_error_arguments

Suggested by Adrian Vogelsgesang.
https://lists.gnu.org/archive/html/bison-patches/2020-02/msg00069.html

* data/skeletons/lalr1.java (Context.EMPTY, Context.getToken): New.
(Context.yyntokens): Rename as...
(Context.NTOKENS): this.
Because (i) all the Java coding styles recommend upper case for
constants, and (ii) the Java Skeleton exposes Lexer.EOF, not
Lexer.YYEOF.
* data/skeletons/yacc.c (yyparse_context_token): New.
* examples/c/bistromathic/parse.y (yyreport_syntax_error): Don't use
yysyntax_error_arguments.
* examples/java/calc/Calc.y (yyreportSyntaxError): Likewise.
This commit is contained in:
Akim Demaille
2020-03-21 08:04:01 +01:00
parent ef8965b5f5
commit 1045c8d0ef
6 changed files with 67 additions and 26 deletions

View File

@@ -964,8 +964,8 @@ m4_define([AT_YYERROR_DEFINE(java)],
]AT_ERROR_CUSTOM_IF([[
public void yyreportSyntaxError (Calc.Context ctx)
{
int[] arg = new int[ctx.yyntokens];
int n = ctx.yysyntaxErrorArguments (arg, ctx.yyntokens);
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)