mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-13 22:33:03 +00:00
yacc.c: let custom error messages see the location
* data/skeletons/yacc.c (yyparse_context_t): Add yylloc when applicable. (yyparse_context_location): New. * tests/local.at (AT_YYERROR_DEFINE(c)): Handle the location. * tests/calc.at: Check it.
This commit is contained in:
@@ -788,6 +788,7 @@ AT_CHECK_CALC_LALR([%no-lines %define api.pure %define parse.error verbose %debu
|
||||
|
||||
|
||||
AT_CHECK_CALC_LALR([%define parse.error custom])
|
||||
AT_CHECK_CALC_LALR([%define parse.error custom %locations])
|
||||
|
||||
# ----------------------- #
|
||||
# Simple GLR Calculator. #
|
||||
|
||||
@@ -619,7 +619,9 @@ yyreport_syntax_error (const yyparse_context_t *ctx)
|
||||
if (n == -2)
|
||||
return 2;
|
||||
if (n)
|
||||
{
|
||||
{]AT_LOCATION_IF([[
|
||||
LOCATION_PRINT (stderr, *yyparse_context_location (ctx));
|
||||
fprintf (stderr, ": ");]])[
|
||||
fprintf (stderr, "syntax error on token [%s]", yysymbol_name (arg[0]));
|
||||
if (1 < n)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user