From f044bf8467aac1e72e9dc9c44a0f88f6a65ecedc Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Wed, 2 Jul 2014 12:25:01 +0200 Subject: [PATCH] separate exception dir --- alib2/src/FromXMLParser.hpp | 4 +- alib2/src/FromXMLParsers.cpp | 2 +- alib2/src/FromXMLParsers.h | 4 +- alib2/src/ToXMLComposers.cpp | 2 +- alib2/src/ToXMLComposers.h | 4 +- alib2/src/alphabet/SymbolFromStringParser.cpp | 27 ++++++++----- alib2/src/alphabet/SymbolFromStringParser.h | 1 + alib2/src/alphabet/SymbolFromXMLParser.cpp | 8 ++-- alib2/src/automaton/AutomatonException.h | 4 +- .../src/automaton/AutomatonFromXMLParser.cpp | 8 ++-- .../FSM/FiniteAutomatonFromStringParser.cpp | 40 +++++++++---------- .../FSM/FiniteAutomatonToStringComposer.cpp | 12 +++--- alib2/src/{ => exception}/AlibException.cpp | 6 +-- alib2/src/{ => exception}/AlibException.h | 4 +- alib2/src/{ => exception}/ExceptionFeatures.h | 4 +- .../ExceptionFromXMLParser.cpp | 8 ++-- .../{ => exception}/ExceptionFromXMLParser.h | 8 ++-- .../ExceptionToXMLComposer.cpp | 4 +- .../{ => exception}/ExceptionToXMLComposer.h | 6 +-- alib2/src/label/LabelFromStringParser.cpp | 23 +++++++---- alib2/src/label/LabelFromStringParser.h | 1 + alib2/src/label/LabelFromXMLParser.cpp | 6 +-- alib2/src/regexp/Alternation.cpp | 6 +-- alib2/src/regexp/Concatenation.cpp | 6 +-- alib2/src/regexp/Iteration.cpp | 6 +-- alib2/src/regexp/RegExp.cpp | 10 ++--- alib2/src/regexp/RegExpFromStringParser.cpp | 10 ++--- alib2/src/regexp/RegExpFromXMLParser.cpp | 2 +- alib2/src/sax/ComposerException.h | 4 +- alib2/src/sax/ParserException.h | 4 +- alib2/src/sax/SaxParseInterface.cpp | 6 +-- alib2/src/string/String.cpp | 10 ++--- alib2/src/string/StringFromStringParser.cpp | 20 +++++----- alib2/src/string/StringFromXMLParser.cpp | 6 +-- 34 files changed, 148 insertions(+), 128 deletions(-) rename alib2/src/{ => exception}/AlibException.cpp (90%) rename alib2/src/{ => exception}/AlibException.h (94%) rename alib2/src/{ => exception}/ExceptionFeatures.h (82%) rename alib2/src/{ => exception}/ExceptionFromXMLParser.cpp (84%) rename alib2/src/{ => exception}/ExceptionFromXMLParser.h (78%) rename alib2/src/{ => exception}/ExceptionToXMLComposer.cpp (93%) rename alib2/src/{ => exception}/ExceptionToXMLComposer.h (90%) diff --git a/alib2/src/FromXMLParser.hpp b/alib2/src/FromXMLParser.hpp index deb214c95c..f772cfcaad 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 b1921a97c1..7142f3c032 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 7d1e9f8c2b..da3da9e356 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 ff59114d7d..fe6c951499 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 4fdb81f08f..60cab59e17 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 f80584c19c..0ca379e8c6 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 f62d3b8fc5..aa510bb978 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 6d41ec9e27..cb1e5b438c 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 864312c09c..99ad765079 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 a49d91db20..fb92ceafd2 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 e48d286921..11e270da0e 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 c5349181a8..f5128e778c 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 2f7103eb10..0bdd0d3862 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 fe9cb78d6d..919f889c92 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 d1757e13f6..89067aa026 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 3b72fff798..0a4c7b60d7 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 28646aa42c..1ab2f1d7d4 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 368765d318..70dd4071dd 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 430a63b9b7..906ad68f6b 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 048552197c..0e154405c2 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 8ba1cf79c1..3119e89ae9 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 c3c6a8a295..8728880c4f 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 1cf04c9af4..a31b08964d 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 8b3aee33c2..c4a40827a2 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 27a470014e..8f80651817 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 03a7d26fb5..2eb5b909b2 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 73699c84ce..1b5a487827 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 bee69acdc4..1fdc6ad223 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 fe662196e2..e1ba2c417c 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 af17aa0d8f..910d5e94dd 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 91b2a22f47..7abcaa3cb6 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 82a51d3dd5..acbff3d6b7 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 bf4eabea7a..f6118ce826 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 0aa3f44f4e..02f306c3b6 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"); -- GitLab