From 187949b1d408d6d779c238facc4a2b713490e37f Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Sat, 17 Jan 2015 11:23:10 +0100 Subject: [PATCH] inplement InputDrivenDPDA and transform IDPDA examples to new format --- aconvert2/src/DotConverter.cpp | 100 ++++++++ aconvert2/src/DotConverter.h | 3 + aconvert2/src/GasTexConverter.cpp | 74 ++++++ aconvert2/src/GasTexConverter.h | 3 + alib2algo/src/automaton/convert/ToGrammar.cpp | 4 + alib2algo/src/automaton/convert/ToGrammar.h | 1 + alib2algo/src/automaton/convert/ToRegExp.cpp | 40 --- alib2algo/src/automaton/convert/ToRegExp.h | 12 +- .../src/automaton/determinize/Determinize.cpp | 10 +- .../src/automaton/determinize/Determinize.h | 4 +- .../determinize/DeterminizeIDPDAPart.cxx | 8 +- .../automaton/properties/EpsilonClosure.cpp | 4 + .../src/automaton/properties/EpsilonClosure.h | 1 + .../properties/UnreachableStates.cpp | 4 + .../automaton/properties/UnreachableStates.h | 1 + .../automaton/properties/UsefullStates.cpp | 4 + .../src/automaton/properties/UsefullStates.h | 1 + alib2algo/src/automaton/run/Accept.cpp | 4 + alib2algo/src/automaton/run/Accept.h | 1 + alib2algo/src/automaton/run/Occurrences.cpp | 4 + alib2algo/src/automaton/run/Occurrences.h | 1 + .../simplify/EpsilonRemoverIncoming.cpp | 4 + .../simplify/EpsilonRemoverIncoming.h | 1 + .../simplify/EpsilonRemoverOutgoing.cpp | 4 + .../simplify/EpsilonRemoverOutgoing.h | 1 + alib2algo/src/automaton/simplify/Minimize.cpp | 4 + alib2algo/src/automaton/simplify/Minimize.h | 1 + .../src/automaton/simplify/Normalize.cpp | 4 + alib2algo/src/automaton/simplify/Normalize.h | 1 + alib2algo/src/automaton/simplify/Rename.cpp | 4 + alib2algo/src/automaton/simplify/Rename.h | 1 + .../automaton/simplify/SingleInitialState.cpp | 4 + .../automaton/simplify/SingleInitialState.h | 1 + alib2algo/src/automaton/simplify/Trim.cpp | 4 + alib2algo/src/automaton/simplify/Trim.h | 1 + .../simplify/UnreachableStatesRemover.cpp | 4 + .../simplify/UnreachableStatesRemover.h | 1 + .../simplify/UselessStatesRemover.cpp | 4 + .../automaton/simplify/UselessStatesRemover.h | 1 + .../transform/AutomataConcatenation.cpp | 5 + .../transform/AutomataConcatenation.h | 1 + ...AutomataConcatenationEpsilonTransition.cpp | 5 + .../AutomataConcatenationEpsilonTransition.h | 1 + .../AutomataIntersectionCartesianProduct.cpp | 5 + .../AutomataIntersectionCartesianProduct.h | 1 + .../AutomataUnionCartesianProduct.cpp | 5 + .../transform/AutomataUnionCartesianProduct.h | 1 + .../AutomataUnionEpsilonTransition.cpp | 5 + .../AutomataUnionEpsilonTransition.h | 1 + .../transform/AutomatonIteration.cpp | 5 + .../automaton/transform/AutomatonIteration.h | 1 + .../AutomatonIterationEpsilonTransition.cpp | 5 + .../AutomatonIterationEpsilonTransition.h | 1 + .../src/automaton/transform/PDAToRHPDA.cpp | 4 + .../src/automaton/transform/PDAToRHPDA.h | 1 + .../src/automaton/transform/RHPDAToPDA.cpp | 4 + .../src/automaton/transform/RHPDAToPDA.h | 1 + .../automaton/determinize/determinizeTest.cpp | 2 +- alib2data/src/XmlApi.cpp | 17 ++ alib2data/src/XmlApi.hpp | 9 + alib2data/src/automaton/AutomatonBase.h | 10 +- alib2data/src/automaton/AutomatonFeatures.h | 1 + .../src/automaton/AutomatonFromXMLParser.cpp | 60 ++++- .../src/automaton/AutomatonFromXMLParser.h | 4 + .../src/automaton/AutomatonToXMLComposer.cpp | 45 ++++ .../src/automaton/AutomatonToXMLComposer.h | 4 + alib2data/src/automaton/FSM/DFA.cpp | 29 +-- .../FSM/FiniteAutomatonToStringComposer.cpp | 4 + .../FSM/FiniteAutomatonToStringComposer.h | 1 + .../src/automaton/PDA/InputDrivenDPDA.cpp | 213 ++++++++++++++++ alib2data/src/automaton/PDA/InputDrivenDPDA.h | 121 ++++++++++ .../src/automaton/PDA/InputDrivenNPDA.cpp | 13 +- alib2data/src/automaton/PDA/InputDrivenNPDA.h | 5 +- alib2data/src/object/ObjectBase.h | 9 +- alib2data/src/std/map.hpp | 28 +++ astat2/src/AutomataStat.cpp | 4 + astat2/src/AutomataStat.h | 1 + examples/automaton/NIDPDA1.DET.xml | 77 ------ examples/automaton/NIDPDA1.xml | 72 ------ examples/automaton/NIDPDA2.DET.xml | 77 ------ examples/automaton/NIDPDA2.xml | 80 ------ examples/automaton/NIDPDA3.DET.xml | 99 -------- examples/automaton/NIDPDA3.xml | 117 --------- examples2/automaton/NIDPDA1.DET.xml | 88 +++++++ examples2/automaton/NIDPDA1.xml | 227 ++++++------------ examples2/automaton/NIDPDA2.DET.xml | 83 +++++++ examples2/automaton/NIDPDA2.xml | 76 ++++++ examples2/automaton/NIDPDA3.DET.xml | 104 ++++++++ examples2/automaton/NIDPDA3.xml | 104 ++++++++ 89 files changed, 1404 insertions(+), 761 deletions(-) create mode 100644 alib2data/src/automaton/PDA/InputDrivenDPDA.cpp create mode 100644 alib2data/src/automaton/PDA/InputDrivenDPDA.h delete mode 100644 examples/automaton/NIDPDA1.DET.xml delete mode 100644 examples/automaton/NIDPDA1.xml delete mode 100644 examples/automaton/NIDPDA2.DET.xml delete mode 100644 examples/automaton/NIDPDA2.xml delete mode 100644 examples/automaton/NIDPDA3.DET.xml delete mode 100644 examples/automaton/NIDPDA3.xml create mode 100644 examples2/automaton/NIDPDA1.DET.xml create mode 100644 examples2/automaton/NIDPDA2.DET.xml create mode 100644 examples2/automaton/NIDPDA2.xml create mode 100644 examples2/automaton/NIDPDA3.DET.xml create mode 100644 examples2/automaton/NIDPDA3.xml diff --git a/aconvert2/src/DotConverter.cpp b/aconvert2/src/DotConverter.cpp index ee7d6bddf1..3801066f96 100644 --- a/aconvert2/src/DotConverter.cpp +++ b/aconvert2/src/DotConverter.cpp @@ -16,6 +16,7 @@ #include <automaton/FSM/CompactNFA.h> #include <automaton/PDA/NPDA.h> #include <automaton/PDA/SinglePopNPDA.h> +#include <automaton/PDA/InputDrivenDPDA.h> #include <automaton/PDA/InputDrivenNPDA.h> #include <automaton/PDA/VisiblyPushdownDPDA.h> #include <automaton/PDA/VisiblyPushdownNPDA.h> @@ -299,6 +300,37 @@ void DotConverter::convert(const automaton::SinglePopDPDA& a, std::ostream& out) out << "}"; } +void DotConverter::convert(const automaton::InputDrivenDPDA& a, std::ostream& out) { + out << "digraph automaton {\n"; + out << "rankdir=LR;\n"; + int cnt = 1; + + //Map states to indices + std::map<automaton::State, int> states; + for (const automaton::State& state : a.getStates()) { + states.insert(std::make_pair(state, cnt++)); + } + + //Print final states + for (const automaton::State& state : a.getFinalStates()) { + out << "node [shape = doublecircle, label=\"" << alib::StringDataFactory::toString(state.getName()) << "\"]; " << states.find(state)->second << ";\n"; + } + + //Print nonfinal states + for (const auto& state : states) { + if (!a.getFinalStates().count(state.first)) { + out << "node [shape = circle, label=\"" << alib::StringDataFactory::toString(state.first.getName()) << "\" ]; " << state.second << ";\n"; + } + } + + //Mark initial states + out << "node [shape = plaintext, label=\"start\"]; 0; \n"; + out << "0 -> " << states.find(a.getInitialState())->second << ";\n"; + + transitions(a, states, out); + out << "}"; +} + void DotConverter::convert(const automaton::InputDrivenNPDA& a, std::ostream& out) { out << "digraph automaton {\n"; out << "rankdir=LR;\n"; @@ -877,6 +909,70 @@ void DotConverter::transitions(const automaton::SinglePopDPDA& pda, const std::m } } +void DotConverter::transitions(const automaton::InputDrivenDPDA& pda, const std::map<automaton::State, int>& states, std::ostream& out) { + std::map<std::pair<int, int>, std::string> transitions; + + const auto& symbolToPDSOperation = pda.getPushdownStoreOperations(); + for (const auto& transition : pda.getTransitions()) { + const auto& pop = symbolToPDSOperation.find(transition.first.second)->second.first; + const auto& push = symbolToPDSOperation.find(transition.first.second)->second.second; + + std::string symbol; + + //input symbol + symbol = alib::StringDataFactory::toString(transition.first.second); + + symbol += " |"; + + //Pop part + if (pop.size() == 0) { + symbol += " ε"; + } else { + for (alphabet::Symbol symb : pop) { + symbol += " " + alib::StringDataFactory::toString(symb); + } + + } + + symbol += " ->"; + + const auto& to = transition.second; + //Push part + if (push.size() == 0) { + symbol += " ε"; + } else { + for (alphabet::Symbol symb : push) { + symbol += " " + alib::StringDataFactory::toString(symb); + } + + } + + //Insert into map + std::pair<int, int> key(states.find(transition.first.first)->second, states.find(to)->second); + std::map<std::pair<int, int>, std::string>::iterator mapit = transitions.find(key); + + if (mapit == transitions.end()) { + transitions.insert(std::make_pair(key, symbol)); + } else { + mapit->second += ","; + + size_t pos = mapit->second.find_last_of("\n"); + if(pos == std::string::npos) pos = 0; + if(mapit->second.size() - pos > 100) mapit->second += "\n"; + else mapit->second += " "; + + mapit->second += symbol; + } + } + + //print the map + for (std::pair<const std::pair<int, int>, std::string>& transition : transitions) { + out << transition.first.first << " -> " << transition.first.second; + replace(transition.second, "\n", "\\n"); + out << "[label=\"" << transition.second << "\"]\n"; + } +} + void DotConverter::transitions(const automaton::InputDrivenNPDA& pda, const std::map<automaton::State, int>& states, std::ostream& out) { std::map<std::pair<int, int>, std::string> transitions; @@ -1626,6 +1722,10 @@ void DotConverter::Visit(void* data, const automaton::SinglePopDPDA& automaton) DotConverter::convert(automaton, *((std::ostream*) data)); } +void DotConverter::Visit(void* data, const automaton::InputDrivenDPDA& automaton) const { + DotConverter::convert(automaton, *((std::ostream*) data)); +} + void DotConverter::Visit(void* data, const automaton::InputDrivenNPDA& automaton) const { DotConverter::convert(automaton, *((std::ostream*) data)); } diff --git a/aconvert2/src/DotConverter.h b/aconvert2/src/DotConverter.h index 256c076582..5a9e26086d 100644 --- a/aconvert2/src/DotConverter.h +++ b/aconvert2/src/DotConverter.h @@ -24,6 +24,7 @@ class DotConverter : public automaton::VisitableAutomatonBase::const_visitor_typ void Visit(void*, const automaton::CompactNFA& automaton) const; void Visit(void*, const automaton::DPDA& automaton) const; void Visit(void*, const automaton::SinglePopDPDA& automaton) const; + void Visit(void*, const automaton::InputDrivenDPDA& automaton) const; void Visit(void*, const automaton::InputDrivenNPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownDPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownNPDA& automaton) const; @@ -41,6 +42,7 @@ class DotConverter : public automaton::VisitableAutomatonBase::const_visitor_typ static void transitions(const automaton::CompactNFA& fsm, const std::map<automaton::State, int>& states, std::ostream& out); static void transitions(const automaton::DPDA& pda, const std::map<automaton::State, int>& states, std::ostream& out); static void transitions(const automaton::SinglePopDPDA& tm, const std::map<automaton::State, int>& states, std::ostream& out); + static void transitions(const automaton::InputDrivenDPDA& pda, const std::map<automaton::State, int>& states, std::ostream& out); static void transitions(const automaton::InputDrivenNPDA& pda, const std::map<automaton::State, int>& states, std::ostream& out); static void transitions(const automaton::VisiblyPushdownDPDA& tm, const std::map<automaton::State, int>& states, std::ostream& out); static void transitions(const automaton::VisiblyPushdownNPDA& tm, const std::map<automaton::State, int>& states, std::ostream& out); @@ -62,6 +64,7 @@ public: static void convert(const automaton::CompactNFA& a, std::ostream& out); static void convert(const automaton::DPDA& a, std::ostream& out); static void convert(const automaton::SinglePopDPDA& a, std::ostream& out); + static void convert(const automaton::InputDrivenDPDA& a, std::ostream& out); static void convert(const automaton::InputDrivenNPDA& a, std::ostream& out); static void convert(const automaton::VisiblyPushdownDPDA& a, std::ostream& out); static void convert(const automaton::VisiblyPushdownNPDA& a, std::ostream& out); diff --git a/aconvert2/src/GasTexConverter.cpp b/aconvert2/src/GasTexConverter.cpp index 9c17c13ca6..e72eeec23c 100644 --- a/aconvert2/src/GasTexConverter.cpp +++ b/aconvert2/src/GasTexConverter.cpp @@ -15,6 +15,7 @@ #include <automaton/FSM/CompactNFA.h> #include <automaton/PDA/DPDA.h> #include <automaton/PDA/SinglePopDPDA.h> +#include <automaton/PDA/InputDrivenDPDA.h> #include <automaton/PDA/InputDrivenNPDA.h> #include <automaton/PDA/VisiblyPushdownDPDA.h> #include <automaton/PDA/VisiblyPushdownNPDA.h> @@ -347,6 +348,45 @@ void GasTexConverter::convert(const automaton::SinglePopDPDA& a, std::ostream& o out << "\\end{picture}\n"; } +void GasTexConverter::convert(const automaton::InputDrivenDPDA& a, std::ostream& out) { + out << "\\begin{center}\n"; + out << "\\begin{picture}(,)(,)\n"; + + for (auto& state : a.getStates()) { + bool initial = false; + bool final = false; + + if(a.getInitialState() == state){ + initial = true; + } + if(a.getFinalStates().count(state)){ + final = true; + } + + if(initial || final) { + out << "\\node[Nmarks="; + if(initial){ + out << "i"; + } + if(final){ + out << "r"; + } + out<<"]("; + } else { + out <<"\\node("; + } + + out << state.getName(); + out << ")(,){"; + out << state.getName(); + out << "}\n"; + } + + transitions(a, out); + out << "\\end{center}\n"; + out << "\\end{picture}\n"; +} + void GasTexConverter::convert(const automaton::InputDrivenNPDA& a, std::ostream& out) { out << "\\begin{center}\n"; out << "\\begin{picture}(,)(,)\n"; @@ -879,6 +919,36 @@ void GasTexConverter::transitions(const automaton::SinglePopDPDA& pda, std::ostr printTransitionMap(transitionMap, out); } +void GasTexConverter::transitions(const automaton::InputDrivenDPDA& pda, std::ostream& out) { + std::map<std::pair<std::string, std::string>, std::string> transitionMap; + + const auto& symbolToPDSOperation = pda.getPushdownStoreOperations(); + for (const auto& transition : pda.getTransitions()) { + const auto& pop = symbolToPDSOperation.find(std::get<1>(transition.first))->second.first; + const auto& push = symbolToPDSOperation.find(std::get<1>(transition.first))->second.second; + + const auto& to = transition.second; + std::pair<std::string, std::string> key((std::string) transition.first.first.getName(), (std::string) to.getName()); + auto mapIterator = transitionMap.find(key); + + std::string symbol = alib::StringDataFactory::toString(transition.first.second); + + symbol += "|"; + + symbol += getStackSymbols(pop); + symbol += "\\rarrow"; + symbol += getStackSymbols(push); + + if (mapIterator == transitionMap.end()) { + transitionMap.insert(std::make_pair(key, symbol)); + } else { + mapIterator->second += "; " + symbol; + } + } + + printTransitionMap(transitionMap, out); +} + void GasTexConverter::transitions(const automaton::InputDrivenNPDA& pda, std::ostream& out) { std::map<std::pair<std::string, std::string>, std::string> transitionMap; @@ -1337,6 +1407,10 @@ void GasTexConverter::Visit(void* data, const automaton::SinglePopDPDA& automato GasTexConverter::convert(automaton, *((std::ostream*) data)); } +void GasTexConverter::Visit(void* data, const automaton::InputDrivenDPDA& automaton) const { + GasTexConverter::convert(automaton, *((std::ostream*) data)); +} + void GasTexConverter::Visit(void* data, const automaton::InputDrivenNPDA& automaton) const { GasTexConverter::convert(automaton, *((std::ostream*) data)); } diff --git a/aconvert2/src/GasTexConverter.h b/aconvert2/src/GasTexConverter.h index 6f3f1f9192..791b28ebf9 100644 --- a/aconvert2/src/GasTexConverter.h +++ b/aconvert2/src/GasTexConverter.h @@ -24,6 +24,7 @@ class GasTexConverter : public automaton::VisitableAutomatonBase::const_visitor_ void Visit(void*, const automaton::CompactNFA& automaton) const; void Visit(void*, const automaton::DPDA& automaton) const; void Visit(void*, const automaton::SinglePopDPDA& automaton) const; + void Visit(void*, const automaton::InputDrivenDPDA& automaton) const; void Visit(void*, const automaton::InputDrivenNPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownDPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownNPDA& automaton) const; @@ -44,6 +45,7 @@ class GasTexConverter : public automaton::VisitableAutomatonBase::const_visitor_ static void transitions(const automaton::CompactNFA& fsm, std::ostream& out); static void transitions(const automaton::DPDA& pda, std::ostream& out); static void transitions(const automaton::SinglePopDPDA& tm, std::ostream& out); + static void transitions(const automaton::InputDrivenDPDA& pda, std::ostream& out); static void transitions(const automaton::InputDrivenNPDA& pda, std::ostream& out); static void transitions(const automaton::VisiblyPushdownDPDA& tm, std::ostream& out); static void transitions(const automaton::VisiblyPushdownNPDA& tm, std::ostream& out); @@ -65,6 +67,7 @@ public: static void convert(const automaton::CompactNFA& a, std::ostream& out); static void convert(const automaton::DPDA& a, std::ostream& out); static void convert(const automaton::SinglePopDPDA& a, std::ostream& out); + static void convert(const automaton::InputDrivenDPDA& a, std::ostream& out); static void convert(const automaton::InputDrivenNPDA& a, std::ostream& out); static void convert(const automaton::VisiblyPushdownDPDA& a, std::ostream& out); static void convert(const automaton::VisiblyPushdownNPDA& a, std::ostream& out); diff --git a/alib2algo/src/automaton/convert/ToGrammar.cpp b/alib2algo/src/automaton/convert/ToGrammar.cpp index 1d99eae5be..9c1695445f 100644 --- a/alib2algo/src/automaton/convert/ToGrammar.cpp +++ b/alib2algo/src/automaton/convert/ToGrammar.cpp @@ -55,6 +55,10 @@ void ToGrammar::Visit(void*, const SinglePopDPDA&) const { throw exception::AlibException("Unsupported automaton type SinglePopDPDA"); } +void ToGrammar::Visit(void*, const InputDrivenDPDA&) const { + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void ToGrammar::Visit(void*, const InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); } diff --git a/alib2algo/src/automaton/convert/ToGrammar.h b/alib2algo/src/automaton/convert/ToGrammar.h index 5a25ba02cb..73e094c4e2 100644 --- a/alib2algo/src/automaton/convert/ToGrammar.h +++ b/alib2algo/src/automaton/convert/ToGrammar.h @@ -36,6 +36,7 @@ private: void Visit(void*, const CompactNFA& automaton) const; void Visit(void*, const DPDA& automaton) const; void Visit(void*, const SinglePopDPDA& automaton) const; + void Visit(void*, const InputDrivenDPDA& automaton) const; void Visit(void*, const InputDrivenNPDA& automaton) const; void Visit(void*, const VisiblyPushdownDPDA& automaton) const; void Visit(void*, const VisiblyPushdownNPDA& automaton) const; diff --git a/alib2algo/src/automaton/convert/ToRegExp.cpp b/alib2algo/src/automaton/convert/ToRegExp.cpp index b92369d796..f73b0792b8 100644 --- a/alib2algo/src/automaton/convert/ToRegExp.cpp +++ b/alib2algo/src/automaton/convert/ToRegExp.cpp @@ -51,46 +51,6 @@ void ToRegExp::Visit(void* data, const automaton::CompactNFA& automaton) const { out = new regexp::RegExp(ToRegExpStateElimination::convert(automaton)); } -void ToRegExp::Visit(void*, const DPDA&) const { - throw exception::AlibException("Unsupported automaton type DPDA"); -} - -void ToRegExp::Visit(void*, const SinglePopDPDA&) const { - throw exception::AlibException("Unsupported automaton type SinglePopDPDA"); -} - -void ToRegExp::Visit(void*, const InputDrivenNPDA&) const { - throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); -} - -void ToRegExp::Visit(void*, const VisiblyPushdownDPDA&) const { - throw exception::AlibException("Unsupported automaton type VisiblyPushdownDPDA"); -} - -void ToRegExp::Visit(void*, const VisiblyPushdownNPDA&) const { - throw exception::AlibException("Unsupported automaton type VisiblyPushdownNPDA"); -} - -void ToRegExp::Visit(void*, const RealTimeHeightDeterministicDPDA&) const { - throw exception::AlibException("Unsupported automaton type RealTimeHeightDeterministicDPDA"); -} - -void ToRegExp::Visit(void*, const RealTimeHeightDeterministicNPDA&) const { - throw exception::AlibException("Unsupported automaton type RealTimeHeightDeterministicNPDA"); -} - -void ToRegExp::Visit(void*, const NPDA&) const { - throw exception::AlibException("Unsupported automaton type NPDA"); -} - -void ToRegExp::Visit(void*, const SinglePopNPDA&) const { - throw exception::AlibException("Unsupported automaton type SinglePopNPDA"); -} - -void ToRegExp::Visit(void*, const OneTapeDTM&) const { - throw exception::AlibException("Unsupported automaton type OneTapeDTM"); -} - const ToRegExp ToRegExp::TO_REGEXP; } /* namespace convert */ diff --git a/alib2algo/src/automaton/convert/ToRegExp.h b/alib2algo/src/automaton/convert/ToRegExp.h index b525181950..3718c38af0 100644 --- a/alib2algo/src/automaton/convert/ToRegExp.h +++ b/alib2algo/src/automaton/convert/ToRegExp.h @@ -20,7 +20,7 @@ namespace automaton { namespace convert { -class ToRegExp : public automaton::VisitableAutomatonBase::const_visitor_type { +class ToRegExp : public automaton::VisitableConstFSMBase { public: /** * Performs conversion. @@ -35,16 +35,6 @@ private: void Visit(void*, const DFA& automaton) const; void Visit(void*, const ExtendedNFA& automaton) const; void Visit(void*, const CompactNFA& automaton) const; - void Visit(void*, const DPDA& automaton) const; - void Visit(void*, const SinglePopDPDA& automaton) const; - void Visit(void*, const InputDrivenNPDA& automaton) const; - void Visit(void*, const VisiblyPushdownDPDA& automaton) const; - void Visit(void*, const VisiblyPushdownNPDA& automaton) const; - void Visit(void*, const RealTimeHeightDeterministicDPDA& automaton) const; - void Visit(void*, const RealTimeHeightDeterministicNPDA& automaton) const; - void Visit(void*, const NPDA& automaton) const; - void Visit(void*, const SinglePopNPDA& automaton) const; - void Visit(void*, const OneTapeDTM& automaton) const; static const ToRegExp TO_REGEXP; }; diff --git a/alib2algo/src/automaton/determinize/Determinize.cpp b/alib2algo/src/automaton/determinize/Determinize.cpp index b2cbd2ce56..f0609e1936 100644 --- a/alib2algo/src/automaton/determinize/Determinize.cpp +++ b/alib2algo/src/automaton/determinize/Determinize.cpp @@ -60,13 +60,19 @@ void Determinize::Visit(void* data, const automaton::SinglePopDPDA& automaton) c out = new automaton::Automaton(automaton); } +void Determinize::Visit(void* data, const automaton::InputDrivenDPDA& automaton) const { + automaton::Automaton* & out = *((automaton::Automaton**) data); + out = new automaton::Automaton(automaton); +} + void Determinize::Visit(void* data, const automaton::InputDrivenNPDA& automaton) const { automaton::Automaton* & out = *((automaton::Automaton**) data); out = new automaton::Automaton(this->determinize(automaton)); } -void Determinize::Visit(void*, const automaton::VisiblyPushdownDPDA&) const { - throw exception::AlibException("Unsupported automaton type VisiblyPushdownDPDA"); +void Determinize::Visit(void* data, const automaton::VisiblyPushdownDPDA& automaton) const { + automaton::Automaton* & out = *((automaton::Automaton**) data); + out = new automaton::Automaton(automaton); } void Determinize::Visit(void* data, const automaton::VisiblyPushdownNPDA& automaton) const { diff --git a/alib2algo/src/automaton/determinize/Determinize.h b/alib2algo/src/automaton/determinize/Determinize.h index 7409d0922c..11f9751504 100644 --- a/alib2algo/src/automaton/determinize/Determinize.h +++ b/alib2algo/src/automaton/determinize/Determinize.h @@ -14,6 +14,7 @@ #include <automaton/Automaton.h> #include <automaton/FSM/DFA.h> #include <automaton/PDA/DPDA.h> +#include <automaton/PDA/InputDrivenDPDA.h> #include <automaton/PDA/SinglePopDPDA.h> #include <automaton/PDA/VisiblyPushdownDPDA.h> #include <automaton/PDA/RealTimeHeightDeterministicDPDA.h> @@ -38,6 +39,7 @@ private: void Visit(void*, const automaton::CompactNFA& automaton) const; void Visit(void*, const automaton::DPDA& automaton) const; void Visit(void*, const automaton::SinglePopDPDA& automaton) const; + void Visit(void*, const automaton::InputDrivenDPDA& automaton) const; void Visit(void*, const automaton::InputDrivenNPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownDPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownNPDA& automaton) const; @@ -61,7 +63,7 @@ public: static automaton::DFA determinize(const automaton::NFA& nfa); static automaton::DFA determinize(const automaton::MultiInitialStateNFA& nfa); static automaton::VisiblyPushdownDPDA determinize(const automaton::VisiblyPushdownNPDA& nondeterministic); - static automaton::DPDA determinize(const automaton::InputDrivenNPDA& nfa); + static automaton::InputDrivenDPDA determinize(const automaton::InputDrivenNPDA& nfa); static automaton::RealTimeHeightDeterministicDPDA determinize(const automaton::RealTimeHeightDeterministicNPDA& nondeterministic); }; diff --git a/alib2algo/src/automaton/determinize/DeterminizeIDPDAPart.cxx b/alib2algo/src/automaton/determinize/DeterminizeIDPDAPart.cxx index 798254e0eb..e172c74d25 100644 --- a/alib2algo/src/automaton/determinize/DeterminizeIDPDAPart.cxx +++ b/alib2algo/src/automaton/determinize/DeterminizeIDPDAPart.cxx @@ -15,12 +15,13 @@ namespace automaton { namespace determinize { -automaton::DPDA Determinize::determinize(const automaton::InputDrivenNPDA& nfa) { +automaton::InputDrivenDPDA Determinize::determinize(const automaton::InputDrivenNPDA& nfa) { // 1, 4 automaton::State initialState(createDFAState({nfa.getInitialState()})); - automaton::DPDA res(initialState, nfa.getInitialSymbol()); + automaton::InputDrivenDPDA res(initialState, nfa.getInitialSymbol()); res.setInputAlphabet(nfa.getInputAlphabet()); res.setStackAlphabet(nfa.getStackAlphabet()); + res.setPushdownStoreOperations(nfa.getPushdownStoreOperations()); // 2 std::deque<automaton::State> todo; @@ -46,8 +47,7 @@ automaton::DPDA Determinize::determinize(const automaton::InputDrivenNPDA& nfa) bool existed = !res.addState(dfaState); // 3b - const auto& pushdownOperation = nfa.getPushdownStoreOperations().find(input)->second; - res.addTransition(state, input, pushdownOperation.first, dfaState, pushdownOperation.second); + res.addTransition(state, input, dfaState); if(!existed) todo.push_back(dfaState); } diff --git a/alib2algo/src/automaton/properties/EpsilonClosure.cpp b/alib2algo/src/automaton/properties/EpsilonClosure.cpp index 43281c325f..56f3c292f7 100644 --- a/alib2algo/src/automaton/properties/EpsilonClosure.cpp +++ b/alib2algo/src/automaton/properties/EpsilonClosure.cpp @@ -178,6 +178,10 @@ void EpsilonClosure::Visit(void*, const SinglePopDPDA&) const { throw exception::AlibException("Unsupported automaton type SinglePopDPDA"); } +void EpsilonClosure::Visit(void*, const InputDrivenDPDA&) const { + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void EpsilonClosure::Visit(void*, const InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); } diff --git a/alib2algo/src/automaton/properties/EpsilonClosure.h b/alib2algo/src/automaton/properties/EpsilonClosure.h index eb768f772a..2746d25f36 100644 --- a/alib2algo/src/automaton/properties/EpsilonClosure.h +++ b/alib2algo/src/automaton/properties/EpsilonClosure.h @@ -42,6 +42,7 @@ private: void Visit(void*, const CompactNFA& automaton) const; void Visit(void*, const DPDA& automaton) const; void Visit(void*, const SinglePopDPDA& automaton) const; + void Visit(void*, const InputDrivenDPDA& automaton) const; void Visit(void*, const InputDrivenNPDA& automaton) const; void Visit(void*, const VisiblyPushdownDPDA& automaton) const; void Visit(void*, const VisiblyPushdownNPDA& automaton) const; diff --git a/alib2algo/src/automaton/properties/UnreachableStates.cpp b/alib2algo/src/automaton/properties/UnreachableStates.cpp index fd730f3edc..6e23bae903 100644 --- a/alib2algo/src/automaton/properties/UnreachableStates.cpp +++ b/alib2algo/src/automaton/properties/UnreachableStates.cpp @@ -149,6 +149,10 @@ void UnreachableStates::Visit(void*, const SinglePopDPDA&) const { throw exception::AlibException("Unsupported automaton type SinglePopDPDA"); } +void UnreachableStates::Visit(void*, const InputDrivenDPDA&) const { + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void UnreachableStates::Visit(void*, const InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); } diff --git a/alib2algo/src/automaton/properties/UnreachableStates.h b/alib2algo/src/automaton/properties/UnreachableStates.h index d50644c4b7..bd51109cb8 100644 --- a/alib2algo/src/automaton/properties/UnreachableStates.h +++ b/alib2algo/src/automaton/properties/UnreachableStates.h @@ -38,6 +38,7 @@ private: void Visit(void*, const CompactNFA& automaton) const; void Visit(void*, const DPDA& automaton) const; void Visit(void*, const SinglePopDPDA& automaton) const; + void Visit(void*, const InputDrivenDPDA& automaton) const; void Visit(void*, const InputDrivenNPDA& automaton) const; void Visit(void*, const VisiblyPushdownDPDA& automaton) const; void Visit(void*, const VisiblyPushdownNPDA& automaton) const; diff --git a/alib2algo/src/automaton/properties/UsefullStates.cpp b/alib2algo/src/automaton/properties/UsefullStates.cpp index 83a53781ae..3c5f246937 100644 --- a/alib2algo/src/automaton/properties/UsefullStates.cpp +++ b/alib2algo/src/automaton/properties/UsefullStates.cpp @@ -119,6 +119,10 @@ void UsefullStates::Visit(void*, const SinglePopDPDA&) const { throw exception::AlibException("Unsupported automaton type SinglePopDPDA"); } +void UsefullStates::Visit(void*, const InputDrivenDPDA&) const { + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void UsefullStates::Visit(void*, const InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); } diff --git a/alib2algo/src/automaton/properties/UsefullStates.h b/alib2algo/src/automaton/properties/UsefullStates.h index 81a1158029..5e8b745df2 100644 --- a/alib2algo/src/automaton/properties/UsefullStates.h +++ b/alib2algo/src/automaton/properties/UsefullStates.h @@ -38,6 +38,7 @@ private: void Visit(void*, const CompactNFA& automaton) const; void Visit(void*, const DPDA& automaton) const; void Visit(void*, const SinglePopDPDA& automaton) const; + void Visit(void*, const InputDrivenDPDA& automaton) const; void Visit(void*, const InputDrivenNPDA& automaton) const; void Visit(void*, const VisiblyPushdownDPDA& automaton) const; void Visit(void*, const VisiblyPushdownNPDA& automaton) const; diff --git a/alib2algo/src/automaton/run/Accept.cpp b/alib2algo/src/automaton/run/Accept.cpp index 6c68c9a12c..be35e5ae2d 100644 --- a/alib2algo/src/automaton/run/Accept.cpp +++ b/alib2algo/src/automaton/run/Accept.cpp @@ -127,6 +127,10 @@ void Accept::Visit(void*, const SinglePopDPDA&) const { throw exception::AlibException("Unsupported automaton type SinglePopDPDA"); } +void Accept::Visit(void*, const InputDrivenDPDA&) const { + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void Accept::Visit(void*, const InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); } diff --git a/alib2algo/src/automaton/run/Accept.h b/alib2algo/src/automaton/run/Accept.h index e4ba6aba2c..e1cc13d7ac 100644 --- a/alib2algo/src/automaton/run/Accept.h +++ b/alib2algo/src/automaton/run/Accept.h @@ -35,6 +35,7 @@ private: void Visit(void*, const CompactNFA& automaton) const; void Visit(void*, const DPDA& automaton) const; void Visit(void*, const SinglePopDPDA& automaton) const; + void Visit(void*, const InputDrivenDPDA& automaton) const; void Visit(void*, const InputDrivenNPDA& automaton) const; void Visit(void*, const VisiblyPushdownDPDA& automaton) const; void Visit(void*, const VisiblyPushdownNPDA& automaton) const; diff --git a/alib2algo/src/automaton/run/Occurrences.cpp b/alib2algo/src/automaton/run/Occurrences.cpp index f898a07474..f04cb5d000 100644 --- a/alib2algo/src/automaton/run/Occurrences.cpp +++ b/alib2algo/src/automaton/run/Occurrences.cpp @@ -129,6 +129,10 @@ void Occurrences::Visit(void*, const SinglePopDPDA&) const { throw exception::AlibException("Unsupported automaton type SinglePopDPDA"); } +void Occurrences::Visit(void*, const InputDrivenDPDA&) const { + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void Occurrences::Visit(void*, const InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); } diff --git a/alib2algo/src/automaton/run/Occurrences.h b/alib2algo/src/automaton/run/Occurrences.h index 844e431243..7481e1033a 100644 --- a/alib2algo/src/automaton/run/Occurrences.h +++ b/alib2algo/src/automaton/run/Occurrences.h @@ -34,6 +34,7 @@ private: void Visit(void*, const CompactNFA& automaton) const; void Visit(void*, const DPDA& automaton) const; void Visit(void*, const SinglePopDPDA& automaton) const; + void Visit(void*, const InputDrivenDPDA& automaton) const; void Visit(void*, const InputDrivenNPDA& automaton) const; void Visit(void*, const VisiblyPushdownDPDA& automaton) const; void Visit(void*, const VisiblyPushdownNPDA& automaton) const; diff --git a/alib2algo/src/automaton/simplify/EpsilonRemoverIncoming.cpp b/alib2algo/src/automaton/simplify/EpsilonRemoverIncoming.cpp index fc35d24f16..d24dcfa8fc 100644 --- a/alib2algo/src/automaton/simplify/EpsilonRemoverIncoming.cpp +++ b/alib2algo/src/automaton/simplify/EpsilonRemoverIncoming.cpp @@ -108,6 +108,10 @@ void EpsilonRemoverIncoming::Visit(void*, const automaton::SinglePopDPDA&) const throw exception::AlibException("Unsupported automaton type SinglePopDPDA"); } +void EpsilonRemoverIncoming::Visit(void*, const automaton::InputDrivenDPDA&) const { + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void EpsilonRemoverIncoming::Visit(void*, const automaton::InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); } diff --git a/alib2algo/src/automaton/simplify/EpsilonRemoverIncoming.h b/alib2algo/src/automaton/simplify/EpsilonRemoverIncoming.h index 098cd15a5b..424a9e23bc 100644 --- a/alib2algo/src/automaton/simplify/EpsilonRemoverIncoming.h +++ b/alib2algo/src/automaton/simplify/EpsilonRemoverIncoming.h @@ -44,6 +44,7 @@ private: void Visit(void*, const automaton::CompactNFA& automaton) const; void Visit(void*, const automaton::DPDA& automaton) const; void Visit(void*, const automaton::SinglePopDPDA& automaton) const; + void Visit(void*, const automaton::InputDrivenDPDA& automaton) const; void Visit(void*, const automaton::InputDrivenNPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownDPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownNPDA& automaton) const; diff --git a/alib2algo/src/automaton/simplify/EpsilonRemoverOutgoing.cpp b/alib2algo/src/automaton/simplify/EpsilonRemoverOutgoing.cpp index d91a376a0f..996c00dca1 100644 --- a/alib2algo/src/automaton/simplify/EpsilonRemoverOutgoing.cpp +++ b/alib2algo/src/automaton/simplify/EpsilonRemoverOutgoing.cpp @@ -106,6 +106,10 @@ void EpsilonRemoverOutgoing::Visit(void*, const automaton::SinglePopDPDA&) const throw exception::AlibException("Unsupported automaton type SinglePopDPDA"); } +void EpsilonRemoverOutgoing::Visit(void*, const automaton::InputDrivenDPDA&) const { + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void EpsilonRemoverOutgoing::Visit(void*, const automaton::InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); } diff --git a/alib2algo/src/automaton/simplify/EpsilonRemoverOutgoing.h b/alib2algo/src/automaton/simplify/EpsilonRemoverOutgoing.h index 190c222887..86f3201e50 100644 --- a/alib2algo/src/automaton/simplify/EpsilonRemoverOutgoing.h +++ b/alib2algo/src/automaton/simplify/EpsilonRemoverOutgoing.h @@ -44,6 +44,7 @@ private: void Visit(void*, const automaton::CompactNFA& automaton) const; void Visit(void*, const automaton::DPDA& automaton) const; void Visit(void*, const automaton::SinglePopDPDA& automaton) const; + void Visit(void*, const automaton::InputDrivenDPDA& automaton) const; void Visit(void*, const automaton::InputDrivenNPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownDPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownNPDA& automaton) const; diff --git a/alib2algo/src/automaton/simplify/Minimize.cpp b/alib2algo/src/automaton/simplify/Minimize.cpp index 9029c723b2..2bd6b930bc 100644 --- a/alib2algo/src/automaton/simplify/Minimize.cpp +++ b/alib2algo/src/automaton/simplify/Minimize.cpp @@ -172,6 +172,10 @@ void Minimize::Visit(void*, const automaton::SinglePopDPDA&) const { throw exception::AlibException("Unsupported automaton type SinglePopDPDA"); } +void Minimize::Visit(void*, const automaton::InputDrivenDPDA&) const { + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void Minimize::Visit(void*, const automaton::InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); } diff --git a/alib2algo/src/automaton/simplify/Minimize.h b/alib2algo/src/automaton/simplify/Minimize.h index 8cd094c7de..00a68b6546 100644 --- a/alib2algo/src/automaton/simplify/Minimize.h +++ b/alib2algo/src/automaton/simplify/Minimize.h @@ -33,6 +33,7 @@ protected: void Visit(void*, const automaton::CompactNFA& automaton) const; void Visit(void*, const automaton::DPDA& automaton) const; void Visit(void*, const automaton::SinglePopDPDA& automaton) const; + void Visit(void*, const automaton::InputDrivenDPDA& automaton) const; void Visit(void*, const automaton::InputDrivenNPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownDPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownNPDA& automaton) const; diff --git a/alib2algo/src/automaton/simplify/Normalize.cpp b/alib2algo/src/automaton/simplify/Normalize.cpp index c49bc62afe..a8af74ae2d 100644 --- a/alib2algo/src/automaton/simplify/Normalize.cpp +++ b/alib2algo/src/automaton/simplify/Normalize.cpp @@ -193,6 +193,10 @@ void Normalize::Visit(void*, const automaton::SinglePopDPDA&) const { throw exception::AlibException("Unsupported automaton type SinglePopDPDA"); } +void Normalize::Visit(void*, const automaton::InputDrivenDPDA&) const { + throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); +} + void Normalize::Visit(void*, const automaton::InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); } diff --git a/alib2algo/src/automaton/simplify/Normalize.h b/alib2algo/src/automaton/simplify/Normalize.h index 2918934782..e6bad87ff6 100644 --- a/alib2algo/src/automaton/simplify/Normalize.h +++ b/alib2algo/src/automaton/simplify/Normalize.h @@ -36,6 +36,7 @@ protected: void Visit(void*, const automaton::CompactNFA& automaton) const; void Visit(void*, const automaton::DPDA& automaton) const; void Visit(void*, const automaton::SinglePopDPDA& automaton) const; + void Visit(void*, const automaton::InputDrivenDPDA& automaton) const; void Visit(void*, const automaton::InputDrivenNPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownDPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownNPDA& automaton) const; diff --git a/alib2algo/src/automaton/simplify/Rename.cpp b/alib2algo/src/automaton/simplify/Rename.cpp index c466d2e29d..f766d66aec 100644 --- a/alib2algo/src/automaton/simplify/Rename.cpp +++ b/alib2algo/src/automaton/simplify/Rename.cpp @@ -139,6 +139,10 @@ void Rename::Visit(void*, const automaton::SinglePopDPDA&) const { throw exception::AlibException("Unsupported automaton type SinglePopDPDA"); } +void Rename::Visit(void*, const automaton::InputDrivenDPDA&) const { + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void Rename::Visit(void*, const automaton::InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); } diff --git a/alib2algo/src/automaton/simplify/Rename.h b/alib2algo/src/automaton/simplify/Rename.h index 45000727d8..8ff66a6f47 100644 --- a/alib2algo/src/automaton/simplify/Rename.h +++ b/alib2algo/src/automaton/simplify/Rename.h @@ -36,6 +36,7 @@ protected: void Visit(void*, const automaton::CompactNFA& automaton) const; void Visit(void*, const automaton::DPDA& automaton) const; void Visit(void*, const automaton::SinglePopDPDA& automaton) const; + void Visit(void*, const automaton::InputDrivenDPDA& automaton) const; void Visit(void*, const automaton::InputDrivenNPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownDPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownNPDA& automaton) const; diff --git a/alib2algo/src/automaton/simplify/SingleInitialState.cpp b/alib2algo/src/automaton/simplify/SingleInitialState.cpp index 7b21af79a2..4712810c6e 100644 --- a/alib2algo/src/automaton/simplify/SingleInitialState.cpp +++ b/alib2algo/src/automaton/simplify/SingleInitialState.cpp @@ -130,6 +130,10 @@ void SingleInitialState::Visit(void*, const SinglePopDPDA&) const { throw exception::AlibException("Unsupported automaton type SinglePopDPDA"); } +void SingleInitialState::Visit(void*, const InputDrivenDPDA&) const { + throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); +} + void SingleInitialState::Visit(void*, const InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); } diff --git a/alib2algo/src/automaton/simplify/SingleInitialState.h b/alib2algo/src/automaton/simplify/SingleInitialState.h index e5b1f6085c..65a0c20cfb 100644 --- a/alib2algo/src/automaton/simplify/SingleInitialState.h +++ b/alib2algo/src/automaton/simplify/SingleInitialState.h @@ -43,6 +43,7 @@ private: void Visit(void*, const CompactNFA& automaton) const; void Visit(void*, const DPDA& automaton) const; void Visit(void*, const SinglePopDPDA& automaton) const; + void Visit(void*, const InputDrivenDPDA& automaton) const; void Visit(void*, const InputDrivenNPDA& automaton) const; void Visit(void*, const VisiblyPushdownDPDA& automaton) const; void Visit(void*, const VisiblyPushdownNPDA& automaton) const; diff --git a/alib2algo/src/automaton/simplify/Trim.cpp b/alib2algo/src/automaton/simplify/Trim.cpp index 416378528d..a2cef7225a 100644 --- a/alib2algo/src/automaton/simplify/Trim.cpp +++ b/alib2algo/src/automaton/simplify/Trim.cpp @@ -81,6 +81,10 @@ void Trim::Visit(void*, const automaton::SinglePopDPDA&) const { throw exception::AlibException("Unsupported automaton type SinglePopDPDA"); } +void Trim::Visit(void*, const automaton::InputDrivenDPDA&) const { + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void Trim::Visit(void*, const automaton::InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); } diff --git a/alib2algo/src/automaton/simplify/Trim.h b/alib2algo/src/automaton/simplify/Trim.h index e5c085bd26..7b6ce047bd 100644 --- a/alib2algo/src/automaton/simplify/Trim.h +++ b/alib2algo/src/automaton/simplify/Trim.h @@ -36,6 +36,7 @@ private: void Visit(void*, const automaton::CompactNFA& automaton) const; void Visit(void*, const automaton::DPDA& automaton) const; void Visit(void*, const automaton::SinglePopDPDA& automaton) const; + void Visit(void*, const automaton::InputDrivenDPDA& automaton) const; void Visit(void*, const automaton::InputDrivenNPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownDPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownNPDA& automaton) const; diff --git a/alib2algo/src/automaton/simplify/UnreachableStatesRemover.cpp b/alib2algo/src/automaton/simplify/UnreachableStatesRemover.cpp index cfab0b7c60..86cdb96c93 100644 --- a/alib2algo/src/automaton/simplify/UnreachableStatesRemover.cpp +++ b/alib2algo/src/automaton/simplify/UnreachableStatesRemover.cpp @@ -157,6 +157,10 @@ void UnreachableStatesRemover::Visit(void*, const automaton::SinglePopDPDA&) con throw exception::AlibException("Unsupported automaton type SinglePopDPDA"); } +void UnreachableStatesRemover::Visit(void*, const automaton::InputDrivenDPDA&) const { + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void UnreachableStatesRemover::Visit(void*, const automaton::InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); } diff --git a/alib2algo/src/automaton/simplify/UnreachableStatesRemover.h b/alib2algo/src/automaton/simplify/UnreachableStatesRemover.h index 1422d99aa9..3f2d436d22 100644 --- a/alib2algo/src/automaton/simplify/UnreachableStatesRemover.h +++ b/alib2algo/src/automaton/simplify/UnreachableStatesRemover.h @@ -36,6 +36,7 @@ private: void Visit(void*, const automaton::CompactNFA& automaton) const; void Visit(void*, const automaton::DPDA& automaton) const; void Visit(void*, const automaton::SinglePopDPDA& automaton) const; + void Visit(void*, const automaton::InputDrivenDPDA& automaton) const; void Visit(void*, const automaton::InputDrivenNPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownDPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownNPDA& automaton) const; diff --git a/alib2algo/src/automaton/simplify/UselessStatesRemover.cpp b/alib2algo/src/automaton/simplify/UselessStatesRemover.cpp index 243a0e99bd..5b843eacdd 100644 --- a/alib2algo/src/automaton/simplify/UselessStatesRemover.cpp +++ b/alib2algo/src/automaton/simplify/UselessStatesRemover.cpp @@ -166,6 +166,10 @@ void UselessStatesRemover::Visit(void*, const automaton::SinglePopDPDA&) const { throw exception::AlibException("Unsupported automaton type SinglePopDPDA"); } +void UselessStatesRemover::Visit(void*, const automaton::InputDrivenDPDA&) const { + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void UselessStatesRemover::Visit(void*, const automaton::InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); } diff --git a/alib2algo/src/automaton/simplify/UselessStatesRemover.h b/alib2algo/src/automaton/simplify/UselessStatesRemover.h index dbf462579d..ba26622ab9 100644 --- a/alib2algo/src/automaton/simplify/UselessStatesRemover.h +++ b/alib2algo/src/automaton/simplify/UselessStatesRemover.h @@ -36,6 +36,7 @@ private: void Visit(void*, const automaton::CompactNFA& automaton) const; void Visit(void*, const automaton::DPDA& automaton) const; void Visit(void*, const automaton::SinglePopDPDA& automaton) const; + void Visit(void*, const automaton::InputDrivenDPDA& automaton) const; void Visit(void*, const automaton::InputDrivenNPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownDPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownNPDA& automaton) const; diff --git a/alib2algo/src/automaton/transform/AutomataConcatenation.cpp b/alib2algo/src/automaton/transform/AutomataConcatenation.cpp index c8e3cdbec3..b935f1892d 100644 --- a/alib2algo/src/automaton/transform/AutomataConcatenation.cpp +++ b/alib2algo/src/automaton/transform/AutomataConcatenation.cpp @@ -160,6 +160,11 @@ void AutomataConcatenation::Visit(void*, const automaton::NPDA&, const automaton throw exception::AlibException("Unsupported automaton type NPDA"); } +void AutomataConcatenation::Visit(void*, const automaton::InputDrivenDPDA&, const automaton::InputDrivenDPDA&) const +{ + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void AutomataConcatenation::Visit(void*, const automaton::InputDrivenNPDA&, const automaton::InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); diff --git a/alib2algo/src/automaton/transform/AutomataConcatenation.h b/alib2algo/src/automaton/transform/AutomataConcatenation.h index 9ee1b5523e..2cec016f66 100644 --- a/alib2algo/src/automaton/transform/AutomataConcatenation.h +++ b/alib2algo/src/automaton/transform/AutomataConcatenation.h @@ -40,6 +40,7 @@ private: void Visit(void* data, const automaton::DPDA& first, const automaton::DPDA& second) const; void Visit(void* data, const automaton::NPDA& first, const automaton::NPDA& second) const; void Visit(void* data, const automaton::InputDrivenNPDA& first, const automaton::InputDrivenNPDA& second) const; + void Visit(void* data, const automaton::InputDrivenDPDA& first, const automaton::InputDrivenDPDA& second) const; void Visit(void* data, const automaton::RealTimeHeightDeterministicDPDA& first, const automaton::RealTimeHeightDeterministicDPDA& second) const; void Visit(void* data, const automaton::RealTimeHeightDeterministicNPDA& first, const automaton::RealTimeHeightDeterministicNPDA& second) const; void Visit(void* data, const automaton::SinglePopNPDA& first, const automaton::SinglePopNPDA& second) const; diff --git a/alib2algo/src/automaton/transform/AutomataConcatenationEpsilonTransition.cpp b/alib2algo/src/automaton/transform/AutomataConcatenationEpsilonTransition.cpp index 199c99da24..8dc1219dad 100644 --- a/alib2algo/src/automaton/transform/AutomataConcatenationEpsilonTransition.cpp +++ b/alib2algo/src/automaton/transform/AutomataConcatenationEpsilonTransition.cpp @@ -162,6 +162,11 @@ void AutomataConcatenationEpsilonTransition::Visit(void*, const automaton::NPDA& throw exception::AlibException("Unsupported automaton type NPDA"); } +void AutomataConcatenationEpsilonTransition::Visit(void*, const automaton::InputDrivenDPDA&, const automaton::InputDrivenDPDA&) const +{ + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void AutomataConcatenationEpsilonTransition::Visit(void*, const automaton::InputDrivenNPDA&, const automaton::InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); diff --git a/alib2algo/src/automaton/transform/AutomataConcatenationEpsilonTransition.h b/alib2algo/src/automaton/transform/AutomataConcatenationEpsilonTransition.h index b1c5c54703..29ea1403b3 100644 --- a/alib2algo/src/automaton/transform/AutomataConcatenationEpsilonTransition.h +++ b/alib2algo/src/automaton/transform/AutomataConcatenationEpsilonTransition.h @@ -40,6 +40,7 @@ private: void Visit(void* data, const automaton::DPDA& first, const automaton::DPDA& second) const; void Visit(void* data, const automaton::NPDA& first, const automaton::NPDA& second) const; + void Visit(void* data, const automaton::InputDrivenDPDA& first, const automaton::InputDrivenDPDA& second) const; void Visit(void* data, const automaton::InputDrivenNPDA& first, const automaton::InputDrivenNPDA& second) const; void Visit(void* data, const automaton::RealTimeHeightDeterministicDPDA& first, const automaton::RealTimeHeightDeterministicDPDA& second) const; void Visit(void* data, const automaton::RealTimeHeightDeterministicNPDA& first, const automaton::RealTimeHeightDeterministicNPDA& second) const; diff --git a/alib2algo/src/automaton/transform/AutomataIntersectionCartesianProduct.cpp b/alib2algo/src/automaton/transform/AutomataIntersectionCartesianProduct.cpp index a287a18b3c..2100360dc2 100644 --- a/alib2algo/src/automaton/transform/AutomataIntersectionCartesianProduct.cpp +++ b/alib2algo/src/automaton/transform/AutomataIntersectionCartesianProduct.cpp @@ -135,6 +135,11 @@ void AutomataIntersectionCartesianProduct::Visit(void*, const automaton::NPDA&, throw exception::AlibException("Unsupported automaton type NPDA"); } +void AutomataIntersectionCartesianProduct::Visit(void*, const automaton::InputDrivenDPDA&, const automaton::InputDrivenDPDA&) const +{ + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void AutomataIntersectionCartesianProduct::Visit(void*, const automaton::InputDrivenNPDA&, const automaton::InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); diff --git a/alib2algo/src/automaton/transform/AutomataIntersectionCartesianProduct.h b/alib2algo/src/automaton/transform/AutomataIntersectionCartesianProduct.h index 2c00f01ea1..2878a772f1 100644 --- a/alib2algo/src/automaton/transform/AutomataIntersectionCartesianProduct.h +++ b/alib2algo/src/automaton/transform/AutomataIntersectionCartesianProduct.h @@ -39,6 +39,7 @@ private: void Visit(void* data, const automaton::DPDA& first, const automaton::DPDA& second) const; void Visit(void* data, const automaton::NPDA& first, const automaton::NPDA& second) const; + void Visit(void* data, const automaton::InputDrivenDPDA& first, const automaton::InputDrivenDPDA& second) const; void Visit(void* data, const automaton::InputDrivenNPDA& first, const automaton::InputDrivenNPDA& second) const; void Visit(void* data, const automaton::RealTimeHeightDeterministicDPDA& first, const automaton::RealTimeHeightDeterministicDPDA& second) const; void Visit(void* data, const automaton::RealTimeHeightDeterministicNPDA& first, const automaton::RealTimeHeightDeterministicNPDA& second) const; diff --git a/alib2algo/src/automaton/transform/AutomataUnionCartesianProduct.cpp b/alib2algo/src/automaton/transform/AutomataUnionCartesianProduct.cpp index 2a03e1e1bf..380da7f87a 100644 --- a/alib2algo/src/automaton/transform/AutomataUnionCartesianProduct.cpp +++ b/alib2algo/src/automaton/transform/AutomataUnionCartesianProduct.cpp @@ -149,6 +149,11 @@ void AutomataUnionCartesianProduct::Visit(void*, const automaton::NPDA&, const a throw exception::AlibException("Unsupported automaton type NPDA"); } +void AutomataUnionCartesianProduct::Visit(void*, const automaton::InputDrivenDPDA&, const automaton::InputDrivenDPDA&) const +{ + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void AutomataUnionCartesianProduct::Visit(void*, const automaton::InputDrivenNPDA&, const automaton::InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); diff --git a/alib2algo/src/automaton/transform/AutomataUnionCartesianProduct.h b/alib2algo/src/automaton/transform/AutomataUnionCartesianProduct.h index 305efabc5f..936de8af9f 100644 --- a/alib2algo/src/automaton/transform/AutomataUnionCartesianProduct.h +++ b/alib2algo/src/automaton/transform/AutomataUnionCartesianProduct.h @@ -39,6 +39,7 @@ private: void Visit(void* data, const automaton::DPDA& first, const automaton::DPDA& second) const; void Visit(void* data, const automaton::NPDA& first, const automaton::NPDA& second) const; + void Visit(void* data, const automaton::InputDrivenDPDA& first, const automaton::InputDrivenDPDA& second) const; void Visit(void* data, const automaton::InputDrivenNPDA& first, const automaton::InputDrivenNPDA& second) const; void Visit(void* data, const automaton::RealTimeHeightDeterministicDPDA& first, const automaton::RealTimeHeightDeterministicDPDA& second) const; void Visit(void* data, const automaton::RealTimeHeightDeterministicNPDA& first, const automaton::RealTimeHeightDeterministicNPDA& second) const; diff --git a/alib2algo/src/automaton/transform/AutomataUnionEpsilonTransition.cpp b/alib2algo/src/automaton/transform/AutomataUnionEpsilonTransition.cpp index 848135ec65..27cef99813 100644 --- a/alib2algo/src/automaton/transform/AutomataUnionEpsilonTransition.cpp +++ b/alib2algo/src/automaton/transform/AutomataUnionEpsilonTransition.cpp @@ -182,6 +182,11 @@ void AutomataUnionEpsilonTransition::Visit(void*, const automaton::NPDA&, const throw exception::AlibException("Unsupported automaton type NPDA"); } +void AutomataUnionEpsilonTransition::Visit(void*, const automaton::InputDrivenDPDA&, const automaton::InputDrivenDPDA&) const +{ + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void AutomataUnionEpsilonTransition::Visit(void*, const automaton::InputDrivenNPDA&, const automaton::InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); diff --git a/alib2algo/src/automaton/transform/AutomataUnionEpsilonTransition.h b/alib2algo/src/automaton/transform/AutomataUnionEpsilonTransition.h index 855fc5b94d..07a987af14 100644 --- a/alib2algo/src/automaton/transform/AutomataUnionEpsilonTransition.h +++ b/alib2algo/src/automaton/transform/AutomataUnionEpsilonTransition.h @@ -40,6 +40,7 @@ private: void Visit(void* data, const automaton::DPDA& first, const automaton::DPDA& second) const; void Visit(void* data, const automaton::NPDA& first, const automaton::NPDA& second) const; + void Visit(void* data, const automaton::InputDrivenDPDA& first, const automaton::InputDrivenDPDA& second) const; void Visit(void* data, const automaton::InputDrivenNPDA& first, const automaton::InputDrivenNPDA& second) const; void Visit(void* data, const automaton::RealTimeHeightDeterministicDPDA& first, const automaton::RealTimeHeightDeterministicDPDA& second) const; void Visit(void* data, const automaton::RealTimeHeightDeterministicNPDA& first, const automaton::RealTimeHeightDeterministicNPDA& second) const; diff --git a/alib2algo/src/automaton/transform/AutomatonIteration.cpp b/alib2algo/src/automaton/transform/AutomatonIteration.cpp index ad8dc7d4f1..e30f54c1ab 100644 --- a/alib2algo/src/automaton/transform/AutomatonIteration.cpp +++ b/alib2algo/src/automaton/transform/AutomatonIteration.cpp @@ -78,6 +78,11 @@ void AutomatonIteration::Visit(void*, const automaton::NPDA&) const throw exception::AlibException("Unsupported automaton type NPDA"); } +void AutomatonIteration::Visit(void*, const automaton::InputDrivenDPDA&) const +{ + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void AutomatonIteration::Visit(void*, const automaton::InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); diff --git a/alib2algo/src/automaton/transform/AutomatonIteration.h b/alib2algo/src/automaton/transform/AutomatonIteration.h index e19861e088..7df870107e 100644 --- a/alib2algo/src/automaton/transform/AutomatonIteration.h +++ b/alib2algo/src/automaton/transform/AutomatonIteration.h @@ -39,6 +39,7 @@ private: void Visit(void* data, const automaton::DPDA& automaton) const; void Visit(void* data, const automaton::NPDA& automaton) const; + void Visit(void* data, const automaton::InputDrivenDPDA& automaton) const; void Visit(void* data, const automaton::InputDrivenNPDA& automaton) const; void Visit(void* data, const automaton::RealTimeHeightDeterministicDPDA& automaton) const; void Visit(void* data, const automaton::RealTimeHeightDeterministicNPDA& automaton) const; diff --git a/alib2algo/src/automaton/transform/AutomatonIterationEpsilonTransition.cpp b/alib2algo/src/automaton/transform/AutomatonIterationEpsilonTransition.cpp index 6cf3b6a1a9..61eda50e79 100644 --- a/alib2algo/src/automaton/transform/AutomatonIterationEpsilonTransition.cpp +++ b/alib2algo/src/automaton/transform/AutomatonIterationEpsilonTransition.cpp @@ -78,6 +78,11 @@ void AutomatonIterationEpsilonTransition::Visit(void*, const automaton::NPDA&) c throw exception::AlibException("Unsupported automaton type NPDA"); } +void AutomatonIterationEpsilonTransition::Visit(void*, const automaton::InputDrivenDPDA&) const +{ + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void AutomatonIterationEpsilonTransition::Visit(void*, const automaton::InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); diff --git a/alib2algo/src/automaton/transform/AutomatonIterationEpsilonTransition.h b/alib2algo/src/automaton/transform/AutomatonIterationEpsilonTransition.h index 7329e8cfb5..2181c1d6f3 100644 --- a/alib2algo/src/automaton/transform/AutomatonIterationEpsilonTransition.h +++ b/alib2algo/src/automaton/transform/AutomatonIterationEpsilonTransition.h @@ -39,6 +39,7 @@ private: void Visit(void* data, const automaton::DPDA& automaton) const; void Visit(void* data, const automaton::NPDA& automaton) const; + void Visit(void* data, const automaton::InputDrivenDPDA& automaton) const; void Visit(void* data, const automaton::InputDrivenNPDA& automaton) const; void Visit(void* data, const automaton::RealTimeHeightDeterministicDPDA& automaton) const; void Visit(void* data, const automaton::RealTimeHeightDeterministicNPDA& automaton) const; diff --git a/alib2algo/src/automaton/transform/PDAToRHPDA.cpp b/alib2algo/src/automaton/transform/PDAToRHPDA.cpp index 6f5452bcc4..68c0d9efa4 100644 --- a/alib2algo/src/automaton/transform/PDAToRHPDA.cpp +++ b/alib2algo/src/automaton/transform/PDAToRHPDA.cpp @@ -176,6 +176,10 @@ void PDAToRHPDA::Visit(void*, const SinglePopDPDA&) const { throw exception::AlibException("Unsupported automaton type SinglePopDPDA"); } +void PDAToRHPDA::Visit(void*, const InputDrivenDPDA&) const { + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void PDAToRHPDA::Visit(void*, const InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); } diff --git a/alib2algo/src/automaton/transform/PDAToRHPDA.h b/alib2algo/src/automaton/transform/PDAToRHPDA.h index 10fe5ff6bc..d0fa1a715a 100644 --- a/alib2algo/src/automaton/transform/PDAToRHPDA.h +++ b/alib2algo/src/automaton/transform/PDAToRHPDA.h @@ -32,6 +32,7 @@ private: void Visit(void*, const DPDA& automaton) const; void Visit(void*, const SinglePopDPDA& automaton) const; void Visit(void*, const InputDrivenNPDA& automaton) const; + void Visit(void*, const InputDrivenDPDA& automaton) const; void Visit(void*, const VisiblyPushdownDPDA& automaton) const; void Visit(void*, const VisiblyPushdownNPDA& automaton) const; void Visit(void*, const RealTimeHeightDeterministicDPDA& automaton) const; diff --git a/alib2algo/src/automaton/transform/RHPDAToPDA.cpp b/alib2algo/src/automaton/transform/RHPDAToPDA.cpp index d2a1d17901..f5f03a3405 100644 --- a/alib2algo/src/automaton/transform/RHPDAToPDA.cpp +++ b/alib2algo/src/automaton/transform/RHPDAToPDA.cpp @@ -265,6 +265,10 @@ void RHPDAToPDA::Visit(void*, const SinglePopDPDA&) const { throw exception::AlibException("Unsupported automaton type SinglePopDPDA"); } +void RHPDAToPDA::Visit(void*, const InputDrivenDPDA&) const { + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void RHPDAToPDA::Visit(void*, const InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); } diff --git a/alib2algo/src/automaton/transform/RHPDAToPDA.h b/alib2algo/src/automaton/transform/RHPDAToPDA.h index 815fddeff3..ece6eb275c 100644 --- a/alib2algo/src/automaton/transform/RHPDAToPDA.h +++ b/alib2algo/src/automaton/transform/RHPDAToPDA.h @@ -31,6 +31,7 @@ public: private: void Visit(void*, const DPDA& automaton) const; void Visit(void*, const SinglePopDPDA& automaton) const; + void Visit(void*, const InputDrivenDPDA& automaton) const; void Visit(void*, const InputDrivenNPDA& automaton) const; void Visit(void*, const VisiblyPushdownDPDA& automaton) const; void Visit(void*, const VisiblyPushdownNPDA& automaton) const; diff --git a/alib2algo/test-src/automaton/determinize/determinizeTest.cpp b/alib2algo/test-src/automaton/determinize/determinizeTest.cpp index 9330207ebb..b0f106ab18 100644 --- a/alib2algo/test-src/automaton/determinize/determinizeTest.cpp +++ b/alib2algo/test-src/automaton/determinize/determinizeTest.cpp @@ -55,7 +55,7 @@ void determinizeTest::testDeterminizeIDPDA() { automaton.addFinalState(automaton::State(3)); - automaton::DPDA determinized = automaton::determinize::Determinize::determinize(automaton); + automaton::InputDrivenDPDA determinized = automaton::determinize::Determinize::determinize(automaton); CPPUNIT_ASSERT(determinized.getStates().size() == 3); } diff --git a/alib2data/src/XmlApi.cpp b/alib2data/src/XmlApi.cpp index 7d1093b107..30ee8856de 100644 --- a/alib2data/src/XmlApi.cpp +++ b/alib2data/src/XmlApi.cpp @@ -59,6 +59,7 @@ const std::string Names::AUTOMATON_EXTENDED_NFA = "ExtendedNFA"; const std::string Names::AUTOMATON_COMPACT_NFA = "CompactNFA"; const std::string Names::AUTOMATON_DPDA = "DPDA"; const std::string Names::AUTOMATON_SINGLE_POP_DPDA = "SinglePopDPDA"; +const std::string Names::AUTOMATON_INPUT_DRIVEN_DPDA = "InputDrivenDPDA"; const std::string Names::AUTOMATON_INPUT_DRIVEN_NPDA = "InputDrivenNPDA"; const std::string Names::AUTOMATON_VISIBLY_PUSHDOWN_DPDA = "VisiblyPushdownDPDA"; const std::string Names::AUTOMATON_VISIBLY_PUSHDOWN_NPDA = "VisiblyPushdownNPDA"; @@ -460,6 +461,18 @@ void xmlApi<automaton::SinglePopDPDA>::compose(std::list<sax::Token>& output, co ToXMLComposers::automatonComposer.compose(output, data); } +automaton::InputDrivenDPDA xmlApi<automaton::InputDrivenDPDA>::parse(std::list<sax::Token>& input) { + return FromXMLParsers::automatonParser.parseInputDrivenDPDA(input); +} + +bool xmlApi<automaton::InputDrivenDPDA>::first(const std::list<sax::Token>& input) { + return sax::FromXMLParserHelper::isToken(input, sax::Token::TokenType::START_ELEMENT, Names::AUTOMATON_INPUT_DRIVEN_DPDA); +} + +void xmlApi<automaton::InputDrivenDPDA>::compose(std::list<sax::Token>& output, const automaton::InputDrivenDPDA& data) { + ToXMLComposers::automatonComposer.compose(output, data); +} + automaton::InputDrivenNPDA xmlApi<automaton::InputDrivenNPDA>::parse(std::list<sax::Token>& input) { return FromXMLParsers::automatonParser.parseInputDrivenNPDA(input); } @@ -1145,6 +1158,10 @@ void ToXMLComposers::Visit(void* data, const automaton::SinglePopDPDA& automaton xmlApi<automaton::SinglePopDPDA>::compose(*((std::list<sax::Token>*) data), automaton); } +void ToXMLComposers::Visit(void* data, const automaton::InputDrivenDPDA& automaton) const { + xmlApi<automaton::InputDrivenDPDA>::compose(*((std::list<sax::Token>*) data), automaton); +} + void ToXMLComposers::Visit(void* data, const automaton::InputDrivenNPDA& automaton) const { xmlApi<automaton::InputDrivenNPDA>::compose(*((std::list<sax::Token>*) data), automaton); } diff --git a/alib2data/src/XmlApi.hpp b/alib2data/src/XmlApi.hpp index ceda78aafa..65e8d82ab7 100644 --- a/alib2data/src/XmlApi.hpp +++ b/alib2data/src/XmlApi.hpp @@ -60,6 +60,7 @@ public: const static std::string AUTOMATON_COMPACT_NFA; const static std::string AUTOMATON_DPDA; const static std::string AUTOMATON_SINGLE_POP_DPDA; + const static std::string AUTOMATON_INPUT_DRIVEN_DPDA; const static std::string AUTOMATON_INPUT_DRIVEN_NPDA; const static std::string AUTOMATON_VISIBLY_PUSHDOWN_DPDA; const static std::string AUTOMATON_VISIBLY_PUSHDOWN_NPDA; @@ -356,6 +357,13 @@ struct xmlApi<automaton::SinglePopDPDA> { static void compose(std::list<sax::Token>& output, const automaton::SinglePopDPDA& data); }; +template<> +struct xmlApi<automaton::InputDrivenDPDA> { + static automaton::InputDrivenDPDA parse(std::list<sax::Token>& input); + static bool first(const std::list<sax::Token>& input); + static void compose(std::list<sax::Token>& output, const automaton::InputDrivenDPDA& data); +}; + template<> struct xmlApi<automaton::InputDrivenNPDA> { static automaton::InputDrivenNPDA parse(std::list<sax::Token>& input); @@ -756,6 +764,7 @@ class ToXMLComposers : public VisitableObjectBase::const_visitor_type { void Visit(void*, const automaton::CompactNFA& automaton) const; void Visit(void*, const automaton::DPDA& automaton) const; void Visit(void*, const automaton::SinglePopDPDA& automaton) const; + void Visit(void*, const automaton::InputDrivenDPDA& automaton) const; void Visit(void*, const automaton::InputDrivenNPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownDPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownNPDA& automaton) const; diff --git a/alib2data/src/automaton/AutomatonBase.h b/alib2data/src/automaton/AutomatonBase.h index 1b3dd4fbdc..088b3b2d24 100644 --- a/alib2data/src/automaton/AutomatonBase.h +++ b/alib2data/src/automaton/AutomatonBase.h @@ -17,7 +17,7 @@ namespace automaton { class AutomatonBase; typedef std::acceptor_base<AutomatonBase, - automaton::DFA, automaton::NFA, automaton::MultiInitialStateNFA, automaton::EpsilonNFA, automaton::CompactNFA, automaton::ExtendedNFA, automaton::DPDA, automaton::SinglePopDPDA, automaton::InputDrivenNPDA, automaton::VisiblyPushdownDPDA, automaton::VisiblyPushdownNPDA, automaton::RealTimeHeightDeterministicDPDA, automaton::RealTimeHeightDeterministicNPDA, automaton::NPDA, automaton::SinglePopNPDA, automaton::OneTapeDTM + automaton::DFA, automaton::NFA, automaton::MultiInitialStateNFA, automaton::EpsilonNFA, automaton::CompactNFA, automaton::ExtendedNFA, automaton::DPDA, automaton::SinglePopDPDA, automaton::InputDrivenDPDA, automaton::VisiblyPushdownDPDA, automaton::RealTimeHeightDeterministicDPDA, automaton::NPDA, automaton::SinglePopNPDA, automaton::InputDrivenNPDA, automaton::VisiblyPushdownNPDA, automaton::RealTimeHeightDeterministicNPDA, automaton::OneTapeDTM > VisitableAutomatonBase; /** @@ -43,6 +43,10 @@ class VisitableConstFSMBase : public VisitableAutomatonBase::const_visitor_type throw exception::AlibException("Unsupported automaton type SinglePopDPDA"); } + void Visit(void*, const InputDrivenDPDA&) const { + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); + } + void Visit(void*, const InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); } @@ -122,6 +126,10 @@ class VisitableConstNondeterministicAutomatonBase : public VisitableAutomatonBas throw exception::AlibException("Unsupported automaton type SinglePopDPDA"); } + void Visit(void*, const InputDrivenDPDA&) const { + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); + } + void Visit(void*, const VisiblyPushdownDPDA&) const { throw exception::AlibException("Unsupported automaton type VisiblyPushdownDPDA"); } diff --git a/alib2data/src/automaton/AutomatonFeatures.h b/alib2data/src/automaton/AutomatonFeatures.h index ec75bd0140..9c9bbdd25d 100644 --- a/alib2data/src/automaton/AutomatonFeatures.h +++ b/alib2data/src/automaton/AutomatonFeatures.h @@ -19,6 +19,7 @@ enum class FEATURES { EXTENDED_NFA, DPDA, SINGLE_POP_DPDA, + INPUT_DRIVEN_DPDA, INPUT_DRIVEN_NPDA, VISIBLY_PUSHDOWN_DPDA, VISIBLY_PUSHDOWN_NPDA, diff --git a/alib2data/src/automaton/AutomatonFromXMLParser.cpp b/alib2data/src/automaton/AutomatonFromXMLParser.cpp index 55c70aeef4..4434411026 100644 --- a/alib2data/src/automaton/AutomatonFromXMLParser.cpp +++ b/alib2data/src/automaton/AutomatonFromXMLParser.cpp @@ -16,7 +16,7 @@ namespace automaton { Automaton AutomatonFromXMLParser::parseAutomaton(std::list<sax::Token> &input) const { - return parseAutomaton(input, std::set<FEATURES>({FEATURES::EPSILON_NFA, FEATURES::MULTI_INITIAL_STATE_NFA, FEATURES::NFA, FEATURES::DFA, FEATURES::COMPACT_NFA, FEATURES::EXTENDED_NFA, FEATURES::DPDA, FEATURES::SINGLE_POP_DPDA, FEATURES::INPUT_DRIVEN_NPDA, FEATURES::VISIBLY_PUSHDOWN_DPDA, FEATURES::VISIBLY_PUSHDOWN_NPDA, FEATURES::REAL_TIME_HEIGHT_DETERMINISTIC_DPDA, FEATURES::REAL_TIME_HEIGHT_DETERMINISTIC_NPDA, FEATURES::NPDA, FEATURES::SINGLE_POP_NPDA, FEATURES::ONE_TAPE_DTM})); + return parseAutomaton(input, std::set<FEATURES>({FEATURES::EPSILON_NFA, FEATURES::MULTI_INITIAL_STATE_NFA, FEATURES::NFA, FEATURES::DFA, FEATURES::COMPACT_NFA, FEATURES::EXTENDED_NFA, FEATURES::DPDA, FEATURES::SINGLE_POP_DPDA, FEATURES::INPUT_DRIVEN_DPDA, FEATURES::INPUT_DRIVEN_NPDA, FEATURES::VISIBLY_PUSHDOWN_DPDA, FEATURES::VISIBLY_PUSHDOWN_NPDA, FEATURES::REAL_TIME_HEIGHT_DETERMINISTIC_DPDA, FEATURES::REAL_TIME_HEIGHT_DETERMINISTIC_NPDA, FEATURES::NPDA, FEATURES::SINGLE_POP_NPDA, FEATURES::ONE_TAPE_DTM})); } Automaton AutomatonFromXMLParser::parseAutomaton(std::list<sax::Token>& input, const std::set<FEATURES>& features) const { @@ -44,6 +44,9 @@ Automaton AutomatonFromXMLParser::parseAutomaton(std::list<sax::Token>& input, c } else if(alib::xmlApi<SinglePopDPDA>::first(input)) { if(!features.count(FEATURES::SINGLE_POP_DPDA)) throw exception::AlibException(); return Automaton(parseSinglePopDPDA(input)); + } else if(alib::xmlApi<InputDrivenDPDA>::first(input)) { + if(!features.count(FEATURES::INPUT_DRIVEN_DPDA)) throw exception::AlibException(); + return Automaton(parseInputDrivenDPDA(input)); } else if(alib::xmlApi<InputDrivenNPDA>::first(input)) { if(!features.count(FEATURES::INPUT_DRIVEN_NPDA)) throw exception::AlibException(); return Automaton(parseInputDrivenNPDA(input)); @@ -69,11 +72,11 @@ Automaton AutomatonFromXMLParser::parseAutomaton(std::list<sax::Token>& input, c if(!features.count(FEATURES::ONE_TAPE_DTM)) throw exception::AlibException(); return Automaton(parseOneTapeDTM(input)); } else - throw sax::ParserException(sax::Token("Automaton / EpsilonNFA / NFA / DFA / CompactNFA / ExtendedNFA / DPDA / SinglePopDPDA / InputDrivenNPDA / VisiblyPushdownDPDA / VisiblyPushdownNPDA / RealTimeHeightDeterministicDPDA / RealTimeHeightDeterministicNPDA / NPDA / SinglePopNPDA / OneTapeDTM", sax::Token::TokenType::START_ELEMENT), input.front()); + throw sax::ParserException(sax::Token("Automaton / EpsilonNFA / NFA / DFA / CompactNFA / ExtendedNFA / DPDA / SinglePopDPDA / InputDrivenDPDA / InputDrivenNPDA / VisiblyPushdownDPDA / VisiblyPushdownNPDA / RealTimeHeightDeterministicDPDA / RealTimeHeightDeterministicNPDA / NPDA / SinglePopNPDA / OneTapeDTM", sax::Token::TokenType::START_ELEMENT), input.front()); } bool AutomatonFromXMLParser::first(const std::list<sax::Token>& input) const { - if(alib::xmlApi<EpsilonNFA>::first(input) || alib::xmlApi<NFA>::first(input) || alib::xmlApi<DFA>::first(input) || alib::xmlApi<CompactNFA>::first(input) || alib::xmlApi<ExtendedNFA>::first(input) || alib::xmlApi<DPDA>::first(input) || alib::xmlApi<SinglePopDPDA>::first(input) || alib::xmlApi<InputDrivenNPDA>::first(input) || alib::xmlApi<VisiblyPushdownDPDA>::first(input) || alib::xmlApi<VisiblyPushdownNPDA>::first(input) || alib::xmlApi<RealTimeHeightDeterministicDPDA>::first(input) || alib::xmlApi<RealTimeHeightDeterministicNPDA>::first(input) || alib::xmlApi<NPDA>::first(input) || alib::xmlApi<SinglePopNPDA>::first(input) || alib::xmlApi<OneTapeDTM>::first(input)) { + if(alib::xmlApi<EpsilonNFA>::first(input) || alib::xmlApi<NFA>::first(input) || alib::xmlApi<DFA>::first(input) || alib::xmlApi<CompactNFA>::first(input) || alib::xmlApi<ExtendedNFA>::first(input) || alib::xmlApi<DPDA>::first(input) || alib::xmlApi<SinglePopDPDA>::first(input) || alib::xmlApi<InputDrivenDPDA>::first(input) || alib::xmlApi<InputDrivenNPDA>::first(input) || alib::xmlApi<VisiblyPushdownDPDA>::first(input) || alib::xmlApi<VisiblyPushdownNPDA>::first(input) || alib::xmlApi<RealTimeHeightDeterministicDPDA>::first(input) || alib::xmlApi<RealTimeHeightDeterministicNPDA>::first(input) || alib::xmlApi<NPDA>::first(input) || alib::xmlApi<SinglePopNPDA>::first(input) || alib::xmlApi<OneTapeDTM>::first(input)) { return true; } else { return false; @@ -250,6 +253,30 @@ SinglePopDPDA AutomatonFromXMLParser::parseSinglePopDPDA(std::list<sax::Token>& return automaton; } +InputDrivenDPDA AutomatonFromXMLParser::parseInputDrivenDPDA(std::list<sax::Token>& input) const { + popToken(input, sax::Token::TokenType::START_ELEMENT, alib::Names::AUTOMATON_INPUT_DRIVEN_DPDA); + + std::set<State> states = parseStates(input); + std::set<alphabet::Symbol> inputSymbols = parseInputAlphabet(input); + std::set<alphabet::Symbol> stackSymbols = parseStackAlphabet(input); + State initialState = parseInitialState(input); + alphabet::Symbol initialStackSymbol = parseInitialStackSymbol(input); + std::set<State> finalStates = parseFinalStates(input); + + InputDrivenDPDA automaton(initialState, initialStackSymbol); + automaton.setStates(states); + automaton.setInputAlphabet(inputSymbols); + automaton.setStackAlphabet(stackSymbols); + automaton.setFinalStates(finalStates); + + parseInputToPushdownStoreOperation(input, automaton); + parseTransitions<InputDrivenDPDA>(input, automaton); + + popToken(input, sax::Token::TokenType::END_ELEMENT, alib::Names::AUTOMATON_INPUT_DRIVEN_DPDA); + + return automaton; +} + InputDrivenNPDA AutomatonFromXMLParser::parseInputDrivenNPDA(std::list<sax::Token>& input) const { popToken(input, sax::Token::TokenType::START_ELEMENT, alib::Names::AUTOMATON_INPUT_DRIVEN_NPDA); @@ -577,6 +604,23 @@ alphabet::Symbol AutomatonFromXMLParser::parseBottomOfTheStackSymbol(std::list<s return blank; } +void AutomatonFromXMLParser::parseInputToPushdownStoreOperation(std::list<sax::Token>& input, automaton::InputDrivenDPDA& automaton) const { + popToken(input, sax::Token::TokenType::START_ELEMENT, "inputToPushdownStoreOperations"); + while (isTokenType(input, sax::Token::TokenType::START_ELEMENT)) { + popToken(input, sax::Token::TokenType::START_ELEMENT, "operation"); + + alphabet::Symbol inputSymbol(alib::xmlApi<alphabet::Symbol>::parse(input)); + + std::vector<alphabet::Symbol> pop = parseTransitionPop(input); + std::vector<alphabet::Symbol> push = parseTransitionPush(input); + + automaton.setPushdownStoreOperation(inputSymbol, pop, push); + + popToken(input, sax::Token::TokenType::END_ELEMENT, "operation"); + } + popToken(input, sax::Token::TokenType::END_ELEMENT, "inputToPushdownStoreOperations"); +} + void AutomatonFromXMLParser::parseInputToPushdownStoreOperation(std::list<sax::Token>& input, automaton::InputDrivenNPDA& automaton) const { popToken(input, sax::Token::TokenType::START_ELEMENT, "inputToPushdownStoreOperations"); while (isTokenType(input, sax::Token::TokenType::START_ELEMENT)) { @@ -678,6 +722,16 @@ void AutomatonFromXMLParser::parseTransition(std::list<sax::Token>& input, Singl automaton.addTransition(from, inputSymbol, pop, to, push); } +void AutomatonFromXMLParser::parseTransition(std::list<sax::Token>& input, InputDrivenDPDA& automaton) const { + popToken(input, sax::Token::TokenType::START_ELEMENT, "transition"); + State from = parseTransitionFrom(input); + alphabet::Symbol inputSymbol = parseTransitionInputSymbol(input); + State to = parseTransitionTo(input); + popToken(input, sax::Token::TokenType::END_ELEMENT, "transition"); + + automaton.addTransition(from, inputSymbol, to); +} + void AutomatonFromXMLParser::parseTransition(std::list<sax::Token>& input, InputDrivenNPDA& automaton) const { popToken(input, sax::Token::TokenType::START_ELEMENT, "transition"); State from = parseTransitionFrom(input); diff --git a/alib2data/src/automaton/AutomatonFromXMLParser.h b/alib2data/src/automaton/AutomatonFromXMLParser.h index 22dda04d42..c032da9819 100644 --- a/alib2data/src/automaton/AutomatonFromXMLParser.h +++ b/alib2data/src/automaton/AutomatonFromXMLParser.h @@ -19,6 +19,7 @@ #include "FSM/ExtendedNFA.h" #include "PDA/DPDA.h" #include "PDA/SinglePopDPDA.h" +#include "PDA/InputDrivenDPDA.h" #include "PDA/InputDrivenNPDA.h" #include "PDA/VisiblyPushdownDPDA.h" #include "PDA/VisiblyPushdownNPDA.h" @@ -61,6 +62,7 @@ class AutomatonFromXMLParser : public sax::FromXMLParserHelper { std::set<State> parseFinalStates(std::list<sax::Token> &input) const; alphabet::Symbol parseBlankSymbol(std::list<sax::Token> &input) const; alphabet::Symbol parseBottomOfTheStackSymbol(std::list<sax::Token> &input) const; + void parseInputToPushdownStoreOperation(std::list<sax::Token>& input, automaton::InputDrivenDPDA& automaton) const; void parseInputToPushdownStoreOperation(std::list<sax::Token>& input, automaton::InputDrivenNPDA& automaton) const; State parseTransitionFrom(std::list<sax::Token>& input) const; @@ -82,6 +84,7 @@ class AutomatonFromXMLParser : public sax::FromXMLParserHelper { void parseTransition(std::list<sax::Token>& input, ExtendedNFA& automaton) const; void parseTransition(std::list<sax::Token>& input, DPDA& automaton) const; void parseTransition(std::list<sax::Token>& input, SinglePopDPDA& automaton) const; + void parseTransition(std::list<sax::Token>& input, InputDrivenDPDA& automaton) const; void parseTransition(std::list<sax::Token>& input, InputDrivenNPDA& automaton) const; void parseTransition(std::list<sax::Token>& input, VisiblyPushdownDPDA& automaton) const; void parseTransition(std::list<sax::Token>& input, VisiblyPushdownNPDA& automaton) const; @@ -116,6 +119,7 @@ class AutomatonFromXMLParser : public sax::FromXMLParserHelper { DPDA parseDPDA(std::list<sax::Token>& input) const; SinglePopDPDA parseSinglePopDPDA(std::list<sax::Token>& input) const; InputDrivenNPDA parseInputDrivenNPDA(std::list<sax::Token>& input) const; + InputDrivenDPDA parseInputDrivenDPDA(std::list<sax::Token>& input) const; VisiblyPushdownDPDA parseVisiblyPushdownDPDA(std::list<sax::Token>& input) const; VisiblyPushdownNPDA parseVisiblyPushdownNPDA(std::list<sax::Token>& input) const; RealTimeHeightDeterministicDPDA parseRealTimeHeightDeterministicDPDA(std::list<sax::Token>& input) const; diff --git a/alib2data/src/automaton/AutomatonToXMLComposer.cpp b/alib2data/src/automaton/AutomatonToXMLComposer.cpp index 017a8ec9c0..b4cd57b1ff 100644 --- a/alib2data/src/automaton/AutomatonToXMLComposer.cpp +++ b/alib2data/src/automaton/AutomatonToXMLComposer.cpp @@ -116,6 +116,21 @@ void AutomatonToXMLComposer::composeBottomOfTheStackSymbol(std::list<sax::Token> out.push_back(sax::Token("bottomOfTheStackSymbol", sax::Token::TokenType::END_ELEMENT)); } +void AutomatonToXMLComposer::composeInputToPushdownStoreOperation(std::list<sax::Token>& out, const automaton::InputDrivenDPDA& automaton) const { + out.push_back(sax::Token("inputToPushdownStoreOperations", sax::Token::TokenType::START_ELEMENT)); + for(const auto& pushdownStoreOperation : automaton.getPushdownStoreOperations()) { + out.push_back(sax::Token("operation", sax::Token::TokenType::START_ELEMENT)); + + alib::xmlApi<alphabet::Symbol>::compose(out, pushdownStoreOperation.first); + + composeTransitionPop(out, pushdownStoreOperation.second.first); + composeTransitionPush(out, pushdownStoreOperation.second.second); + + out.push_back(sax::Token("operation", sax::Token::TokenType::END_ELEMENT)); + } + out.push_back(sax::Token("inputToPushdownStoreOperations", sax::Token::TokenType::END_ELEMENT)); +} + void AutomatonToXMLComposer::composeInputToPushdownStoreOperation(std::list<sax::Token>& out, const automaton::InputDrivenNPDA& automaton) const { out.push_back(sax::Token("inputToPushdownStoreOperations", sax::Token::TokenType::START_ELEMENT)); for(const auto& pushdownStoreOperation : automaton.getPushdownStoreOperations()) { @@ -265,6 +280,21 @@ void AutomatonToXMLComposer::composeTransitions(std::list<sax::Token>& out, cons out.push_back(sax::Token("transitions", sax::Token::TokenType::END_ELEMENT)); } +void AutomatonToXMLComposer::composeTransitions(std::list<sax::Token>& out, const InputDrivenDPDA& automaton) const { + out.push_back(sax::Token("transitions", sax::Token::TokenType::START_ELEMENT)); + for(const auto& transition : automaton.getTransitions()) { + out.push_back(sax::Token("transition", sax::Token::TokenType::START_ELEMENT)); + + composeTransitionFrom(out, transition.first.first); + composeTransitionInputSymbol(out, transition.first.second); + composeTransitionTo(out, transition.second); + + out.push_back(sax::Token("transition", sax::Token::TokenType::END_ELEMENT)); + } + + out.push_back(sax::Token("transitions", sax::Token::TokenType::END_ELEMENT)); +} + void AutomatonToXMLComposer::composeTransitions(std::list<sax::Token>& out, const InputDrivenNPDA& automaton) const { out.push_back(sax::Token("transitions", sax::Token::TokenType::START_ELEMENT)); for(const auto& transition : automaton.getTransitions()) { @@ -685,6 +715,21 @@ void AutomatonToXMLComposer::compose(std::list<sax::Token>& out, const SinglePop out.push_back(sax::Token(alib::Names::AUTOMATON_SINGLE_POP_DPDA, sax::Token::TokenType::END_ELEMENT)); } +void AutomatonToXMLComposer::compose(std::list<sax::Token>& out, const InputDrivenDPDA& automaton) const { + out.push_back(sax::Token(alib::Names::AUTOMATON_INPUT_DRIVEN_DPDA, sax::Token::TokenType::START_ELEMENT)); + + composeStates(out, automaton.getStates()); + composeInputAlphabet(out, automaton.getInputAlphabet()); + composeStackAlphabet(out, automaton.getStackAlphabet()); + composeInitialState(out, automaton.getInitialState()); + composeInitialStackSymbol(out, automaton.getInitialSymbol()); + composeFinalStates(out, automaton.getFinalStates()); + composeInputToPushdownStoreOperation(out, automaton); + composeTransitions(out, automaton); + + out.push_back(sax::Token(alib::Names::AUTOMATON_INPUT_DRIVEN_DPDA, sax::Token::TokenType::END_ELEMENT)); +} + void AutomatonToXMLComposer::compose(std::list<sax::Token>& out, const InputDrivenNPDA& automaton) const { out.push_back(sax::Token(alib::Names::AUTOMATON_INPUT_DRIVEN_NPDA, sax::Token::TokenType::START_ELEMENT)); diff --git a/alib2data/src/automaton/AutomatonToXMLComposer.h b/alib2data/src/automaton/AutomatonToXMLComposer.h index 7da4b6aeda..34a2eaa9a1 100644 --- a/alib2data/src/automaton/AutomatonToXMLComposer.h +++ b/alib2data/src/automaton/AutomatonToXMLComposer.h @@ -17,6 +17,7 @@ #include "FSM/DFA.h" #include "FSM/CompactNFA.h" #include "FSM/ExtendedNFA.h" +#include "PDA/InputDrivenDPDA.h" #include "PDA/InputDrivenNPDA.h" #include "PDA/VisiblyPushdownDPDA.h" #include "PDA/VisiblyPushdownNPDA.h" @@ -54,6 +55,7 @@ class AutomatonToXMLComposer { void composeTapeAlphabet(std::list<sax::Token>&, const std::set<alphabet::Symbol>& symbols) const; void composeBlankSymbol(std::list<sax::Token>&, const alphabet::Symbol& symbol) const; void composeBottomOfTheStackSymbol(std::list<sax::Token>&, const alphabet::Symbol& symbol) const; + void composeInputToPushdownStoreOperation(std::list<sax::Token>&, const automaton::InputDrivenDPDA& automaton) const; void composeInputToPushdownStoreOperation(std::list<sax::Token>&, const automaton::InputDrivenNPDA& automaton) const; void composeTransitions(std::list<sax::Token>&, const EpsilonNFA& automaton) const; @@ -64,6 +66,7 @@ class AutomatonToXMLComposer { void composeTransitions(std::list<sax::Token>&, const DFA& automaton) const; void composeTransitions(std::list<sax::Token>&, const DPDA& automaton) const; void composeTransitions(std::list<sax::Token>&, const SinglePopDPDA& automaton) const; + void composeTransitions(std::list<sax::Token>&, const InputDrivenDPDA& automaton) const; void composeTransitions(std::list<sax::Token>&, const InputDrivenNPDA& automaton) const; void composeTransitions(std::list<sax::Token>&, const VisiblyPushdownDPDA& automaton) const; void composeTransitions(std::list<sax::Token>&, const VisiblyPushdownNPDA& automaton) const; @@ -104,6 +107,7 @@ class AutomatonToXMLComposer { void compose(std::list<sax::Token>& output, const CompactNFA& automaton) const; void compose(std::list<sax::Token>& output, const DPDA& automaton) const; void compose(std::list<sax::Token>& output, const SinglePopDPDA& automaton) const; + void compose(std::list<sax::Token>& output, const InputDrivenDPDA& automaton) const; void compose(std::list<sax::Token>& output, const InputDrivenNPDA& automaton) const; void compose(std::list<sax::Token>& output, const VisiblyPushdownNPDA& automaton) const; void compose(std::list<sax::Token>& output, const VisiblyPushdownDPDA& automaton) const; diff --git a/alib2data/src/automaton/FSM/DFA.cpp b/alib2data/src/automaton/FSM/DFA.cpp index 7d96daf4b8..cffffdd7b9 100644 --- a/alib2data/src/automaton/FSM/DFA.cpp +++ b/alib2data/src/automaton/FSM/DFA.cpp @@ -35,8 +35,8 @@ bool DFA::removeState(const State& state) { throw AutomatonException("State \"" + (std::string) state.getName() + "\" is final state."); } - for (std::map<std::pair<State, alphabet::Symbol>, State>::const_iterator t = transitions.begin(); t != transitions.end(); t++) { - if (t->first.first == state || t->second == state) + for (const std::pair<std::pair<State, alphabet::Symbol>, State>& t : transitions) { + if (t.first.first == state || t.second == state) throw AutomatonException("State \"" + (std::string) state.getName() + "\" is used in transition."); } @@ -44,9 +44,8 @@ bool DFA::removeState(const State& state) { } bool DFA::removeInputSymbol(const alphabet::Symbol& symbol) { - for (std::map<std::pair<State, alphabet::Symbol>, State>::const_iterator transition = transitions.begin(); transition != transitions.end(); - transition++) { - if (transition->first.second == symbol) + for (const std::pair<std::pair<State, alphabet::Symbol>, State>& transition : transitions) { + if (transition.first.second == symbol) throw AutomatonException("Input symbol \"" + (std::string) symbol + "\" is used."); } @@ -65,7 +64,7 @@ bool DFA::addTransition(const State& from, const alphabet::Symbol& input, const throw AutomatonException("State \"" + (std::string) to.getName() + "\" doesn't exist."); std::pair<State, alphabet::Symbol> key = std::make_pair(from, input); - + if (transitions.find(key) != transitions.end()) { if(transitions.find(key)->second == to) return false; @@ -74,14 +73,14 @@ bool DFA::addTransition(const State& from, const alphabet::Symbol& input, const "Transition from this state and symbol already exists (\"" + (std::string) from.getName() + "\", \"" + (std::string) input + "\") -> \"" + (std::string) to.getName() + "\"."); } - + transitions.insert(std::make_pair(key, to)); return true; } bool DFA::removeTransition(const State& from, const alphabet::Symbol& input, const State& to) { std::pair<State, alphabet::Symbol> key = std::make_pair(from, input); - + if (transitions.find(key) == transitions.end()) return false; @@ -103,10 +102,9 @@ std::map<std::pair<State, alphabet::Symbol>, State> DFA::getTransitionsFromState throw AutomatonException("State \"" + (std::string) from.getName() + "\" doesn't exist"); std::map<std::pair<State, alphabet::Symbol>, State> transitionsFromState; - for (std::map<std::pair<State, alphabet::Symbol>, State>::const_iterator transition = transitions.begin(); transition != transitions.end(); - transition++) { - if (transition->first.first == from) { - transitionsFromState.insert(std::make_pair(transition->first, transition->second)); + for (const std::pair<std::pair<State, alphabet::Symbol>, State>& transition : transitions) { + if (transition.first.first == from) { + transitionsFromState.insert(transition); } } @@ -118,10 +116,9 @@ std::map<std::pair<State, alphabet::Symbol>, State> DFA::getTransitionsToState(c throw AutomatonException("State \"" + (std::string) to.getName() + "\" doesn't exist"); std::map<std::pair<State, alphabet::Symbol>, State> transitionsToState; - for (std::map<std::pair<State, alphabet::Symbol>, State>::const_iterator transition = transitions.begin(); transition != transitions.end(); - transition++) { - if (transition->second == to) { - transitionsToState.insert(std::make_pair(transition->first, transition->second)); + for (const std::pair<std::pair<State, alphabet::Symbol>, State>& transition : transitions) { + if (transition.second == to) { + transitionsToState.insert(transition); } } diff --git a/alib2data/src/automaton/FSM/FiniteAutomatonToStringComposer.cpp b/alib2data/src/automaton/FSM/FiniteAutomatonToStringComposer.cpp index f9456785c9..7fd35170a7 100644 --- a/alib2data/src/automaton/FSM/FiniteAutomatonToStringComposer.cpp +++ b/alib2data/src/automaton/FSM/FiniteAutomatonToStringComposer.cpp @@ -225,6 +225,10 @@ void FiniteAutomatonToStringComposer::Visit(void*, const SinglePopDPDA&) const { throw exception::AlibException(); } +void FiniteAutomatonToStringComposer::Visit(void*, const InputDrivenDPDA&) const { + throw exception::AlibException(); +} + void FiniteAutomatonToStringComposer::Visit(void*, const InputDrivenNPDA&) const { throw exception::AlibException(); } diff --git a/alib2data/src/automaton/FSM/FiniteAutomatonToStringComposer.h b/alib2data/src/automaton/FSM/FiniteAutomatonToStringComposer.h index e16b9dd80f..394f801137 100644 --- a/alib2data/src/automaton/FSM/FiniteAutomatonToStringComposer.h +++ b/alib2data/src/automaton/FSM/FiniteAutomatonToStringComposer.h @@ -26,6 +26,7 @@ class FiniteAutomatonToStringComposer : public VisitableAutomatonBase::const_vis void Visit(void*, const CompactNFA& automaton) const; void Visit(void*, const DPDA& automaton) const; void Visit(void*, const SinglePopDPDA& automaton) const; + void Visit(void*, const InputDrivenDPDA& automaton) const; void Visit(void*, const InputDrivenNPDA& automaton) const; void Visit(void*, const VisiblyPushdownDPDA& automaton) const; void Visit(void*, const VisiblyPushdownNPDA& automaton) const; diff --git a/alib2data/src/automaton/PDA/InputDrivenDPDA.cpp b/alib2data/src/automaton/PDA/InputDrivenDPDA.cpp new file mode 100644 index 0000000000..1742413448 --- /dev/null +++ b/alib2data/src/automaton/PDA/InputDrivenDPDA.cpp @@ -0,0 +1,213 @@ +/* + * InputDrivenDPDA.cpp + * + * Created on: Mar 25, 2013 + * Author: Jan Travnicek + */ + +#include "InputDrivenDPDA.h" +#include "../AutomatonException.h" +#include <ostream> +#include <sstream> +#include <algorithm> + +namespace automaton { + +InputDrivenDPDA::InputDrivenDPDA(const State& initialState, const alphabet::Symbol& initialPushdownSymbol) : SingleInitialSymbolPushdownStoreAlphabet(initialPushdownSymbol), SingleInitialState(initialState) { + +} + +AutomatonBase* InputDrivenDPDA::clone() const { + return new InputDrivenDPDA(*this); +} + +AutomatonBase* InputDrivenDPDA::plunder() && { + return new InputDrivenDPDA(std::move(*this)); +} + +bool InputDrivenDPDA::removeState(const State& state) { + if (initialState == state) { + throw AutomatonException("State \"" + (std::string) state.getName() + "\" is initial state."); + } + + if (finalStates.find(state) != finalStates.end()) { + throw AutomatonException("State \"" + (std::string) state.getName() + "\" is final state."); + } + + for (const std::pair<std::pair<State, alphabet::Symbol>, State>& t : transitions) { + if (t.first.first == state || t.second == state) + throw AutomatonException("State \"" + (std::string) state.getName() + "\" is used in transition."); + } + + return states.erase(state); +} + +bool InputDrivenDPDA::removeInputSymbol(const alphabet::Symbol& symbol) { + for (const std::pair<std::pair<State, alphabet::Symbol>, State>& transition : transitions) { + if (transition.first.second == symbol) + throw AutomatonException("Input symbol \"" + (std::string) symbol + "\" is used."); + } + + return inputAlphabet.erase(symbol); +} + +bool InputDrivenDPDA::removeStackSymbol(const alphabet::Symbol& symbol) { + for (const auto& pushdownStoreOperation : inputSymbolToPushdownStoreOperation) { + if (std::find(pushdownStoreOperation.second.first.begin(), pushdownStoreOperation.second.first.end(), symbol) != pushdownStoreOperation.second.first.end()) + throw AutomatonException("Stack symbol \"" + (std::string) symbol + "\" is used in transition."); + if (std::find(pushdownStoreOperation.second.second.begin(), pushdownStoreOperation.second.second.end(), symbol) != pushdownStoreOperation.second.second.end()) + throw AutomatonException("Stack symbol \"" + (std::string) symbol + "\" is used in transition."); + } + + if(initialSymbol == symbol) { + throw AutomatonException("Stack symbol \"" + (std::string) symbol + "\" is start symbol."); + } + + return stackAlphabet.erase(symbol); +} + +bool InputDrivenDPDA::setPushdownStoreOperation(const alphabet::Symbol& input, const std::vector<alphabet::Symbol>& pop, const std::vector<alphabet::Symbol>& push) { + if (inputAlphabet.find(input) == inputAlphabet.end()) { + throw AutomatonException("Input symbol \"" + (std::string) input + "\" doesn't exist."); + } + + for(const alphabet::Symbol& popSymbol : pop) { + if (stackAlphabet.find(popSymbol) == stackAlphabet.end()) { + throw AutomatonException("Stack symbol \"" + (std::string) popSymbol + "\" doesn't exist."); + } + } + + for(const alphabet::Symbol& pushSymbol : push) { + if (stackAlphabet.find(pushSymbol) == stackAlphabet.end()) { + throw AutomatonException("Stack symbol \"" + (std::string) pushSymbol + "\" doesn't exist."); + } + } + + return inputSymbolToPushdownStoreOperation.insert(std::make_pair(input, std::make_pair(pop, push))).second; +} + +void InputDrivenDPDA::setPushdownStoreOperations(const std::map<alphabet::Symbol, std::pair<std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol>>>& operations) { + if(operations.size() && inputAlphabet.size() && std::equal(key_begin(operations), key_end(operations), inputAlphabet.begin())) + for(const auto& operation : operations) { + setPushdownStoreOperation(operation.first, operation.second.first, operation.second.second); + } + else + throw AutomatonException("All pushdown store operations of InputDrivenDPDA must be set"); +} + +bool InputDrivenDPDA::clearPushdownStoreOperation(const alphabet::Symbol& input) { + for (const std::pair<std::pair<State, alphabet::Symbol>, State>& transition : transitions) { + if (transition.first.second == input) + throw AutomatonException("Input symbol \"" + (std::string) input + "\" is used."); + } + + return inputSymbolToPushdownStoreOperation.erase(input); +} + +const std::map<alphabet::Symbol, std::pair<std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol>>>& InputDrivenDPDA::getPushdownStoreOperations() const { + return inputSymbolToPushdownStoreOperation; +} + +bool InputDrivenDPDA::addTransition(const State& from, const alphabet::Symbol& input, const State& to) { + if (states.find(from) == states.end()) + throw AutomatonException("State \"" + (std::string) from.getName() + "\" doesn't exist."); + + if (inputAlphabet.find(input) == inputAlphabet.end()) + throw AutomatonException("Input symbol \"" + (std::string) input + "\" doesn't exist."); + + if (inputSymbolToPushdownStoreOperation.find(input) == inputSymbolToPushdownStoreOperation.end()) + throw AutomatonException("Input symbol \"" + (std::string) input + "\" doesn't exist."); + + if (states.find(to) == states.end()) + throw AutomatonException("State \"" + (std::string) to.getName() + "\" doesn't exist."); + + std::pair<State, alphabet::Symbol> key = std::make_pair(from, input); + + if (transitions.find(key) != transitions.end()) { + if(transitions.find(key)->second == to) + return false; + else + throw AutomatonException( + "Transition from this state and symbol already exists (\"" + (std::string) from.getName() + "\", \"" + (std::string) input + "\") -> \"" + (std::string) to.getName() + + "\"."); + } + + transitions.insert(std::make_pair(key, to)); + return true; +} + +bool InputDrivenDPDA::removeTransition(const State& from, const alphabet::Symbol& input, const State& to) { + std::pair<State, alphabet::Symbol> key = std::make_pair(from, input); + + if (transitions.find(key) == transitions.end()) + return false; + + if(transitions.find(key)->second != to) + throw AutomatonException( + "Transition (\"" + (std::string) from.getName() + "\", \"" + (std::string) input + + "\") -> \"" + (std::string) to.getName() + "\" doesn't exist."); + + transitions.erase(key); + return true; +} + +const std::map<std::pair<State, alphabet::Symbol>, State>& InputDrivenDPDA::getTransitions() const { + return transitions; +} + +std::map<std::pair<State, alphabet::Symbol>, State > InputDrivenDPDA::getTransitionsFromState(const State& from) const { + if( states.find(from) == states.end()) + throw AutomatonException("State \"" + (std::string) from.getName() + "\" doesn't exist"); + + std::map<std::pair<State, alphabet::Symbol>, State> transitionsFromState; + for (const std::pair<std::pair<State, alphabet::Symbol>, State>& transition : transitions) { + if (transition.first.first == from) { + transitionsFromState.insert(transition); + } + } + + return transitionsFromState; +} + +std::map<std::pair<State, alphabet::Symbol>, State> InputDrivenDPDA::getTransitionsToState(const State& to) const { + if( states.find(to) == states.end()) + throw AutomatonException("State \"" + (std::string) to.getName() + "\" doesn't exist"); + + std::map<std::pair<State, alphabet::Symbol>, State> transitionsToState; + for (const std::pair<std::pair<State, alphabet::Symbol>, State>& transition : transitions) { + if (transition.second == to) { + transitionsToState.insert(transition); + } + } + + return transitionsToState; +} + +int InputDrivenDPDA::compare(const InputDrivenDPDA& other) const { + auto first = std::tie(states, inputAlphabet, initialState, finalStates, stackAlphabet, initialSymbol, inputSymbolToPushdownStoreOperation, transitions); + auto second = std::tie(other.states, other.inputAlphabet, other.initialState, other.finalStates, other.stackAlphabet, other.initialSymbol, other.inputSymbolToPushdownStoreOperation, other.transitions); + + std::compare<decltype(first)> comp; + return comp(first, second); +} + +void InputDrivenDPDA::operator>>(std::ostream& out) const { + out << "(InputDrivenDPDA " + << " states = " << states + << " inputAlphabet = " << inputAlphabet + << " initialState = " << initialState + << " finalStates = " << finalStates + << " stackAlphabet = " << stackAlphabet + << " initialSymbol = " << initialSymbol + << " transitions = " << transitions + << " inputSymbolToPushdownStoreOperation = " << inputSymbolToPushdownStoreOperation + << ")"; +} + +InputDrivenDPDA::operator std::string () const { + std::stringstream ss; + ss << *this; + return ss.str(); +} + +} /* namespace automaton */ diff --git a/alib2data/src/automaton/PDA/InputDrivenDPDA.h b/alib2data/src/automaton/PDA/InputDrivenDPDA.h new file mode 100644 index 0000000000..4d92e00439 --- /dev/null +++ b/alib2data/src/automaton/PDA/InputDrivenDPDA.h @@ -0,0 +1,121 @@ +/* + * INPUT_DRIVEN_DPDA.h + * + * Created on: Mar 25, 2013 + * Author: Jan Travnicek + */ + +#ifndef INPUT_DRIVEN_DPDA_H_ +#define INPUT_DRIVEN_DPDA_H_ + +#include "../../std/map.hpp" +#include "../AutomatonBase.h" +#include "../common/SingleInitialState.h" +#include "../common/InputAlphabet.h" +#include "../common/SingleInitialSymbolPushdownStoreAlphabet.h" +#include "../../alphabet/Symbol.h" + +namespace automaton { + +/** + * Represents Finite Automaton. + * Can store nondeterministic finite automaton without epsilon transitions. + */ +class InputDrivenDPDA : public std::acceptor<InputDrivenDPDA, VisitableAutomatonBase, std::acceptor<InputDrivenDPDA, alib::VisitableObjectBase, AutomatonBase> >, public SingleInitialSymbolPushdownStoreAlphabet, public SingleInitialState, public InputAlphabet { +protected: + std::map<std::pair<State, alphabet::Symbol>, State> transitions; + std::map<alphabet::Symbol, std::pair<std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol>>> inputSymbolToPushdownStoreOperation; +public: + explicit InputDrivenDPDA(const State& initialState, const alphabet::Symbol& initialPushdownSymbol); + + virtual AutomatonBase* clone() const; + + virtual AutomatonBase* plunder() &&; + + /** + * @copydoc Automaton::removeState(const State&) + */ + virtual bool removeState(const State& state); + + /** + * @copydoc Automaton::removeInputSymbol(const Symbol&) + */ + virtual bool removeInputSymbol(const alphabet::Symbol& symbol); + + /* + * @copydoc Automaton::removeStackSymbol(const Symbol&) + */ + virtual bool removeStackSymbol(const alphabet::Symbol& symbol); + + bool setPushdownStoreOperation(const alphabet::Symbol& input, const std::vector<alphabet::Symbol>& pop, const std::vector<alphabet::Symbol>& push); + + void setPushdownStoreOperations(const std::map<alphabet::Symbol, std::pair<std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol>>>& operations); + + bool clearPushdownStoreOperation(const alphabet::Symbol& input); + + const std::map<alphabet::Symbol, std::pair<std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol>>>& getPushdownStoreOperations() const; + + /** + * Adds transition defined by parameters to the automaton. + * @param current current state + * @param input input symbol + * @param next next state + * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton + */ + bool addTransition(const State& current, const alphabet::Symbol& input, const State& next); + + /** + * Removes transition from the automaton. + * @param transition transition to remove + * @throws AutomatonException when transition doesn't exists. + */ + bool removeTransition(const State& current, const alphabet::Symbol& input, const State& next); + + /** + * @return automaton transitions + */ + const std::map<std::pair<State, alphabet::Symbol>, State>& getTransitions() const; + + std::map<std::pair<State, alphabet::Symbol>, State> getTransitionsFromState(const State& from) const; + + std::map<std::pair<State, alphabet::Symbol>, State> getTransitionsToState(const State& to) const; + + /** + * Determines whether InputDrivenDPDA is deterministic. + * FA is deterministic if and only if: + * \li \c contains only 1 initial state. + * \li \c is epsilon free. Trivial for this class + * \li \c size of transition function \delta (from state, input symbol) \leq 1 + * @return true when automaton is deterministic, false otherwise + */ + bool isDeterministic() const; + + virtual int compare(const ObjectBase& other) const { + return -other.compare(*this); + } + + virtual int compare(const InputDrivenDPDA& other) const; + + virtual void operator>>(std::ostream& os) const; + + virtual operator std::string() const; + + virtual int selfTypeId() const { + return typeId<InputDrivenDPDA>(); + } +}; + +} /* namespace automaton */ + +namespace std { + +template<> +struct compare<automaton::InputDrivenDPDA> { + int operator()(const automaton::InputDrivenDPDA& first, const automaton::InputDrivenDPDA& second) const { + return first.compare(second); + } +}; + +} /* namespace std */ + +#endif /* INPUT_DRIVEN_DPDA_H_ */ diff --git a/alib2data/src/automaton/PDA/InputDrivenNPDA.cpp b/alib2data/src/automaton/PDA/InputDrivenNPDA.cpp index 11396954a9..87a0c7af51 100644 --- a/alib2data/src/automaton/PDA/InputDrivenNPDA.cpp +++ b/alib2data/src/automaton/PDA/InputDrivenNPDA.cpp @@ -87,6 +87,15 @@ bool InputDrivenNPDA::setPushdownStoreOperation(const alphabet::Symbol& input, c return inputSymbolToPushdownStoreOperation.insert(std::make_pair(input, std::make_pair(pop, push))).second; } +void InputDrivenNPDA::setPushdownStoreOperations(const std::map<alphabet::Symbol, std::pair<std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol>>>& operations) { + if(operations.size() == inputAlphabet.size() && std::equal(key_begin(operations), key_end(operations), inputAlphabet.begin())) + for(const auto& operation : operations) { + setPushdownStoreOperation(operation.first, operation.second.first, operation.second.second); + } + else + throw AutomatonException("All pushdown store operations of InputDrivenDPDA must be set"); +} + bool InputDrivenNPDA::clearPushdownStoreOperation(const alphabet::Symbol& input) { for (std::map<std::pair<State, alphabet::Symbol>, std::set<State> >::const_iterator transition = transitions.begin(); transition != transitions.end(); transition++) { @@ -115,13 +124,13 @@ bool InputDrivenNPDA::addTransition(const State& from, const alphabet::Symbol& i throw AutomatonException("State \"" + (std::string) to.getName() + "\" doesn't exist."); std::pair<State, alphabet::Symbol> key = std::make_pair(from, input); - + return transitions[key].insert(to).second; } bool InputDrivenNPDA::removeTransition(const State& from, const alphabet::Symbol& input, const State& to) { std::pair<State, alphabet::Symbol> key = std::make_pair(from, input); - + return transitions[key].erase(to); } diff --git a/alib2data/src/automaton/PDA/InputDrivenNPDA.h b/alib2data/src/automaton/PDA/InputDrivenNPDA.h index d137411c7c..75159d0a7c 100644 --- a/alib2data/src/automaton/PDA/InputDrivenNPDA.h +++ b/alib2data/src/automaton/PDA/InputDrivenNPDA.h @@ -8,7 +8,6 @@ #ifndef INPUT_DRIVEN_NPDA_H_ #define INPUT_DRIVEN_NPDA_H_ -#include <map> #include "../../std/map.hpp" #include "../AutomatonBase.h" #include "../common/SingleInitialState.h" @@ -30,7 +29,7 @@ public: explicit InputDrivenNPDA(const State& initialState, const alphabet::Symbol& initialPushdownSymbol); virtual AutomatonBase* clone() const; - + virtual AutomatonBase* plunder() &&; /** @@ -50,6 +49,8 @@ public: bool setPushdownStoreOperation(const alphabet::Symbol& input, const std::vector<alphabet::Symbol>& pop, const std::vector<alphabet::Symbol>& push); + void setPushdownStoreOperations(const std::map<alphabet::Symbol, std::pair<std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol>>>& operations); + bool clearPushdownStoreOperation(const alphabet::Symbol& input); const std::map<alphabet::Symbol, std::pair<std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol>>>& getPushdownStoreOperations() const; diff --git a/alib2data/src/object/ObjectBase.h b/alib2data/src/object/ObjectBase.h index 736a5a07ff..04a619b2f0 100644 --- a/alib2data/src/object/ObjectBase.h +++ b/alib2data/src/object/ObjectBase.h @@ -34,12 +34,13 @@ class CompactNFA; class ExtendedNFA; class DPDA; class SinglePopDPDA; +class InputDrivenDPDA; +class VisiblyPushdownDPDA; +class RealTimeHeightDeterministicDPDA; class NPDA; class SinglePopNPDA; class InputDrivenNPDA; -class VisiblyPushdownDPDA; class VisiblyPushdownNPDA; -class RealTimeHeightDeterministicDPDA; class RealTimeHeightDeterministicNPDA; class OneTapeDTM; @@ -132,7 +133,7 @@ class ObjectBase; typedef std::acceptor_base<ObjectBase, Void, exception::AlibException, - automaton::DFA, automaton::NFA, automaton::MultiInitialStateNFA, automaton::EpsilonNFA, automaton::CompactNFA, automaton::ExtendedNFA, automaton::DPDA, automaton::SinglePopDPDA, automaton::InputDrivenNPDA, automaton::VisiblyPushdownDPDA, automaton::VisiblyPushdownNPDA, automaton::RealTimeHeightDeterministicDPDA, automaton::RealTimeHeightDeterministicNPDA, automaton::NPDA, automaton::SinglePopNPDA, automaton::OneTapeDTM, + automaton::DFA, automaton::NFA, automaton::MultiInitialStateNFA, automaton::EpsilonNFA, automaton::CompactNFA, automaton::ExtendedNFA, automaton::DPDA, automaton::SinglePopDPDA, automaton::InputDrivenDPDA, automaton::VisiblyPushdownDPDA, automaton::RealTimeHeightDeterministicDPDA, automaton::NPDA, automaton::SinglePopNPDA, automaton::InputDrivenNPDA, automaton::VisiblyPushdownNPDA, automaton::RealTimeHeightDeterministicNPDA, automaton::OneTapeDTM, grammar::LeftLG, grammar::LeftRG, grammar::RightLG, grammar::RightRG, grammar::LG, grammar::CFG, grammar::EpsilonFreeCFG, grammar::CNF, grammar::GNF, grammar::CSG, grammar::NonContractingGrammar, grammar::ContextPreservingUnrestrictedGrammar, grammar::UnrestrictedGrammar, label::PrimitiveLabel, label::HexavigesimalLabel, label::ObjectLabel, label::LabelSetLabel, label::LabelPairLabel, label::UniqueLabel, regexp::UnboundedRegExp, regexp::FormalRegExp, @@ -147,7 +148,7 @@ class ObjectBase : ObjectBase, Void, exception::AlibException, - automaton::DFA, automaton::NFA, automaton::MultiInitialStateNFA, automaton::EpsilonNFA, automaton::CompactNFA, automaton::ExtendedNFA, automaton::DPDA, automaton::SinglePopDPDA, automaton::InputDrivenNPDA, automaton::VisiblyPushdownDPDA, automaton::VisiblyPushdownNPDA, automaton::RealTimeHeightDeterministicDPDA, automaton::RealTimeHeightDeterministicNPDA, automaton::NPDA, automaton::SinglePopNPDA, automaton::OneTapeDTM, + automaton::DFA, automaton::NFA, automaton::MultiInitialStateNFA, automaton::EpsilonNFA, automaton::CompactNFA, automaton::ExtendedNFA, automaton::DPDA, automaton::SinglePopDPDA, automaton::InputDrivenDPDA, automaton::VisiblyPushdownDPDA, automaton::RealTimeHeightDeterministicDPDA, automaton::NPDA, automaton::SinglePopNPDA, automaton::InputDrivenNPDA, automaton::VisiblyPushdownNPDA, automaton::RealTimeHeightDeterministicNPDA, automaton::OneTapeDTM, grammar::LeftLG, grammar::LeftRG, grammar::RightLG, grammar::RightRG, grammar::LG, grammar::CFG, grammar::EpsilonFreeCFG, grammar::CNF, grammar::GNF, grammar::CSG, grammar::NonContractingGrammar, grammar::ContextPreservingUnrestrictedGrammar, grammar::UnrestrictedGrammar, label::PrimitiveLabel, label::HexavigesimalLabel, label::ObjectLabel, label::LabelSetLabel, label::LabelPairLabel, label::UniqueLabel, regexp::UnboundedRegExp, regexp::FormalRegExp, diff --git a/alib2data/src/std/map.hpp b/alib2data/src/std/map.hpp index 5f821152d4..a67dc66080 100644 --- a/alib2data/src/std/map.hpp +++ b/alib2data/src/std/map.hpp @@ -34,6 +34,34 @@ std::ostream& operator<<(std::ostream& out, const std::map<T, R>& map) { return out; } +template<typename map_type> +class key_iterator : public map_type::const_iterator { +public: + typedef typename map_type::const_iterator map_iterator; + typedef typename map_iterator::value_type::first_type key_type; + + key_iterator(const map_iterator& other) : map_iterator(other) {} ; + + const key_type& operator *() const { + return map_iterator::operator*().first; + } + + const key_type* operator ->() const { + return &(map_iterator::operator*().first); + } +}; + +// helpers to create iterators easier: +template<typename map_type> +key_iterator<map_type> key_begin(const map_type& m) { + return key_iterator<map_type>(m.begin()); +} + +template<typename map_type> +key_iterator<map_type> key_end(const map_type& m) { + return key_iterator<map_type>(m.end()); +} + } /* namespace std */ #endif /* __MAP_HPP_ */ diff --git a/astat2/src/AutomataStat.cpp b/astat2/src/AutomataStat.cpp index 684805b344..d34f26b92e 100644 --- a/astat2/src/AutomataStat.cpp +++ b/astat2/src/AutomataStat.cpp @@ -206,6 +206,10 @@ void AutomataStat::Visit(void*, const automaton::SinglePopDPDA&) const { throw exception::AlibException("Unsupported automaton type SinglePopDPDA"); } +void AutomataStat::Visit(void*, const automaton::InputDrivenDPDA&) const { + throw exception::AlibException("Unsupported automaton type InputDrivenDPDA"); +} + void AutomataStat::Visit(void*, const automaton::InputDrivenNPDA&) const { throw exception::AlibException("Unsupported automaton type InputDrivenNPDA"); } diff --git a/astat2/src/AutomataStat.h b/astat2/src/AutomataStat.h index c481f06f59..0facfcdad4 100644 --- a/astat2/src/AutomataStat.h +++ b/astat2/src/AutomataStat.h @@ -33,6 +33,7 @@ private: void Visit(void*, const automaton::CompactNFA& automaton) const; void Visit(void*, const automaton::DPDA& automaton) const; void Visit(void*, const automaton::SinglePopDPDA& automaton) const; + void Visit(void*, const automaton::InputDrivenDPDA& automaton) const; void Visit(void*, const automaton::InputDrivenNPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownDPDA& automaton) const; void Visit(void*, const automaton::VisiblyPushdownNPDA& automaton) const; diff --git a/examples/automaton/NIDPDA1.DET.xml b/examples/automaton/NIDPDA1.DET.xml deleted file mode 100644 index 55acf68a7c..0000000000 --- a/examples/automaton/NIDPDA1.DET.xml +++ /dev/null @@ -1,77 +0,0 @@ -<automaton> - <states> - <state>['0']</state> - <state>['1']</state> - <state>['1', '2']</state> - <state>['2']</state> - <state>['3']</state> - </states> - <inputAlphabet> - <symbol>a</symbol> - <symbol>b</symbol> - <symbol>c</symbol> - <symbol>d</symbol> - </inputAlphabet> - <stackAlphabet> - <symbol>a</symbol> - <symbol>b</symbol> - </stackAlphabet> - <transitions> - <transition> - <from>['0']</from> - <input>a</input> - <to>['1']</to> - <pop></pop> - <push><symbol>a</symbol></push> - </transition> - <transition> - <from>['1']</from> - <input>b</input> - <to>['1', '2']</to> - <pop></pop> - <push><symbol>b</symbol></push> - </transition> - <transition> - <from>['1', '2']</from> - <input>b</input> - <to>['1', '2']</to> - <pop></pop> - <push><symbol>b</symbol></push> - </transition> - <transition> - <from>['1', '2']</from> - <input>c</input> - <to>['2']</to> - <pop><symbol>b</symbol></pop> - <push></push> - </transition> - <transition> - <from>['1', '2']</from> - <input>d</input> - <to>['3']</to> - <pop><symbol>a</symbol></pop> - <push></push> - </transition> - <transition> - <from>['2']</from> - <input>c</input> - <to>['2']</to> - <pop><symbol>b</symbol></pop> - <push></push> - </transition> - <transition> - <from>['2']</from> - <input>d</input> - <to>['3']</to> - <pop><symbol>a</symbol></pop> - <push></push> - </transition> - </transitions> - <initialStates> - <state>['0']</state> - </initialStates> - <startSymbols></startSymbols> - <finalStates> - <state>['3']</state> - </finalStates> -</automaton> diff --git a/examples/automaton/NIDPDA1.xml b/examples/automaton/NIDPDA1.xml deleted file mode 100644 index 5c874b111b..0000000000 --- a/examples/automaton/NIDPDA1.xml +++ /dev/null @@ -1,72 +0,0 @@ -<automaton> - <states> - <state>0</state> - <state>1</state> - <state>2</state> - <state>3</state> - </states> - <inputAlphabet> - <symbol>a</symbol> - <symbol>b</symbol> - <symbol>c</symbol> - <symbol>d</symbol> - </inputAlphabet> - <stackAlphabet> - <symbol>a</symbol> - <symbol>b</symbol> - </stackAlphabet> - <transitions> - <transition> - <from>0</from> - <input>a</input> - <to>1</to> - <pop></pop> - <push> - <symbol>a</symbol> - </push> - </transition> - <transition> - <from>1</from> - <input>b</input> - <to>1</to> - <pop></pop> - <push> - <symbol>b</symbol> - </push> - </transition> - <transition> - <from>1</from> - <input>b</input> - <to>2</to> - <pop></pop> - <push> - <symbol>b</symbol> - </push> - </transition> - <transition> - <from>2</from> - <input>c</input> - <to>2</to> - <pop> - <symbol>b</symbol> - </pop> - <push></push> - </transition> - <transition> - <from>2</from> - <input>d</input> - <to>3</to> - <pop> - <symbol>a</symbol> - </pop> - <push></push> - </transition> - </transitions> - <initialStates> - <state>0</state> - </initialStates> - <startSymbols></startSymbols> - <finalStates> - <state>3</state> - </finalStates> -</automaton> diff --git a/examples/automaton/NIDPDA2.DET.xml b/examples/automaton/NIDPDA2.DET.xml deleted file mode 100644 index cf64064d6a..0000000000 --- a/examples/automaton/NIDPDA2.DET.xml +++ /dev/null @@ -1,77 +0,0 @@ -<automaton> - <states> - <state>['0']</state> - <state>['0', '1', '2']</state> - <state>['1', '2']</state> - <state>['2']</state> - </states> - <inputAlphabet> - <symbol>a</symbol> - <symbol>b</symbol> - <symbol>c</symbol> - </inputAlphabet> - <stackAlphabet> - <symbol>a</symbol> - </stackAlphabet> - <transitions> - <transition> - <from>['0']</from> - <input>a</input> - <to>['0', '1', '2']</to> - <pop></pop> - <push><symbol>a</symbol></push> - </transition> - <transition> - <from>['0', '1', '2']</from> - <input>a</input> - <to>['0', '1', '2']</to> - <pop></pop> - <push><symbol>a</symbol></push> - </transition> - <transition> - <from>['0', '1', '2']</from> - <input>b</input> - <to>['1', '2']</to> - <pop><symbol>a</symbol></pop> - <push></push> - </transition> - <transition> - <from>['0', '1', '2']</from> - <input>c</input> - <to>['2']</to> - <pop><symbol>a</symbol></pop> - <push></push> - </transition> - <transition> - <from>['1', '2']</from> - <input>b</input> - <to>['1', '2']</to> - <pop><symbol>a</symbol></pop> - <push></push> - </transition> - <transition> - <from>['1', '2']</from> - <input>c</input> - <to>['2']</to> - <pop><symbol>a</symbol></pop> - <push></push> - </transition> - <transition> - <from>['2']</from> - <input>c</input> - <to>['2']</to> - <pop><symbol>a</symbol></pop> - <push></push> - </transition> - </transitions> - <initialStates> - <state>['0']</state> - </initialStates> - <startSymbols></startSymbols> - <finalStates> - <state>['0']</state> - <state>['0', '1', '2']</state> - <state>['1', '2']</state> - <state>['2']</state> - </finalStates> -</automaton> diff --git a/examples/automaton/NIDPDA2.xml b/examples/automaton/NIDPDA2.xml deleted file mode 100644 index ab1bab24f4..0000000000 --- a/examples/automaton/NIDPDA2.xml +++ /dev/null @@ -1,80 +0,0 @@ -<automaton> - <states> - <state>0</state> - <state>1</state> - <state>2</state> - </states> - <inputAlphabet> - <symbol>a</symbol> - <symbol>b</symbol> - <symbol>c</symbol> - </inputAlphabet> - <stackAlphabet> - <symbol>a</symbol> - </stackAlphabet> - <transitions> - <transition> - <from>0</from> - <input>a</input> - <to>0</to> - <pop></pop> - <push> - <symbol>a</symbol> - </push> - </transition> - <transition> - <from>0</from> - <input>a</input> - <to>1</to> - <pop></pop> - <push> - <symbol>a</symbol> - </push> - </transition> - <transition> - <from>0</from> - <input>a</input> - <to>2</to> - <pop></pop> - <push> - <symbol>a</symbol> - </push> - </transition> - <transition> - <from>1</from> - <input>b</input> - <to>1</to> - <pop> - <symbol>a</symbol> - </pop> - <push></push> - </transition> - <transition> - <from>1</from> - <input>b</input> - <to>2</to> - <pop> - <symbol>a</symbol> - </pop> - <push></push> - </transition> - <transition> - <from>2</from> - <input>c</input> - <to>2</to> - <pop> - <symbol>a</symbol> - </pop> - <push></push> - </transition> - </transitions> - <initialStates> - <state>0</state> - </initialStates> - <startSymbols></startSymbols> - <finalStates> - <state>0</state> - <state>1</state> - <state>2</state> - </finalStates> -</automaton> diff --git a/examples/automaton/NIDPDA3.DET.xml b/examples/automaton/NIDPDA3.DET.xml deleted file mode 100644 index 48dc4528ab..0000000000 --- a/examples/automaton/NIDPDA3.DET.xml +++ /dev/null @@ -1,99 +0,0 @@ -<automaton> - <states> - <state>['0']</state> - <state>['0', 'B1', 'C1']</state> - <state>['B1', 'B2', 'C2']</state> - <state>['B1', 'B2']</state> - <state>['3', 'C2']</state> - <state>['3']</state> - <state>['4']</state> - </states> - <inputAlphabet> - <symbol>a</symbol> - <symbol>b</symbol> - <symbol>c</symbol> - <symbol>d</symbol> - </inputAlphabet> - <stackAlphabet> - <symbol>a</symbol> - </stackAlphabet> - <transitions> - <transition> - <from>['0']</from> - <input>a</input> - <to>['0', 'B1', 'C1']</to> - <pop></pop> - <push><symbol>a</symbol></push> - </transition> - <transition> - <from>['0', 'B1', 'C1']</from> - <input>a</input> - <to>['0', 'B1', 'C1']</to> - <pop></pop> - <push><symbol>a</symbol></push> - </transition> - <transition> - <from>['0', 'B1', 'C1']</from> - <input>b</input> - <to>['B1', 'B2', 'C2']</to> - <pop><symbol>a</symbol></pop> - <push></push> - </transition> - <transition> - <from>['B1', 'B2', 'C2']</from> - <input>b</input> - <to>['B1', 'B2']</to> - <pop><symbol>a</symbol></pop> - <push></push> - </transition> - <transition> - <from>['B1', 'B2', 'C2']</from> - <input>c</input> - <to>['3', 'C2']</to> - <pop><symbol>a</symbol></pop> - <push></push> - </transition> - <transition> - <from>['B1', 'B2']</from> - <input>b</input> - <to>['B1', 'B2']</to> - <pop><symbol>a</symbol></pop> - <push></push> - </transition> - <transition> - <from>['B1', 'B2']</from> - <input>c</input> - <to>['3']</to> - <pop><symbol>a</symbol></pop> - <push></push> - </transition> - <transition> - <from>['3', 'C2']</from> - <input>c</input> - <to>['3', 'C2']</to> - <pop><symbol>a</symbol></pop> - <push></push> - </transition> - <transition> - <from>['3', 'C2']</from> - <input>d</input> - <to>['4']</to> - <pop></pop> - <push></push> - </transition> - <transition> - <from>['3']</from> - <input>d</input> - <to>['4']</to> - <pop></pop> - <push></push> - </transition> - </transitions> - <initialStates> - <state>['0']</state> - </initialStates> - <startSymbols></startSymbols> - <finalStates> - <state>['4']</state> - </finalStates> -</automaton> diff --git a/examples/automaton/NIDPDA3.xml b/examples/automaton/NIDPDA3.xml deleted file mode 100644 index 021d66f251..0000000000 --- a/examples/automaton/NIDPDA3.xml +++ /dev/null @@ -1,117 +0,0 @@ -<automaton> - <states> - <state>0</state> - <state>B1</state> - <state>B2</state> - <state>C1</state> - <state>C2</state> - <state>3</state> - <state>4</state> - </states> - <inputAlphabet> - <symbol>a</symbol> - <symbol>b</symbol> - <symbol>c</symbol> - <symbol>d</symbol> - </inputAlphabet> - <stackAlphabet> - <symbol>a</symbol> - </stackAlphabet> - <transitions> - <transition> - <from>0</from> - <input>a</input> - <to>0</to> - <pop></pop> - <push> - <symbol>a</symbol> - </push> - </transition> - <transition> - <from>0</from> - <input>a</input> - <to>B1</to> - <pop></pop> - <push> - <symbol>a</symbol> - </push> - </transition> - <transition> - <from>0</from> - <input>a</input> - <to>C1</to> - <pop></pop> - <push> - <symbol>a</symbol> - </push> - </transition> - <transition> - <from>B1</from> - <input>b</input> - <to>B1</to> - <pop> - <symbol>a</symbol> - </pop> - <push></push> - </transition> - <transition> - <from>B1</from> - <input>b</input> - <to>B2</to> - <pop> - <symbol>a</symbol> - </pop> - <push></push> - </transition> - <transition> - <from>B2</from> - <input>c</input> - <to>3</to> - <pop> - <symbol>a</symbol> - </pop> - <push></push> - </transition> - <transition> - <from>C1</from> - <input>b</input> - <to>C2</to> - <pop> - <symbol>a</symbol> - </pop> - <push></push> - </transition> - <transition> - <from>C2</from> - <input>c</input> - <to>C2</to> - <pop> - <symbol>a</symbol> - </pop> - <push></push> - </transition> - <transition> - <from>C2</from> - <input>c</input> - <to>3</to> - <pop> - <symbol>a</symbol> - </pop> - <push></push> - </transition> - <transition> - <from>3</from> - <input>d</input> - <to>4</to> - <pop></pop> - <push></push> - </transition> - </transitions> - <initialStates> - <state>0</state> - </initialStates> - <startSymbols></startSymbols> - <finalStates> - <state>4</state> - </finalStates> -</automaton> diff --git a/examples2/automaton/NIDPDA1.DET.xml b/examples2/automaton/NIDPDA1.DET.xml new file mode 100644 index 0000000000..b0bb5a9867 --- /dev/null +++ b/examples2/automaton/NIDPDA1.DET.xml @@ -0,0 +1,88 @@ +<InputDrivenDPDA> + <states> + <PrimitiveLabel><String>['0']</String></PrimitiveLabel> + <PrimitiveLabel><String>['1']</String></PrimitiveLabel> + <PrimitiveLabel><String>['1', '2']</String></PrimitiveLabel> + <PrimitiveLabel><String>['2']</String></PrimitiveLabel> + <PrimitiveLabel><String>['3']</String></PrimitiveLabel> + </states> + <inputAlphabet> + <LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol> + <LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol> + <LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol> + <LabeledSymbol><PrimitiveLabel><Character>d</Character></PrimitiveLabel></LabeledSymbol> + </inputAlphabet> + <stackAlphabet> + <BottomOfTheStackSymbol /> + <LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol> + <LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol> + </stackAlphabet> + <initialState> + <PrimitiveLabel><String>['0']</String></PrimitiveLabel> + </initialState> + <initialStackSymbol> + <BottomOfTheStackSymbol /> + </initialStackSymbol> + <finalStates> + <PrimitiveLabel><String>['3']</String></PrimitiveLabel> + </finalStates> + <inputToPushdownStoreOperations> + <operation> + <LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol> + <pop></pop> + <push><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></push> + </operation> + <operation> + <LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol> + <pop></pop> + <push><LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol></push> + </operation> + <operation> + <LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol> + <pop><LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol></pop> + <push></push> + </operation> + <operation> + <LabeledSymbol><PrimitiveLabel><Character>d</Character></PrimitiveLabel></LabeledSymbol> + <pop><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></pop> + <push></push> + </operation> + </inputToPushdownStoreOperations> + <transitions> + <transition> + <from><PrimitiveLabel><String>['0']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['1']</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>['1']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['1', '2']</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>['1', '2']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['1', '2']</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>['1', '2']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['2']</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>['1', '2']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>d</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['3']</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>['2']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['2']</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>['2']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>d</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['3']</String></PrimitiveLabel></to> + </transition> + </transitions> +</InputDrivenDPDA> diff --git a/examples2/automaton/NIDPDA1.xml b/examples2/automaton/NIDPDA1.xml index d6e4419c89..f281664d37 100644 --- a/examples2/automaton/NIDPDA1.xml +++ b/examples2/automaton/NIDPDA1.xml @@ -1,154 +1,77 @@ <InputDrivenNPDA> - <states> - <PrimitiveLabel><Integer>0</Integer></PrimitiveLabel> - <PrimitiveLabel><Integer>1</Integer></PrimitiveLabel> - <PrimitiveLabel><Integer>2</Integer></PrimitiveLabel> - <PrimitiveLabel><Integer>3</Integer></PrimitiveLabel> - </states> - <inputAlphabet> - <LabeledSymbol> - <PrimitiveLabel><String>a</String></PrimitiveLabel> - </LabeledSymbol> - <LabeledSymbol> - <PrimitiveLabel><String>b</String></PrimitiveLabel> - </LabeledSymbol> - <LabeledSymbol> - <PrimitiveLabel><String>c</String></PrimitiveLabel> - </LabeledSymbol> - <LabeledSymbol> - <PrimitiveLabel><String>d</String></PrimitiveLabel> - </LabeledSymbol> - </inputAlphabet> - <stackAlphabet> - <LabeledSymbol> - <PrimitiveLabel><String>a</String></PrimitiveLabel> - </LabeledSymbol> - <LabeledSymbol> - <PrimitiveLabel><String>b</String></PrimitiveLabel> - </LabeledSymbol> - </stackAlphabet> - <initialState> - <PrimitiveLabel><Integer>0</Integer></PrimitiveLabel> - </initialState> - <initialStackSymbol> - <LabeledSymbol> - <PrimitiveLabel><String>a</String></PrimitiveLabel> - </LabeledSymbol> - </initialStackSymbol> - <finalStates> - <PrimitiveLabel><Integer>3</Integer></PrimitiveLabel> - </finalStates> - <inputToPushdownStoreOperations> - <operation> - <LabeledSymbol> - <PrimitiveLabel><String>a</String></PrimitiveLabel> - </LabeledSymbol> - <pop/> - <push> - <LabeledSymbol> - <PrimitiveLabel><String>a</String></PrimitiveLabel> - </LabeledSymbol> - </push> - </operation> - <operation> - <LabeledSymbol> - <PrimitiveLabel><String>b</String></PrimitiveLabel> - </LabeledSymbol> - <pop/> - <push> - <LabeledSymbol> - <PrimitiveLabel><String>b</String></PrimitiveLabel> - </LabeledSymbol> - </push> - </operation> - <operation> - <LabeledSymbol> - <PrimitiveLabel><String>c</String></PrimitiveLabel> - </LabeledSymbol> - <pop> - <LabeledSymbol> - <PrimitiveLabel><String>b</String></PrimitiveLabel> - </LabeledSymbol> - </pop> - <push/> - </operation> - <operation> - <LabeledSymbol> - <PrimitiveLabel><String>d</String></PrimitiveLabel> - </LabeledSymbol> - <pop> - <LabeledSymbol> - <PrimitiveLabel><String>a</String></PrimitiveLabel> - </LabeledSymbol> - </pop> - <push/> - </operation> - </inputToPushdownStoreOperations> - <transitions> - <transition> - <from> - <PrimitiveLabel><Integer>0</Integer></PrimitiveLabel> - </from> - <input> - <LabeledSymbol> - <PrimitiveLabel><String>a</String></PrimitiveLabel> - </LabeledSymbol> - </input> - <to> - <PrimitiveLabel><Integer>1</Integer></PrimitiveLabel> - </to> - </transition> - <transition> - <from> - <PrimitiveLabel><Integer>1</Integer></PrimitiveLabel> - </from> - <input> - <LabeledSymbol> - <PrimitiveLabel><String>b</String></PrimitiveLabel> - </LabeledSymbol> - </input> - <to> - <PrimitiveLabel><Integer>1</Integer></PrimitiveLabel> - </to> - </transition> - <transition> - <from> - <PrimitiveLabel><Integer>1</Integer></PrimitiveLabel> - </from> - <input> - <LabeledSymbol> - <PrimitiveLabel><String>b</String></PrimitiveLabel> - </LabeledSymbol> - </input> - <to> - <PrimitiveLabel><Integer>2</Integer></PrimitiveLabel> - </to> - </transition> - <transition> - <from> - <PrimitiveLabel><Integer>2</Integer></PrimitiveLabel> - </from> - <input> - <LabeledSymbol> - <PrimitiveLabel><String>c</String></PrimitiveLabel> - </LabeledSymbol> - </input> - <to> - <PrimitiveLabel><Integer>2</Integer></PrimitiveLabel> - </to> - </transition> - <transition> - <from> - <PrimitiveLabel><Integer>2</Integer></PrimitiveLabel> - </from> - <input> - <LabeledSymbol> - <PrimitiveLabel><String>d</String></PrimitiveLabel> - </LabeledSymbol> - </input> - <to> - <PrimitiveLabel><Integer>3</Integer></PrimitiveLabel> - </to> - </transition> - </transitions> + <states> + <PrimitiveLabel><String>0</String></PrimitiveLabel> + <PrimitiveLabel><String>1</String></PrimitiveLabel> + <PrimitiveLabel><String>2</String></PrimitiveLabel> + <PrimitiveLabel><String>3</String></PrimitiveLabel> + </states> + <inputAlphabet> + <LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol> + <LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol> + <LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol> + <LabeledSymbol><PrimitiveLabel><Character>d</Character></PrimitiveLabel></LabeledSymbol> + </inputAlphabet> + <stackAlphabet> + <BottomOfTheStackSymbol /> + <LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol> + <LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol> + </stackAlphabet> + <initialState> + <PrimitiveLabel><String>0</String></PrimitiveLabel> + </initialState> + <initialStackSymbol> + <BottomOfTheStackSymbol /> + </initialStackSymbol> + <finalStates> + <PrimitiveLabel><String>3</String></PrimitiveLabel> + </finalStates> + <inputToPushdownStoreOperations> + <operation> + <LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol> + <pop></pop> + <push><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></push> + </operation> + <operation> + <LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol> + <pop></pop> + <push><LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol></push> + </operation> + <operation> + <LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol> + <pop><LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol></pop> + <push></push> + </operation> + <operation> + <LabeledSymbol><PrimitiveLabel><Character>d</Character></PrimitiveLabel></LabeledSymbol> + <pop><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></pop> + <push></push> + </operation> + </inputToPushdownStoreOperations> + <transitions> + <transition> + <from><PrimitiveLabel><String>0</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>1</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>1</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>1</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>1</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>2</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>2</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>2</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>2</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>d</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>3</String></PrimitiveLabel></to> + </transition> + </transitions> </InputDrivenNPDA> diff --git a/examples2/automaton/NIDPDA2.DET.xml b/examples2/automaton/NIDPDA2.DET.xml new file mode 100644 index 0000000000..5afab0389a --- /dev/null +++ b/examples2/automaton/NIDPDA2.DET.xml @@ -0,0 +1,83 @@ +<InputDrivenDPDA> + <states> + <PrimitiveLabel><String>['0']</String></PrimitiveLabel> + <PrimitiveLabel><String>['0', '1', '2']</String></PrimitiveLabel> + <PrimitiveLabel><String>['1', '2']</String></PrimitiveLabel> + <PrimitiveLabel><String>['2']</String></PrimitiveLabel> + </states> + <inputAlphabet> + <LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol> + <LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol> + <LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol> + </inputAlphabet> + <stackAlphabet> + <BottomOfTheStackSymbol /> + <LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol> + </stackAlphabet> + <initialState> + <PrimitiveLabel><String>['0']</String></PrimitiveLabel> + </initialState> + <initialStackSymbol> + <BottomOfTheStackSymbol /> + </initialStackSymbol> + <finalStates> + <PrimitiveLabel><String>['0']</String></PrimitiveLabel> + <PrimitiveLabel><String>['0', '1', '2']</String></PrimitiveLabel> + <PrimitiveLabel><String>['1', '2']</String></PrimitiveLabel> + <PrimitiveLabel><String>['2']</String></PrimitiveLabel> + </finalStates> + <inputToPushdownStoreOperations> + <operation> + <LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol> + <pop></pop> + <push><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></push> + </operation> + <operation> + <LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol> + <pop><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></pop> + <push></push> + </operation> + <operation> + <LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol> + <pop><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></pop> + <push></push> + </operation> + </inputToPushdownStoreOperations> + <transitions> + <transition> + <from><PrimitiveLabel><String>['0']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['0', '1', '2']</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>['0', '1', '2']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['0', '1', '2']</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>['0', '1', '2']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['1', '2']</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>['0', '1', '2']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['2']</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>['1', '2']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['1', '2']</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>['1', '2']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['2']</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>['2']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['2']</String></PrimitiveLabel></to> + </transition> + </transitions> +</InputDrivenDPDA> diff --git a/examples2/automaton/NIDPDA2.xml b/examples2/automaton/NIDPDA2.xml new file mode 100644 index 0000000000..c11d137c27 --- /dev/null +++ b/examples2/automaton/NIDPDA2.xml @@ -0,0 +1,76 @@ +<InputDrivenNPDA> + <states> + <PrimitiveLabel><String>0</String></PrimitiveLabel> + <PrimitiveLabel><String>1</String></PrimitiveLabel> + <PrimitiveLabel><String>2</String></PrimitiveLabel> + </states> + <inputAlphabet> + <LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol> + <LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol> + <LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol> + </inputAlphabet> + <stackAlphabet> + <BottomOfTheStackSymbol /> + <LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol> + </stackAlphabet> + <initialState> + <PrimitiveLabel><String>0</String></PrimitiveLabel> + </initialState> + <initialStackSymbol> + <BottomOfTheStackSymbol /> + </initialStackSymbol> + <finalStates> + <PrimitiveLabel><String>0</String></PrimitiveLabel> + <PrimitiveLabel><String>1</String></PrimitiveLabel> + <PrimitiveLabel><String>2</String></PrimitiveLabel> + </finalStates> + <inputToPushdownStoreOperations> + <operation> + <LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol> + <pop></pop> + <push><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></push> + </operation> + <operation> + <LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol> + <pop><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></pop> + <push></push> + </operation> + <operation> + <LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol> + <pop><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></pop> + <push></push> + </operation> + </inputToPushdownStoreOperations> + <transitions> + <transition> + <from><PrimitiveLabel><String>0</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>0</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>0</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>1</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>0</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>2</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>1</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>1</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>1</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>2</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>2</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>2</String></PrimitiveLabel></to> + </transition> + </transitions> +</InputDrivenNPDA> diff --git a/examples2/automaton/NIDPDA3.DET.xml b/examples2/automaton/NIDPDA3.DET.xml new file mode 100644 index 0000000000..5096cce2c6 --- /dev/null +++ b/examples2/automaton/NIDPDA3.DET.xml @@ -0,0 +1,104 @@ +<InputDrivenDPDA> + <states> + <PrimitiveLabel><String>['0']</String></PrimitiveLabel> + <PrimitiveLabel><String>['0', 'B1', 'C1']</String></PrimitiveLabel> + <PrimitiveLabel><String>['B1', 'B2', 'C2']</String></PrimitiveLabel> + <PrimitiveLabel><String>['B1', 'B2']</String></PrimitiveLabel> + <PrimitiveLabel><String>['3', 'C2']</String></PrimitiveLabel> + <PrimitiveLabel><String>['3']</String></PrimitiveLabel> + <PrimitiveLabel><String>['4']</String></PrimitiveLabel> + </states> + <inputAlphabet> + <LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol> + <LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol> + <LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol> + <LabeledSymbol><PrimitiveLabel><Character>d</Character></PrimitiveLabel></LabeledSymbol> + </inputAlphabet> + <stackAlphabet> + <BottomOfTheStackSymbol /> + <LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol> + </stackAlphabet> + <initialState> + <PrimitiveLabel><String>['0']</String></PrimitiveLabel> + </initialState> + <initialStackSymbol> + <BottomOfTheStackSymbol /> + </initialStackSymbol> + <finalStates> + <PrimitiveLabel><String>['4']</String></PrimitiveLabel> + </finalStates> + <inputToPushdownStoreOperations> + <operation> + <LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol> + <pop></pop> + <push><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></push> + </operation> + <operation> + <LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol> + <pop><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></pop> + <push></push> + </operation> + <operation> + <LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol> + <pop><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></pop> + <push></push> + </operation> + <operation> + <LabeledSymbol><PrimitiveLabel><Character>d</Character></PrimitiveLabel></LabeledSymbol> + <pop></pop> + <push></push> + </operation> + </inputToPushdownStoreOperations> + <transitions> + <transition> + <from><PrimitiveLabel><String>['0']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['0', 'B1', 'C1']</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>['0', 'B1', 'C1']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['0', 'B1', 'C1']</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>['0', 'B1', 'C1']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['B1', 'B2', 'C2']</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>['B1', 'B2', 'C2']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['B1', 'B2']</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>['B1', 'B2', 'C2']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['3', 'C2']</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>['B1', 'B2']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['B1', 'B2']</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>['B1', 'B2']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['3']</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>['3', 'C2']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['3', 'C2']</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>['3', 'C2']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>d</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['4']</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>['3']</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>d</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>['4']</String></PrimitiveLabel></to> + </transition> + </transitions> +</InputDrivenDPDA> diff --git a/examples2/automaton/NIDPDA3.xml b/examples2/automaton/NIDPDA3.xml new file mode 100644 index 0000000000..4c9877662f --- /dev/null +++ b/examples2/automaton/NIDPDA3.xml @@ -0,0 +1,104 @@ +<InputDrivenNPDA> + <states> + <PrimitiveLabel><String>0</String></PrimitiveLabel> + <PrimitiveLabel><String>B1</String></PrimitiveLabel> + <PrimitiveLabel><String>B2</String></PrimitiveLabel> + <PrimitiveLabel><String>C1</String></PrimitiveLabel> + <PrimitiveLabel><String>C2</String></PrimitiveLabel> + <PrimitiveLabel><String>3</String></PrimitiveLabel> + <PrimitiveLabel><String>4</String></PrimitiveLabel> + </states> + <inputAlphabet> + <LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol> + <LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol> + <LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol> + <LabeledSymbol><PrimitiveLabel><Character>d</Character></PrimitiveLabel></LabeledSymbol> + </inputAlphabet> + <stackAlphabet> + <BottomOfTheStackSymbol /> + <LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol> + </stackAlphabet> + <initialState> + <PrimitiveLabel><String>0</String></PrimitiveLabel> + </initialState> + <initialStackSymbol> + <BottomOfTheStackSymbol /> + </initialStackSymbol> + <finalStates> + <PrimitiveLabel><String>4</String></PrimitiveLabel> + </finalStates> + <inputToPushdownStoreOperations> + <operation> + <LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol> + <pop></pop> + <push><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></push> + </operation> + <operation> + <LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol> + <pop><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></pop> + <push></push> + </operation> + <operation> + <LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol> + <pop><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></pop> + <push></push> + </operation> + <operation> + <LabeledSymbol><PrimitiveLabel><Character>d</Character></PrimitiveLabel></LabeledSymbol> + <pop></pop> + <push></push> + </operation> + </inputToPushdownStoreOperations> + <transitions> + <transition> + <from><PrimitiveLabel><String>0</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>0</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>0</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>B1</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>0</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>a</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>C1</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>B1</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>B1</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>B1</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>B2</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>B2</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>3</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>C1</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>b</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>C2</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>C2</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>C2</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>C2</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>c</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>3</String></PrimitiveLabel></to> + </transition> + <transition> + <from><PrimitiveLabel><String>3</String></PrimitiveLabel></from> + <input><LabeledSymbol><PrimitiveLabel><Character>d</Character></PrimitiveLabel></LabeledSymbol></input> + <to><PrimitiveLabel><String>4</String></PrimitiveLabel></to> + </transition> + </transitions> +</InputDrivenNPDA> -- GitLab