From ce79e836ae8d3cd150923dea0af1e173df677ef1 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Sat, 2 Feb 2019 20:41:01 +0100 Subject: [PATCH] user documentation of automata run algos --- alib2algo/src/automaton/run/Accept.cpp | 79 ++++++++++-- alib2algo/src/automaton/run/Occurrences.cpp | 47 +++++++- alib2algo/src/automaton/run/Result.cpp | 103 ++++++++++++++-- alib2algo/src/automaton/run/Translate.cpp | 43 ++++--- alib2algo/src/automaton/run/Translate.h | 126 ++++++++++---------- 5 files changed, 287 insertions(+), 111 deletions(-) diff --git a/alib2algo/src/automaton/run/Accept.cpp b/alib2algo/src/automaton/run/Accept.cpp index 725e85f854..3f1e273540 100644 --- a/alib2algo/src/automaton/run/Accept.cpp +++ b/alib2algo/src/automaton/run/Accept.cpp @@ -12,16 +12,75 @@ namespace automaton { namespace run { -auto AcceptDFALinearString = registration::AbstractRegister < Accept, bool, const automaton::DFA < > &, const string::LinearString < > & > ( Accept::accept ); -auto AcceptNFALinearString = registration::AbstractRegister < Accept, bool, const automaton::NFA < > &, const string::LinearString < > & > ( Accept::accept ); -auto AcceptEpsilonNFALinearString = registration::AbstractRegister < Accept, bool, const automaton::EpsilonNFA < > &, const string::LinearString < > & > ( Accept::accept ); -auto AcceptDFTARankedTree = registration::AbstractRegister < Accept, bool, const automaton::DFTA < > &, const tree::RankedTree < > & > ( Accept::accept ); -auto AcceptNFTARankedTree = registration::AbstractRegister < Accept, bool, const automaton::NFTA < > &, const tree::RankedTree < > & > ( Accept::accept ); -auto AcceptInputDrivenDPDALinearString = registration::AbstractRegister < Accept, bool, const automaton::InputDrivenDPDA < > &, const string::LinearString < > & > ( Accept::accept ); -auto AcceptVisiblyPushdownDPDALinearString = registration::AbstractRegister < Accept, bool, const automaton::VisiblyPushdownDPDA < > &, const string::LinearString < > & > ( Accept::accept ); -auto AcceptRealTimeHeightDeterministicDPDALinearString = registration::AbstractRegister < Accept, bool, const automaton::RealTimeHeightDeterministicDPDA < > &, const string::LinearString < > & > ( Accept::accept ); -auto AcceptDPDALinearString = registration::AbstractRegister < Accept, bool, const automaton::DPDA < > &, const string::LinearString < > & > ( Accept::accept ); -auto AcceptNPDTALinearString = registration::AbstractRegister < Accept, bool, const automaton::NPDTA < > &, const string::LinearString < > & > ( Accept::accept ); +auto AcceptDFALinearString = registration::AbstractRegister < Accept, bool, const automaton::DFA < > &, const string::LinearString < > & > ( Accept::accept, "automaton", "string" ).setDocumentation ( +"Automaton run implementation resulting in boolean true if the automaton accepted the input.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return true if the automaton accepts given string" ); + +auto AcceptNFALinearString = registration::AbstractRegister < Accept, bool, const automaton::NFA < > &, const string::LinearString < > & > ( Accept::accept, "automaton", "string" ).setDocumentation ( +"Automaton run implementation resulting in boolean true if the automaton accepted the input.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return true if the automaton accepts given string" ); + +auto AcceptEpsilonNFALinearString = registration::AbstractRegister < Accept, bool, const automaton::EpsilonNFA < > &, const string::LinearString < > & > ( Accept::accept, "automaton", "string" ).setDocumentation ( +"Automaton run implementation resulting in boolean true if the automaton accepted the input.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return true if the automaton accepts given string" ); + +auto AcceptDFTARankedTree = registration::AbstractRegister < Accept, bool, const automaton::DFTA < > &, const tree::RankedTree < > & > ( Accept::accept, "automaton", "tree" ).setDocumentation ( +"Automaton run implementation resulting in boolean true if the automaton accepted the input.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return true if the automaton accepts given string" ); + +auto AcceptNFTARankedTree = registration::AbstractRegister < Accept, bool, const automaton::NFTA < > &, const tree::RankedTree < > & > ( Accept::accept, "automaton", "tree" ).setDocumentation ( +"Automaton run implementation resulting in boolean true if the automaton accepted the input.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return true if the automaton accepts given string" ); + +auto AcceptInputDrivenDPDALinearString = registration::AbstractRegister < Accept, bool, const automaton::InputDrivenDPDA < > &, const string::LinearString < > & > ( Accept::accept, "automaton", "string" ).setDocumentation ( +"Automaton run implementation resulting in boolean true if the automaton accepted the input.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return true if the automaton accepts given string" ); + +auto AcceptVisiblyPushdownDPDALinearString = registration::AbstractRegister < Accept, bool, const automaton::VisiblyPushdownDPDA < > &, const string::LinearString < > & > ( Accept::accept, "automaton", "string" ).setDocumentation ( +"Automaton run implementation resulting in boolean true if the automaton accepted the input.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return true if the automaton accepts given string" ); + +auto AcceptRealTimeHeightDeterministicDPDALinearString = registration::AbstractRegister < Accept, bool, const automaton::RealTimeHeightDeterministicDPDA < > &, const string::LinearString < > & > ( Accept::accept, "automaton", "string" ).setDocumentation ( +"Automaton run implementation resulting in boolean true if the automaton accepted the input.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return true if the automaton accepts given string" ); + +auto AcceptDPDALinearString = registration::AbstractRegister < Accept, bool, const automaton::DPDA < > &, const string::LinearString < > & > ( Accept::accept, "automaton", "string" ).setDocumentation ( +"Automaton run implementation resulting in boolean true if the automaton accepted the input.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return true if the automaton accepts given string" ); + +auto AcceptNPDTALinearString = registration::AbstractRegister < Accept, bool, const automaton::NPDTA < > &, const string::LinearString < > & > ( Accept::accept, "automaton", "string" ).setDocumentation ( +"Automaton run implementation resulting in boolean true if the automaton accepted the input.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return true if the automaton accepts given string" ); } /* namespace run */ diff --git a/alib2algo/src/automaton/run/Occurrences.cpp b/alib2algo/src/automaton/run/Occurrences.cpp index fe57243339..2632372ddc 100644 --- a/alib2algo/src/automaton/run/Occurrences.cpp +++ b/alib2algo/src/automaton/run/Occurrences.cpp @@ -12,12 +12,47 @@ namespace automaton { namespace run { -auto OccurrencesDFALinearString = registration::AbstractRegister < Occurrences, ext::set < unsigned >, const automaton::DFA < > &, const string::LinearString < > & > ( Occurrences::occurrences ); -auto OccurrencesDFTARankedTree = registration::AbstractRegister < Occurrences, ext::set < unsigned >, const automaton::DFTA < > &, const tree::RankedTree < > & > ( Occurrences::occurrences ); -auto OccurrencesInputDrivenDPDALinearString = registration::AbstractRegister < Occurrences, ext::set < unsigned >, const automaton::InputDrivenDPDA < > &, const string::LinearString < > & > ( Occurrences::occurrences ); -auto OccurrencesVisiblyPushdownDPDALinearString = registration::AbstractRegister < Occurrences, ext::set < unsigned >, const automaton::VisiblyPushdownDPDA < > &, const string::LinearString < > & > ( Occurrences::occurrences ); -auto OccurrencesRealTimeHeightDeterministicDPDALinearString = registration::AbstractRegister < Occurrences, ext::set < unsigned >, const automaton::RealTimeHeightDeterministicDPDA < > &, const string::LinearString < > & > ( Occurrences::occurrences ); -auto OccurrencesDPDALinearString = registration::AbstractRegister < Occurrences, ext::set < unsigned >, const automaton::DPDA < > &, const string::LinearString < > & > ( Occurrences::occurrences ); +auto OccurrencesDFALinearString = registration::AbstractRegister < Occurrences, ext::set < unsigned >, const automaton::DFA < > &, const string::LinearString < > & > ( Occurrences::occurrences, "automaton", "string" ).setDocumentation ( +"Automaton occurrences run implementation.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return set of indexes to the string where the automaton passed a final state" ); + +auto OccurrencesDFTARankedTree = registration::AbstractRegister < Occurrences, ext::set < unsigned >, const automaton::DFTA < > &, const tree::RankedTree < > & > ( Occurrences::occurrences, "automaton", "tree" ).setDocumentation ( +"Automaton occurrences run implementation.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return set of indexes to the string where the automaton passed a final state" ); + +auto OccurrencesInputDrivenDPDALinearString = registration::AbstractRegister < Occurrences, ext::set < unsigned >, const automaton::InputDrivenDPDA < > &, const string::LinearString < > & > ( Occurrences::occurrences, "automaton", "string" ).setDocumentation ( +"Automaton occurrences run implementation.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return set of indexes to the string where the automaton passed a final state" ); + +auto OccurrencesVisiblyPushdownDPDALinearString = registration::AbstractRegister < Occurrences, ext::set < unsigned >, const automaton::VisiblyPushdownDPDA < > &, const string::LinearString < > & > ( Occurrences::occurrences, "automaton", "string" ).setDocumentation ( +"Automaton occurrences run implementation.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return set of indexes to the string where the automaton passed a final state" ); + +auto OccurrencesRealTimeHeightDeterministicDPDALinearString = registration::AbstractRegister < Occurrences, ext::set < unsigned >, const automaton::RealTimeHeightDeterministicDPDA < > &, const string::LinearString < > & > ( Occurrences::occurrences, "automaton", "string" ).setDocumentation ( +"Automaton occurrences run implementation.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return set of indexes to the string where the automaton passed a final state" ); + +auto OccurrencesDPDALinearString = registration::AbstractRegister < Occurrences, ext::set < unsigned >, const automaton::DPDA < > &, const string::LinearString < > & > ( Occurrences::occurrences, "automaton", "string" ).setDocumentation ( +"Automaton occurrences run implementation.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return set of indexes to the string where the automaton passed a final state" ); } /* namespace run */ diff --git a/alib2algo/src/automaton/run/Result.cpp b/alib2algo/src/automaton/run/Result.cpp index ea862e291a..04356157f1 100644 --- a/alib2algo/src/automaton/run/Result.cpp +++ b/alib2algo/src/automaton/run/Result.cpp @@ -12,19 +12,96 @@ namespace automaton { namespace run { -auto ResultDFALinearString = registration::AbstractRegister < Result, DefaultStateType, const automaton::DFA < > &, const string::LinearString < > & > ( Result::result ); -auto ResultDFTARankedTree = registration::AbstractRegister < Result, DefaultStateType, const automaton::DFTA < > &, const tree::RankedTree < > & > ( Result::result ); -auto ResultInputDrivenDPDALinearString = registration::AbstractRegister < Result, DefaultStateType, const automaton::InputDrivenDPDA < > &, const string::LinearString < > & > ( Result::result ); -auto ResultVisiblyPushdownDPDALinearString = registration::AbstractRegister < Result, DefaultStateType, const automaton::VisiblyPushdownDPDA < > &, const string::LinearString < > & > ( Result::result ); -auto ResultRealTimeHeightDeterministicDPDALinearString = registration::AbstractRegister < Result, DefaultStateType, const automaton::RealTimeHeightDeterministicDPDA < > &, const string::LinearString < > & > ( Result::result ); -auto ResultDPDALinearString = registration::AbstractRegister < Result, DefaultStateType, const automaton::DPDA < > &, const string::LinearString < > & > ( Result::result ); - -auto ResultDFALinearString2 = registration::AbstractRegister < Result, DefaultStateType, const automaton::DFA < > &, const string::LinearString < > &, const DefaultStateType & > ( Result::result ); -auto ResultDFTARankedTree2 = registration::AbstractRegister < Result, DefaultStateType, const automaton::DFTA < > &, const tree::RankedTree < > &, const DefaultStateType & > ( Result::result ); -auto ResultInputDrivenDPDALinearString2 = registration::AbstractRegister < Result, DefaultStateType, const automaton::InputDrivenDPDA < > &, const string::LinearString < > &, const DefaultStateType & > ( Result::result ); -auto ResultVisiblyPushdownDPDALinearString2 = registration::AbstractRegister < Result, DefaultStateType, const automaton::VisiblyPushdownDPDA < > &, const string::LinearString < > &, const DefaultStateType & > ( Result::result ); -auto ResultRealTimeHeightDeterministicDPDALinearString2 = registration::AbstractRegister < Result, DefaultStateType, const automaton::RealTimeHeightDeterministicDPDA < > &, const string::LinearString < > &, const DefaultStateType & > ( Result::result ); -auto ResultDPDALinearString2 = registration::AbstractRegister < Result, DefaultStateType, const automaton::DPDA < > &, const string::LinearString < > &, const DefaultStateType & > ( Result::result ); +auto ResultDFALinearString = registration::AbstractRegister < Result, DefaultStateType, const automaton::DFA < > &, const string::LinearString < > & > ( Result::result, "automaton", "string" ).setDocumentation ( +"General automaton run implementation resulting in the reached state. Generic fail state is returned if the automaton's transition function was not defined for the input.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return state where the run stopped" ); + +auto ResultDFTARankedTree = registration::AbstractRegister < Result, DefaultStateType, const automaton::DFTA < > &, const tree::RankedTree < > & > ( Result::result, "automaton", "tree" ).setDocumentation ( +"General automaton run implementation resulting in the reached state. Generic fail state is returned if the automaton's transition function was not defined for the input.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return state where the run stopped" ); + +auto ResultInputDrivenDPDALinearString = registration::AbstractRegister < Result, DefaultStateType, const automaton::InputDrivenDPDA < > &, const string::LinearString < > & > ( Result::result, "automaton", "string" ).setDocumentation ( +"General automaton run implementation resulting in the reached state. Generic fail state is returned if the automaton's transition function was not defined for the input.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return state where the run stopped" ); + +auto ResultVisiblyPushdownDPDALinearString = registration::AbstractRegister < Result, DefaultStateType, const automaton::VisiblyPushdownDPDA < > &, const string::LinearString < > & > ( Result::result, "automaton", "string" ).setDocumentation ( +"General automaton run implementation resulting in the reached state. Generic fail state is returned if the automaton's transition function was not defined for the input.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return state where the run stopped" ); + +auto ResultRealTimeHeightDeterministicDPDALinearString = registration::AbstractRegister < Result, DefaultStateType, const automaton::RealTimeHeightDeterministicDPDA < > &, const string::LinearString < > & > ( Result::result, "automaton", "string" ).setDocumentation ( +"General automaton run implementation resulting in the reached state. Generic fail state is returned if the automaton's transition function was not defined for the input.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return state where the run stopped" ); + +auto ResultDPDALinearString = registration::AbstractRegister < Result, DefaultStateType, const automaton::DPDA < > &, const string::LinearString < > & > ( Result::result, "automaton", "string" ).setDocumentation ( +"General automaton run implementation resulting in the reached state. Generic fail state is returned if the automaton's transition function was not defined for the input.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return state where the run stopped" ); + + +auto ResultDFALinearString2 = registration::AbstractRegister < Result, DefaultStateType, const automaton::DFA < > &, const string::LinearString < > &, const DefaultStateType & > ( Result::result, "automaton", "string", "fail" ).setDocumentation ( +"General automaton run implementation resulting in the reached state. Generic fail state is returned if the automaton's transition function was not defined for the input.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@param fail the state to use when transition function is not defined for the input\n\ +@return state where the run stopped" ); + +auto ResultDFTARankedTree2 = registration::AbstractRegister < Result, DefaultStateType, const automaton::DFTA < > &, const tree::RankedTree < > &, const DefaultStateType & > ( Result::result, "automaton", "tree", "fail" ).setDocumentation ( +"General automaton run implementation resulting in the reached state. Generic fail state is returned if the automaton's transition function was not defined for the input.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@param fail the state to use when transition function is not defined for the input\n\ +@return state where the run stopped" ); + +auto ResultInputDrivenDPDALinearString2 = registration::AbstractRegister < Result, DefaultStateType, const automaton::InputDrivenDPDA < > &, const string::LinearString < > &, const DefaultStateType & > ( Result::result, "automaton", "string", "fail" ).setDocumentation ( +"General automaton run implementation resulting in the reached state. Generic fail state is returned if the automaton's transition function was not defined for the input.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@param fail the state to use when transition function is not defined for the input\n\ +@return state where the run stopped" ); + +auto ResultVisiblyPushdownDPDALinearString2 = registration::AbstractRegister < Result, DefaultStateType, const automaton::VisiblyPushdownDPDA < > &, const string::LinearString < > &, const DefaultStateType & > ( Result::result, "automaton", "string", "fail" ).setDocumentation ( +"General automaton run implementation resulting in the reached state. Generic fail state is returned if the automaton's transition function was not defined for the input.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@param fail the state to use when transition function is not defined for the input\n\ +@return state where the run stopped" ); + +auto ResultRealTimeHeightDeterministicDPDALinearString2 = registration::AbstractRegister < Result, DefaultStateType, const automaton::RealTimeHeightDeterministicDPDA < > &, const string::LinearString < > &, const DefaultStateType & > ( Result::result, "automaton", "string", "fail" ).setDocumentation ( +"General automaton run implementation resulting in the reached state. Generic fail state is returned if the automaton's transition function was not defined for the input.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@param fail the state to use when transition function is not defined for the input\n\ +@return state where the run stopped" ); + +auto ResultDPDALinearString2 = registration::AbstractRegister < Result, DefaultStateType, const automaton::DPDA < > &, const string::LinearString < > &, const DefaultStateType & > ( Result::result, "automaton", "string", "fail" ).setDocumentation ( +"General automaton run implementation resulting in the reached state. Generic fail state is returned if the automaton's transition function was not defined for the input.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@param fail the state to use when transition function is not defined for the input\n\ +@return state where the run stopped" ); } /* namespace run */ diff --git a/alib2algo/src/automaton/run/Translate.cpp b/alib2algo/src/automaton/run/Translate.cpp index c1b605fa57..8a094a0eac 100644 --- a/alib2algo/src/automaton/run/Translate.cpp +++ b/alib2algo/src/automaton/run/Translate.cpp @@ -1,19 +1,24 @@ -/* - * Translate.cpp - * - * Created on: 12. 5. 2016 - * Author: Jakub Doupal - */ - -#include "Translate.h" -#include <registration/AlgoRegistration.hpp> - -namespace automaton { - -namespace run { - -auto TranslateNPDTALinearString = registration::AbstractRegister < Translate, ext::set < string::LinearString < > >, const automaton::NPDTA < > &, const string::LinearString < > & > ( Translate::translate ); - -} /* namespace run */ - -} /* namespace automaton */ +/* + * Translate.cpp + * + * Created on: 12. 5. 2016 + * Author: Jakub Doupal + */ + +#include "Translate.h" +#include <registration/AlgoRegistration.hpp> + +namespace automaton { + +namespace run { + +auto TranslateNPDTALinearString = registration::AbstractRegister < Translate, ext::set < string::LinearString < > >, const automaton::NPDTA < > &, const string::LinearString < > & > ( Translate::translate, "automaton", "string" ).setDocumentation ( +"Implementation of a run of an automaton that is producing output.\n\ +\n\ +@param automaton the runned automaton\n\ +@param string the input of the automaton\n\ +@return set of strings representing the translations" ); + +} /* namespace run */ + +} /* namespace automaton */ diff --git a/alib2algo/src/automaton/run/Translate.h b/alib2algo/src/automaton/run/Translate.h index 315926cf8c..4f4cfaa204 100644 --- a/alib2algo/src/automaton/run/Translate.h +++ b/alib2algo/src/automaton/run/Translate.h @@ -1,63 +1,63 @@ -/* - * Translate.h - * - * Created on: 12. 5. 2016 - * Author: Jakub Doupal - */ - -#ifndef _AUTOMATON_TRANSLATE_H__ -#define _AUTOMATON_TRANSLATE_H__ - -#include <string/LinearString.h> - -#include "Run.h" -#include <automaton/PDA/NPDTA.h> - -#include <alib/deque> -#include <alib/set> - -namespace automaton { - -namespace run { - -/** - * \brief - * Implementation of transducer run over its input. - */ -class Translate { -public: - /** - * \override - * - * \tparam InputSymbolType type of input symbols of the string and terminal symbols of the runned automaton - * \tparam OutputSymbolType type of output symbols of the runned automaton - * \tparam EpsilonType type of epsilon in the runned automaton - * \tparam PushdownStoreSymbolType type of pushdown store symbols of the runned automaton - * \tparam StateType type of states of the runned automaton - * - * \param automaton the runned automaton - * \param string the input of the automaton - * - * \return set of strings representing the translations - */ - template < class InputSymbolType, class OutputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > - static ext::set < string::LinearString < OutputSymbolType > > translate ( const automaton::NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const string::LinearString < InputSymbolType > & string ); - -}; - -template < class InputSymbolType, class OutputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -ext::set < string::LinearString < OutputSymbolType > > Translate::translate ( const automaton::NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const string::LinearString < InputSymbolType > & string ) { - ext::tuple < bool, ext::set < StateType >, ext::set < ext::vector < OutputSymbolType > > > res = Run::calculateStates ( automaton, string ); - ext::set < string::LinearString < OutputSymbolType > > strings; - - for ( const auto & rawString : std::get < 2 > ( res ) ) - strings . insert ( string::LinearString < OutputSymbolType > ( rawString ) ); - - return strings; -} - -} /* namespace run */ - -} /* namespace automaton */ - -#endif /* _AUTOMATON_TRANSLATE_H__ */ +/* + * Translate.h + * + * Created on: 12. 5. 2016 + * Author: Jakub Doupal + */ + +#ifndef _AUTOMATON_TRANSLATE_H__ +#define _AUTOMATON_TRANSLATE_H__ + +#include <string/LinearString.h> + +#include "Run.h" +#include <automaton/PDA/NPDTA.h> + +#include <alib/deque> +#include <alib/set> + +namespace automaton { + +namespace run { + +/** + * \brief + * Implementation of transducer run over its input. + */ +class Translate { +public: + /** + * Implementation of a run of an automaton that is producing output. + * + * \tparam InputSymbolType type of input symbols of the string and terminal symbols of the runned automaton + * \tparam OutputSymbolType type of output symbols of the runned automaton + * \tparam EpsilonType type of epsilon in the runned automaton + * \tparam PushdownStoreSymbolType type of pushdown store symbols of the runned automaton + * \tparam StateType type of states of the runned automaton + * + * \param automaton the runned automaton + * \param string the input of the automaton + * + * \return set of strings representing the translations + */ + template < class InputSymbolType, class OutputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > + static ext::set < string::LinearString < OutputSymbolType > > translate ( const automaton::NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const string::LinearString < InputSymbolType > & string ); + +}; + +template < class InputSymbolType, class OutputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > +ext::set < string::LinearString < OutputSymbolType > > Translate::translate ( const automaton::NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const string::LinearString < InputSymbolType > & string ) { + ext::tuple < bool, ext::set < StateType >, ext::set < ext::vector < OutputSymbolType > > > res = Run::calculateStates ( automaton, string ); + ext::set < string::LinearString < OutputSymbolType > > strings; + + for ( const auto & rawString : std::get < 2 > ( res ) ) + strings . insert ( string::LinearString < OutputSymbolType > ( rawString ) ); + + return strings; +} + +} /* namespace run */ + +} /* namespace automaton */ + +#endif /* _AUTOMATON_TRANSLATE_H__ */ -- GitLab