diff --git a/alib2data/src/alphabet/Symbol.cpp b/alib2data/src/alphabet/Symbol.cpp index b6e64a111ca74931b70b2bb3784e98e51055d4dc..aa676f4988ae5199d2cb6aa2607f3064b2fff2fa 100644 --- a/alib2data/src/alphabet/Symbol.cpp +++ b/alib2data/src/alphabet/Symbol.cpp @@ -13,85 +13,12 @@ namespace alphabet { -Symbol::Symbol(const SymbolBase& symbol) : symbol(symbol.clone()) { - -} - -Symbol::Symbol(SymbolBase&& symbol) : symbol(std::move(symbol).plunder()) { - -} - -Symbol::Symbol(const Symbol& other) : symbol(other.getSymbol().clone()) { - -} - -Symbol::Symbol(Symbol&& other) noexcept : symbol(other.symbol) { - other.symbol = NULL; -} - -Symbol& Symbol::operator=(const Symbol& other) { - if(this == &other) return *this; - - delete symbol; - symbol = other.getSymbol().clone(); - - return *this; -} - -Symbol& Symbol::operator=(Symbol&& other) noexcept { - std::swap(this->symbol, other.symbol); - return *this; -} - -Symbol::~Symbol() { - delete symbol; -} - -const SymbolBase& Symbol::getSymbol() const { - return *symbol; -} - -SymbolBase& Symbol::getSymbol() { - return *symbol; -} - -void Symbol::setSymbol(const SymbolBase& symbol) { - delete this->symbol; - this->symbol = symbol.clone(); -} - -void Symbol::setSymbol(SymbolBase&& symbol) { - delete this->symbol; - this->symbol = std::move(symbol).plunder(); -} - -bool Symbol::operator<(const Symbol& other) const { - return *symbol < *other.symbol; -} - -bool Symbol::operator!=(const Symbol& other) const { - return !(*this == other); -} - -bool Symbol::operator==(const Symbol& other) const { - return *symbol == *other.symbol; -} - -std::ostream& operator<<(std::ostream& os, const Symbol& symbol) { - os << symbol.getSymbol(); - return os; -} - -Symbol::operator std::string() const { - return (std::string) *symbol; -} - -alphabet::Symbol Symbol::createUniqueSymbol(const alphabet::Symbol& base, const std::set<alphabet::Symbol>& terminalAlphabet, const std::set<alphabet::Symbol>& nonterminalAlphabet) { +alphabet::Symbol createUniqueSymbol(const alphabet::Symbol& base, const std::set<alphabet::Symbol>& terminalAlphabet, const std::set<alphabet::Symbol>& nonterminalAlphabet) { label::NextLabel nextLabelCreator; - const alphabet::LabeledSymbol* baseSymbol = dynamic_cast<const alphabet::LabeledSymbol*>(&(base.getSymbol())); + const alphabet::LabeledSymbol* baseSymbol = dynamic_cast<const alphabet::LabeledSymbol*>(&(base.getData())); if(baseSymbol == NULL) - throw exception::AlibException("Could not create unique symbol with nonlabeled base symbol " + (std::string) base.getSymbol() + "." ); + throw exception::AlibException("Could not create unique symbol with nonlabeled base symbol " + (std::string) base + "." ); label::Label nextLabel = baseSymbol->getLabel(); @@ -103,7 +30,7 @@ alphabet::Symbol Symbol::createUniqueSymbol(const alphabet::Symbol& base, const return attempt; } while(++i < INT_MAX); - throw exception::AlibException("Could not create unique symbol with base symbol " + (std::string) base.getSymbol() + "." ); + throw exception::AlibException("Could not create unique symbol with base symbol " + (std::string) base + "." ); } } /* namespace alphabet */ diff --git a/alib2data/src/alphabet/Symbol.h b/alib2data/src/alphabet/Symbol.h index 3b9499efb535e13817b67b8364e52e8c00dcfddb..e7f3fa355be80ef9f886cd874ce0a16c9e6e051c 100644 --- a/alib2data/src/alphabet/Symbol.h +++ b/alib2data/src/alphabet/Symbol.h @@ -10,6 +10,8 @@ #include "../std/visitor.hpp" #include "SymbolBase.h" +#include "../common/wrapper.hpp" + #include <set> namespace alphabet { @@ -17,43 +19,16 @@ namespace alphabet { /** * Wrapper around automata. */ -class Symbol { //TODO toto udělat v std templatované -protected: - SymbolBase* symbol; -public: - explicit Symbol(const SymbolBase& symbol); - explicit Symbol(SymbolBase&& symbol); - Symbol(const Symbol& other); - Symbol(Symbol&&) noexcept; - Symbol& operator=(const Symbol& other); - Symbol& operator=(Symbol&& other) noexcept; - virtual ~Symbol() noexcept; - - const SymbolBase& getSymbol() const; - SymbolBase& getSymbol(); - - void setSymbol(const SymbolBase& symbol); - void setSymbol(SymbolBase&& symbol); - - bool operator<(const Symbol& other) const; - - bool operator!=(const Symbol& other) const; - - bool operator==(const Symbol& other) const; - - friend std::ostream& operator<<(std::ostream& os, const Symbol& symbol); - - operator std::string () const; - - /** - * Creates and adds unique state to grammar. If given state name is - * already used, appends apostrophe or integer suffix - * @param name name of the state - * @throws AutomatonException if symbol could not be created - * @return created symbol - */ - static alphabet::Symbol createUniqueSymbol(const alphabet::Symbol& base, const std::set<alphabet::Symbol>& Terminals, const std::set<alphabet::Symbol>& nonterminals); -}; +typedef alib::wrapper<SymbolBase> Symbol; + +/** + * Creates and adds unique state to grammar. If given state name is + * already used, appends apostrophe or integer suffix + * @param name name of the state + * @throws AutomatonException if symbol could not be created + * @return created symbol + */ +alphabet::Symbol createUniqueSymbol(const alphabet::Symbol& base, const std::set<alphabet::Symbol>& Terminals, const std::set<alphabet::Symbol>& nonterminals); } /* namespace alphabet */ diff --git a/alib2data/src/alphabet/SymbolToStringComposer.cpp b/alib2data/src/alphabet/SymbolToStringComposer.cpp index 48ea246c22a658130dfa2c5cda58df53e4731feb..610052de8655d9cac76a8fda31853b3269153942 100644 --- a/alib2data/src/alphabet/SymbolToStringComposer.cpp +++ b/alib2data/src/alphabet/SymbolToStringComposer.cpp @@ -38,7 +38,7 @@ void SymbolToStringComposer::Visit(void* userData, const EndSymbol&) { } void SymbolToStringComposer::Visit(void* userData, const Symbol& symbol) { - symbol.getSymbol().Accept(userData, *this); + symbol.getData().Accept(userData, *this); } diff --git a/alib2data/src/alphabet/SymbolToXMLComposer.cpp b/alib2data/src/alphabet/SymbolToXMLComposer.cpp index 9db986691339f0ea1a59138f0fee8045b8592f71..13b01b8734a7aa6570ead858d1dfd22d78aaba26 100644 --- a/alib2data/src/alphabet/SymbolToXMLComposer.cpp +++ b/alib2data/src/alphabet/SymbolToXMLComposer.cpp @@ -41,7 +41,7 @@ void SymbolToXMLComposer::Visit(void* userData, const LabeledSymbol& symbol) con } void SymbolToXMLComposer::Visit(void* userData, const Symbol& symbol) const { - symbol.getSymbol().Accept(userData, *this); + symbol.getData().Accept(userData, *this); } diff --git a/alib2data/src/common/wrapper.hpp b/alib2data/src/common/wrapper.hpp index 3b674f9bb2b5d3a65a9208f9e10497ee6614aafc..fb053875c038b6165b7ea67422b0ba647edb7eb7 100644 --- a/alib2data/src/common/wrapper.hpp +++ b/alib2data/src/common/wrapper.hpp @@ -70,10 +70,26 @@ public: this->data = std::move(data).plunder(); } + bool operator>=(const wrapper& other) const { + return *(this->data) >= *(other.data); + } + + bool operator<=(const wrapper& other) const { + return *(this->data) <= *(other.data); + } + + bool operator>(const wrapper& other) const { + return *(this->data) > *(other.data); + } + bool operator<(const wrapper& other) const { return *(this->data) < *(other.data); } + bool operator!=(const wrapper& other) const { + return *(this->data) != *(other.data); + } + bool operator==(const wrapper& other) const { return *(this->data) == *(other.data); } diff --git a/alib2data/src/grammar/ContextFree/CFG.cpp b/alib2data/src/grammar/ContextFree/CFG.cpp index dc421d214447d9b81b14236e91c177617ad7d348..2e391191f2f7251f3630f95753273aadcb5b8e43 100644 --- a/alib2data/src/grammar/ContextFree/CFG.cpp +++ b/alib2data/src/grammar/ContextFree/CFG.cpp @@ -35,7 +35,7 @@ bool CFG::removeTerminalSymbol(const alphabet::Symbol& symbol) { for(const std::pair<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>>& rule : rules) { for(const std::vector<alphabet::Symbol>& rhs : rule.second) if(std::find(rhs.begin(), rhs.end(), symbol) != rhs.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } return terminalAlphabet.erase(symbol); @@ -44,15 +44,15 @@ bool CFG::removeTerminalSymbol(const alphabet::Symbol& symbol) { bool CFG::removeNonterminalSymbol(const alphabet::Symbol& symbol) { for(const std::pair<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>>& rule : rules) { if(rule.first == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); for(const std::vector<alphabet::Symbol>& rhs : rule.second) if(std::find(rhs.begin(), rhs.end(), symbol) != rhs.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } if(initialSymbol == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is initial symbol."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is initial symbol."); return nonterminalAlphabet.erase(symbol); @@ -64,7 +64,7 @@ bool CFG::addRule(const alphabet::Symbol& leftHandSide, const std::vector<alphab for(const alphabet::Symbol& symbol : rightHandSide) if(terminalAlphabet.find(symbol) == terminalAlphabet.end() && nonterminalAlphabet.find(symbol) == nonterminalAlphabet.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is not neither terminal nor nonterminal symbol"); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is not neither terminal nor nonterminal symbol"); return rules[leftHandSide].insert(rightHandSide).second; } diff --git a/alib2data/src/grammar/ContextFree/CNF.cpp b/alib2data/src/grammar/ContextFree/CNF.cpp index d6b39fff17ae06dd6e81cd258b3a53b9a497bdce..4abd662ffc4296320eab3503b590c110ac53a1bc 100644 --- a/alib2data/src/grammar/ContextFree/CNF.cpp +++ b/alib2data/src/grammar/ContextFree/CNF.cpp @@ -35,7 +35,7 @@ bool CNF::removeTerminalSymbol(const alphabet::Symbol& symbol) { for(const std::pair<alphabet::Symbol, std::set<std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>>>>& rule : rules) { for(const std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>>& rhs : rule.second) { if((rhs.is<alphabet::Symbol>() && rhs.get<alphabet::Symbol>() == symbol) || (rhs.get<std::pair<alphabet::Symbol, alphabet::Symbol>>().first == symbol)) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } } @@ -45,15 +45,15 @@ bool CNF::removeTerminalSymbol(const alphabet::Symbol& symbol) { bool CNF::removeNonterminalSymbol(const alphabet::Symbol& symbol) { for(const std::pair<alphabet::Symbol, std::set<std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>>>>& rule : rules) { if(rule.first == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); for(const std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>>& rhs : rule.second) if(rhs.get<std::pair<alphabet::Symbol, alphabet::Symbol>>().second == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } if(initialSymbol == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is initial symbol."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is initial symbol."); return nonterminalAlphabet.erase(symbol); } @@ -74,10 +74,10 @@ bool CNF::addRule(const alphabet::Symbol& leftHandSide, const std::variant<alpha throw GrammarException("Rule must rewrite nonterminal symbol"); if(nonterminalAlphabet.find(rhs.first) == nonterminalAlphabet.end()) - throw GrammarException("Symbol \"" + (std::string) rhs.first.getSymbol() + "\" is not a nonterminal symbol"); + throw GrammarException("Symbol \"" + (std::string) rhs.first + "\" is not a nonterminal symbol"); if(nonterminalAlphabet.find(rhs.second) == nonterminalAlphabet.end()) - throw GrammarException("Symbol \"" + (std::string) rhs.second.getSymbol() + "\" is not a nonterminal symbol"); + throw GrammarException("Symbol \"" + (std::string) rhs.second + "\" is not a nonterminal symbol"); return rules[leftHandSide].insert(rightHandSide).second; } diff --git a/alib2data/src/grammar/ContextFree/EpsilonFreeCFG.cpp b/alib2data/src/grammar/ContextFree/EpsilonFreeCFG.cpp index 3cd49c41e533a6651e0ae6a4cbe6d07072d4dd32..be29e4a054a2566bced394b8df9b874e06940bc1 100644 --- a/alib2data/src/grammar/ContextFree/EpsilonFreeCFG.cpp +++ b/alib2data/src/grammar/ContextFree/EpsilonFreeCFG.cpp @@ -35,7 +35,7 @@ bool EpsilonFreeCFG::removeTerminalSymbol(const alphabet::Symbol& symbol) { for(const std::pair<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>>& rule : rules) { for(const std::vector<alphabet::Symbol>& rhs : rule.second) if(std::find(rhs.begin(), rhs.end(), symbol) != rhs.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } return terminalAlphabet.erase(symbol); @@ -44,15 +44,15 @@ bool EpsilonFreeCFG::removeTerminalSymbol(const alphabet::Symbol& symbol) { bool EpsilonFreeCFG::removeNonterminalSymbol(const alphabet::Symbol& symbol) { for(const std::pair<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>>& rule : rules) { if(rule.first == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); for(const std::vector<alphabet::Symbol>& rhs : rule.second) if(std::find(rhs.begin(), rhs.end(), symbol) != rhs.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } if(initialSymbol == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is initial symbol."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is initial symbol."); return nonterminalAlphabet.erase(symbol); @@ -69,7 +69,7 @@ bool EpsilonFreeCFG::addRule(const alphabet::Symbol& leftHandSide, const std::ve for(const alphabet::Symbol& symbol : rightHandSide) { if(terminalAlphabet.find(symbol) == terminalAlphabet.end() && nonterminalAlphabet.find(symbol) == nonterminalAlphabet.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is not neither terminal nor nonterminal symbol"); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is not neither terminal nor nonterminal symbol"); } return rules[leftHandSide].insert(rightHandSide).second; diff --git a/alib2data/src/grammar/ContextFree/GNF.cpp b/alib2data/src/grammar/ContextFree/GNF.cpp index 6519eaa5fa01d345b6e536bc390029739eeea3bf..258f41162fe374aa76d909797d0e9739001b45e8 100644 --- a/alib2data/src/grammar/ContextFree/GNF.cpp +++ b/alib2data/src/grammar/ContextFree/GNF.cpp @@ -35,7 +35,7 @@ bool GNF::removeTerminalSymbol(const alphabet::Symbol& symbol) { for(const std::pair<alphabet::Symbol, std::set<std::pair<alphabet::Symbol, std::vector<alphabet::Symbol> >> >& rule : rules) { for(const std::pair<alphabet::Symbol, std::vector<alphabet::Symbol> >& rhs : rule.second) if(rhs.first == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } return terminalAlphabet.erase(symbol); @@ -44,15 +44,15 @@ bool GNF::removeTerminalSymbol(const alphabet::Symbol& symbol) { bool GNF::removeNonterminalSymbol(const alphabet::Symbol& symbol) { for(const std::pair<alphabet::Symbol, std::set<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."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); for(const std::pair<alphabet::Symbol, std::vector<alphabet::Symbol> >& rhs : rule.second) if(std::find(rhs.second.begin(), rhs.second.end(), symbol) != rhs.second.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } if(initialSymbol == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is initial symbol."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is initial symbol."); return nonterminalAlphabet.erase(symbol); @@ -67,7 +67,7 @@ bool GNF::addRule(const alphabet::Symbol& leftHandSide, const std::pair<alphabet for(const alphabet::Symbol& rhsNTs : rightHandSide.second) if(nonterminalAlphabet.find(rhsNTs) == nonterminalAlphabet.end()) - throw GrammarException("Symbol \"" + (std::string) rhsNTs.getSymbol() + "\" is not a nonterminal symbol"); + throw GrammarException("Symbol \"" + (std::string) rhsNTs + "\" is not a nonterminal symbol"); return rules[leftHandSide].insert(rightHandSide).second; } diff --git a/alib2data/src/grammar/ContextFree/LG.cpp b/alib2data/src/grammar/ContextFree/LG.cpp index 6e75d796af6c71fb45694c18fc93b754fbe4b525..b6e1afa4c44de051f6370547a8920c704021d7ed 100644 --- a/alib2data/src/grammar/ContextFree/LG.cpp +++ b/alib2data/src/grammar/ContextFree/LG.cpp @@ -38,17 +38,17 @@ bool LG::removeTerminalSymbol(const alphabet::Symbol& symbol) { const std::vector<alphabet::Symbol>& rhs = rhsTmp.get<std::vector<alphabet::Symbol>>(); if(std::find(rhs.begin(), rhs.end(), symbol) != rhs.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } else { const std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>>& rhs = rhsTmp.get<std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>>>(); const std::vector<alphabet::Symbol>& lPart = std::get<0>(rhs); if(std::find(lPart.begin(), lPart.end(), symbol) != lPart.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); const std::vector<alphabet::Symbol>& rPart = std::get<2>(rhs); if(std::find(rPart.begin(), rPart.end(), symbol) != rPart.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } } @@ -58,19 +58,19 @@ bool LG::removeTerminalSymbol(const alphabet::Symbol& symbol) { bool LG::removeNonterminalSymbol(const alphabet::Symbol& symbol) { for(const std::pair<alphabet::Symbol, std::set<std::variant<std::vector<alphabet::Symbol>, std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>> >> >& rule : rules) { if(rule.first == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); for(const std::variant<std::vector<alphabet::Symbol>, std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>> >& rhsTmp : rule.second) if(rhsTmp.is<std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>>>()) { const std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>>& rhs = rhsTmp.get<std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>>>(); if(std::get<1>(rhs) == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } } if(initialSymbol == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is initial symbol."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is initial symbol."); return nonterminalAlphabet.erase(symbol); @@ -84,7 +84,7 @@ bool LG::addRule(const alphabet::Symbol& leftHandSide, const std::variant<std::v const std::vector<alphabet::Symbol>& rhs = rightHandSide.get<std::vector<alphabet::Symbol>>(); for(const auto & symbol : rhs ) { if(terminalAlphabet.find(symbol) == terminalAlphabet.end()) - throw GrammarException("Symbol " + (std::string) symbol.getSymbol() + " is not a terminal symbol"); + throw GrammarException("Symbol " + (std::string) symbol + " is not a terminal symbol"); } return rules[leftHandSide].insert(rightHandSide).second; @@ -93,14 +93,14 @@ bool LG::addRule(const alphabet::Symbol& leftHandSide, const std::variant<std::v for(const auto & symbol : std::get<0>(rhs) ) if(terminalAlphabet.find(symbol) == terminalAlphabet.end()) - throw GrammarException("Symbol " + (std::string) symbol.getSymbol() + " is not a terminal symbol"); + throw GrammarException("Symbol " + (std::string) symbol + " is not a terminal symbol"); if(nonterminalAlphabet.find(std::get<1>(rhs)) == nonterminalAlphabet.end()) - throw GrammarException("Symbol " + (std::string) std::get<1>(rhs).getSymbol() + " is not a nonterminal symbol"); + throw GrammarException("Symbol " + (std::string) std::get<1>(rhs) + " is not a nonterminal symbol"); for(const auto & symbol : std::get<2>(rhs) ) { if(terminalAlphabet.find(symbol) == terminalAlphabet.end()) - throw GrammarException("Symbol " + (std::string) symbol.getSymbol() + " is not a terminal symbol"); + throw GrammarException("Symbol " + (std::string) symbol + " is not a terminal symbol"); } return rules[leftHandSide].insert(rightHandSide).second; diff --git a/alib2data/src/grammar/ContextSensitive/CSG.cpp b/alib2data/src/grammar/ContextSensitive/CSG.cpp index 5e9134aad2421c3138bfdf098bd7aa9d4f84c8e4..196f3b4c5375cee8a6e8e6b77aa14f1a63c119ce 100644 --- a/alib2data/src/grammar/ContextSensitive/CSG.cpp +++ b/alib2data/src/grammar/ContextSensitive/CSG.cpp @@ -36,15 +36,15 @@ bool CSG::removeTerminalSymbol(const alphabet::Symbol& symbol) { for(const std::pair<std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>>, std::set<std::vector<alphabet::Symbol>>>& rule : rules) { for(const alphabet::Symbol& lCont : std::get<0>(rule.first)) if(lCont == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); for(const alphabet::Symbol& rCont : std::get<2>(rule.first)) if(rCont == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); for(const std::vector<alphabet::Symbol>& rhs : rule.second) if(std::find(rhs.begin(), rhs.end(), symbol) != rhs.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } return terminalAlphabet.erase(symbol); @@ -54,22 +54,22 @@ bool CSG::removeNonterminalSymbol(const alphabet::Symbol& symbol) { for(const std::pair<std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>>, std::set<std::vector<alphabet::Symbol>>>& rule : rules) { for(const alphabet::Symbol& lCont : std::get<0>(rule.first)) if(lCont == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); if(std::get<1>(rule.first) == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); for(const alphabet::Symbol& rCont : std::get<2>(rule.first)) if(rCont == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); for(const std::vector<alphabet::Symbol>& rhs : rule.second) if(std::find(rhs.begin(), rhs.end(), symbol) != rhs.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } if(initialSymbol == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is initial symbol."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is initial symbol."); return nonterminalAlphabet.erase(symbol); @@ -83,7 +83,7 @@ bool CSG::addRule(const std::vector<alphabet::Symbol>& lContext, const alphabet: } else { for(const alphabet::Symbol& symbol : lContext) { if(terminalAlphabet.find(symbol) == terminalAlphabet.end() && nonterminalAlphabet.find(symbol) == nonterminalAlphabet.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is not neither terminal nor nonterminal symbol"); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is not neither terminal nor nonterminal symbol"); } if(!nonterminalAlphabet.count(leftHandSide)) @@ -91,12 +91,12 @@ bool CSG::addRule(const std::vector<alphabet::Symbol>& lContext, const alphabet: for(const alphabet::Symbol& symbol : rContext) { if(terminalAlphabet.find(symbol) == terminalAlphabet.end() && nonterminalAlphabet.find(symbol) == nonterminalAlphabet.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is not neither terminal nor nonterminal symbol"); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is not neither terminal nor nonterminal symbol"); } for(const alphabet::Symbol& symbol : rightHandSide) { if(terminalAlphabet.find(symbol) == terminalAlphabet.end() && nonterminalAlphabet.find(symbol) == nonterminalAlphabet.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is not neither terminal nor nonterminal symbol"); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is not neither terminal nor nonterminal symbol"); } return rules[make_tuple(lContext, leftHandSide, rContext)].insert(rightHandSide).second; diff --git a/alib2data/src/grammar/ContextSensitive/NonContractingGrammar.cpp b/alib2data/src/grammar/ContextSensitive/NonContractingGrammar.cpp index b2609ce18f5a3ee0dc6989e500c0966dadbd015c..7b6262a9119d40e89f491463133681c0ae34d23e 100644 --- a/alib2data/src/grammar/ContextSensitive/NonContractingGrammar.cpp +++ b/alib2data/src/grammar/ContextSensitive/NonContractingGrammar.cpp @@ -35,11 +35,11 @@ GrammarBase* NonContractingGrammar::plunder() && { bool NonContractingGrammar::removeTerminalSymbol(const alphabet::Symbol& symbol) { for(const std::pair<std::vector<alphabet::Symbol>, std::set<std::vector<alphabet::Symbol>>>& rule : rules) { if(std::find(rule.first.begin(), rule.first.end(), symbol) != rule.first.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); for(const std::vector<alphabet::Symbol>& rhs : rule.second) if(std::find(rhs.begin(), rhs.end(), symbol) != rhs.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } return terminalAlphabet.erase(symbol); @@ -48,15 +48,15 @@ bool NonContractingGrammar::removeTerminalSymbol(const alphabet::Symbol& symbol) bool NonContractingGrammar::removeNonterminalSymbol(const alphabet::Symbol& symbol) { for(const std::pair<std::vector<alphabet::Symbol>, std::set<std::vector<alphabet::Symbol>>>& rule : rules) { if(std::find(rule.first.begin(), rule.first.end(), symbol) != rule.first.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); for(const std::vector<alphabet::Symbol>& rhs : rule.second) if(std::find(rhs.begin(), rhs.end(), symbol) != rhs.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } if(initialSymbol == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is initial symbol."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is initial symbol."); return nonterminalAlphabet.erase(symbol); @@ -74,11 +74,11 @@ bool NonContractingGrammar::addRule(const std::vector<alphabet::Symbol>& leftHan for(const alphabet::Symbol& symbol : leftHandSide) if(terminalAlphabet.find(symbol) == terminalAlphabet.end() && nonterminalAlphabet.find(symbol) == nonterminalAlphabet.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is not neither terminal nor nonterminal symbol"); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is not neither terminal nor nonterminal symbol"); for(const alphabet::Symbol& symbol : rightHandSide) { if(terminalAlphabet.find(symbol) == terminalAlphabet.end() && nonterminalAlphabet.find(symbol) == nonterminalAlphabet.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is not neither terminal nor nonterminal symbol"); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is not neither terminal nor nonterminal symbol"); } return rules[leftHandSide].insert(rightHandSide).second; diff --git a/alib2data/src/grammar/Regular/LeftLG.cpp b/alib2data/src/grammar/Regular/LeftLG.cpp index 50c84ce8e70715b93c7ece66980394ea6df91e77..45aef55602e978c64e06570b257965cdbe1e1564 100644 --- a/alib2data/src/grammar/Regular/LeftLG.cpp +++ b/alib2data/src/grammar/Regular/LeftLG.cpp @@ -39,12 +39,12 @@ bool LeftLG::removeTerminalSymbol(const alphabet::Symbol& symbol) { const std::vector<alphabet::Symbol>& rhs = rhsTmp.get<std::vector<alphabet::Symbol>>(); if(std::find(rhs.begin(), rhs.end(), symbol) != rhs.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } else { const std::pair<alphabet::Symbol, std::vector<alphabet::Symbol>>& rhs = rhsTmp.get<std::pair<alphabet::Symbol, std::vector<alphabet::Symbol>>>(); if(std::find(rhs.second.begin(), rhs.second.end(), symbol) != rhs.second.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } } @@ -54,19 +54,19 @@ bool LeftLG::removeTerminalSymbol(const alphabet::Symbol& symbol) { bool LeftLG::removeNonterminalSymbol(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."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" 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::pair<alphabet::Symbol, std::vector<alphabet::Symbol>>>()) { const std::pair<alphabet::Symbol, std::vector<alphabet::Symbol>>& rhs = rhsTmp.get<std::pair<alphabet::Symbol, std::vector<alphabet::Symbol>>>(); if(rhs.first == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } } if(initialSymbol == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is initial symbol."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is initial symbol."); return nonterminalAlphabet.erase(symbol); @@ -80,7 +80,7 @@ bool LeftLG::addRule(const alphabet::Symbol& leftHandSide, const std::variant<st const std::vector<alphabet::Symbol>& rhs = rightHandSide.get<std::vector<alphabet::Symbol>>(); for(const auto & symbol : rhs ) { if(terminalAlphabet.find(symbol) == terminalAlphabet.end()) - throw GrammarException("Symbol " + (std::string) symbol.getSymbol() + " is not a terminal symbol"); + throw GrammarException("Symbol " + (std::string) symbol + " is not a terminal symbol"); } return rules[leftHandSide].insert(rightHandSide).second; @@ -88,11 +88,11 @@ bool LeftLG::addRule(const alphabet::Symbol& leftHandSide, const std::variant<st const std::pair<alphabet::Symbol, std::vector<alphabet::Symbol>>& rhs = rightHandSide.get<std::pair<alphabet::Symbol, std::vector<alphabet::Symbol>>>(); if(nonterminalAlphabet.find(rhs.first) == nonterminalAlphabet.end()) - throw GrammarException("Symbol " + (std::string) rhs.first.getSymbol() + " is not a nonterminal symbol"); + throw GrammarException("Symbol " + (std::string) rhs.first + " is not a nonterminal symbol"); for(const auto & symbol : rhs.second ) { if(terminalAlphabet.find(symbol) == terminalAlphabet.end()) - throw GrammarException("Symbol " + (std::string) symbol.getSymbol() + " is not a terminal symbol"); + throw GrammarException("Symbol " + (std::string) symbol + " is not a terminal symbol"); } return rules[leftHandSide].insert(rightHandSide).second; diff --git a/alib2data/src/grammar/Regular/LeftRG.cpp b/alib2data/src/grammar/Regular/LeftRG.cpp index 4b919635ef097b09bacb5db7a102ff947e6cea7f..b337d4e7d7f3f67a11bb409500ea8f5a856d8fa0 100644 --- a/alib2data/src/grammar/Regular/LeftRG.cpp +++ b/alib2data/src/grammar/Regular/LeftRG.cpp @@ -36,7 +36,7 @@ bool LeftRG::removeTerminalSymbol(const alphabet::Symbol& symbol) { for(const std::pair<alphabet::Symbol, std::set<std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>>>>& rule : rules) { for(const std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>>& rhs : rule.second) { if((rhs.is<alphabet::Symbol>() && rhs.get<alphabet::Symbol>() == symbol) || (rhs.get<std::pair<alphabet::Symbol, alphabet::Symbol>>().first == symbol)) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } } @@ -46,15 +46,15 @@ bool LeftRG::removeTerminalSymbol(const alphabet::Symbol& symbol) { bool LeftRG::removeNonterminalSymbol(const alphabet::Symbol& symbol) { for(const std::pair<alphabet::Symbol, std::set<std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>>>>& rule : rules) { if(rule.first == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); for(const std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>>& rhs : rule.second) if(rhs.get<std::pair<alphabet::Symbol, alphabet::Symbol>>().second == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } if(initialSymbol == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is initial symbol."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is initial symbol."); return nonterminalAlphabet.erase(symbol); } diff --git a/alib2data/src/grammar/Regular/RightLG.cpp b/alib2data/src/grammar/Regular/RightLG.cpp index 53fdb3466aa4a2db0bc0c5b8fafc86f553cbc969..f347252e0be89b7a65459a4ee09335bf1cf2a8cc 100644 --- a/alib2data/src/grammar/Regular/RightLG.cpp +++ b/alib2data/src/grammar/Regular/RightLG.cpp @@ -39,12 +39,12 @@ bool RightLG::removeTerminalSymbol(const alphabet::Symbol& symbol) { const std::vector<alphabet::Symbol>& rhs = rhsTmp.get<std::vector<alphabet::Symbol>>(); if(std::find(rhs.begin(), rhs.end(), symbol) != rhs.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } else { const std::pair<std::vector<alphabet::Symbol>, alphabet::Symbol>& rhs = rhsTmp.get<std::pair<std::vector<alphabet::Symbol>, alphabet::Symbol>>(); if(std::find(rhs.first.begin(), rhs.first.end(), symbol) != rhs.first.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } } @@ -54,19 +54,19 @@ bool RightLG::removeTerminalSymbol(const alphabet::Symbol& symbol) { bool RightLG::removeNonterminalSymbol(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."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" 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::pair<std::vector<alphabet::Symbol>, alphabet::Symbol>>()) { const std::pair<std::vector<alphabet::Symbol>, alphabet::Symbol>& rhs = rhsTmp.get<std::pair<std::vector<alphabet::Symbol>, alphabet::Symbol>>(); if(rhs.second == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } } if(initialSymbol == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is initial symbol."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is initial symbol."); return nonterminalAlphabet.erase(symbol); @@ -80,7 +80,7 @@ bool RightLG::addRule(const alphabet::Symbol& leftHandSide, const std::variant<s const std::vector<alphabet::Symbol>& rhs = rightHandSide.get<std::vector<alphabet::Symbol>>(); for(const auto & symbol : rhs ) { if(terminalAlphabet.find(symbol) == terminalAlphabet.end()) - throw GrammarException("Symbol " + (std::string) symbol.getSymbol() + " is not a terminal symbol"); + throw GrammarException("Symbol " + (std::string) symbol + " is not a terminal symbol"); } return rules[leftHandSide].insert(rightHandSide).second; @@ -88,11 +88,11 @@ bool RightLG::addRule(const alphabet::Symbol& leftHandSide, const std::variant<s const std::pair<std::vector<alphabet::Symbol>, alphabet::Symbol>& rhs = rightHandSide.get<std::pair<std::vector<alphabet::Symbol>, alphabet::Symbol>>(); if(nonterminalAlphabet.find(rhs.second) == nonterminalAlphabet.end()) - throw GrammarException("Symbol " + (std::string) rhs.second.getSymbol() + " is not a nonterminal symbol"); + throw GrammarException("Symbol " + (std::string) rhs.second + " is not a nonterminal symbol"); for(const auto & symbol : rhs.first ) { if(terminalAlphabet.find(symbol) == terminalAlphabet.end()) - throw GrammarException("Symbol " + (std::string) symbol.getSymbol() + " is not a terminal symbol"); + throw GrammarException("Symbol " + (std::string) symbol + " is not a terminal symbol"); } return rules[leftHandSide].insert(rightHandSide).second; diff --git a/alib2data/src/grammar/Regular/RightRG.cpp b/alib2data/src/grammar/Regular/RightRG.cpp index 2a203c073ddb2feb264e00dd71415e0a38af06ee..a21b1aa265359c851df68a8e0564cfcb6fb9a5eb 100644 --- a/alib2data/src/grammar/Regular/RightRG.cpp +++ b/alib2data/src/grammar/Regular/RightRG.cpp @@ -36,7 +36,7 @@ bool RightRG::removeTerminalSymbol(const alphabet::Symbol& symbol) { for(const std::pair<alphabet::Symbol, std::set<std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>>>>& rule : rules) { for(const std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>>& rhs : rule.second) { if((rhs.is<alphabet::Symbol>() && rhs.get<alphabet::Symbol>() == symbol) || (rhs.get<std::pair<alphabet::Symbol, alphabet::Symbol>>().first == symbol)) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } } @@ -46,15 +46,15 @@ bool RightRG::removeTerminalSymbol(const alphabet::Symbol& symbol) { bool RightRG::removeNonterminalSymbol(const alphabet::Symbol& symbol) { for(const std::pair<alphabet::Symbol, std::set<std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>>>>& rule : rules) { if(rule.first == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); for(const std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>>& rhs : rule.second) if(rhs.get<std::pair<alphabet::Symbol, alphabet::Symbol>>().second == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } if(initialSymbol == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is initial symbol."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is initial symbol."); return nonterminalAlphabet.erase(symbol); } diff --git a/alib2data/src/grammar/UnknownRule.cpp b/alib2data/src/grammar/UnknownRule.cpp index 37c1e6fabef60c048a44b8aa2e71e13cb2cc4c34..07884ca6d87b8f0e17275f2176ef82e130a6e9e6 100644 --- a/alib2data/src/grammar/UnknownRule.cpp +++ b/alib2data/src/grammar/UnknownRule.cpp @@ -38,11 +38,11 @@ std::string UnknownRule::toString() const { std::string output; output += "["; for(auto const& symbol : leftSide) { - output += " " + (std::string) symbol.getSymbol(); + output += " " + (std::string) symbol; } output += " -> "; for(auto const& symbol : rightSide) { - output += " " + (std::string) symbol.getSymbol(); + output += " " + (std::string) symbol; } output += "]"; diff --git a/alib2data/src/grammar/Unrestricted/ContextPreservingUnrestrictedGrammar.cpp b/alib2data/src/grammar/Unrestricted/ContextPreservingUnrestrictedGrammar.cpp index 1bd96b3a99ae2c31e82e3eeb33c614ddcf25989e..667f24fae049438151a96dc0b89a6b671adbffb8 100644 --- a/alib2data/src/grammar/Unrestricted/ContextPreservingUnrestrictedGrammar.cpp +++ b/alib2data/src/grammar/Unrestricted/ContextPreservingUnrestrictedGrammar.cpp @@ -36,15 +36,15 @@ bool ContextPreservingUnrestrictedGrammar::removeTerminalSymbol(const alphabet:: for(const std::pair<std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>>, std::set<std::vector<alphabet::Symbol>>>& rule : rules) { for(const alphabet::Symbol& lCont : std::get<0>(rule.first)) if(lCont == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); for(const alphabet::Symbol& rCont : std::get<2>(rule.first)) if(rCont == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); for(const std::vector<alphabet::Symbol>& rhs : rule.second) if(std::find(rhs.begin(), rhs.end(), symbol) != rhs.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } return terminalAlphabet.erase(symbol); @@ -54,22 +54,22 @@ bool ContextPreservingUnrestrictedGrammar::removeNonterminalSymbol(const alphabe for(const std::pair<std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>>, std::set<std::vector<alphabet::Symbol>>>& rule : rules) { for(const alphabet::Symbol& lCont : std::get<0>(rule.first)) if(lCont == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); if(std::get<1>(rule.first) == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); for(const alphabet::Symbol& rCont : std::get<2>(rule.first)) if(rCont == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); for(const std::vector<alphabet::Symbol>& rhs : rule.second) if(std::find(rhs.begin(), rhs.end(), symbol) != rhs.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } if(initialSymbol == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is initial symbol."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is initial symbol."); return nonterminalAlphabet.erase(symbol); @@ -78,7 +78,7 @@ bool ContextPreservingUnrestrictedGrammar::removeNonterminalSymbol(const alphabe bool ContextPreservingUnrestrictedGrammar::addRule(const std::vector<alphabet::Symbol>& lContext, const alphabet::Symbol& leftHandSide, const std::vector<alphabet::Symbol>& rContext, const std::vector<alphabet::Symbol>& rightHandSide) { for(const alphabet::Symbol& symbol : lContext) { if(terminalAlphabet.find(symbol) == terminalAlphabet.end() && nonterminalAlphabet.find(symbol) == nonterminalAlphabet.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is not neither terminal nor nonterminal symbol"); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is not neither terminal nor nonterminal symbol"); } if(!nonterminalAlphabet.count(leftHandSide)) @@ -86,12 +86,12 @@ bool ContextPreservingUnrestrictedGrammar::addRule(const std::vector<alphabet::S for(const alphabet::Symbol& symbol : rContext) { if(terminalAlphabet.find(symbol) == terminalAlphabet.end() && nonterminalAlphabet.find(symbol) == nonterminalAlphabet.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is not neither terminal nor nonterminal symbol"); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is not neither terminal nor nonterminal symbol"); } for(const alphabet::Symbol& symbol : rightHandSide) { if(terminalAlphabet.find(symbol) == terminalAlphabet.end() && nonterminalAlphabet.find(symbol) == nonterminalAlphabet.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is not neither terminal nor nonterminal symbol"); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is not neither terminal nor nonterminal symbol"); } return rules[make_tuple(lContext, leftHandSide, rContext)].insert(rightHandSide).second; diff --git a/alib2data/src/grammar/Unrestricted/UnrestrictedGrammar.cpp b/alib2data/src/grammar/Unrestricted/UnrestrictedGrammar.cpp index 90786844b02876660dbd8cf04b19c1edcd98e23a..fda7e4982cb42d938b236d594ad501b3164fd43d 100644 --- a/alib2data/src/grammar/Unrestricted/UnrestrictedGrammar.cpp +++ b/alib2data/src/grammar/Unrestricted/UnrestrictedGrammar.cpp @@ -35,11 +35,11 @@ GrammarBase* UnrestrictedGrammar::plunder() && { bool UnrestrictedGrammar::removeTerminalSymbol(const alphabet::Symbol& symbol) { for(const std::pair<std::vector<alphabet::Symbol>, std::set<std::vector<alphabet::Symbol>>>& rule : rules) { if(std::find(rule.first.begin(), rule.first.end(), symbol) != rule.first.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); for(const std::vector<alphabet::Symbol>& rhs : rule.second) if(std::find(rhs.begin(), rhs.end(), symbol) != rhs.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } return terminalAlphabet.erase(symbol); @@ -48,15 +48,15 @@ bool UnrestrictedGrammar::removeTerminalSymbol(const alphabet::Symbol& symbol) { bool UnrestrictedGrammar::removeNonterminalSymbol(const alphabet::Symbol& symbol) { for(const std::pair<std::vector<alphabet::Symbol>, std::set<std::vector<alphabet::Symbol>>>& rule : rules) { if(std::find(rule.first.begin(), rule.first.end(), symbol) != rule.first.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); for(const std::vector<alphabet::Symbol>& rhs : rule.second) if(std::find(rhs.begin(), rhs.end(), symbol) != rhs.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is used in rule."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is used in rule."); } if(initialSymbol == symbol) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is initial symbol."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is initial symbol."); return nonterminalAlphabet.erase(symbol); @@ -69,11 +69,11 @@ bool UnrestrictedGrammar::addRule(const std::vector<alphabet::Symbol>& leftHandS for(const alphabet::Symbol& symbol : leftHandSide) if(terminalAlphabet.find(symbol) == terminalAlphabet.end() && nonterminalAlphabet.find(symbol) == nonterminalAlphabet.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is not neither terminal nor nonterminal symbol"); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is not neither terminal nor nonterminal symbol"); for(const alphabet::Symbol& symbol : rightHandSide) if(terminalAlphabet.find(symbol) == terminalAlphabet.end() && nonterminalAlphabet.find(symbol) == nonterminalAlphabet.end()) - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is not neither terminal nor nonterminal symbol"); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is not neither terminal nor nonterminal symbol"); return rules[leftHandSide].insert(rightHandSide).second; } diff --git a/alib2data/src/grammar/common/TerminalNonterminalAlphabetInitialSymbol.cpp b/alib2data/src/grammar/common/TerminalNonterminalAlphabetInitialSymbol.cpp index 5bb1f15fda247543b401ff816b477a42cbac4dda..03295dc7d9f03b7b486ce4f3853b3736a2a032ca 100644 --- a/alib2data/src/grammar/common/TerminalNonterminalAlphabetInitialSymbol.cpp +++ b/alib2data/src/grammar/common/TerminalNonterminalAlphabetInitialSymbol.cpp @@ -22,7 +22,7 @@ TerminalNonterminalAlphabetInitialSymbol::TerminalNonterminalAlphabetInitialSymb bool TerminalNonterminalAlphabetInitialSymbol::addTerminalSymbol(const alphabet::Symbol& symbol) { if(nonterminalAlphabet.find(symbol) != nonterminalAlphabet.end()){ - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is nonterminal symbol."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is nonterminal symbol."); } return terminalAlphabet.insert(symbol).second; @@ -50,7 +50,7 @@ void TerminalNonterminalAlphabetInitialSymbol::setTerminalAlphabet(const std::se bool TerminalNonterminalAlphabetInitialSymbol::addNonterminalSymbol(const alphabet::Symbol& symbol) { if(terminalAlphabet.find(symbol) != terminalAlphabet.end()){ - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" is terminal symbol."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" is terminal symbol."); } return nonterminalAlphabet.insert(symbol).second; @@ -82,7 +82,7 @@ const alphabet::Symbol& TerminalNonterminalAlphabetInitialSymbol::getInitialSymb void TerminalNonterminalAlphabetInitialSymbol::setInitialSymbol(const alphabet::Symbol& symbol) { if(nonterminalAlphabet.find(symbol) == nonterminalAlphabet.end()) { - throw GrammarException("Symbol \"" + (std::string) symbol.getSymbol() + "\" isn't nonterminal symbol."); + throw GrammarException("Symbol \"" + (std::string) symbol + "\" isn't nonterminal symbol."); } initialSymbol = symbol;