Fix error when grammar contains to error productions
This commit is contained in:
parent
9b09c1c615
commit
6951acb13b
2 changed files with 7 additions and 0 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue