Handle extra tokens properly during error recovery

This commit is contained in:
Max Brunsfeld 2016-06-18 20:35:33 -07:00
parent 773e50f26b
commit 45f7cee0c8
3 changed files with 15 additions and 3 deletions

View file

@ -224,9 +224,13 @@ class CCodeGenerator {
for (const auto &entry : parse_table.error_state.actions) {
const rules::Symbol &symbol = entry.first;
if (!entry.second.empty()) {
ParseStateId state = entry.second[0].state_index;
line("[" + symbol_id(symbol) + "] = RECOVER(" + to_string(state) +
"),");
line("[" + symbol_id(symbol) + "] = ");
ParseAction action = entry.second[0];
if (action.extra) {
add("RECOVER_EXTRA(),");
} else {
add("RECOVER(" + to_string(action.state_index) + "),");
}
}
}
});