mirror of
https://github.com/cwbaker/lalr.git
synced 2026-09-26 16:33:18 +03:00
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:
parent
4ba3456df4
commit
4881754402
1 changed files with 7 additions and 4 deletions
|
|
@ -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() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue