diff --git a/alib2/src/automaton/PDA/NPDA.cpp b/alib2/src/automaton/PDA/NPDA.cpp index 49eda1d1acef31b1a048b7f0a11d56bd72a71c42..9225975116326e3e923f7fa8f15ba267d5b6afa0 100644 --- a/alib2/src/automaton/PDA/NPDA.cpp +++ b/alib2/src/automaton/PDA/NPDA.cpp @@ -50,26 +50,6 @@ bool NPDA::removeInputSymbol(const alphabet::Symbol& symbol) { return inputAlphabet.erase(symbol); } -bool NPDA::addStackSymbol(const alphabet::Symbol& symbol) { - return stackAlphabet.insert(symbol).second; -} - -void NPDA::setStackSymbols(const std::set<alphabet::Symbol>& newSymbols) { - std::set<alphabet::Symbol> removed; - std::set_difference(stackAlphabet.begin(), stackAlphabet.end(), newSymbols.begin(), newSymbols.end(), std::inserter(removed, removed.end())); - - std::set<alphabet::Symbol> added; - std::set_difference(newSymbols.begin(), newSymbols.end(), stackAlphabet.begin(), stackAlphabet.end(), std::inserter(added, added.end())); - - for(const alphabet::Symbol& removedSymbol : removed) { - removeStackSymbol(removedSymbol); - } - - for(const alphabet::Symbol& addedSymbol : added) { - addStackSymbol(addedSymbol); - } -} - bool NPDA::removeStackSymbol(const alphabet::Symbol& symbol) { for (std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::pair<State, std::vector<alphabet::Symbol> > > >::const_iterator transition = transitions.begin(); transition != transitions.end(); transition++) { for (std::vector<alphabet::Symbol>::const_iterator popSymbol = std::get<2>(transition->first).begin(); popSymbol != std::get<2>(transition->first).end(); @@ -90,10 +70,6 @@ bool NPDA::removeStackSymbol(const alphabet::Symbol& symbol) { return stackAlphabet.erase(symbol); } -const std::set<alphabet::Symbol>& NPDA::getStackAlphabet() const { - return stackAlphabet; -} - bool NPDA::addTransition(const State& from, const alphabet::Symbol& input, const std::vector<alphabet::Symbol>& pop, const State& to, const std::vector<alphabet::Symbol>& push) { if (states.find(from) == states.end()) { throw AutomatonException("State \"" + (std::string) from.getName() + "\" doesn't exist."); @@ -142,31 +118,6 @@ const std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol> return transitions; } -bool NPDA::addInitialSymbol(const alphabet::Symbol& start) { - if (stackAlphabet.find(start) == stackAlphabet.end()) { - throw AutomatonException("Stack symbol \"" + (std::string) start + "\" doesn't exist."); - } - - return this->initialSymbols.insert(start).second; -} - -bool NPDA::removeInitialSymbol(const alphabet::Symbol& start) { - return this->initialSymbols.erase(start); -} - -void NPDA::setInitialSymbols(const std::set<alphabet::Symbol>& symbols) { - std::set<alphabet::Symbol> tmp; - std::set_difference(symbols.begin(), symbols.end(), this->stackAlphabet.begin(), this->stackAlphabet.end(), std::inserter(tmp, tmp.end())); - if(tmp.size() != 0) - throw AutomatonException("Initial symbols not in stack alphabet"); - - this->initialSymbols = symbols; -} - -const std::set<alphabet::Symbol>& NPDA::getInitialSymbols() const { - return initialSymbols; -} - bool NPDA::operator==(const AutomatonBase& other) const { return other == *this; } diff --git a/alib2/src/automaton/PDA/NPDA.h b/alib2/src/automaton/PDA/NPDA.h index dd7912bd61b292570a607757efb0ef89224f4942..ec46075001be390f20068808c2038dd539d0de8d 100644 --- a/alib2/src/automaton/PDA/NPDA.h +++ b/alib2/src/automaton/PDA/NPDA.h @@ -14,6 +14,7 @@ #include "../../std/variant.hpp" #include "../AutomatonBase.h" #include "../common/MultiInitialStates.h" +#include "../common/MultiInitialSymbolsPushdownStoreAlphabet.h" #include "../common/InputAlphabet.h" #include "../../alphabet/Symbol.h" #include "../../string/Epsilon.h" @@ -23,11 +24,9 @@ namespace automaton { /** * Push Down Automaton */ -class NPDA: public std::element<NPDA, AutomatonBase>, public MultiInitialStates, public InputAlphabet { +class NPDA : public std::element<NPDA, AutomatonBase>, public MultiInitialSymbolsPushdownStoreAlphabet, public MultiInitialStates, public InputAlphabet { protected: - std::set<alphabet::Symbol> stackAlphabet; std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::pair<State, std::vector<alphabet::Symbol> > > > transitions; - std::set<alphabet::Symbol> initialSymbols; public: virtual AutomatonBase* clone() const; @@ -44,32 +43,9 @@ public: virtual bool removeInputSymbol(const alphabet::Symbol& symbol); /** - * Adds symbol to the stack alphabet. - * @param symbol Symbol to add - * @throws AutomatonException when symbol is already present in stack alphabet + * @copydoc Automaton::removeStackSymbol(const Symbol&) */ - bool addStackSymbol(const alphabet::Symbol& symbol); - - /** - * Sets stack symbols of the automaton. - * @param symbols Symbols to set - * @throws AutomatonException when symbol is already present in stack alphabet - */ - void setStackSymbols(const std::set<alphabet::Symbol>& symbols); - - /** - * Removes symbol from the stack alphabet. - * @param symbol Symbol to remove - * @throws AutomatonException when symbol is used in transition - * (popped from or pushed to the stack), when it is a start symbol - * or when it is not present in the stack alphabet - */ - bool removeStackSymbol(const alphabet::Symbol& symbol); - - /** - * @return the stack alphabet - */ - const std::set<alphabet::Symbol>& getStackAlphabet() const; + virtual bool removeStackSymbol(const alphabet::Symbol& symbol); /** * Adds transition to the NPDA. @@ -91,36 +67,6 @@ public: */ const std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::pair<State, std::vector<alphabet::Symbol> > > >& getTransitions() const; - /** - * Adds initial symbol. Initial symbols are symbols that are pushed - * to the stack when NPDA is created. - * @param start new initial symbol - * @throws AutomatonException when symbol is not present in the stack alphabet or it is already in the set - */ - bool addInitialSymbol(const alphabet::Symbol& start); - - - /** - * Adds initial symbol. Initial symbols are symbols that are pushed - * to the stack when NPDA is created. - * @param start new initial symbol - * @throws AutomatonException when symbol is not present in the set of initial symbols - */ - bool removeInitialSymbol(const alphabet::Symbol& start); - - /** - * Sets initial symbols. Initial symbols are symbols that are pushed - * to the stack when NPDA is created. - * @param symbols new initial symbols - * @throws AutomatonException when any of symbols is not present in the stack alphabet - */ - void setInitialSymbols(const std::set<alphabet::Symbol>& symbols); - - /** - * @return list of start symbols - */ - const std::set<alphabet::Symbol>& getInitialSymbols() const; - virtual bool operator==(const AutomatonBase& other) const; virtual bool operator==(const NPDA& other) const; diff --git a/alib2/src/automaton/PDA/SinglePopNPDA.cpp b/alib2/src/automaton/PDA/SinglePopNPDA.cpp index 826e9ea0e0ccb8170c35ff9e19840fe4b37f9916..daf9ec411c6eb9ad2828d1a7de0df73d8d190f51 100644 --- a/alib2/src/automaton/PDA/SinglePopNPDA.cpp +++ b/alib2/src/automaton/PDA/SinglePopNPDA.cpp @@ -50,26 +50,6 @@ bool SinglePopNPDA::removeInputSymbol(const alphabet::Symbol& symbol) { return inputAlphabet.erase(symbol); } -bool SinglePopNPDA::addStackSymbol(const alphabet::Symbol& symbol) { - return stackAlphabet.insert(symbol).second; -} - -void SinglePopNPDA::setStackSymbols(const std::set<alphabet::Symbol>& newSymbols) { - std::set<alphabet::Symbol> removed; - std::set_difference(stackAlphabet.begin(), stackAlphabet.end(), newSymbols.begin(), newSymbols.end(), std::inserter(removed, removed.end())); - - std::set<alphabet::Symbol> added; - std::set_difference(newSymbols.begin(), newSymbols.end(), stackAlphabet.begin(), stackAlphabet.end(), std::inserter(added, added.end())); - - for(const alphabet::Symbol& removedSymbol : removed) { - removeStackSymbol(removedSymbol); - } - - for(const alphabet::Symbol& addedSymbol : added) { - addStackSymbol(addedSymbol); - } -} - bool SinglePopNPDA::removeStackSymbol(const alphabet::Symbol& symbol) { for (std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::set<std::pair<State, std::vector<alphabet::Symbol> > > >::const_iterator transition = transitions.begin(); transition != transitions.end(); transition++) { if (symbol == std::get<2>(transition->first)) @@ -88,10 +68,6 @@ bool SinglePopNPDA::removeStackSymbol(const alphabet::Symbol& symbol) { return stackAlphabet.erase(symbol); } -const std::set<alphabet::Symbol>& SinglePopNPDA::getStackAlphabet() const { - return stackAlphabet; -} - bool SinglePopNPDA::addTransition(const State& from, const alphabet::Symbol& input, const alphabet::Symbol& pop, const State& to, const std::vector<alphabet::Symbol>& push) { if (states.find(from) == states.end()) { throw AutomatonException("State \"" + (std::string) from.getName() + "\" doesn't exist."); @@ -138,31 +114,6 @@ const std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol> return transitions; } -bool SinglePopNPDA::addInitialSymbol(const alphabet::Symbol& start) { - if (stackAlphabet.find(start) == stackAlphabet.end()) { - throw AutomatonException("Stack symbol \"" + (std::string) start + "\" doesn't exist."); - } - - return this->initialSymbols.insert(start).second; -} - -bool SinglePopNPDA::removeInitialSymbol(const alphabet::Symbol& start) { - return this->initialSymbols.erase(start); -} - -void SinglePopNPDA::setInitialSymbols(const std::set<alphabet::Symbol>& symbols) { - std::set<alphabet::Symbol> tmp; - std::set_difference(symbols.begin(), symbols.end(), this->stackAlphabet.begin(), this->stackAlphabet.end(), std::inserter(tmp, tmp.end())); - if(tmp.size() != 0) - throw AutomatonException("Initial symbols not in stack alphabet"); - - this->initialSymbols = symbols; -} - -const std::set<alphabet::Symbol>& SinglePopNPDA::getInitialSymbols() const { - return initialSymbols; -} - bool SinglePopNPDA::operator==(const AutomatonBase& other) const { return other == *this; } diff --git a/alib2/src/automaton/PDA/SinglePopNPDA.h b/alib2/src/automaton/PDA/SinglePopNPDA.h index feee9ee94e025e2d3e664ef4813c7883ab6cfd8a..d3cc5b1629a3dfae91cfbc4e8e3e8a3025686381 100644 --- a/alib2/src/automaton/PDA/SinglePopNPDA.h +++ b/alib2/src/automaton/PDA/SinglePopNPDA.h @@ -14,6 +14,7 @@ #include "../../std/variant.hpp" #include "../AutomatonBase.h" #include "../common/MultiInitialStates.h" +#include "../common/MultiInitialSymbolsPushdownStoreAlphabet.h" #include "../common/InputAlphabet.h" #include "../../alphabet/Symbol.h" #include "../../string/Epsilon.h" @@ -23,11 +24,9 @@ namespace automaton { /** * Push Down Automaton */ -class SinglePopNPDA: public std::element<SinglePopNPDA, AutomatonBase>, public MultiInitialStates, public InputAlphabet { +class SinglePopNPDA: public std::element<SinglePopNPDA, AutomatonBase>, public MultiInitialSymbolsPushdownStoreAlphabet, public MultiInitialStates, public InputAlphabet { protected: - std::set<alphabet::Symbol> stackAlphabet; std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::set<std::pair<State, std::vector<alphabet::Symbol> > > > transitions; - std::set<alphabet::Symbol> initialSymbols; public: virtual AutomatonBase* clone() const; @@ -44,32 +43,9 @@ public: virtual bool removeInputSymbol(const alphabet::Symbol& symbol); /** - * Adds symbol to the stack alphabet. - * @param symbol Symbol to add - * @throws AutomatonException when symbol is already present in stack alphabet + * @copydoc Automaton::removeStackSymbol(const Symbol&) */ - bool addStackSymbol(const alphabet::Symbol& symbol); - - /** - * Sets stack symbols of the automaton. - * @param symbols Symbols to set - * @throws AutomatonException when symbol is already present in stack alphabet - */ - void setStackSymbols(const std::set<alphabet::Symbol>& symbols); - - /** - * Removes symbol from the stack alphabet. - * @param symbol Symbol to remove - * @throws AutomatonException when symbol is used in transition - * (popped from or pushed to the stack), when it is a start symbol - * or when it is not present in the stack alphabet - */ - bool removeStackSymbol(const alphabet::Symbol& symbol); - - /** - * @return the stack alphabet - */ - const std::set<alphabet::Symbol>& getStackAlphabet() const; + virtual bool removeStackSymbol(const alphabet::Symbol& symbol); /** * Adds transition to the SinglePopNPDA. @@ -91,36 +67,6 @@ public: */ const std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::set<std::pair<State, std::vector<alphabet::Symbol> > > >& getTransitions() const; - /** - * Adds initial symbol. Initial symbols are symbols that are pushed - * to the stack when SinglePopNPDA is created. - * @param start new initial symbol - * @throws AutomatonException when symbol is not present in the stack alphabet or it is already in the set - */ - bool addInitialSymbol(const alphabet::Symbol& start); - - - /** - * Adds initial symbol. Initial symbols are symbols that are pushed - * to the stack when SinglePopNPDA is created. - * @param start new initial symbol - * @throws AutomatonException when symbol is not present in the set of initial symbols - */ - bool removeInitialSymbol(const alphabet::Symbol& start); - - /** - * Sets initial symbols. Initial symbols are symbols that are pushed - * to the stack when SinglePopNPDA is created. - * @param symbols new initial symbols - * @throws AutomatonException when any of symbols is not present in the stack alphabet - */ - void setInitialSymbols(const std::set<alphabet::Symbol>& symbols); - - /** - * @return list of start symbols - */ - const std::set<alphabet::Symbol>& getInitialSymbols() const; - virtual bool operator==(const AutomatonBase& other) const; virtual bool operator==(const SinglePopNPDA& other) const; diff --git a/alib2/src/automaton/common/MultiInitialSymbolsPushdownStoreAlphabet.cpp b/alib2/src/automaton/common/MultiInitialSymbolsPushdownStoreAlphabet.cpp new file mode 100644 index 0000000000000000000000000000000000000000..53f69416a7148d6c6c6adea783d8c9fe304b74db --- /dev/null +++ b/alib2/src/automaton/common/MultiInitialSymbolsPushdownStoreAlphabet.cpp @@ -0,0 +1,39 @@ +/* + * MultiInitialSymbols.cpp + * + * Created on: Apr 10, 2013 + * Author: martin + */ + +#include "MultiInitialSymbolsPushdownStoreAlphabet.h" +#include "../AutomatonException.h" +#include <algorithm> + +namespace automaton { + +bool MultiInitialSymbolsPushdownStoreAlphabet::addInitialSymbol(const alphabet::Symbol& start) { + if (stackAlphabet.find(start) == stackAlphabet.end()) { + throw AutomatonException("Stack symbol \"" + (std::string) start + "\" doesn't exist."); + } + + return this->initialSymbols.insert(start).second; +} + +bool MultiInitialSymbolsPushdownStoreAlphabet::removeInitialSymbol(const alphabet::Symbol& start) { + return this->initialSymbols.erase(start); +} + +void MultiInitialSymbolsPushdownStoreAlphabet::setInitialSymbols(const std::set<alphabet::Symbol>& symbols) { + std::set<alphabet::Symbol> tmp; + std::set_difference(symbols.begin(), symbols.end(), this->stackAlphabet.begin(), this->stackAlphabet.end(), std::inserter(tmp, tmp.end())); + if(tmp.size() != 0) + throw AutomatonException("Initial symbols not in stack alphabet"); + + this->initialSymbols = symbols; +} + +const std::set<alphabet::Symbol>& MultiInitialSymbolsPushdownStoreAlphabet::getInitialSymbols() const { + return initialSymbols; +} + +} /* namespace automaton */ diff --git a/alib2/src/automaton/common/MultiInitialSymbolsPushdownStoreAlphabet.h b/alib2/src/automaton/common/MultiInitialSymbolsPushdownStoreAlphabet.h new file mode 100644 index 0000000000000000000000000000000000000000..5f4c26464206e7ecd1a7a1f85e9433c96eccf7f7 --- /dev/null +++ b/alib2/src/automaton/common/MultiInitialSymbolsPushdownStoreAlphabet.h @@ -0,0 +1,58 @@ +/* + * MultiInitialSymbols.h + * + * Created on: Apr 10, 2013 + * Author: martin + */ + +#ifndef MULTI_INITIAL_SYMBOLS_PUSHDOWN_STORE_ALPHABET_H_ +#define MULTI_INITIAL_SYMBOLS_PUSHDOWN_STORE_ALPHABET_H_ + +#include <set> +#include "../../alphabet/Symbol.h" +#include "PushdownStoreAlphabet.h" + +namespace automaton { + +/** + * Push Down Automaton + */ +class MultiInitialSymbolsPushdownStoreAlphabet : public PushdownStoreAlphabet { +protected: + std::set<alphabet::Symbol> initialSymbols; +public: + /** + * Adds initial symbol. Initial symbols are symbols that are pushed + * to the stack when MultiInitialSymbols is created. + * @param start new initial symbol + * @throws AutomatonException when symbol is not present in the stack alphabet or it is already in the set + */ + bool addInitialSymbol(const alphabet::Symbol& start); + + + /** + * Adds initial symbol. Initial symbols are symbols that are pushed + * to the stack when MultiInitialSymbols is created. + * @param start new initial symbol + * @throws AutomatonException when symbol is not present in the set of initial symbols + */ + bool removeInitialSymbol(const alphabet::Symbol& start); + + /** + * Sets initial symbols. Initial symbols are symbols that are pushed + * to the stack when MultiInitialSymbols is created. + * @param symbols new initial symbols + * @throws AutomatonException when any of symbols is not present in the stack alphabet + */ + void setInitialSymbols(const std::set<alphabet::Symbol>& symbols); + + /** + * @return list of start symbols + */ + const std::set<alphabet::Symbol>& getInitialSymbols() const; + +}; + +} /* namespace automaton */ + +#endif /* MULTI_INITIAL_SYMBOLS_PUSHDOWN_STORE_ALPHABET_H_ */ diff --git a/alib2/src/automaton/common/PushdownStoreAlphabet.cpp b/alib2/src/automaton/common/PushdownStoreAlphabet.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e9475f5fde2cbe0452a0a8f58f1068a373ca1f04 --- /dev/null +++ b/alib2/src/automaton/common/PushdownStoreAlphabet.cpp @@ -0,0 +1,38 @@ +/* + * PushdownStoreAlphabet.cpp + * + * Created on: Apr 10, 2013 + * Author: martin + */ + +#include "PushdownStoreAlphabet.h" +#include "../AutomatonException.h" +#include <algorithm> + +namespace automaton { + +bool PushdownStoreAlphabet::addStackSymbol(const alphabet::Symbol& symbol) { + return stackAlphabet.insert(symbol).second; +} + +void PushdownStoreAlphabet::setStackSymbols(const std::set<alphabet::Symbol>& newSymbols) { + std::set<alphabet::Symbol> removed; + std::set_difference(stackAlphabet.begin(), stackAlphabet.end(), newSymbols.begin(), newSymbols.end(), std::inserter(removed, removed.end())); + + std::set<alphabet::Symbol> added; + std::set_difference(newSymbols.begin(), newSymbols.end(), stackAlphabet.begin(), stackAlphabet.end(), std::inserter(added, added.end())); + + for(const alphabet::Symbol& removedSymbol : removed) { + removeStackSymbol(removedSymbol); + } + + for(const alphabet::Symbol& addedSymbol : added) { + addStackSymbol(addedSymbol); + } +} + +const std::set<alphabet::Symbol>& PushdownStoreAlphabet::getStackAlphabet() const { + return stackAlphabet; +} + +} /* namespace automaton */ diff --git a/alib2/src/automaton/common/PushdownStoreAlphabet.h b/alib2/src/automaton/common/PushdownStoreAlphabet.h new file mode 100644 index 0000000000000000000000000000000000000000..2c665173dcc60da52bdbcc8914abc96f2ab1acdc --- /dev/null +++ b/alib2/src/automaton/common/PushdownStoreAlphabet.h @@ -0,0 +1,55 @@ +/* + * PushdownStoreAlphabet.h + * + * Created on: Apr 10, 2013 + * Author: martin + */ + +#ifndef PUSHDOWN_STORE_ALPHABET_H_ +#define PUSHDOWN_STORE_ALPHABET_H_ + +#include <set> +#include "../../alphabet/Symbol.h" + +namespace automaton { + +/** + * Push Down Automaton + */ +class PushdownStoreAlphabet { +protected: + std::set<alphabet::Symbol> stackAlphabet; +public: + /** + * Adds symbol to the stack alphabet. + * @param symbol Symbol to add + * @throws AutomatonException when symbol is already present in stack alphabet + */ + bool addStackSymbol(const alphabet::Symbol& symbol); + + /** + * Sets stack symbols of the automaton. + * @param symbols Symbols to set + * @throws AutomatonException when symbol is already present in stack alphabet + */ + void setStackSymbols(const std::set<alphabet::Symbol>& symbols); + + /** + * Removes symbol from the stack alphabet. + * @param symbol Symbol to remove + * @throws AutomatonException when symbol is used in transition + * (popped from or pushed to the stack), when it is a start symbol + * or when it is not present in the stack alphabet + */ + virtual bool removeStackSymbol(const alphabet::Symbol& symbol) = 0; + + /** + * @return the stack alphabet + */ + const std::set<alphabet::Symbol>& getStackAlphabet() const; + +}; + +} /* namespace automaton */ + +#endif /* PUSHDOWN_STORE_ALPHABET_H_ */ diff --git a/alib2/src/automaton/common/SingleInitialSymbolPushdownStoreAlphabet.cpp b/alib2/src/automaton/common/SingleInitialSymbolPushdownStoreAlphabet.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c8532e2e2edb75db0f6d4460a0198087e3d9e0c8 --- /dev/null +++ b/alib2/src/automaton/common/SingleInitialSymbolPushdownStoreAlphabet.cpp @@ -0,0 +1,30 @@ +/* + * SingleInitialSymbolPushdownStore.cpp + * + * Created on: Apr 10, 2013 + * Author: martin + */ + +#include "SingleInitialSymbolPushdownStoreAlphabet.h" +#include "../AutomatonException.h" +#include <algorithm> + +namespace automaton { + +SingleInitialSymbolPushdownStoreAlphabet::SingleInitialSymbolPushdownStoreAlphabet(const alphabet::Symbol& initialSymbol) : initialSymbol(initialSymbol) { + addStackSymbol(initialSymbol); +} + +void SingleInitialSymbolPushdownStoreAlphabet::setInitialSymbol(const alphabet::Symbol& start) { + if (stackAlphabet.find(start) == stackAlphabet.end()) { + throw AutomatonException("Stack symbol \"" + (std::string) start + "\" doesn't exist."); + } + + initialSymbol = start; +} + +const alphabet::Symbol& SingleInitialSymbolPushdownStoreAlphabet::getInitialSymbol() const { + return initialSymbol; +} + +} /* namespace automaton */ diff --git a/alib2/src/automaton/common/SingleInitialSymbolPushdownStoreAlphabet.h b/alib2/src/automaton/common/SingleInitialSymbolPushdownStoreAlphabet.h new file mode 100644 index 0000000000000000000000000000000000000000..911b8bb7405d83bf251eb6ef7d20864ac46b68db --- /dev/null +++ b/alib2/src/automaton/common/SingleInitialSymbolPushdownStoreAlphabet.h @@ -0,0 +1,44 @@ +/* + * SingleInitialSymbolPushdownStore.h + * + * Created on: Apr 10, 2013 + * Author: martin + */ + +#ifndef SINGLE_INITIAL_SYMBOL_PUSHDOWN_STORE_ALPHABET_H_ +#define SINGLE_INITIAL_SYMBOL_PUSHDOWN_STORE_ALPHABET_H_ + +#include <set> +#include "../../alphabet/Symbol.h" +#include "PushdownStoreAlphabet.h" + +namespace automaton { + +/** + * Push Down Automaton + */ +class SingleInitialSymbolPushdownStoreAlphabet : public PushdownStoreAlphabet { +protected: + alphabet::Symbol initialSymbol; +public: + SingleInitialSymbolPushdownStoreAlphabet(const alphabet::Symbol& initialSymbol); + + /** + * Set initial symbol. Initial symbol is symbol that is pushed + * to the stack when SingleInitialSymbolPushdownStore is created. + * @param start new initial symbol + * @throws AutomatonException when symbol is not present in the stack alphabet + */ + void setInitialSymbol(const alphabet::Symbol& start); + + + /** + * @return list of start symbols + */ + const alphabet::Symbol& getInitialSymbol() const; + +}; + +} /* namespace automaton */ + +#endif /* SINGLE_INITIAL_SYMBOL_PUSHDOWN_STORE_ALPHABET_H_ */