diff --git a/alib2/src/FromXMLParser.hpp b/alib2/src/FromXMLParser.hpp index deb214c95c5224bdb0b2901fb19a1f2ac72d979e..f772cfcaadaff2a9ae4e06acd48c5094b0caf466 100644 --- a/alib2/src/FromXMLParser.hpp +++ b/alib2/src/FromXMLParser.hpp @@ -12,7 +12,7 @@ #include <list> #include <set> #include "sax/Token.h" -#include "AlibException.h" +#include "exception/AlibException.h" namespace alib { @@ -53,7 +53,7 @@ public: if(input.size() == 0) { return res; } else { - throw alib::AlibException(); + throw exception::AlibException(); } } diff --git a/alib2/src/FromXMLParsers.cpp b/alib2/src/FromXMLParsers.cpp index b1921a97c1526510be22610d8c87331ef7e401f0..7142f3c032a5ae1be45fc37da45eccab992c332c 100644 --- a/alib2/src/FromXMLParsers.cpp +++ b/alib2/src/FromXMLParsers.cpp @@ -14,6 +14,6 @@ const alphabet::SymbolFromXMLParser FromXMLParsers::symbolParser; const regexp::RegExpFromXMLParser FromXMLParsers::regexpParser; const string::StringFromXMLParser FromXMLParsers::stringParser; const automaton::AutomatonFromXMLParser FromXMLParsers::automatonParser; -const alib::ExceptionFromXMLParser FromXMLParsers::exceptionParser; +const exception::ExceptionFromXMLParser FromXMLParsers::exceptionParser; } /* namespace alib */ diff --git a/alib2/src/FromXMLParsers.h b/alib2/src/FromXMLParsers.h index 7d1e9f8c2bf2571ec71a0b0a5fe2a972bc36685c..da3da9e356060ba74700dbbe1c9d67daef0aaf19 100644 --- a/alib2/src/FromXMLParsers.h +++ b/alib2/src/FromXMLParsers.h @@ -13,7 +13,7 @@ #include "regexp/RegExpFromXMLParser.h" #include "string/StringFromXMLParser.h" #include "automaton/AutomatonFromXMLParser.h" -#include "ExceptionFromXMLParser.h" +#include "exception/ExceptionFromXMLParser.h" namespace alib { @@ -28,7 +28,7 @@ public: static const regexp::RegExpFromXMLParser regexpParser; static const string::StringFromXMLParser stringParser; static const automaton::AutomatonFromXMLParser automatonParser; - static const alib::ExceptionFromXMLParser exceptionParser; + static const exception::ExceptionFromXMLParser exceptionParser; }; diff --git a/alib2/src/ToXMLComposers.cpp b/alib2/src/ToXMLComposers.cpp index ff59114d7d2d388abd397f09f4cfc0bbe10855b6..fe6c9514997125f07f5f2a1cc8700da4ad7066f2 100644 --- a/alib2/src/ToXMLComposers.cpp +++ b/alib2/src/ToXMLComposers.cpp @@ -14,6 +14,6 @@ const alphabet::SymbolToXMLComposer ToXMLComposers::symbolComposer; const regexp::RegExpToXMLComposer ToXMLComposers::regexpComposer; const string::StringToXMLComposer ToXMLComposers::stringComposer; const automaton::AutomatonToXMLComposer ToXMLComposers::automatonComposer; -const alib::ExceptionToXMLComposer ToXMLComposers::exceptionComposer; +const exception::ExceptionToXMLComposer ToXMLComposers::exceptionComposer; } /* namespace alib */ diff --git a/alib2/src/ToXMLComposers.h b/alib2/src/ToXMLComposers.h index 4fdb81f08fd523f6a3c2ae0fceddfb1b268d92e7..60cab59e1743c4ae48a08f3c166306bb056a4c7a 100644 --- a/alib2/src/ToXMLComposers.h +++ b/alib2/src/ToXMLComposers.h @@ -13,7 +13,7 @@ #include "regexp/RegExpToXMLComposer.h" #include "string/StringToXMLComposer.h" #include "automaton/AutomatonToXMLComposer.h" -#include "ExceptionToXMLComposer.h" +#include "exception/ExceptionToXMLComposer.h" namespace alib { @@ -28,7 +28,7 @@ public: static const regexp::RegExpToXMLComposer regexpComposer; static const string::StringToXMLComposer stringComposer; static const automaton::AutomatonToXMLComposer automatonComposer; - static const alib::ExceptionToXMLComposer exceptionComposer; + static const exception::ExceptionToXMLComposer exceptionComposer; }; diff --git a/alib2/src/alphabet/SymbolFromStringParser.cpp b/alib2/src/alphabet/SymbolFromStringParser.cpp index f80584c19cdacfbd4598305b250e5b3c06a03f65..0ca379e8c633f49671deebc429f3550ec8148e13 100644 --- a/alib2/src/alphabet/SymbolFromStringParser.cpp +++ b/alib2/src/alphabet/SymbolFromStringParser.cpp @@ -1,5 +1,5 @@ #include "SymbolFromStringParser.h" -#include "../AlibException.h" +#include "../exception/AlibException.h" #include "BlankSymbol.h" #include "BottomOfTheStackSymbol.h" #include "EndSymbol.h" @@ -19,21 +19,21 @@ Symbol SymbolFromStringParser::parse(const std::set<FEATURES>& features) { SymbolFromStringLexer::Token token = m_SymbolLexer.token(); switch(token.type) { case SymbolFromStringLexer::TokenType::BLANK: - if(!features.count(FEATURES::BLANK)) throw alib::AlibException(); + if(!features.count(FEATURES::BLANK)) throw exception::AlibException(); return Symbol(BlankSymbol()); case SymbolFromStringLexer::TokenType::BOTTOM: - if(!features.count(FEATURES::BOTTOM)) throw alib::AlibException(); + if(!features.count(FEATURES::BOTTOM)) throw exception::AlibException(); return Symbol(BottomOfTheStackSymbol()); case SymbolFromStringLexer::TokenType::END: - if(!features.count(FEATURES::END)) throw alib::AlibException(); + if(!features.count(FEATURES::END)) throw exception::AlibException(); return Symbol(EndSymbol()); case SymbolFromStringLexer::TokenType::ERROR: - if(!features.count(FEATURES::LABELED)) throw alib::AlibException(); + if(!features.count(FEATURES::LABELED)) throw exception::AlibException(); return Symbol(LabeledSymbol(m_LabelParser.parse())); case SymbolFromStringLexer::TokenType::TEOF: - throw alib::AlibException(); + throw exception::AlibException(); } - throw alib::AlibException(); + throw exception::AlibException(); } Symbol SymbolFromStringParser::parseValue() { @@ -45,13 +45,22 @@ Symbol SymbolFromStringParser::parseValue() { if(token.type == SymbolFromStringLexer::TokenType::TEOF) { return std::move(res); } else { - throw alib::AlibException(); + throw exception::AlibException(); + } +} + +bool SymbolFromStringParser::next() { + SymbolFromStringLexer::Token token = m_SymbolLexer.next().token(); + if(token.type == SymbolFromStringLexer::TokenType::BLANK || token.type == SymbolFromStringLexer::TokenType::BOTTOM || token.type == SymbolFromStringLexer::TokenType::END) { + return true; + } else { + return false; } } bool SymbolFromStringParser::first() { SymbolFromStringLexer::Token token = m_SymbolLexer.next().token(); - if(token.type == SymbolFromStringLexer::TokenType::BLANK || token.type == SymbolFromStringLexer::TokenType::BOTTOM) { + if(token.type == SymbolFromStringLexer::TokenType::BLANK || token.type == SymbolFromStringLexer::TokenType::BOTTOM || token.type == SymbolFromStringLexer::TokenType::END) { return true; } else { return false; diff --git a/alib2/src/alphabet/SymbolFromStringParser.h b/alib2/src/alphabet/SymbolFromStringParser.h index f62d3b8fc5822aae3b4759c597a9f5d82a166474..aa510bb978cfbfc6679c1e73464d556323f2d7e1 100644 --- a/alib2/src/alphabet/SymbolFromStringParser.h +++ b/alib2/src/alphabet/SymbolFromStringParser.h @@ -42,6 +42,7 @@ class SymbolFromStringParser { label::LabelFromStringParser m_LabelParser; Symbol parse(); Symbol parse(const std::set<FEATURES>& features); + bool next(); public: bool first(); SymbolFromStringParser(std::stringstream&); diff --git a/alib2/src/alphabet/SymbolFromXMLParser.cpp b/alib2/src/alphabet/SymbolFromXMLParser.cpp index 6d41ec9e27f87206988360d51588f732b8dd5ae5..cb1e5b438c0b1bd9b4544c9101f1670c7550c4b7 100644 --- a/alib2/src/alphabet/SymbolFromXMLParser.cpp +++ b/alib2/src/alphabet/SymbolFromXMLParser.cpp @@ -24,16 +24,16 @@ Symbol SymbolFromXMLParser::parse(std::list<sax::Token>& input) const { Symbol SymbolFromXMLParser::parse(std::list<sax::Token>& input, const std::set<FEATURES>& features) const { if(isToken(input, sax::Token::TokenType::START_ELEMENT, "LabeledSymbol")) { - if(!features.count(FEATURES::LABELED)) throw alib::AlibException(); + if(!features.count(FEATURES::LABELED)) throw exception::AlibException(); return parseLabeledSymbol(input); } else if(isToken(input, sax::Token::TokenType::START_ELEMENT, "BlankSymbol")) { - if(!features.count(FEATURES::BLANK)) throw alib::AlibException(); + if(!features.count(FEATURES::BLANK)) throw exception::AlibException(); return parseBlankSymbol(input); } else if(isToken(input, sax::Token::TokenType::START_ELEMENT, "BottomOfTheStackSymbol")) { - if(!features.count(FEATURES::BOTTOM)) throw alib::AlibException(); + if(!features.count(FEATURES::BOTTOM)) throw exception::AlibException(); return parseBlankSymbol(input); } else if(isToken(input, sax::Token::TokenType::START_ELEMENT, "EndSymbol")) { - if(!features.count(FEATURES::END)) throw alib::AlibException(); + if(!features.count(FEATURES::END)) throw exception::AlibException(); return parseEndSymbol(input); } else { throw sax::ParserException(sax::Token("LabeledSymbol, BlankSymbol, BottomOfTheStackSymbol, EndSymbol", sax::Token::TokenType::START_ELEMENT), input.front()); diff --git a/alib2/src/automaton/AutomatonException.h b/alib2/src/automaton/AutomatonException.h index 864312c09cc229d3494f0df222ce6d16412d795b..99ad76507939843c952f3b662c77b8790be0c406 100644 --- a/alib2/src/automaton/AutomatonException.h +++ b/alib2/src/automaton/AutomatonException.h @@ -8,14 +8,14 @@ #ifndef AUTOMATON_EXCEPTION_H_ #define AUTOMATON_EXCEPTION_H_ -#include "../AlibException.h" +#include "../exception/AlibException.h" namespace automaton { /** * Exception thrown by an automaton, automaton parser or automaton printer. */ -class AutomatonException: public alib::AlibException { +class AutomatonException: public exception::AlibException { public: AutomatonException(); explicit AutomatonException(const std::string& cause); diff --git a/alib2/src/automaton/AutomatonFromXMLParser.cpp b/alib2/src/automaton/AutomatonFromXMLParser.cpp index a49d91db20d30e0a9fda9fb1d2a3f8b043bcc5e3..fb92ceafd2f73c06d2f5c0e57e43b232e688b8d4 100644 --- a/alib2/src/automaton/AutomatonFromXMLParser.cpp +++ b/alib2/src/automaton/AutomatonFromXMLParser.cpp @@ -23,16 +23,16 @@ Automaton AutomatonFromXMLParser::parse(std::list<sax::Token> &input) const { Automaton AutomatonFromXMLParser::parse(std::list<sax::Token>& input, const std::set<FEATURES>& features) const { if(isToken(input, sax::Token::TokenType::START_ELEMENT, "automaton")) { - if(!features.count(FEATURES::AUTOMATON)) throw alib::AlibException(); + if(!features.count(FEATURES::AUTOMATON)) throw exception::AlibException(); return Automaton(parseUnknownAutomaton(input)); } else if(isToken(input, sax::Token::TokenType::START_ELEMENT, "EpsilonNFA")) { - if(!features.count(FEATURES::EPSILON_NFA)) throw alib::AlibException(); + if(!features.count(FEATURES::EPSILON_NFA)) throw exception::AlibException(); return Automaton(parseEpsilonNFA(input)); } else if(isToken(input, sax::Token::TokenType::START_ELEMENT, "NFA")) { - if(!features.count(FEATURES::NFA)) throw alib::AlibException(); + if(!features.count(FEATURES::NFA)) throw exception::AlibException(); return Automaton(parseNFA(input)); } else if(isToken(input, sax::Token::TokenType::START_ELEMENT, "DFA")) { - if(!features.count(FEATURES::DFA)) throw alib::AlibException(); + if(!features.count(FEATURES::DFA)) throw exception::AlibException(); return Automaton(parseDFA(input)); } else throw sax::ParserException(sax::Token("Automaton / EpsilonNFA / NFA / DFA", sax::Token::TokenType::START_ELEMENT), input.front()); diff --git a/alib2/src/automaton/FSM/FiniteAutomatonFromStringParser.cpp b/alib2/src/automaton/FSM/FiniteAutomatonFromStringParser.cpp index e48d286921a7d71b6a32031349fc33582691dce9..11e270da0e926378195f5806c0519780eae55ed9 100644 --- a/alib2/src/automaton/FSM/FiniteAutomatonFromStringParser.cpp +++ b/alib2/src/automaton/FSM/FiniteAutomatonFromStringParser.cpp @@ -1,6 +1,6 @@ #include "FiniteAutomatonFromStringParser.h" -#include "../../AlibException.h" +#include "../../exception/AlibException.h" #include "EpsilonNFA.h" #include "NFA.h" @@ -22,16 +22,16 @@ Automaton FiniteAutomatonFromStringParser::parse() { Automaton FiniteAutomatonFromStringParser::parse(const std::set<FEATURES>& features) { FiniteAutomatonFromStringLexer::Token token = m_FiniteAutomatonLexer.token(); if(token.type == FiniteAutomatonFromStringLexer::TokenType::EPSILON_NFA) { - if(!features.count(FEATURES::EPSILON_NFA)) throw alib::AlibException(); + if(!features.count(FEATURES::EPSILON_NFA)) throw exception::AlibException(); return Automaton(parseEpsilonNFA()); } else if(token.type == FiniteAutomatonFromStringLexer::TokenType::NFA) { - if(!features.count(FEATURES::NFA)) throw alib::AlibException(); + if(!features.count(FEATURES::NFA)) throw exception::AlibException(); return Automaton(parseNFA()); } else if(token.type == FiniteAutomatonFromStringLexer::TokenType::DFA) { - if(!features.count(FEATURES::DFA)) throw alib::AlibException(); + if(!features.count(FEATURES::DFA)) throw exception::AlibException(); return Automaton(parseDFA()); } else { - throw alib::AlibException(); + throw exception::AlibException(); } } @@ -43,7 +43,7 @@ Automaton FiniteAutomatonFromStringParser::parseValue() { if(token.type == FiniteAutomatonFromStringLexer::TokenType::TEOF) { return std::move(res); } else { - throw alib::AlibException(); + throw exception::AlibException(); } } @@ -78,7 +78,7 @@ EpsilonNFA FiniteAutomatonFromStringParser::parseEpsilonNFA() { FiniteAutomatonFromStringLexer::Token token = m_FiniteAutomatonLexer.token(); if(token.type != FiniteAutomatonFromStringLexer::TokenType::EPSILON_NFA) { - throw alib::AlibException(); + throw exception::AlibException(); } std::vector<std::variant<string::Epsilon, alphabet::Symbol> > symbols; @@ -101,7 +101,7 @@ EpsilonNFA FiniteAutomatonFromStringParser::parseEpsilonNFA() { } token = m_FiniteAutomatonLexer.token(); - if(token.type != FiniteAutomatonFromStringLexer::TokenType::NEW_LINE) throw alib::AlibException(); + if(token.type != FiniteAutomatonFromStringLexer::TokenType::NEW_LINE) throw exception::AlibException(); next() || m_LabelParser.first(); parseEpsilonNFATransition(res, symbols); @@ -124,7 +124,7 @@ NFA FiniteAutomatonFromStringParser::parseNFA() { FiniteAutomatonFromStringLexer::Token token = m_FiniteAutomatonLexer.token(); if(token.type != FiniteAutomatonFromStringLexer::TokenType::NFA) { - throw alib::AlibException(); + throw exception::AlibException(); } std::vector<alphabet::Symbol> symbols; @@ -140,7 +140,7 @@ NFA FiniteAutomatonFromStringParser::parseNFA() { } token = m_FiniteAutomatonLexer.token(); - if(token.type != FiniteAutomatonFromStringLexer::TokenType::NEW_LINE) throw alib::AlibException(); + if(token.type != FiniteAutomatonFromStringLexer::TokenType::NEW_LINE) throw exception::AlibException(); next() || m_LabelParser.first(); parseNFATransition(res, symbols); @@ -162,7 +162,7 @@ DFA FiniteAutomatonFromStringParser::parseDFA() { FiniteAutomatonFromStringLexer::Token token = m_FiniteAutomatonLexer.token(); if(token.type != FiniteAutomatonFromStringLexer::TokenType::DFA) { - throw alib::AlibException(); + throw exception::AlibException(); } std::vector<alphabet::Symbol> symbols; @@ -177,7 +177,7 @@ DFA FiniteAutomatonFromStringParser::parseDFA() { } token = m_FiniteAutomatonLexer.token(); - if(token.type != FiniteAutomatonFromStringLexer::TokenType::NEW_LINE) throw alib::AlibException(); + if(token.type != FiniteAutomatonFromStringLexer::TokenType::NEW_LINE) throw exception::AlibException(); State* initialState = NULL; std::set<State> finalStates; @@ -197,7 +197,7 @@ DFA FiniteAutomatonFromStringParser::parseDFA() { token = m_FiniteAutomatonLexer.token(); } - if(initialState == NULL) throw alib::AlibException(); + if(initialState == NULL) throw exception::AlibException(); DFA res(*initialState); delete initialState; @@ -255,7 +255,7 @@ void FiniteAutomatonFromStringParser::parseEpsilonNFATransition(EpsilonNFA& res, FiniteAutomatonFromStringLexer::Token token; std::vector<std::variant<string::Epsilon, alphabet::Symbol>>::const_iterator iter = symbols.begin(); do { - if(iter == symbols.end()) throw alib::AlibException(); + if(iter == symbols.end()) throw exception::AlibException(); token = m_FiniteAutomatonLexer.token(); if(token.type != FiniteAutomatonFromStringLexer::TokenType::NONE) { @@ -277,7 +277,7 @@ void FiniteAutomatonFromStringParser::parseEpsilonNFATransition(EpsilonNFA& res, } iter++; } while(token.type != FiniteAutomatonFromStringLexer::TokenType::NEW_LINE); - if(iter != symbols.end()) throw alib::AlibException(); + if(iter != symbols.end()) throw exception::AlibException(); } void FiniteAutomatonFromStringParser::parseNFATransition(NFA& res, const std::vector<alphabet::Symbol>& symbols) { @@ -296,7 +296,7 @@ void FiniteAutomatonFromStringParser::parseNFATransition(NFA& res, const std::ve FiniteAutomatonFromStringLexer::Token token; std::vector<alphabet::Symbol>::const_iterator iter = symbols.begin(); do { - if(iter == symbols.end()) throw alib::AlibException(); + if(iter == symbols.end()) throw exception::AlibException(); token = m_FiniteAutomatonLexer.token(); if(token.type != FiniteAutomatonFromStringLexer::TokenType::NONE) { @@ -318,7 +318,7 @@ void FiniteAutomatonFromStringParser::parseNFATransition(NFA& res, const std::ve } iter++; } while(token.type != FiniteAutomatonFromStringLexer::TokenType::NEW_LINE); - if(iter != symbols.end()) throw alib::AlibException(); + if(iter != symbols.end()) throw exception::AlibException(); } void FiniteAutomatonFromStringParser::parseDFATransition(std::set<State>& states, const std::vector<alphabet::Symbol>& symbols, State*& initialState, std::set<State>& finalStates, std::set<std::tuple<State, alphabet::Symbol, State>>& transitionFunction) { @@ -330,7 +330,7 @@ void FiniteAutomatonFromStringParser::parseDFATransition(std::set<State>& states State from(m_LabelParser.parse()); states.insert(from); if(initial) { - if(initialState != NULL) throw alib::AlibException(); + if(initialState != NULL) throw exception::AlibException(); initialState = new State(from); } if(final) finalStates.insert(from); @@ -340,7 +340,7 @@ void FiniteAutomatonFromStringParser::parseDFATransition(std::set<State>& states FiniteAutomatonFromStringLexer::Token token; std::vector<alphabet::Symbol>::const_iterator iter = symbols.begin(); do { - if(iter == symbols.end()) throw alib::AlibException(); + if(iter == symbols.end()) throw exception::AlibException(); token = m_FiniteAutomatonLexer.token(); if(token.type != FiniteAutomatonFromStringLexer::TokenType::NONE) { @@ -362,7 +362,7 @@ void FiniteAutomatonFromStringParser::parseDFATransition(std::set<State>& states } iter++; } while(token.type != FiniteAutomatonFromStringLexer::TokenType::NEW_LINE); - if(iter != symbols.end()) throw alib::AlibException(); + if(iter != symbols.end()) throw exception::AlibException(); } } /* namespace automaton */ diff --git a/alib2/src/automaton/FSM/FiniteAutomatonToStringComposer.cpp b/alib2/src/automaton/FSM/FiniteAutomatonToStringComposer.cpp index c5349181a83d4e6047489dd707b09d0098c62d70..f5128e778c8314b5e85ab6d307ea04cd7b72d393 100644 --- a/alib2/src/automaton/FSM/FiniteAutomatonToStringComposer.cpp +++ b/alib2/src/automaton/FSM/FiniteAutomatonToStringComposer.cpp @@ -1,5 +1,5 @@ #include "FiniteAutomatonToStringComposer.h" -#include "../../AlibException.h" +#include "../../exception/AlibException.h" #include "../../alphabet/SymbolToStringComposer.h" #include "../../label/LabelToStringComposer.h" @@ -167,7 +167,7 @@ void FiniteAutomatonToStringComposer::Visit(void* data, const Automaton& automat } void FiniteAutomatonToStringComposer::Visit(void*, const UnknownAutomaton&) const { - throw alib::AlibException(); + throw exception::AlibException(); } void FiniteAutomatonToStringComposer::Visit(void* data, const EpsilonNFA& automaton) const { @@ -183,19 +183,19 @@ void FiniteAutomatonToStringComposer::Visit(void* data, const DFA& automaton) co } void FiniteAutomatonToStringComposer::Visit(void*, const ExtendedNFA&) const { - throw alib::AlibException(); + throw exception::AlibException(); } void FiniteAutomatonToStringComposer::Visit(void*, const CompactNFA&) const { - throw alib::AlibException(); + throw exception::AlibException(); } void FiniteAutomatonToStringComposer::Visit(void*, const PDA&) const { - throw alib::AlibException(); + throw exception::AlibException(); } void FiniteAutomatonToStringComposer::Visit(void*, const OneTapeDTM&) const { - throw alib::AlibException(); + throw exception::AlibException(); } } /* namespace automaton */ diff --git a/alib2/src/AlibException.cpp b/alib2/src/exception/AlibException.cpp similarity index 90% rename from alib2/src/AlibException.cpp rename to alib2/src/exception/AlibException.cpp index 2f7103eb10fbad216d3717445b0a5bb3a8848ef4..0bdd0d38627d3ca2efd08281555c9333a90d0846 100644 --- a/alib2/src/AlibException.cpp +++ b/alib2/src/exception/AlibException.cpp @@ -13,9 +13,9 @@ #include <sstream> #include <execinfo.h> -#include "std/stacktrace.h" +#include "../std/stacktrace.h" -namespace alib { +namespace exception { AlibException::AlibException ( ) { this->backtrace = std::stacktrace(); @@ -45,4 +45,4 @@ const std::string & AlibException::getBacktrace ( ) const { return backtrace; } -} /* namespace alib */ +} /* namespace exception */ diff --git a/alib2/src/AlibException.h b/alib2/src/exception/AlibException.h similarity index 94% rename from alib2/src/AlibException.h rename to alib2/src/exception/AlibException.h index fe9cb78d6db1dbadd55df6865d3a7cefee4d7540..919f889c92730e23df7e4c5cba945fddb2961216 100644 --- a/alib2/src/AlibException.h +++ b/alib2/src/exception/AlibException.h @@ -11,7 +11,7 @@ #include <exception> #include <string> -namespace alib { +namespace exception { /** * Basic exception from which are derived all other exceptions. @@ -46,6 +46,6 @@ public: }; -} /* namespace alib */ +} /* namespace exception */ #endif /* ALIB_EXCEPTION_H_ */ diff --git a/alib2/src/ExceptionFeatures.h b/alib2/src/exception/ExceptionFeatures.h similarity index 82% rename from alib2/src/ExceptionFeatures.h rename to alib2/src/exception/ExceptionFeatures.h index d1757e13f6fd4e4e9266273774547b5b063db915..89067aa026adfd4ad66bd8562081a634129078e0 100644 --- a/alib2/src/ExceptionFeatures.h +++ b/alib2/src/exception/ExceptionFeatures.h @@ -8,12 +8,12 @@ #ifndef EXCEPTION_FEATURES_H_ #define EXCEPTION_FEATURES_H_ -namespace alib { +namespace exception { enum class FEATURES { ALIB_EXCEPTION }; -} /* namespace alib */ +} /* namespace exception */ #endif /* EXCEPTION_FEATURES_H_ */ diff --git a/alib2/src/ExceptionFromXMLParser.cpp b/alib2/src/exception/ExceptionFromXMLParser.cpp similarity index 84% rename from alib2/src/ExceptionFromXMLParser.cpp rename to alib2/src/exception/ExceptionFromXMLParser.cpp index 3b72fff798c1edef11fbc94c6dd63f79f888cf0e..0a4c7b60d7603edcc06bb65e4c40d346a41811a3 100644 --- a/alib2/src/ExceptionFromXMLParser.cpp +++ b/alib2/src/exception/ExceptionFromXMLParser.cpp @@ -6,17 +6,17 @@ */ #include "ExceptionFromXMLParser.h" -#include "sax/ParserException.h" +#include "../sax/ParserException.h" #include <string> -namespace alib { +namespace exception { AlibException ExceptionFromXMLParser::parse(std::list<sax::Token>& input) const { return parse(input, std::set<FEATURES>({FEATURES::ALIB_EXCEPTION})); } AlibException ExceptionFromXMLParser::parse(std::list<sax::Token>& input, const std::set<FEATURES>& features) const { - if(!features.count(FEATURES::ALIB_EXCEPTION)) throw alib::AlibException(); + if(!features.count(FEATURES::ALIB_EXCEPTION)) throw exception::AlibException(); popToken(input, sax::Token::TokenType::START_ELEMENT, "exception"); std::string cause = ""; if (input.front().getType() == sax::Token::TokenType::CHARACTER) { @@ -35,4 +35,4 @@ bool ExceptionFromXMLParser::first(std::list<sax::Token>& input) const { } } -} /* namespace alib */ +} /* namespace exception */ diff --git a/alib2/src/ExceptionFromXMLParser.h b/alib2/src/exception/ExceptionFromXMLParser.h similarity index 78% rename from alib2/src/ExceptionFromXMLParser.h rename to alib2/src/exception/ExceptionFromXMLParser.h index 28646aa42ca559ccceed2b79c284e8a370e73200..1ab2f1d7d4eba911c5702ce207c91fe69db874e7 100644 --- a/alib2/src/ExceptionFromXMLParser.h +++ b/alib2/src/exception/ExceptionFromXMLParser.h @@ -9,22 +9,22 @@ #define EXCEPTION_FROM_XML_PARSER_H_ #include <list> -#include "FromXMLParser.hpp" +#include "../FromXMLParser.hpp" #include "ExceptionFeatures.h" #include "AlibException.h" -namespace alib { +namespace exception { /** * Parser used to get String from XML parsed into list of tokens. */ -class ExceptionFromXMLParser : public FromXMLParser<AlibException, FEATURES> { +class ExceptionFromXMLParser : public alib::FromXMLParser<AlibException, FEATURES> { virtual AlibException parse(std::list<sax::Token>& input) const; virtual AlibException parse(std::list<sax::Token>& input, const std::set<FEATURES>& features) const; public: virtual bool first(std::list<sax::Token>& input) const; }; -} /* namespace alib */ +} /* namespace exception */ #endif /* EXCEPTION_FROM_XML_PARSER_H_ */ diff --git a/alib2/src/ExceptionToXMLComposer.cpp b/alib2/src/exception/ExceptionToXMLComposer.cpp similarity index 93% rename from alib2/src/ExceptionToXMLComposer.cpp rename to alib2/src/exception/ExceptionToXMLComposer.cpp index 368765d318c8a2da13e4c38e1c7c5c69eb4687b2..70dd4071ddd72fc926b032dec4378c233ef3d71f 100644 --- a/alib2/src/ExceptionToXMLComposer.cpp +++ b/alib2/src/exception/ExceptionToXMLComposer.cpp @@ -7,7 +7,7 @@ #include "ExceptionToXMLComposer.h" -namespace alib { +namespace exception { void ExceptionToXMLComposer::Visit(void* userData, const AlibException& exception) const { std::list<sax::Token> &out = *((std::list<sax::Token>*) userData); @@ -23,4 +23,4 @@ std::list<sax::Token> ExceptionToXMLComposer::compose(const AlibException& excep return out; } -} /* namespace alib */ +} /* namespace exception */ diff --git a/alib2/src/ExceptionToXMLComposer.h b/alib2/src/exception/ExceptionToXMLComposer.h similarity index 90% rename from alib2/src/ExceptionToXMLComposer.h rename to alib2/src/exception/ExceptionToXMLComposer.h index 430a63b9b75c1dc06047c32383e76ba7e6260fcf..906ad68f6bf687d9ceafef49236a0d6eccf71ee4 100644 --- a/alib2/src/ExceptionToXMLComposer.h +++ b/alib2/src/exception/ExceptionToXMLComposer.h @@ -10,9 +10,9 @@ #include <list> #include "AlibException.h" -#include "sax/Token.h" +#include "../sax/Token.h" -namespace alib { +namespace exception { /** * This class contains methods to print XML representation of string to the output stream. @@ -28,6 +28,6 @@ public: std::list<sax::Token> compose(const AlibException& exception) const; }; -} /* namespace alib */ +} /* namespace exception */ #endif /* EXCEPTION_TO_XML_COMPOSER_H_ */ diff --git a/alib2/src/label/LabelFromStringParser.cpp b/alib2/src/label/LabelFromStringParser.cpp index 048552197c5068729b34fc11eeffbd1ef5323500..0e154405c259f8b8991f4ab9e07cd693e15adbd6 100644 --- a/alib2/src/label/LabelFromStringParser.cpp +++ b/alib2/src/label/LabelFromStringParser.cpp @@ -1,5 +1,5 @@ #include "LabelFromStringParser.h" -#include "../AlibException.h" +#include "../exception/AlibException.h" #include "StringLabel.h" #include "IntegerLabel.h" #include "CharacterLabel.h" @@ -19,20 +19,20 @@ Label LabelFromStringParser::parse(const std::set<FEATURES>& features) { LabelFromStringLexer::Token token = m_Lexer.token(); switch(token.type) { case LabelFromStringLexer::TokenType::TEOF: - throw alib::AlibException(); + throw exception::AlibException(); case LabelFromStringLexer::TokenType::STRING: - if(!features.count(FEATURES::STRING)) throw alib::AlibException(); + if(!features.count(FEATURES::STRING)) throw exception::AlibException(); return Label(label::StringLabel(token.value)); case LabelFromStringLexer::TokenType::CHAR: - if(!features.count(FEATURES::CHAR)) throw alib::AlibException(); + if(!features.count(FEATURES::CHAR)) throw exception::AlibException(); return Label(label::CharacterLabel(token.value[0])); case LabelFromStringLexer::TokenType::INTEGER: - if(!features.count(FEATURES::INTEGER)) throw alib::AlibException(); + if(!features.count(FEATURES::INTEGER)) throw exception::AlibException(); return Label(label::IntegerLabel(std::stoi(token.value))); case LabelFromStringLexer::TokenType::ERROR: break; } - throw alib::AlibException(); + throw exception::AlibException(); } Label LabelFromStringParser::parseValue() { @@ -43,7 +43,16 @@ Label LabelFromStringParser::parseValue() { if(token.type == LabelFromStringLexer::TokenType::TEOF) { return std::move(res); } else { - throw alib::AlibException(); + throw exception::AlibException(); + } +} + +bool LabelFromStringParser::next() { + LabelFromStringLexer::Token token = m_Lexer.next().token(); + if(token.type == LabelFromStringLexer::TokenType::STRING || token.type == LabelFromStringLexer::TokenType::CHAR || token.type == LabelFromStringLexer::TokenType::INTEGER) { + return true; + } else { + return false; } } diff --git a/alib2/src/label/LabelFromStringParser.h b/alib2/src/label/LabelFromStringParser.h index 8ba1cf79c11e615b3c1b32a477222eafdb1bc28f..3119e89ae9d64b64c9fc29203c2045779d1cd353 100644 --- a/alib2/src/label/LabelFromStringParser.h +++ b/alib2/src/label/LabelFromStringParser.h @@ -46,6 +46,7 @@ class LabelFromStringParser { Label parse(const std::set<FEATURES>&); Label parse(); + bool next(); public: bool first(); LabelFromStringParser(std::stringstream&); diff --git a/alib2/src/label/LabelFromXMLParser.cpp b/alib2/src/label/LabelFromXMLParser.cpp index c3c6a8a295636fe820bfbf9a62db2063f984c8b5..8728880c4f1ccc375c5b7bcd006f51291b837b37 100644 --- a/alib2/src/label/LabelFromXMLParser.cpp +++ b/alib2/src/label/LabelFromXMLParser.cpp @@ -20,19 +20,19 @@ Label LabelFromXMLParser::parse(std::list<sax::Token>& input) const { Label LabelFromXMLParser::parse(std::list<sax::Token>& input, const std::set<FEATURES>& features) const { if(isToken(input, sax::Token::TokenType::START_ELEMENT, "IntegerLabel")) { - if(!features.count(FEATURES::INTEGER)) throw alib::AlibException(); + if(!features.count(FEATURES::INTEGER)) throw exception::AlibException(); popToken(input, sax::Token::TokenType::START_ELEMENT, "IntegerLabel"); Label data(IntegerLabel(std::stoi(popTokenData(input, sax::Token::TokenType::CHARACTER)))); popToken(input, sax::Token::TokenType::END_ELEMENT, "IntegerLabel"); return data; } else if(isToken(input, sax::Token::TokenType::START_ELEMENT, "StringLabel")) { - if(!features.count(FEATURES::STRING)) throw alib::AlibException(); + if(!features.count(FEATURES::STRING)) throw exception::AlibException(); popToken(input, sax::Token::TokenType::START_ELEMENT, "StringLabel"); Label data(StringLabel(popTokenData(input, sax::Token::TokenType::CHARACTER))); popToken(input, sax::Token::TokenType::END_ELEMENT, "StringLabel"); return data; } else if(isToken(input, sax::Token::TokenType::START_ELEMENT, "CharacterLabel")) { - if(!features.count(FEATURES::CHAR)) throw alib::AlibException(); + if(!features.count(FEATURES::CHAR)) throw exception::AlibException(); popToken(input, sax::Token::TokenType::START_ELEMENT, "CharacterLabel"); Label data(CharacterLabel(popTokenData(input, sax::Token::TokenType::CHARACTER)[0])); popToken(input, sax::Token::TokenType::END_ELEMENT, "CharacterLabel"); diff --git a/alib2/src/regexp/Alternation.cpp b/alib2/src/regexp/Alternation.cpp index 1cf04c9af44a77644353101451b4be211659fab4..a31b08964d46728bb6f1b4c9e0bdb4945cd0be4a 100644 --- a/alib2/src/regexp/Alternation.cpp +++ b/alib2/src/regexp/Alternation.cpp @@ -6,7 +6,7 @@ */ #include "Alternation.h" -#include "../AlibException.h" +#include "../exception/AlibException.h" namespace regexp { @@ -68,14 +68,14 @@ const std::vector<RegExpElement*> & Alternation::getElements() { void Alternation::appendElement(const RegExpElement& element) { RegExpElement* elem = element.clone(); if(this->parentRegExp && !elem->attachRegExp(this->parentRegExp)) - throw alib::AlibException("Input symbols not in the alphabet."); + throw exception::AlibException("Input symbols not in the alphabet."); this->elements.push_back(elem); } void Alternation::appendElement(RegExpElement&& element) { RegExpElement* elem = std::move(element).plunder(); if(this->parentRegExp && !elem->attachRegExp(this->parentRegExp)) - throw alib::AlibException("Input symbols not in the alphabet."); + throw exception::AlibException("Input symbols not in the alphabet."); this->elements.push_back(elem); } diff --git a/alib2/src/regexp/Concatenation.cpp b/alib2/src/regexp/Concatenation.cpp index 8b3aee33c225dc815e9bbcdd3273326712facecb..c4a40827a27929906c475cf4bc09beeed84e12a1 100644 --- a/alib2/src/regexp/Concatenation.cpp +++ b/alib2/src/regexp/Concatenation.cpp @@ -6,7 +6,7 @@ */ #include "Concatenation.h" -#include "../AlibException.h" +#include "../exception/AlibException.h" namespace regexp { @@ -68,14 +68,14 @@ const std::vector<RegExpElement*> & Concatenation::getElements() { void Concatenation::appendElement(const RegExpElement& element) { RegExpElement* elem = element.clone(); if(this->parentRegExp && !elem->attachRegExp(this->parentRegExp)) - throw alib::AlibException("Input symbols not in the alphabet."); + throw exception::AlibException("Input symbols not in the alphabet."); this->elements.push_back(elem); } void Concatenation::appendElement(RegExpElement&& element) { RegExpElement* elem = std::move(element).plunder(); if(this->parentRegExp && !elem->attachRegExp(this->parentRegExp)) - throw alib::AlibException("Input symbols not in the alphabet."); + throw exception::AlibException("Input symbols not in the alphabet."); this->elements.push_back(elem); } diff --git a/alib2/src/regexp/Iteration.cpp b/alib2/src/regexp/Iteration.cpp index 27a470014ed96d6e060c21054cf7a48543b40a15..8f806518173a86ad2c60d5214094bdfcc1cde9f9 100644 --- a/alib2/src/regexp/Iteration.cpp +++ b/alib2/src/regexp/Iteration.cpp @@ -6,7 +6,7 @@ */ #include "Iteration.h" -#include "../AlibException.h" +#include "../exception/AlibException.h" namespace regexp { @@ -62,7 +62,7 @@ RegExpElement & Iteration::getElement() { void Iteration::setElement(const RegExpElement& element) { RegExpElement* elem = element.clone(); if(this->parentRegExp && !this->element->attachRegExp(this->parentRegExp)) - throw alib::AlibException("Input symbols not in the alphabet."); + throw exception::AlibException("Input symbols not in the alphabet."); delete this->element; this->element = elem; } @@ -70,7 +70,7 @@ void Iteration::setElement(const RegExpElement& element) { void Iteration::setElement(RegExpElement&& element) { RegExpElement* elem = std::move(element).plunder(); if(this->parentRegExp && !this->element->attachRegExp(this->parentRegExp)) - throw alib::AlibException("Input symbols not in the alphabet."); + throw exception::AlibException("Input symbols not in the alphabet."); delete this->element; this->element = elem; } diff --git a/alib2/src/regexp/RegExp.cpp b/alib2/src/regexp/RegExp.cpp index 03a7d26fb5d073fbeeba30309848b85b6210141d..2eb5b909b2a707342df86e4d52e915a0947b6aab 100644 --- a/alib2/src/regexp/RegExp.cpp +++ b/alib2/src/regexp/RegExp.cpp @@ -6,7 +6,7 @@ */ #include "RegExp.h" -#include "../AlibException.h" +#include "../exception/AlibException.h" #include "RegExpEmpty.h" #include "RegExpSymbol.h" @@ -84,14 +84,14 @@ void RegExp::setRegExp(const RegExpElement& regExp) { delete this->regExp; this->regExp = regExp.clone(); if(!this->regExp->attachRegExp(this)) - throw alib::AlibException("Input symbols not in the alphabet."); + throw exception::AlibException("Input symbols not in the alphabet."); } void RegExp::setRegExp(RegExpElement&& regExp) { delete this->regExp; this->regExp = std::move(regExp).plunder(); if(!this->regExp->attachRegExp(this)) - throw alib::AlibException("Input symbols not in the alphabet."); + throw exception::AlibException("Input symbols not in the alphabet."); } const std::set<alphabet::Symbol>& RegExp::getAlphabet() const { @@ -109,14 +109,14 @@ void RegExp::setAlphabet(const std::set<alphabet::Symbol> & symbols) { std::set_difference(minimalAlphabet.begin(), minimalAlphabet.end(), symbols.begin(), symbols.end(), std::inserter(removedSymbols, removedSymbols.end())); if(removedSymbols.size() > 0) - throw alib::AlibException("Input symbols are used."); + throw exception::AlibException("Input symbols are used."); this->alphabet = symbols; } bool RegExp::removeSymbolFromAlphabet(const alphabet::Symbol & symbol) { if(this->regExp->testSymbol(symbol)) - throw alib::AlibException("Input symbol \"" + (std::string) symbol + "\" is used."); + throw exception::AlibException("Input symbol \"" + (std::string) symbol + "\" is used."); return alphabet.erase(symbol); } diff --git a/alib2/src/regexp/RegExpFromStringParser.cpp b/alib2/src/regexp/RegExpFromStringParser.cpp index 73699c84ce74819ff370e7505bb2a293cdbb3084..1b5a487827af70fff0fe92157d47097221afcd6d 100644 --- a/alib2/src/regexp/RegExpFromStringParser.cpp +++ b/alib2/src/regexp/RegExpFromStringParser.cpp @@ -1,5 +1,5 @@ #include "RegExpFromStringParser.h" -#include "../AlibException.h" +#include "../exception/AlibException.h" #include "../label/StringLabel.h" namespace regexp { @@ -13,7 +13,7 @@ RegExp RegExpFromStringParser::parse() { } RegExp RegExpFromStringParser::parse(const std::set<FEATURES>& features) { - if(!features.count(FEATURES::COMPACT)) throw alib::AlibException(); + if(!features.count(FEATURES::COMPACT)) throw exception::AlibException(); RegExpElement* element = this->alternation(); RegExp regexp(std::move(*element)); delete element; @@ -28,7 +28,7 @@ RegExp RegExpFromStringParser::parseValue() { if(token.type == RegExpFromStringLexer::TokenType::TEOF) { return std::move(res); } else { - throw alib::AlibException(); + throw exception::AlibException(); } } @@ -156,7 +156,7 @@ RegExpElement* RegExpFromStringParser::factor() { RegExpElement* base = this->alternation(); token = m_RegexpLexer.token(); - if(token.type != RegExpFromStringLexer::TokenType::RPAR) throw alib::AlibException(); + if(token.type != RegExpFromStringLexer::TokenType::RPAR) throw exception::AlibException(); return this->star(base); } else if(token.type == RegExpFromStringLexer::TokenType::EPS) { return this->star(new RegExpEpsilon()); @@ -166,7 +166,7 @@ RegExpElement* RegExpFromStringParser::factor() { RegExpSymbol* res = new RegExpSymbol(m_SymbolParser.parse()); return this->star(res); } else { - throw alib::AlibException(); + throw exception::AlibException(); } } diff --git a/alib2/src/regexp/RegExpFromXMLParser.cpp b/alib2/src/regexp/RegExpFromXMLParser.cpp index bee69acdc4d89daaf598aacc42ee4e09f7b1c782..1fdc6ad2239023784fc97a054f0cd1542a6fc143 100644 --- a/alib2/src/regexp/RegExpFromXMLParser.cpp +++ b/alib2/src/regexp/RegExpFromXMLParser.cpp @@ -18,7 +18,7 @@ RegExp RegExpFromXMLParser::parse(std::list<sax::Token>& input) const { } RegExp RegExpFromXMLParser::parse(std::list<sax::Token>& input, const std::set<FEATURES>& features) const { - if(!features.count(FEATURES::COMPACT)) throw alib::AlibException(); + if(!features.count(FEATURES::COMPACT)) throw exception::AlibException(); popToken(input, sax::Token::TokenType::START_ELEMENT, "regexp"); RegExp regexp; diff --git a/alib2/src/sax/ComposerException.h b/alib2/src/sax/ComposerException.h index fe662196e2f09dd846c0e784e3692d0dbe736667..e1ba2c417c88410009f3f355ce396575d06c6ef3 100644 --- a/alib2/src/sax/ComposerException.h +++ b/alib2/src/sax/ComposerException.h @@ -8,7 +8,7 @@ #ifndef COMPOSER_EXCEPTION_H_ #define COMPOSER_EXCEPTION_H_ -#include "../AlibException.h" +#include "../exception/AlibException.h" #include "Token.h" namespace sax { @@ -16,7 +16,7 @@ namespace sax { /** * Exception thrown by XML parser when is expected different tag than the one which is read. */ -class ComposerException: public alib::AlibException { +class ComposerException: public exception::AlibException { protected: Token expected; Token read; diff --git a/alib2/src/sax/ParserException.h b/alib2/src/sax/ParserException.h index af17aa0d8fcf9f38fc8d91b9f91a3433a8218a05..910d5e94dd46b95660274f2e2ab08cebad41dc33 100644 --- a/alib2/src/sax/ParserException.h +++ b/alib2/src/sax/ParserException.h @@ -8,7 +8,7 @@ #ifndef PARSER_EXCEPTION_H_ #define PARSER_EXCEPTION_H_ -#include "../AlibException.h" +#include "../exception/AlibException.h" #include "Token.h" namespace sax { @@ -16,7 +16,7 @@ namespace sax { /** * Exception thrown by XML parser when is expected different tag than the one which is read. */ -class ParserException: public alib::AlibException { +class ParserException: public exception::AlibException { protected: Token expected; Token read; diff --git a/alib2/src/sax/SaxParseInterface.cpp b/alib2/src/sax/SaxParseInterface.cpp index 91b2a22f478bbc2b9a841505383e8a635c0f3570..7abcaa3cb61b34f39c8d3abe55d18eff4cb7d565 100644 --- a/alib2/src/sax/SaxParseInterface.cpp +++ b/alib2/src/sax/SaxParseInterface.cpp @@ -12,7 +12,7 @@ #include <cstdlib> #include <iostream> #include <algorithm> -#include "../AlibException.h" +#include "../exception/AlibException.h" namespace sax { @@ -33,7 +33,7 @@ void SaxParseInterface::parseMemory(const std::string& xmlIn, std::list<Token>& xmlCleanupParser(); if (result != 0) { - throw alib::AlibException("Cannot parse the XML string."); + throw exception::AlibException("Cannot parse the XML string."); } } @@ -45,7 +45,7 @@ void SaxParseInterface::parseFile(const std::string& filename, std::list<Token>& xmlCleanupParser(); if (result != 0) { - throw alib::AlibException("Cannot parse the XML file " + filename); + throw exception::AlibException("Cannot parse the XML file " + filename); } } diff --git a/alib2/src/string/String.cpp b/alib2/src/string/String.cpp index 82a51d3dd5333e5b379a900b02b4fc4cd301687c..acbff3d6b79f51323f618381c347f7db5f3b2cff 100644 --- a/alib2/src/string/String.cpp +++ b/alib2/src/string/String.cpp @@ -6,7 +6,7 @@ */ #include "String.h" -#include "../AlibException.h" +#include "../exception/AlibException.h" #include <algorithm> #include "Epsilon.h" @@ -74,7 +74,7 @@ void String::setString(const StringBase& string) { this->string = string.clone(); if(!this->string->attachString(this)) - throw alib::AlibException("String symbols not in the alphabet"); + throw exception::AlibException("String symbols not in the alphabet"); } void String::setString(StringBase&& string) { @@ -82,7 +82,7 @@ void String::setString(StringBase&& string) { this->string = std::move(string).plunder(); if(!this->string->attachString(this)) - throw alib::AlibException("String symbols not in the alphabet"); + throw exception::AlibException("String symbols not in the alphabet"); } const std::set<alphabet::Symbol>& String::getAlphabet() const { @@ -100,14 +100,14 @@ void String::setAlphabet(const std::set<alphabet::Symbol> & symbols) { std::set_difference(minimalAlphabet.begin(), minimalAlphabet.end(), symbols.begin(), symbols.end(), std::inserter(removedSymbols, removedSymbols.end())); if(removedSymbols.size() > 0) - throw alib::AlibException("Input symbols are used."); + throw exception::AlibException("Input symbols are used."); this->alphabet = symbols; } bool String::removeSymbolFromAlphabet(const alphabet::Symbol & symbol) { if(this->string->testSymbol(symbol)) - throw alib::AlibException("Input symbol \"" + (std::string) symbol + "\" is used."); + throw exception::AlibException("Input symbol \"" + (std::string) symbol + "\" is used."); return alphabet.erase(symbol); } diff --git a/alib2/src/string/StringFromStringParser.cpp b/alib2/src/string/StringFromStringParser.cpp index bf4eabea7a72d5f474e1e14d9826f81d98e12b43..f6118ce82641ad678f444e5cb4a97353fe6c7ac1 100644 --- a/alib2/src/string/StringFromStringParser.cpp +++ b/alib2/src/string/StringFromStringParser.cpp @@ -1,5 +1,5 @@ #include "StringFromStringParser.h" -#include "../AlibException.h" +#include "../exception/AlibException.h" #include "Epsilon.h" #include "LinearString.h" #include "CyclicString.h" @@ -20,38 +20,38 @@ String StringFromStringParser::parse() { String StringFromStringParser::parse(const std::set<FEATURES>& features) { StringFromStringLexer::Token token = m_StringLexer.token(); if(token.type == StringFromStringLexer::TokenType::EPSILON) { - if(!features.count(FEATURES::EPSILON)) throw alib::AlibException(); + if(!features.count(FEATURES::EPSILON)) throw exception::AlibException(); return String(Epsilon()); } else if(token.type == StringFromStringLexer::TokenType::LESS) { - if(!features.count(FEATURES::CYCLIC)) throw alib::AlibException(); + if(!features.count(FEATURES::CYCLIC)) throw exception::AlibException(); std::vector<alphabet::Symbol> data = parseContent(); if(token.type == StringFromStringLexer::TokenType::GREATER) { return String(CyclicString(data)); } else { - throw alib::AlibException(); + throw exception::AlibException(); } } else if(token.type == StringFromStringLexer::TokenType::QUOTE) { - if(!features.count(FEATURES::LINEAR)) throw alib::AlibException(); + if(!features.count(FEATURES::LINEAR)) throw exception::AlibException(); std::vector<alphabet::Symbol> data = parseContent(); if(token.type == StringFromStringLexer::TokenType::QUOTE) { return String(LinearString(data)); } else { - throw alib::AlibException(); + throw exception::AlibException(); } } else { - throw alib::AlibException(); + throw exception::AlibException(); } } String StringFromStringParser::parseValue() { - first(); + first() || m_SymbolParser.first() || m_SymbolParser.m_LabelParser.first(); String res = parse(); StringFromStringLexer::Token token = m_StringLexer.next().token(); if(token.type == StringFromStringLexer::TokenType::TEOF) { return std::move(res); } else { - throw alib::AlibException(); + throw exception::AlibException(); } } @@ -84,7 +84,7 @@ String* StringFromStringParser::parsePointer() { std::vector<alphabet::Symbol> StringFromStringParser::parseContent() { std::vector<alphabet::Symbol> data; do { - next() || m_SymbolParser.first() || m_SymbolParser.m_LabelParser.first(); + next() || m_SymbolParser.next() || m_SymbolParser.m_LabelParser.next(); StringFromStringLexer::Token token = m_StringLexer.token(); if(token.type == StringFromStringLexer::TokenType::GREATER || token.type == StringFromStringLexer::TokenType::QUOTE) diff --git a/alib2/src/string/StringFromXMLParser.cpp b/alib2/src/string/StringFromXMLParser.cpp index 0aa3f44f4e362a1997942c40b15e478ac686af7c..02f306c3b62f46a29cb09db1af4aacca0d89ccdc 100644 --- a/alib2/src/string/StringFromXMLParser.cpp +++ b/alib2/src/string/StringFromXMLParser.cpp @@ -33,18 +33,18 @@ String StringFromXMLParser::parse(std::list<sax::Token>& input, const std::set<F void StringFromXMLParser::parseContent(std::list<sax::Token>& input, String& string, const std::set<FEATURES>& features) const { if(isToken(input, sax::Token::TokenType::START_ELEMENT, "Epsilon")) { - if(!features.count(FEATURES::EPSILON)) throw alib::AlibException(); + if(!features.count(FEATURES::EPSILON)) throw exception::AlibException(); popToken(input, sax::Token::TokenType::START_ELEMENT, "Epsilon"); popToken(input, sax::Token::TokenType::END_ELEMENT, "Epsilon"); string.setString(Epsilon()); } else if(isToken(input, sax::Token::TokenType::START_ELEMENT, "LinearString")) { - if(!features.count(FEATURES::LINEAR)) throw alib::AlibException(); + if(!features.count(FEATURES::LINEAR)) throw exception::AlibException(); popToken(input, sax::Token::TokenType::START_ELEMENT, "LinearString"); std::vector<alphabet::Symbol> data = parseContentData(input); popToken(input, sax::Token::TokenType::END_ELEMENT, "LinearString"); string.setString(LinearString(data)); } else if(isToken(input, sax::Token::TokenType::START_ELEMENT, "CyclicString")) { - if(!features.count(FEATURES::CYCLIC)) throw alib::AlibException(); + if(!features.count(FEATURES::CYCLIC)) throw exception::AlibException(); popToken(input, sax::Token::TokenType::START_ELEMENT, "CyclicString"); std::vector<alphabet::Symbol> data = parseContentData(input); popToken(input, sax::Token::TokenType::END_ELEMENT, "CyclicString");