Add stream operator for parse states

This commit is contained in:
Max Brunsfeld 2014-01-26 16:38:41 -08:00
parent 5d9dc71da1
commit 0877d01194
3 changed files with 34 additions and 0 deletions

View file

@ -59,6 +59,25 @@ namespace tree_sitter {
return result;
}
ostream& operator<<(ostream &stream, const ParseState &state) {
stream << string("#<parse_state ");
bool started1 = false;
for (auto pair : state.actions) {
if (started1) stream << string(", ");
stream << pair.first << string(" => #<set: ");
bool started2 = false;
for (auto action : pair.second) {
if (started2) stream << string(", ");
stream << action;
started2 = true;
}
stream << string(">");
started1 = true;
}
stream << string(">");
return stream;
}
// Table
size_t ParseTable::add_state() {
states.push_back(ParseState());