/* * ToRegExpStateElimination.h * * Created on: 9. 2. 2014 * Author: Tomas Pecka */ #ifndef TO_REG_EXP_STATE_ELIMINATION_H_ #define TO_REG_EXP_STATE_ELIMINATION_H_ #include <core/multipleDispatch.hpp> #include <regexp/RegExp.h> #include <regexp/unbounded/UnboundedRegExp.h> #include <automaton/Automaton.h> #include <automaton/FSM/DFA.h> #include <automaton/FSM/NFA.h> #include <automaton/FSM/MultiInitialStateNFA.h> #include <automaton/FSM/EpsilonNFA.h> #include <automaton/FSM/ExtendedNFA.h> namespace automaton { namespace convert { /** * Converts FSM to RE using State Elimination algorithm. * Source: Melichar 2.118 */ class ToRegExpStateElimination : public std::SingleDispatch<ToRegExpStateElimination, regexp::RegExp, const automaton::AutomatonBase &> { public: /** * Performs conversion. * @param automaton automaton to convert * @return regular expression equivalent to source NFA. */ static regexp::RegExp convert(const automaton::Automaton& automaton); template<class T> static regexp::UnboundedRegExp < > convert(const T& automaton); private: static void extendExtendedNFA(automaton::ExtendedNFA < > & automaton); static const regexp::UnboundedRegExpStructure < alphabet::Symbol > transition(const automaton::ExtendedNFA < > & automaton, const label::Label& from, const label::Label& to); static automaton::ExtendedNFA < > eliminateState(const automaton::ExtendedNFA < > & extendedAutomaton, const label::Label& state); }; } /* namespace convert */ } /* namespace automaton */ #endif /* TO_REG_EXP_STATE_ELIMINATION_H_ */