mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 10:13:03 +00:00
lalr1.cc: pass the full lookahead to yysyntax_error_.
* data/lalr1.cc (yysyntax_error_): Instead of only taking the kind of the guilty token, take the full lookahead.
This commit is contained in:
@@ -237,8 +237,9 @@ do { \
|
|||||||
|
|
||||||
/// Generate an error message.
|
/// Generate an error message.
|
||||||
/// \param yystate the state where the error occurred.
|
/// \param yystate the state where the error occurred.
|
||||||
/// \param yytoken the lookahead token.
|
/// \param yyla the (invalid) lookahead token.
|
||||||
virtual std::string yysyntax_error_ (state_type yystate, int yytoken);
|
virtual std::string yysyntax_error_ (state_type yystate,
|
||||||
|
const symbol_type& yyla);
|
||||||
|
|
||||||
/// Compute post-reduction state.
|
/// Compute post-reduction state.
|
||||||
/// \param yystate the current state
|
/// \param yystate the current state
|
||||||
@@ -853,7 +854,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
|
|||||||
{
|
{
|
||||||
++yynerrs_;
|
++yynerrs_;
|
||||||
error (]b4_args(b4_locations_if([yyla.location]),
|
error (]b4_args(b4_locations_if([yyla.location]),
|
||||||
[[yysyntax_error_ (yystack_[0].state, yyla.type)]])[);
|
[[yysyntax_error_ (yystack_[0].state, yyla)]])[);
|
||||||
}
|
}
|
||||||
|
|
||||||
]b4_locations_if([[
|
]b4_locations_if([[
|
||||||
@@ -966,8 +967,8 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
|
|||||||
// Generate an error message.
|
// Generate an error message.
|
||||||
std::string
|
std::string
|
||||||
]b4_parser_class_name[::yysyntax_error_ (]dnl
|
]b4_parser_class_name[::yysyntax_error_ (]dnl
|
||||||
b4_error_verbose_if([state_type yystate, int yytoken],
|
b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
|
||||||
[state_type, int])[)
|
[state_type, const symbol_type&])[)
|
||||||
{
|
{
|
||||||
std::string yyres;]b4_error_verbose_if([[
|
std::string yyres;]b4_error_verbose_if([[
|
||||||
int yyn = yypact_[yystate];
|
int yyn = yypact_[yystate];
|
||||||
@@ -989,7 +990,8 @@ b4_error_verbose_if([state_type yystate, int yytoken],
|
|||||||
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
|
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
|
||||||
// Arguments of yyformat.
|
// Arguments of yyformat.
|
||||||
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
|
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
|
||||||
yyarg[yycount++] = yytname_[yytoken];
|
// The unexpected token.
|
||||||
|
yyarg[yycount++] = yytname_[yyla.type_get ()];
|
||||||
for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
|
for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
|
||||||
if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
|
if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
|
||||||
&& !yy_table_value_is_error_ (yytable_[yyx + yyn]))
|
&& !yy_table_value_is_error_ (yytable_[yyx + yyn]))
|
||||||
|
|||||||
Reference in New Issue
Block a user