Add stream operator for PrecedenceRange in spec helpers

This commit is contained in:
Max Brunsfeld 2015-10-06 10:50:09 -07:00
parent 5455fb977f
commit aaafdd4797
2 changed files with 10 additions and 4 deletions

View file

@ -73,13 +73,13 @@ ostream &operator<<(ostream &stream, const ParseAction &action) {
case ParseActionTypeAccept:
return stream << string("#<accept>");
case ParseActionTypeShift:
return stream << (string("#<shift ") + to_string(action.state_index) +
">");
return stream << string("#<shift state:") << to_string(action.state_index) <<
string(" precedence:") << action.precedence_range << ">";
case ParseActionTypeShiftExtra:
return stream << string("#<shift_extra");
case ParseActionTypeReduceExtra:
return stream << ("#<reduce_extra sym" + to_string(action.symbol.index) +
">");
return stream << "#<reduce_extra sym:" << action.symbol <<
string(" precedence:") << to_string(action.precedence_range.min) << ">";
case ParseActionTypeReduce:
return stream << ("#<reduce sym" + to_string(action.symbol.index) + " " +
to_string(action.consumed_symbol_count) + ">");
@ -109,6 +109,10 @@ ostream &operator<<(ostream &stream, const ProductionStep &step) {
return stream << string("(production_step symbol:") << step.symbol << string(" precedence:") << to_string(step.precedence) << ")";
}
ostream &operator<<(ostream &stream, const PrecedenceRange &range) {
return stream << string("{") << to_string(range.min) << string(", ") << to_string(range.max) << string("}");
}
namespace build_tables {
ostream &operator<<(ostream &stream, const LexItem &item) {

View file

@ -95,6 +95,7 @@ class LexAction;
class ParseAction;
class ParseState;
struct ProductionStep;
struct PrecedenceRange;
ostream &operator<<(ostream &, const Grammar &);
ostream &operator<<(ostream &, const GrammarError &);
@ -106,6 +107,7 @@ ostream &operator<<(ostream &, const LexAction &);
ostream &operator<<(ostream &, const ParseAction &);
ostream &operator<<(ostream &, const ParseState &);
ostream &operator<<(ostream &, const ProductionStep &);
ostream &operator<<(ostream &, const PrecedenceRange &);
namespace build_tables {