From b68f7212c874b3419a5334e2062ee41d50307805 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 2 Mar 2016 20:47:20 -0800 Subject: [PATCH] Do not consider any symbols to be 'in-progress' in out-of-context states --- src/compiler/build_tables/build_parse_table.cc | 2 +- src/compiler/generate_code/c_code.cc | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/compiler/build_tables/build_parse_table.cc b/src/compiler/build_tables/build_parse_table.cc index 29410e52..e96df059 100644 --- a/src/compiler/build_tables/build_parse_table.cc +++ b/src/compiler/build_tables/build_parse_table.cc @@ -143,7 +143,7 @@ class ParseTableBuilder { ParseStateId state_id = parse_table.add_state(); for (const auto &entry : item_set.entries) { const ParseItem &item = entry.first; - if (item.step_index > 0 && item.lhs() != rules::START()) + if (item.step_index > 0 && item.lhs() != rules::START() && !allow_any_conflict) parse_table.states[state_id].in_progress_symbols.insert(item.lhs()); } diff --git a/src/compiler/generate_code/c_code.cc b/src/compiler/generate_code/c_code.cc index 8906fdf5..4d7475b1 100644 --- a/src/compiler/generate_code/c_code.cc +++ b/src/compiler/generate_code/c_code.cc @@ -269,14 +269,17 @@ class CCodeGenerator { } void add_in_progress_symbol_table() { - line("static unsigned short ts_in_progress_symbol_table[] = {"); + add_in_progress_symbol_list_id({}); + line("static unsigned short ts_in_progress_symbol_table[STATE_COUNT] = {"); indent([&]() { size_t state_id = 0; for (const ParseState &state : parse_table.states) { - line("[" + to_string(state_id) + "] = "); - add(to_string(add_in_progress_symbol_list_id(state.in_progress_symbols))); - add(","); + if (!state.in_progress_symbols.empty()) { + line("[" + to_string(state_id) + "] = "); + add(to_string(add_in_progress_symbol_list_id(state.in_progress_symbols))); + add(","); + } state_id++; } });