diff --git a/acat/src/acat.cpp b/acat/src/acat.cpp index f1ab25b513465116282423a2509d52e3f192e242..92ee523d548bcf55bb597eb717c90e7b709188af 100644 --- a/acat/src/acat.cpp +++ b/acat/src/acat.cpp @@ -34,21 +34,21 @@ void getAutomaton(list<Token>& tokens, bool complexTypes) { UnknownAutomaton automaton = AutomatonParser::parse(tokens); if(complexTypes) { - Automaton* concreateAutomaton = AutomatonFactory::buildAutomaton(automaton); - concreateAutomaton->toXML(cout); + Automaton* concreteAutomaton = AutomatonFactory::buildAutomaton(automaton); + cout << *concreteAutomaton; } else { - automaton.toXML(cout); + cout << automaton; } } void getGrammar(list<Token>& tokens) { UnknownGrammar grammar = GrammarParser::parse(tokens); - grammar.toXML(cout); + cout << grammar; } void getRegExp(list<Token>& tokens) { RegExp regexp = RegExpParser::parse(tokens); - regexp.toXML(cout); + cout << regexp; } int main(int argc, char** argv) { diff --git a/alib/src/automaton/Automaton.cpp b/alib/src/automaton/Automaton.cpp index 519b65c7c2d4e6eff25aaf1b0da7893e736c03a5..27235c01383ca74fb5f5af4b456d062d36e3d6ee 100644 --- a/alib/src/automaton/Automaton.cpp +++ b/alib/src/automaton/Automaton.cpp @@ -77,4 +77,11 @@ const set<State>& Automaton::getFinalStates() const { return finalStates; } +ostream& operator <<(ostream& out, const Automaton& automaton) { + automaton.toXML(out); + return out; +} + } /* namespace automaton */ + + diff --git a/alib/src/automaton/Automaton.h b/alib/src/automaton/Automaton.h index bfbfd4cfb8cd6b3d258a3491954a830892317b86..7686fe04e91df3a682c04c2e58a63d9b03373bb2 100644 --- a/alib/src/automaton/Automaton.h +++ b/alib/src/automaton/Automaton.h @@ -111,10 +111,17 @@ public: const set<State>& getFinalStates() const; /** - * Prints XML representation of the automaton. + * Prints XML representation of the automaton to the ostream. * @param out output stream to which print the automaton */ virtual void toXML(ostream& out) const = 0; + + /** + * Prints XML representation of the automaton to the ostream. + * @param out output stream to which print the automaton + * @param automaton automaton to print + */ + friend ostream& operator<<(ostream& out, const Automaton& automaton); }; } /* namespace automaton */ diff --git a/alib/src/grammar/Grammar.cpp b/alib/src/grammar/Grammar.cpp index be42c3f2d1e62b1cb1fa796ec5c5423b143bec2d..c1d28daed371558cdbe39d3b12fa5be2df3b444e 100644 --- a/alib/src/grammar/Grammar.cpp +++ b/alib/src/grammar/Grammar.cpp @@ -114,4 +114,9 @@ void Grammar::toXML(ostream& out) const { GrammarPrinter::toXML(*this, out); } +ostream& operator <<(ostream& out, const Grammar& grammar) { + grammar.toXML(out); + return out; +} + } /* namespace grammar */ diff --git a/alib/src/grammar/Grammar.h b/alib/src/grammar/Grammar.h index a6833a74f7e9ecfd1e8e40ed5932edbb41bf0575..fd4c2fe856de892b5e9a1cb9f2bb765d612cb362 100644 --- a/alib/src/grammar/Grammar.h +++ b/alib/src/grammar/Grammar.h @@ -116,6 +116,13 @@ public: * @param out output stream to print to */ void toXML(ostream& out) const; + + /** + * Prints the XML representation of grammar to the output stream. + * @param out output stream to print to + * @param grammar grammar to print + */ + friend ostream& operator<<(ostream& out, const Grammar& grammar); }; } /* namespace grammar */ diff --git a/alib/src/grammar/Rule.cpp b/alib/src/grammar/Rule.cpp index 6aa296a25fcbd8d65ce5573cef86924867b3d42e..1abe676b2552ec48a0a4ff49c270bd68eab990e7 100644 --- a/alib/src/grammar/Rule.cpp +++ b/alib/src/grammar/Rule.cpp @@ -102,7 +102,7 @@ bool Rule::operator !=(const Rule& other) const { || !equal(rightSide.begin(), rightSide.end(), other.rightSide.begin()); } -std::ostream& operator<<(std::ostream& out, const Rule& rule) { +ostream& operator<<(ostream& out, const Rule& rule) { bool first; out << " leftSide = ["; @@ -113,7 +113,7 @@ std::ostream& operator<<(std::ostream& out, const Rule& rule) { out << *iter; } - out << "] rightSize = ["; + out << "] rightSide = ["; first = true; for(list<Symbol>::const_iterator iter = rule.rightSide.begin(); iter != rule.rightSide.end(); iter++) { diff --git a/alib/src/grammar/Rule.h b/alib/src/grammar/Rule.h index ab2235a83688e4f82a53b1f438015d51de1aa286..f708aa71f5ee53a4bea1765754947858431dd08b 100644 --- a/alib/src/grammar/Rule.h +++ b/alib/src/grammar/Rule.h @@ -66,7 +66,7 @@ public: bool operator ==(const Rule& other) const; bool operator !=(const Rule& other) const; - friend std::ostream& operator<<(std::ostream&, const Rule&); + friend ostream& operator<<(ostream&, const Rule&); }; } /* namespace grammar */ diff --git a/alib/src/regexp/RegExp.cpp b/alib/src/regexp/RegExp.cpp index 92641f64ab2cbd000b06812647a3fa039ced5953..6cec78b363919503f23e2e06415217cfd3cc9e4f 100644 --- a/alib/src/regexp/RegExp.cpp +++ b/alib/src/regexp/RegExp.cpp @@ -70,4 +70,9 @@ void RegExp::toXML(ostream& out) { RegExpPrinter::toXML(*this, out); } +ostream& operator <<(ostream& out, RegExp& regexp) { + regexp.toXML(out); + return out; +} + } /* namespace regexp */ diff --git a/alib/src/regexp/RegExp.h b/alib/src/regexp/RegExp.h index f26f94fbf7ce1dfb7baee1317c9d353e4335ec34..73507c1fa4f01cf3152fcab3687eec88b8be62da 100644 --- a/alib/src/regexp/RegExp.h +++ b/alib/src/regexp/RegExp.h @@ -54,6 +54,13 @@ public: * @param out output stream to which print the RegExp */ void toXML(ostream& out); + + /** + * Prints XML representation of the RegExp to the output stream. + * @param out output stream to which print the RegExp + * @param regexp RegExp to print + */ + friend ostream& operator<<(ostream& out, RegExp& regexp); }; } /* namespace regexp */