diff --git a/spec/compiler/build_tables/build_parse_table_spec.cc b/spec/compiler/build_tables/build_parse_table_spec.cc index 040f318d..c50bf8c1 100644 --- a/spec/compiler/build_tables/build_parse_table_spec.cc +++ b/spec/compiler/build_tables/build_parse_table_spec.cc @@ -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); diff --git a/src/compiler/build_tables/build_parse_table.cc b/src/compiler/build_tables/build_parse_table.cc index 9319fdcd..89ecd877 100644 --- a/src/compiler/build_tables/build_parse_table.cc +++ b/src/compiler/build_tables/build_parse_table.cc @@ -127,6 +127,8 @@ namespace tree_sitter { ParseItem start_item(rules::START(), make_shared(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;