/*
 * ToRegExp.h
 *
 *  Created on: 4. 3. 2014
 *	  Author: Jan Travnicek
 */

#ifndef GRAMMAR_TO_REG_EXP_H_
#define GRAMMAR_TO_REG_EXP_H_

#include <grammar/Regular/RightRG.h>
#include <grammar/Regular/LeftRG.h>

#include "ToRegExpAlgebraic.h"

namespace grammar {

namespace convert {

class ToRegExp {
public:
	/**
	 * Converts a regular grammar to regular expression.
	 *
	 * \param grammar the regular grammar to convert
	 *
	 * \return regexp describing language generated by @p grammar.
	 */
	template < class TerminalSymbolType, class NonterminalSymbolType >
	static regexp::UnboundedRegExp < TerminalSymbolType > convert ( const grammar::RightRG < TerminalSymbolType, NonterminalSymbolType > & grammar );

	/**
	 * \override
	 */
	template < class TerminalSymbolType, class NonterminalSymbolType >
	static regexp::UnboundedRegExp < TerminalSymbolType > convert ( const grammar::LeftRG < TerminalSymbolType, NonterminalSymbolType > & grammar );
};

template < class TerminalSymbolType, class NonterminalSymbolType >
regexp::UnboundedRegExp < TerminalSymbolType > ToRegExp::convert ( const grammar::RightRG < TerminalSymbolType, NonterminalSymbolType > & grammar ) {
	return ToRegExpAlgebraic::convert ( grammar );
}

template < class TerminalSymbolType, class NonterminalSymbolType >
regexp::UnboundedRegExp < TerminalSymbolType > ToRegExp::convert ( const grammar::LeftRG < TerminalSymbolType, NonterminalSymbolType > & grammar ) {
	return ToRegExpAlgebraic::convert ( grammar );
}

} /* namespace covert */

} /* namespace grammar */

#endif /* GRAMMAR_TO_REG_EXP_H_ */
