Allow LookaheadSet::for_each to terminate early

This commit is contained in:
Max Brunsfeld 2018-03-22 09:10:55 -07:00
parent 43e14332ed
commit a8bc67ac42
6 changed files with 19 additions and 5 deletions

View file

@ -239,6 +239,8 @@ class ParseTableBuilderImpl : public ParseTableBuilder {
}
}
}
return true;
});
// If the item is unfinished, create a new item by advancing one symbol.
@ -835,13 +837,15 @@ class ParseTableBuilderImpl : public ParseTableBuilder {
if (!left_tokens.empty() && !right_tokens.empty()) {
left_tokens.for_each([&](Symbol left_symbol) {
if (!left_symbol.is_non_terminal() && !left_symbol.is_built_in()) {
if (left_symbol.is_terminal() && !left_symbol.is_built_in()) {
right_tokens.for_each([&](Symbol right_symbol) {
if (right_symbol.is_terminal() && !right_symbol.is_built_in()) {
following_tokens_by_token[left_symbol].insert(right_symbol);
}
return true;
});
}
return true;
});
}
}