/*
 * GlushkovIndexate.h
 *
 *  Created on: 14. 4. 2016
 *	  Author: Tomas Pecka
 */

#ifndef RTE_GLUSHKOV_INDEXATE_H_
#define RTE_GLUSHKOV_INDEXATE_H_

#include <common/ranked_symbol.hpp>

#include <rte/formal/FormalRTE.h>

namespace rte {

class GlushkovIndexate {
public:
	/**
	 * @param re rte to index
	 * @return FormalRTE with indexed elements
	 */
	static FormalRTE < > index ( const rte::FormalRTE < > & re );

	/**
	 * @param symbol Glushkov Pair symbol, i.e., SymbolPair of RankedSymbol < > and integer index
	 * @return RankedSymbol < > from the pair on input
	 */
	static common::ranked_symbol < > getSymbolFromGlushkovPair ( const common::ranked_symbol < > & symbol );

	class Formal {
	public:
		static ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > visit ( const rte::FormalRTEAlternation < DefaultSymbolType, unsigned > & node, int & i );
		static ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > visit ( const rte::FormalRTESubstitution < DefaultSymbolType, unsigned > & node, int & i );
		static ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > visit ( const rte::FormalRTEIteration < DefaultSymbolType, unsigned > & node, int & i );
		static ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > visit ( const rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > & node, int & i );
		static ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > visit ( const rte::FormalRTESymbolSubst < DefaultSymbolType, unsigned > & node, int & i );
		static ext::ptr_value < FormalRTEElement < DefaultSymbolType, unsigned > > visit ( const rte::FormalRTEEmpty < DefaultSymbolType, unsigned > & node, int & i );
	};
};

} /* namespace rte */

#endif /* RTE_GLUSHKOV_INDEXATE_H_ */