Remove unused methods and members

This commit is contained in:
Max Brunsfeld 2013-12-17 18:27:32 -08:00
parent 3417ad5adb
commit 2f74c1de10
3 changed files with 10 additions and 54 deletions

View file

@ -5,12 +5,6 @@ using namespace std;
namespace tree_sitter {
namespace lr {
// Action
ParseAction::ParseAction() :
type(ParseActionTypeError),
state_index(-1),
symbol_name(""),
child_symbol_count(-1) {};
ParseAction::ParseAction(ParseActionType type, size_t state_index, string symbol_name, size_t child_symbol_count) :
type(type),
state_index(state_index),
@ -36,23 +30,20 @@ namespace tree_sitter {
bool ParseAction::operator==(const ParseAction &other) const {
bool types_eq = type == other.type;
bool state_indices_eq = state_index == other.state_index;
bool symbol_ids_eq = symbol_name == other.symbol_name;
bool child_symbol_counts_eq = child_symbol_count == other.child_symbol_count;
return types_eq && state_indices_eq && symbol_ids_eq && child_symbol_counts_eq;
return types_eq && state_indices_eq && child_symbol_counts_eq;
}
ostream& operator<<(ostream &stream, const ParseAction &action) {
switch (action.type) {
case ParseActionTypeError:
return stream << string("error");
case ParseActionTypeAccept:
return stream << string("accept");
case ParseActionTypeAdvance:
return stream << (string("(advance ") + to_string(action.state_index) + ")");
case ParseActionTypeShift:
return stream << (string("(shift ") + to_string(action.state_index) + ")");
case ParseActionTypeReduce:
return stream << (string("(reduce ") + action.symbol_name + ")");
case ParseActionTypeError:
return stream << string("error");
}
}
@ -60,18 +51,7 @@ namespace tree_sitter {
ParseState::ParseState() : actions(unordered_map<string, unordered_set<ParseAction>>()) {}
// Table
unordered_map<string, size_t> get_symbol_id_map(const vector<string> &names) {
unordered_map<string, size_t> result;
size_t i = 0;
for (string name : names) {
result[name] = i;
i++;
}
return result;
}
ParseTable::ParseTable(vector<string> symbol_names) :
symbol_ids(get_symbol_id_map(symbol_names)),
symbol_names(symbol_names),
states(vector<ParseState>()) {};
@ -84,10 +64,6 @@ namespace tree_sitter {
states[state_index].actions[sym_name].insert(action);
}
ParseState ParseTable::starting_state() const {
return states[0];
}
unordered_map<string, unordered_set<ParseAction>> ParseTable::actions_for(size_t state_index) const {
return states[state_index].actions;
}