* data/lalr1.cc (parser::yylval, parser::yylloc): Replace by...
(parser::yyla): this.
+2008-11-09 Akim Demaille <demaille@gostai.com>
+
+ Agregate yylval and yylloc.
+ * data/lalr1.cc (parser::yylval, parser::yylloc): Replace by...
+ (parser::yyla): this.
+
2008-11-09 Akim Demaille <demaille@gostai.com>
Rely on the state stack to display reduction traces.
2008-11-09 Akim Demaille <demaille@gostai.com>
Rely on the state stack to display reduction traces.
int yynerrs_ = 0;
int yyerrstatus_ = 0;
int yynerrs_ = 0;
int yyerrstatus_ = 0;
- /// Semantic value of the lookahead.
- semantic_type yylval;
- /// Location of the lookahead.
- location_type yylloc;
+ /// The lookahead symbol.
+ data_type yyla;
+
/// The locations where the error started and ended.
data_type yyerror_range[2];
/// The locations where the error started and ended.
data_type yyerror_range[2];
YYCDEBUG << "Starting parse" << std::endl;
]m4_ifdef([b4_initial_action], [
YYCDEBUG << "Starting parse" << std::endl;
]m4_ifdef([b4_initial_action], [
-m4_pushdef([b4_at_dollar], [yylloc])dnl
-m4_pushdef([b4_dollar_dollar], [yylval])dnl
+m4_pushdef([b4_at_dollar], [yyla.location])dnl
+m4_pushdef([b4_dollar_dollar], [yyla.value])dnl
/* User initialization code. */
b4_user_initial_action
m4_popdef([b4_dollar_dollar])dnl
/* User initialization code. */
b4_user_initial_action
m4_popdef([b4_dollar_dollar])dnl
location values to have been already stored, initialize these
stacks with a primary value. */
yystack_ = stack_type (0);
location values to have been already stored, initialize these
stacks with a primary value. */
yystack_ = stack_type (0);
- yypush_ (0, yystate, yylval, yylloc);
+ yypush_ (0, yyla.state, yyla.value, yyla.location);
// A new state was pushed on the stack.
// Invariant: yystate == yystack_[0].state, i.e.,
// A new state was pushed on the stack.
// Invariant: yystate == yystack_[0].state, i.e.,
{
YYCDEBUG << "Reading a token: ";
yychar = ]b4_c_function_call([yylex], [int],
{
YYCDEBUG << "Reading a token: ";
yychar = ]b4_c_function_call([yylex], [int],
- [[YYSTYPE*], [&yylval]][]dnl
-b4_locations_if([, [[location*], [&yylloc]]])dnl
+ [[YYSTYPE*], [&yyla.value]][]dnl
+b4_locations_if([, [[location*], [&yyla.location]]])dnl
m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
}
m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
}
else
{
yytoken = yytranslate_ (yychar);
else
{
yytoken = yytranslate_ (yychar);
- YY_SYMBOL_PRINT ("Next token is", yytoken, yylval, yylloc);
+ YY_SYMBOL_PRINT ("Next token is", yytoken, yyla.value, yyla.location);
}
/* If the proper action on seeing token YYTOKEN is to reduce or to
}
/* If the proper action on seeing token YYTOKEN is to reduce or to
if (yyn <= 0)
{
if (yyn == 0 || yyn == yytable_ninf_)
if (yyn <= 0)
{
if (yyn == 0 || yyn == yytable_ninf_)
yyn = -yyn;
goto yyreduce;
}
yyn = -yyn;
goto yyreduce;
}
--yyerrstatus_;
/* Shift the lookahead token. */
--yyerrstatus_;
/* Shift the lookahead token. */
- yystate = yyn;
- yypush_ ("Shifting", yystate, yylval, yylloc);
+ yyla.state = yystate = yyn;
+ yypush_ ("Shifting", yyla.state, yyla.value, yyla.location);
goto yynewstate;
/*-----------------------------------------------------------.
goto yynewstate;
/*-----------------------------------------------------------.
if (!yyerrstatus_)
{
++yynerrs_;
if (!yyerrstatus_)
{
++yynerrs_;
- error (yylloc, yysyntax_error_ (yystate, yytoken));
+ error (yyla.location, yysyntax_error_ (yystate, yytoken));
- yyerror_range[0].location = yylloc;
+ yyerror_range[0].location = yyla.location;
if (yyerrstatus_ == 3)
{
/* If just tried and failed to reuse lookahead token after an
if (yyerrstatus_ == 3)
{
/* If just tried and failed to reuse lookahead token after an
- yydestruct_ ("Error: discarding", yytoken, yylval, yylloc);
+ yydestruct_ ("Error: discarding",
+ yytoken, yyla.value, yyla.location);
- yyerror_range[1].location = yylloc;
+ yyerror_range[1].location = yyla.location;
YYLLOC_DEFAULT (error_token.location, (yyerror_range - 1), 2);
/* Shift the error token. */
YYLLOC_DEFAULT (error_token.location, (yyerror_range - 1), 2);
/* Shift the error token. */
yyreturn:
if (yychar != yyempty_)
yyreturn:
if (yychar != yyempty_)
- yydestruct_ ("Cleanup: discarding lookahead", yytoken, yylval, yylloc);
+ yydestruct_ ("Cleanup: discarding lookahead",
+ yytoken, yyla.value, yyla.location);
/* Do not reclaim the symbols of the rule which action triggered
this YYABORT or YYACCEPT. */
/* Do not reclaim the symbols of the rule which action triggered
this YYABORT or YYACCEPT. */