Store error recovery actions in the normal parse table
This commit is contained in:
parent
08e47001f1
commit
8c26d99353
11 changed files with 84 additions and 112 deletions
|
|
@ -100,7 +100,6 @@ class CCodeGenerator {
|
|||
add_symbol_node_types_list();
|
||||
add_lex_function();
|
||||
add_lex_states_list();
|
||||
add_recovery_parse_states_list();
|
||||
add_parse_table();
|
||||
add_parser_export();
|
||||
|
||||
|
|
@ -211,27 +210,6 @@ class CCodeGenerator {
|
|||
line();
|
||||
}
|
||||
|
||||
void add_recovery_parse_states_list() {
|
||||
line("static TSParseAction ts_recovery_actions[SYMBOL_COUNT] = {");
|
||||
indent([&]() {
|
||||
for (const auto &pair : parse_table.symbols) {
|
||||
const rules::Symbol &symbol = pair.first;
|
||||
line("[" + symbol_id(pair.first) + "] = ");
|
||||
const auto &entry = parse_table.error_state.entries.find(symbol);
|
||||
if (entry != parse_table.error_state.entries.end()) {
|
||||
ParseAction action = entry->second.actions[0];
|
||||
if (!action.extra) {
|
||||
add("RECOVER(" + to_string(action.state_index) + "),");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
add("RECOVER_EXTRA(),");
|
||||
}
|
||||
});
|
||||
line("};");
|
||||
line();
|
||||
}
|
||||
|
||||
void add_parse_table() {
|
||||
add_parse_action_list_id(ParseTableEntry{ {}, true, false });
|
||||
|
||||
|
|
@ -372,6 +350,9 @@ class CCodeGenerator {
|
|||
to_string(action.consumed_symbol_count) + ")");
|
||||
}
|
||||
break;
|
||||
case ParseActionTypeRecover:
|
||||
add("RECOVER(" + to_string(action.state_index) + ")");
|
||||
break;
|
||||
default: {}
|
||||
}
|
||||
add(",");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue