diff --git a/alib2str/src/StringApi.cpp b/alib2str/src/StringApi.cpp index a3c97bbb2393f789ecb750a908cf4a6635c4af99..4de165f956b62177f219856e7fdffbf75d66ff6e 100644 --- a/alib2str/src/StringApi.cpp +++ b/alib2str/src/StringApi.cpp @@ -7,7 +7,7 @@ #include "StringApi.hpp" -#include "exception/AlibException.h" +#include "exception/CommonException.h" namespace alib { diff --git a/alib2str/src/alphabet/SymbolFromStringParser.cpp b/alib2str/src/alphabet/SymbolFromStringParser.cpp index 1f6b41f8dfe6d3f5a664a8c54c4c7296394a51ba..645fdc4f781c514701f10058fc2ad3b27532b2ae 100644 --- a/alib2str/src/alphabet/SymbolFromStringParser.cpp +++ b/alib2str/src/alphabet/SymbolFromStringParser.cpp @@ -6,7 +6,7 @@ */ #include "SymbolFromStringParser.h" -#include "exception/AlibException.h" +#include "exception/CommonException.h" #include "alphabet/BlankSymbol.h" #include "alphabet/BottomOfTheStackSymbol.h" #include "alphabet/EndSymbol.h" @@ -25,25 +25,25 @@ Symbol SymbolFromStringParser::parseSymbol(std::istream& input, const std::set<F SymbolFromStringLexer::Token token = m_SymbolLexer.next(input); switch(token.type) { case SymbolFromStringLexer::TokenType::BLANK: - if(!features.count(FEATURES::BLANK)) throw exception::AlibException(); + if(!features.count(FEATURES::BLANK)) throw exception::CommonException("Disabled formalism BlankSymbol"); return Symbol(BlankSymbol()); case SymbolFromStringLexer::TokenType::BOTTOM: - if(!features.count(FEATURES::BOTTOM)) throw exception::AlibException(); + if(!features.count(FEATURES::BOTTOM)) throw exception::CommonException("Disabled formalism BottomSymbol"); return Symbol(BottomOfTheStackSymbol()); case SymbolFromStringLexer::TokenType::END: - if(!features.count(FEATURES::END)) throw exception::AlibException(); + if(!features.count(FEATURES::END)) throw exception::CommonException("Disabled formalism EndSymbol"); return Symbol(EndSymbol()); case SymbolFromStringLexer::TokenType::START: - if(!features.count(FEATURES::START)) throw exception::AlibException(); + if(!features.count(FEATURES::START)) throw exception::CommonException("Disabled formalism StartSymbol"); return Symbol(StartSymbol()); case SymbolFromStringLexer::TokenType::ERROR: - if(!features.count(FEATURES::LABELED)) throw exception::AlibException(); + if(!features.count(FEATURES::LABELED)) throw exception::CommonException("Disabled formalism LabeledSymbol"); m_SymbolLexer.putback(input, token); return Symbol(LabeledSymbol(alib::stringApi<label::Label>::parse(input))); case SymbolFromStringLexer::TokenType::TEOF: - throw exception::AlibException("Unexpected end of file"); + throw exception::CommonException("Unexpected end of file"); } - throw exception::AlibException(); + throw exception::CommonException("Formalism not recognised (token = \"" + token.value + "\")"); } } /* namespace alphabet */ diff --git a/alib2str/src/automaton/AutomatonFromStringParser.cpp b/alib2str/src/automaton/AutomatonFromStringParser.cpp index 5f65a7512a9297bfd3e5720a5ff3ab5d2e25621e..35e15bf511e02ea9ead1cb02318c878df8373dde 100644 --- a/alib2str/src/automaton/AutomatonFromStringParser.cpp +++ b/alib2str/src/automaton/AutomatonFromStringParser.cpp @@ -7,7 +7,7 @@ #include "AutomatonFromStringParser.h" -#include "exception/AlibException.h" +#include "exception/CommonException.h" #include "automaton/FSM/EpsilonNFA.h" #include "automaton/FSM/MultiInitialStateNFA.h" @@ -25,30 +25,30 @@ Automaton AutomatonFromStringParser::parseAutomaton(std::istream& input) const { Automaton AutomatonFromStringParser::parseAutomaton(std::istream& input, const std::set<FEATURES>& features) const { AutomatonFromStringLexer::Token token = m_AutomatonLexer.next(input); if(token.type == AutomatonFromStringLexer::TokenType::EPSILON_NFA) { - if(!features.count(FEATURES::EPSILON_NFA)) throw exception::AlibException("Disabled formalism EpsilonNFA"); + if(!features.count(FEATURES::EPSILON_NFA)) throw exception::CommonException("Disabled formalism EpsilonNFA"); m_AutomatonLexer.putback(input, token); return Automaton(parseEpsilonNFA(input)); } else if(token.type == AutomatonFromStringLexer::TokenType::MULTI_INITIAL_STATE_NFA) { - if(!features.count(FEATURES::MULTI_INITIAL_STATE_NFA)) throw exception::AlibException("Disabled Formalism MultiInitialStateNFA"); + if(!features.count(FEATURES::MULTI_INITIAL_STATE_NFA)) throw exception::CommonException("Disabled Formalism MultiInitialStateNFA"); m_AutomatonLexer.putback(input, token); return Automaton(parseMultiInitialStateNFA(input)); } else if(token.type == AutomatonFromStringLexer::TokenType::NFA) { - if(!features.count(FEATURES::NFA)) throw exception::AlibException("Disabled formalism NFA"); + if(!features.count(FEATURES::NFA)) throw exception::CommonException("Disabled formalism NFA"); m_AutomatonLexer.putback(input, token); return Automaton(parseNFA(input)); } else if(token.type == AutomatonFromStringLexer::TokenType::DFA) { - if(!features.count(FEATURES::DFA)) throw exception::AlibException("Disabled formalism DFA"); + if(!features.count(FEATURES::DFA)) throw exception::CommonException("Disabled formalism DFA"); m_AutomatonLexer.putback(input, token); return Automaton(parseDFA(input)); } else { - throw exception::AlibException("Formalism not recognised (token = \"" + token.value + "\")"); + throw exception::CommonException("Formalism not recognised (token = \"" + token.value + "\")"); } } EpsilonNFA AutomatonFromStringParser::parseEpsilonNFA(std::istream& input) const { AutomatonFromStringLexer::Token token = m_AutomatonLexer.next(input); if(token.type != AutomatonFromStringLexer::TokenType::EPSILON_NFA) { - throw exception::AlibException("Unrecognised ENFA token."); + throw exception::CommonException("Unrecognised ENFA token."); } std::vector<std::variant<string::Epsilon, alphabet::Symbol> > symbols; @@ -86,7 +86,7 @@ EpsilonNFA AutomatonFromStringParser::parseEpsilonNFA(std::istream& input) const token = m_AutomatonLexer.next(input); } - if(initialState == NULL) throw exception::AlibException("No initial state recognised."); + if(initialState == NULL) throw exception::CommonException("No initial state recognised."); EpsilonNFA res(*initialState); delete initialState; @@ -109,7 +109,7 @@ MultiInitialStateNFA AutomatonFromStringParser::parseMultiInitialStateNFA(std::i AutomatonFromStringLexer::Token token = m_AutomatonLexer.next(input); if(token.type != AutomatonFromStringLexer::TokenType::MULTI_INITIAL_STATE_NFA) { - throw exception::AlibException("Unrecognised MISNFA token."); + throw exception::CommonException("Unrecognised MISNFA token."); } std::vector<alphabet::Symbol> symbols; @@ -143,7 +143,7 @@ MultiInitialStateNFA AutomatonFromStringParser::parseMultiInitialStateNFA(std::i NFA AutomatonFromStringParser::parseNFA(std::istream& input) const { AutomatonFromStringLexer::Token token = m_AutomatonLexer.next(input); if(token.type != AutomatonFromStringLexer::TokenType::NFA) { - throw exception::AlibException("Unrecognised NFA token."); + throw exception::CommonException("Unrecognised NFA token."); } std::vector<alphabet::Symbol> symbols; @@ -175,7 +175,7 @@ NFA AutomatonFromStringParser::parseNFA(std::istream& input) const { token = m_AutomatonLexer.next(input); } - if(initialState == NULL) throw exception::AlibException("No initial state recognised."); + if(initialState == NULL) throw exception::CommonException("No initial state recognised."); NFA res(*initialState); delete initialState; @@ -193,7 +193,7 @@ NFA AutomatonFromStringParser::parseNFA(std::istream& input) const { DFA AutomatonFromStringParser::parseDFA(std::istream& input) const { AutomatonFromStringLexer::Token token = m_AutomatonLexer.next(input); if(token.type != AutomatonFromStringLexer::TokenType::DFA) { - throw exception::AlibException("Unrecognised DFA token."); + throw exception::CommonException("Unrecognised DFA token."); } std::vector<alphabet::Symbol> symbols; @@ -225,7 +225,7 @@ DFA AutomatonFromStringParser::parseDFA(std::istream& input) const { token = m_AutomatonLexer.next(input); } - if(initialState == NULL) throw exception::AlibException("No initial state recognised."); + if(initialState == NULL) throw exception::CommonException("No initial state recognised."); DFA res(*initialState); delete initialState; @@ -278,7 +278,7 @@ void AutomatonFromStringParser::parseEpsilonNFATransition(std::istream& input, s State from(alib::stringApi<label::Label>::parse(input)); states.insert(from); if(initial) { - if(initialState != NULL) throw exception::AlibException("Multiple initial states are not avaiable for NFA type"); + if(initialState != NULL) throw exception::CommonException("Multiple initial states are not avaiable for NFA type"); initialState = new State(from); } if(final) finalStates.insert(from); @@ -287,7 +287,7 @@ void AutomatonFromStringParser::parseEpsilonNFATransition(std::istream& input, s std::vector<std::variant<string::Epsilon, alphabet::Symbol>>::const_iterator iter = symbols.begin(); while(token.type != AutomatonFromStringLexer::TokenType::NEW_LINE) { - if(iter == symbols.end()) throw exception::AlibException("Invalid line format"); + if(iter == symbols.end()) throw exception::CommonException("Invalid line format"); if(token.type != AutomatonFromStringLexer::TokenType::NONE) { m_AutomatonLexer.putback(input, token); @@ -306,7 +306,7 @@ void AutomatonFromStringParser::parseEpsilonNFATransition(std::istream& input, s } m_AutomatonLexer.putback(input, token); - if(iter != symbols.end()) throw exception::AlibException("Invalid line format"); + if(iter != symbols.end()) throw exception::CommonException("Invalid line format"); } void AutomatonFromStringParser::parseMultiInitialStateNFATransition(std::istream& input, MultiInitialStateNFA& res, const std::vector<alphabet::Symbol>& symbols) const { @@ -324,7 +324,7 @@ void AutomatonFromStringParser::parseMultiInitialStateNFATransition(std::istream std::vector<alphabet::Symbol>::const_iterator iter = symbols.begin(); while(token.type != AutomatonFromStringLexer::TokenType::NEW_LINE) { - if(iter == symbols.end()) throw exception::AlibException("Invalid line format"); + if(iter == symbols.end()) throw exception::CommonException("Invalid line format"); if(token.type != AutomatonFromStringLexer::TokenType::NONE) { m_AutomatonLexer.putback(input, token); @@ -343,7 +343,7 @@ void AutomatonFromStringParser::parseMultiInitialStateNFATransition(std::istream } m_AutomatonLexer.putback(input, token); - if(iter != symbols.end()) throw exception::AlibException("Invalid line format"); + if(iter != symbols.end()) throw exception::CommonException("Invalid line format"); } void AutomatonFromStringParser::parseNFATransition(std::istream& input, 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) const { @@ -355,7 +355,7 @@ void AutomatonFromStringParser::parseNFATransition(std::istream& input, std::set State from(alib::stringApi<label::Label>::parse(input)); states.insert(from); if(initial) { - if(initialState != NULL) throw exception::AlibException("Multiple initial states are not avaiable for NFA type"); + if(initialState != NULL) throw exception::CommonException("Multiple initial states are not avaiable for NFA type"); initialState = new State(from); } if(final) finalStates.insert(from); @@ -364,7 +364,7 @@ void AutomatonFromStringParser::parseNFATransition(std::istream& input, std::set std::vector<alphabet::Symbol>::const_iterator iter = symbols.begin(); while(token.type != AutomatonFromStringLexer::TokenType::NEW_LINE) { - if(iter == symbols.end()) throw exception::AlibException("Invalid line format"); + if(iter == symbols.end()) throw exception::CommonException("Invalid line format"); if(token.type != AutomatonFromStringLexer::TokenType::NONE) { m_AutomatonLexer.putback(input, token); @@ -383,7 +383,7 @@ void AutomatonFromStringParser::parseNFATransition(std::istream& input, std::set } m_AutomatonLexer.putback(input, token); - if(iter != symbols.end()) throw exception::AlibException("Invalid line format"); + if(iter != symbols.end()) throw exception::CommonException("Invalid line format"); } void AutomatonFromStringParser::parseDFATransition(std::istream& input, 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) const { @@ -395,7 +395,7 @@ void AutomatonFromStringParser::parseDFATransition(std::istream& input, std::set State from(alib::stringApi<label::Label>::parse(input)); states.insert(from); if(initial) { - if(initialState != NULL) throw exception::AlibException("Multiple initial states are not avaiable for NFA type"); + if(initialState != NULL) throw exception::CommonException("Multiple initial states are not avaiable for NFA type"); initialState = new State(from); } if(final) finalStates.insert(from); @@ -404,7 +404,7 @@ void AutomatonFromStringParser::parseDFATransition(std::istream& input, std::set std::vector<alphabet::Symbol>::const_iterator iter = symbols.begin(); while(token.type != AutomatonFromStringLexer::TokenType::NEW_LINE) { - if(iter == symbols.end()) throw exception::AlibException("Invalid line format"); + if(iter == symbols.end()) throw exception::CommonException("Invalid line format"); if(token.type != AutomatonFromStringLexer::TokenType::NONE) { m_AutomatonLexer.putback(input, token); @@ -420,7 +420,7 @@ void AutomatonFromStringParser::parseDFATransition(std::istream& input, std::set } m_AutomatonLexer.putback(input, token); - if(iter != symbols.end()) throw exception::AlibException("Invalid line format"); + if(iter != symbols.end()) throw exception::CommonException("Invalid line format"); } } /* namespace automaton */ diff --git a/alib2str/src/automaton/AutomatonToStringComposer.cpp b/alib2str/src/automaton/AutomatonToStringComposer.cpp index cce2cb00eff88f8c0910037b7cd74c8fbea38801..396cc0fbab4c01852e2e58f7490fdcc976374a80 100644 --- a/alib2str/src/automaton/AutomatonToStringComposer.cpp +++ b/alib2str/src/automaton/AutomatonToStringComposer.cpp @@ -6,7 +6,7 @@ */ #include "AutomatonToStringComposer.h" -#include "exception/AlibException.h" +#include "exception/CommonException.h" #include "automaton/FSM/DFA.h" #include "automaton/FSM/NFA.h" #include "automaton/FSM/MultiInitialStateNFA.h" diff --git a/alib2str/src/factory/StringDataFactory.hpp b/alib2str/src/factory/StringDataFactory.hpp index 40e11f16a5267e5568be0c004837c69c1233f265..4e126d23d2a82e74ac5e153091a62860b2141ef4 100644 --- a/alib2str/src/factory/StringDataFactory.hpp +++ b/alib2str/src/factory/StringDataFactory.hpp @@ -9,7 +9,7 @@ #define STRING_DATA_FACTORY #include <set> -#include "exception/AlibException.h" +#include "exception/CommonException.h" #include "../StringApi.hpp" #include <fstream> #include <sstream> @@ -38,12 +38,12 @@ public: template<class T> static T fromStream(std::istream& in) { - if(in.peek() == EOF) throw exception::AlibException("Empty stream"); + if(in.peek() == EOF) throw exception::CommonException("Empty stream"); T res = alib::stringApi<T>::parse(in); while(isspace(in.peek())) in.get(); - if(in.peek() != EOF) throw exception::AlibException("Unexpected characters at the end of the stream"); + if(in.peek() != EOF) throw exception::CommonException("Unexpected characters at the end of the stream"); return res; } diff --git a/alib2str/src/grammar/GrammarFromStringParser.cpp b/alib2str/src/grammar/GrammarFromStringParser.cpp index c3d5682654badd648a436245bd8dd31492e9f9fc..19bb3b4d356e7896aa20dea574e14e83125e84fe 100644 --- a/alib2str/src/grammar/GrammarFromStringParser.cpp +++ b/alib2str/src/grammar/GrammarFromStringParser.cpp @@ -7,7 +7,7 @@ #include "GrammarFromStringParser.h" -#include "exception/AlibException.h" +#include "exception/CommonException.h" #include "grammar/GrammarClasses.h" @@ -22,59 +22,59 @@ Grammar GrammarFromStringParser::parseGrammar(std::istream& input) const { Grammar GrammarFromStringParser::parseGrammar(std::istream& input, const std::set<FEATURES>& features) const { GrammarFromStringLexer::Token token = m_GrammarLexer.next(input); if(token.type == GrammarFromStringLexer::TokenType::LEFT_RG) { - if(!features.count(FEATURES::LEFT_RG)) throw exception::AlibException("Disabled Formalism LeftRG"); + if(!features.count(FEATURES::LEFT_RG)) throw exception::CommonException("Disabled Formalism LeftRG"); m_GrammarLexer.putback(input, token); return Grammar(parseLeftRG(input)); } else if(token.type == GrammarFromStringLexer::TokenType::RIGHT_RG) { - if(!features.count(FEATURES::RIGHT_RG)) throw exception::AlibException("Disabled Formalism RightRG"); + if(!features.count(FEATURES::RIGHT_RG)) throw exception::CommonException("Disabled Formalism RightRG"); m_GrammarLexer.putback(input, token); return Grammar(parseRightRG(input)); } else if(token.type == GrammarFromStringLexer::TokenType::LEFT_LG) { - if(!features.count(FEATURES::LEFT_LG)) throw exception::AlibException("Disabled Formalism LeftLG"); + if(!features.count(FEATURES::LEFT_LG)) throw exception::CommonException("Disabled Formalism LeftLG"); m_GrammarLexer.putback(input, token); return Grammar(parseLeftLG(input)); } else if(token.type == GrammarFromStringLexer::TokenType::RIGHT_LG) { - if(!features.count(FEATURES::RIGHT_LG)) throw exception::AlibException("Disabled Formalism RightLG"); + if(!features.count(FEATURES::RIGHT_LG)) throw exception::CommonException("Disabled Formalism RightLG"); m_GrammarLexer.putback(input, token); return Grammar(parseRightLG(input)); } else if(token.type == GrammarFromStringLexer::TokenType::LG) { - if(!features.count(FEATURES::LG)) throw exception::AlibException("Disabled formalism LG"); + if(!features.count(FEATURES::LG)) throw exception::CommonException("Disabled formalism LG"); m_GrammarLexer.putback(input, token); return Grammar(parseLG(input)); } else if(token.type == GrammarFromStringLexer::TokenType::CFG) { - if(!features.count(FEATURES::CFG)) throw exception::AlibException("Disabled formalism CFG"); + if(!features.count(FEATURES::CFG)) throw exception::CommonException("Disabled formalism CFG"); m_GrammarLexer.putback(input, token); return Grammar(parseCFG(input)); } else if(token.type == GrammarFromStringLexer::TokenType::EPSILON_FREE_CFG) { - if(!features.count(FEATURES::EPSILON_FREE_CFG)) throw exception::AlibException("Disabled formalism EpsilonFreeCFG"); + if(!features.count(FEATURES::EPSILON_FREE_CFG)) throw exception::CommonException("Disabled formalism EpsilonFreeCFG"); m_GrammarLexer.putback(input, token); return Grammar(parseEpsilonFreeCFG(input)); } else if(token.type == GrammarFromStringLexer::TokenType::GNF) { - if(!features.count(FEATURES::GNF)) throw exception::AlibException("Disabled formalism GNF"); + if(!features.count(FEATURES::GNF)) throw exception::CommonException("Disabled formalism GNF"); m_GrammarLexer.putback(input, token); return Grammar(parseGNF(input)); } else if(token.type == GrammarFromStringLexer::TokenType::CNF) { - if(!features.count(FEATURES::CNF)) throw exception::AlibException("Disabled formalism CNF"); + if(!features.count(FEATURES::CNF)) throw exception::CommonException("Disabled formalism CNF"); m_GrammarLexer.putback(input, token); return Grammar(parseCNF(input)); } else if(token.type == GrammarFromStringLexer::TokenType::NON_CONTRACTING_GRAMMAR) { - if(!features.count(FEATURES::NON_CONTRACTING_GRAMMAR)) throw exception::AlibException("Disabled formalism NonContractingGrammar"); + if(!features.count(FEATURES::NON_CONTRACTING_GRAMMAR)) throw exception::CommonException("Disabled formalism NonContractingGrammar"); m_GrammarLexer.putback(input, token); return Grammar(parseNonContractingGrammar(input)); } else if(token.type == GrammarFromStringLexer::TokenType::CSG) { - if(!features.count(FEATURES::CSG)) throw exception::AlibException("Disabled formalism CSG"); + if(!features.count(FEATURES::CSG)) throw exception::CommonException("Disabled formalism CSG"); m_GrammarLexer.putback(input, token); return Grammar(parseCSG(input)); } else if(token.type == GrammarFromStringLexer::TokenType::CONTEXT_PRESERVING_UNRESTRICTED_GRAMMAR) { - if(!features.count(FEATURES::CONTEXT_PRESERVING_UNRESTRICTED_GRAMMAR)) throw exception::AlibException("Disabled formalism ContextPreservingUnrestrictedGrammar"); + if(!features.count(FEATURES::CONTEXT_PRESERVING_UNRESTRICTED_GRAMMAR)) throw exception::CommonException("Disabled formalism ContextPreservingUnrestrictedGrammar"); m_GrammarLexer.putback(input, token); return Grammar(parseContextPreservingUnrestrictedGrammar(input)); } else if(token.type == GrammarFromStringLexer::TokenType::UNRESTRICTED_GRAMMAR) { - if(!features.count(FEATURES::UNRESTRICTED_GRAMMAR)) throw exception::AlibException("Disabled formalism UnrestrictedGrammar"); + if(!features.count(FEATURES::UNRESTRICTED_GRAMMAR)) throw exception::CommonException("Disabled formalism UnrestrictedGrammar"); m_GrammarLexer.putback(input, token); return Grammar(parseUnrestrictedGrammar(input)); } else { - throw exception::AlibException("Formalism not recognised (token = \"" + token.value + "\")"); + throw exception::CommonException("Formalism not recognised (token = \"" + token.value + "\")"); } } @@ -83,7 +83,7 @@ std::set<alphabet::Symbol> GrammarFromStringParser::parseSet(std::istream& input GrammarFromStringLexer::Token token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::SET_BEGIN) { - throw exception::AlibException(); + throw exception::CommonException("Expected SET_BEGIN token."); } token = m_GrammarLexer.next(input); @@ -98,13 +98,13 @@ std::set<alphabet::Symbol> GrammarFromStringParser::parseSet(std::istream& input break; } if(token.type != GrammarFromStringLexer::TokenType::COMMA) { - throw exception::AlibException("Expected SET_END or COMMA token"); + throw exception::CommonException("Expected SET_END or COMMA token"); } } } if(token.type != GrammarFromStringLexer::TokenType::SET_END) { - throw exception::AlibException("Expected SET_END token"); + throw exception::CommonException("Expected SET_END token"); } return res; @@ -115,7 +115,7 @@ std::map<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>> GrammarFromS GrammarFromStringLexer::Token token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::SET_BEGIN) { - throw exception::AlibException(); + throw exception::CommonException("Expected SET_BEGIN token."); } token = m_GrammarLexer.next(input); @@ -126,7 +126,7 @@ std::map<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>> GrammarFromS token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::MAPS_TO) { - throw exception::AlibException(); + throw exception::CommonException("Expected MAPS_TO token."); } while(true) { @@ -147,7 +147,7 @@ std::map<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>> GrammarFromS break; } if(token.type != GrammarFromStringLexer::TokenType::SEPARATOR) { - throw exception::AlibException("Expected SEPARATOR, SETEND or COMMA token"); + throw exception::CommonException("Expected SEPARATOR, SETEND or COMMA token"); } } @@ -155,13 +155,13 @@ std::map<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>> GrammarFromS break; } if(token.type != GrammarFromStringLexer::TokenType::COMMA) { - throw exception::AlibException("Expected SET_END or COMMA token"); + throw exception::CommonException("Expected SET_END or COMMA token"); } } } if(token.type != GrammarFromStringLexer::TokenType::SET_END) { - throw exception::AlibException("Expected SET_END token"); + throw exception::CommonException("Expected SET_END token"); } return result; } @@ -170,35 +170,35 @@ template<class T> T GrammarFromStringParser::parseCFLikeGrammar(std::istream& input) const { GrammarFromStringLexer::Token token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::TUPLE_BEGIN) { - throw exception::AlibException("Unrecognised Tuple begin token."); + throw exception::CommonException("Unrecognised Tuple begin token."); } std::set<alphabet::Symbol> nonterminals = parseSet(input); token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::COMMA) { - throw exception::AlibException("Unrecognised Comma token."); + throw exception::CommonException("Unrecognised Comma token."); } std::set<alphabet::Symbol> terminals = parseSet(input); token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::COMMA) { - throw exception::AlibException("Unrecognised Comma token."); + throw exception::CommonException("Unrecognised Comma token."); } std::map<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>> rules = parseCFLikeRules(input); token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::COMMA) { - throw exception::AlibException("Unrecognised Comma token."); + throw exception::CommonException("Unrecognised Comma token."); } alphabet::Symbol initialSymbol = alib::stringApi<alphabet::Symbol>::parse(input); token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::TUPLE_END) { - throw exception::AlibException("Unrecognised Tuple end token."); + throw exception::CommonException("Unrecognised Tuple end token."); } T grammar(nonterminals, terminals, initialSymbol); @@ -215,7 +215,7 @@ std::map<std::vector<alphabet::Symbol>, std::set<std::vector<alphabet::Symbol>>> GrammarFromStringLexer::Token token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::SET_BEGIN) { - throw exception::AlibException(); + throw exception::CommonException("Expected SET_BEGIN token."); } token = m_GrammarLexer.next(input); @@ -233,7 +233,7 @@ std::map<std::vector<alphabet::Symbol>, std::set<std::vector<alphabet::Symbol>>> } if(token.type != GrammarFromStringLexer::TokenType::MAPS_TO) { - throw exception::AlibException(); + throw exception::CommonException("Expected MAPS_TO token."); } while(true) { @@ -254,7 +254,7 @@ std::map<std::vector<alphabet::Symbol>, std::set<std::vector<alphabet::Symbol>>> break; } if(token.type != GrammarFromStringLexer::TokenType::SEPARATOR) { - throw exception::AlibException("Expected SEPARATOR, SETEND or COMMA token"); + throw exception::CommonException("Expected SEPARATOR, SETEND or COMMA token"); } } @@ -262,13 +262,13 @@ std::map<std::vector<alphabet::Symbol>, std::set<std::vector<alphabet::Symbol>>> break; } if(token.type != GrammarFromStringLexer::TokenType::COMMA) { - throw exception::AlibException("Expected SET_END or COMMA token"); + throw exception::CommonException("Expected SET_END or COMMA token"); } } } if(token.type != GrammarFromStringLexer::TokenType::SET_END) { - throw exception::AlibException("Expected SET_END token"); + throw exception::CommonException("Expected SET_END token"); } return result; } @@ -277,35 +277,35 @@ template<class T> T GrammarFromStringParser::parseCSLikeGrammar(std::istream& input) const { GrammarFromStringLexer::Token token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::TUPLE_BEGIN) { - throw exception::AlibException("Unrecognised Tuple begin token."); + throw exception::CommonException("Unrecognised Tuple begin token."); } std::set<alphabet::Symbol> nonterminals = parseSet(input); token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::COMMA) { - throw exception::AlibException("Unrecognised Comma token."); + throw exception::CommonException("Unrecognised Comma token."); } std::set<alphabet::Symbol> terminals = parseSet(input); token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::COMMA) { - throw exception::AlibException("Unrecognised Comma token."); + throw exception::CommonException("Unrecognised Comma token."); } std::map<std::vector<alphabet::Symbol>, std::set<std::vector<alphabet::Symbol>>> rules = parseCSLikeRules(input); token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::COMMA) { - throw exception::AlibException("Unrecognised Comma token."); + throw exception::CommonException("Unrecognised Comma token."); } alphabet::Symbol initialSymbol = alib::stringApi<alphabet::Symbol>::parse(input); token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::TUPLE_END) { - throw exception::AlibException("Unrecognised Tuple end token."); + throw exception::CommonException("Unrecognised Tuple end token."); } T grammar(nonterminals, terminals, initialSymbol); @@ -322,7 +322,7 @@ std::map<std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector GrammarFromStringLexer::Token token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::SET_BEGIN) { - throw exception::AlibException(); + throw exception::CommonException("Expected SET_BEGIN token."); } token = m_GrammarLexer.next(input); @@ -341,14 +341,14 @@ std::map<std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector } if(token.type != GrammarFromStringLexer::TokenType::SEPARATOR) { - throw exception::AlibException(); + throw exception::CommonException("Expected SEPARATOR token."); } alphabet::Symbol lhs = alib::stringApi<alphabet::Symbol>::parse(input); token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::SEPARATOR) { - throw exception::AlibException(); + throw exception::CommonException("Expected SEPARATOR token."); } std::vector<alphabet::Symbol> rContext; @@ -363,7 +363,7 @@ std::map<std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector } if(token.type != GrammarFromStringLexer::TokenType::MAPS_TO) { - throw exception::AlibException(); + throw exception::CommonException("Expected MAPS_TO token."); } std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>> key = std::make_tuple(lContext, lhs, rContext); @@ -386,7 +386,7 @@ std::map<std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector break; } if(token.type != GrammarFromStringLexer::TokenType::SEPARATOR) { - throw exception::AlibException("Expected SEPARATOR, SETEND or COMMA token"); + throw exception::CommonException("Expected SEPARATOR, SETEND or COMMA token"); } } @@ -394,13 +394,13 @@ std::map<std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector break; } if(token.type != GrammarFromStringLexer::TokenType::COMMA) { - throw exception::AlibException("Expected SET_END or COMMA token"); + throw exception::CommonException("Expected SET_END or COMMA token"); } } } if(token.type != GrammarFromStringLexer::TokenType::SET_END) { - throw exception::AlibException("Expected SET_END token"); + throw exception::CommonException("Expected SET_END token"); } return result; } @@ -409,35 +409,35 @@ template<class T> T GrammarFromStringParser::parsePreservingCSLikeGrammar(std::istream& input) const { GrammarFromStringLexer::Token token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::TUPLE_BEGIN) { - throw exception::AlibException("Unrecognised Tuple begin token."); + throw exception::CommonException("Unrecognised Tuple begin token."); } std::set<alphabet::Symbol> nonterminals = parseSet(input); token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::COMMA) { - throw exception::AlibException("Unrecognised Comma token."); + throw exception::CommonException("Unrecognised Comma token."); } std::set<alphabet::Symbol> terminals = parseSet(input); token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::COMMA) { - throw exception::AlibException("Unrecognised Comma token."); + throw exception::CommonException("Unrecognised Comma token."); } std::map<std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>>, std::set<std::vector<alphabet::Symbol>>> rules = parsePreservingCSLikeRules(input); token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::COMMA) { - throw exception::AlibException("Unrecognised Comma token."); + throw exception::CommonException("Unrecognised Comma token."); } alphabet::Symbol initialSymbol = alib::stringApi<alphabet::Symbol>::parse(input); token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::TUPLE_END) { - throw exception::AlibException("Unrecognised Tuple end token."); + throw exception::CommonException("Unrecognised Tuple end token."); } T grammar(nonterminals, terminals, initialSymbol); @@ -452,7 +452,7 @@ T GrammarFromStringParser::parsePreservingCSLikeGrammar(std::istream& input) con RightRG GrammarFromStringParser::parseRightRG(std::istream& input) const { GrammarFromStringLexer::Token token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::RIGHT_RG) { - throw exception::AlibException("Unrecognised RightRG token."); + throw exception::CommonException("Unrecognised RightRG token."); } return parseCFLikeGrammar<RightRG>(input); @@ -461,7 +461,7 @@ RightRG GrammarFromStringParser::parseRightRG(std::istream& input) const { LeftRG GrammarFromStringParser::parseLeftRG(std::istream& input) const { GrammarFromStringLexer::Token token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::LEFT_RG) { - throw exception::AlibException("Unrecognised LeftRG token."); + throw exception::CommonException("Unrecognised LeftRG token."); } return parseCFLikeGrammar<LeftRG>(input); @@ -470,7 +470,7 @@ LeftRG GrammarFromStringParser::parseLeftRG(std::istream& input) const { RightLG GrammarFromStringParser::parseRightLG(std::istream& input) const { GrammarFromStringLexer::Token token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::RIGHT_LG) { - throw exception::AlibException("Unrecognised RightLG token."); + throw exception::CommonException("Unrecognised RightLG token."); } return parseCFLikeGrammar<RightLG>(input); @@ -479,7 +479,7 @@ RightLG GrammarFromStringParser::parseRightLG(std::istream& input) const { LeftLG GrammarFromStringParser::parseLeftLG(std::istream& input) const { GrammarFromStringLexer::Token token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::LEFT_LG) { - throw exception::AlibException("Unrecognised LeftLG token."); + throw exception::CommonException("Unrecognised LeftLG token."); } return parseCFLikeGrammar<LeftLG>(input); @@ -488,7 +488,7 @@ LeftLG GrammarFromStringParser::parseLeftLG(std::istream& input) const { LG GrammarFromStringParser::parseLG(std::istream& input) const { GrammarFromStringLexer::Token token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::LG) { - throw exception::AlibException("Unrecognised LG token."); + throw exception::CommonException("Unrecognised LG token."); } return parseCFLikeGrammar<LG>(input); @@ -497,7 +497,7 @@ LG GrammarFromStringParser::parseLG(std::istream& input) const { CFG GrammarFromStringParser::parseCFG(std::istream& input) const { GrammarFromStringLexer::Token token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::CFG) { - throw exception::AlibException("Unrecognised CFG token."); + throw exception::CommonException("Unrecognised CFG token."); } return parseCFLikeGrammar<CFG>(input); @@ -506,7 +506,7 @@ CFG GrammarFromStringParser::parseCFG(std::istream& input) const { EpsilonFreeCFG GrammarFromStringParser::parseEpsilonFreeCFG(std::istream& input) const { GrammarFromStringLexer::Token token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::EPSILON_FREE_CFG) { - throw exception::AlibException("Unrecognised EpsilonFreeCFG token."); + throw exception::CommonException("Unrecognised EpsilonFreeCFG token."); } return parseCFLikeGrammar<EpsilonFreeCFG>(input); @@ -515,7 +515,7 @@ EpsilonFreeCFG GrammarFromStringParser::parseEpsilonFreeCFG(std::istream& input) GNF GrammarFromStringParser::parseGNF(std::istream& input) const { GrammarFromStringLexer::Token token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::GNF) { - throw exception::AlibException("Unrecognised GNF token."); + throw exception::CommonException("Unrecognised GNF token."); } return parseCFLikeGrammar<GNF>(input); @@ -524,7 +524,7 @@ GNF GrammarFromStringParser::parseGNF(std::istream& input) const { CNF GrammarFromStringParser::parseCNF(std::istream& input) const { GrammarFromStringLexer::Token token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::CNF) { - throw exception::AlibException("Unrecognised CNF token."); + throw exception::CommonException("Unrecognised CNF token."); } return parseCFLikeGrammar<CNF>(input); @@ -533,7 +533,7 @@ CNF GrammarFromStringParser::parseCNF(std::istream& input) const { NonContractingGrammar GrammarFromStringParser::parseNonContractingGrammar(std::istream& input) const { GrammarFromStringLexer::Token token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::NON_CONTRACTING_GRAMMAR) { - throw exception::AlibException("Unrecognised NonContractingGrammar token."); + throw exception::CommonException("Unrecognised NonContractingGrammar token."); } return parseCSLikeGrammar<NonContractingGrammar>(input); @@ -542,7 +542,7 @@ NonContractingGrammar GrammarFromStringParser::parseNonContractingGrammar(std::i CSG GrammarFromStringParser::parseCSG(std::istream& input) const { GrammarFromStringLexer::Token token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::CSG) { - throw exception::AlibException("Unrecognised CSG token."); + throw exception::CommonException("Unrecognised CSG token."); } return parsePreservingCSLikeGrammar<CSG>(input); @@ -551,7 +551,7 @@ CSG GrammarFromStringParser::parseCSG(std::istream& input) const { ContextPreservingUnrestrictedGrammar GrammarFromStringParser::parseContextPreservingUnrestrictedGrammar(std::istream& input) const { GrammarFromStringLexer::Token token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::CONTEXT_PRESERVING_UNRESTRICTED_GRAMMAR) { - throw exception::AlibException("Unrecognised ContextPreservingUnrestrictedGrammar token."); + throw exception::CommonException("Unrecognised ContextPreservingUnrestrictedGrammar token."); } return parsePreservingCSLikeGrammar<ContextPreservingUnrestrictedGrammar>(input); @@ -560,7 +560,7 @@ ContextPreservingUnrestrictedGrammar GrammarFromStringParser::parseContextPreser UnrestrictedGrammar GrammarFromStringParser::parseUnrestrictedGrammar(std::istream& input) const { GrammarFromStringLexer::Token token = m_GrammarLexer.next(input); if(token.type != GrammarFromStringLexer::TokenType::UNRESTRICTED_GRAMMAR) { - throw exception::AlibException("Unrecognised UnrestrictedGrammar token."); + throw exception::CommonException("Unrecognised UnrestrictedGrammar token."); } return parseCSLikeGrammar<UnrestrictedGrammar>(input); diff --git a/alib2str/src/graph/GraphFromStringParser.cpp b/alib2str/src/graph/GraphFromStringParser.cpp index 9f5f146a72661ae5f2138288399f08fbd603b9b9..279630e4e5ccb3a8eaeaa79a5c32508327b965bb 100644 --- a/alib2str/src/graph/GraphFromStringParser.cpp +++ b/alib2str/src/graph/GraphFromStringParser.cpp @@ -6,7 +6,7 @@ */ #include "GraphFromStringParser.h" -#include "exception/AlibException.h" +#include "exception/CommonException.h" #include "graph/GraphClasses.h" #include "../StringApi.hpp" @@ -17,7 +17,7 @@ Graph GraphFromStringParser::parseGraph(std::istream &input) const { GraphFromStringLexer::Token token = lexer.next(input); if (token.type != GraphFromStringLexer::TokenType::LPAR) { - throw exception::AlibException("Invalid input. Expected LPAR"); + throw exception::CommonException("Invalid input. Expected LPAR"); } const std::string &str = lexer.getString(input); @@ -26,7 +26,7 @@ Graph GraphFromStringParser::parseGraph(std::istream &input) const Graph graph{parseDirectedGraph(input)}; if (lexer.next(input).type != GraphFromStringLexer::TokenType::RPAR) { - throw exception::AlibException("Invalid input. Expected RPAR"); + throw exception::CommonException("Invalid input. Expected RPAR"); } return graph; } else if (str == "UndirectedGraph") { @@ -34,12 +34,12 @@ Graph GraphFromStringParser::parseGraph(std::istream &input) const Graph graph{parseUndirectedGraph(input)}; if (lexer.next(input).type != GraphFromStringLexer::TokenType::RPAR) { - throw exception::AlibException("Invalid input. Expected RPAR"); + throw exception::CommonException("Invalid input. Expected RPAR"); } return graph; } - throw exception::AlibException("Invalid graph type"); + throw exception::CommonException("Invalid graph type"); } DirectedGraph GraphFromStringParser::parseDirectedGraph(std::istream &input) const @@ -74,7 +74,7 @@ REPRESENTATION GraphFromStringParser::parseRepresentation(std::istream &input) c { std::string representation = lexer.getString(input); if (representation.empty()) { - throw exception::AlibException("Invalid representation"); + throw exception::CommonException("Invalid representation"); } return representationFromString(representation); } @@ -168,7 +168,7 @@ void GraphFromStringParser::parseDelimiter(std::istream &input) const { GraphFromStringLexer::Token token = lexer.next(input); if (token.type != GraphFromStringLexer::TokenType::COLON) { - throw exception::AlibException("Invalid input. Expected COLON"); + throw exception::CommonException("Invalid input. Expected COLON"); } } @@ -176,12 +176,12 @@ int GraphFromStringParser::parseValue(std::istream &input) const { GraphFromStringLexer::Token token = lexer.next(input); if (token.type != GraphFromStringLexer::TokenType::EQUAL) { - throw exception::AlibException("Invalid input. Expected EQUAL"); + throw exception::CommonException("Invalid input. Expected EQUAL"); } token = lexer.next(input); if (token.type != GraphFromStringLexer::TokenType::INTEGER) { - throw exception::AlibException("Invalid input. Expected INTEGER"); + throw exception::CommonException("Invalid input. Expected INTEGER"); } return std::stoi(token.value); diff --git a/alib2str/src/label/LabelFromStringParser.cpp b/alib2str/src/label/LabelFromStringParser.cpp index 33df133ca1a77e43b179afce8f6bb95075426da2..68095dd4fccad0f67d93f6765df12741f305f717 100644 --- a/alib2str/src/label/LabelFromStringParser.cpp +++ b/alib2str/src/label/LabelFromStringParser.cpp @@ -6,7 +6,7 @@ */ #include "LabelFromStringParser.h" -#include "exception/AlibException.h" +#include "exception/CommonException.h" #include "label/PrimitiveLabel.h" #include "label/ObjectLabel.h" #include "label/LabelSetLabel.h" @@ -24,9 +24,9 @@ Label LabelFromStringParser::parseLabel(std::istream& input, const std::set<FEAT LabelFromStringLexer::Token token = m_Lexer.next(input); switch(token.type) { case LabelFromStringLexer::TokenType::TEOF: - throw exception::AlibException("Unexpected end of file"); + throw exception::CommonException("Unexpected end of file"); case LabelFromStringLexer::TokenType::SET_BEGIN: { - if(!features.count(FEATURES::LABEL_SET)) throw exception::AlibException(); + if(!features.count(FEATURES::LABEL_SET)) throw exception::CommonException("Diabled formalism LabelSet"); token = m_Lexer.next(input); std::set<Label> labelSet; @@ -43,38 +43,38 @@ Label LabelFromStringParser::parseLabel(std::istream& input, const std::set<FEAT } if(token.type != LabelFromStringLexer::TokenType::SET_END) - throw exception::AlibException("Expected SET_END token."); + throw exception::CommonException("Expected SET_END token."); return Label(label::LabelSetLabel(labelSet)); } case LabelFromStringLexer::TokenType::PAIR_BEGIN: { - if(!features.count(FEATURES::LABEL_PAIR)) throw exception::AlibException(); + if(!features.count(FEATURES::LABEL_PAIR)) throw exception::CommonException("Diabled formalism LabelPair"); Label firstLabel = this->parseLabel(input); token = m_Lexer.next(input); if(token.type != LabelFromStringLexer::TokenType::COMMA) - throw exception::AlibException("Excepted COMMA token."); + throw exception::CommonException("Excepted COMMA token."); Label secondLabel = this->parseLabel(input); token = m_Lexer.next(input); if(token.type != LabelFromStringLexer::TokenType::PAIR_END) - throw exception::AlibException("Expected PAIR_END token."); + throw exception::CommonException("Expected PAIR_END token."); return Label(label::LabelPairLabel(std::make_pair(firstLabel, secondLabel))); } case LabelFromStringLexer::TokenType::SET_END: - throw exception::AlibException("Unexpected start of Label SET_END."); + throw exception::CommonException("Unexpected start of Label SET_END."); case LabelFromStringLexer::TokenType::PAIR_END: - throw exception::AlibException("Unexpected start of Label PAIR_END."); + throw exception::CommonException("Unexpected start of Label PAIR_END."); case LabelFromStringLexer::TokenType::COMMA: - throw exception::AlibException("Unexpected start of Label COMMA."); + throw exception::CommonException("Unexpected start of Label COMMA."); case LabelFromStringLexer::TokenType::ERROR: - if(!features.count(FEATURES::PRIMITIVE)) throw exception::AlibException(); + if(!features.count(FEATURES::PRIMITIVE)) throw exception::CommonException("Disabled formalism PrimitiveLabel"); m_Lexer.putback(input, token); return Label(PrimitiveLabel(alib::stringApi<primitive::Primitive>::parse(input))); } - throw exception::AlibException("Unrecognised input \"" + token.value + "\""); + throw exception::CommonException("Unrecognised input \"" + token.value + "\""); } } /* namespace label */ diff --git a/alib2str/src/primitive/PrimitiveFromStringParser.cpp b/alib2str/src/primitive/PrimitiveFromStringParser.cpp index 10be4244d6b54176c05fdf90abf804c5843b1ed8..ac0625f4790b25286dbdda8ba611ea205649c8c9 100644 --- a/alib2str/src/primitive/PrimitiveFromStringParser.cpp +++ b/alib2str/src/primitive/PrimitiveFromStringParser.cpp @@ -6,7 +6,7 @@ */ #include "PrimitiveFromStringParser.h" -#include "exception/AlibException.h" +#include "exception/CommonException.h" #include "primitive/Primitive.h" #include "primitive/String.h" #include "primitive/Integer.h" @@ -22,20 +22,20 @@ Primitive PrimitiveFromStringParser::parsePrimitive(std::istream& input, const s PrimitiveFromStringLexer::Token token = m_Lexer.next(input); switch(token.type) { case PrimitiveFromStringLexer::TokenType::TEOF: - throw exception::AlibException("Unexpected end of file"); + throw exception::CommonException("Unexpected end of file"); case PrimitiveFromStringLexer::TokenType::STRING: - if(!features.count(FEATURES::STRING)) throw exception::AlibException(); + if(!features.count(FEATURES::STRING)) throw exception::CommonException("Disabled formalism String"); return Primitive(String(token.value)); case PrimitiveFromStringLexer::TokenType::CHAR: - if(!features.count(FEATURES::CHAR)) throw exception::AlibException(); + if(!features.count(FEATURES::CHAR)) throw exception::CommonException("Disabled formalism Char"); return Primitive(Character(token.value[0])); case PrimitiveFromStringLexer::TokenType::INTEGER: - if(!features.count(FEATURES::INTEGER)) throw exception::AlibException(); + if(!features.count(FEATURES::INTEGER)) throw exception::CommonException("Disabled formalism Integer"); return Primitive(Integer(std::stoi(token.value))); case PrimitiveFromStringLexer::TokenType::ERROR: break; } - throw exception::AlibException("Unrecognised input \"" + token.value + "...\""); + throw exception::CommonException("Unrecognised input \"" + token.value + "...\""); } } /* namespace primitive */ diff --git a/alib2str/src/regexp/RegExpFromStringParser.cpp b/alib2str/src/regexp/RegExpFromStringParser.cpp index b9da3e064ed78da7cda3d39d3587114413136e41..11f7f6354d223a7ae01ba3068f7cd6d43d8252d7 100644 --- a/alib2str/src/regexp/RegExpFromStringParser.cpp +++ b/alib2str/src/regexp/RegExpFromStringParser.cpp @@ -6,7 +6,7 @@ */ #include "RegExpFromStringParser.h" -#include "exception/AlibException.h" +#include "exception/CommonException.h" #include "regexp/RegExpClasses.h" #include "regexp/unbounded/UnboundedRegExpElements.h" @@ -28,7 +28,7 @@ RegExp RegExpFromStringParser::parseRegExp(std::istream& input, const std::set<F if(features.count(FEATURES::FORMAL)) return RegExp{FormalRegExp{regexp}}; - throw exception::AlibException("Invalid input"); + throw exception::CommonException("Invalid input"); } UnboundedRegExpElement* RegExpFromStringParser::alternation(std::istream& input) const { @@ -131,7 +131,7 @@ UnboundedRegExpElement* RegExpFromStringParser::factor(std::istream& input) cons if(token.type == RegExpFromStringLexer::TokenType::LPAR) { UnboundedRegExpElement* base = this->alternation(input); token = m_RegexpLexer.next(input); - if(token.type != RegExpFromStringLexer::TokenType::RPAR) throw exception::AlibException("Expected RPAR"); + if(token.type != RegExpFromStringLexer::TokenType::RPAR) throw exception::CommonException("Expected RPAR"); return this->star(input, base); } else if(token.type == RegExpFromStringLexer::TokenType::EPS) { return this->star(input, new UnboundedRegExpEpsilon()); @@ -141,7 +141,7 @@ UnboundedRegExpElement* RegExpFromStringParser::factor(std::istream& input) cons UnboundedRegExpSymbol* res = new UnboundedRegExpSymbol(alib::stringApi<alphabet::Symbol>::parse(input)); return this->star(input, res); } else { - throw exception::AlibException("Unrecognised token at factor rule"); + throw exception::CommonException("Unrecognised token at factor rule"); } } diff --git a/alib2str/src/string/StringFromStringParser.cpp b/alib2str/src/string/StringFromStringParser.cpp index ae36090094c363f590ba2c1ec51dabdcc2153e9c..6f76309befc23286e4aceea13e40443bc172e7dc 100644 --- a/alib2str/src/string/StringFromStringParser.cpp +++ b/alib2str/src/string/StringFromStringParser.cpp @@ -6,7 +6,7 @@ */ #include "StringFromStringParser.h" -#include "exception/AlibException.h" +#include "exception/CommonException.h" #include "string/StringClasses.h" #include <vector> @@ -21,28 +21,28 @@ String StringFromStringParser::parseString(std::istream& input) const { String StringFromStringParser::parseString(std::istream& input, const std::set<FEATURES>& features) const { StringFromStringLexer::Token token = m_StringLexer.next(input); if(token.type == StringFromStringLexer::TokenType::EPSILON) { - if(!features.count(FEATURES::EPSILON)) throw exception::AlibException(); + if(!features.count(FEATURES::EPSILON)) throw exception::CommonException("Disabled formalism Epsilon"); return String(Epsilon()); } else if(token.type == StringFromStringLexer::TokenType::LESS) { - if(!features.count(FEATURES::CYCLIC)) throw exception::AlibException(); + if(!features.count(FEATURES::CYCLIC)) throw exception::CommonException("Disabled formalism CyclicString"); std::vector<alphabet::Symbol> data = parseContent(input); token = m_StringLexer.next(input); if(token.type == StringFromStringLexer::TokenType::GREATER) { return String(CyclicString(data)); } else { - throw exception::AlibException("Invalid cyclic string terminating character"); + throw exception::CommonException("Invalid cyclic string terminating character"); } } else if(token.type == StringFromStringLexer::TokenType::QUOTE) { - if(!features.count(FEATURES::LINEAR)) throw exception::AlibException(); + if(!features.count(FEATURES::LINEAR)) throw exception::CommonException("Disabled formalism LinearString"); std::vector<alphabet::Symbol> data = parseContent(input); token = m_StringLexer.next(input); if(token.type == StringFromStringLexer::TokenType::QUOTE) { return String(LinearString(data)); } else { - throw exception::AlibException("Invalid linear string terminating character"); + throw exception::CommonException("Invalid linear string terminating character"); } } else { - throw exception::AlibException(); + throw exception::CommonException("Formalism not recognised (token = \"" + token.value + "\")"); } } diff --git a/alib2str/src/tree/TreeFromStringParser.cpp b/alib2str/src/tree/TreeFromStringParser.cpp index bdda346bebd1ee2db85176129ef8048a32921255..184718f16867ea67321b844efdb705530dfe4dd2 100644 --- a/alib2str/src/tree/TreeFromStringParser.cpp +++ b/alib2str/src/tree/TreeFromStringParser.cpp @@ -6,7 +6,7 @@ */ #include "TreeFromStringParser.h" -#include "exception/AlibException.h" +#include "exception/CommonException.h" #include "tree/TreeClasses.h" #include "../StringApi.hpp" @@ -91,7 +91,7 @@ Tree TreeFromStringParser::parseTree ( std::istream & input, const std::set < FE } if ( token.type != TreeFromStringLexer::TokenType::BAR ) - throw exception::AlibException ( "Missing bar" ); + throw exception::CommonException ( "Missing bar" ); if ( isPattern && nonlinearVariables.size ( ) ) { alphabet::Symbol subtreeWildcard ( alphabet::SubtreeWildcardSymbol::SUBTREE_WILDCARD ); @@ -110,7 +110,7 @@ Tree TreeFromStringParser::parseTree ( std::istream & input, const std::set < FE } } - throw exception::AlibException ( "Invalid input" ); + throw exception::CommonException ( "Invalid input" ); } } @@ -138,7 +138,7 @@ tree::RankedNode * TreeFromStringParser::parseRankedContent ( std::istream & inp if ( token.type == TreeFromStringLexer::TokenType::RANK ) rank = std::stou ( token.value ); else - throw exception::AlibException ( "Missing rank" ); + throw exception::CommonException ( "Missing rank" ); for ( unsigned i = 0; i < rank; i++ ) childs.push_back ( parseRankedContent ( input, isPattern, nonlinearVariables ) ); @@ -154,7 +154,7 @@ tree::UnrankedNode * TreeFromStringParser::parseUnrankedContent ( std::istream & token = m_TreeLexer.next ( input ); if ( token.type != TreeFromStringLexer::TokenType::BAR ) - throw exception::AlibException ( "Missing bar" ); + throw exception::CommonException ( "Missing bar" ); isPattern = true; alphabet::Symbol subtreeWildcard ( alphabet::SubtreeWildcardSymbol::SUBTREE_WILDCARD ); @@ -163,7 +163,7 @@ tree::UnrankedNode * TreeFromStringParser::parseUnrankedContent ( std::istream & token = m_TreeLexer.next ( input ); if ( token.type != TreeFromStringLexer::TokenType::BAR ) - throw exception::AlibException ( "Missing bar" ); + throw exception::CommonException ( "Missing bar" ); isPattern = true; alphabet::Symbol nonlinearVariable ( alphabet::NonlinearVariableSymbol ( alphabet::symbolFrom ( token.value ) ) ); @@ -184,7 +184,7 @@ tree::UnrankedNode * TreeFromStringParser::parseUnrankedContent ( std::istream & } if ( token.type != TreeFromStringLexer::TokenType::BAR ) - throw exception::AlibException ( "Missing bar" ); + throw exception::CommonException ( "Missing bar" ); return new UnrankedNode ( std::move ( symbol ), std::move ( childs ) ); }