Remove old error recovery code
This commit is contained in:
parent
501e426d29
commit
e0c24e3be6
15 changed files with 78 additions and 75 deletions
|
|
@ -65,9 +65,7 @@ class LexTableBuilder {
|
|||
LexItemSet result;
|
||||
for (const Symbol &symbol : symbols) {
|
||||
vector<rule_ptr> rules;
|
||||
if (symbol == rules::ERROR()) {
|
||||
continue;
|
||||
} else if (symbol == rules::END_OF_INPUT()) {
|
||||
if (symbol == rules::END_OF_INPUT()) {
|
||||
rules.push_back(CharacterSet().include(0).copy());
|
||||
} else if (symbol.is_token) {
|
||||
rule_ptr rule = lex_grammar.variables[symbol.index].rule;
|
||||
|
|
|
|||
|
|
@ -80,8 +80,6 @@ class ParseTableBuilder {
|
|||
mark_fragile_actions();
|
||||
remove_duplicate_parse_states();
|
||||
|
||||
parse_table.symbols.insert({ rules::ERROR(), { true } });
|
||||
|
||||
return { parse_table, CompileError::none() };
|
||||
}
|
||||
|
||||
|
|
@ -400,9 +398,7 @@ class ParseTableBuilder {
|
|||
|
||||
string symbol_name(const rules::Symbol &symbol) const {
|
||||
if (symbol.is_built_in()) {
|
||||
if (symbol == rules::ERROR())
|
||||
return "ERROR";
|
||||
else if (symbol == rules::END_OF_INPUT())
|
||||
if (symbol == rules::END_OF_INPUT())
|
||||
return "END_OF_INPUT";
|
||||
else
|
||||
return "";
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ using std::to_string;
|
|||
using std::vector;
|
||||
using util::escape_char;
|
||||
|
||||
static Variable ERROR_ENTRY("error", VariableTypeNamed, rule_ptr());
|
||||
static Variable EOF_ENTRY("end", VariableTypeNamed, rule_ptr());
|
||||
|
||||
static const map<char, string> REPLACEMENTS({
|
||||
|
|
@ -465,8 +464,6 @@ class CCodeGenerator {
|
|||
// Helper functions
|
||||
|
||||
string symbol_id(const rules::Symbol &symbol) {
|
||||
if (symbol == rules::ERROR())
|
||||
return "ts_builtin_sym_error";
|
||||
if (symbol == rules::END_OF_INPUT())
|
||||
return "ts_builtin_sym_end";
|
||||
|
||||
|
|
@ -484,16 +481,12 @@ class CCodeGenerator {
|
|||
}
|
||||
|
||||
string symbol_name(const rules::Symbol &symbol) {
|
||||
if (symbol == rules::ERROR())
|
||||
return "ERROR";
|
||||
if (symbol == rules::END_OF_INPUT())
|
||||
return "END";
|
||||
return entry_for_symbol(symbol).first;
|
||||
}
|
||||
|
||||
VariableType symbol_type(const rules::Symbol &symbol) {
|
||||
if (symbol == rules::ERROR())
|
||||
return VariableTypeNamed;
|
||||
if (symbol == rules::END_OF_INPUT())
|
||||
return VariableTypeHidden;
|
||||
return entry_for_symbol(symbol).second;
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ ParseRuleResult parse_rule(json_value *rule_json) {
|
|||
json_value content_json = rule_json->operator[]("content");
|
||||
ParseRuleResult content = parse_rule(&content_json);
|
||||
if (content.rule.get()) {
|
||||
return { err(content.rule), "" };
|
||||
return { content.rule, "" };
|
||||
} else {
|
||||
error_message = "Invalid error content: " + content.error_message;
|
||||
goto error;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ rule_ptr seq(const std::vector<rule_ptr> &);
|
|||
rule_ptr sym(const std::string &);
|
||||
rule_ptr pattern(const std::string &);
|
||||
rule_ptr str(const std::string &);
|
||||
rule_ptr err(const rule_ptr &);
|
||||
rule_ptr prec(int precedence, const rule_ptr &);
|
||||
rule_ptr prec_left(const rule_ptr &);
|
||||
rule_ptr prec_left(int precedence, const rule_ptr &);
|
||||
|
|
|
|||
|
|
@ -7,16 +7,12 @@ Symbol END_OF_INPUT() {
|
|||
return Symbol(-1, true);
|
||||
}
|
||||
|
||||
Symbol ERROR() {
|
||||
return Symbol(-2, true);
|
||||
}
|
||||
|
||||
Symbol START() {
|
||||
return Symbol(-3);
|
||||
return Symbol(-2);
|
||||
}
|
||||
|
||||
Symbol NONE() {
|
||||
return Symbol(-4);
|
||||
return Symbol(-3);
|
||||
}
|
||||
|
||||
} // namespace rules
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
namespace tree_sitter {
|
||||
namespace rules {
|
||||
|
||||
Symbol ERROR();
|
||||
Symbol END_OF_INPUT();
|
||||
Symbol START();
|
||||
Symbol NONE();
|
||||
|
|
|
|||
|
|
@ -59,10 +59,6 @@ rule_ptr str(const string &value) {
|
|||
return make_shared<rules::String>(value);
|
||||
}
|
||||
|
||||
rule_ptr err(const rule_ptr &rule) {
|
||||
return choice({ rule, rules::ERROR().copy() });
|
||||
}
|
||||
|
||||
rule_ptr prec_left(const rule_ptr &rule) {
|
||||
return metadata(rule, { { rules::ASSOCIATIVITY, rules::AssociativityLeft } });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue