From f4df7b745ed1745f3529ba17418391a8a29563aa Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Thu, 17 Jul 2014 10:14:27 +0200 Subject: [PATCH] fix compare and print methods --- alib2data/src/grammar/Regular/LeftLG.cpp | 3 --- alib2data/src/grammar/Regular/LeftRG.cpp | 3 ++- alib2data/src/grammar/Regular/RightLG.cpp | 3 --- alib2data/src/grammar/Regular/RightRG.cpp | 3 ++- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/alib2data/src/grammar/Regular/LeftLG.cpp b/alib2data/src/grammar/Regular/LeftLG.cpp index 29db7f37bc..f3ca254390 100644 --- a/alib2data/src/grammar/Regular/LeftLG.cpp +++ b/alib2data/src/grammar/Regular/LeftLG.cpp @@ -33,9 +33,6 @@ GrammarBase* LeftLG::plunder() && { bool LeftLG::removeTerminalSymbol(const alphabet::Symbol& symbol) { for(const std::pair<alphabet::Symbol, std::set<std::variant<std::vector<alphabet::Symbol>, std::pair<alphabet::Symbol, std::vector<alphabet::Symbol>> >> >& rule : rules) { - if(rule.first == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); - for(const std::variant<std::vector<alphabet::Symbol>, std::pair<alphabet::Symbol, std::vector<alphabet::Symbol>> >& rhsTmp : rule.second) if(rhsTmp.is<std::vector<alphabet::Symbol>>()) { const std::vector<alphabet::Symbol>& rhs = rhsTmp.get<std::vector<alphabet::Symbol>>(); diff --git a/alib2data/src/grammar/Regular/LeftRG.cpp b/alib2data/src/grammar/Regular/LeftRG.cpp index 1e497fd010..3c04fdb46e 100644 --- a/alib2data/src/grammar/Regular/LeftRG.cpp +++ b/alib2data/src/grammar/Regular/LeftRG.cpp @@ -110,7 +110,7 @@ bool LeftRG::operator==(const GrammarBase& other) const { } bool LeftRG::operator==(const LeftRG& other) const { - return this->nonterminalAlphabet == other.nonterminalAlphabet && this->terminalAlphabet == other.terminalAlphabet && this->initialSymbol == other.initialSymbol && this->rules == other.rules; + return this->nonterminalAlphabet == other.nonterminalAlphabet && this->terminalAlphabet == other.terminalAlphabet && this->initialSymbol == other.initialSymbol && this->rules == other.rules && this->generatesEpsilon == other.generatesEpsilon; } void LeftRG::operator>>(std::ostream& out) const { @@ -119,6 +119,7 @@ void LeftRG::operator>>(std::ostream& out) const { << "terminalAlphabet = " << terminalAlphabet << "initialSymbol = " << initialSymbol << "rules = " << rules + << "generatesEpsilon = " << generatesEpsilon << ")"; } diff --git a/alib2data/src/grammar/Regular/RightLG.cpp b/alib2data/src/grammar/Regular/RightLG.cpp index a124a0151a..1ba4a09b65 100644 --- a/alib2data/src/grammar/Regular/RightLG.cpp +++ b/alib2data/src/grammar/Regular/RightLG.cpp @@ -33,9 +33,6 @@ GrammarBase* RightLG::plunder() && { bool RightLG::removeTerminalSymbol(const alphabet::Symbol& symbol) { for(const std::pair<alphabet::Symbol, std::set<std::variant<std::vector<alphabet::Symbol>, std::pair<std::vector<alphabet::Symbol>, alphabet::Symbol> >> >& rule : rules) { - if(rule.first == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); - for(const std::variant<std::vector<alphabet::Symbol>, std::pair<std::vector<alphabet::Symbol>, alphabet::Symbol> >& rhsTmp : rule.second) if(rhsTmp.is<std::vector<alphabet::Symbol>>()) { const std::vector<alphabet::Symbol>& rhs = rhsTmp.get<std::vector<alphabet::Symbol>>(); diff --git a/alib2data/src/grammar/Regular/RightRG.cpp b/alib2data/src/grammar/Regular/RightRG.cpp index c185eb08b9..1091151e9e 100644 --- a/alib2data/src/grammar/Regular/RightRG.cpp +++ b/alib2data/src/grammar/Regular/RightRG.cpp @@ -110,7 +110,7 @@ bool RightRG::operator==(const GrammarBase& other) const { } bool RightRG::operator==(const RightRG& other) const { - return this->nonterminalAlphabet == other.nonterminalAlphabet && this->terminalAlphabet == other.terminalAlphabet && this->initialSymbol == other.initialSymbol && this->rules == other.rules; + return this->nonterminalAlphabet == other.nonterminalAlphabet && this->terminalAlphabet == other.terminalAlphabet && this->initialSymbol == other.initialSymbol && this->rules == other.rules && this->generatesEpsilon == other.generatesEpsilon; } void RightRG::operator>>(std::ostream& out) const { @@ -119,6 +119,7 @@ void RightRG::operator>>(std::ostream& out) const { << "terminalAlphabet = " << terminalAlphabet << "initialSymbol = " << initialSymbol << "rules = " << rules + << "generatesEpsilon = " << generatesEpsilon << ")"; } -- GitLab