Fix error when grammar contains to error productions

This commit is contained in:
Max Brunsfeld 2014-07-13 21:26:21 -07:00
parent 9b09c1c615
commit 6951acb13b
2 changed files with 7 additions and 0 deletions

View file

@ -39,6 +39,11 @@ describe("building parse tables", []() {
})));
});
it("ensures that the built-in 'ERROR' symbol is in the symbol set", [&]() {
auto result = build_parse_table(parse_grammar, lex_grammar);
AssertThat(result.first.symbols, Contains(rules::ERROR()));
});
it("accepts the input when EOF occurs after the start rule", [&]() {
auto result = build_parse_table(parse_grammar, lex_grammar);

View file

@ -127,6 +127,8 @@ namespace tree_sitter {
ParseItem start_item(rules::START(), make_shared<Symbol>(0), 0);
add_parse_state(item_set_closure(start_item, { rules::END_OF_INPUT() }, grammar));
parse_table.symbols.insert(rules::ERROR());
while (!item_sets_to_process.empty()) {
auto pair = item_sets_to_process.back();
ParseItemSet &item_set = pair.first;