Move state_id check into each_referenced_state

This commit is contained in:
Phil Turnbull 2017-06-09 16:13:17 -04:00
parent 6897530c47
commit 18ba6ebbd7
2 changed files with 3 additions and 3 deletions

View file

@ -394,8 +394,7 @@ class ParseTableBuilder {
} else {
ParseState &state = *iter;
state.each_referenced_state([&new_state_ids](ParseStateId *state_index) {
if (*state_index != (ParseStateId)(-1))
*state_index = new_state_ids[*state_index];
*state_index = new_state_ids[*state_index];
});
++iter;
}

View file

@ -154,7 +154,8 @@ void ParseState::each_referenced_state(function<void(ParseStateId *)> fn) {
if (action.type == ParseActionTypeShift || action.type == ParseActionTypeRecover)
fn(&action.state_index);
for (auto &entry : nonterminal_entries)
fn(&entry.second);
if (entry.second != (ParseStateId)(-1))
fn(&entry.second);
}
bool ParseState::operator==(const ParseState &other) const {