Include out-of-context states starting with non-terminals

This commit is contained in:
Max Brunsfeld 2016-03-02 20:45:13 -08:00
parent e7abfdd373
commit 76d072545d
4 changed files with 54 additions and 25 deletions

View file

@ -225,10 +225,12 @@ class CCodeGenerator {
indent([&]() {
for (const auto &entry : parse_table.symbols) {
const rules::Symbol &symbol = entry.first;
ParseStateId state = parse_table.out_of_context_state_indices.find(symbol)->second;
if (symbol.is_token && !symbol.is_built_in()) {
line("[" + symbol_id(symbol) + "] = " + to_string(state) + ",");
}
if (symbol.is_built_in())
continue;
auto iter = parse_table.out_of_context_state_indices.find(symbol);
string state = (iter != parse_table.out_of_context_state_indices.end()) ?
to_string(iter->second) : "ts_parse_state_error";
line("[" + symbol_id(symbol) + "] = " + state + ",");
}
});
line("};");