From 5d9dc71da1032e2acd2c5dc7da1e740390913774 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Sat, 25 Jan 2014 23:40:51 -0800 Subject: [PATCH] Remove default_actions from ParseTable --- src/compiler/build_tables/perform.cpp | 3 +-- src/compiler/generate_code/c_code.cpp | 2 +- src/compiler/parse_table.cpp | 4 ---- src/compiler/parse_table.h | 2 -- 4 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/compiler/build_tables/perform.cpp b/src/compiler/build_tables/perform.cpp index 7557f111..c8f01a37 100644 --- a/src/compiler/build_tables/perform.cpp +++ b/src/compiler/build_tables/perform.cpp @@ -36,8 +36,7 @@ namespace tree_sitter { } void add_shift_actions(const ParseItemSet &item_set, size_t state_index) { - auto x = sym_transitions(item_set, grammar); - for (auto transition : x) { + for (auto transition : sym_transitions(item_set, grammar)) { rules::Symbol symbol = *transition.first; ParseItemSet item_set = *transition.second; size_t new_state_index = add_parse_state(item_set); diff --git a/src/compiler/generate_code/c_code.cpp b/src/compiler/generate_code/c_code.cpp index c90d9172..1ccd0e99 100644 --- a/src/compiler/generate_code/c_code.cpp +++ b/src/compiler/generate_code/c_code.cpp @@ -182,7 +182,7 @@ namespace tree_sitter { string body = ""; for (auto pair : parse_state.actions) body += _case(symbol_id(pair.first), code_for_parse_actions(pair.second, parse_state.expected_inputs())); - body += _default(code_for_parse_actions(parse_state.default_actions, parse_state.expected_inputs())); + body += _default(parse_error_call(parse_state.expected_inputs())); return string("SET_LEX_STATE(") + to_string(parse_state.lex_state_index) + ");\n" + _switch("LOOKAHEAD_SYM()", body); diff --git a/src/compiler/parse_table.cpp b/src/compiler/parse_table.cpp index f3fb5177..bc265fdc 100644 --- a/src/compiler/parse_table.cpp +++ b/src/compiler/parse_table.cpp @@ -69,8 +69,4 @@ namespace tree_sitter { symbol_names.insert(sym_name); states[state_index].actions[sym_name].insert(action); } - - void ParseTable::add_default_action(size_t state_index, ParseAction action) { - states[state_index].default_actions.insert(action); - } } diff --git a/src/compiler/parse_table.h b/src/compiler/parse_table.h index 2bbdc47a..f9efcd92 100644 --- a/src/compiler/parse_table.h +++ b/src/compiler/parse_table.h @@ -50,7 +50,6 @@ namespace tree_sitter { public: ParseState(); std::unordered_map> actions; - std::unordered_set default_actions; std::unordered_set expected_inputs() const; size_t lex_state_index; }; @@ -59,7 +58,6 @@ namespace tree_sitter { public: size_t add_state(); void add_action(size_t state_index, std::string symbol_name, ParseAction action); - void add_default_action(size_t state_index, ParseAction action); std::vector states; std::unordered_set symbol_names;