Add stream operator for parse states
This commit is contained in:
parent
5d9dc71da1
commit
0877d01194
3 changed files with 34 additions and 0 deletions
|
|
@ -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());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue