-
Tomáš Pecka authoredTomáš Pecka authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
ConversionHandler.h 3.22 KiB
/*
* ConversionHandler.h
*
* Created on: 23. 2. 2014
* Author: tomas
*/
#ifndef ALGORITHMCHOOSER_H_
#define ALGORITHMCHOOSER_H_
#include <list>
#include <AlibException.h>
#include <AutomatonFactory.h>
#include <automaton/AutomatonParser.h>
#include <GrammarFactory.h>
#include <grammar/GrammarParser.h>
#include <regexp/RegExpParser.h>
#include "../fa2re/StateElimination.h"
#include "../fa2re/BrzozowskiAlgebraic.h"
#include "../re2fa/Glushkov.h"
#include "../re2fa/Thompson.h"
#include "../re2fa/Brzozowski.h"
#include "../fa2rg/fa2lrg/FAtoLRGConverter.h"
#include "../fa2rg/fa2rrg/FAtoRRGConverter.h"
#include "../rg2fa/lrg2fa/LRGtoFAConverter.h"
#include "../rg2fa/rrg2fa/RRGtoFAConverter.h"
#include "../rg2re/rrg2re/RRGAlgebraic.h"
#include "../rg2re/lrg2re/LRGAlgebraic.h"
#include "../re2rg/re2rrg/GlushkovRRG.h"
#include "../re2rg/re2rrg/BrzozowskiDerivationRRG.h"
#include "../rg2rg/lrg2rrg/LeftToRightRegularGrammar.h"
#include "../rg2rg/rrg2lrg/RightToLeftRegularGrammar.h"
namespace conversions
{
class ConversionHandler
{
public:
enum TAlgorithm
{
DEFAULT,
/* FA to RE */
BRZOZOWSKI_ALGEBRAIC,
STATE_ELIMINATION,
/* FA to RG */
// FA to LRG,
// FA to RRG
/* RE to FA */
BRZOZOWSKI_DERIVATION,
THOMPSON_NFA,
GLUSHKOV_NFA,
/* RE to RG */
/* RG to FA */
// LRG to FSM
// RRG to FSM
/* RG to RE */
// BRZOZOWSKI_ALGEBRAIC
/* RG to RG */
// RRG to LRG
// LRG to RRG
};
enum TFormalism
{
FINITE_AUTOMATA,
REGULAR_GRAMMAR,
LEFT_REGULAR_GRAMMAR,
RIGHT_REGULAR_GRAMMAR,
LINEAR_GRAMMAR,
LEFT_LINEAR_GRAMMAR,
RIGHT_LINEAR_GRAMMAR,
REGULAR_EXPRESSION,
UNKNOWN,
};
#define isGrammar(x) ( (x) == REGULAR_GRAMMAR || (x) == LEFT_REGULAR_GRAMMAR || (x) == RIGHT_REGULAR_GRAMMAR \
|| (x) == LINEAR_GRAMMAR || (x) == LEFT_LINEAR_GRAMMAR || (x) == RIGHT_LINEAR_GRAMMAR )
ConversionHandler( std::list<sax::Token> & tokens, const std::string & target, const std::string & algorithm, std::ostream & out );
void convert( void );
private:
TFormalism parseFormalismFromString( const std::string & _target ) const;
TFormalism parseFormalismFromTokens( void ) const;
TAlgorithm parseAlgorithmFromString( const std::string & _algorithm ) const;
void convertFSM( void );
void convertFSMtoRE( void );
void convertFSMtoRG( void );
void convertFSMtoLRG( void );
void convertFSMtoRRG( void );
void convertRE( void );
void convertREtoFSM( void );
void convertREtoRG( void );
void convertREtoRRG( void );
void convertRG( void );
void convertRGtoFSM( void );
void convertLRGtoFSM( void );
void convertRRGtoFSM( void );
void convertRGtoRE( void );
void convertLRGtoRE( void );
void convertRRGtoRE( void );
void convertRGtoRG( void );
void convertLRGtoRRG( void );
void convertRRGtoLRG( void );
std::list<sax::Token> & m_tokens;
TFormalism m_source, m_target;
TAlgorithm m_algorithm;
std::ostream & m_out;
};
} /* namespace conversions */
#endif /* ALGORITHMCHOOSER_H_ */