Remove unneeded method from parse table

This commit is contained in:
Max Brunsfeld 2013-12-19 12:53:32 -08:00
parent b1bbeae2a1
commit c3b8a73831
3 changed files with 4 additions and 10 deletions

View file

@ -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<string, actions>({
AssertThat(table.states[0].actions, Equals(unordered_map<string, actions>({
{ "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<string, actions>({
AssertThat(table.states[1].actions, Equals(unordered_map<string, actions>({
{ ParseTable::END_OF_INPUT, actions({ ParseAction::Accept() }) }
})));
}
It(has_the_right_next_states) {
AssertThat(table.actions_for(2), Equals(unordered_map<string, actions>({
AssertThat(table.states[2].actions, Equals(unordered_map<string, actions>({
{ "plus", actions({ ParseAction::Shift(3) }) },
})));
AssertThat(table.actions_for(3), Equals(unordered_map<string, actions>({
AssertThat(table.states[3].actions, Equals(unordered_map<string, actions>({
{ "variable", actions({ ParseAction::Shift(8) }) },
{ "factor", actions({ ParseAction::Shift(5) }) },
{ "left_paren", actions({ ParseAction::Shift(9) }) },

View file

@ -64,10 +64,6 @@ namespace tree_sitter {
states[state_index].actions[sym_name].insert(action);
}
unordered_map<string, unordered_set<ParseAction>> 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__";
}

View file

@ -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<std::string> rule_names);
std::unordered_map<std::string, std::unordered_set<ParseAction>> actions_for(size_t state_index) const;
size_t add_state();
void add_action(size_t state_index, std::string symbol_name, ParseAction action);