summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <demaille@gostai.com>2009-08-21 12:30:09 +0200
committerAkim Demaille <demaille@gostai.com>2009-08-26 13:25:11 +0200
commita57ca64a80b6823e329237558c92295b6604b286 (patch)
tree46157e94ba438812d4cb0011b7d69320392e2dd6
parent560d4c8dd971759a458f838e05200b06bc1333af (diff)
downloadbison-a57ca64a80b6823e329237558c92295b6604b286.tar.gz
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.
-rw-r--r--data/lalr1.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/data/lalr1.cc b/data/lalr1.cc
index 2d0ff01c..5ad33287 100644
--- a/data/lalr1.cc
+++ b/data/lalr1.cc
@@ -237,8 +237,9 @@ do { \
/// Generate an error message.
/// \param yystate the state where the error occurred.
- /// \param yytoken the lookahead token.
- virtual std::string yysyntax_error_ (state_type yystate, int yytoken);
+ /// \param yyla the (invalid) lookahead token.
+ virtual std::string yysyntax_error_ (state_type yystate,
+ const symbol_type& yyla);
/// Compute post-reduction state.
/// \param yystate the current state
@@ -853,7 +854,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
{
++yynerrs_;
error (]b4_args(b4_locations_if([yyla.location]),
- [[yysyntax_error_ (yystack_[0].state, yyla.type)]])[);
+ [[yysyntax_error_ (yystack_[0].state, yyla)]])[);
}
]b4_locations_if([[
@@ -966,8 +967,8 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
// Generate an error message.
std::string
]b4_parser_class_name[::yysyntax_error_ (]dnl
-b4_error_verbose_if([state_type yystate, int yytoken],
- [state_type, int])[)
+b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
+ [state_type, const symbol_type&])[)
{
std::string yyres;]b4_error_verbose_if([[
int yyn = yypact_[yystate];
@@ -989,7 +990,8 @@ b4_error_verbose_if([state_type yystate, int yytoken],
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
// Arguments of yyformat.
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)
if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
&& !yy_table_value_is_error_ (yytable_[yyx + yyn]))