mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-16 15:53:03 +00:00
c++: provide a means to clear symbols
The symbol destructor is currently the only means to clear a symbol. Unfortunately during error recovery we might have to clear the lookahead, which is a local variable (yyla) that has not yet reached its end of scope. Rather that duplicating the code to destroy a symbol, or rather than destroying and recreating yyla, let's provide a means to clear a symbol. Reported by Antonio Silva Correia, with an analysis from Michel d'Hooge. <http://savannah.gnu.org/support/?108481> * data/c++.m4, data/lalr1.cc (basis_symbol::clear, by_state::clear) (by_type::clear): New. (basic_symbol::~basic_symbol): Use clear.
This commit is contained in:
@@ -288,6 +288,9 @@ b4_location_define])])[
|
||||
/// Copy constructor.
|
||||
by_state (const by_state& other);
|
||||
|
||||
/// Record that this symbol is empty.
|
||||
void clear ();
|
||||
|
||||
/// Steal the symbol type from \a that.
|
||||
void move (by_state& that);
|
||||
|
||||
@@ -542,12 +545,19 @@ m4_if(b4_prefix, [yy], [],
|
||||
: state (other.state)
|
||||
{}
|
||||
|
||||
inline
|
||||
void
|
||||
]b4_parser_class_name[::by_state::clear ()
|
||||
{
|
||||
state = empty_state;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
]b4_parser_class_name[::by_state::move (by_state& that)
|
||||
{
|
||||
state = that.state;
|
||||
that.state = empty_state;
|
||||
that.clear ();
|
||||
}
|
||||
|
||||
inline
|
||||
|
||||
Reference in New Issue
Block a user