From 38eb8f323cca2299adb710bb8b0c770647acbbae Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Thu, 1 Sep 2016 18:37:48 +0200 Subject: [PATCH] templated epsilon --- aconvert2/src/DotConverter.cpp | 22 ++-- aconvert2/src/GasTexConverter.cpp | 22 ++-- aconvert2/src/TikZConverter.cpp | 22 ++-- .../determinize/DeterminizeRHDPDAPart.cxx | 44 ++++---- .../determinize/common/RHDPDACommon.cpp | 18 ++-- .../determinize/common/RHDPDACommon.h | 4 +- .../automaton/properties/EpsilonClosure.cpp | 2 +- alib2algo/src/automaton/run/Run.cpp | 14 +-- .../src/automaton/simplify/Normalize.cpp | 4 +- .../src/automaton/transform/RHPDAToPDA.cpp | 12 +-- .../parsing/DeterministicLL1Grammar.cpp | 14 +-- .../parsing/DeterministicLL1ParseTable.cpp | 8 +- .../parsing/DeterministicLL1ParseTable.h | 2 +- alib2algo/src/grammar/parsing/First.cpp | 36 +++---- alib2algo/src/grammar/parsing/First.h | 8 +- alib2algo/src/grammar/parsing/Follow.cpp | 22 ++-- alib2algo/src/grammar/parsing/Follow.h | 6 +- .../src/grammar/parsing/LL1ParseTable.cpp | 38 +++---- alib2algo/src/grammar/parsing/LL1ParseTable.h | 6 +- .../src/grammar/parsing/SLR1ParseTable.cpp | 2 +- .../regexp/convert/ToAutomatonThompson.cpp | 36 +++---- alib2algo/src/string/naive/ExactCompare.cpp | 4 +- alib2algo/src/string/naive/ExactCompare.h | 2 +- alib2algo/src/string/naive/ExactEqual.cpp | 4 +- alib2algo/src/string/naive/ExactEqual.h | 2 +- .../test-src/grammar/parsing/FirstTest.cpp | 58 +++++----- .../test-src/grammar/parsing/FollowTest.cpp | 42 ++++---- .../grammar/parsing/LL1ParseTable.cpp | 8 +- alib2data/src/automaton/AutomatonFeatures.h | 2 +- alib2data/src/automaton/FSM/CompactNFA.h | 3 +- alib2data/src/automaton/FSM/ExtendedNFA.cpp | 2 +- alib2data/src/automaton/PDA/DPDA.cpp | 44 ++++---- alib2data/src/automaton/PDA/DPDA.h | 18 ++-- alib2data/src/automaton/PDA/NPDA.cpp | 20 ++-- alib2data/src/automaton/PDA/NPDA.h | 14 +-- alib2data/src/automaton/PDA/NPDTA.cpp | 24 ++--- alib2data/src/automaton/PDA/NPDTA.h | 18 ++-- .../PDA/RealTimeHeightDeterministicDPDA.cpp | 84 +++++++-------- .../PDA/RealTimeHeightDeterministicDPDA.h | 40 +++---- .../PDA/RealTimeHeightDeterministicNPDA.cpp | 60 +++++------ .../PDA/RealTimeHeightDeterministicNPDA.h | 40 +++---- alib2data/src/automaton/PDA/SinglePopDPDA.cpp | 30 +++--- alib2data/src/automaton/PDA/SinglePopDPDA.h | 14 +-- alib2data/src/automaton/PDA/SinglePopNPDA.cpp | 20 ++-- alib2data/src/automaton/PDA/SinglePopNPDA.h | 14 +-- alib2data/src/string/CyclicString.cpp | 8 +- alib2data/src/string/CyclicString.h | 4 +- alib2data/src/string/Epsilon.cpp | 63 +---------- alib2data/src/string/Epsilon.h | 100 +++++++++++++++--- alib2data/src/string/LinearString.cpp | 8 +- alib2data/src/string/LinearString.h | 4 +- .../string/LinearStringTerminatingSymbol.cpp | 4 +- alib2data/src/string/StringFeatures.h | 3 + .../src/string/common/StringFromXMLParser.cpp | 34 ------ .../src/string/common/StringFromXMLParser.h | 31 +++++- .../src/string/common/StringToXMLComposer.cpp | 29 ----- .../src/string/common/StringToXMLComposer.h | 26 ++++- alib2data/test-src/string/StringTest.cpp | 28 ++--- .../automaton/AutomatonFromStringParser.cpp | 16 +-- .../src/automaton/AutomatonFromStringParser.h | 2 +- .../src/string/StringFromStringParser.cpp | 2 +- .../src/string/StringToStringComposer.cpp | 4 +- alib2str/src/string/StringToStringComposer.h | 2 +- 63 files changed, 636 insertions(+), 641 deletions(-) delete mode 100644 alib2data/src/string/common/StringFromXMLParser.cpp delete mode 100644 alib2data/src/string/common/StringToXMLComposer.cpp diff --git a/aconvert2/src/DotConverter.cpp b/aconvert2/src/DotConverter.cpp index f3f5d3127b..03bc851d81 100644 --- a/aconvert2/src/DotConverter.cpp +++ b/aconvert2/src/DotConverter.cpp @@ -681,7 +681,7 @@ void DotConverter::transitions(const automaton::EpsilonNFA < > & fsm, const std: //put transitions from automaton to "transitions" for (const auto& transition : fsm.getTransitions()) { std::string symbol; - if (transition.first.second.is<string::Epsilon>()) { + if (transition.first.second.is<string::Epsilon < >>()) { symbol = "ε"; } else { symbol = alib::StringDataFactory::toString(std::get<1>(transition.first).get<alphabet::Symbol>()); @@ -989,7 +989,7 @@ void DotConverter::transitions(const automaton::DPDA& pda, const std::map<label: std::string symbol; //input symbol - if (std::get<1>(transition.first).is<string::Epsilon>()) { + if (std::get<1>(transition.first).is<string::Epsilon < >>()) { symbol = "ε"; } else { symbol = alib::StringDataFactory::toString(std::get<1>(transition.first).get<alphabet::Symbol>()); @@ -1052,7 +1052,7 @@ void DotConverter::transitions(const automaton::SinglePopDPDA& pda, const std::m std::string symbol; //input symbol - if (std::get<1>(transition.first).is<string::Epsilon>()) { + if (std::get<1>(transition.first).is<string::Epsilon < >>()) { symbol = "ε"; } else { symbol = alib::StringDataFactory::toString(std::get<1>(transition.first).get<alphabet::Symbol>()); @@ -1465,7 +1465,7 @@ void DotConverter::transitions(const automaton::RealTimeHeightDeterministicDPDA& std::string symbol; //input symbol - if(transition.first.second.is<string::Epsilon>()) + if(transition.first.second.is<string::Epsilon < >>()) symbol = "&epsilon"; else symbol = alib::StringDataFactory::toString(transition.first.second.get<alphabet::Symbol>()); @@ -1500,7 +1500,7 @@ void DotConverter::transitions(const automaton::RealTimeHeightDeterministicDPDA& std::string symbol; //input symbol - if(std::get<1>(transition.first).is<string::Epsilon>()) + if(std::get<1>(transition.first).is<string::Epsilon < >>()) symbol = "&epsilon"; else symbol = alib::StringDataFactory::toString(std::get<1>(transition.first).get<alphabet::Symbol>()); @@ -1535,7 +1535,7 @@ void DotConverter::transitions(const automaton::RealTimeHeightDeterministicDPDA& std::string symbol; //input symbol - if(transition.first.second.is<string::Epsilon>()) + if(transition.first.second.is<string::Epsilon < >>()) symbol = "&epsilon"; else symbol = alib::StringDataFactory::toString(transition.first.second.get<alphabet::Symbol>()); @@ -1581,7 +1581,7 @@ void DotConverter::transitions(const automaton::RealTimeHeightDeterministicNPDA& std::string symbol; //input symbol - if(transition.first.second.is<string::Epsilon>()) + if(transition.first.second.is<string::Epsilon < >>()) symbol = "&epsilon"; else symbol = alib::StringDataFactory::toString(transition.first.second.get<alphabet::Symbol>()); @@ -1620,7 +1620,7 @@ void DotConverter::transitions(const automaton::RealTimeHeightDeterministicNPDA& std::string symbol; //input symbol - if(std::get<1>(transition.first).is<string::Epsilon>()) + if(std::get<1>(transition.first).is<string::Epsilon < >>()) symbol = "ε"; else symbol = alib::StringDataFactory::toString(std::get<1>(transition.first).get<alphabet::Symbol>()); @@ -1659,7 +1659,7 @@ void DotConverter::transitions(const automaton::RealTimeHeightDeterministicNPDA& std::string symbol; //input symbol - if(transition.first.second.is<string::Epsilon>()) + if(transition.first.second.is<string::Epsilon < >>()) symbol = "ε"; else symbol = alib::StringDataFactory::toString(transition.first.second.get<alphabet::Symbol>()); @@ -1709,7 +1709,7 @@ void DotConverter::transitions(const automaton::NPDA& pda, const std::map<label: std::string symbol; //input symbol - if (std::get<1>(transition.first).is<string::Epsilon>()) { + if (std::get<1>(transition.first).is<string::Epsilon < >>()) { symbol = "ε"; } else { symbol = alib::StringDataFactory::toString(std::get<1>(transition.first).get<alphabet::Symbol>()); @@ -1776,7 +1776,7 @@ void DotConverter::transitions(const automaton::SinglePopNPDA& pda, const std::m std::string symbol; //input symbol - if (std::get<1>(transition.first).is<string::Epsilon>()) { + if (std::get<1>(transition.first).is<string::Epsilon < >>()) { symbol = "ε"; } else { symbol = alib::StringDataFactory::toString(std::get<1>(transition.first).get<alphabet::Symbol>()); diff --git a/aconvert2/src/GasTexConverter.cpp b/aconvert2/src/GasTexConverter.cpp index 171da4461f..c2f719a95a 100644 --- a/aconvert2/src/GasTexConverter.cpp +++ b/aconvert2/src/GasTexConverter.cpp @@ -795,7 +795,7 @@ void GasTexConverter::transitions(const automaton::EpsilonNFA < > & fsm, std::os std::pair<std::string, std::string> key((std::string) transition.first.first, (std::string) to); std::string symbol; - if (transition.first.second.is<string::Epsilon>()) { + if (transition.first.second.is<string::Epsilon < >>()) { symbol = "$\\varepsilon$"; } else { symbol = (std::string) transition.first.second.get<alphabet::Symbol>(); @@ -923,7 +923,7 @@ void GasTexConverter::transitions(const automaton::DPDA& pda, std::ostream& out) auto mapIterator = transitionMap.find(key); std::string symbol; - if (std::get<1>(transition.first).is<string::Epsilon>()) { + if (std::get<1>(transition.first).is<string::Epsilon < >>()) { symbol = "$\\varepsilon;$"; } else { symbol = alib::StringDataFactory::toString(std::get<1>(transition.first).get<alphabet::Symbol>()); @@ -953,7 +953,7 @@ void GasTexConverter::transitions(const automaton::SinglePopDPDA& pda, std::ostr auto mapIterator = transitionMap.find(key); std::string symbol; - if (std::get<1>(transition.first).is<string::Epsilon>()) { + if (std::get<1>(transition.first).is<string::Epsilon < >>()) { symbol = "$\\varepsilon;$"; } else { symbol = alib::StringDataFactory::toString(std::get<1>(transition.first).get<alphabet::Symbol>()); @@ -1182,7 +1182,7 @@ void GasTexConverter::transitions(const automaton::RealTimeHeightDeterministicDP auto mapIterator = transitionMap.find(key); std::string symbol; - if(transition.first.second.is<string::Epsilon>()) + if(transition.first.second.is<string::Epsilon < >>()) symbol = "$\\varepsilon;$"; else symbol = alib::StringDataFactory::toString(transition.first.second.get<alphabet::Symbol>()); @@ -1205,7 +1205,7 @@ void GasTexConverter::transitions(const automaton::RealTimeHeightDeterministicDP auto mapIterator = transitionMap.find(key); std::string symbol; - if(std::get<1>(transition.first).is<string::Epsilon>()) + if(std::get<1>(transition.first).is<string::Epsilon < >>()) symbol = "$\\varepsilon;$"; else symbol = alib::StringDataFactory::toString(std::get<1>(transition.first).get<alphabet::Symbol>()); @@ -1228,7 +1228,7 @@ void GasTexConverter::transitions(const automaton::RealTimeHeightDeterministicDP auto mapIterator = transitionMap.find(key); std::string symbol; - if(transition.first.second.is<string::Epsilon>()) + if(transition.first.second.is<string::Epsilon < >>()) symbol = "$\\varepsilon;$"; else symbol = alib::StringDataFactory::toString(transition.first.second.get<alphabet::Symbol>()); @@ -1258,7 +1258,7 @@ void GasTexConverter::transitions(const automaton::RealTimeHeightDeterministicNP auto mapIterator = transitionMap.find(key); std::string symbol; - if(transition.first.second.is<string::Epsilon>()) + if(transition.first.second.is<string::Epsilon < >>()) symbol = "$\\varepsilon;$"; else symbol = alib::StringDataFactory::toString(transition.first.second.get<alphabet::Symbol>()); @@ -1283,7 +1283,7 @@ void GasTexConverter::transitions(const automaton::RealTimeHeightDeterministicNP auto mapIterator = transitionMap.find(key); std::string symbol; - if(std::get<1>(transition.first).is<string::Epsilon>()) + if(std::get<1>(transition.first).is<string::Epsilon < >>()) symbol = "$\\varepsilon;$"; else symbol = alib::StringDataFactory::toString(std::get<1>(transition.first).get<alphabet::Symbol>()); @@ -1308,7 +1308,7 @@ void GasTexConverter::transitions(const automaton::RealTimeHeightDeterministicNP auto mapIterator = transitionMap.find(key); std::string symbol; - if(transition.first.second.is<string::Epsilon>()) + if(transition.first.second.is<string::Epsilon < >>()) symbol = "$\\varepsilon;$"; else symbol = alib::StringDataFactory::toString(transition.first.second.get<alphabet::Symbol>()); @@ -1339,7 +1339,7 @@ void GasTexConverter::transitions(const automaton::NPDA& pda, std::ostream& out) auto mapIterator = transitionMap.find(key); std::string symbol; - if (std::get<1>(transition.first).is<string::Epsilon>()) { + if (std::get<1>(transition.first).is<string::Epsilon < >>()) { symbol = "$\\varepsilon;$"; } else { symbol = alib::StringDataFactory::toString(std::get<1>(transition.first).get<alphabet::Symbol>()); @@ -1371,7 +1371,7 @@ void GasTexConverter::transitions(const automaton::SinglePopNPDA& pda, std::ostr auto mapIterator = transitionMap.find(key); std::string symbol; - if (std::get<1>(transition.first).is<string::Epsilon>()) { + if (std::get<1>(transition.first).is<string::Epsilon < >>()) { symbol = "$\\varepsilon;$"; } else { symbol = alib::StringDataFactory::toString(std::get<1>(transition.first).get<alphabet::Symbol>()); diff --git a/aconvert2/src/TikZConverter.cpp b/aconvert2/src/TikZConverter.cpp index 7fe94c188f..deb7781968 100644 --- a/aconvert2/src/TikZConverter.cpp +++ b/aconvert2/src/TikZConverter.cpp @@ -603,7 +603,7 @@ void TikZConverter::transitions ( const automaton::EpsilonNFA < > & fsm, const s for ( const auto & transition : fsm.getTransitions ( ) ) { std::string symbol; - if ( transition.first.second.is < string::Epsilon > ( ) ) + if ( transition.first.second.is < string::Epsilon < > > ( ) ) symbol = "ε"; else symbol = alib::StringDataFactory::toString ( std::get < 1 > ( transition.first ).get < alphabet::Symbol > ( ) ); @@ -986,7 +986,7 @@ void TikZConverter::transitions ( const automaton::DPDA & pda, const std::map < std::string symbol; // input symbol - if ( std::get < 1 > ( transition.first ).is < string::Epsilon > ( ) ) + if ( std::get < 1 > ( transition.first ).is < string::Epsilon < > > ( ) ) symbol = "ε"; else symbol = alib::StringDataFactory::toString ( std::get < 1 > ( transition.first ).get < alphabet::Symbol > ( ) ); @@ -1050,7 +1050,7 @@ void TikZConverter::transitions ( const automaton::SinglePopDPDA & pda, const st std::string symbol; // input symbol - if ( std::get < 1 > ( transition.first ).is < string::Epsilon > ( ) ) + if ( std::get < 1 > ( transition.first ).is < string::Epsilon < > > ( ) ) symbol = "ε"; else symbol = alib::StringDataFactory::toString ( std::get < 1 > ( transition.first ).get < alphabet::Symbol > ( ) ); @@ -1511,7 +1511,7 @@ void TikZConverter::transitions ( const automaton::RealTimeHeightDeterministicDP std::string symbol; // input symbol - if ( transition.first.second.is < string::Epsilon > ( ) ) + if ( transition.first.second.is < string::Epsilon < > > ( ) ) symbol = "&epsilon"; else symbol = alib::StringDataFactory::toString ( transition.first.second.get < alphabet::Symbol > ( ) ); @@ -1550,7 +1550,7 @@ void TikZConverter::transitions ( const automaton::RealTimeHeightDeterministicDP std::string symbol; // input symbol - if ( std::get < 1 > ( transition.first ).is < string::Epsilon > ( ) ) + if ( std::get < 1 > ( transition.first ).is < string::Epsilon < > > ( ) ) symbol = "&epsilon"; else symbol = alib::StringDataFactory::toString ( std::get < 1 > ( transition.first ).get < alphabet::Symbol > ( ) ); @@ -1589,7 +1589,7 @@ void TikZConverter::transitions ( const automaton::RealTimeHeightDeterministicDP std::string symbol; // input symbol - if ( transition.first.second.is < string::Epsilon > ( ) ) + if ( transition.first.second.is < string::Epsilon < > > ( ) ) symbol = "&epsilon"; else symbol = alib::StringDataFactory::toString ( transition.first.second.get < alphabet::Symbol > ( ) ); @@ -1643,7 +1643,7 @@ void TikZConverter::transitions ( const automaton::RealTimeHeightDeterministicNP std::string symbol; // input symbol - if ( transition.first.second.is < string::Epsilon > ( ) ) + if ( transition.first.second.is < string::Epsilon < > > ( ) ) symbol = "&epsilon"; else symbol = alib::StringDataFactory::toString ( transition.first.second.get < alphabet::Symbol > ( ) ); @@ -1687,7 +1687,7 @@ void TikZConverter::transitions ( const automaton::RealTimeHeightDeterministicNP std::string symbol; // input symbol - if ( std::get < 1 > ( transition.first ).is < string::Epsilon > ( ) ) + if ( std::get < 1 > ( transition.first ).is < string::Epsilon < > > ( ) ) symbol = "ε"; else symbol = alib::StringDataFactory::toString ( std::get < 1 > ( transition.first ).get < alphabet::Symbol > ( ) ); @@ -1731,7 +1731,7 @@ void TikZConverter::transitions ( const automaton::RealTimeHeightDeterministicNP std::string symbol; // input symbol - if ( transition.first.second.is < string::Epsilon > ( ) ) + if ( transition.first.second.is < string::Epsilon < > > ( ) ) symbol = "ε"; else symbol = alib::StringDataFactory::toString ( transition.first.second.get < alphabet::Symbol > ( ) ); @@ -1790,7 +1790,7 @@ void TikZConverter::transitions ( const automaton::NPDA & pda, const std::map < std::string symbol; // input symbol - if ( std::get < 1 > ( transition.first ).is < string::Epsilon > ( ) ) + if ( std::get < 1 > ( transition.first ).is < string::Epsilon < > > ( ) ) symbol = "ε"; else symbol = alib::StringDataFactory::toString ( std::get < 1 > ( transition.first ).get < alphabet::Symbol > ( ) ); @@ -1860,7 +1860,7 @@ void TikZConverter::transitions ( const automaton::SinglePopNPDA & pda, const st std::string symbol; // input symbol - if ( std::get < 1 > ( transition.first ).is < string::Epsilon > ( ) ) + if ( std::get < 1 > ( transition.first ).is < string::Epsilon < > > ( ) ) symbol = "ε"; else symbol = alib::StringDataFactory::toString ( std::get < 1 > ( transition.first ).get < alphabet::Symbol > ( ) ); diff --git a/alib2algo/src/automaton/determinize/DeterminizeRHDPDAPart.cxx b/alib2algo/src/automaton/determinize/DeterminizeRHDPDAPart.cxx index dc91deeaeb..3487eff259 100644 --- a/alib2algo/src/automaton/determinize/DeterminizeRHDPDAPart.cxx +++ b/alib2algo/src/automaton/determinize/DeterminizeRHDPDAPart.cxx @@ -18,7 +18,7 @@ namespace automaton { namespace determinize { -void addRetTransition(const label::Label& from, const std::variant<string::Epsilon, alphabet::Symbol>& input, const alphabet::Symbol& dvpdaSymbol, const label::Label& to, automaton::RealTimeHeightDeterministicDPDA& deterministic) { +void addRetTransition(const label::Label& from, const std::variant<string::Epsilon < >, alphabet::Symbol>& input, const alphabet::Symbol& dvpdaSymbol, const label::Label& to, automaton::RealTimeHeightDeterministicDPDA& deterministic) { deterministic.addState(from); deterministic.addState(to); deterministic.addPushdownStoreSymbol(dvpdaSymbol); @@ -26,7 +26,7 @@ void addRetTransition(const label::Label& from, const std::variant<string::Epsil deterministic.addReturnTransition(from, input, dvpdaSymbol, to); } -void retInitial(const label::Label& state, const alphabet::Symbol& pdaSymbol, const std::variant<string::Epsilon, alphabet::Symbol>& input, const automaton::RealTimeHeightDeterministicNPDA& nondeterministic, automaton::RealTimeHeightDeterministicDPDA& deterministic, std::map<std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, label::Label>& rubbishReturnTransitions) { +void retInitial(const label::Label& state, const alphabet::Symbol& pdaSymbol, const std::variant<string::Epsilon < >, alphabet::Symbol>& input, const automaton::RealTimeHeightDeterministicNPDA& nondeterministic, automaton::RealTimeHeightDeterministicDPDA& deterministic, std::map<std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol>, label::Label>& rubbishReturnTransitions) { std::set<std::pair<label::Label, label::Label>> S = unpackFromStateLabel(state); std::set<std::pair<label::Label, label::Label>> S1; @@ -48,16 +48,16 @@ void retInitial(const label::Label& state, const alphabet::Symbol& pdaSymbol, co label::Label to(packToStateLabel(std::move(S1))); if(S1.empty()) { - std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol> key(state, input, pdaSymbol); + std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol> key(state, input, pdaSymbol); rubbishReturnTransitions.insert(std::make_pair(key, to)); } else { addRetTransition(state, input, pdaSymbol, to, deterministic); } } -void ret(const label::Label& state, const alphabet::Symbol& pdaSymbol, const std::variant<string::Epsilon, alphabet::Symbol>& input, const automaton::RealTimeHeightDeterministicNPDA& nondeterministic, automaton::RealTimeHeightDeterministicDPDA& deterministic, std::map<std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, label::Label>& rubbishReturnTransitions) { +void ret(const label::Label& state, const alphabet::Symbol& pdaSymbol, const std::variant<string::Epsilon < >, alphabet::Symbol>& input, const automaton::RealTimeHeightDeterministicNPDA& nondeterministic, automaton::RealTimeHeightDeterministicDPDA& deterministic, std::map<std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol>, label::Label>& rubbishReturnTransitions) { std::set<std::pair<label::Label, label::Label>> S = unpackFromStateLabel(state); - std::pair<std::set<std::pair<label::Label, label::Label>>, std::variant<string::Epsilon, alphabet::Symbol>> pdaSymbolUnpack = unpackFromDRHDPDAStackSymbol(pdaSymbol); + std::pair<std::set<std::pair<label::Label, label::Label>>, std::variant<string::Epsilon < >, alphabet::Symbol>> pdaSymbolUnpack = unpackFromDRHDPDAStackSymbol(pdaSymbol); const std::set<std::pair<label::Label, label::Label>>& S1 = pdaSymbolUnpack.first; std::set<std::pair<label::Label, label::Label>> update; @@ -104,14 +104,14 @@ void ret(const label::Label& state, const alphabet::Symbol& pdaSymbol, const std label::Label to(packToStateLabel(std::move(S2))); if(S2.empty()) { - std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol> key(state, input, pdaSymbol); + std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol> key(state, input, pdaSymbol); rubbishReturnTransitions.insert(std::make_pair(key, to)); } else { addRetTransition(state, input, pdaSymbol, to, deterministic); } } -void addCallTransition(const label::Label& from, const std::variant<string::Epsilon, alphabet::Symbol>& input, const label::Label& to, const alphabet::Symbol& dvpdaSymbol, automaton::RealTimeHeightDeterministicDPDA& deterministic) { +void addCallTransition(const label::Label& from, const std::variant<string::Epsilon < >, alphabet::Symbol>& input, const label::Label& to, const alphabet::Symbol& dvpdaSymbol, automaton::RealTimeHeightDeterministicDPDA& deterministic) { deterministic.addState(from); deterministic.addState(to); deterministic.addPushdownStoreSymbol(dvpdaSymbol); @@ -119,7 +119,7 @@ void addCallTransition(const label::Label& from, const std::variant<string::Epsi deterministic.addCallTransition(from, input, to, dvpdaSymbol); } -void call(const label::Label& state, const std::variant<string::Epsilon, alphabet::Symbol>& input, const automaton::RealTimeHeightDeterministicNPDA& nondeterministic, automaton::RealTimeHeightDeterministicDPDA& deterministic, std::map<std::pair<label::Label, std::variant<string::Epsilon, alphabet::Symbol>>, std::pair<label::Label, alphabet::Symbol> >& rubbishCallTransitions) { +void call(const label::Label& state, const std::variant<string::Epsilon < >, alphabet::Symbol>& input, const automaton::RealTimeHeightDeterministicNPDA& nondeterministic, automaton::RealTimeHeightDeterministicDPDA& deterministic, std::map<std::pair<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>>, std::pair<label::Label, alphabet::Symbol> >& rubbishCallTransitions) { std::set<std::pair<label::Label, label::Label>> S = unpackFromStateLabel(state); std::set<label::Label> R = retrieveDSubSet(S); @@ -147,14 +147,14 @@ void call(const label::Label& state, const std::variant<string::Epsilon, alphabe } } -void addLocalTransition(const label::Label& from, const std::variant<string::Epsilon, alphabet::Symbol>& input, const label::Label& to, automaton::RealTimeHeightDeterministicDPDA& deterministic) { +void addLocalTransition(const label::Label& from, const std::variant<string::Epsilon < >, alphabet::Symbol>& input, const label::Label& to, automaton::RealTimeHeightDeterministicDPDA& deterministic) { deterministic.addState(from); deterministic.addState(to); deterministic.addLocalTransition(from, input, to); } -void local(const label::Label& state, const std::variant<string::Epsilon, alphabet::Symbol>& input, const automaton::RealTimeHeightDeterministicNPDA& nondeterministic, automaton::RealTimeHeightDeterministicDPDA& deterministic, std::map<std::pair<label::Label, std::variant<string::Epsilon, alphabet::Symbol>>, label::Label>& rubbishLocalTransitions ) { +void local(const label::Label& state, const std::variant<string::Epsilon < >, alphabet::Symbol>& input, const automaton::RealTimeHeightDeterministicNPDA& nondeterministic, automaton::RealTimeHeightDeterministicDPDA& deterministic, std::map<std::pair<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>>, label::Label>& rubbishLocalTransitions ) { std::set<std::pair<label::Label, label::Label>> S = unpackFromStateLabel(state); std::set<std::pair<label::Label, label::Label>> S1; @@ -181,10 +181,10 @@ void local(const label::Label& state, const std::variant<string::Epsilon, alphab } } -std::tuple<std::set<std::variant<string::Epsilon, alphabet::Symbol>>, std::set<std::variant<string::Epsilon, alphabet::Symbol>>, std::set<std::variant<string::Epsilon, alphabet::Symbol>>> getLocalCallRetPartitioning(const automaton::RealTimeHeightDeterministicNPDA& n, const label::Label& state) { - std::set<std::variant<string::Epsilon, alphabet::Symbol>> local; - std::set<std::variant<string::Epsilon, alphabet::Symbol>> call; - std::set<std::variant<string::Epsilon, alphabet::Symbol>> ret; +std::tuple<std::set<std::variant<string::Epsilon < >, alphabet::Symbol>>, std::set<std::variant<string::Epsilon < >, alphabet::Symbol>>, std::set<std::variant<string::Epsilon < >, alphabet::Symbol>>> getLocalCallRetPartitioning(const automaton::RealTimeHeightDeterministicNPDA& n, const label::Label& state) { + std::set<std::variant<string::Epsilon < >, alphabet::Symbol>> local; + std::set<std::variant<string::Epsilon < >, alphabet::Symbol>> call; + std::set<std::variant<string::Epsilon < >, alphabet::Symbol>> ret; const std::set<label::Label> dSubSet = retrieveDSubSet(unpackFromStateLabel(state)); @@ -213,9 +213,9 @@ automaton::RealTimeHeightDeterministicDPDA Determinize::determinize(const automa d.setInputAlphabet(n.getInputAlphabet()); std::set<label::Label> rubbishStates = {label::Label(packToStateLabel({}))}; - std::map<std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, label::Label> rubbishReturnTransitions; - std::map<std::pair<label::Label, std::variant<string::Epsilon, alphabet::Symbol>>, std::pair<label::Label, alphabet::Symbol> > rubbishCallTransitions; - std::map<std::pair<label::Label, std::variant<string::Epsilon, alphabet::Symbol>>, label::Label> rubbishLocalTransitions; + std::map<std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol>, label::Label> rubbishReturnTransitions; + std::map<std::pair<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>>, std::pair<label::Label, alphabet::Symbol> > rubbishCallTransitions; + std::map<std::pair<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>>, label::Label> rubbishLocalTransitions; for(;;) { std::set<std::pair<label::Label, alphabet::Symbol>> stateSymbols = existsDirtyStateSymbol(d, rubbishStates, rubbishCallTransitions, rubbishReturnTransitions, n); @@ -227,9 +227,9 @@ automaton::RealTimeHeightDeterministicDPDA Determinize::determinize(const automa if ( common::GlobalData::verbose ) std::clog << "Dirty state symbol: " << stateSymbol << std::endl; - std::tuple<std::set<std::variant<string::Epsilon, alphabet::Symbol>>, std::set<std::variant<string::Epsilon, alphabet::Symbol>>, std::set<std::variant<string::Epsilon, alphabet::Symbol>>> partitioning = getLocalCallRetPartitioning(n, stateSymbol.first); + std::tuple<std::set<std::variant<string::Epsilon < >, alphabet::Symbol>>, std::set<std::variant<string::Epsilon < >, alphabet::Symbol>>, std::set<std::variant<string::Epsilon < >, alphabet::Symbol>>> partitioning = getLocalCallRetPartitioning(n, stateSymbol.first); - std::set<std::variant<string::Epsilon, alphabet::Symbol>>& retPart = std::get<2>(partitioning); + std::set<std::variant<string::Epsilon < >, alphabet::Symbol>>& retPart = std::get<2>(partitioning); for(const auto& symbol : retPart) { if(stateSymbol.second == d.getBottomOfTheStackSymbol()) { @@ -243,10 +243,10 @@ automaton::RealTimeHeightDeterministicDPDA Determinize::determinize(const automa for(const auto& state : states) { if ( common::GlobalData::verbose ) std::clog << "Dirty state: " << state << std::endl; - std::tuple<std::set<std::variant<string::Epsilon, alphabet::Symbol>>, std::set<std::variant<string::Epsilon, alphabet::Symbol>>, std::set<std::variant<string::Epsilon, alphabet::Symbol>>> partitioning = getLocalCallRetPartitioning(n, state); + std::tuple<std::set<std::variant<string::Epsilon < >, alphabet::Symbol>>, std::set<std::variant<string::Epsilon < >, alphabet::Symbol>>, std::set<std::variant<string::Epsilon < >, alphabet::Symbol>>> partitioning = getLocalCallRetPartitioning(n, state); - std::set<std::variant<string::Epsilon, alphabet::Symbol>>& localPart = std::get<0>(partitioning); - std::set<std::variant<string::Epsilon, alphabet::Symbol>>& callPart = std::get<1>(partitioning); + std::set<std::variant<string::Epsilon < >, alphabet::Symbol>>& localPart = std::get<0>(partitioning); + std::set<std::variant<string::Epsilon < >, alphabet::Symbol>>& callPart = std::get<1>(partitioning); for(const auto& symbol : localPart) { local(state, symbol, n, d, rubbishLocalTransitions); diff --git a/alib2algo/src/automaton/determinize/common/RHDPDACommon.cpp b/alib2algo/src/automaton/determinize/common/RHDPDACommon.cpp index c9e8220778..ed7872ce6f 100644 --- a/alib2algo/src/automaton/determinize/common/RHDPDACommon.cpp +++ b/alib2algo/src/automaton/determinize/common/RHDPDACommon.cpp @@ -48,10 +48,10 @@ std::pair<std::set<std::pair<label::Label, label::Label>>, alphabet::Symbol> unp return std::make_pair(std::move(res), alphabet::Symbol(static_cast<const alphabet::SymbolBase&>(object.getData()))); } -label::Label packToStackSymbolLabel(std::pair<std::set<std::pair<label::Label, label::Label>>, std::variant<string::Epsilon, alphabet::Symbol>>&& data) { +label::Label packToStackSymbolLabel(std::pair<std::set<std::pair<label::Label, label::Label>>, std::variant<string::Epsilon < >, alphabet::Symbol>>&& data) { label::Label res1 = packToStateLabel(std::move(data.first)); - if(data.second.is<string::Epsilon>()) { - label::Label res2 = label::Label(label::ObjectLabel(alib::Object(std::move(data.second.get<string::Epsilon>())))); + if(data.second.is<string::Epsilon < >>()) { + label::Label res2 = label::Label(label::ObjectLabel(alib::Object(std::move(data.second.get<string::Epsilon < >>())))); return label::Label(label::LabelPairLabel(std::make_pair(std::move(res1), std::move(res2)))); } else { label::Label res2 = label::Label(label::ObjectLabel(alib::Object(std::move(data.second.get<alphabet::Symbol>().getData())))); @@ -59,17 +59,17 @@ label::Label packToStackSymbolLabel(std::pair<std::set<std::pair<label::Label, l } } -std::pair<std::set<std::pair<label::Label, label::Label>>, std::variant<string::Epsilon, alphabet::Symbol>> unpackFromDRHDPDAStackSymbol(const alphabet::Symbol& symbol) { +std::pair<std::set<std::pair<label::Label, label::Label>>, std::variant<string::Epsilon < >, alphabet::Symbol>> unpackFromDRHDPDAStackSymbol(const alphabet::Symbol& symbol) { const label::Label& data = static_cast<const alphabet::LabeledSymbol&>(symbol.getData()).getLabel(); const label::Label& labelPairFirst = static_cast<const label::LabelPairLabel&>(data.getData()).getData().first; std::set<std::pair<label::Label, label::Label>> res = unpackFromStateLabel(labelPairFirst); const label::Label& labelPairSecond = static_cast<const label::LabelPairLabel&>(data.getData()).getData().second; const alib::Object& object = static_cast<const label::ObjectLabel&>(labelPairSecond.getData()).getData(); - if(object.getData() == string::Epsilon::EPSILON) { - return std::make_pair(std::move(res), std::variant<string::Epsilon, alphabet::Symbol>(static_cast<const string::Epsilon&>(object.getData()))); + if(object.getData() == string::Epsilon < >::EPSILON) { + return std::make_pair(std::move(res), std::variant<string::Epsilon < >, alphabet::Symbol>(static_cast<const string::Epsilon < >&>(object.getData()))); } else { - return std::make_pair(std::move(res), std::variant<string::Epsilon, alphabet::Symbol>(alphabet::Symbol(static_cast<const alphabet::SymbolBase&>(object.getData())))); + return std::make_pair(std::move(res), std::variant<string::Epsilon < >, alphabet::Symbol>(alphabet::Symbol(static_cast<const alphabet::SymbolBase&>(object.getData())))); } } @@ -142,7 +142,7 @@ std::set<label::Label> existsDirtyState(const T& d, const std::set<label::Label> } template std::set<label::Label> existsDirtyState(const automaton::VisiblyPushdownDPDA& d, const std::set<label::Label>& rubbishStates, const std::map<std::pair<label::Label, alphabet::Symbol>, std::pair<label::Label, alphabet::Symbol> >& rubbishCallTransitions, const std::map<std::pair<label::Label, alphabet::Symbol>, label::Label>& rubbishLocalTransitions, const automaton::VisiblyPushdownNPDA& n); -template std::set<label::Label> existsDirtyState(const automaton::RealTimeHeightDeterministicDPDA& d, const std::set<label::Label>& rubbishStates, const std::map<std::pair<label::Label, std::variant<string::Epsilon, alphabet::Symbol>>, std::pair<label::Label, alphabet::Symbol> >& rubbishCallTransitions, const std::map<std::pair<label::Label, std::variant<string::Epsilon, alphabet::Symbol>>, label::Label>& rubbishLocalTransitions, const automaton::RealTimeHeightDeterministicNPDA& n); +template std::set<label::Label> existsDirtyState(const automaton::RealTimeHeightDeterministicDPDA& d, const std::set<label::Label>& rubbishStates, const std::map<std::pair<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>>, std::pair<label::Label, alphabet::Symbol> >& rubbishCallTransitions, const std::map<std::pair<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>>, label::Label>& rubbishLocalTransitions, const automaton::RealTimeHeightDeterministicNPDA& n); template<class T> void localClosure(std::set<label::Label>& states, const std::set<label::Label>& oldStates, const T& d) { @@ -235,7 +235,7 @@ break2: if(!originalPops) continue; } template std::set<std::pair<label::Label, alphabet::Symbol>> existsDirtyStateSymbol(const automaton::VisiblyPushdownDPDA& d, const std::set<label::Label>& rubbishStates, const std::map<std::pair<label::Label, alphabet::Symbol>, std::pair<label::Label, alphabet::Symbol> >& rubbishCallTransitions, const std::map<std::tuple<label::Label, alphabet::Symbol, alphabet::Symbol>, label::Label>& rubbishReturnTransitions, const automaton::VisiblyPushdownNPDA& n); -template std::set<std::pair<label::Label, alphabet::Symbol>> existsDirtyStateSymbol(const automaton::RealTimeHeightDeterministicDPDA& d, const std::set<label::Label>& rubbishStates, const std::map<std::pair<label::Label, std::variant<string::Epsilon, alphabet::Symbol>>, std::pair<label::Label, alphabet::Symbol> >& rubbishCallTransitions, const std::map<std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, label::Label>& rubbishReturnTransitions, const automaton::RealTimeHeightDeterministicNPDA& n); +template std::set<std::pair<label::Label, alphabet::Symbol>> existsDirtyStateSymbol(const automaton::RealTimeHeightDeterministicDPDA& d, const std::set<label::Label>& rubbishStates, const std::map<std::pair<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>>, std::pair<label::Label, alphabet::Symbol> >& rubbishCallTransitions, const std::map<std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol>, label::Label>& rubbishReturnTransitions, const automaton::RealTimeHeightDeterministicNPDA& n); } /* namespace automaton */ diff --git a/alib2algo/src/automaton/determinize/common/RHDPDACommon.h b/alib2algo/src/automaton/determinize/common/RHDPDACommon.h index 20e71031e4..e60d267063 100644 --- a/alib2algo/src/automaton/determinize/common/RHDPDACommon.h +++ b/alib2algo/src/automaton/determinize/common/RHDPDACommon.h @@ -20,9 +20,9 @@ label::Label packToStackSymbolLabel(std::pair<std::set<std::pair<label::Label, l std::pair<std::set<std::pair<label::Label, label::Label>>, alphabet::Symbol> unpackFromDVPAStackSymbol(const alphabet::Symbol& symbol); -label::Label packToStackSymbolLabel(std::pair<std::set<std::pair<label::Label, label::Label>>, std::variant<string::Epsilon, alphabet::Symbol>>&& data); +label::Label packToStackSymbolLabel(std::pair<std::set<std::pair<label::Label, label::Label>>, std::variant<string::Epsilon < >, alphabet::Symbol>>&& data); -std::pair<std::set<std::pair<label::Label, label::Label>>, std::variant<string::Epsilon, alphabet::Symbol>> unpackFromDRHDPDAStackSymbol(const alphabet::Symbol& symbol); +std::pair<std::set<std::pair<label::Label, label::Label>>, std::variant<string::Epsilon < >, alphabet::Symbol>> unpackFromDRHDPDAStackSymbol(const alphabet::Symbol& symbol); std::set<label::Label> retrieveDSubSet(const std::set<std::pair<label::Label, label::Label>>& localOperation); diff --git a/alib2algo/src/automaton/properties/EpsilonClosure.cpp b/alib2algo/src/automaton/properties/EpsilonClosure.cpp index 2c1538d3e4..6260c7e60d 100644 --- a/alib2algo/src/automaton/properties/EpsilonClosure.cpp +++ b/alib2algo/src/automaton/properties/EpsilonClosure.cpp @@ -42,7 +42,7 @@ std::set<label::Label> EpsilonClosure::epsilonClosure( const automaton::EpsilonN visited[ p ] = true; closure.insert( p ); - auto tos = fsm.getTransitions( ).find(std::make_pair(p, std::variant<string::Epsilon, alphabet::Symbol>(string::Epsilon::EPSILON) ) ); + auto tos = fsm.getTransitions( ).find(std::make_pair(p, std::variant<string::Epsilon < >, alphabet::Symbol>(string::Epsilon < >::EPSILON) ) ); if(tos == fsm.getTransitions().end()) continue; for( const auto & to : tos->second ) diff --git a/alib2algo/src/automaton/run/Run.cpp b/alib2algo/src/automaton/run/Run.cpp index ed08f0c483..e2a7f5fafd 100644 --- a/alib2algo/src/automaton/run/Run.cpp +++ b/alib2algo/src/automaton/run/Run.cpp @@ -354,7 +354,7 @@ std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::S symbolIter++; i++; } else { - callTransition = automaton.getCallTransitions ( ).find ( std::make_pair ( state, string::Epsilon::EPSILON ) ); + callTransition = automaton.getCallTransitions ( ).find ( std::make_pair ( state, string::Epsilon < >::EPSILON ) ); } if ( callTransition != automaton.getCallTransitions ( ).end ( ) ) { @@ -371,7 +371,7 @@ std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::S symbolIter++; i++; } else { - returnTransition = automaton.getReturnTransitions ( ).find ( std::make_tuple ( state, string::Epsilon::EPSILON, pushdownStore.back ( ) ) ); + returnTransition = automaton.getReturnTransitions ( ).find ( std::make_tuple ( state, string::Epsilon < >::EPSILON, pushdownStore.back ( ) ) ); } if ( returnTransition != automaton.getReturnTransitions ( ).end ( ) ) { @@ -389,7 +389,7 @@ std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::S symbolIter++; i++; } else { - localTransition = automaton.getLocalTransitions ( ).find ( std::make_pair ( state, string::Epsilon::EPSILON ) ); + localTransition = automaton.getLocalTransitions ( ).find ( std::make_pair ( state, string::Epsilon < >::EPSILON ) ); } if ( localTransition != automaton.getLocalTransitions ( ).end ( ) ) @@ -435,7 +435,7 @@ std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::S auto transition = transitions.begin ( ); for ( ; transition != transitions.end ( ); transition++ ) { - if ( ( std::get < 1 > ( transition->first ) != * symbolIter ) && !std::get < 1 > ( transition->first ).is < string::Epsilon > ( ) ) continue; + if ( ( std::get < 1 > ( transition->first ) != * symbolIter ) && !std::get < 1 > ( transition->first ).is < string::Epsilon < > > ( ) ) continue; if ( canPop ( pushdownStore, std::get < 2 > ( transition->first ) ) ) break; } @@ -454,7 +454,7 @@ std::tuple < bool, label::Label, std::set < unsigned >, std::deque < alphabet::S state = transition->second.first; - if ( !std::get < 1 > ( transition->first ).is < string::Epsilon > ( ) ) { + if ( !std::get < 1 > ( transition->first ).is < string::Epsilon < > > ( ) ) { i++; symbolIter++; } @@ -522,7 +522,7 @@ std::tuple < bool, std::set < label::Label >, std::set < std::vector < alphabet: } for ( const auto & transition : automaton . getTransitionsFromState ( state ) ) { - if ( std::get<1>(transition . first) != * symbolIter && ! std::get<1>(transition . first) . is<string::Epsilon>() ) + if ( std::get<1>(transition . first) != * symbolIter && ! std::get<1>(transition . first) . is<string::Epsilon < >>() ) continue; const auto & pop = std::get<2>(transition . first); @@ -544,7 +544,7 @@ std::tuple < bool, std::set < label::Label >, std::set < std::vector < alphabet: outputNodeCopy = std::make_shared < graphStructuredStack > ( outputNodeCopy, elem ); } - if ( ! std::get<1>(transition . first) . is<string::Epsilon>() ) { + if ( ! std::get<1>(transition . first) . is<string::Epsilon < >>() ) { configuration = std::make_tuple ( std::get<0>(transition . second), symbolIter + 1, stackNodeCopy, outputNodeCopy ); } else { configuration = std::make_tuple ( std::get<0>(transition . second), symbolIter, stackNodeCopy, outputNodeCopy ); diff --git a/alib2algo/src/automaton/simplify/Normalize.cpp b/alib2algo/src/automaton/simplify/Normalize.cpp index 483178145f..84f3492d25 100644 --- a/alib2algo/src/automaton/simplify/Normalize.cpp +++ b/alib2algo/src/automaton/simplify/Normalize.cpp @@ -88,10 +88,10 @@ automaton::DPDA Normalize::normalize(const automaton::DPDA& pda) { label::Label current = processingData.front(); processingData.pop_front(); - std::map<std::pair<std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > > transform; + std::map<std::pair<std::variant<string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > > transform; bool stateFinished = true; // For each transition from state current - for(const std::pair<const std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > >& iter : pda.getTransitionsFromState(current)) { + for(const std::pair<const std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > >& iter : pda.getTransitionsFromState(current)) { // look whether all poped symbols are already transformed if(std::all_of(std::get<2>(iter.first).begin(), std::get<2>(iter.first).end(), [&](const alphabet::Symbol& symbol) { return normalizationDataSymbol.find(symbol) != normalizationDataSymbol.end(); })) { std::vector<alphabet::Symbol> transformedSymbols; diff --git a/alib2algo/src/automaton/transform/RHPDAToPDA.cpp b/alib2algo/src/automaton/transform/RHPDAToPDA.cpp index 72873a9413..684a0ddb09 100644 --- a/alib2algo/src/automaton/transform/RHPDAToPDA.cpp +++ b/alib2algo/src/automaton/transform/RHPDAToPDA.cpp @@ -58,7 +58,7 @@ automaton::DPDA RHPDAToPDA::convert ( const automaton::RealTimeHeightDeterminist std::map < label::Label, std::set < std::tuple < std::vector < alphabet::Symbol >, label::Label, std::vector < alphabet::Symbol > > > > epsilonTransitions; for ( const auto & transition : pda.getCallTransitions ( ) ) { - if ( std::get < 1 > ( transition.first ).is < string::Epsilon > ( ) ) { + if ( std::get < 1 > ( transition.first ).is < string::Epsilon < > > ( ) ) { auto & epsT = epsilonTransitions[std::get < 0 > ( transition.first )]; const auto & to = transition.second; epsT.insert ( std::make_tuple ( std::vector < alphabet::Symbol > { }, to.first, std::vector < alphabet::Symbol > { to.second } ) ); @@ -70,7 +70,7 @@ automaton::DPDA RHPDAToPDA::convert ( const automaton::RealTimeHeightDeterminist } for ( const auto & transition : pda.getLocalTransitions ( ) ) { - if ( std::get < 1 > ( transition.first ).is < string::Epsilon > ( ) ) { + if ( std::get < 1 > ( transition.first ).is < string::Epsilon < > > ( ) ) { auto & epsT = epsilonTransitions[std::get < 0 > ( transition.first )]; const auto & to = transition.second; epsT.insert ( std::make_tuple ( std::vector < alphabet::Symbol > { }, to, std::vector < alphabet::Symbol > { } ) ); @@ -84,7 +84,7 @@ automaton::DPDA RHPDAToPDA::convert ( const automaton::RealTimeHeightDeterminist for ( const auto & transition : pda.getReturnTransitions ( ) ) { if ( std::get < 2 > ( transition.first ).getData ( ) == alphabet::BottomOfTheStackSymbol::BOTTOM_OF_THE_STACK ) continue; - if ( std::get < 1 > ( transition.first ).is < string::Epsilon > ( ) ) { + if ( std::get < 1 > ( transition.first ).is < string::Epsilon < > > ( ) ) { auto & epsT = epsilonTransitions[std::get < 0 > ( transition.first )]; const auto & to = transition.second; epsT.insert ( std::make_tuple ( std::vector < alphabet::Symbol > { std::get < 2 > ( transition.first ) }, to, std::vector < alphabet::Symbol > { } ) ); @@ -161,7 +161,7 @@ automaton::NPDA RHPDAToPDA::convert ( const automaton::RealTimeHeightDeterminist std::map < label::Label, std::set < std::tuple < std::vector < alphabet::Symbol >, label::Label, std::vector < alphabet::Symbol > > > > epsilonTransitions; for ( const auto & transition : pda.getCallTransitions ( ) ) { - if ( std::get < 1 > ( transition.first ).is < string::Epsilon > ( ) ) { + if ( std::get < 1 > ( transition.first ).is < string::Epsilon < > > ( ) ) { auto & epsT = epsilonTransitions[std::get < 0 > ( transition.first )]; for ( const auto & to : transition.second ) { @@ -177,7 +177,7 @@ automaton::NPDA RHPDAToPDA::convert ( const automaton::RealTimeHeightDeterminist } for ( const auto & transition : pda.getLocalTransitions ( ) ) { - if ( std::get < 1 > ( transition.first ).is < string::Epsilon > ( ) ) { + if ( std::get < 1 > ( transition.first ).is < string::Epsilon < > > ( ) ) { auto & epsT = epsilonTransitions[std::get < 0 > ( transition.first )]; for ( const auto & to : transition.second ) { @@ -195,7 +195,7 @@ automaton::NPDA RHPDAToPDA::convert ( const automaton::RealTimeHeightDeterminist for ( const auto & transition : pda.getReturnTransitions ( ) ) { if ( std::get < 2 > ( transition.first ).getData ( ) == alphabet::BottomOfTheStackSymbol::BOTTOM_OF_THE_STACK ) continue; - if ( std::get < 1 > ( transition.first ).is < string::Epsilon > ( ) ) { + if ( std::get < 1 > ( transition.first ).is < string::Epsilon < > > ( ) ) { auto & epsT = epsilonTransitions[std::get < 0 > ( transition.first )]; for ( const auto & to : transition.second ) { diff --git a/alib2algo/src/grammar/parsing/DeterministicLL1Grammar.cpp b/alib2algo/src/grammar/parsing/DeterministicLL1Grammar.cpp index e0465e48fa..a28b3ae6f7 100644 --- a/alib2algo/src/grammar/parsing/DeterministicLL1Grammar.cpp +++ b/alib2algo/src/grammar/parsing/DeterministicLL1Grammar.cpp @@ -30,17 +30,17 @@ grammar::CFG DeterministicLL1Grammar::convert ( const grammar::CFG & param ) { grammar::CFG grammar = param; while ( true ) { - std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > parseTable = LL1ParseTable::parseTable ( grammar ); + std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > parseTable = LL1ParseTable::parseTable ( grammar ); bool deterministic = true; - for ( const std::pair < const std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > & elem : parseTable ) + for ( const std::pair < const std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > & elem : parseTable ) if ( elem.second.size ( ) > 1 ) - if ( elem.first.first.is < string::Epsilon > ( ) ) + if ( elem.first.first.is < string::Epsilon < > > ( ) ) throw exception::CommonException ( "Cant handle conflict in epsilon" ); - for ( const std::pair < const std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > & elem : parseTable ) { - if ( elem.first.first.is < string::Epsilon > ( ) ) continue; + for ( const std::pair < const std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > & elem : parseTable ) { + if ( elem.first.first.is < string::Epsilon < > > ( ) ) continue; const alphabet::Symbol & terminal = elem.first.first.get < alphabet::Symbol > ( ); const alphabet::Symbol & nonterminal = elem.first.second; @@ -57,8 +57,8 @@ grammar::CFG DeterministicLL1Grammar::convert ( const grammar::CFG & param ) { if ( !deterministic ) continue; - for ( const std::pair < const std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > & elem : parseTable ) { - if ( elem.first.first.is < string::Epsilon > ( ) ) continue; + for ( const std::pair < const std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > & elem : parseTable ) { + if ( elem.first.first.is < string::Epsilon < > > ( ) ) continue; const alphabet::Symbol & terminal = elem.first.first.get < alphabet::Symbol > ( ); const alphabet::Symbol & nonterminal = elem.first.second; diff --git a/alib2algo/src/grammar/parsing/DeterministicLL1ParseTable.cpp b/alib2algo/src/grammar/parsing/DeterministicLL1ParseTable.cpp index 9695d578e4..681fd9a60f 100644 --- a/alib2algo/src/grammar/parsing/DeterministicLL1ParseTable.cpp +++ b/alib2algo/src/grammar/parsing/DeterministicLL1ParseTable.cpp @@ -13,15 +13,15 @@ namespace grammar { namespace parsing { -std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::vector < alphabet::Symbol > > DeterministicLL1ParseTable::parseTable ( const std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > & parseTable ) { +std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::vector < alphabet::Symbol > > DeterministicLL1ParseTable::parseTable ( const std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > & parseTable ) { - for ( const std::pair < const std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > & elem : parseTable ) + for ( const std::pair < const std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > & elem : parseTable ) if ( elem.second.size ( ) > 1 ) throw exception::CommonException ( "Cant handle conflict in epsilon" ); - std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::vector < alphabet::Symbol > > res; + std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::vector < alphabet::Symbol > > res; - for ( const std::pair < const std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > & elem : parseTable ) + for ( const std::pair < const std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > & elem : parseTable ) if ( elem.second.size ( ) == 1 ) res.insert ( std::make_pair ( elem.first, * elem.second.begin ( ) ) ); diff --git a/alib2algo/src/grammar/parsing/DeterministicLL1ParseTable.h b/alib2algo/src/grammar/parsing/DeterministicLL1ParseTable.h index d44c97c183..b5bae8714e 100644 --- a/alib2algo/src/grammar/parsing/DeterministicLL1ParseTable.h +++ b/alib2algo/src/grammar/parsing/DeterministicLL1ParseTable.h @@ -21,7 +21,7 @@ namespace parsing { class DeterministicLL1ParseTable { public: - static std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::vector < alphabet::Symbol > > parseTable ( const std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > & parseTable ); + static std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::vector < alphabet::Symbol > > parseTable ( const std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > & parseTable ); }; } /* namespace parsing */ diff --git a/alib2algo/src/grammar/parsing/First.cpp b/alib2algo/src/grammar/parsing/First.cpp index db0071cd56..ad946807a5 100644 --- a/alib2algo/src/grammar/parsing/First.cpp +++ b/alib2algo/src/grammar/parsing/First.cpp @@ -22,10 +22,10 @@ namespace grammar { namespace parsing { -std::set < std::variant < alphabet::Symbol, string::Epsilon > > First::first ( const std::set < alphabet::Symbol > & terminals, const std::set < alphabet::Symbol > & nonterminals, const std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > & firstOfNonterminal, const std::vector < alphabet::Symbol > & rhs ) { +std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > First::first ( const std::set < alphabet::Symbol > & terminals, const std::set < alphabet::Symbol > & nonterminals, const std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > & firstOfNonterminal, const std::vector < alphabet::Symbol > & rhs ) { // 1. FIRST(\varepsilon) = { \varepsilon } if ( rhs.size ( ) == 0 ) { - return { string::Epsilon::EPSILON }; + return { string::Epsilon < >::EPSILON }; } // 2. FIRST(a) = { a } forall a \in T @@ -34,16 +34,16 @@ std::set < std::variant < alphabet::Symbol, string::Epsilon > > First::first ( c } // 4. FIRST(A \alpha) = first(A) if A \in N and \varepsilon \notin first(A) - else if ( nonterminals.count ( rhs[0] ) && !firstOfNonterminal.find ( rhs[0] )->second.count ( string::Epsilon::EPSILON ) ) { + else if ( nonterminals.count ( rhs[0] ) && !firstOfNonterminal.find ( rhs[0] )->second.count ( string::Epsilon < >::EPSILON ) ) { return firstOfNonterminal.find ( rhs[0] )->second; } // 5. FIRST(A \alpha) = (first(A) - \varepsilon) \cup FIRST(\alpha) if A \in N and \varepsilon \in first(A) - else if ( nonterminals.count ( rhs[0] ) && firstOfNonterminal.find ( rhs[0] )->second.count ( string::Epsilon::EPSILON ) ) { - std::set < std::variant < alphabet::Symbol, string::Epsilon > > res = firstOfNonterminal.find ( rhs[0] )->second; - res.erase ( string::Epsilon::EPSILON ); + else if ( nonterminals.count ( rhs[0] ) && firstOfNonterminal.find ( rhs[0] )->second.count ( string::Epsilon < >::EPSILON ) ) { + std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > res = firstOfNonterminal.find ( rhs[0] )->second; + res.erase ( string::Epsilon < >::EPSILON ); - std::set < std::variant < alphabet::Symbol, string::Epsilon > > next = first ( terminals, nonterminals, firstOfNonterminal, std::vector < alphabet::Symbol > ( rhs.begin ( ) + 1, rhs.end ( ) ) ); + std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > next = first ( terminals, nonterminals, firstOfNonterminal, std::vector < alphabet::Symbol > ( rhs.begin ( ) + 1, rhs.end ( ) ) ); res.insert ( next.begin ( ), next.end ( ) ); return res; } else { @@ -51,7 +51,7 @@ std::set < std::variant < alphabet::Symbol, string::Epsilon > > First::first ( c } } -std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > First::first ( const std::set < alphabet::Symbol > & terminals, const std::set < alphabet::Symbol > & nonterminals, const std::map < alphabet::Symbol, std::set < std::vector < alphabet::Symbol > > > & rules ) { +std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > First::first ( const std::set < alphabet::Symbol > & terminals, const std::set < alphabet::Symbol > & nonterminals, const std::map < alphabet::Symbol, std::set < std::vector < alphabet::Symbol > > > & rules ) { /* * * 1. foreach A \in N: first(A) = \emptyset @@ -60,17 +60,17 @@ std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string: * 3. repeat step 2 if at least one set first(A) has changed * */ - std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > firstOfNonterminal1; + std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > firstOfNonterminal1; for ( const alphabet::Symbol & nonterminal : nonterminals ) firstOfNonterminal1[nonterminal]; - std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > firstOfNonterminal2 = firstOfNonterminal1; + std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > firstOfNonterminal2 = firstOfNonterminal1; do { for ( const std::pair < const alphabet::Symbol, std::set < std::vector < alphabet::Symbol > > > & rule : rules ) for ( const std::vector < alphabet::Symbol > & rhs : rule.second ) { - std::set < std::variant < alphabet::Symbol, string::Epsilon > > newFirst = first ( terminals, nonterminals, firstOfNonterminal1, rhs ); + std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > newFirst = first ( terminals, nonterminals, firstOfNonterminal1, rhs ); firstOfNonterminal2[rule.first].insert ( newFirst.begin ( ), newFirst.end ( ) ); } @@ -85,10 +85,10 @@ std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string: } template < class T > -std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > First::first ( const T & grammar ) { - std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > firstNt = first ( grammar.getTerminalAlphabet ( ), grammar.getNonterminalAlphabet ( ), grammar.getRawRules ( ) ); +std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > First::first ( const T & grammar ) { + std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > firstNt = first ( grammar.getTerminalAlphabet ( ), grammar.getNonterminalAlphabet ( ), grammar.getRawRules ( ) ); - std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > res; + std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > res; for ( const std::pair < const alphabet::Symbol, std::set < std::vector < alphabet::Symbol > > > & rule : grammar.getRawRules ( ) ) for ( const std::vector < alphabet::Symbol > & rhs : rule.second ) @@ -98,8 +98,8 @@ std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet: } template < class T > -std::set < std::variant < alphabet::Symbol, string::Epsilon > > First::first ( const T & grammar, const std::vector < alphabet::Symbol > & rhs ) { - std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > firstNt = first ( grammar.getTerminalAlphabet ( ), grammar.getNonterminalAlphabet ( ), grammar.getRawRules ( ) ); +std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > First::first ( const T & grammar, const std::vector < alphabet::Symbol > & rhs ) { + std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > firstNt = first ( grammar.getTerminalAlphabet ( ), grammar.getNonterminalAlphabet ( ), grammar.getRawRules ( ) ); return first ( grammar.getTerminalAlphabet ( ), grammar.getNonterminalAlphabet ( ), firstNt, rhs ); } @@ -114,7 +114,7 @@ auto FirstLeftRG = FirstBase1::RegistratorWrapper < FirstResult1, grammar::Left auto FirstRightLG = FirstBase1::RegistratorWrapper < FirstResult1, grammar::RightLG > ( First::first ); auto FirstRightRG = FirstBase1::RegistratorWrapper < FirstResult1, grammar::RightRG > ( First::first ); -std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > First::first ( const grammar::Grammar & grammar ) { +std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > First::first ( const grammar::Grammar & grammar ) { return FirstBase1::dispatch ( grammar.getData ( ) ); } @@ -128,7 +128,7 @@ auto FirstLeftRG2 = FirstBase2::RegistratorWrapper < FirstResult2, grammar::Lef auto FirstRightLG2 = FirstBase2::RegistratorWrapper < FirstResult2, grammar::RightLG > ( First::first ); auto FirstRightRG2 = FirstBase2::RegistratorWrapper < FirstResult2, grammar::RightRG > ( First::first ); -std::set < std::variant < alphabet::Symbol, string::Epsilon > > First::first ( const grammar::Grammar & grammar, const std::vector < alphabet::Symbol > & rhs ) { +std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > First::first ( const grammar::Grammar & grammar, const std::vector < alphabet::Symbol > & rhs ) { return FirstBase2::dispatch ( grammar.getData ( ), rhs ); } diff --git a/alib2algo/src/grammar/parsing/First.h b/alib2algo/src/grammar/parsing/First.h index 1a8813b6d3..2bce4f8ed4 100644 --- a/alib2algo/src/grammar/parsing/First.h +++ b/alib2algo/src/grammar/parsing/First.h @@ -22,16 +22,16 @@ namespace parsing { class First; -typedef std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > FirstResult1; +typedef std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > FirstResult1; typedef std::SingleDispatch < First, FirstResult1, grammar::GrammarBase > FirstBase1; -typedef std::set < std::variant < alphabet::Symbol, string::Epsilon > > FirstResult2; +typedef std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > FirstResult2; typedef std::SingleDispatchLastStaticParam < First, FirstResult2, grammar::GrammarBase, const std::vector < alphabet::Symbol > & > FirstBase2; class First : public FirstBase1, public FirstBase2 { - static std::set < std::variant < alphabet::Symbol, string::Epsilon > > first ( const std::set < alphabet::Symbol > & terminals, const std::set < alphabet::Symbol > & nonterminals, const std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > & firstOfNonterminal, const std::vector < alphabet::Symbol > & rhs ); + static std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > first ( const std::set < alphabet::Symbol > & terminals, const std::set < alphabet::Symbol > & nonterminals, const std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > & firstOfNonterminal, const std::vector < alphabet::Symbol > & rhs ); - static std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > first ( const std::set < alphabet::Symbol > & terminals, const std::set < alphabet::Symbol > & nonterminals, const std::map < alphabet::Symbol, std::set < std::vector < alphabet::Symbol > > > & rules ); + static std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > first ( const std::set < alphabet::Symbol > & terminals, const std::set < alphabet::Symbol > & nonterminals, const std::map < alphabet::Symbol, std::set < std::vector < alphabet::Symbol > > > & rules ); public: template < class T > diff --git a/alib2algo/src/grammar/parsing/Follow.cpp b/alib2algo/src/grammar/parsing/Follow.cpp index 5ecb9f1968..804f460d79 100644 --- a/alib2algo/src/grammar/parsing/Follow.cpp +++ b/alib2algo/src/grammar/parsing/Follow.cpp @@ -27,7 +27,7 @@ namespace grammar { namespace parsing { template < class T > -void Follow::follow ( const T & grammar, std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > & followSet ) { +void Follow::follow ( const T & grammar, std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > & followSet ) { for ( const std::pair < const alphabet::Symbol, std::set < std::vector < alphabet::Symbol > > > & rule : grammar.getRawRules ( ) ) { const alphabet::Symbol & X = rule.first; @@ -38,10 +38,10 @@ void Follow::follow ( const T & grammar, std::map < alphabet::Symbol, std::set < if ( !grammar.getNonterminalAlphabet ( ).count ( Y ) ) continue; - std::set < std::variant < alphabet::Symbol, string::Epsilon > > firstBeta = First::first ( grammar, std::vector < alphabet::Symbol > ( std::next ( it ), rhs.end ( ) ) ); + std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > firstBeta = First::first ( grammar, std::vector < alphabet::Symbol > ( std::next ( it ), rhs.end ( ) ) ); - if ( firstBeta.count ( string::Epsilon::EPSILON ) ) { - firstBeta.erase ( string::Epsilon::EPSILON ); + if ( firstBeta.count ( string::Epsilon < >::EPSILON ) ) { + firstBeta.erase ( string::Epsilon < >::EPSILON ); followSet[Y].insert ( followSet[X].begin ( ), followSet[X].end ( ) ); } @@ -52,7 +52,7 @@ void Follow::follow ( const T & grammar, std::map < alphabet::Symbol, std::set < } template < class T > -std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > Follow::follow ( const T & grammar ) { +std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > Follow::follow ( const T & grammar ) { /* * 1. Follow(S) = { \varepsilon } * Follow(A) = {} forall A \in N, A \neq S @@ -64,14 +64,14 @@ std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string: * 3. goto 2 if any follow set was changed in prev step. */ - std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > followSet1; + std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > followSet1; for ( const alphabet::Symbol & symb : grammar.getNonterminalAlphabet ( ) ) followSet1[symb]; - followSet1[grammar.getInitialSymbol ( )] = { string::Epsilon::EPSILON }; + followSet1[grammar.getInitialSymbol ( )] = { string::Epsilon < >::EPSILON }; - std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > followSet2 = followSet1; + std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > followSet2 = followSet1; do { follow ( grammar, followSet2 ); @@ -85,7 +85,7 @@ std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string: } template < class T > -std::set < std::variant < alphabet::Symbol, string::Epsilon > > Follow::follow ( const T & grammar, const alphabet::Symbol & nt ) { +std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > Follow::follow ( const T & grammar, const alphabet::Symbol & nt ) { if ( !grammar.getNonterminalAlphabet ( ).count ( nt ) ) throw exception::CommonException ( "Follow: Given symbol is not nonterminal." ); @@ -102,7 +102,7 @@ auto FollowLeftRG = FollowBase1::RegistratorWrapper < FollowResult1, grammar::L auto FollowRightLG = FollowBase1::RegistratorWrapper < FollowResult1, grammar::RightLG > ( Follow::follow ); auto FollowRightRG = FollowBase1::RegistratorWrapper < FollowResult1, grammar::RightRG > ( Follow::follow ); -std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > Follow::follow ( const grammar::Grammar & grammar ) { +std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > Follow::follow ( const grammar::Grammar & grammar ) { return FollowBase1::dispatch ( grammar.getData ( ) ); } @@ -116,7 +116,7 @@ auto FollowLeftRG2 = FollowBase2::RegistratorWrapper < FollowResult2, grammar::L auto FollowRightLG2 = FollowBase2::RegistratorWrapper < FollowResult2, grammar::RightLG > ( Follow::follow ); auto FollowRightRG2 = FollowBase2::RegistratorWrapper < FollowResult2, grammar::RightRG > ( Follow::follow ); -std::set < std::variant < alphabet::Symbol, string::Epsilon > > Follow::follow ( const grammar::Grammar & grammar, const alphabet::Symbol & nt ) { +std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > Follow::follow ( const grammar::Grammar & grammar, const alphabet::Symbol & nt ) { return FollowBase2::dispatch ( grammar.getData ( ), nt ); } diff --git a/alib2algo/src/grammar/parsing/Follow.h b/alib2algo/src/grammar/parsing/Follow.h index 3fab8f22f6..f4ee6f7263 100644 --- a/alib2algo/src/grammar/parsing/Follow.h +++ b/alib2algo/src/grammar/parsing/Follow.h @@ -22,15 +22,15 @@ namespace parsing { class Follow; -typedef std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > FollowResult1; +typedef std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > FollowResult1; typedef std::SingleDispatch < Follow, FollowResult1, grammar::GrammarBase > FollowBase1; -typedef std::set < std::variant < alphabet::Symbol, string::Epsilon > > FollowResult2; +typedef std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > FollowResult2; typedef std::SingleDispatchLastStaticParam < Follow, FollowResult2, grammar::GrammarBase, const alphabet::Symbol & > FollowBase2; class Follow : public FollowBase1, public FollowBase2 { template < class T > - static void follow ( const T & grammar, std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > & followSet ); + static void follow ( const T & grammar, std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > & followSet ); static Follow & getInstance ( ) { static Follow res; diff --git a/alib2algo/src/grammar/parsing/LL1ParseTable.cpp b/alib2algo/src/grammar/parsing/LL1ParseTable.cpp index a39a0111b6..4592d6f7a7 100644 --- a/alib2algo/src/grammar/parsing/LL1ParseTable.cpp +++ b/alib2algo/src/grammar/parsing/LL1ParseTable.cpp @@ -24,24 +24,24 @@ namespace grammar { namespace parsing { template < class T > -std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > LL1ParseTable::parseTable ( const T & grammar ) { - std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > res; +std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > LL1ParseTable::parseTable ( const T & grammar ) { + std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > res; - std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > first = First::first ( grammar ); - std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > follow = Follow::follow ( grammar ); + std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > first = First::first ( grammar ); + std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > follow = Follow::follow ( grammar ); for ( const std::pair < const alphabet::Symbol, std::set < std::vector < alphabet::Symbol > > > & transition : grammar.getRawRules ( ) ) { const alphabet::Symbol & lhs = transition.first; for ( const std::vector < alphabet::Symbol > & rhs : transition.second ) { - for ( const std::variant < alphabet::Symbol, string::Epsilon > & firstElem : first[rhs] ) { - if ( firstElem.is < string::Epsilon > ( ) ) continue; + for ( const std::variant < alphabet::Symbol, string::Epsilon < > > & firstElem : first[rhs] ) { + if ( firstElem.is < string::Epsilon < > > ( ) ) continue; res[std::make_pair ( firstElem, lhs )].insert ( rhs ); } - if ( first[rhs].count ( string::Epsilon::EPSILON ) ) - for ( const std::variant < alphabet::Symbol, string::Epsilon > & followElem : follow[lhs] ) + if ( first[rhs].count ( string::Epsilon < >::EPSILON ) ) + for ( const std::variant < alphabet::Symbol, string::Epsilon < > > & followElem : follow[lhs] ) res[std::make_pair ( followElem, lhs )].insert ( rhs ); } @@ -50,17 +50,17 @@ std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alpha return res; } -auto LL1ParseTableCFG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::CFG > ( LL1ParseTable::parseTable ); -auto LL1ParseTableEpsilonFreeCFG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::EpsilonFreeCFG > ( LL1ParseTable::parseTable ); -auto LL1ParseTableGNF = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::GNF > ( LL1ParseTable::parseTable ); -auto LL1ParseTableCNF = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::CNF > ( LL1ParseTable::parseTable ); -auto LL1ParseTableLG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::LG > ( LL1ParseTable::parseTable ); -auto LL1ParseTableLeftLG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::LeftLG > ( LL1ParseTable::parseTable ); -auto LL1ParseTableLeftRG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::LeftRG > ( LL1ParseTable::parseTable ); -auto LL1ParseTableRightLG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::RightLG > ( LL1ParseTable::parseTable ); -auto LL1ParseTableRightRG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::RightRG > ( LL1ParseTable::parseTable ); - -std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > LL1ParseTable::parseTable ( const grammar::Grammar & grammar ) { +auto LL1ParseTableCFG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::CFG > ( LL1ParseTable::parseTable ); +auto LL1ParseTableEpsilonFreeCFG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::EpsilonFreeCFG > ( LL1ParseTable::parseTable ); +auto LL1ParseTableGNF = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::GNF > ( LL1ParseTable::parseTable ); +auto LL1ParseTableCNF = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::CNF > ( LL1ParseTable::parseTable ); +auto LL1ParseTableLG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::LG > ( LL1ParseTable::parseTable ); +auto LL1ParseTableLeftLG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::LeftLG > ( LL1ParseTable::parseTable ); +auto LL1ParseTableLeftRG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::LeftRG > ( LL1ParseTable::parseTable ); +auto LL1ParseTableRightLG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::RightLG > ( LL1ParseTable::parseTable ); +auto LL1ParseTableRightRG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::RightRG > ( LL1ParseTable::parseTable ); + +std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > LL1ParseTable::parseTable ( const grammar::Grammar & grammar ) { return dispatch ( grammar.getData ( ) ); } diff --git a/alib2algo/src/grammar/parsing/LL1ParseTable.h b/alib2algo/src/grammar/parsing/LL1ParseTable.h index 24fb7b5d86..8e6456e319 100644 --- a/alib2algo/src/grammar/parsing/LL1ParseTable.h +++ b/alib2algo/src/grammar/parsing/LL1ParseTable.h @@ -21,12 +21,12 @@ namespace grammar { namespace parsing { -class LL1ParseTable : public std::SingleDispatch < LL1ParseTable, std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::GrammarBase > { +class LL1ParseTable : public std::SingleDispatch < LL1ParseTable, std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::GrammarBase > { public: template < class T > - static std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > parseTable ( const T & grammar ); + static std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > parseTable ( const T & grammar ); - static std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > parseTable ( const grammar::Grammar & grammar ); + static std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > parseTable ( const grammar::Grammar & grammar ); }; diff --git a/alib2algo/src/grammar/parsing/SLR1ParseTable.cpp b/alib2algo/src/grammar/parsing/SLR1ParseTable.cpp index a23c3c3c38..cd9bdf910f 100644 --- a/alib2algo/src/grammar/parsing/SLR1ParseTable.cpp +++ b/alib2algo/src/grammar/parsing/SLR1ParseTable.cpp @@ -46,7 +46,7 @@ LRActionTable SLR1ParseTable::getActionTable ( grammar::CFG originalGrammar ) { grammar::parsing::FollowResult2 followSet = grammar::parsing::Follow::follow ( augmentedGrammar, leftHandSide ); std::pair < alphabet::Symbol, std::vector < alphabet::Symbol > > currentRule = { leftHandSide, rightHandSide }; - for ( const std::variant < alphabet::Symbol, string::Epsilon > & followSymbol : followSet ) { + for ( const std::variant < alphabet::Symbol, string::Epsilon < > > & followSymbol : followSet ) { if ( followSymbol.is < alphabet::Symbol > ( ) ) { insertToActionTable(actionTable, { state, followSymbol.get < alphabet::Symbol > ( ) }, { LRAction::Reduce, currentRule } ); } else { diff --git a/alib2algo/src/regexp/convert/ToAutomatonThompson.cpp b/alib2algo/src/regexp/convert/ToAutomatonThompson.cpp index 3ecbd3e115..ffe7c1f07e 100644 --- a/alib2algo/src/regexp/convert/ToAutomatonThompson.cpp +++ b/alib2algo/src/regexp/convert/ToAutomatonThompson.cpp @@ -51,12 +51,12 @@ void ToAutomatonThompson::Visit(void* userData, const regexp::FormalRegExpAltern automaton.addState(tail); static_cast<const regexp::FormalRegExpElement&>(alternation.getLeftElement()).Accept(userData, *this); - automaton.addTransition(head, string::Epsilon::EPSILON, *std::get<2>(out)); - automaton.addTransition(*std::get<3>(out), string::Epsilon::EPSILON, tail); + automaton.addTransition(head, string::Epsilon < >::EPSILON, *std::get<2>(out)); + automaton.addTransition(*std::get<3>(out), string::Epsilon < >::EPSILON, tail); static_cast<const regexp::FormalRegExpElement&>(alternation.getRightElement()).Accept(userData, *this); - automaton.addTransition(head, string::Epsilon::EPSILON, *std::get<2>(out)); - automaton.addTransition(*std::get<3>(out), string::Epsilon::EPSILON, tail); + automaton.addTransition(head, string::Epsilon < >::EPSILON, *std::get<2>(out)); + automaton.addTransition(*std::get<3>(out), string::Epsilon < >::EPSILON, tail); std::get<2>(out) = &(*automaton.getStates().find(head)); std::get<3>(out) = &(*automaton.getStates().find(tail)); @@ -73,7 +73,7 @@ void ToAutomatonThompson::Visit(void* userData, const regexp::FormalRegExpConcat const label::Label* leftTail = std::get<3>(out); static_cast<const regexp::FormalRegExpElement&>(concatenation.getRightElement()).Accept(userData, *this); - automaton.addTransition(*leftTail, string::Epsilon::EPSILON, *std::get<2>(out)); + automaton.addTransition(*leftTail, string::Epsilon < >::EPSILON, *std::get<2>(out)); std::get<2>(out) = &(*automaton.getStates().find(*leftHead)); // std::get<3>(out) = std::get<3>(out); @@ -91,10 +91,10 @@ void ToAutomatonThompson::Visit(void* userData, const regexp::FormalRegExpIterat automaton.addState(tail); static_cast<const regexp::FormalRegExpElement&>(iteration.getElement()).Accept(userData, *this); - automaton.addTransition(head, string::Epsilon::EPSILON, *std::get<2>(out)); - automaton.addTransition(head, string::Epsilon::EPSILON, tail); - automaton.addTransition(*std::get<3>(out), string::Epsilon::EPSILON, tail); - automaton.addTransition(*std::get<3>(out), string::Epsilon::EPSILON, *std::get<2>(out)); + automaton.addTransition(head, string::Epsilon < >::EPSILON, *std::get<2>(out)); + automaton.addTransition(head, string::Epsilon < >::EPSILON, tail); + automaton.addTransition(*std::get<3>(out), string::Epsilon < >::EPSILON, tail); + automaton.addTransition(*std::get<3>(out), string::Epsilon < >::EPSILON, *std::get<2>(out)); std::get<2>(out) = &(*automaton.getStates().find(head)); std::get<3>(out) = &(*automaton.getStates().find(tail)); @@ -127,7 +127,7 @@ void ToAutomatonThompson::Visit(void* userData, const regexp::FormalRegExpEpsilo automaton.addState(head); automaton.addState(tail); - automaton.addTransition(head, string::Epsilon::EPSILON, tail); + automaton.addTransition(head, string::Epsilon < >::EPSILON, tail); std::get<2>(out) = &(*automaton.getStates().find(head)); std::get<3>(out) = &(*automaton.getStates().find(tail)); } @@ -162,8 +162,8 @@ void ToAutomatonThompson::Visit(void* userData, const regexp::UnboundedRegExpAlt for(const auto& element : alternation.getElements()) { static_cast<const regexp::UnboundedRegExpElement&>(*element).Accept(userData, *this); - automaton.addTransition(head, string::Epsilon::EPSILON, *std::get<2>(out)); - automaton.addTransition(*std::get<3>(out), string::Epsilon::EPSILON, tail); + automaton.addTransition(head, string::Epsilon < >::EPSILON, *std::get<2>(out)); + automaton.addTransition(*std::get<3>(out), string::Epsilon < >::EPSILON, tail); } std::get<2>(out) = &(*automaton.getStates().find(head)); @@ -183,7 +183,7 @@ void ToAutomatonThompson::Visit(void* userData, const regexp::UnboundedRegExpCon } for(size_t i = 1; i < tails.size(); i++) - automaton.addTransition(*tails[i-1].second, string::Epsilon::EPSILON, *tails[i].first); + automaton.addTransition(*tails[i-1].second, string::Epsilon < >::EPSILON, *tails[i].first); std::get<2>(out) = tails[0].first; std::get<3>(out) = tails[tails.size()-1].second; @@ -200,10 +200,10 @@ void ToAutomatonThompson::Visit(void* userData, const regexp::UnboundedRegExpIte automaton.addState(tail); static_cast<const regexp::UnboundedRegExpElement&>(iteration.getElement()).Accept(userData, *this); - automaton.addTransition(head, string::Epsilon::EPSILON, *std::get<2>(out)); - automaton.addTransition(head, string::Epsilon::EPSILON, tail); - automaton.addTransition(*std::get<3>(out), string::Epsilon::EPSILON, tail); - automaton.addTransition(*std::get<3>(out), string::Epsilon::EPSILON, *std::get<2>(out)); + automaton.addTransition(head, string::Epsilon < >::EPSILON, *std::get<2>(out)); + automaton.addTransition(head, string::Epsilon < >::EPSILON, tail); + automaton.addTransition(*std::get<3>(out), string::Epsilon < >::EPSILON, tail); + automaton.addTransition(*std::get<3>(out), string::Epsilon < >::EPSILON, *std::get<2>(out)); std::get<2>(out) = &(*automaton.getStates().find(head)); std::get<3>(out) = &(*automaton.getStates().find(tail)); @@ -234,7 +234,7 @@ void ToAutomatonThompson::Visit(void* userData, const regexp::UnboundedRegExpEps automaton.addState(head); automaton.addState(tail); - automaton.addTransition(head, string::Epsilon::EPSILON, tail); + automaton.addTransition(head, string::Epsilon < >::EPSILON, tail); std::get<2>(out) = &(*automaton.getStates().find(head)); std::get<3>(out) = &(*automaton.getStates().find(tail)); } diff --git a/alib2algo/src/string/naive/ExactCompare.cpp b/alib2algo/src/string/naive/ExactCompare.cpp index f5b448a664..6b6ccee2cc 100644 --- a/alib2algo/src/string/naive/ExactCompare.cpp +++ b/alib2algo/src/string/naive/ExactCompare.cpp @@ -18,11 +18,11 @@ int ExactCompare::compare ( const string::String & u, const string::String & v ) return dispatch ( u.getData ( ), v.getData ( ) ); } -int ExactCompare::compare ( const string::Epsilon &, const string::Epsilon & ) { +int ExactCompare::compare ( const string::Epsilon < > &, const string::Epsilon < > & ) { return 0; } -auto ExactCompareEpsilon = ExactCompare::RegistratorWrapper < int, string::Epsilon > ( ExactCompare::compare ); +auto ExactCompareEpsilon = ExactCompare::RegistratorWrapper < int, string::Epsilon < > > ( ExactCompare::compare ); int ExactCompare::compare ( const string::LinearString & u, const string::LinearString & v ) { int n = ( int ) u.getContent ( ).size ( ), m = ( int ) v.getContent ( ).size ( ); diff --git a/alib2algo/src/string/naive/ExactCompare.h b/alib2algo/src/string/naive/ExactCompare.h index 8be5ce24e6..5f0419b669 100644 --- a/alib2algo/src/string/naive/ExactCompare.h +++ b/alib2algo/src/string/naive/ExactCompare.h @@ -20,7 +20,7 @@ class ExactCompare : public std::PromotingDoubleDispatch<ExactCompare, int, stri public: static int compare(const string::String& u, const string::String& v); - static int compare(const string::Epsilon& u, const string::Epsilon& v); + static int compare(const string::Epsilon < >& u, const string::Epsilon < >& v); static int compare(const string::LinearString& u, const string::LinearString& v); static int compare(const string::CyclicString& u, const string::CyclicString& v); }; diff --git a/alib2algo/src/string/naive/ExactEqual.cpp b/alib2algo/src/string/naive/ExactEqual.cpp index 7e01a22346..43572b11f1 100644 --- a/alib2algo/src/string/naive/ExactEqual.cpp +++ b/alib2algo/src/string/naive/ExactEqual.cpp @@ -18,11 +18,11 @@ bool ExactEqual::equals ( const string::String & u, const string::String & v ) { return dispatch ( u.getData ( ), v.getData ( ) ); } -bool ExactEqual::equals ( const string::Epsilon &, const string::Epsilon & ) { +bool ExactEqual::equals ( const string::Epsilon < > &, const string::Epsilon < > & ) { return true; } -auto ExactEqualEpsilon = ExactEqual::RegistratorWrapper < bool, string::Epsilon > ( ExactEqual::equals ); +auto ExactEqualEpsilon = ExactEqual::RegistratorWrapper < bool, string::Epsilon < > > ( ExactEqual::equals ); bool ExactEqual::equals ( const string::LinearString & u, const string::LinearString & v ) { int n = ( int ) u.getContent ( ).size ( ), m = ( int ) v.getContent ( ).size ( ); diff --git a/alib2algo/src/string/naive/ExactEqual.h b/alib2algo/src/string/naive/ExactEqual.h index 5d446552d2..aa13df39ac 100644 --- a/alib2algo/src/string/naive/ExactEqual.h +++ b/alib2algo/src/string/naive/ExactEqual.h @@ -20,7 +20,7 @@ class ExactEqual : public std::PromotingDoubleDispatch<ExactEqual, bool, string: public: static bool equals(const string::String& u, const string::String& v); - static bool equals(const string::Epsilon& u, const string::Epsilon& v); + static bool equals(const string::Epsilon < >& u, const string::Epsilon < >& v); static bool equals(const string::LinearString& u, const string::LinearString& v); static bool equals(const string::CyclicString& u, const string::CyclicString& v); }; diff --git a/alib2algo/test-src/grammar/parsing/FirstTest.cpp b/alib2algo/test-src/grammar/parsing/FirstTest.cpp index 7027f7bfeb..50a413d959 100644 --- a/alib2algo/test-src/grammar/parsing/FirstTest.cpp +++ b/alib2algo/test-src/grammar/parsing/FirstTest.cpp @@ -44,30 +44,30 @@ void FirstTest::testFirst ( ) { grammar.addRule ( nF, rhsF2 ); // -------------------------------------------------- - std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > first; + std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > first; - first[rhsE1] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { + first[rhsE1] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { tA, tL }; - first[rhsE2] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { + first[rhsE2] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { tA, tL }; - first[rhsT1] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { + first[rhsT1] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { tA, tL }; - first[rhsT2] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { + first[rhsT2] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { tA, tL }; - first[rhsF1] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { + first[rhsF1] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { tA }; - first[rhsF2] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { + first[rhsF2] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { tL }; // -------------------------------------------------- - std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > firstAlgo; + std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > firstAlgo; for ( const auto & rule : grammar.getRawRules ( ) ) for ( const auto & rhs : rule.second ) @@ -126,54 +126,54 @@ void FirstTest::testFirst ( ) { grammar.addRule ( nF, rhsF2 ); // -------------------------------------------------- - std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > first; + std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > first; - first[rhsS1] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { + first[rhsS1] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { tA, tB }; - first[rhsS2] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { + first[rhsS2] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { tD }; - first[rhsS3] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { + first[rhsS3] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { tC }; - first[rhsA1] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { + first[rhsA1] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { tA }; - first[rhsA2] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { + first[rhsA2] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { tB }; - first[rhsB1] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { + first[rhsB1] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { tA }; - first[rhsB2] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { + first[rhsB2] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { tB }; - first[rhsC1] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { + first[rhsC1] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { tA }; - first[rhsC2] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { + first[rhsC2] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { tE }; - first[rhsD1] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { + first[rhsD1] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { tC }; - first[rhsE1] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { + first[rhsE1] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { tC }; - first[rhsE2] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { - string::Epsilon::EPSILON + first[rhsE2] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { + string::Epsilon < >::EPSILON }; - first[rhsF1] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { + first[rhsF1] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { tE }; - first[rhsF2] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { - string::Epsilon::EPSILON + first[rhsF2] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { + string::Epsilon < >::EPSILON }; // -------------------------------------------------- - std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > firstAlgo; + std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > firstAlgo; for ( const auto & rule : grammar.getRawRules ( ) ) for ( const auto & rhs : rule.second ) @@ -197,7 +197,7 @@ void FirstTest::testFirst2 ( ) { grammar.addRule ( A, std::vector < alphabet::Symbol > { A, c } ); grammar.addRule ( A, std::vector < alphabet::Symbol > { d } ); - std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > res = { { { d }, { d } }, { { A, c }, { d } } }; + std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > res = { { { d }, { d } }, { { A, c }, { d } } }; CPPUNIT_ASSERT ( res == grammar::parsing::First::first ( grammar ) ); } @@ -224,9 +224,9 @@ void FirstTest::testFirst3 ( ) { grammar.addRule ( B, std::vector < alphabet::Symbol > { f, S } ); grammar.addRule ( B, std::vector < alphabet::Symbol > { } ); - std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > res = + std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > res = { - { { A, a }, { c, f, a } }, { { b, S }, { b } }, { { c, A, d }, { c } }, { { B }, { f, string::Epsilon::EPSILON } }, { { f, S }, { f } }, { { }, { string::Epsilon::EPSILON } } + { { A, a }, { c, f, a } }, { { b, S }, { b } }, { { c, A, d }, { c } }, { { B }, { f, string::Epsilon < >::EPSILON } }, { { f, S }, { f } }, { { }, { string::Epsilon < >::EPSILON } } }; CPPUNIT_ASSERT ( res == grammar::parsing::First::first ( grammar ) ); } diff --git a/alib2algo/test-src/grammar/parsing/FollowTest.cpp b/alib2algo/test-src/grammar/parsing/FollowTest.cpp index d48c667fc8..208a07b8c9 100644 --- a/alib2algo/test-src/grammar/parsing/FollowTest.cpp +++ b/alib2algo/test-src/grammar/parsing/FollowTest.cpp @@ -44,21 +44,21 @@ void FollowTest::testFollow ( ) { grammar.addRule ( nF, rhsF2 ); // -------------------------------------------------- - std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > follow; + std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > follow; - follow[nE] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { - string::Epsilon::EPSILON, tP, tR + follow[nE] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { + string::Epsilon < >::EPSILON, tP, tR }; - follow[nT] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { - string::Epsilon::EPSILON, tP, tR, tS + follow[nT] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { + string::Epsilon < >::EPSILON, tP, tR, tS }; - follow[nF] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { - string::Epsilon::EPSILON, tP, tR, tS + follow[nF] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { + string::Epsilon < >::EPSILON, tP, tR, tS }; // -------------------------------------------------- - std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > followAlgo; + std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > followAlgo; for ( const auto & nt : grammar.getNonterminalAlphabet ( ) ) followAlgo[nt] = grammar::parsing::Follow::follow ( grammar, nt ); @@ -118,33 +118,33 @@ void FollowTest::testFollow ( ) { grammar.addRule ( nF, rhsF2 ); // -------------------------------------------------- - std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > follow; + std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > follow; - follow[nS] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { - string::Epsilon::EPSILON + follow[nS] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { + string::Epsilon < >::EPSILON }; - follow[nA] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { - string::Epsilon::EPSILON + follow[nA] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { + string::Epsilon < >::EPSILON }; - follow[nB] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { + follow[nB] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { tD }; - follow[nC] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { - string::Epsilon::EPSILON + follow[nC] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { + string::Epsilon < >::EPSILON }; - follow[nD] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { + follow[nD] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { tD }; - follow[nE] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { - string::Epsilon::EPSILON + follow[nE] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { + string::Epsilon < >::EPSILON }; - follow[nF] = std::set < std::variant < alphabet::Symbol, string::Epsilon > > { + follow[nF] = std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > { tD }; // -------------------------------------------------- - std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > followAlgo; + std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon < > > > > followAlgo; for ( const auto & nt : grammar.getNonterminalAlphabet ( ) ) followAlgo[nt] = grammar::parsing::Follow::follow ( grammar, nt ); diff --git a/alib2algo/test-src/grammar/parsing/LL1ParseTable.cpp b/alib2algo/test-src/grammar/parsing/LL1ParseTable.cpp index 8d7d48452e..1caad2588d 100644 --- a/alib2algo/test-src/grammar/parsing/LL1ParseTable.cpp +++ b/alib2algo/test-src/grammar/parsing/LL1ParseTable.cpp @@ -50,14 +50,14 @@ void LL1ParseTable::testLL1Table ( ) { grammar.addRule ( nF, rhsF2 ); // -------------------------------------------------- - std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > parseTable; + std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > parseTable; parseTable[std::make_pair ( tA, nE )].insert ( rhsE1 ); parseTable[std::make_pair ( tL, nE )].insert ( rhsE1 ); parseTable[std::make_pair ( tP, nEp )].insert ( rhsEp1 ); parseTable[std::make_pair ( tR, nEp )].insert ( rhsEp2 ); - parseTable[std::make_pair ( string::Epsilon::EPSILON, nEp )].insert ( rhsEp2 ); + parseTable[std::make_pair ( string::Epsilon < >::EPSILON, nEp )].insert ( rhsEp2 ); parseTable[std::make_pair ( tA, nT )].insert ( rhsT1 ); parseTable[std::make_pair ( tL, nT )].insert ( rhsT1 ); @@ -65,14 +65,14 @@ void LL1ParseTable::testLL1Table ( ) { parseTable[std::make_pair ( tS, nTp )].insert ( rhsTp1 ); parseTable[std::make_pair ( tP, nTp )].insert ( rhsTp2 ); parseTable[std::make_pair ( tR, nTp )].insert ( rhsTp2 ); - parseTable[std::make_pair ( string::Epsilon::EPSILON, nTp )].insert ( rhsTp2 ); + parseTable[std::make_pair ( string::Epsilon < >::EPSILON, nTp )].insert ( rhsTp2 ); parseTable[std::make_pair ( tA, nF )].insert ( rhsF1 ); parseTable[std::make_pair ( tL, nF )].insert ( rhsF2 ); // -------------------------------------------------- - std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > parseTableAlgo = grammar::parsing::LL1ParseTable::parseTable ( grammar ); + std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon < > >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > parseTableAlgo = grammar::parsing::LL1ParseTable::parseTable ( grammar ); std::cout << parseTable << std::endl; std::cout << parseTableAlgo << std::endl; diff --git a/alib2data/src/automaton/AutomatonFeatures.h b/alib2data/src/automaton/AutomatonFeatures.h index 0bf3c5a926..c0d058d8c7 100644 --- a/alib2data/src/automaton/AutomatonFeatures.h +++ b/alib2data/src/automaton/AutomatonFeatures.h @@ -40,7 +40,7 @@ class Automaton; class AutomatonBase; enum class Shift; -template<class SymbolType = typename alphabet::Symbol, class EpsilonType = typename string::Epsilon, class StateType = typename label::Label > +template<class SymbolType = typename alphabet::Symbol, class EpsilonType = typename string::Epsilon < SymbolType >, class StateType = typename label::Label > class EpsilonNFA; template<class SymbolType = typename alphabet::Symbol, class StateType = typename label::Label > class NFA; diff --git a/alib2data/src/automaton/FSM/CompactNFA.h b/alib2data/src/automaton/FSM/CompactNFA.h index 1756b87585..107bf0c91c 100644 --- a/alib2data/src/automaton/FSM/CompactNFA.h +++ b/alib2data/src/automaton/FSM/CompactNFA.h @@ -24,7 +24,6 @@ #include "../../label/InitialStateLabel.h" - #include "EpsilonNFA.h" #include "MultiInitialStateNFA.h" #include "NFA.h" @@ -185,7 +184,7 @@ CompactNFA < SymbolType, StateType >::CompactNFA ( StateType initialState ) : Co template < class SymbolType, class StateType > CompactNFA < SymbolType, StateType >::CompactNFA ( const EpsilonNFA < > & other ) : CompactNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) { - if ( transition.first.second.is < string::Epsilon > ( ) ) { + if ( transition.first.second.is < string::Epsilon < > > ( ) ) { std::pair < StateType, std::vector < SymbolType > > key = std::make_pair ( transition.first.first, std::vector < SymbolType > { } ); transitions[key] = transition.second; } else { diff --git a/alib2data/src/automaton/FSM/ExtendedNFA.cpp b/alib2data/src/automaton/FSM/ExtendedNFA.cpp index 49237ccfaf..88bfc87d20 100644 --- a/alib2data/src/automaton/FSM/ExtendedNFA.cpp +++ b/alib2data/src/automaton/FSM/ExtendedNFA.cpp @@ -42,7 +42,7 @@ ExtendedNFA::ExtendedNFA ( const CompactNFA < > & other ) : ExtendedNFA ( other. ExtendedNFA::ExtendedNFA ( const EpsilonNFA < > & other ) : ExtendedNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) { - if ( transition.first.second.is < string::Epsilon > ( ) ) { + if ( transition.first.second.is < string::Epsilon < > > ( ) ) { std::pair < label::Label, regexp::RegExp > key = std::make_pair ( transition.first.first, regexp::RegExp ( regexp::regexpFrom ( ) ) ); transitions[key] = transition.second; } else { diff --git a/alib2data/src/automaton/PDA/DPDA.cpp b/alib2data/src/automaton/PDA/DPDA.cpp index 9ec92f2a32..062fcd325d 100644 --- a/alib2data/src/automaton/PDA/DPDA.cpp +++ b/alib2data/src/automaton/PDA/DPDA.cpp @@ -33,7 +33,7 @@ AutomatonBase* DPDA::plunder() && { return new DPDA(std::move(*this)); } -bool DPDA::addTransition(label::Label from, std::variant<string::Epsilon, alphabet::Symbol> input, std::vector<alphabet::Symbol> pop, label::Label to, std::vector<alphabet::Symbol> push) { +bool DPDA::addTransition(label::Label from, std::variant<string::Epsilon < >, alphabet::Symbol> input, std::vector<alphabet::Symbol> pop, label::Label to, std::vector<alphabet::Symbol> push) { if (! getStates().count(from)) { throw AutomatonException("State \"" + std::to_string ( from ) + "\" doesn't exist."); } @@ -58,7 +58,7 @@ bool DPDA::addTransition(label::Label from, std::variant<string::Epsilon, alphab } } - std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> > key(std::move(from), std::move(input), std::move(pop)); + std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> > key(std::move(from), std::move(input), std::move(pop)); std::pair<label::Label, std::vector<alphabet::Symbol> > value = std::make_pair(std::move(to), std::move(push)); if (transitions.find(key) != transitions.end()) { @@ -69,11 +69,11 @@ bool DPDA::addTransition(label::Label from, std::variant<string::Epsilon, alphab "Transition (\"" + std::to_string ( std::get<0>(key) ) + "\", \"" + std::to_string ( std::get<1>(key).get<alphabet::Symbol>() ) + "\", \"pop\") -> ?? already exists."); else throw AutomatonException( - "Transition (\"" + std::to_string ( std::get<0>(key) ) + "\", \"" + std::to_string ( std::get<1>(key).get<string::Epsilon>() ) + "\", \"pop\") -> ?? already exists."); + "Transition (\"" + std::to_string ( std::get<0>(key) ) + "\", \"" + std::to_string ( std::get<1>(key).get<string::Epsilon < >>() ) + "\", \"pop\") -> ?? already exists."); } - if(std::get<1>(key).is<string::Epsilon>()) { - if(std::any_of(transitions.begin(), transitions.end(), [&](const std::pair<const std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > > & transition) { + if(std::get<1>(key).is<string::Epsilon < >>()) { + if(std::any_of(transitions.begin(), transitions.end(), [&](const std::pair<const std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > > & transition) { if(std::get<0>(transition.first) == std::get<0>(key)) { const std::vector<alphabet::Symbol>& alpha = std::get<2>(transition.first); const std::vector<alphabet::Symbol>& beta = std::get<2>(key); @@ -90,8 +90,8 @@ bool DPDA::addTransition(label::Label from, std::variant<string::Epsilon, alphab })) throw AutomatonException("Conflicting transition"); } else { - if(std::any_of(transitions.begin(), transitions.end(), [&](const std::pair<const std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > > & transition) { - if(std::get<0>(transition.first) == std::get<0>(key) && ( std::get<1>(transition.first) == std::get<1>(key) || std::get<1>(transition.first).is<string::Epsilon>() )) { + if(std::any_of(transitions.begin(), transitions.end(), [&](const std::pair<const std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > > & transition) { + if(std::get<0>(transition.first) == std::get<0>(key) && ( std::get<1>(transition.first) == std::get<1>(key) || std::get<1>(transition.first).is<string::Epsilon < >>() )) { const std::vector<alphabet::Symbol>& alpha = std::get<2>(transition.first); const std::vector<alphabet::Symbol>& beta = std::get<2>(key); @@ -113,17 +113,17 @@ bool DPDA::addTransition(label::Label from, std::variant<string::Epsilon, alphab } bool DPDA::addTransition(label::Label from, alphabet::Symbol input, std::vector<alphabet::Symbol> pop, label::Label to, std::vector<alphabet::Symbol> push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(std::move(input)); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(std::move(input)); return addTransition(std::move(from), std::move(inputVariant), std::move(pop), std::move(to), std::move(push)); } bool DPDA::addTransition(label::Label from, std::vector<alphabet::Symbol> pop, label::Label to, std::vector<alphabet::Symbol> push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(string::Epsilon::EPSILON); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(string::Epsilon < >::EPSILON); return addTransition(std::move(from), std::move(inputVariant), std::move(pop), std::move(to), std::move(push)); } -bool DPDA::removeTransition(const label::Label& from, const std::variant<string::Epsilon, alphabet::Symbol>& input, const std::vector<alphabet::Symbol>& pop, const label::Label& to, const std::vector<alphabet::Symbol>& push) { - std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> > key(from, input, pop); +bool DPDA::removeTransition(const label::Label& from, const std::variant<string::Epsilon < >, alphabet::Symbol>& input, const std::vector<alphabet::Symbol>& pop, const label::Label& to, const std::vector<alphabet::Symbol>& push) { + std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> > key(from, input, pop); std::pair<label::Label, std::vector<alphabet::Symbol> > value = std::make_pair(to, push); if (transitions.find(key) == transitions.end()) @@ -135,7 +135,7 @@ bool DPDA::removeTransition(const label::Label& from, const std::variant<string: "Transition (\"" + std::to_string ( from ) + "\", \"" + std::to_string ( input.get<alphabet::Symbol>() ) + "\") -> \"to\" doesn't exist."); else throw AutomatonException( - "Transition (\"" + std::to_string ( from ) + "\", \"" + std::to_string ( input.get<string::Epsilon>() ) + "\") -> \"to\" doesn't exist."); + "Transition (\"" + std::to_string ( from ) + "\", \"" + std::to_string ( input.get<string::Epsilon < >>() ) + "\") -> \"to\" doesn't exist."); } transitions.erase(key); @@ -143,25 +143,25 @@ bool DPDA::removeTransition(const label::Label& from, const std::variant<string: } bool DPDA::removeTransition(const label::Label& from, const alphabet::Symbol& input, const std::vector<alphabet::Symbol>& pop, const label::Label& to, const std::vector<alphabet::Symbol>& push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(input); return removeTransition(from, inputVariant, pop, to, push); } bool DPDA::removeTransition(const label::Label& from, const std::vector<alphabet::Symbol>& pop, const label::Label& to, const std::vector<alphabet::Symbol>& push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(string::Epsilon::EPSILON); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(string::Epsilon < >::EPSILON); return removeTransition(from, inputVariant, pop, to, push); } -const std::map<std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > >& DPDA::getTransitions() const { +const std::map<std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > >& DPDA::getTransitions() const { return transitions; } -std::map<std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > > DPDA::getTransitionsFromState(const label::Label& from) const { +std::map<std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > > DPDA::getTransitionsFromState(const label::Label& from) const { if( ! getStates().count(from) ) throw AutomatonException("State \"" + std::to_string ( from ) + "\" doesn't exist"); - std::map<std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > > transitionsFromState; - for (const std::pair<const std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > >& transition : transitions) { + std::map<std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > > transitionsFromState; + for (const std::pair<const std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > >& transition : transitions) { if (std::get<0>(transition.first) == from) { transitionsFromState.insert(std::make_pair(transition.first, transition.second)); } @@ -170,12 +170,12 @@ std::map<std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol return transitionsFromState; } -std::map<std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > > DPDA::getTransitionsToState(const label::Label& to) const { +std::map<std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > > DPDA::getTransitionsToState(const label::Label& to) const { if( ! getStates().count(to)) throw AutomatonException("State \"" + std::to_string ( to ) + "\" doesn't exist"); - std::map<std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > > transitionsToState; - for (const std::pair<const std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > >& transition : transitions) { + std::map<std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > > transitionsToState; + for (const std::pair<const std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > >& transition : transitions) { if (transition.second.first == to) { transitionsToState.insert(std::make_pair(transition.first, transition.second)); } @@ -235,7 +235,7 @@ DPDA DPDA::parse(std::deque<sax::Token>::iterator& input) { void DPDA::parseTransition(std::deque<sax::Token>::iterator& input, DPDA& automaton) { sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, "transition"); label::Label from = AutomatonFromXMLParser::parseTransitionFrom<label::Label>(input); - std::variant<string::Epsilon, alphabet::Symbol> inputSymbol = AutomatonFromXMLParser::parseTransitionInputEpsilonSymbol<string::Epsilon, alphabet::Symbol>(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputSymbol = AutomatonFromXMLParser::parseTransitionInputEpsilonSymbol<string::Epsilon < >, alphabet::Symbol>(input); std::vector<alphabet::Symbol> pop = AutomatonFromXMLParser::parseTransitionPop<alphabet::Symbol>(input); label::Label to = AutomatonFromXMLParser::parseTransitionTo<label::Label>(input); std::vector<alphabet::Symbol> push = AutomatonFromXMLParser::parseTransitionPush<alphabet::Symbol>(input); diff --git a/alib2data/src/automaton/PDA/DPDA.h b/alib2data/src/automaton/PDA/DPDA.h index d398f1aa58..2ed39c486b 100644 --- a/alib2data/src/automaton/PDA/DPDA.h +++ b/alib2data/src/automaton/PDA/DPDA.h @@ -37,7 +37,7 @@ class InitialState; */ class DPDA : public AutomatonBase, public std::Components < DPDA, alphabet::Symbol, std::tuple < InputAlphabet, PushdownStoreAlphabet >, std::tuple < InitialSymbol >, label::Label, std::tuple < States, FinalStates >, std::tuple < InitialState > > { protected: - std::map < std::tuple < label::Label, std::variant < string::Epsilon, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::pair < label::Label, std::vector < alphabet::Symbol > > > transitions; + std::map < std::tuple < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::pair < label::Label, std::vector < alphabet::Symbol > > > transitions; public: explicit DPDA ( std::set < label::Label > states, std::set < alphabet::Symbol > inputAlphabet, std::set < alphabet::Symbol > pushdownStoreSymbol, label::Label initialState, alphabet::Symbol initialPushdownSymbol, std::set < label::Label > finalStates ); @@ -141,7 +141,7 @@ public: * @throws AutomatonException when some part of the transition is not present * in the DPDA (state, input symbol, stack symbol) or when transition already exists */ - bool addTransition ( label::Label from, std::variant < string::Epsilon, alphabet::Symbol > input, std::vector < alphabet::Symbol > pop, label::Label to, std::vector < alphabet::Symbol > push ); + bool addTransition ( label::Label from, std::variant < string::Epsilon < >, alphabet::Symbol > input, std::vector < alphabet::Symbol > pop, label::Label to, std::vector < alphabet::Symbol > push ); bool addTransition ( label::Label from, alphabet::Symbol input, std::vector < alphabet::Symbol > pop, label::Label to, std::vector < alphabet::Symbol > push ); @@ -152,7 +152,7 @@ public: * @param transition transition to remove * @throws AutomatonException when transition is not present in the DPDA */ - bool removeTransition ( const label::Label & from, const std::variant < string::Epsilon, alphabet::Symbol > & input, const std::vector < alphabet::Symbol > & pop, const label::Label & to, const std::vector < alphabet::Symbol > & push ); + bool removeTransition ( const label::Label & from, const std::variant < string::Epsilon < >, alphabet::Symbol > & input, const std::vector < alphabet::Symbol > & pop, const label::Label & to, const std::vector < alphabet::Symbol > & push ); bool removeTransition ( const label::Label & from, const alphabet::Symbol & input, const std::vector < alphabet::Symbol > & pop, const label::Label & to, const std::vector < alphabet::Symbol > & push ); @@ -161,17 +161,17 @@ public: /** * @return DPDA transitions */ - const std::map < std::tuple < label::Label, std::variant < string::Epsilon, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::pair < label::Label, std::vector < alphabet::Symbol > > > & getTransitions ( ) const; + const std::map < std::tuple < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::pair < label::Label, std::vector < alphabet::Symbol > > > & getTransitions ( ) const; /** * @return automaton transitions from state */ - std::map < std::tuple < label::Label, std::variant < string::Epsilon, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::pair < label::Label, std::vector < alphabet::Symbol > > > getTransitionsFromState ( const label::Label & from ) const; + std::map < std::tuple < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::pair < label::Label, std::vector < alphabet::Symbol > > > getTransitionsFromState ( const label::Label & from ) const; /** * @return automaton transitions to state */ - std::map < std::tuple < label::Label, std::variant < string::Epsilon, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::pair < label::Label, std::vector < alphabet::Symbol > > > getTransitionsToState ( const label::Label & from ) const; + std::map < std::tuple < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::pair < label::Label, std::vector < alphabet::Symbol > > > getTransitionsToState ( const label::Label & from ) const; virtual int compare ( const ObjectBase & other ) const { if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); @@ -206,7 +206,7 @@ template < > class ComponentConstraint< automaton::DPDA, alphabet::Symbol, automaton::InputAlphabet > { public: static bool used ( const automaton::DPDA & automaton, const alphabet::Symbol & symbol ) { - for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > >& transition : automaton.getTransitions()) + for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > >& transition : automaton.getTransitions()) if (std::get<1>(transition.first).is<alphabet::Symbol>() && symbol == std::get<1>(transition.first).get<alphabet::Symbol>()) return true; @@ -228,7 +228,7 @@ public: if(automaton.getInitialSymbol() == symbol) return true; - for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > >& transition : automaton.getTransitions()) { + for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > >& transition : automaton.getTransitions()) { const auto & popSymbols = std::get<2>(transition.first); const auto & pushSymbols = transition.second.second; if(std::contains(popSymbols.begin(), popSymbols.end(), symbol ) || std::contains(pushSymbols.begin(), pushSymbols.end(), symbol)) @@ -267,7 +267,7 @@ public: if ( automaton.getFinalStates ( ).count ( state ) ) return true; - for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > >& transition : automaton.getTransitions()) + for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<label::Label, std::vector<alphabet::Symbol> > >& transition : automaton.getTransitions()) if ( state == std::get<0>(transition.first) || transition.second.first == state ) return true; diff --git a/alib2data/src/automaton/PDA/NPDA.cpp b/alib2data/src/automaton/PDA/NPDA.cpp index 6c11bd2582..21c50d5643 100644 --- a/alib2data/src/automaton/PDA/NPDA.cpp +++ b/alib2data/src/automaton/PDA/NPDA.cpp @@ -33,7 +33,7 @@ AutomatonBase* NPDA::plunder() && { return new NPDA(std::move(*this)); } -bool NPDA::addTransition(label::Label from, std::variant<string::Epsilon, alphabet::Symbol> input, std::vector<alphabet::Symbol> pop, label::Label to, std::vector<alphabet::Symbol> push) { +bool NPDA::addTransition(label::Label from, std::variant<string::Epsilon < >, alphabet::Symbol> input, std::vector<alphabet::Symbol> pop, label::Label to, std::vector<alphabet::Symbol> push) { if (! getStates().count(from)) throw AutomatonException("State \"" + std::to_string ( from ) + "\" doesn't exist."); @@ -51,40 +51,40 @@ bool NPDA::addTransition(label::Label from, std::variant<string::Epsilon, alphab if (! getPushdownStoreAlphabet().count(pushSymbol)) throw AutomatonException("Pushdown store symbol \"" + std::to_string ( pushSymbol ) + "\" doesn't exist."); - std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> > key(std::move(from), std::move(input), std::move(pop)); + std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> > key(std::move(from), std::move(input), std::move(pop)); std::pair<label::Label, std::vector<alphabet::Symbol> > value = std::make_pair(std::move(to), std::move(push)); return transitions[std::move(key)].insert(std::move(value)).second; } bool NPDA::addTransition(label::Label from, alphabet::Symbol input, std::vector<alphabet::Symbol> pop, label::Label to, std::vector<alphabet::Symbol> push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(std::move(input)); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(std::move(input)); return addTransition(std::move(from), std::move(inputVariant), std::move(pop), std::move(to), std::move(push)); } bool NPDA::addTransition(label::Label from, std::vector<alphabet::Symbol> pop, label::Label to, std::vector<alphabet::Symbol> push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(string::Epsilon::EPSILON); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(string::Epsilon < >::EPSILON); return addTransition(std::move(from), std::move(inputVariant), std::move(pop), std::move(to), std::move(push)); } -bool NPDA::removeTransition(const label::Label& from, const std::variant<string::Epsilon, alphabet::Symbol>& input, const std::vector<alphabet::Symbol>& pop, const label::Label& to, const std::vector<alphabet::Symbol>& push) { - std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> > key(from, input, pop); +bool NPDA::removeTransition(const label::Label& from, const std::variant<string::Epsilon < >, alphabet::Symbol>& input, const std::vector<alphabet::Symbol>& pop, const label::Label& to, const std::vector<alphabet::Symbol>& push) { + std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> > key(from, input, pop); std::pair<label::Label, std::vector<alphabet::Symbol> > value = std::make_pair(to, push); return transitions[key].erase(value); } bool NPDA::removeTransition(const label::Label& from, const alphabet::Symbol& input, const std::vector<alphabet::Symbol>& pop, const label::Label& to, const std::vector<alphabet::Symbol>& push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(input); return removeTransition(from, inputVariant, pop, to, push); } bool NPDA::removeTransition(const label::Label& from, const std::vector<alphabet::Symbol>& pop, const label::Label& to, const std::vector<alphabet::Symbol>& push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(string::Epsilon::EPSILON); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(string::Epsilon < >::EPSILON); return removeTransition(from, inputVariant, pop, to, push); } -const std::map<std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::pair<label::Label, std::vector<alphabet::Symbol> > > >& NPDA::getTransitions() const { +const std::map<std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::pair<label::Label, std::vector<alphabet::Symbol> > > >& NPDA::getTransitions() const { return transitions; } @@ -139,7 +139,7 @@ NPDA NPDA::parse(std::deque<sax::Token>::iterator& input) { void NPDA::parseTransition(std::deque<sax::Token>::iterator& input, NPDA& automaton) { sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, "transition"); label::Label from = AutomatonFromXMLParser::parseTransitionFrom<label::Label>(input); - std::variant<string::Epsilon, alphabet::Symbol> inputSymbol = AutomatonFromXMLParser::parseTransitionInputEpsilonSymbol<string::Epsilon, alphabet::Symbol>(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputSymbol = AutomatonFromXMLParser::parseTransitionInputEpsilonSymbol<string::Epsilon < >, alphabet::Symbol>(input); std::vector<alphabet::Symbol> pop = AutomatonFromXMLParser::parseTransitionPop<alphabet::Symbol>(input); label::Label to = AutomatonFromXMLParser::parseTransitionTo<label::Label>(input); std::vector<alphabet::Symbol> push = AutomatonFromXMLParser::parseTransitionPush<alphabet::Symbol>(input); diff --git a/alib2data/src/automaton/PDA/NPDA.h b/alib2data/src/automaton/PDA/NPDA.h index 076d736491..48673a9c00 100644 --- a/alib2data/src/automaton/PDA/NPDA.h +++ b/alib2data/src/automaton/PDA/NPDA.h @@ -33,7 +33,7 @@ class InitialState; */ class NPDA : public AutomatonBase, public std::Components < NPDA, alphabet::Symbol, std::tuple < InputAlphabet, PushdownStoreAlphabet >, std::tuple < InitialSymbol >, label::Label, std::tuple < States, FinalStates >, std::tuple < InitialState > > { protected: - std::map < std::tuple < label::Label, std::variant < string::Epsilon, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::set < std::pair < label::Label, std::vector < alphabet::Symbol > > > > transitions; + std::map < std::tuple < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::set < std::pair < label::Label, std::vector < alphabet::Symbol > > > > transitions; public: explicit NPDA ( std::set < label::Label > states, std::set < alphabet::Symbol > inputAlphabet, std::set < alphabet::Symbol > pushdownStoreSymbol, label::Label initialState, alphabet::Symbol initialPushdownSymbol, std::set < label::Label > finalStates ); @@ -137,7 +137,7 @@ public: * @throws AutomatonException when some part of the transition is not present * in the NPDA (state, input symbol, stack symbol) or when transition already exists */ - bool addTransition ( label::Label from, std::variant < string::Epsilon, alphabet::Symbol > input, std::vector < alphabet::Symbol > pop, label::Label to, std::vector < alphabet::Symbol > push ); + bool addTransition ( label::Label from, std::variant < string::Epsilon < >, alphabet::Symbol > input, std::vector < alphabet::Symbol > pop, label::Label to, std::vector < alphabet::Symbol > push ); bool addTransition ( label::Label from, alphabet::Symbol input, std::vector < alphabet::Symbol > pop, label::Label to, std::vector < alphabet::Symbol > push ); @@ -148,7 +148,7 @@ public: * @param transition transition to remove * @throws AutomatonException when transition is not present in the NPDA */ - bool removeTransition ( const label::Label & from, const std::variant < string::Epsilon, alphabet::Symbol > & input, const std::vector < alphabet::Symbol > & pop, const label::Label & to, const std::vector < alphabet::Symbol > & push ); + bool removeTransition ( const label::Label & from, const std::variant < string::Epsilon < >, alphabet::Symbol > & input, const std::vector < alphabet::Symbol > & pop, const label::Label & to, const std::vector < alphabet::Symbol > & push ); bool removeTransition ( const label::Label & from, const alphabet::Symbol & input, const std::vector < alphabet::Symbol > & pop, const label::Label & to, const std::vector < alphabet::Symbol > & push ); @@ -157,7 +157,7 @@ public: /** * @return NPDA transitions */ - const std::map < std::tuple < label::Label, std::variant < string::Epsilon, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::set < std::pair < label::Label, std::vector < alphabet::Symbol > > > > & getTransitions ( ) const; + const std::map < std::tuple < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::set < std::pair < label::Label, std::vector < alphabet::Symbol > > > > & getTransitions ( ) const; virtual int compare ( const ObjectBase & other ) const { if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); @@ -192,7 +192,7 @@ template < > class ComponentConstraint< automaton::NPDA, alphabet::Symbol, automaton::InputAlphabet > { public: static bool used ( const automaton::NPDA & automaton, const alphabet::Symbol & symbol ) { - for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::pair<label::Label, std::vector<alphabet::Symbol> > > >& transition : automaton.getTransitions()) + for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::pair<label::Label, std::vector<alphabet::Symbol> > > >& transition : automaton.getTransitions()) if (std::get<1>(transition.first).is<alphabet::Symbol>() && symbol == std::get<1>(transition.first).get<alphabet::Symbol>()) return true; @@ -214,7 +214,7 @@ public: if(automaton.getInitialSymbol() == symbol) return true; - for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::pair<label::Label, std::vector<alphabet::Symbol> > > >& transition : automaton.getTransitions()) { + for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::pair<label::Label, std::vector<alphabet::Symbol> > > >& transition : automaton.getTransitions()) { for (const alphabet::Symbol& popSymbol : std::get<2>(transition.first)) if (symbol == popSymbol) return true; @@ -256,7 +256,7 @@ public: if ( automaton.getFinalStates ( ).count ( state ) ) return true; - for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::pair<label::Label, std::vector<alphabet::Symbol> > > >& transition : automaton.getTransitions()) { + for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::pair<label::Label, std::vector<alphabet::Symbol> > > >& transition : automaton.getTransitions()) { if (state == std::get<0>(transition.first)) return true; for(const std::pair<label::Label, std::vector<alphabet::Symbol> >& target : transition.second) diff --git a/alib2data/src/automaton/PDA/NPDTA.cpp b/alib2data/src/automaton/PDA/NPDTA.cpp index 8f334f1e9b..cf3b3c0a39 100644 --- a/alib2data/src/automaton/PDA/NPDTA.cpp +++ b/alib2data/src/automaton/PDA/NPDTA.cpp @@ -33,7 +33,7 @@ AutomatonBase* NPDTA::plunder() && { return new NPDTA(std::move(*this)); } -bool NPDTA::addTransition(label::Label from, std::variant<string::Epsilon, alphabet::Symbol> input, std::vector<alphabet::Symbol> pop, label::Label to, std::vector<alphabet::Symbol> push, std::vector<alphabet::Symbol> output) { +bool NPDTA::addTransition(label::Label from, std::variant<string::Epsilon < >, alphabet::Symbol> input, std::vector<alphabet::Symbol> pop, label::Label to, std::vector<alphabet::Symbol> push, std::vector<alphabet::Symbol> output) { if (!getStates().count(from)) { throw AutomatonException("State \"" + std::to_string ( from ) + "\" doesn't exist."); } @@ -64,48 +64,48 @@ bool NPDTA::addTransition(label::Label from, std::variant<string::Epsilon, alpha } } - std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> > key(std::move(from), std::move(input), std::move(pop)); + std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> > key(std::move(from), std::move(input), std::move(pop)); std::tuple<label::Label, std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol> > value(std::move(to), std::move(push), std::move(output)); return transitions[std::move(key)].insert(std::move(value)).second; } bool NPDTA::addTransition(label::Label from, alphabet::Symbol input, std::vector<alphabet::Symbol> pop, label::Label to, std::vector<alphabet::Symbol> push, std::vector<alphabet::Symbol> output) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(std::move(input)); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(std::move(input)); return addTransition(std::move(from), std::move(inputVariant), std::move(pop), std::move(to), std::move(push), std::move(output)); } bool NPDTA::addTransition(label::Label from, std::vector<alphabet::Symbol> pop, label::Label to, std::vector<alphabet::Symbol> push, std::vector<alphabet::Symbol> output) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(string::Epsilon::EPSILON); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(string::Epsilon < >::EPSILON); return addTransition(std::move(from), std::move(inputVariant), std::move(pop), std::move(to), std::move(push), std::move(output)); } -bool NPDTA::removeTransition(const label::Label& from, const std::variant<string::Epsilon, alphabet::Symbol>& input, const std::vector<alphabet::Symbol>& pop, const label::Label& to, const std::vector<alphabet::Symbol>& push, const std::vector<alphabet::Symbol>& output) { - std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> > key(from, input, pop); +bool NPDTA::removeTransition(const label::Label& from, const std::variant<string::Epsilon < >, alphabet::Symbol>& input, const std::vector<alphabet::Symbol>& pop, const label::Label& to, const std::vector<alphabet::Symbol>& push, const std::vector<alphabet::Symbol>& output) { + std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> > key(from, input, pop); std::tuple<label::Label, std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol> > value(to, push, output); return transitions[key].erase(value); } bool NPDTA::removeTransition(const label::Label& from, const alphabet::Symbol& input, const std::vector<alphabet::Symbol>& pop, const label::Label& to, const std::vector<alphabet::Symbol>& push, const std::vector<alphabet::Symbol>& output) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(input); return removeTransition(from, inputVariant, pop, to, push, output); } bool NPDTA::removeTransition(const label::Label& from, const std::vector<alphabet::Symbol>& pop, const label::Label& to, const std::vector<alphabet::Symbol>& push, const std::vector<alphabet::Symbol>& output) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(string::Epsilon::EPSILON); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(string::Epsilon < >::EPSILON); return removeTransition(from, inputVariant, pop, to, push, output); } -const std::map<std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::tuple<label::Label, std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol> > > >& NPDTA::getTransitions() const { +const std::map<std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::tuple<label::Label, std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol> > > >& NPDTA::getTransitions() const { return transitions; } -std::set < std::pair < std::tuple < label::Label, std::variant < string::Epsilon, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::tuple < label::Label, std::vector < alphabet::Symbol >, std::vector < alphabet::Symbol > > > > NPDTA::getTransitionsFromState ( const label::Label & from ) const { +std::set < std::pair < std::tuple < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::tuple < label::Label, std::vector < alphabet::Symbol >, std::vector < alphabet::Symbol > > > > NPDTA::getTransitionsFromState ( const label::Label & from ) const { if( !getStates().count(from)) throw AutomatonException("State \"" + std::to_string ( from ) + "\" doesn't exist"); - std::set < std::pair < std::tuple < label::Label, std::variant < string::Epsilon, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::tuple < label::Label, std::vector < alphabet::Symbol >, std::vector < alphabet::Symbol > > > > transitionsFromState; + std::set < std::pair < std::tuple < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::tuple < label::Label, std::vector < alphabet::Symbol >, std::vector < alphabet::Symbol > > > > transitionsFromState; for ( auto transition: transitions ) { for ( auto iter: transition.second ) { if ( std::get<0>(transition.first) == from ) { @@ -171,7 +171,7 @@ NPDTA NPDTA::parse(std::deque<sax::Token>::iterator& input) { void NPDTA::parseTransition(std::deque<sax::Token>::iterator& input, NPDTA& automaton) { sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, "transition"); label::Label from = AutomatonFromXMLParser::parseTransitionFrom<label::Label>(input); - std::variant<string::Epsilon, alphabet::Symbol> inputSymbol = AutomatonFromXMLParser::parseTransitionInputEpsilonSymbol<string::Epsilon, alphabet::Symbol>(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputSymbol = AutomatonFromXMLParser::parseTransitionInputEpsilonSymbol<string::Epsilon < >, alphabet::Symbol>(input); std::vector<alphabet::Symbol> pop = AutomatonFromXMLParser::parseTransitionPop<alphabet::Symbol>(input); label::Label to = AutomatonFromXMLParser::parseTransitionTo<label::Label>(input); std::vector<alphabet::Symbol> push = AutomatonFromXMLParser::parseTransitionPush<alphabet::Symbol>(input); diff --git a/alib2data/src/automaton/PDA/NPDTA.h b/alib2data/src/automaton/PDA/NPDTA.h index 4cdd49114a..8fcb46a0bc 100644 --- a/alib2data/src/automaton/PDA/NPDTA.h +++ b/alib2data/src/automaton/PDA/NPDTA.h @@ -34,7 +34,7 @@ class InitialState; */ class NPDTA : public AutomatonBase, public std::Components < NPDTA, alphabet::Symbol, std::tuple < InputAlphabet, OutputAlphabet, PushdownStoreAlphabet >, std::tuple < InitialSymbol >, label::Label, std::tuple < States, FinalStates >, std::tuple < InitialState > > { protected: - std::map < std::tuple < label::Label, std::variant < string::Epsilon, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::set < std::tuple < label::Label, std::vector < alphabet::Symbol >, std::vector < alphabet::Symbol > > > > transitions; + std::map < std::tuple < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::set < std::tuple < label::Label, std::vector < alphabet::Symbol >, std::vector < alphabet::Symbol > > > > transitions; public: explicit NPDTA ( std::set < label::Label > states, std::set < alphabet::Symbol > inputAlphabet, std::set < alphabet::Symbol > outputAlphabet, std::set < alphabet::Symbol > pushdownStoreSymbol, label::Label initialState, alphabet::Symbol initialPushdownSymbol, std::set < label::Label > finalStates ); @@ -159,7 +159,7 @@ public: * @throws AutomatonException when some part of the transition is not present * in the NPDTA (state, input symbol, stack symbol, output symbol) or when transition already exists */ - bool addTransition ( label::Label from, std::variant < string::Epsilon, alphabet::Symbol > input, std::vector < alphabet::Symbol > pop, label::Label to, std::vector < alphabet::Symbol > push, std::vector < alphabet::Symbol > output ); + bool addTransition ( label::Label from, std::variant < string::Epsilon < >, alphabet::Symbol > input, std::vector < alphabet::Symbol > pop, label::Label to, std::vector < alphabet::Symbol > push, std::vector < alphabet::Symbol > output ); bool addTransition ( label::Label from, alphabet::Symbol input, std::vector < alphabet::Symbol > pop, label::Label to, std::vector < alphabet::Symbol > push, std::vector < alphabet::Symbol > output ); @@ -170,7 +170,7 @@ public: * @param transition transition to remove * @throws AutomatonException when transition is not present in the NPDTA */ - bool removeTransition ( const label::Label & from, const std::variant < string::Epsilon, alphabet::Symbol > & input, const std::vector < alphabet::Symbol > & pop, const label::Label & to, const std::vector < alphabet::Symbol > & push, const std::vector < alphabet::Symbol > & output ); + bool removeTransition ( const label::Label & from, const std::variant < string::Epsilon < >, alphabet::Symbol > & input, const std::vector < alphabet::Symbol > & pop, const label::Label & to, const std::vector < alphabet::Symbol > & push, const std::vector < alphabet::Symbol > & output ); bool removeTransition ( const label::Label & from, const alphabet::Symbol & input, const std::vector < alphabet::Symbol > & pop, const label::Label & to, const std::vector < alphabet::Symbol > & push, const std::vector < alphabet::Symbol > & output ); @@ -179,9 +179,9 @@ public: /** * @return NPDTA transitions */ - const std::map < std::tuple < label::Label, std::variant < string::Epsilon, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::set < std::tuple < label::Label, std::vector < alphabet::Symbol >, std::vector < alphabet::Symbol > > > > & getTransitions ( ) const; + const std::map < std::tuple < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::set < std::tuple < label::Label, std::vector < alphabet::Symbol >, std::vector < alphabet::Symbol > > > > & getTransitions ( ) const; - std::set < std::pair < std::tuple < label::Label, std::variant < string::Epsilon, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::tuple < label::Label, std::vector < alphabet::Symbol >, std::vector < alphabet::Symbol > > > > getTransitionsFromState ( const label::Label & from ) const; + std::set < std::pair < std::tuple < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::tuple < label::Label, std::vector < alphabet::Symbol >, std::vector < alphabet::Symbol > > > > getTransitionsFromState ( const label::Label & from ) const; virtual int compare ( const ObjectBase & other ) const { if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); @@ -216,7 +216,7 @@ template < > class ComponentConstraint< automaton::NPDTA, alphabet::Symbol, automaton::InputAlphabet > { public: static bool used ( const automaton::NPDTA & automaton, const alphabet::Symbol & symbol ) { - for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::tuple<label::Label, std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol> > > >& transition : automaton.getTransitions()) + for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::tuple<label::Label, std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol> > > >& transition : automaton.getTransitions()) if (std::get<1>(transition.first).is<alphabet::Symbol>() && symbol == std::get<1>(transition.first).get<alphabet::Symbol>()) return true; @@ -235,7 +235,7 @@ template < > class ComponentConstraint< automaton::NPDTA, alphabet::Symbol, automaton::OutputAlphabet > { public: static bool used ( const automaton::NPDTA & automaton, const alphabet::Symbol & symbol ) { - for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::tuple<label::Label, std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol> > > >& transition : automaton.getTransitions()) + for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::tuple<label::Label, std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol> > > >& transition : automaton.getTransitions()) for(const std::tuple<label::Label, std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol> >& target : transition.second) if (std::find(std::get<2>(target).begin(), std::get<2>(target).end(), symbol) != std::get<2>(target).end()) return true; @@ -258,7 +258,7 @@ public: if(automaton.getInitialSymbol() == symbol) return true; - for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::tuple<label::Label, std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol> > > >& transition : automaton.getTransitions()) { + for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::tuple<label::Label, std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol> > > >& transition : automaton.getTransitions()) { for (const alphabet::Symbol& popSymbol : std::get<2>(transition.first)) if (symbol == popSymbol) return true; @@ -300,7 +300,7 @@ public: if ( automaton.getFinalStates ( ).count ( state ) ) return true; - for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::tuple<label::Label, std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol> > > >& transition : automaton.getTransitions()) { + for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::tuple<label::Label, std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol> > > >& transition : automaton.getTransitions()) { if (state == std::get<0>(transition.first)) return true; diff --git a/alib2data/src/automaton/PDA/RealTimeHeightDeterministicDPDA.cpp b/alib2data/src/automaton/PDA/RealTimeHeightDeterministicDPDA.cpp index f42ee70d0e..55a14c9e9e 100644 --- a/alib2data/src/automaton/PDA/RealTimeHeightDeterministicDPDA.cpp +++ b/alib2data/src/automaton/PDA/RealTimeHeightDeterministicDPDA.cpp @@ -33,7 +33,7 @@ AutomatonBase* RealTimeHeightDeterministicDPDA::plunder() && { return new RealTimeHeightDeterministicDPDA(std::move(*this)); } -bool RealTimeHeightDeterministicDPDA::addCallTransition(label::Label from, std::variant<string::Epsilon, alphabet::Symbol> input, label::Label to, alphabet::Symbol push) { +bool RealTimeHeightDeterministicDPDA::addCallTransition(label::Label from, std::variant<string::Epsilon < >, alphabet::Symbol> input, label::Label to, alphabet::Symbol push) { if (!getStates().count(from)) { throw AutomatonException("State \"" + std::to_string ( from ) + "\" doesn't exist."); } @@ -53,13 +53,13 @@ bool RealTimeHeightDeterministicDPDA::addCallTransition(label::Label from, std:: if(getBottomOfTheStackSymbol() == push) throw AutomatonException("Pushdown store symbol \"" + std::to_string ( push ) + "\" is bottom of the stack."); - std::pair<label::Label, std::variant<string::Epsilon, alphabet::Symbol>> key(std::move(from), std::move(input)); + std::pair<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>> key(std::move(from), std::move(input)); std::pair<label::Label, alphabet::Symbol> value = std::make_pair(std::move(to), std::move(push)); if(callTransitions.find(key) != callTransitions.end() && callTransitions.find(key)->second == value) return false; - if(key.second.is<string::Epsilon>()) { + if(key.second.is<string::Epsilon < >>()) { for(const auto& transition : callTransitions) if(transition.first.first == key.first ) throw AutomatonException("Can't add epsilon transition from state \"" + std::to_string ( key.first ) + "\" when other transitions are present."); @@ -73,15 +73,15 @@ bool RealTimeHeightDeterministicDPDA::addCallTransition(label::Label from, std:: throw AutomatonException("Can't add epsilon transition from state \"" + std::to_string ( from ) + "\" when other transitions are present."); } else { for(const auto& transition : callTransitions) - if(transition.first.first == key.first && (transition.first.second.is<string::Epsilon>() || transition.first.second == key.second)) + if(transition.first.first == key.first && (transition.first.second.is<string::Epsilon < >>() || transition.first.second == key.second)) throw AutomatonException("Can't add transition from state \"" + std::to_string ( key.first ) + "\" when transition reading \"" + std::to_string ( key.second ) + "\" is present."); for(const auto& transition : returnTransitions) - if(std::get<0>(transition.first) == key.first && (std::get<1>(transition.first).is<string::Epsilon>() || std::get<1>(transition.first) == key.second)) + if(std::get<0>(transition.first) == key.first && (std::get<1>(transition.first).is<string::Epsilon < >>() || std::get<1>(transition.first) == key.second)) throw AutomatonException("Can't add transition from state \"" + std::to_string ( key.first ) + "\" when transition reading \"" + std::to_string ( key.second ) + "\" is present."); for(const auto& transition : localTransitions) - if(transition.first.first == key.first && (transition.first.second.is<string::Epsilon>() || transition.first.second == key.second)) + if(transition.first.first == key.first && (transition.first.second.is<string::Epsilon < >>() || transition.first.second == key.second)) throw AutomatonException("Can't add transition from state \"" + std::to_string ( key.first ) + "\" when transition reading \"" + std::to_string ( key.second ) + "\" is present."); } @@ -90,16 +90,16 @@ bool RealTimeHeightDeterministicDPDA::addCallTransition(label::Label from, std:: } bool RealTimeHeightDeterministicDPDA::addCallTransition(label::Label from, label::Label to, alphabet::Symbol push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(string::Epsilon::EPSILON); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(string::Epsilon < >::EPSILON); return addCallTransition(std::move(from), std::move(inputVariant), std::move(to), std::move(push)); } bool RealTimeHeightDeterministicDPDA::addCallTransition(label::Label from, alphabet::Symbol input, label::Label to, alphabet::Symbol push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(std::move(input)); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(std::move(input)); return addCallTransition(std::move(from), std::move(inputVariant), std::move(to), std::move(push)); } -bool RealTimeHeightDeterministicDPDA::addReturnTransition(label::Label from, std::variant<string::Epsilon, alphabet::Symbol> input, alphabet::Symbol pop, label::Label to) { +bool RealTimeHeightDeterministicDPDA::addReturnTransition(label::Label from, std::variant<string::Epsilon < >, alphabet::Symbol> input, alphabet::Symbol pop, label::Label to) { if (!getStates().count(from)) { throw AutomatonException("State \"" + std::to_string ( from ) + "\" doesn't exist."); } @@ -116,12 +116,12 @@ bool RealTimeHeightDeterministicDPDA::addReturnTransition(label::Label from, std throw AutomatonException("Pushdown store symbol \"" + std::to_string ( pop ) + "\" doesn't exist."); } - std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol> key(std::move(from), std::move(input), std::move(pop)); + std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol> key(std::move(from), std::move(input), std::move(pop)); if(returnTransitions.find(key) != returnTransitions.end() && returnTransitions.find(key)->second == to) return false; - if(std::get<1>(key).is<string::Epsilon>()) { + if(std::get<1>(key).is<string::Epsilon < >>()) { for(const auto& transition : callTransitions) if(transition.first.first == std::get<0>(key) ) throw AutomatonException("Can't add epsilon transition from state \"" + std::to_string ( std::get<0>(key) ) + "\" when other transitions are present."); @@ -135,15 +135,15 @@ bool RealTimeHeightDeterministicDPDA::addReturnTransition(label::Label from, std throw AutomatonException("Can't add epsilon transition from state \"" + std::to_string ( std::get<0>(key) ) + "\" when other transitions are present."); } else { for(const auto& transition : callTransitions) - if(transition.first.first == std::get<0>(key) && (transition.first.second.is<string::Epsilon>() || transition.first.second == std::get<1>(key))) + if(transition.first.first == std::get<0>(key) && (transition.first.second.is<string::Epsilon < >>() || transition.first.second == std::get<1>(key))) throw AutomatonException("Can't add transition from state \"" + std::to_string ( std::get<0>(key) ) + "\" when transition reading \"" + std::to_string ( std::get<1>(key) ) + "\" is present."); for(const auto& transition : returnTransitions) - if(std::get<0>(transition.first) == std::get<0>(key) && (std::get<1>(transition.first).is<string::Epsilon>() || std::get<1>(transition.first) == std::get<1>(key)) && std::get<2>(transition.first) == std::get<2>(key)) + if(std::get<0>(transition.first) == std::get<0>(key) && (std::get<1>(transition.first).is<string::Epsilon < >>() || std::get<1>(transition.first) == std::get<1>(key)) && std::get<2>(transition.first) == std::get<2>(key)) throw AutomatonException("Can't add transition from state \"" + std::to_string ( std::get<0>(key) ) + "\" when transition reading \"" + std::to_string ( std::get<1>(key) ) + "\" is present."); for(const auto& transition : localTransitions) - if(transition.first.first == std::get<0>(key) && (transition.first.second.is<string::Epsilon>() || transition.first.second == std::get<1>(key))) + if(transition.first.first == std::get<0>(key) && (transition.first.second.is<string::Epsilon < >>() || transition.first.second == std::get<1>(key))) throw AutomatonException("Can't add transition from state \"" + std::to_string ( std::get<0>(key) ) + "\" when transition reading \"" + std::to_string ( std::get<1>(key) ) + "\" is present."); } @@ -152,16 +152,16 @@ bool RealTimeHeightDeterministicDPDA::addReturnTransition(label::Label from, std } bool RealTimeHeightDeterministicDPDA::addReturnTransition(label::Label from, alphabet::Symbol pop, label::Label to) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(string::Epsilon::EPSILON); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(string::Epsilon < >::EPSILON); return addReturnTransition(std::move(from), std::move(inputVariant), std::move(pop), std::move(to)); } bool RealTimeHeightDeterministicDPDA::addReturnTransition(label::Label from, alphabet::Symbol input, alphabet::Symbol pop, label::Label to) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(std::move(input)); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(std::move(input)); return addReturnTransition(std::move(from), std::move(inputVariant), std::move(pop), std::move(to)); } -bool RealTimeHeightDeterministicDPDA::addLocalTransition(label::Label from, std::variant<string::Epsilon, alphabet::Symbol> input, label::Label to) { +bool RealTimeHeightDeterministicDPDA::addLocalTransition(label::Label from, std::variant<string::Epsilon < >, alphabet::Symbol> input, label::Label to) { if (!getStates().count(from)) { throw AutomatonException("State \"" + std::to_string ( from ) + "\" doesn't exist."); } @@ -174,12 +174,12 @@ bool RealTimeHeightDeterministicDPDA::addLocalTransition(label::Label from, std: throw AutomatonException("State \"" + std::to_string ( to ) + "\" doesn't exist."); } - std::pair<label::Label, std::variant<string::Epsilon, alphabet::Symbol>> key(std::move(from), std::move(input)); + std::pair<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>> key(std::move(from), std::move(input)); if(localTransitions.find(key) != localTransitions.end() && localTransitions.find(key)->second == to) return false; - if(key.second.is<string::Epsilon>()) { + if(key.second.is<string::Epsilon < >>()) { for(const auto& transition : callTransitions) if(transition.first.first == key.first ) throw AutomatonException("Can't add epsilon transition from state \"" + std::to_string ( key.first ) + "\" when other transitions are present."); @@ -193,15 +193,15 @@ bool RealTimeHeightDeterministicDPDA::addLocalTransition(label::Label from, std: throw AutomatonException("Can't add epsilon transition from state \"" + std::to_string ( key.first ) + "\" when other transitions are present."); } else { for(const auto& transition : callTransitions) - if(transition.first.first == key.first && (transition.first.second.is<string::Epsilon>() || transition.first.second == key.second)) + if(transition.first.first == key.first && (transition.first.second.is<string::Epsilon < >>() || transition.first.second == key.second)) throw AutomatonException("Can't add transition from state \"" + std::to_string ( key.first ) + "\" when transition reading \"" + std::to_string ( key.second ) + "\" is present."); for(const auto& transition : returnTransitions) - if(std::get<0>(transition.first) == key.first && (std::get<1>(transition.first).is<string::Epsilon>() || std::get<1>(transition.first) == key.second)) + if(std::get<0>(transition.first) == key.first && (std::get<1>(transition.first).is<string::Epsilon < >>() || std::get<1>(transition.first) == key.second)) throw AutomatonException("Can't add transition from state \"" + std::to_string ( key.first ) + "\" when transition reading \"" + std::to_string ( key.second ) + "\" is present."); for(const auto& transition : localTransitions) - if(transition.first.first == key.first && (transition.first.second.is<string::Epsilon>() || transition.first.second == key.second)) + if(transition.first.first == key.first && (transition.first.second.is<string::Epsilon < >>() || transition.first.second == key.second)) throw AutomatonException("Can't add transition from state \"" + std::to_string ( key.first ) + "\" when transition reading \"" + std::to_string ( key.second ) + "\" is present."); } @@ -210,17 +210,17 @@ bool RealTimeHeightDeterministicDPDA::addLocalTransition(label::Label from, std: } bool RealTimeHeightDeterministicDPDA::addLocalTransition(label::Label from, label::Label to) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(string::Epsilon::EPSILON); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(string::Epsilon < >::EPSILON); return addLocalTransition(std::move(from), std::move(inputVariant), std::move(to)); } bool RealTimeHeightDeterministicDPDA::addLocalTransition(label::Label from, alphabet::Symbol input, label::Label to) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(std::move(input)); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(std::move(input)); return addLocalTransition(std::move(from), std::move(inputVariant), std::move(to)); } -bool RealTimeHeightDeterministicDPDA::removeCallTransition(const label::Label& from, const std::variant<string::Epsilon, alphabet::Symbol>& input, const label::Label& to, const alphabet::Symbol& push) { - std::pair<label::Label, std::variant<string::Epsilon, alphabet::Symbol>> key(from, input); +bool RealTimeHeightDeterministicDPDA::removeCallTransition(const label::Label& from, const std::variant<string::Epsilon < >, alphabet::Symbol>& input, const label::Label& to, const alphabet::Symbol& push) { + std::pair<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>> key(from, input); std::pair<label::Label, alphabet::Symbol> value = std::make_pair(to, push); if (callTransitions.find(key) == callTransitions.end()) @@ -234,17 +234,17 @@ bool RealTimeHeightDeterministicDPDA::removeCallTransition(const label::Label& f } bool RealTimeHeightDeterministicDPDA::removeCallTransition(const label::Label& from, const label::Label& to, const alphabet::Symbol& push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(string::Epsilon::EPSILON); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(string::Epsilon < >::EPSILON); return removeCallTransition(from, inputVariant, to, push); } bool RealTimeHeightDeterministicDPDA::removeCallTransition(const label::Label& from, const alphabet::Symbol& input, const label::Label& to, const alphabet::Symbol& push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(input); return removeCallTransition(from, inputVariant, to, push); } -bool RealTimeHeightDeterministicDPDA::removeReturnTransition(const label::Label& from, const std::variant<string::Epsilon, alphabet::Symbol>& input, const alphabet::Symbol& pop, const label::Label& to) { - std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol> key(from, input, pop); +bool RealTimeHeightDeterministicDPDA::removeReturnTransition(const label::Label& from, const std::variant<string::Epsilon < >, alphabet::Symbol>& input, const alphabet::Symbol& pop, const label::Label& to) { + std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol> key(from, input, pop); if (returnTransitions.find(key) == returnTransitions.end()) return false; @@ -257,17 +257,17 @@ bool RealTimeHeightDeterministicDPDA::removeReturnTransition(const label::Label& } bool RealTimeHeightDeterministicDPDA::removeReturnTransition(const label::Label& from, const alphabet::Symbol& pop, const label::Label& to) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(string::Epsilon::EPSILON); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(string::Epsilon < >::EPSILON); return removeReturnTransition(from, inputVariant, pop, to); } bool RealTimeHeightDeterministicDPDA::removeReturnTransition(const label::Label& from, const alphabet::Symbol& input, const alphabet::Symbol& pop, const label::Label& to) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(input); return removeReturnTransition(from, inputVariant, pop, to); } -bool RealTimeHeightDeterministicDPDA::removeLocalTransition(const label::Label& from, const std::variant<string::Epsilon, alphabet::Symbol>& input, const label::Label& to) { - std::pair<label::Label, std::variant<string::Epsilon, alphabet::Symbol>> key(from, input); +bool RealTimeHeightDeterministicDPDA::removeLocalTransition(const label::Label& from, const std::variant<string::Epsilon < >, alphabet::Symbol>& input, const label::Label& to) { + std::pair<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>> key(from, input); if (localTransitions.find(key) == localTransitions.end()) return false; @@ -280,24 +280,24 @@ bool RealTimeHeightDeterministicDPDA::removeLocalTransition(const label::Label& } bool RealTimeHeightDeterministicDPDA::removeLocalTransition(const label::Label& from, const label::Label& to) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(string::Epsilon::EPSILON); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(string::Epsilon < >::EPSILON); return removeLocalTransition(from, inputVariant, to); } bool RealTimeHeightDeterministicDPDA::removeLocalTransition(const label::Label& from, const alphabet::Symbol& input, const label::Label& to) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(input); return removeLocalTransition(from, inputVariant, to); } -const std::map<std::pair<label::Label, std::variant<string::Epsilon, alphabet::Symbol>>, std::pair<label::Label, alphabet::Symbol> >& RealTimeHeightDeterministicDPDA::getCallTransitions() const { +const std::map<std::pair<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>>, std::pair<label::Label, alphabet::Symbol> >& RealTimeHeightDeterministicDPDA::getCallTransitions() const { return callTransitions; } -const std::map<std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, label::Label>& RealTimeHeightDeterministicDPDA::getReturnTransitions() const { +const std::map<std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol>, label::Label>& RealTimeHeightDeterministicDPDA::getReturnTransitions() const { return returnTransitions; } -const std::map<std::pair<label::Label, std::variant<string::Epsilon, alphabet::Symbol>>, label::Label>& RealTimeHeightDeterministicDPDA::getLocalTransitions() const { +const std::map<std::pair<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>>, label::Label>& RealTimeHeightDeterministicDPDA::getLocalTransitions() const { return localTransitions; } @@ -355,7 +355,7 @@ void RealTimeHeightDeterministicDPDA::parseTransition(std::deque<sax::Token>::it if(sax::FromXMLParserHelper::isToken(input, sax::Token::TokenType::START_ELEMENT, "callTransition")) { sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, "callTransition"); label::Label from = AutomatonFromXMLParser::parseTransitionFrom<label::Label>(input); - std::variant<string::Epsilon, alphabet::Symbol> inputSymbol = AutomatonFromXMLParser::parseTransitionInputEpsilonSymbol<string::Epsilon,alphabet::Symbol>(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputSymbol = AutomatonFromXMLParser::parseTransitionInputEpsilonSymbol<string::Epsilon < >,alphabet::Symbol>(input); label::Label to = AutomatonFromXMLParser::parseTransitionTo<label::Label>(input); alphabet::Symbol push = AutomatonFromXMLParser::parseTransitionSinglePush<alphabet::Symbol>(input); @@ -364,7 +364,7 @@ void RealTimeHeightDeterministicDPDA::parseTransition(std::deque<sax::Token>::it } else if(sax::FromXMLParserHelper::isToken(input, sax::Token::TokenType::START_ELEMENT, "returnTransition")) { sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, "returnTransition"); label::Label from = AutomatonFromXMLParser::parseTransitionFrom<label::Label>(input); - std::variant<string::Epsilon, alphabet::Symbol> inputSymbol = AutomatonFromXMLParser::parseTransitionInputEpsilonSymbol<string::Epsilon,alphabet::Symbol>(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputSymbol = AutomatonFromXMLParser::parseTransitionInputEpsilonSymbol<string::Epsilon < >,alphabet::Symbol>(input); alphabet::Symbol pop = AutomatonFromXMLParser::parseTransitionSinglePop<alphabet::Symbol>(input); label::Label to = AutomatonFromXMLParser::parseTransitionTo<label::Label>(input); @@ -373,7 +373,7 @@ void RealTimeHeightDeterministicDPDA::parseTransition(std::deque<sax::Token>::it } else { sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, "localTransition"); label::Label from = AutomatonFromXMLParser::parseTransitionFrom<label::Label>(input); - std::variant<string::Epsilon, alphabet::Symbol> inputSymbol = AutomatonFromXMLParser::parseTransitionInputEpsilonSymbol<string::Epsilon,alphabet::Symbol>(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputSymbol = AutomatonFromXMLParser::parseTransitionInputEpsilonSymbol<string::Epsilon < >,alphabet::Symbol>(input); label::Label to = AutomatonFromXMLParser::parseTransitionTo<label::Label>(input); automaton.addLocalTransition(std::move(from), std::move(inputSymbol), std::move(to)); diff --git a/alib2data/src/automaton/PDA/RealTimeHeightDeterministicDPDA.h b/alib2data/src/automaton/PDA/RealTimeHeightDeterministicDPDA.h index 8f6b03bafb..8f61268de0 100644 --- a/alib2data/src/automaton/PDA/RealTimeHeightDeterministicDPDA.h +++ b/alib2data/src/automaton/PDA/RealTimeHeightDeterministicDPDA.h @@ -33,9 +33,9 @@ class InitialState; */ class RealTimeHeightDeterministicDPDA : public AutomatonBase, public std::Components < RealTimeHeightDeterministicDPDA, alphabet::Symbol, std::tuple < InputAlphabet, PushdownStoreAlphabet >, std::tuple < BottomOfTheStackSymbol >, label::Label, std::tuple < States, FinalStates >, std::tuple < InitialState > > { protected: - std::map < std::pair < label::Label, std::variant < string::Epsilon, alphabet::Symbol > >, std::pair < label::Label, alphabet::Symbol > > callTransitions; - std::map < std::tuple < label::Label, std::variant < string::Epsilon, alphabet::Symbol >, alphabet::Symbol >, label::Label > returnTransitions; - std::map < std::pair < label::Label, std::variant < string::Epsilon, alphabet::Symbol > >, label::Label > localTransitions; + std::map < std::pair < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol > >, std::pair < label::Label, alphabet::Symbol > > callTransitions; + std::map < std::tuple < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol >, alphabet::Symbol >, label::Label > returnTransitions; + std::map < std::pair < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol > >, label::Label > localTransitions; public: explicit RealTimeHeightDeterministicDPDA ( std::set < label::Label > states, std::set < alphabet::Symbol > inputAlphabet, std::set < alphabet::Symbol > pushdownStoreSymbol, label::Label initialState, alphabet::Symbol bottomOfTheStackSymbol, std::set < label::Label > finalStates ); @@ -140,7 +140,7 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addCallTransition ( label::Label current, std::variant < string::Epsilon, alphabet::Symbol > input, label::Label next, alphabet::Symbol push ); + bool addCallTransition ( label::Label current, std::variant < string::Epsilon < >, alphabet::Symbol > input, label::Label next, alphabet::Symbol push ); bool addCallTransition ( label::Label current, label::Label next, alphabet::Symbol push ); bool addCallTransition ( label::Label current, alphabet::Symbol input, label::Label next, alphabet::Symbol push ); @@ -151,7 +151,7 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addReturnTransition ( label::Label current, std::variant < string::Epsilon, alphabet::Symbol > input, alphabet::Symbol pop, label::Label next ); + bool addReturnTransition ( label::Label current, std::variant < string::Epsilon < >, alphabet::Symbol > input, alphabet::Symbol pop, label::Label next ); bool addReturnTransition ( label::Label current, alphabet::Symbol pop, label::Label next ); bool addReturnTransition ( label::Label current, alphabet::Symbol input, alphabet::Symbol pop, label::Label next ); @@ -162,7 +162,7 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addLocalTransition ( label::Label current, std::variant < string::Epsilon, alphabet::Symbol > input, label::Label next ); + bool addLocalTransition ( label::Label current, std::variant < string::Epsilon < >, alphabet::Symbol > input, label::Label next ); bool addLocalTransition ( label::Label current, label::Label next ); bool addLocalTransition ( label::Label current, alphabet::Symbol input, label::Label next ); @@ -171,7 +171,7 @@ public: * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeCallTransition ( const label::Label & current, const std::variant < string::Epsilon, alphabet::Symbol > & input, const label::Label & next, const alphabet::Symbol & push ); + bool removeCallTransition ( const label::Label & current, const std::variant < string::Epsilon < >, alphabet::Symbol > & input, const label::Label & next, const alphabet::Symbol & push ); bool removeCallTransition ( const label::Label & current, const label::Label & next, const alphabet::Symbol & push ); bool removeCallTransition ( const label::Label & current, const alphabet::Symbol & input, const label::Label & next, const alphabet::Symbol & push ); @@ -180,7 +180,7 @@ public: * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeReturnTransition ( const label::Label & current, const std::variant < string::Epsilon, alphabet::Symbol > & input, const alphabet::Symbol & pop, const label::Label & next ); + bool removeReturnTransition ( const label::Label & current, const std::variant < string::Epsilon < >, alphabet::Symbol > & input, const alphabet::Symbol & pop, const label::Label & next ); bool removeReturnTransition ( const label::Label & current, const alphabet::Symbol & pop, const label::Label & next ); bool removeReturnTransition ( const label::Label & current, const alphabet::Symbol & input, const alphabet::Symbol & pop, const label::Label & next ); @@ -189,15 +189,15 @@ public: * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeLocalTransition ( const label::Label & current, const std::variant < string::Epsilon, alphabet::Symbol > & input, const label::Label & next ); + bool removeLocalTransition ( const label::Label & current, const std::variant < string::Epsilon < >, alphabet::Symbol > & input, const label::Label & next ); bool removeLocalTransition ( const label::Label & current, const label::Label & next ); bool removeLocalTransition ( const label::Label & current, const alphabet::Symbol & input, const label::Label & next ); - const std::map < std::pair < label::Label, std::variant < string::Epsilon, alphabet::Symbol > >, std::pair < label::Label, alphabet::Symbol > > & getCallTransitions ( ) const; + const std::map < std::pair < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol > >, std::pair < label::Label, alphabet::Symbol > > & getCallTransitions ( ) const; - const std::map < std::tuple < label::Label, std::variant < string::Epsilon, alphabet::Symbol >, alphabet::Symbol >, label::Label > & getReturnTransitions ( ) const; + const std::map < std::tuple < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol >, alphabet::Symbol >, label::Label > & getReturnTransitions ( ) const; - const std::map < std::pair < label::Label, std::variant < string::Epsilon, alphabet::Symbol > >, label::Label > & getLocalTransitions ( ) const; + const std::map < std::pair < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol > >, label::Label > & getLocalTransitions ( ) const; virtual int compare ( const ObjectBase & other ) const { if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); @@ -232,15 +232,15 @@ template < > class ComponentConstraint< automaton::RealTimeHeightDeterministicDPDA, alphabet::Symbol, automaton::InputAlphabet > { public: static bool used ( const automaton::RealTimeHeightDeterministicDPDA & automaton, const alphabet::Symbol & symbol ) { - for (const std::pair<const std::pair<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>>, std::pair<label::Label, alphabet::Symbol> >& callTransition : automaton.getCallTransitions()) + for (const std::pair<const std::pair<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>>, std::pair<label::Label, alphabet::Symbol> >& callTransition : automaton.getCallTransitions()) if (callTransition.first.second.is<alphabet::Symbol>() && symbol == callTransition.first.second.get<alphabet::Symbol>()) return true; - for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, label::Label>& returnTransition : automaton.getReturnTransitions()) + for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol>, label::Label>& returnTransition : automaton.getReturnTransitions()) if (std::get<1>(returnTransition.first).is<alphabet::Symbol>() && symbol == std::get<1>(returnTransition.first).get<alphabet::Symbol>()) return true; - for (const std::pair<const std::pair<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>>, label::Label>& localTransition : automaton.getLocalTransitions()) + for (const std::pair<const std::pair<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>>, label::Label>& localTransition : automaton.getLocalTransitions()) if (localTransition.first.second.is<alphabet::Symbol>() && symbol == localTransition.first.second.get<alphabet::Symbol>()) return true; @@ -259,11 +259,11 @@ template < > class ComponentConstraint< automaton::RealTimeHeightDeterministicDPDA, alphabet::Symbol, automaton::PushdownStoreAlphabet > { public: static bool used ( const automaton::RealTimeHeightDeterministicDPDA & automaton, const alphabet::Symbol & symbol ) { - for (const std::pair<const std::pair<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>>, std::pair<label::Label, alphabet::Symbol> >& callTransition : automaton.getCallTransitions()) + for (const std::pair<const std::pair<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>>, std::pair<label::Label, alphabet::Symbol> >& callTransition : automaton.getCallTransitions()) if (symbol == callTransition.second.second) return true; - for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, label::Label>& returnTransition : automaton.getReturnTransitions()) + for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol>, label::Label>& returnTransition : automaton.getReturnTransitions()) if (symbol == std::get<2>(returnTransition.first)) return true; @@ -302,15 +302,15 @@ public: if ( automaton.getFinalStates ( ).count ( state ) ) return true; - for (const std::pair<const std::pair<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>>, std::pair<label::Label, alphabet::Symbol> >& callTransition : automaton.getCallTransitions()) + for (const std::pair<const std::pair<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>>, std::pair<label::Label, alphabet::Symbol> >& callTransition : automaton.getCallTransitions()) if (state == callTransition.first.first || callTransition.second.first == state) return true; - for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, label::Label>& returnTransition : automaton.getReturnTransitions()) + for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol>, label::Label>& returnTransition : automaton.getReturnTransitions()) if (state == std::get<0>(returnTransition.first) || returnTransition.second == state) return true; - for (const std::pair<const std::pair<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>>, label::Label>& localTransition : automaton.getLocalTransitions()) + for (const std::pair<const std::pair<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>>, label::Label>& localTransition : automaton.getLocalTransitions()) if (state == localTransition.first.first || localTransition.second == state) return true; diff --git a/alib2data/src/automaton/PDA/RealTimeHeightDeterministicNPDA.cpp b/alib2data/src/automaton/PDA/RealTimeHeightDeterministicNPDA.cpp index 6d9667745b..53a6992a94 100644 --- a/alib2data/src/automaton/PDA/RealTimeHeightDeterministicNPDA.cpp +++ b/alib2data/src/automaton/PDA/RealTimeHeightDeterministicNPDA.cpp @@ -33,7 +33,7 @@ AutomatonBase* RealTimeHeightDeterministicNPDA::plunder() && { return new RealTimeHeightDeterministicNPDA(std::move(*this)); } -bool RealTimeHeightDeterministicNPDA::addCallTransition(label::Label from, std::variant<string::Epsilon, alphabet::Symbol> input, label::Label to, alphabet::Symbol push) { +bool RealTimeHeightDeterministicNPDA::addCallTransition(label::Label from, std::variant<string::Epsilon < >, alphabet::Symbol> input, label::Label to, alphabet::Symbol push) { if (! getStates().count(from)) { throw AutomatonException("State \"" + std::to_string ( from ) + "\" doesn't exist."); } @@ -50,23 +50,23 @@ bool RealTimeHeightDeterministicNPDA::addCallTransition(label::Label from, std:: throw AutomatonException("Pushdown store symbol \"" + std::to_string ( push ) + "\" doesn't exist."); } - std::pair<label::Label, std::variant<string::Epsilon, alphabet::Symbol>> key(std::move(from), std::move(input)); + std::pair<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>> key(std::move(from), std::move(input)); std::pair<label::Label, alphabet::Symbol> value = std::make_pair(std::move(to), std::move(push)); return callTransitions[std::move(key)].insert(std::move(value)).second; } bool RealTimeHeightDeterministicNPDA::addCallTransition(label::Label from, label::Label to, alphabet::Symbol push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(string::Epsilon::EPSILON); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(string::Epsilon < >::EPSILON); return addCallTransition(std::move(from), std::move(inputVariant), std::move(to), std::move(push)); } bool RealTimeHeightDeterministicNPDA::addCallTransition(label::Label from, alphabet::Symbol input, label::Label to, alphabet::Symbol push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(input); return addCallTransition(std::move(from), std::move(inputVariant), std::move(to), std::move(push)); } -bool RealTimeHeightDeterministicNPDA::addReturnTransition(label::Label from, std::variant<string::Epsilon, alphabet::Symbol> input, alphabet::Symbol pop, label::Label to) { +bool RealTimeHeightDeterministicNPDA::addReturnTransition(label::Label from, std::variant<string::Epsilon < >, alphabet::Symbol> input, alphabet::Symbol pop, label::Label to) { if (! getStates().count(from)) { throw AutomatonException("State \"" + std::to_string ( from ) + "\" doesn't exist."); } @@ -83,22 +83,22 @@ bool RealTimeHeightDeterministicNPDA::addReturnTransition(label::Label from, std throw AutomatonException("Pushdown store symbol \"" + std::to_string ( pop ) + "\" doesn't exist."); } - std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol> key(std::move(from), std::move(input), std::move(pop)); + std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol> key(std::move(from), std::move(input), std::move(pop)); return returnTransitions[std::move(key)].insert(std::move(to)).second; } bool RealTimeHeightDeterministicNPDA::addReturnTransition(label::Label from, alphabet::Symbol pop, label::Label to) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(string::Epsilon::EPSILON); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(string::Epsilon < >::EPSILON); return addReturnTransition(std::move(from), std::move(inputVariant), std::move(pop), std::move(to)); } bool RealTimeHeightDeterministicNPDA::addReturnTransition(label::Label from, alphabet::Symbol input, alphabet::Symbol pop, label::Label to) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(std::move(input)); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(std::move(input)); return addReturnTransition(std::move(from), std::move(inputVariant), std::move(pop), std::move(to)); } -bool RealTimeHeightDeterministicNPDA::addLocalTransition(label::Label from, std::variant<string::Epsilon, alphabet::Symbol> input, label::Label to) { +bool RealTimeHeightDeterministicNPDA::addLocalTransition(label::Label from, std::variant<string::Epsilon < >, alphabet::Symbol> input, label::Label to) { if (! getStates().count(from)) { throw AutomatonException("State \"" + std::to_string ( from ) + "\" doesn't exist."); } @@ -111,79 +111,79 @@ bool RealTimeHeightDeterministicNPDA::addLocalTransition(label::Label from, std: throw AutomatonException("State \"" + std::to_string ( to ) + "\" doesn't exist."); } - std::pair<label::Label, std::variant<string::Epsilon, alphabet::Symbol>> key(std::move(from), std::move(input)); + std::pair<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>> key(std::move(from), std::move(input)); return localTransitions[std::move(key)].insert(std::move(to)).second; } bool RealTimeHeightDeterministicNPDA::addLocalTransition(label::Label from, label::Label to) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(string::Epsilon::EPSILON); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(string::Epsilon < >::EPSILON); return addLocalTransition(std::move(from), std::move(inputVariant), std::move(to)); } bool RealTimeHeightDeterministicNPDA::addLocalTransition(label::Label from, alphabet::Symbol input, label::Label to) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(std::move(input)); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(std::move(input)); return addLocalTransition(std::move(from), std::move(inputVariant), std::move(to)); } -bool RealTimeHeightDeterministicNPDA::removeCallTransition(const label::Label& from, const std::variant<string::Epsilon, alphabet::Symbol>& input, const label::Label& to, const alphabet::Symbol& push) { - std::pair<label::Label, std::variant<string::Epsilon, alphabet::Symbol>> key(from, input); +bool RealTimeHeightDeterministicNPDA::removeCallTransition(const label::Label& from, const std::variant<string::Epsilon < >, alphabet::Symbol>& input, const label::Label& to, const alphabet::Symbol& push) { + std::pair<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>> key(from, input); std::pair<label::Label, alphabet::Symbol> value = std::make_pair(to, push); return callTransitions[key].erase(value); } bool RealTimeHeightDeterministicNPDA::removeCallTransition(const label::Label& from, const label::Label& to, const alphabet::Symbol& push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(string::Epsilon::EPSILON); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(string::Epsilon < >::EPSILON); return removeCallTransition(from, inputVariant, to, push); } bool RealTimeHeightDeterministicNPDA::removeCallTransition(const label::Label& from, const alphabet::Symbol& input, const label::Label& to, const alphabet::Symbol& push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(input); return removeCallTransition(from, inputVariant, to, push); } -bool RealTimeHeightDeterministicNPDA::removeReturnTransition(const label::Label& from, const std::variant<string::Epsilon, alphabet::Symbol>& input, const alphabet::Symbol& pop, const label::Label& to) { - std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol> key(from, input, pop); +bool RealTimeHeightDeterministicNPDA::removeReturnTransition(const label::Label& from, const std::variant<string::Epsilon < >, alphabet::Symbol>& input, const alphabet::Symbol& pop, const label::Label& to) { + std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol> key(from, input, pop); return returnTransitions[key].erase(to); } bool RealTimeHeightDeterministicNPDA::removeReturnTransition(const label::Label& from, const alphabet::Symbol& pop, const label::Label& to) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(string::Epsilon::EPSILON); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(string::Epsilon < >::EPSILON); return removeReturnTransition(from, inputVariant, pop, to); } bool RealTimeHeightDeterministicNPDA::removeReturnTransition(const label::Label& from, const alphabet::Symbol& input, const alphabet::Symbol& pop, const label::Label& to) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(input); return removeReturnTransition(from, inputVariant, pop, to); } -bool RealTimeHeightDeterministicNPDA::removeLocalTransition(const label::Label& from, const std::variant<string::Epsilon, alphabet::Symbol>& input, const label::Label& to) { - std::pair<label::Label, std::variant<string::Epsilon, alphabet::Symbol>> key(from, input); +bool RealTimeHeightDeterministicNPDA::removeLocalTransition(const label::Label& from, const std::variant<string::Epsilon < >, alphabet::Symbol>& input, const label::Label& to) { + std::pair<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>> key(from, input); return localTransitions[key].erase(to); } bool RealTimeHeightDeterministicNPDA::removeLocalTransition(const label::Label& from, const label::Label& to) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(string::Epsilon::EPSILON); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(string::Epsilon < >::EPSILON); return removeLocalTransition(from, inputVariant, to); } bool RealTimeHeightDeterministicNPDA::removeLocalTransition(const label::Label& from, const alphabet::Symbol& input, const label::Label& to) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(input); return removeLocalTransition(from, inputVariant, to); } -const std::map<std::pair<label::Label, std::variant<string::Epsilon, alphabet::Symbol>>, std::set<std::pair<label::Label, alphabet::Symbol> > >& RealTimeHeightDeterministicNPDA::getCallTransitions() const { +const std::map<std::pair<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>>, std::set<std::pair<label::Label, alphabet::Symbol> > >& RealTimeHeightDeterministicNPDA::getCallTransitions() const { return callTransitions; } -const std::map<std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::set<label::Label> >& RealTimeHeightDeterministicNPDA::getReturnTransitions() const { +const std::map<std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol>, std::set<label::Label> >& RealTimeHeightDeterministicNPDA::getReturnTransitions() const { return returnTransitions; } -const std::map<std::pair<label::Label, std::variant<string::Epsilon, alphabet::Symbol>>, std::set<label::Label> >& RealTimeHeightDeterministicNPDA::getLocalTransitions() const { +const std::map<std::pair<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>>, std::set<label::Label> >& RealTimeHeightDeterministicNPDA::getLocalTransitions() const { return localTransitions; } @@ -242,7 +242,7 @@ void RealTimeHeightDeterministicNPDA::parseTransition(std::deque<sax::Token>::it if(sax::FromXMLParserHelper::isToken(input, sax::Token::TokenType::START_ELEMENT, "callTransition")) { sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, "callTransition"); label::Label from = AutomatonFromXMLParser::parseTransitionFrom<label::Label>(input); - std::variant<string::Epsilon, alphabet::Symbol> inputSymbol = AutomatonFromXMLParser::parseTransitionInputEpsilonSymbol<string::Epsilon, alphabet::Symbol>(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputSymbol = AutomatonFromXMLParser::parseTransitionInputEpsilonSymbol<string::Epsilon < >, alphabet::Symbol>(input); label::Label to = AutomatonFromXMLParser::parseTransitionTo<label::Label>(input); alphabet::Symbol push = AutomatonFromXMLParser::parseTransitionSinglePush<alphabet::Symbol>(input); @@ -251,7 +251,7 @@ void RealTimeHeightDeterministicNPDA::parseTransition(std::deque<sax::Token>::it } else if(sax::FromXMLParserHelper::isToken(input, sax::Token::TokenType::START_ELEMENT, "returnTransition")) { sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, "returnTransition"); label::Label from = AutomatonFromXMLParser::parseTransitionFrom<label::Label>(input); - std::variant<string::Epsilon, alphabet::Symbol> inputSymbol = AutomatonFromXMLParser::parseTransitionInputEpsilonSymbol<string::Epsilon, alphabet::Symbol>(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputSymbol = AutomatonFromXMLParser::parseTransitionInputEpsilonSymbol<string::Epsilon < >, alphabet::Symbol>(input); alphabet::Symbol pop = AutomatonFromXMLParser::parseTransitionSinglePop<alphabet::Symbol>(input); label::Label to = AutomatonFromXMLParser::parseTransitionTo<label::Label>(input); @@ -260,7 +260,7 @@ void RealTimeHeightDeterministicNPDA::parseTransition(std::deque<sax::Token>::it } else { sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, "localTransition"); label::Label from = AutomatonFromXMLParser::parseTransitionFrom<label::Label>(input); - std::variant<string::Epsilon, alphabet::Symbol> inputSymbol = AutomatonFromXMLParser::parseTransitionInputEpsilonSymbol<string::Epsilon, alphabet::Symbol>(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputSymbol = AutomatonFromXMLParser::parseTransitionInputEpsilonSymbol<string::Epsilon < >, alphabet::Symbol>(input); label::Label to = AutomatonFromXMLParser::parseTransitionTo<label::Label>(input); automaton.addLocalTransition(std::move(from), std::move(inputSymbol), std::move(to)); diff --git a/alib2data/src/automaton/PDA/RealTimeHeightDeterministicNPDA.h b/alib2data/src/automaton/PDA/RealTimeHeightDeterministicNPDA.h index 6d34a069ec..1e21e84115 100644 --- a/alib2data/src/automaton/PDA/RealTimeHeightDeterministicNPDA.h +++ b/alib2data/src/automaton/PDA/RealTimeHeightDeterministicNPDA.h @@ -33,9 +33,9 @@ class InitialStates; */ class RealTimeHeightDeterministicNPDA : public AutomatonBase, public std::Components < RealTimeHeightDeterministicNPDA, alphabet::Symbol, std::tuple < InputAlphabet, PushdownStoreAlphabet >, std::tuple < BottomOfTheStackSymbol >, label::Label, std::tuple < States, InitialStates, FinalStates >, std::tuple < > > { protected: - std::map < std::pair < label::Label, std::variant < string::Epsilon, alphabet::Symbol > >, std::set < std::pair < label::Label, alphabet::Symbol > > > callTransitions; - std::map < std::tuple < label::Label, std::variant < string::Epsilon, alphabet::Symbol >, alphabet::Symbol >, std::set < label::Label > > returnTransitions; - std::map < std::pair < label::Label, std::variant < string::Epsilon, alphabet::Symbol > >, std::set < label::Label > > localTransitions; + std::map < std::pair < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol > >, std::set < std::pair < label::Label, alphabet::Symbol > > > callTransitions; + std::map < std::tuple < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol >, alphabet::Symbol >, std::set < label::Label > > returnTransitions; + std::map < std::pair < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol > >, std::set < label::Label > > localTransitions; public: explicit RealTimeHeightDeterministicNPDA ( std::set < label::Label > states, std::set < alphabet::Symbol > inputAlphabet, std::set < alphabet::Symbol > pushdownStoreSymbol, std::set < label::Label > initialStates, alphabet::Symbol bottomOfTheStackSymbol, std::set < label::Label > finalStates ); @@ -148,7 +148,7 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addCallTransition ( label::Label current, std::variant < string::Epsilon, alphabet::Symbol > input, label::Label next, alphabet::Symbol push ); + bool addCallTransition ( label::Label current, std::variant < string::Epsilon < >, alphabet::Symbol > input, label::Label next, alphabet::Symbol push ); bool addCallTransition ( label::Label current, label::Label next, alphabet::Symbol push ); bool addCallTransition ( label::Label current, alphabet::Symbol input, label::Label next, alphabet::Symbol push ); @@ -159,7 +159,7 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addReturnTransition ( label::Label current, std::variant < string::Epsilon, alphabet::Symbol > input, alphabet::Symbol pop, label::Label next ); + bool addReturnTransition ( label::Label current, std::variant < string::Epsilon < >, alphabet::Symbol > input, alphabet::Symbol pop, label::Label next ); bool addReturnTransition ( label::Label current, alphabet::Symbol pop, label::Label next ); bool addReturnTransition ( label::Label current, alphabet::Symbol input, alphabet::Symbol pop, label::Label next ); @@ -170,7 +170,7 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addLocalTransition ( label::Label current, std::variant < string::Epsilon, alphabet::Symbol > input, label::Label next ); + bool addLocalTransition ( label::Label current, std::variant < string::Epsilon < >, alphabet::Symbol > input, label::Label next ); bool addLocalTransition ( label::Label current, label::Label next ); bool addLocalTransition ( label::Label current, alphabet::Symbol input, label::Label next ); @@ -179,7 +179,7 @@ public: * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeCallTransition ( const label::Label & current, const std::variant < string::Epsilon, alphabet::Symbol > & input, const label::Label & next, const alphabet::Symbol & push ); + bool removeCallTransition ( const label::Label & current, const std::variant < string::Epsilon < >, alphabet::Symbol > & input, const label::Label & next, const alphabet::Symbol & push ); bool removeCallTransition ( const label::Label & current, const label::Label & next, const alphabet::Symbol & push ); bool removeCallTransition ( const label::Label & current, const alphabet::Symbol & input, const label::Label & next, const alphabet::Symbol & push ); @@ -188,7 +188,7 @@ public: * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeReturnTransition ( const label::Label & current, const std::variant < string::Epsilon, alphabet::Symbol > & input, const alphabet::Symbol & pop, const label::Label & next ); + bool removeReturnTransition ( const label::Label & current, const std::variant < string::Epsilon < >, alphabet::Symbol > & input, const alphabet::Symbol & pop, const label::Label & next ); bool removeReturnTransition ( const label::Label & current, const alphabet::Symbol & pop, const label::Label & next ); bool removeReturnTransition ( const label::Label & current, const alphabet::Symbol & input, const alphabet::Symbol & pop, const label::Label & next ); @@ -197,15 +197,15 @@ public: * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeLocalTransition ( const label::Label & current, const std::variant < string::Epsilon, alphabet::Symbol > & input, const label::Label & next ); + bool removeLocalTransition ( const label::Label & current, const std::variant < string::Epsilon < >, alphabet::Symbol > & input, const label::Label & next ); bool removeLocalTransition ( const label::Label & current, const label::Label & next ); bool removeLocalTransition ( const label::Label & current, const alphabet::Symbol & input, const label::Label & next ); - const std::map < std::pair < label::Label, std::variant < string::Epsilon, alphabet::Symbol > >, std::set < std::pair < label::Label, alphabet::Symbol > > > & getCallTransitions ( ) const; + const std::map < std::pair < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol > >, std::set < std::pair < label::Label, alphabet::Symbol > > > & getCallTransitions ( ) const; - const std::map < std::tuple < label::Label, std::variant < string::Epsilon, alphabet::Symbol >, alphabet::Symbol >, std::set < label::Label > > & getReturnTransitions ( ) const; + const std::map < std::tuple < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol >, alphabet::Symbol >, std::set < label::Label > > & getReturnTransitions ( ) const; - const std::map < std::pair < label::Label, std::variant < string::Epsilon, alphabet::Symbol > >, std::set < label::Label > > & getLocalTransitions ( ) const; + const std::map < std::pair < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol > >, std::set < label::Label > > & getLocalTransitions ( ) const; virtual int compare ( const ObjectBase & other ) const { if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); @@ -240,15 +240,15 @@ template < > class ComponentConstraint< automaton::RealTimeHeightDeterministicNPDA, alphabet::Symbol, automaton::InputAlphabet > { public: static bool used ( const automaton::RealTimeHeightDeterministicNPDA & automaton, const alphabet::Symbol & symbol ) { - for (const std::pair<const std::pair<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>>, std::set<std::pair<label::Label, alphabet::Symbol> > >& callTransition : automaton.getCallTransitions()) + for (const std::pair<const std::pair<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>>, std::set<std::pair<label::Label, alphabet::Symbol> > >& callTransition : automaton.getCallTransitions()) if (callTransition.first.second.is<alphabet::Symbol>() && symbol == callTransition.first.second.get<alphabet::Symbol>()) return true; - for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::set<label::Label> >& returnTransition : automaton.getReturnTransitions()) + for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol>, std::set<label::Label> >& returnTransition : automaton.getReturnTransitions()) if (std::get<1>(returnTransition.first).is<alphabet::Symbol>() && symbol == std::get<1>(returnTransition.first).get<alphabet::Symbol>()) return true; - for (const std::pair<const std::pair<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>>, std::set<label::Label> >& localTransition : automaton.getLocalTransitions()) + for (const std::pair<const std::pair<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>>, std::set<label::Label> >& localTransition : automaton.getLocalTransitions()) if (localTransition.first.second.is<alphabet::Symbol>() && symbol == localTransition.first.second.get<alphabet::Symbol>()) return true; @@ -270,12 +270,12 @@ public: if(automaton.getBottomOfTheStackSymbol() == symbol) return true; - for (const std::pair<const std::pair<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>>, std::set<std::pair<label::Label, alphabet::Symbol> > >& callTransition : automaton.getCallTransitions()) + for (const std::pair<const std::pair<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>>, std::set<std::pair<label::Label, alphabet::Symbol> > >& callTransition : automaton.getCallTransitions()) for(const std::pair<label::Label, alphabet::Symbol>& to : callTransition.second) if (symbol == to.second) return true; - for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::set<label::Label> >& returnTransition : automaton.getReturnTransitions()) + for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol>, std::set<label::Label> >& returnTransition : automaton.getReturnTransitions()) if (symbol == std::get<2>(returnTransition.first)) return true; @@ -311,7 +311,7 @@ public: if ( automaton.getFinalStates ( ).count ( state ) ) return true; - for (const std::pair<const std::pair<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>>, std::set<std::pair<label::Label, alphabet::Symbol> > >& callTransition : automaton.getCallTransitions()) { + for (const std::pair<const std::pair<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>>, std::set<std::pair<label::Label, alphabet::Symbol> > >& callTransition : automaton.getCallTransitions()) { if (state == callTransition.first.first) return true; @@ -320,7 +320,7 @@ public: return true; } - for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::set<label::Label> >& returnTransition : automaton.getReturnTransitions()) { + for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol>, std::set<label::Label> >& returnTransition : automaton.getReturnTransitions()) { if (state == std::get<0>(returnTransition.first)) return true; @@ -329,7 +329,7 @@ public: return true; } - for (const std::pair<const std::pair<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>>, std::set<label::Label> >& localTransition : automaton.getLocalTransitions()) { + for (const std::pair<const std::pair<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>>, std::set<label::Label> >& localTransition : automaton.getLocalTransitions()) { if (state == localTransition.first.first) return true; diff --git a/alib2data/src/automaton/PDA/SinglePopDPDA.cpp b/alib2data/src/automaton/PDA/SinglePopDPDA.cpp index 8153373c77..ba69138bd6 100644 --- a/alib2data/src/automaton/PDA/SinglePopDPDA.cpp +++ b/alib2data/src/automaton/PDA/SinglePopDPDA.cpp @@ -34,7 +34,7 @@ AutomatonBase* SinglePopDPDA::plunder() && { return new SinglePopDPDA(std::move(*this)); } -bool SinglePopDPDA::addTransition(label::Label from, std::variant<string::Epsilon, alphabet::Symbol> input, alphabet::Symbol pop, label::Label to, std::vector<alphabet::Symbol> push) { +bool SinglePopDPDA::addTransition(label::Label from, std::variant<string::Epsilon < >, alphabet::Symbol> input, alphabet::Symbol pop, label::Label to, std::vector<alphabet::Symbol> push) { if (!getStates().count(from)) { throw AutomatonException("State \"" + std::to_string ( from ) + "\" doesn't exist."); } @@ -57,7 +57,7 @@ bool SinglePopDPDA::addTransition(label::Label from, std::variant<string::Epsilo } } - std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol> key(std::move(from), std::move(input), std::move(pop)); + std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol> key(std::move(from), std::move(input), std::move(pop)); std::pair<label::Label, std::vector<alphabet::Symbol> > value = std::make_pair(std::move(to), std::move(push)); if (transitions.find(key) != transitions.end()) { @@ -66,17 +66,17 @@ bool SinglePopDPDA::addTransition(label::Label from, std::variant<string::Epsilo else if (input.is<alphabet::Symbol>()) throw AutomatonException("Transition (\"" + std::to_string ( std::get<0>(key) ) + "\", \"" + std::to_string ( std::get<1>(key).get<alphabet::Symbol>() ) + "\", \"" + std::to_string ( std::get<2>(key) ) + "\") -> ?? already exists."); else - throw AutomatonException("Transition (\"" + std::to_string ( std::get<0>(key) ) + "\", \"" + std::to_string ( std::get<1>(key).get<string::Epsilon>() ) + "\", \"" + std::to_string ( std::get<2>(key) ) + "\") -> ?? already exists."); + throw AutomatonException("Transition (\"" + std::to_string ( std::get<0>(key) ) + "\", \"" + std::to_string ( std::get<1>(key).get<string::Epsilon < >>() ) + "\", \"" + std::to_string ( std::get<2>(key) ) + "\") -> ?? already exists."); } - if(input.is<string::Epsilon>()) { - if(std::any_of(transitions.begin(), transitions.end(), [&](const std::pair<std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::pair<label::Label, std::vector<alphabet::Symbol> > > & transition) { + if(input.is<string::Epsilon < >>()) { + if(std::any_of(transitions.begin(), transitions.end(), [&](const std::pair<std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol>, std::pair<label::Label, std::vector<alphabet::Symbol> > > & transition) { if(std::get<0>(transition.first) == std::get<0>(key) && std::get<2>(transition.first) == std::get<2>(key)) return true; return false; })) throw AutomatonException("Conflicting transition"); } else { - std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol> key2(std::get<0>(key), std::variant<string::Epsilon, alphabet::Symbol>{ string::Epsilon::EPSILON }, std::get<2>(key)); + std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol> key2(std::get<0>(key), std::variant<string::Epsilon < >, alphabet::Symbol>{ string::Epsilon < >::EPSILON }, std::get<2>(key)); if(transitions.find(key2) != transitions.end()) throw AutomatonException("Conflicting transition"); } @@ -86,17 +86,17 @@ bool SinglePopDPDA::addTransition(label::Label from, std::variant<string::Epsilo } bool SinglePopDPDA::addTransition(label::Label from, alphabet::Symbol input, alphabet::Symbol pop, label::Label to, std::vector<alphabet::Symbol> push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(std::move(input)); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(std::move(input)); return addTransition(std::move(from), std::move(inputVariant), std::move(pop), std::move(to), std::move(push)); } bool SinglePopDPDA::addTransition(label::Label from, alphabet::Symbol pop, label::Label to, std::vector<alphabet::Symbol> push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(string::Epsilon::EPSILON); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(string::Epsilon < >::EPSILON); return addTransition(std::move(from), std::move(inputVariant), std::move(pop), std::move(to), std::move(push)); } -bool SinglePopDPDA::removeTransition(const label::Label& from, const std::variant<string::Epsilon, alphabet::Symbol>& input, const alphabet::Symbol& pop, const label::Label& to, const std::vector<alphabet::Symbol>& push) { - std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol> key(from, input, pop); +bool SinglePopDPDA::removeTransition(const label::Label& from, const std::variant<string::Epsilon < >, alphabet::Symbol>& input, const alphabet::Symbol& pop, const label::Label& to, const std::vector<alphabet::Symbol>& push) { + std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol> key(from, input, pop); std::pair<label::Label, std::vector<alphabet::Symbol> > value = std::make_pair(to, push); if (transitions.find(key) == transitions.end()) @@ -106,7 +106,7 @@ bool SinglePopDPDA::removeTransition(const label::Label& from, const std::varian if (input.is<alphabet::Symbol>()) throw AutomatonException("Transition (\"" + std::to_string ( from ) + "\", \"" + std::to_string ( input.get<alphabet::Symbol>() ) + "\") -> \"" + std::to_string ( to ) + "\" doesn't exist."); else - throw AutomatonException("Transition (\"" + std::to_string ( from ) + "\", \"" + std::to_string ( input.get<string::Epsilon>() ) + "\") -> \"" + std::to_string ( to ) + "\" doesn't exist."); + throw AutomatonException("Transition (\"" + std::to_string ( from ) + "\", \"" + std::to_string ( input.get<string::Epsilon < >>() ) + "\") -> \"" + std::to_string ( to ) + "\" doesn't exist."); } transitions.erase(key); @@ -114,16 +114,16 @@ bool SinglePopDPDA::removeTransition(const label::Label& from, const std::varian } bool SinglePopDPDA::removeTransition(const label::Label& from, const alphabet::Symbol& input, const alphabet::Symbol& pop, const label::Label& to, const std::vector<alphabet::Symbol>& push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(input); return removeTransition(from, inputVariant, pop, to, push); } bool SinglePopDPDA::removeTransition(const label::Label& from, const alphabet::Symbol& pop, const label::Label& to, const std::vector<alphabet::Symbol>& push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(string::Epsilon::EPSILON); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(string::Epsilon < >::EPSILON); return removeTransition(from, inputVariant, pop, to, push); } -const std::map<std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::pair<label::Label, std::vector<alphabet::Symbol> > >& SinglePopDPDA::getTransitions() const { +const std::map<std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol>, std::pair<label::Label, std::vector<alphabet::Symbol> > >& SinglePopDPDA::getTransitions() const { return transitions; } @@ -178,7 +178,7 @@ SinglePopDPDA SinglePopDPDA::parse(std::deque<sax::Token>::iterator& input) { void SinglePopDPDA::parseTransition(std::deque<sax::Token>::iterator& input, SinglePopDPDA& automaton) { sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, "transition"); label::Label from = AutomatonFromXMLParser::parseTransitionFrom<label::Label>(input); - std::variant<string::Epsilon, alphabet::Symbol> inputSymbol = AutomatonFromXMLParser::parseTransitionInputEpsilonSymbol<string::Epsilon, alphabet::Symbol>(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputSymbol = AutomatonFromXMLParser::parseTransitionInputEpsilonSymbol<string::Epsilon < >, alphabet::Symbol>(input); alphabet::Symbol pop = AutomatonFromXMLParser::parseTransitionSinglePop<alphabet::Symbol>(input); label::Label to = AutomatonFromXMLParser::parseTransitionTo<label::Label>(input); std::vector<alphabet::Symbol> push = AutomatonFromXMLParser::parseTransitionPush<alphabet::Symbol>(input); diff --git a/alib2data/src/automaton/PDA/SinglePopDPDA.h b/alib2data/src/automaton/PDA/SinglePopDPDA.h index c960ab48f7..2ba15c9668 100644 --- a/alib2data/src/automaton/PDA/SinglePopDPDA.h +++ b/alib2data/src/automaton/PDA/SinglePopDPDA.h @@ -37,7 +37,7 @@ class InitialState; */ class SinglePopDPDA : public AutomatonBase, public std::Components < SinglePopDPDA, alphabet::Symbol, std::tuple < InputAlphabet, PushdownStoreAlphabet >, std::tuple < InitialSymbol >, label::Label, std::tuple < States, FinalStates >, std::tuple < InitialState > > { protected: - std::map < std::tuple < label::Label, std::variant < string::Epsilon, alphabet::Symbol >, alphabet::Symbol >, std::pair < label::Label, std::vector < alphabet::Symbol > > > transitions; + std::map < std::tuple < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol >, alphabet::Symbol >, std::pair < label::Label, std::vector < alphabet::Symbol > > > transitions; public: explicit SinglePopDPDA ( std::set < label::Label > states, std::set < alphabet::Symbol > inputAlphabet, std::set < alphabet::Symbol > pushdownStoreSymbol, label::Label initialState, alphabet::Symbol initialPushdownSymbol, std::set < label::Label > finalStates ); @@ -141,7 +141,7 @@ public: * @throws AutomatonException when some part of the transition is not present * in the SinglePopDPDA (state, input symbol, stack symbol) or when transition already exists */ - bool addTransition ( label::Label from, std::variant < string::Epsilon, alphabet::Symbol > input, alphabet::Symbol pop, label::Label to, std::vector < alphabet::Symbol > push ); + bool addTransition ( label::Label from, std::variant < string::Epsilon < >, alphabet::Symbol > input, alphabet::Symbol pop, label::Label to, std::vector < alphabet::Symbol > push ); bool addTransition ( label::Label from, alphabet::Symbol input, alphabet::Symbol pop, label::Label to, std::vector < alphabet::Symbol > push ); @@ -152,7 +152,7 @@ public: * @param transition transition to remove * @throws AutomatonException when transition is not present in the SinglePopDPDA */ - bool removeTransition ( const label::Label & from, const std::variant < string::Epsilon, alphabet::Symbol > & input, const alphabet::Symbol & pop, const label::Label & to, const std::vector < alphabet::Symbol > & push ); + bool removeTransition ( const label::Label & from, const std::variant < string::Epsilon < >, alphabet::Symbol > & input, const alphabet::Symbol & pop, const label::Label & to, const std::vector < alphabet::Symbol > & push ); bool removeTransition ( const label::Label & from, const alphabet::Symbol & input, const alphabet::Symbol & pop, const label::Label & to, const std::vector < alphabet::Symbol > & push ); @@ -161,7 +161,7 @@ public: /** * @return SinglePopDPDA transitions */ - const std::map < std::tuple < label::Label, std::variant < string::Epsilon, alphabet::Symbol >, alphabet::Symbol >, std::pair < label::Label, std::vector < alphabet::Symbol > > > & getTransitions ( ) const; + const std::map < std::tuple < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol >, alphabet::Symbol >, std::pair < label::Label, std::vector < alphabet::Symbol > > > & getTransitions ( ) const; virtual int compare ( const ObjectBase & other ) const { if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); @@ -196,7 +196,7 @@ template < > class ComponentConstraint< automaton::SinglePopDPDA, alphabet::Symbol, automaton::InputAlphabet > { public: static bool used ( const automaton::SinglePopDPDA & automaton, const alphabet::Symbol & symbol ) { - for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::pair<label::Label, std::vector<alphabet::Symbol> > >& transition : automaton.getTransitions()) + for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol>, std::pair<label::Label, std::vector<alphabet::Symbol> > >& transition : automaton.getTransitions()) if (std::get<1>(transition.first).is<alphabet::Symbol>() && symbol == std::get<1>(transition.first).get<alphabet::Symbol>()) return true; @@ -215,7 +215,7 @@ template < > class ComponentConstraint< automaton::SinglePopDPDA, alphabet::Symbol, automaton::PushdownStoreAlphabet > { public: static bool used ( const automaton::SinglePopDPDA & automaton, const alphabet::Symbol & symbol ) { - for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::pair<label::Label, std::vector<alphabet::Symbol> > >& transition : automaton.getTransitions()) + for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol>, std::pair<label::Label, std::vector<alphabet::Symbol> > >& transition : automaton.getTransitions()) if (symbol == std::get<2>(transition.first) || std::find(transition.second.second.begin(), transition.second.second.end(), symbol) != transition.second.second.end()) return true; @@ -254,7 +254,7 @@ public: if ( automaton.getFinalStates ( ).count ( state ) ) return true; - for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::pair<label::Label, std::vector<alphabet::Symbol> > >& transition : automaton.getTransitions()) + for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol>, std::pair<label::Label, std::vector<alphabet::Symbol> > >& transition : automaton.getTransitions()) if (state == std::get<0>(transition.first) || transition.second.first == state) return true; diff --git a/alib2data/src/automaton/PDA/SinglePopNPDA.cpp b/alib2data/src/automaton/PDA/SinglePopNPDA.cpp index 87e5b99aea..fe89c43dde 100644 --- a/alib2data/src/automaton/PDA/SinglePopNPDA.cpp +++ b/alib2data/src/automaton/PDA/SinglePopNPDA.cpp @@ -32,7 +32,7 @@ AutomatonBase* SinglePopNPDA::plunder() && { return new SinglePopNPDA(std::move(*this)); } -bool SinglePopNPDA::addTransition(label::Label from, std::variant<string::Epsilon, alphabet::Symbol> input, alphabet::Symbol pop, label::Label to, std::vector<alphabet::Symbol> push) { +bool SinglePopNPDA::addTransition(label::Label from, std::variant<string::Epsilon < >, alphabet::Symbol> input, alphabet::Symbol pop, label::Label to, std::vector<alphabet::Symbol> push) { if (! getStates().count(from)) { throw AutomatonException("State \"" + std::to_string ( from ) + "\" doesn't exist."); } @@ -55,40 +55,40 @@ bool SinglePopNPDA::addTransition(label::Label from, std::variant<string::Epsilo } } - std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol> key(std::move(from), std::move(input), std::move(pop)); + std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol> key(std::move(from), std::move(input), std::move(pop)); std::pair<label::Label, std::vector<alphabet::Symbol> > value = std::make_pair(std::move(to), std::move(push)); return transitions[std::move(key)].insert(std::move(value)).second; } bool SinglePopNPDA::addTransition(label::Label from, alphabet::Symbol input, alphabet::Symbol pop, label::Label to, std::vector<alphabet::Symbol> push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(std::move(input)); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(std::move(input)); return addTransition(std::move(from), std::move(inputVariant), std::move(pop), std::move(to), std::move(push)); } bool SinglePopNPDA::addTransition(label::Label from, alphabet::Symbol pop, label::Label to, std::vector<alphabet::Symbol> push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(string::Epsilon::EPSILON); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(string::Epsilon < >::EPSILON); return addTransition(std::move(from), std::move(inputVariant), std::move(pop), std::move(to), std::move(push)); } -bool SinglePopNPDA::removeTransition(const label::Label& from, const std::variant<string::Epsilon, alphabet::Symbol>& input, const alphabet::Symbol& pop, const label::Label& to, const std::vector<alphabet::Symbol>& push) { - std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol> key(from, input, pop); +bool SinglePopNPDA::removeTransition(const label::Label& from, const std::variant<string::Epsilon < >, alphabet::Symbol>& input, const alphabet::Symbol& pop, const label::Label& to, const std::vector<alphabet::Symbol>& push) { + std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol> key(from, input, pop); std::pair<label::Label, std::vector<alphabet::Symbol> > value = std::make_pair(to, push); return transitions[key].erase(value); } bool SinglePopNPDA::removeTransition(const label::Label& from, const alphabet::Symbol& input, const alphabet::Symbol& pop, const label::Label& to, const std::vector<alphabet::Symbol>& push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(input); return removeTransition(from, inputVariant, pop, to, push); } bool SinglePopNPDA::removeTransition(const label::Label& from, const alphabet::Symbol& pop, const label::Label& to, const std::vector<alphabet::Symbol>& push) { - std::variant<string::Epsilon, alphabet::Symbol> inputVariant(string::Epsilon::EPSILON); + std::variant<string::Epsilon < >, alphabet::Symbol> inputVariant(string::Epsilon < >::EPSILON); return removeTransition(from, inputVariant, pop, to, push); } -const std::map<std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::set<std::pair<label::Label, std::vector<alphabet::Symbol> > > >& SinglePopNPDA::getTransitions() const { +const std::map<std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol>, std::set<std::pair<label::Label, std::vector<alphabet::Symbol> > > >& SinglePopNPDA::getTransitions() const { return transitions; } @@ -143,7 +143,7 @@ SinglePopNPDA SinglePopNPDA::parse(std::deque<sax::Token>::iterator& input) { void SinglePopNPDA::parseTransition(std::deque<sax::Token>::iterator& input, SinglePopNPDA& automaton) { sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, "transition"); label::Label from = AutomatonFromXMLParser::parseTransitionFrom<label::Label>(input); - std::variant<string::Epsilon, alphabet::Symbol> inputSymbol = AutomatonFromXMLParser::parseTransitionInputEpsilonSymbol<string::Epsilon, alphabet::Symbol>(input); + std::variant<string::Epsilon < >, alphabet::Symbol> inputSymbol = AutomatonFromXMLParser::parseTransitionInputEpsilonSymbol<string::Epsilon < >, alphabet::Symbol>(input); alphabet::Symbol pop = AutomatonFromXMLParser::parseTransitionSinglePop<alphabet::Symbol>(input); label::Label to = AutomatonFromXMLParser::parseTransitionTo<label::Label>(input); std::vector<alphabet::Symbol> push = AutomatonFromXMLParser::parseTransitionPush<alphabet::Symbol>(input); diff --git a/alib2data/src/automaton/PDA/SinglePopNPDA.h b/alib2data/src/automaton/PDA/SinglePopNPDA.h index 116e46a2fd..3e2bd27388 100644 --- a/alib2data/src/automaton/PDA/SinglePopNPDA.h +++ b/alib2data/src/automaton/PDA/SinglePopNPDA.h @@ -33,7 +33,7 @@ class InitialState; */ class SinglePopNPDA : public AutomatonBase, public std::Components < SinglePopNPDA, alphabet::Symbol, std::tuple < InputAlphabet, PushdownStoreAlphabet >, std::tuple < InitialSymbol >, label::Label, std::tuple < States, FinalStates >, std::tuple < InitialState > > { protected: - std::map < std::tuple < label::Label, std::variant < string::Epsilon, alphabet::Symbol >, alphabet::Symbol >, std::set < std::pair < label::Label, std::vector < alphabet::Symbol > > > > transitions; + std::map < std::tuple < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol >, alphabet::Symbol >, std::set < std::pair < label::Label, std::vector < alphabet::Symbol > > > > transitions; public: explicit SinglePopNPDA ( std::set < label::Label > states, std::set < alphabet::Symbol > inputAlphabet, std::set < alphabet::Symbol > pushdownStoreSymbol, label::Label initialState, alphabet::Symbol initialPushdownSymbol, std::set < label::Label > finalStates ); @@ -137,7 +137,7 @@ public: * @throws AutomatonException when some part of the transition is not present * in the SinglePopNPDA (state, input symbol, stack symbol) or when transition already exists */ - bool addTransition ( label::Label from, std::variant < string::Epsilon, alphabet::Symbol > input, alphabet::Symbol pop, label::Label to, std::vector < alphabet::Symbol > push ); + bool addTransition ( label::Label from, std::variant < string::Epsilon < >, alphabet::Symbol > input, alphabet::Symbol pop, label::Label to, std::vector < alphabet::Symbol > push ); bool addTransition ( label::Label from, alphabet::Symbol input, alphabet::Symbol pop, label::Label to, std::vector < alphabet::Symbol > push ); @@ -148,7 +148,7 @@ public: * @param transition transition to remove * @throws AutomatonException when transition is not present in the SinglePopNPDA */ - bool removeTransition ( const label::Label & from, const std::variant < string::Epsilon, alphabet::Symbol > & input, const alphabet::Symbol & pop, const label::Label & to, const std::vector < alphabet::Symbol > & push ); + bool removeTransition ( const label::Label & from, const std::variant < string::Epsilon < >, alphabet::Symbol > & input, const alphabet::Symbol & pop, const label::Label & to, const std::vector < alphabet::Symbol > & push ); bool removeTransition ( const label::Label & from, const alphabet::Symbol & input, const alphabet::Symbol & pop, const label::Label & to, const std::vector < alphabet::Symbol > & push ); @@ -157,7 +157,7 @@ public: /** * @return SinglePopNPDA transitions */ - const std::map < std::tuple < label::Label, std::variant < string::Epsilon, alphabet::Symbol >, alphabet::Symbol >, std::set < std::pair < label::Label, std::vector < alphabet::Symbol > > > > & getTransitions ( ) const; + const std::map < std::tuple < label::Label, std::variant < string::Epsilon < >, alphabet::Symbol >, alphabet::Symbol >, std::set < std::pair < label::Label, std::vector < alphabet::Symbol > > > > & getTransitions ( ) const; virtual int compare ( const ObjectBase & other ) const { if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); @@ -192,7 +192,7 @@ template < > class ComponentConstraint< automaton::SinglePopNPDA, alphabet::Symbol, automaton::InputAlphabet > { public: static bool used ( const automaton::SinglePopNPDA & automaton, const alphabet::Symbol & symbol ) { - for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::set<std::pair<label::Label, std::vector<alphabet::Symbol> > > >& transition : automaton.getTransitions()) + for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol>, std::set<std::pair<label::Label, std::vector<alphabet::Symbol> > > >& transition : automaton.getTransitions()) if (std::get<1>(transition.first).is<alphabet::Symbol>() && symbol == std::get<1>(transition.first).get<alphabet::Symbol>()) return true; @@ -214,7 +214,7 @@ public: if(automaton.getInitialSymbol() == symbol) return true; - for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::set<std::pair<label::Label, std::vector<alphabet::Symbol> > > >& transition : automaton.getTransitions()) { + for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol>, std::set<std::pair<label::Label, std::vector<alphabet::Symbol> > > >& transition : automaton.getTransitions()) { if (symbol == std::get<2>(transition.first)) return true; @@ -255,7 +255,7 @@ public: if ( automaton.getFinalStates ( ).count ( state ) ) return true; - for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::set<std::pair<label::Label, std::vector<alphabet::Symbol> > > >& transition : automaton.getTransitions()) { + for (const std::pair<const std::tuple<label::Label, std::variant<::string::Epsilon < >, alphabet::Symbol>, alphabet::Symbol>, std::set<std::pair<label::Label, std::vector<alphabet::Symbol> > > >& transition : automaton.getTransitions()) { if (state == std::get<0>(transition.first)) return true; diff --git a/alib2data/src/string/CyclicString.cpp b/alib2data/src/string/CyclicString.cpp index 1d432e3db2..ee48fc2c25 100644 --- a/alib2data/src/string/CyclicString.cpp +++ b/alib2data/src/string/CyclicString.cpp @@ -39,7 +39,7 @@ CyclicString::CyclicString(const std::string& string) : CyclicString ( StringAux CyclicString::CyclicString(const char* string) : CyclicString((std::string) string) { } -CyclicString::CyclicString(const Epsilon& epsilon) : CyclicString ( epsilon.getAlphabet( ), std::vector < alphabet::Symbol > ( ) ) { +CyclicString::CyclicString(const Epsilon < > & epsilon) : CyclicString ( epsilon.getAlphabet( ), std::vector < alphabet::Symbol > ( ) ) { } StringBase* CyclicString::clone() const { @@ -96,8 +96,8 @@ CyclicString::operator std::string () const { CyclicString CyclicString::parse(std::deque<sax::Token>::iterator& input) { sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, CyclicString::getXmlTagName()); - std::set<alphabet::Symbol> alphabet = StringFromXMLParser::parseAlphabet(input); - std::vector<alphabet::Symbol> content = StringFromXMLParser::parseContent(input); + std::set<alphabet::Symbol> alphabet = StringFromXMLParser::parseAlphabet < alphabet::Symbol > (input); + std::vector<alphabet::Symbol> content = StringFromXMLParser::parseContent < alphabet::Symbol > (input); sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::END_ELEMENT, CyclicString::getXmlTagName()); return CyclicString ( std::move ( alphabet ), std::move ( content ) ); } @@ -116,7 +116,7 @@ namespace alib { auto cyclicStringParserRegister = xmlApi<string::String>::ParserRegister<string::CyclicString>(); auto cyclicStringParserRegister2 = xmlApi<alib::Object>::ParserRegister<string::CyclicString>(); -auto CyclicStringFromEpsilon = castApi::CastRegister<string::CyclicString, string::Epsilon>(); +auto CyclicStringFromEpsilon = castApi::CastRegister<string::CyclicString, string::Epsilon < > >(); auto CyclicStringCastBinder = castApi::CastPoolStringBinder<string::CyclicString>(string::CyclicString::getXmlTagName()); } /* namespace alib */ diff --git a/alib2data/src/string/CyclicString.h b/alib2data/src/string/CyclicString.h index caa139bec5..cc9810b135 100644 --- a/alib2data/src/string/CyclicString.h +++ b/alib2data/src/string/CyclicString.h @@ -12,12 +12,12 @@ #include <set> #include <vector> +#include "StringFeatures.h" #include "../alphabet/Symbol.h" #include <core/components.hpp> namespace string { -class Epsilon; class GeneralAlphabet; /** @@ -33,7 +33,7 @@ public: explicit CyclicString ( std::vector < alphabet::Symbol > data ); explicit CyclicString ( const std::string & string ); explicit CyclicString ( const char * string ); - explicit CyclicString ( const Epsilon & epsilon ); + explicit CyclicString ( const Epsilon < > & epsilon ); virtual StringBase * clone ( ) const; virtual StringBase * plunder ( ) &&; diff --git a/alib2data/src/string/Epsilon.cpp b/alib2data/src/string/Epsilon.cpp index 826b925788..912fd7ed30 100644 --- a/alib2data/src/string/Epsilon.cpp +++ b/alib2data/src/string/Epsilon.cpp @@ -7,72 +7,13 @@ #include "Epsilon.h" -#include <sax/FromXMLParserHelper.h> -#include "common/StringFromXMLParser.h" -#include "common/StringToXMLComposer.h" #include "String.h" #include <object/Object.h> #include <XmlApi.hpp> -namespace string { - -Epsilon::Epsilon(std::set<alphabet::Symbol> alphabet) : std::Components < Epsilon, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ) { -} - -Epsilon::Epsilon() : Epsilon ( std::set< alphabet::Symbol > ( ) ) { -} - -StringBase* Epsilon::clone() const { - return new Epsilon(*this); -} - -StringBase* Epsilon::plunder() && { - return new Epsilon(std::move(*this)); -} - -const std::vector<alphabet::Symbol> & Epsilon::getContent() const { - return Epsilon::content; -} - -bool Epsilon::isEmpty() const { - return true; -} - -int Epsilon::compare(const Epsilon& other) const { - std::compare<std::set<alphabet::Symbol>> comp; - return comp(getAlphabet(), other.getAlphabet()); -} - -void Epsilon::operator>>(std::ostream& out) const { - out << "(Epsilon)"; -} - -Epsilon::operator std::string() const { - return "E"; -} - -Epsilon Epsilon::EPSILON = Epsilon(); - -std::vector<alphabet::Symbol> Epsilon::content; - -Epsilon Epsilon::parse(std::deque<sax::Token>::iterator& input) { - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, Epsilon::getXmlTagName()); - std::set<alphabet::Symbol> alphabet = StringFromXMLParser::parseAlphabet(input); - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::END_ELEMENT, Epsilon::getXmlTagName()); - return Epsilon(alphabet); -} - -void Epsilon::compose(std::deque<sax::Token>& out) const { - out.emplace_back(Epsilon::getXmlTagName(), sax::Token::TokenType::START_ELEMENT); - StringToXMLComposer::compose(out, getAlphabet()); - out.emplace_back(Epsilon::getXmlTagName(), sax::Token::TokenType::END_ELEMENT); -} - -} /* namespace string */ - namespace alib { -auto epsilonParserRegister = xmlApi<string::String>::ParserRegister<string::Epsilon>(); -auto epsilonParserRegister2 = xmlApi<alib::Object>::ParserRegister<string::Epsilon>(); +auto epsilonParserRegister = xmlApi<string::String>::ParserRegister<string::Epsilon < > >(); +auto epsilonParserRegister2 = xmlApi<alib::Object>::ParserRegister<string::Epsilon < > >(); } /* namespace alib */ diff --git a/alib2data/src/string/Epsilon.h b/alib2data/src/string/Epsilon.h index 91568e8c9c..bd340eb1de 100644 --- a/alib2data/src/string/Epsilon.h +++ b/alib2data/src/string/Epsilon.h @@ -8,13 +8,17 @@ #ifndef EPSILON_H_ #define EPSILON_H_ -#include "StringBase.h" #include <set> #include <vector> -#include "../alphabet/Symbol.h" +#include <sax/FromXMLParserHelper.h> #include <core/components.hpp> +#include "StringBase.h" +#include "StringFeatures.h" +#include "common/StringFromXMLParser.h" +#include "common/StringToXMLComposer.h" + namespace string { class GeneralAlphabet; @@ -23,27 +27,28 @@ class GeneralAlphabet; * Represents epsilon. Regular expression is stored * as a tree of EpsilonElement. */ -class Epsilon : public StringBase, public std::Components < Epsilon, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > { +template < class SymbolType > +class Epsilon : public StringBase, public std::Components < Epsilon < SymbolType >, SymbolType, std::tuple < GeneralAlphabet >, std::tuple < > > { public: Epsilon ( ); - Epsilon ( std::set < alphabet::Symbol > alphabet ); + Epsilon ( std::set < SymbolType > alphabet ); virtual StringBase * clone ( ) const; virtual StringBase * plunder ( ) &&; - virtual const std::set < alphabet::Symbol > & getAlphabet ( ) const { - return accessComponent < GeneralAlphabet > ( ).get ( ); + virtual const std::set < SymbolType > & getAlphabet ( ) const { + return this->template accessComponent < GeneralAlphabet > ( ).get ( ); } - void extendAlphabet ( const std::set < alphabet::Symbol > & symbols ) { - accessComponent < GeneralAlphabet > ( ).add( symbols ); + void extendAlphabet ( const std::set < SymbolType > & symbols ) { + this->template accessComponent < GeneralAlphabet > ( ).add( symbols ); } /** * @return List of symbols forming string (const version). */ - const std::vector < alphabet::Symbol > & getContent ( ) const; + const std::vector < SymbolType > & getContent ( ) const; /** * @return true @@ -74,25 +79,90 @@ public: void compose ( std::deque < sax::Token > & out ) const; - static std::vector < alphabet::Symbol > content; + static std::vector < SymbolType > content; }; +template < class SymbolType > +Epsilon < SymbolType >::Epsilon(std::set<SymbolType> alphabet) : std::Components < Epsilon < SymbolType >, SymbolType, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ) { +} + +template < class SymbolType > +Epsilon < SymbolType >::Epsilon() : Epsilon ( std::set< SymbolType > ( ) ) { +} + +template < class SymbolType > +StringBase* Epsilon < SymbolType >::clone() const { + return new Epsilon(*this); +} + +template < class SymbolType > +StringBase* Epsilon < SymbolType >::plunder() && { + return new Epsilon(std::move(*this)); +} + +template < class SymbolType > +const std::vector<SymbolType> & Epsilon < SymbolType >::getContent() const { + return Epsilon::content; +} + +template < class SymbolType > +bool Epsilon < SymbolType >::isEmpty() const { + return true; +} + +template < class SymbolType > +int Epsilon < SymbolType >::compare(const Epsilon& other) const { + std::compare<std::set<SymbolType>> comp; + return comp(getAlphabet(), other.getAlphabet()); +} + +template < class SymbolType > +void Epsilon < SymbolType >::operator>>(std::ostream& out) const { + out << "(Epsilon)"; +} + +template < class SymbolType > +Epsilon < SymbolType >::operator std::string() const { + return "E"; +} + +template < class SymbolType > +Epsilon < SymbolType > Epsilon < SymbolType >::EPSILON = Epsilon < SymbolType >(); + +template < class SymbolType > +std::vector<SymbolType> Epsilon < SymbolType >::content; + +template < class SymbolType > +Epsilon < SymbolType > Epsilon < SymbolType >::parse(std::deque<sax::Token>::iterator& input) { + sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, Epsilon::getXmlTagName()); + std::set<SymbolType> alphabet = StringFromXMLParser::parseAlphabet < SymbolType > (input); + sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::END_ELEMENT, Epsilon::getXmlTagName()); + return Epsilon < SymbolType > (alphabet); +} + +template < class SymbolType > +void Epsilon < SymbolType >::compose(std::deque<sax::Token>& out) const { + out.emplace_back(Epsilon::getXmlTagName(), sax::Token::TokenType::START_ELEMENT); + StringToXMLComposer::compose(out, getAlphabet()); + out.emplace_back(Epsilon::getXmlTagName(), sax::Token::TokenType::END_ELEMENT); +} + } /* namespace string */ namespace std { -template < > -class ComponentConstraint< ::string::Epsilon, alphabet::Symbol, ::string::GeneralAlphabet > { +template < class SymbolType > +class ComponentConstraint< ::string::Epsilon < SymbolType >, SymbolType, ::string::GeneralAlphabet > { public: - static bool used ( const ::string::Epsilon &, const alphabet::Symbol & ) { + static bool used ( const ::string::Epsilon < SymbolType > &, const SymbolType & ) { return false; } - static bool available ( const ::string::Epsilon &, const alphabet::Symbol & ) { + static bool available ( const ::string::Epsilon < SymbolType > &, const SymbolType & ) { return true; } - static void valid ( const ::string::Epsilon &, const alphabet::Symbol & ) { + static void valid ( const ::string::Epsilon < SymbolType > &, const SymbolType & ) { } }; diff --git a/alib2data/src/string/LinearString.cpp b/alib2data/src/string/LinearString.cpp index 3939338bf7..74e4a39e90 100644 --- a/alib2data/src/string/LinearString.cpp +++ b/alib2data/src/string/LinearString.cpp @@ -47,7 +47,7 @@ LinearString::LinearString(const std::string& string) : LinearString ( StringAux LinearString::LinearString(const char* string) : LinearString((std::string) string) { } -LinearString::LinearString(const Epsilon& epsilon) : LinearString ( epsilon.getAlphabet( ), std::vector < alphabet::Symbol > ( ) ) { +LinearString::LinearString(const Epsilon < > & epsilon) : LinearString ( epsilon.getAlphabet( ), std::vector < alphabet::Symbol > ( ) ) { } LinearString::LinearString ( const tree::PrefixRankedTree & tree ) : LinearString ( StringAuxiliary::wrapSymbols ( tree.getAlphabet ( ) ), StringAuxiliary::wrapSymbols ( tree.getContent ( ) ) ) { @@ -136,8 +136,8 @@ LinearString::operator std::string ( ) const { LinearString LinearString::parse ( std::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, LinearString::getXmlTagName() ); - std::set < alphabet::Symbol > alphabet = StringFromXMLParser::parseAlphabet ( input ); - std::vector < alphabet::Symbol > content = StringFromXMLParser::parseContent ( input ); + std::set < alphabet::Symbol > alphabet = StringFromXMLParser::parseAlphabet < alphabet::Symbol > ( input ); + std::vector < alphabet::Symbol > content = StringFromXMLParser::parseContent < alphabet::Symbol > ( input ); sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, LinearString::getXmlTagName() ); return LinearString ( alphabet, content ); @@ -157,7 +157,7 @@ namespace alib { auto linearStringParserRegister = xmlApi < string::String >::ParserRegister < string::LinearString > (); auto linearStringParserRegister2 = xmlApi < alib::Object >::ParserRegister < string::LinearString > (); -auto LinearStringFromEpsilon = castApi::CastRegister < string::LinearString, string::Epsilon > ( ); +auto LinearStringFromEpsilon = castApi::CastRegister < string::LinearString, string::Epsilon < > > ( ); auto LinearStringFromPrefixRankedTree = castApi::CastRegister < string::LinearString, tree::PrefixRankedTree > ( ); auto LinearStringFromPrefixRankedPattern = castApi::CastRegister < string::LinearString, tree::PrefixRankedPattern > ( ); auto LinearStringFromPrefixRankedNonlinearPattern = castApi::CastRegister < string::LinearString, tree::PrefixRankedNonlinearPattern > ( ); diff --git a/alib2data/src/string/LinearString.h b/alib2data/src/string/LinearString.h index 0e8e438ffc..ea89ac8b45 100644 --- a/alib2data/src/string/LinearString.h +++ b/alib2data/src/string/LinearString.h @@ -12,6 +12,7 @@ #include <set> #include <vector> +#include "StringFeatures.h" #include "../alphabet/Symbol.h" #include <core/components.hpp> @@ -29,7 +30,6 @@ class PrefixBarTree; namespace string { -class Epsilon; class GeneralAlphabet; /** @@ -52,7 +52,7 @@ public: explicit LinearString ( std::vector < alphabet::Symbol > data ); explicit LinearString ( const std::string & string ); explicit LinearString ( const char * string ); - explicit LinearString ( const Epsilon & epsilon ); + explicit LinearString ( const Epsilon < > & epsilon ); virtual StringBase * clone ( ) const; virtual StringBase * plunder ( ) &&; diff --git a/alib2data/src/string/LinearStringTerminatingSymbol.cpp b/alib2data/src/string/LinearStringTerminatingSymbol.cpp index dc5cf56d07..034992a55a 100644 --- a/alib2data/src/string/LinearStringTerminatingSymbol.cpp +++ b/alib2data/src/string/LinearStringTerminatingSymbol.cpp @@ -100,9 +100,9 @@ LinearStringTerminatingSymbol::operator std::string ( ) const { LinearStringTerminatingSymbol LinearStringTerminatingSymbol::parse ( std::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, LinearStringTerminatingSymbol::getXmlTagName() ); - std::set < alphabet::Symbol > alphabet = StringFromXMLParser::parseAlphabet ( input ); + std::set < alphabet::Symbol > alphabet = StringFromXMLParser::parseAlphabet < alphabet::Symbol > ( input ); alphabet::Symbol terminatingSymbol = alib::xmlApi < alphabet::Symbol >::parse ( input ); - std::vector < alphabet::Symbol > content = StringFromXMLParser::parseContent ( input ); + std::vector < alphabet::Symbol > content = StringFromXMLParser::parseContent < alphabet::Symbol > ( input ); sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, LinearStringTerminatingSymbol::getXmlTagName() ); return LinearStringTerminatingSymbol ( alphabet, terminatingSymbol, content ); diff --git a/alib2data/src/string/StringFeatures.h b/alib2data/src/string/StringFeatures.h index e8187b712a..f73ca684b5 100644 --- a/alib2data/src/string/StringFeatures.h +++ b/alib2data/src/string/StringFeatures.h @@ -8,6 +8,8 @@ #ifndef STRING_FEATURES_H_ #define STRING_FEATURES_H_ +#include <alphabet/Symbol.h> + namespace string { enum class FEATURES { @@ -19,6 +21,7 @@ enum class FEATURES { class String; class StringBase; +template < class SymbolType = alphabet::Symbol > class Epsilon; class LinearString; class CyclicString; diff --git a/alib2data/src/string/common/StringFromXMLParser.cpp b/alib2data/src/string/common/StringFromXMLParser.cpp deleted file mode 100644 index f6a3ae204e..0000000000 --- a/alib2data/src/string/common/StringFromXMLParser.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * StringFromXMLParser.cpp - * - * Created on: Nov 23, 2013 - * Author: Jan Travnicek - */ - -#include "StringFromXMLParser.h" -#include <sax/FromXMLParserHelper.h> -#include <XmlApi.hpp> - -namespace string { - -std::set<alphabet::Symbol> StringFromXMLParser::parseAlphabet(std::deque<sax::Token>::iterator& input) { - std::set<alphabet::Symbol> alphabet; - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, "alphabet"); - while (sax::FromXMLParserHelper::isTokenType(input, sax::Token::TokenType::START_ELEMENT)) { - alphabet.insert(alib::xmlApi<alphabet::Symbol>::parse(input)); - } - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::END_ELEMENT, "alphabet"); - return alphabet; -} - -std::vector<alphabet::Symbol> StringFromXMLParser::parseContent(std::deque<sax::Token>::iterator& input) { - std::vector<alphabet::Symbol> data; - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, "content"); - while (sax::FromXMLParserHelper::isTokenType(input, sax::Token::TokenType::START_ELEMENT)) { - data.push_back(alib::xmlApi<alphabet::Symbol>::parse(input)); - } - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::END_ELEMENT, "content"); - return data; -} - -} /* namespace string */ diff --git a/alib2data/src/string/common/StringFromXMLParser.h b/alib2data/src/string/common/StringFromXMLParser.h index 7782227c2f..b957285eb2 100644 --- a/alib2data/src/string/common/StringFromXMLParser.h +++ b/alib2data/src/string/common/StringFromXMLParser.h @@ -12,7 +12,8 @@ #include <set> #include <deque> #include <sax/Token.h> -#include "../../alphabet/Symbol.h" +#include <sax/FromXMLParserHelper.h> +#include <XmlApi.hpp> namespace string { @@ -21,10 +22,34 @@ namespace string { */ class StringFromXMLParser { public: - static std::vector<alphabet::Symbol> parseContent(std::deque<sax::Token>::iterator& input); - static std::set<alphabet::Symbol> parseAlphabet(std::deque<sax::Token>::iterator& input); + template < class SymbolType > + static std::vector<SymbolType> parseContent(std::deque<sax::Token>::iterator& input); + template < class SymbolType > + static std::set<SymbolType> parseAlphabet(std::deque<sax::Token>::iterator& input); }; +template < class SymbolType > +std::set<SymbolType> StringFromXMLParser::parseAlphabet(std::deque<sax::Token>::iterator& input) { + std::set<SymbolType> alphabet; + sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, "alphabet"); + while (sax::FromXMLParserHelper::isTokenType(input, sax::Token::TokenType::START_ELEMENT)) { + alphabet.insert(alib::xmlApi<SymbolType>::parse(input)); + } + sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::END_ELEMENT, "alphabet"); + return alphabet; +} + +template < class SymbolType > +std::vector<SymbolType> StringFromXMLParser::parseContent(std::deque<sax::Token>::iterator& input) { + std::vector<SymbolType> data; + sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, "content"); + while (sax::FromXMLParserHelper::isTokenType(input, sax::Token::TokenType::START_ELEMENT)) { + data.push_back(alib::xmlApi<SymbolType>::parse(input)); + } + sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::END_ELEMENT, "content"); + return data; +} + } /* namespace string */ #endif /* STRING_FROM_XML_PARSER_H_ */ diff --git a/alib2data/src/string/common/StringToXMLComposer.cpp b/alib2data/src/string/common/StringToXMLComposer.cpp deleted file mode 100644 index fa7a6eb788..0000000000 --- a/alib2data/src/string/common/StringToXMLComposer.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * StringToXMLComposer.cpp - * - * Created on: Nov 23, 2013 - * Author: Jan Travnicek - */ - -#include "StringToXMLComposer.h" -#include <XmlApi.hpp> - -namespace string { - -void StringToXMLComposer::compose(std::deque<sax::Token>& out, const std::set<alphabet::Symbol>& alphabet) { - out.emplace_back("alphabet", sax::Token::TokenType::START_ELEMENT); - for (const auto& symbol : alphabet) { - alib::xmlApi<alphabet::Symbol>::compose(out, symbol); - } - out.emplace_back("alphabet", sax::Token::TokenType::END_ELEMENT); -} - -void StringToXMLComposer::compose(std::deque<sax::Token>& out, const std::vector<alphabet::Symbol>& content) { - out.emplace_back("content", sax::Token::TokenType::START_ELEMENT); - for(const auto& symbol : content) { - alib::xmlApi<alphabet::Symbol>::compose(out, symbol); - } - out.emplace_back("content", sax::Token::TokenType::END_ELEMENT); -} - -} /* namespace string */ diff --git a/alib2data/src/string/common/StringToXMLComposer.h b/alib2data/src/string/common/StringToXMLComposer.h index 077b160e45..7eab5ccf9d 100644 --- a/alib2data/src/string/common/StringToXMLComposer.h +++ b/alib2data/src/string/common/StringToXMLComposer.h @@ -12,7 +12,7 @@ #include <sax/Token.h> #include <set> #include <vector> -#include "../../alphabet/Symbol.h" +#include <XmlApi.hpp> namespace string { @@ -21,10 +21,30 @@ namespace string { */ class StringToXMLComposer { public: - static void compose(std::deque<sax::Token>& out, const std::set<alphabet::Symbol>& alphabet); - static void compose(std::deque<sax::Token>& out, const std::vector<alphabet::Symbol>& content); + template < class SymbolType > + static void compose(std::deque<sax::Token>& out, const std::set<SymbolType>& alphabet); + template < class SymbolType > + static void compose(std::deque<sax::Token>& out, const std::vector<SymbolType>& content); }; +template < class SymbolType > +void StringToXMLComposer::compose(std::deque<sax::Token>& out, const std::set<SymbolType>& alphabet) { + out.emplace_back("alphabet", sax::Token::TokenType::START_ELEMENT); + for (const auto& symbol : alphabet) { + alib::xmlApi<SymbolType>::compose(out, symbol); + } + out.emplace_back("alphabet", sax::Token::TokenType::END_ELEMENT); +} + +template < class SymbolType > +void StringToXMLComposer::compose(std::deque<sax::Token>& out, const std::vector<SymbolType>& content) { + out.emplace_back("content", sax::Token::TokenType::START_ELEMENT); + for(const auto& symbol : content) { + alib::xmlApi<SymbolType>::compose(out, symbol); + } + out.emplace_back("content", sax::Token::TokenType::END_ELEMENT); +} + } /* namespace string */ #endif /* STRING_TO_XML_COMPOSER_H_ */ diff --git a/alib2data/test-src/string/StringTest.cpp b/alib2data/test-src/string/StringTest.cpp index b6fe0e7fa2..5e237fb113 100644 --- a/alib2data/test-src/string/StringTest.cpp +++ b/alib2data/test-src/string/StringTest.cpp @@ -73,29 +73,29 @@ void StringTest::testXMLParser ( ) { } void StringTest::testStringInMap ( ) { - std::map < std::variant < string::Epsilon, int >, int > testMap; - std::variant < string::Epsilon, int > epsVar { - string::Epsilon { } + std::map < std::variant < string::Epsilon < >, int >, int > testMap; + std::variant < string::Epsilon < >, int > epsVar { + string::Epsilon < > { } }; - CPPUNIT_ASSERT ( string::Epsilon::EPSILON == epsVar.get < string::Epsilon > ( ) ); - CPPUNIT_ASSERT ( epsVar.get < string::Epsilon > ( ) == string::Epsilon::EPSILON ); + CPPUNIT_ASSERT ( string::Epsilon < >::EPSILON == epsVar.get < string::Epsilon < > > ( ) ); + CPPUNIT_ASSERT ( epsVar.get < string::Epsilon < > > ( ) == string::Epsilon < >::EPSILON ); - std::pair < std::variant < string::Epsilon, int >, int > epsVarPair = std::make_pair ( epsVar, 10 ); - CPPUNIT_ASSERT ( string::Epsilon::EPSILON == epsVarPair.first.get < string::Epsilon > ( ) ); - CPPUNIT_ASSERT ( epsVarPair.first.get < string::Epsilon > ( ) == string::Epsilon::EPSILON ); + std::pair < std::variant < string::Epsilon < >, int >, int > epsVarPair = std::make_pair ( epsVar, 10 ); + CPPUNIT_ASSERT ( string::Epsilon < >::EPSILON == epsVarPair.first.get < string::Epsilon < > > ( ) ); + CPPUNIT_ASSERT ( epsVarPair.first.get < string::Epsilon < > > ( ) == string::Epsilon < >::EPSILON ); - testMap.insert ( std::make_pair ( std::variant < string::Epsilon, int > { string::Epsilon { } + testMap.insert ( std::make_pair ( std::variant < string::Epsilon < >, int > { string::Epsilon < > { } }, 10 ) ); - CPPUNIT_ASSERT ( testMap.find ( std::variant < string::Epsilon, int > { string::Epsilon { } + CPPUNIT_ASSERT ( testMap.find ( std::variant < string::Epsilon < >, int > { string::Epsilon < > { } } ) != testMap.end ( ) ); for ( const auto & entry : testMap ) { - CPPUNIT_ASSERT ( entry.first.is < string::Epsilon > ( ) ); + CPPUNIT_ASSERT ( entry.first.is < string::Epsilon < > > ( ) ); - if ( entry.first.is < string::Epsilon > ( ) ) - CPPUNIT_ASSERT ( string::Epsilon::EPSILON == entry.first.get < string::Epsilon > ( ) ); + if ( entry.first.is < string::Epsilon < > > ( ) ) + CPPUNIT_ASSERT ( string::Epsilon < >::EPSILON == entry.first.get < string::Epsilon < > > ( ) ); - CPPUNIT_ASSERT ( entry.first.get < string::Epsilon > ( ) == string::Epsilon::EPSILON ); + CPPUNIT_ASSERT ( entry.first.get < string::Epsilon < > > ( ) == string::Epsilon < >::EPSILON ); } } diff --git a/alib2str/src/automaton/AutomatonFromStringParser.cpp b/alib2str/src/automaton/AutomatonFromStringParser.cpp index ad01bbb3b3..c271c2235b 100644 --- a/alib2str/src/automaton/AutomatonFromStringParser.cpp +++ b/alib2str/src/automaton/AutomatonFromStringParser.cpp @@ -50,7 +50,7 @@ EpsilonNFA < > AutomatonFromStringParser::parseEpsilonNFA(std::istream& input) c if(token.type != AutomatonFromStringLexer::TokenType::EPSILON_NFA) { throw exception::CommonException("Unrecognised ENFA token."); } - std::vector<std::variant<string::Epsilon, alphabet::Symbol> > symbols; + std::vector<std::variant<string::Epsilon < >, alphabet::Symbol> > symbols; token = m_AutomatonLexer.next(input); while(token.type != AutomatonFromStringLexer::TokenType::NEW_LINE) { @@ -58,10 +58,10 @@ EpsilonNFA < > AutomatonFromStringParser::parseEpsilonNFA(std::istream& input) c m_AutomatonLexer.putback(input, token); alphabet::Symbol symbol = alib::stringApi<alphabet::Symbol>::parse(input); - std::variant<string::Epsilon, alphabet::Symbol> symbolVariant(symbol); + std::variant<string::Epsilon < >, alphabet::Symbol> symbolVariant(symbol); symbols.push_back(symbolVariant); } else if(token.type == AutomatonFromStringLexer::TokenType::EPSILON) { - symbols.push_back(std::variant<string::Epsilon, alphabet::Symbol>(string::Epsilon::EPSILON)); + symbols.push_back(std::variant<string::Epsilon < >, alphabet::Symbol>(string::Epsilon < >::EPSILON)); } token = m_AutomatonLexer.next(input); @@ -70,7 +70,7 @@ EpsilonNFA < > AutomatonFromStringParser::parseEpsilonNFA(std::istream& input) c label::Label* initialState = NULL; std::set<label::Label> finalStates; std::set<label::Label> states; - std::set<std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, label::Label>> transitionFunction; + std::set<std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, label::Label>> transitionFunction; parseEpsilonNFATransition(input, states, symbols, initialState, finalStates, transitionFunction); token = m_AutomatonLexer.next(input); @@ -91,13 +91,13 @@ EpsilonNFA < > AutomatonFromStringParser::parseEpsilonNFA(std::istream& input) c EpsilonNFA < > res(*initialState); delete initialState; - for(const std::variant<string::Epsilon, alphabet::Symbol> inputSymbol : symbols) { + for(const std::variant<string::Epsilon < >, alphabet::Symbol> inputSymbol : symbols) { if(inputSymbol.is<alphabet::Symbol>()) res.addInputSymbol(inputSymbol.get<alphabet::Symbol>()); } res.setStates(states); res.setFinalStates(finalStates); - for(const std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, label::Label> transition : transitionFunction) { + for(const std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, label::Label> transition : transitionFunction) { res.addTransition(std::get<0>(transition), std::get<1>(transition), std::get<2>(transition)); } @@ -269,7 +269,7 @@ void AutomatonFromStringParser::initialFinalState(std::istream& input, bool& ini } -void AutomatonFromStringParser::parseEpsilonNFATransition(std::istream& input, std::set<label::Label>& states, const std::vector<std::variant<string::Epsilon, alphabet::Symbol>>& symbols, label::Label*& initialState, std::set<label::Label>& finalStates, std::set<std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, label::Label>>& transitionFunction) const { +void AutomatonFromStringParser::parseEpsilonNFATransition(std::istream& input, std::set<label::Label>& states, const std::vector<std::variant<string::Epsilon < >, alphabet::Symbol>>& symbols, label::Label*& initialState, std::set<label::Label>& finalStates, std::set<std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, label::Label>>& transitionFunction) const { bool initial = false; bool final = false; @@ -284,7 +284,7 @@ void AutomatonFromStringParser::parseEpsilonNFATransition(std::istream& input, s if(final) finalStates.insert(from); AutomatonFromStringLexer::Token token = m_AutomatonLexer.next(input); - std::vector<std::variant<string::Epsilon, alphabet::Symbol>>::const_iterator iter = symbols.begin(); + 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::CommonException("Invalid line format"); diff --git a/alib2str/src/automaton/AutomatonFromStringParser.h b/alib2str/src/automaton/AutomatonFromStringParser.h index e15e42a533..1a3e8985c8 100644 --- a/alib2str/src/automaton/AutomatonFromStringParser.h +++ b/alib2str/src/automaton/AutomatonFromStringParser.h @@ -38,7 +38,7 @@ private: void initialFinalState(std::istream& input, bool& initial, bool& final) const; - void parseEpsilonNFATransition(std::istream& input, std::set<label::Label>& states, const std::vector<std::variant<string::Epsilon, alphabet::Symbol>>& symbols, label::Label*& initialState, std::set<label::Label>& finalStates, std::set<std::tuple<label::Label, std::variant<string::Epsilon, alphabet::Symbol>, label::Label>>& transitionFunction) const; + void parseEpsilonNFATransition(std::istream& input, std::set<label::Label>& states, const std::vector<std::variant<string::Epsilon < >, alphabet::Symbol>>& symbols, label::Label*& initialState, std::set<label::Label>& finalStates, std::set<std::tuple<label::Label, std::variant<string::Epsilon < >, alphabet::Symbol>, label::Label>>& transitionFunction) const; void parseMultiInitialStateNFATransition(std::istream& input, MultiInitialStateNFA < > & res, const std::vector<alphabet::Symbol>& symbols) const; void parseNFATransition(std::istream& input, std::set<label::Label>& states, const std::vector<alphabet::Symbol>& symbols, label::Label*& initialState, std::set<label::Label>& finalStates, std::set<std::tuple<label::Label, alphabet::Symbol, label::Label>>& transitionFunction) const; void parseDFATransition(std::istream& input, std::set<label::Label>& states, const std::vector<alphabet::Symbol>& symbols, label::Label*& initialState, std::set<label::Label>& finalStates, std::set<std::tuple<label::Label, alphabet::Symbol, label::Label>>& transitionFunction) const; diff --git a/alib2str/src/string/StringFromStringParser.cpp b/alib2str/src/string/StringFromStringParser.cpp index 6f76309bef..b79cf85b8b 100644 --- a/alib2str/src/string/StringFromStringParser.cpp +++ b/alib2str/src/string/StringFromStringParser.cpp @@ -22,7 +22,7 @@ String StringFromStringParser::parseString(std::istream& input, const std::set<F StringFromStringLexer::Token token = m_StringLexer.next(input); if(token.type == StringFromStringLexer::TokenType::EPSILON) { if(!features.count(FEATURES::EPSILON)) throw exception::CommonException("Disabled formalism Epsilon"); - return String(Epsilon()); + return String(Epsilon < > ()); } else if(token.type == StringFromStringLexer::TokenType::LESS) { if(!features.count(FEATURES::CYCLIC)) throw exception::CommonException("Disabled formalism CyclicString"); std::vector<alphabet::Symbol> data = parseContent(input); diff --git a/alib2str/src/string/StringToStringComposer.cpp b/alib2str/src/string/StringToStringComposer.cpp index 66164521cc..4e2c07470c 100644 --- a/alib2str/src/string/StringToStringComposer.cpp +++ b/alib2str/src/string/StringToStringComposer.cpp @@ -36,11 +36,11 @@ void StringToStringComposer::compose ( std::ostream & out, const LinearString & StringToStringComposer::RegistratorWrapper < void, LinearString > StringToStringComposerLinearString = StringToStringComposer::RegistratorWrapper < void, LinearString > ( StringToStringComposer::compose ); -void StringToStringComposer::compose ( std::ostream & out, const Epsilon & ) { +void StringToStringComposer::compose ( std::ostream & out, const Epsilon < > & ) { out << "#E"; } -StringToStringComposer::RegistratorWrapper < void, Epsilon > StringToStringComposerEpsilon = StringToStringComposer::RegistratorWrapper < void, Epsilon > ( StringToStringComposer::compose ); +StringToStringComposer::RegistratorWrapper < void, Epsilon < > > StringToStringComposerEpsilon = StringToStringComposer::RegistratorWrapper < void, Epsilon < > > ( StringToStringComposer::compose ); void StringToStringComposer::compose ( std::ostream & out, const String & string ) { dispatch ( out, string.getData ( ) ); diff --git a/alib2str/src/string/StringToStringComposer.h b/alib2str/src/string/StringToStringComposer.h index 34197585f7..4283fc2db6 100644 --- a/alib2str/src/string/StringToStringComposer.h +++ b/alib2str/src/string/StringToStringComposer.h @@ -22,7 +22,7 @@ class StringToStringComposer: public std::SingleDispatchFirstStaticParam<StringT public: static void compose(std::ostream&, const LinearString& string); static void compose(std::ostream&, const CyclicString& string); - static void compose(std::ostream&, const Epsilon& string); + static void compose(std::ostream&, const Epsilon < > & string); /** * Prints XML representation of String to the output stream. -- GitLab