diff --git a/alib/src/grammar/Rule.cpp b/alib/src/grammar/Rule.cpp index 8113b2ca37d6dcc924e11298ffb744870e202fe5..6aa296a25fcbd8d65ce5573cef86924867b3d42e 100644 --- a/alib/src/grammar/Rule.cpp +++ b/alib/src/grammar/Rule.cpp @@ -102,4 +102,28 @@ bool Rule::operator !=(const Rule& other) const { || !equal(rightSide.begin(), rightSide.end(), other.rightSide.begin()); } +std::ostream& operator<<(std::ostream& out, const Rule& rule) { + bool first; + out << " leftSide = ["; + + first = true; + for(list<Symbol>::const_iterator iter = rule.leftSide.begin(); iter != rule.leftSide.end(); iter++) { + if(!first) out << ", "; + first = false; + out << *iter; + } + + out << "] rightSize = ["; + + first = true; + for(list<Symbol>::const_iterator iter = rule.rightSide.begin(); iter != rule.rightSide.end(); iter++) { + if(!first) out << ", "; + first = false; + out << *iter; + } + out << "]"; + + return out; +} + } /* namespace grammar */ diff --git a/alib/src/grammar/Rule.h b/alib/src/grammar/Rule.h index 1395dc2fef8746b4229af7275f263b70bd7e9f50..ab2235a83688e4f82a53b1f438015d51de1aa286 100644 --- a/alib/src/grammar/Rule.h +++ b/alib/src/grammar/Rule.h @@ -65,6 +65,8 @@ public: bool operator <(const Rule& other) const; bool operator ==(const Rule& other) const; bool operator !=(const Rule& other) const; + + friend std::ostream& operator<<(std::ostream&, const Rule&); }; } /* namespace grammar */