Avoid initializing Parser with invalid ParserStateMachine

When a grammar fails to generate a parser the ParserStateMachine has a
null start state.  When this is passed to construct a Parser quietly
avoid creating any parser specific state, esp. ParserNode which will
assert if passed a null state.
This commit is contained in:
Charles Baker 2023-07-16 08:10:39 +12:00
parent 4ba3456df4
commit 4881754402

View file

@ -82,10 +82,13 @@ Parser<Iterator, UserData, Char, Traits, Allocator>::Parser( const ParserStateMa
++action;
}
nodes_.reserve( 64 );
user_data_.reserve( 64 );
nodes_.push_back( ParserNode(state_machine_->start_state, nullptr, 0, 1) );
user_data_.push_back( UserData() );
if ( state_machine_->start_state )
{
nodes_.reserve( 64 );
user_data_.reserve( 64 );
nodes_.push_back( ParserNode(state_machine_->start_state, nullptr, 0, 1) );
user_data_.push_back( UserData() );
}
}
/**