Push a complete symbol, not connected parts.

* data/lalr1.cc (yypush_): Take a data_type&, not disconnected
	state, value and location.
	Adjust callers.
This commit is contained in:
Akim Demaille
2008-08-02 14:00:39 +02:00
parent 6082531abb
commit e9b0834e18
2 changed files with 20 additions and 16 deletions

View File

@@ -1,3 +1,10 @@
2008-11-09 Akim Demaille <demaille@gostai.com>
Push a complete symbol, not connected parts.
* data/lalr1.cc (yypush_): Take a data_type&, not disconnected
state, value and location.
Adjust callers.
2008-11-09 Akim Demaille <demaille@gostai.com> 2008-11-09 Akim Demaille <demaille@gostai.com>
Agregate yylval and yylloc. Agregate yylval and yylloc.

View File

@@ -514,12 +514,9 @@ m4_ifdef([b4_stype],
/// Push a new state on the stack. /// Push a new state on the stack.
/// \param m a debug message to display /// \param m a debug message to display
/// if null, no trace is output. /// if null, no trace is output.
/// \param s the state entered /// \param s the symbol
/// \param v semantic value /// \warning the contents of \a s.value is stolen.
/// \param l location inline void yypush_ (const char* m, data_type& s);
/// \warning the contents of \a v is stolen.
inline void yypush_ (const char* m, state_type s,
semantic_type& v, const location_type& l);
/// Pop \a n symbols the three stacks. /// Pop \a n symbols the three stacks.
inline void yypop_ (unsigned int n = 1); inline void yypop_ (unsigned int n = 1);
@@ -757,15 +754,15 @@ b4_percent_code_get[]dnl
} }
void void
]b4_parser_class_name[::yypush_ (const char* m, state_type s, ]b4_parser_class_name[::yypush_ (const char* m, data_type& s)
semantic_type& v, const location_type& l)
{ {
if (m) if (m)
YY_SYMBOL_PRINT (m, yystos_[s], v, l); YY_SYMBOL_PRINT (m, yystos_[s.state], s.value, s.location);
]b4_variant_if( ]b4_variant_if(
[[ yystack_.push (data_type (s, semantic_type(), l)); [[ yystack_.push (data_type (s, semantic_type(), l));
]b4_symbol_variant([[yystos_[s]]], [[yystack_[0].value]], [build], [v])], ]b4_symbol_variant([[yystos_[s]]], [[yystack_[0].value]],
[ yystack_.push (data_type (s, v, l));])[ [build], [s.value])],
[ yystack_.push (s);])[
} }
void void
@@ -844,7 +841,7 @@ m4_popdef([b4_at_dollar])])dnl
location values to have been already stored, initialize these location values to have been already stored, initialize these
stacks with a primary value. */ stacks with a primary value. */
yystack_ = stack_type (0); yystack_ = stack_type (0);
yypush_ (0, yyla.state, yyla.value, yyla.location); yypush_ (0, yyla);
// A new state was pushed on the stack. // A new state was pushed on the stack.
// Invariant: yystate == yystack_[0].state, i.e., // Invariant: yystate == yystack_[0].state, i.e.,
@@ -915,7 +912,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
/* Shift the lookahead token. */ /* Shift the lookahead token. */
yyla.state = yystate = yyn; yyla.state = yystate = yyn;
yypush_ ("Shifting", yyla.state, yyla.value, yyla.location); yypush_ ("Shifting", yyla);
goto yynewstate; goto yynewstate;
/*-----------------------------------------------------------. /*-----------------------------------------------------------.
@@ -991,7 +988,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
YY_STACK_PRINT (); YY_STACK_PRINT ();
/* Shift the result of the reduction. */ /* Shift the result of the reduction. */
yypush_ (0, yylhs.state, yylhs.value, yylhs.location); yypush_ (0, yylhs);
goto yynewstate; goto yynewstate;
/*------------------------------------. /*------------------------------------.
@@ -1087,8 +1084,8 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
YYLLOC_DEFAULT (error_token.location, (yyerror_range - 1), 2); YYLLOC_DEFAULT (error_token.location, (yyerror_range - 1), 2);
/* Shift the error token. */ /* Shift the error token. */
yystate = yyn; error_token.state = yystate = yyn;
yypush_ ("Shifting", yystate, error_token.value, error_token.location); yypush_ ("Shifting", error_token);
} }
goto yynewstate; goto yynewstate;