news: update the yyreport_syntax_error example

* examples/c/bistromathic/parse.y, tests/local.at
(yyreport_syntax_error): Fix use of YYSYMBOL_YYEMPTY.
* NEWS: Update.
This commit is contained in:
Akim Demaille
2020-04-04 19:35:33 +02:00
parent 4e3c06b0f8
commit 225a67321b
3 changed files with 27 additions and 15 deletions

View File

@@ -287,6 +287,7 @@ yyreport_syntax_error (const yypcontext_t *ctx)
int res = 0;
YY_LOCATION_PRINT (stderr, *yypcontext_location (ctx));
fprintf (stderr, ": syntax error");
// Report the tokens expected at this point.
{
enum { TOKENMAX = 10 };
yysymbol_type_t expected[TOKENMAX];
@@ -299,9 +300,10 @@ yyreport_syntax_error (const yypcontext_t *ctx)
fprintf (stderr, "%s %s",
i == 0 ? ": expected" : " or", yysymbol_name (expected[i]));
}
// Report the unexpected token.
{
yysymbol_type_t lookahead = yypcontext_token (ctx);
if (lookahead != YYEMPTY)
if (lookahead != YYSYMBOL_YYEMPTY)
fprintf (stderr, " before %s", yysymbol_name (lookahead));
}
fprintf (stderr, "\n");