Relax overly conservative parse state mergeability check

Built-in symbols (e.g. EOF, ERROR) should not prevent parse states from being
merged. Neither should non-token productions.
This commit is contained in:
Max Brunsfeld 2016-10-26 21:58:15 -07:00
parent e53beb66c9
commit 3b3fddd64d

View file

@ -206,7 +206,7 @@ bool ParseTable::merge_state(size_t i, size_t j) {
const auto &other_entry = other.entries.find(symbol);
if (other_entry == other.entries.end()) {
if (mergeable_symbols.count(symbol) == 0)
if (mergeable_symbols.count(symbol) == 0 && !symbol.is_built_in() && symbol.is_token)
return false;
if (actions.back().type != ParseActionTypeReduce)
return false;
@ -224,7 +224,7 @@ bool ParseTable::merge_state(size_t i, size_t j) {
const vector<ParseAction> &actions = entry.second.actions;
if (!state.entries.count(symbol)) {
if (mergeable_symbols.count(symbol) == 0)
if (mergeable_symbols.count(symbol) == 0 && !symbol.is_built_in() && symbol.is_token)
return false;
if (actions.back().type != ParseActionTypeReduce)
return false;