Skip to content
Snippets Groups Projects
Commit 1d89fcc0 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

+explicit to all constructors; parse/compose State

parent b3a26853
No related branches found
No related tags found
No related merge requests found
Showing
with 47 additions and 19 deletions
......@@ -250,6 +250,14 @@ std::list<sax::Token> api<automaton::OneTapeDTM>::compose(const automaton::OneTa
return ToXMLComposers::automatonComposer.compose(data);
}
 
automaton::State api<automaton::State>::parse(std::list<sax::Token>& input) {
return FromXMLParsers::automatonParser.parseState(input);
}
std::list<sax::Token> api<automaton::State>::compose(const automaton::State& data) {
return ToXMLComposers::automatonComposer.compose(data);
}
 
grammar::Grammar api<grammar::Grammar>::parse(std::list<sax::Token>& input) {
return FromXMLParsers::grammarParser.parseGrammar(input);
......
......@@ -222,6 +222,11 @@ struct api<automaton::OneTapeDTM> {
static std::list<sax::Token> compose(const automaton::OneTapeDTM& data);
};
 
template<>
struct api<automaton::State> {
static automaton::State parse(std::list<sax::Token>& input);
static std::list<sax::Token> compose(const automaton::State& data);
};
 
template<>
struct api<grammar::Grammar> {
......
......@@ -21,7 +21,7 @@ public:
* Creates a blank symbol.
* @param symbol name of the symbol
*/
BlankSymbol();
explicit BlankSymbol();
 
virtual SymbolBase* clone() const;
virtual SymbolBase* plunder() &&;
......
......@@ -21,7 +21,7 @@ public:
* Creates a blank symbol.
* @param symbol name of the symbol
*/
BottomOfTheStackSymbol();
explicit BottomOfTheStackSymbol();
 
virtual SymbolBase* clone() const;
virtual SymbolBase* plunder() &&;
......
......@@ -21,7 +21,7 @@ public:
* Creates a blank symbol.
* @param symbol name of the symbol
*/
EndSymbol();
explicit EndSymbol();
 
virtual SymbolBase* clone() const;
virtual SymbolBase* plunder() &&;
......
......@@ -435,12 +435,16 @@ std::set<State> AutomatonFromXMLParser::parseStates(std::list<sax::Token> &input
std::set<State> states;
popToken(input, sax::Token::TokenType::START_ELEMENT, "states");
while (isTokenType(input, sax::Token::TokenType::START_ELEMENT)) {
states.insert(State(alib::api<label::Label>::parse(input)));
states.insert(parseState(input));
}
popToken(input, sax::Token::TokenType::END_ELEMENT, "states");
return states;
}
 
State AutomatonFromXMLParser::parseState(std::list<sax::Token> &input) const {
return State(alib::api<label::Label>::parse(input));
}
std::set<alphabet::Symbol> AutomatonFromXMLParser::parseCallInputAlphabet(std::list<sax::Token> &input) const {
std::set<alphabet::Symbol> inputSymbols;
popToken(input, sax::Token::TokenType::START_ELEMENT, "callInputAlphabet");
......
......@@ -45,6 +45,7 @@ namespace automaton {
*/
class AutomatonFromXMLParser : public sax::FromXMLParserHelper {
std::set<State> parseStates(std::list<sax::Token> &input) const;
State parseState(std::list<sax::Token> &input) const;
std::set<alphabet::Symbol> parseInputAlphabet(std::list<sax::Token> &input) const;
std::set<alphabet::Symbol> parseCallInputAlphabet(std::list<sax::Token> &input) const;
std::set<alphabet::Symbol> parseReturnInputAlphabet(std::list<sax::Token> &input) const;
......
......@@ -776,5 +776,11 @@ std::list<sax::Token> AutomatonToXMLComposer::compose(const OneTapeDTM& automato
return out;
}
 
std::list<sax::Token> AutomatonToXMLComposer::compose(const State& state) const {
std::list<sax::Token> out;
out.splice(out.end(), alib::api<label::Label>::compose(state.getName()));
return out;
}
} /* namespace automaton */
 
......@@ -106,6 +106,8 @@ class AutomatonToXMLComposer {
std::list<sax::Token> compose(const SinglePopNPDA& automaton) const;
std::list<sax::Token> compose(const OneTapeDTM& automaton) const;
 
std::list<sax::Token> compose(const State& state) const;
template<typename T> friend class alib::api;
};
 
......
......@@ -24,7 +24,7 @@ class DFA : public std::acceptor<DFA, VisitableAutomatonBase, std::acceptor<DFA,
protected:
std::map<std::pair<State, alphabet::Symbol>, State> transitions;
public:
DFA(const State& initialState);
explicit DFA(const State& initialState);
 
virtual AutomatonBase* clone() const;
......
......@@ -32,7 +32,7 @@ class DPDA : public std::acceptor<DPDA, VisitableAutomatonBase, std::acceptor<DP
protected:
std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<State, std::vector<alphabet::Symbol> > > transitions;
public:
DPDA(const State& initialState, const alphabet::Symbol& initialPushdownSymbol);
explicit DPDA(const State& initialState, const alphabet::Symbol& initialPushdownSymbol);
 
virtual AutomatonBase* clone() const;
......
......@@ -27,7 +27,7 @@ protected:
std::map<std::pair<State, alphabet::Symbol>, std::set<State> > transitions;
std::map<alphabet::Symbol, std::pair<std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol>>> inputSymbolToPushdownStoreOperation;
public:
InputDrivenNPDA(const alphabet::Symbol& initialPushdownSymbol);
explicit InputDrivenNPDA(const alphabet::Symbol& initialPushdownSymbol);
 
virtual AutomatonBase* clone() const;
......
......@@ -31,7 +31,7 @@ protected:
std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::set<State> > returnTransitions;
std::map<std::pair<State, std::variant<string::Epsilon, alphabet::Symbol>>, std::set<State> > localTransitions;
public:
RealTimeHeightDeterministicNPDA(const alphabet::Symbol& bottomOfTheStackSymbol);
explicit RealTimeHeightDeterministicNPDA(const alphabet::Symbol& bottomOfTheStackSymbol);
 
virtual AutomatonBase* clone() const;
......
......@@ -32,7 +32,7 @@ class SinglePopDPDA: public std::acceptor<SinglePopDPDA, VisitableAutomatonBase,
protected:
std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::pair<State, std::vector<alphabet::Symbol> > > transitions;
public:
SinglePopDPDA(const State& initialState, const alphabet::Symbol& initialPushdownSymbol);
explicit SinglePopDPDA(const State& initialState, const alphabet::Symbol& initialPushdownSymbol);
 
virtual AutomatonBase* clone() const;
......
......@@ -29,7 +29,7 @@ protected:
std::map<std::tuple<State, alphabet::Symbol, alphabet::Symbol>, std::set<State> > returnTransitions;
std::map<std::pair<State, alphabet::Symbol>, std::set<State> > localTransitions;
public:
VisiblyPushdownNPDA(const alphabet::Symbol& bottomOfTheStackSymbol);
explicit VisiblyPushdownNPDA(const alphabet::Symbol& bottomOfTheStackSymbol);
 
virtual AutomatonBase* clone() const;
......
......@@ -27,11 +27,11 @@ protected:
std::map<std::pair<State, alphabet::Symbol>, std::tuple<State, alphabet::Symbol, Shift> > transitions;
 
public:
explicit OneTapeDTM(const State& initialState, const alphabet::Symbol& blank);
virtual AutomatonBase* clone() const;
virtual AutomatonBase* plunder() &&;
 
OneTapeDTM(const State& initialState, const alphabet::Symbol& blank);
virtual AutomatonBase* plunder() &&;
 
/**
* @copydoc Automaton::removeState(const State&)
......
......@@ -34,7 +34,8 @@ protected:
 
std::set<UnknownTransition> transitions;
public:
UnknownAutomaton();
explicit UnknownAutomaton();
//TODO destructor and operator= and copy constructor
~UnknownAutomaton() noexcept;
 
......
......@@ -35,9 +35,10 @@ protected:
Shift shift;
 
public:
UnknownTransition();
UnknownTransition(const State& from, const State& to, const std::vector<alphabet::Symbol>& pop, const std::vector<alphabet::Symbol>& push, const std::variant<string::Epsilon, alphabet::Symbol>& input, const std::variant<string::Epsilon, alphabet::Symbol>& output, Shift shift);
explicit UnknownTransition();
explicit UnknownTransition(const State& from, const State& to, const std::vector<alphabet::Symbol>& pop, const std::vector<alphabet::Symbol>& push, const std::variant<string::Epsilon, alphabet::Symbol>& input, const std::variant<string::Epsilon, alphabet::Symbol>& output, Shift shift);
~UnknownTransition();
 
/**
......
......@@ -22,7 +22,7 @@ namespace container {
*/
class ObjectsPair : public std::pair<alib::Object, alib::Object>, public std::acceptor<ObjectsPair, VisitableContainerBase, std::acceptor<ObjectsPair, alib::VisitableObjectBase, ContainerBase> > {
public:
ObjectsPair(const alib::Object& first, const alib::Object& second);
explicit ObjectsPair(const alib::Object& first, const alib::Object& second);
 
virtual ContainerBase* clone() const;
......
......@@ -23,7 +23,7 @@ AlibException::AlibException ( ) {
this->whatMessage += this->backtrace;
}
 
AlibException::AlibException ( const std::string & cause ) : AlibException() {
AlibException::AlibException ( const std::string & cause ) : AlibException { } {
this->cause = cause;
this->whatMessage += this->cause;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment