From c3b8a73831dc9ae049e5eb500781e463d2ede0ba Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 19 Dec 2013 12:53:32 -0800 Subject: [PATCH] Remove unneeded method from parse table --- spec/compiler/lr/parse_table_builder_spec.cpp | 8 ++++---- src/compiler/lr/parse_table.cpp | 4 ---- src/compiler/lr/parse_table.h | 2 -- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/spec/compiler/lr/parse_table_builder_spec.cpp b/spec/compiler/lr/parse_table_builder_spec.cpp index d23c51cc..f1596437 100644 --- a/spec/compiler/lr/parse_table_builder_spec.cpp +++ b/spec/compiler/lr/parse_table_builder_spec.cpp @@ -11,7 +11,7 @@ Describe(ParseTableBuilder_test) { ParseTable table = build_tables(grammar); It(has_the_right_starting_state) { - AssertThat(table.actions_for(0), Equals(unordered_map({ + AssertThat(table.states[0].actions, Equals(unordered_map({ { "expression", actions({ ParseAction::Shift(1) }) }, { "term", actions({ ParseAction::Shift(2) }) }, { "factor", actions({ ParseAction::Shift(5) }) }, @@ -22,17 +22,17 @@ Describe(ParseTableBuilder_test) { } It(accepts_when_the_start_symbol_is_reduced) { - AssertThat(table.actions_for(1), Equals(unordered_map({ + AssertThat(table.states[1].actions, Equals(unordered_map({ { ParseTable::END_OF_INPUT, actions({ ParseAction::Accept() }) } }))); } It(has_the_right_next_states) { - AssertThat(table.actions_for(2), Equals(unordered_map({ + AssertThat(table.states[2].actions, Equals(unordered_map({ { "plus", actions({ ParseAction::Shift(3) }) }, }))); - AssertThat(table.actions_for(3), Equals(unordered_map({ + AssertThat(table.states[3].actions, Equals(unordered_map({ { "variable", actions({ ParseAction::Shift(8) }) }, { "factor", actions({ ParseAction::Shift(5) }) }, { "left_paren", actions({ ParseAction::Shift(9) }) }, diff --git a/src/compiler/lr/parse_table.cpp b/src/compiler/lr/parse_table.cpp index e830e037..558126e2 100644 --- a/src/compiler/lr/parse_table.cpp +++ b/src/compiler/lr/parse_table.cpp @@ -64,10 +64,6 @@ namespace tree_sitter { states[state_index].actions[sym_name].insert(action); } - unordered_map> ParseTable::actions_for(size_t state_index) const { - return states[state_index].actions; - } - const string ParseTable::START = "__START__"; const string ParseTable::END_OF_INPUT = "__END__"; } diff --git a/src/compiler/lr/parse_table.h b/src/compiler/lr/parse_table.h index bcb87c8d..90bcbeba 100644 --- a/src/compiler/lr/parse_table.h +++ b/src/compiler/lr/parse_table.h @@ -19,7 +19,6 @@ namespace tree_sitter { ParseAction(ParseActionType type, size_t state_index, std::string symbol_name, size_t child_symbol_count); public: static ParseAction Accept(); - static ParseAction Advance(size_t state_index); static ParseAction Error(); static ParseAction Shift(size_t state_index); static ParseAction Reduce(std::string symbol_name, size_t child_symbol_count); @@ -43,7 +42,6 @@ namespace tree_sitter { public: ParseTable(std::vector rule_names); - std::unordered_map> actions_for(size_t state_index) const; size_t add_state(); void add_action(size_t state_index, std::string symbol_name, ParseAction action);