Skip to content
Snippets Groups Projects
Commit fa1025cc authored by Jan Trávníček's avatar Jan Trávníček
Browse files

prepare grammar normalize for generalized templating of grammars

parent 2417af8e
No related branches found
No related tags found
No related merge requests found
...@@ -22,64 +22,64 @@ namespace grammar { ...@@ -22,64 +22,64 @@ namespace grammar {
*/ */
class GrammarNormalize { class GrammarNormalize {
public: public:
template < class SymbolType > template < class FirstSymbolType, class SecondSymbolType >
static ext::pair < DefaultSymbolType, ext::vector < DefaultSymbolType > > normalizeRHS ( ext::pair < SymbolType, ext::vector < SymbolType > > && symbol ); static ext::pair < DefaultSymbolType, ext::vector < DefaultSymbolType > > normalizeRHS ( ext::pair < FirstSymbolType, ext::vector < SecondSymbolType > > && symbol );
   
template < class SymbolType > template < class FirstSymbolType, class SecondSymbolType, class ThirdSymbolType >
static ext::variant < DefaultSymbolType, ext::pair < DefaultSymbolType, DefaultSymbolType > > normalizeRHS ( ext::variant < SymbolType, ext::pair < SymbolType, SymbolType > > && symbol ); static ext::variant < DefaultSymbolType, ext::pair < DefaultSymbolType, DefaultSymbolType > > normalizeRHS ( ext::variant < FirstSymbolType, ext::pair < SecondSymbolType, ThirdSymbolType > > && symbol );
   
template < class SymbolType > template < class FirstSymbolType, class SecondSymbolType, class ThirdSymbolType >
static ext::variant < ext::vector < DefaultSymbolType >, ext::pair < DefaultSymbolType, ext::vector < DefaultSymbolType > > > normalizeRHS ( ext::variant < ext::vector < SymbolType >, ext::pair < SymbolType, ext::vector < SymbolType > > > && symbol ); static ext::variant < ext::vector < DefaultSymbolType >, ext::pair < DefaultSymbolType, ext::vector < DefaultSymbolType > > > normalizeRHS ( ext::variant < ext::vector < FirstSymbolType >, ext::pair < SecondSymbolType, ext::vector < ThirdSymbolType > > > && symbol );
   
template < class SymbolType > template < class FirstSymbolType, class SecondSymbolType, class ThirdSymbolType >
static ext::variant < ext::vector < DefaultSymbolType >, ext::pair < ext::vector < DefaultSymbolType >, DefaultSymbolType > > normalizeRHS ( ext::variant < ext::vector < SymbolType >, ext::pair < ext::vector < SymbolType >, SymbolType > > && symbol ); static ext::variant < ext::vector < DefaultSymbolType >, ext::pair < ext::vector < DefaultSymbolType >, DefaultSymbolType > > normalizeRHS ( ext::variant < ext::vector < FirstSymbolType >, ext::pair < ext::vector < SecondSymbolType >, ThirdSymbolType > > && symbol );
   
template < class SymbolType > template < class FirstSymbolType, class SecondSymbolType, class ThirdSymbolType, class FourthSymbolType >
static ext::variant < ext::vector < DefaultSymbolType >, ext::tuple < ext::vector < DefaultSymbolType >, DefaultSymbolType, ext::vector < DefaultSymbolType > > > normalizeRHS ( ext::variant < ext::vector < SymbolType >, ext::tuple < ext::vector < SymbolType >, SymbolType, ext::vector < SymbolType > > > && symbols ); static ext::variant < ext::vector < DefaultSymbolType >, ext::tuple < ext::vector < DefaultSymbolType >, DefaultSymbolType, ext::vector < DefaultSymbolType > > > normalizeRHS ( ext::variant < ext::vector < FirstSymbolType >, ext::tuple < ext::vector < SecondSymbolType >, ThirdSymbolType, ext::vector < FourthSymbolType > > > && symbols );
   
}; };
   
template < class SymbolType > template < class FirstSymbolType, class SecondSymbolType >
ext::pair < DefaultSymbolType, ext::vector < DefaultSymbolType > > GrammarNormalize::normalizeRHS ( ext::pair < SymbolType, ext::vector < SymbolType > > && symbol ) { ext::pair < DefaultSymbolType, ext::vector < DefaultSymbolType > > GrammarNormalize::normalizeRHS ( ext::pair < FirstSymbolType, ext::vector < SecondSymbolType > > && symbol ) {
return ext::make_pair ( alphabet::SymbolNormalize::normalizeSymbol ( std::move ( symbol.first ) ), alphabet::SymbolNormalize::normalizeSymbols ( std::move ( symbol.second ) ) ); return ext::make_pair ( alphabet::SymbolNormalize::normalizeSymbol ( std::move ( symbol.first ) ), alphabet::SymbolNormalize::normalizeSymbols ( std::move ( symbol.second ) ) );
} }
   
template < class SymbolType > template < class FirstSymbolType, class SecondSymbolType, class ThirdSymbolType >
ext::variant < DefaultSymbolType, ext::pair < DefaultSymbolType, DefaultSymbolType > > GrammarNormalize::normalizeRHS ( ext::variant < SymbolType, ext::pair < SymbolType, SymbolType > > && symbol ) { ext::variant < DefaultSymbolType, ext::pair < DefaultSymbolType, DefaultSymbolType > > GrammarNormalize::normalizeRHS ( ext::variant < FirstSymbolType, ext::pair < SecondSymbolType, ThirdSymbolType > > && symbol ) {
if ( symbol.template is < SymbolType > ( ) ) { if ( symbol.template is < FirstSymbolType > ( ) ) {
return ext::variant < DefaultSymbolType, ext::pair < DefaultSymbolType, DefaultSymbolType > > ( alphabet::SymbolNormalize::normalizeSymbol ( std::move ( symbol.template get < SymbolType > ( ) ) ) ); return ext::variant < DefaultSymbolType, ext::pair < DefaultSymbolType, DefaultSymbolType > > ( alphabet::SymbolNormalize::normalizeSymbol ( std::move ( symbol.template get < FirstSymbolType > ( ) ) ) );
} else { } else {
ext::pair < SymbolType, SymbolType > & inner = symbol.template get < ext::pair < SymbolType, SymbolType > > ( ); ext::pair < SecondSymbolType, ThirdSymbolType > & inner = symbol.template get < ext::pair < SecondSymbolType, ThirdSymbolType > > ( );
return ext::variant < DefaultSymbolType, ext::pair < DefaultSymbolType, DefaultSymbolType > > ( ext::make_pair ( alphabet::SymbolNormalize::normalizeSymbol ( std::move ( inner.first ) ), alphabet::SymbolNormalize::normalizeSymbol ( std::move ( inner.second ) ) ) ); return ext::variant < DefaultSymbolType, ext::pair < DefaultSymbolType, DefaultSymbolType > > ( ext::make_pair ( alphabet::SymbolNormalize::normalizeSymbol ( std::move ( inner.first ) ), alphabet::SymbolNormalize::normalizeSymbol ( std::move ( inner.second ) ) ) );
} }
} }
   
template < class SymbolType > template < class FirstSymbolType, class SecondSymbolType, class ThirdSymbolType >
ext::variant < ext::vector < DefaultSymbolType >, ext::pair < DefaultSymbolType, ext::vector < DefaultSymbolType > > > GrammarNormalize::normalizeRHS ( ext::variant < ext::vector < SymbolType >, ext::pair < SymbolType, ext::vector < SymbolType > > > && symbol ) { ext::variant < ext::vector < DefaultSymbolType >, ext::pair < DefaultSymbolType, ext::vector < DefaultSymbolType > > > GrammarNormalize::normalizeRHS ( ext::variant < ext::vector < FirstSymbolType >, ext::pair < SecondSymbolType, ext::vector < ThirdSymbolType > > > && symbol ) {
if ( symbol.template is < ext::vector < SymbolType > > ( ) ) { if ( symbol.template is < ext::vector < FirstSymbolType > > ( ) ) {
return ext::variant < ext::vector < DefaultSymbolType >, ext::pair < DefaultSymbolType, ext::vector < DefaultSymbolType > > > ( alphabet::SymbolNormalize::normalizeSymbols ( std::move ( symbol.template get < ext::vector < SymbolType > > ( ) ) ) ); return ext::variant < ext::vector < DefaultSymbolType >, ext::pair < DefaultSymbolType, ext::vector < DefaultSymbolType > > > ( alphabet::SymbolNormalize::normalizeSymbols ( std::move ( symbol.template get < ext::vector < FirstSymbolType > > ( ) ) ) );
} else { } else {
ext::pair < SymbolType, ext::vector < SymbolType > > & inner = symbol.template get < ext::pair < SymbolType, ext::vector < SymbolType > > > ( ); ext::pair < SecondSymbolType, ext::vector < ThirdSymbolType > > & inner = symbol.template get < ext::pair < SecondSymbolType, ext::vector < ThirdSymbolType > > > ( );
return ext::variant < ext::vector < DefaultSymbolType >, ext::pair < DefaultSymbolType, ext::vector < DefaultSymbolType > > > ( ext::make_pair ( alphabet::SymbolNormalize::normalizeSymbol ( std::move ( inner.first ) ), alphabet::SymbolNormalize::normalizeSymbols ( std::move ( inner.second ) ) ) ); return ext::variant < ext::vector < DefaultSymbolType >, ext::pair < DefaultSymbolType, ext::vector < DefaultSymbolType > > > ( ext::make_pair ( alphabet::SymbolNormalize::normalizeSymbol ( std::move ( inner.first ) ), alphabet::SymbolNormalize::normalizeSymbols ( std::move ( inner.second ) ) ) );
} }
} }
   
template < class SymbolType > template < class FirstSymbolType, class SecondSymbolType, class ThirdSymbolType >
ext::variant < ext::vector < DefaultSymbolType >, ext::pair < ext::vector < DefaultSymbolType >, DefaultSymbolType > > GrammarNormalize::normalizeRHS ( ext::variant < ext::vector < SymbolType >, ext::pair < ext::vector < SymbolType >, SymbolType > > && symbol ) { ext::variant < ext::vector < DefaultSymbolType >, ext::pair < ext::vector < DefaultSymbolType >, DefaultSymbolType > > GrammarNormalize::normalizeRHS ( ext::variant < ext::vector < FirstSymbolType >, ext::pair < ext::vector < SecondSymbolType >, ThirdSymbolType > > && symbol ) {
if ( symbol.template is < ext::vector < SymbolType > > ( ) ) { if ( symbol.template is < ext::vector < FirstSymbolType > > ( ) ) {
return ext::variant < ext::vector < DefaultSymbolType >, ext::pair < ext::vector < DefaultSymbolType >, DefaultSymbolType > > ( alphabet::SymbolNormalize::normalizeSymbols ( std::move ( symbol.template get < ext::vector < SymbolType > > ( ) ) ) ); return ext::variant < ext::vector < DefaultSymbolType >, ext::pair < ext::vector < DefaultSymbolType >, DefaultSymbolType > > ( alphabet::SymbolNormalize::normalizeSymbols ( std::move ( symbol.template get < ext::vector < FirstSymbolType > > ( ) ) ) );
} else { } else {
ext::pair < ext::vector < SymbolType >, SymbolType > & inner = symbol.template get < ext::pair < ext::vector < SymbolType >, SymbolType > > ( ); ext::pair < ext::vector < SecondSymbolType >, ThirdSymbolType > & inner = symbol.template get < ext::pair < ext::vector < SecondSymbolType >, ThirdSymbolType > > ( );
return ext::variant < ext::vector < DefaultSymbolType >, ext::pair < ext::vector < DefaultSymbolType >, DefaultSymbolType > > ( ext::make_pair ( alphabet::SymbolNormalize::normalizeSymbols ( std::move ( inner.first ) ), alphabet::SymbolNormalize::normalizeSymbol ( std::move ( inner.second ) ) ) ); return ext::variant < ext::vector < DefaultSymbolType >, ext::pair < ext::vector < DefaultSymbolType >, DefaultSymbolType > > ( ext::make_pair ( alphabet::SymbolNormalize::normalizeSymbols ( std::move ( inner.first ) ), alphabet::SymbolNormalize::normalizeSymbol ( std::move ( inner.second ) ) ) );
} }
} }
   
template < class SymbolType > template < class FirstSymbolType, class SecondSymbolType, class ThirdSymbolType, class FourthSymbolType >
ext::variant < ext::vector < DefaultSymbolType >, ext::tuple < ext::vector < DefaultSymbolType >, DefaultSymbolType, ext::vector < DefaultSymbolType > > > GrammarNormalize::normalizeRHS ( ext::variant < ext::vector < SymbolType >, ext::tuple < ext::vector < SymbolType >, SymbolType, ext::vector < SymbolType > > > && symbols ) { ext::variant < ext::vector < DefaultSymbolType >, ext::tuple < ext::vector < DefaultSymbolType >, DefaultSymbolType, ext::vector < DefaultSymbolType > > > GrammarNormalize::normalizeRHS ( ext::variant < ext::vector < FirstSymbolType >, ext::tuple < ext::vector < SecondSymbolType >, ThirdSymbolType, ext::vector < FourthSymbolType > > > && symbols ) {
if ( symbols.template is < ext::vector < SymbolType > > ( ) ) { if ( symbols.template is < ext::vector < FirstSymbolType > > ( ) ) {
return ext::variant < ext::vector < DefaultSymbolType >, ext::tuple < ext::vector < DefaultSymbolType >, DefaultSymbolType, ext::vector < DefaultSymbolType > > > ( alphabet::SymbolNormalize::normalizeSymbols ( std::move ( symbols.template get < ext::vector < SymbolType > > ( ) ) ) ); return ext::variant < ext::vector < DefaultSymbolType >, ext::tuple < ext::vector < DefaultSymbolType >, DefaultSymbolType, ext::vector < DefaultSymbolType > > > ( alphabet::SymbolNormalize::normalizeSymbols ( std::move ( symbols.template get < ext::vector < FirstSymbolType > > ( ) ) ) );
} else { } else {
ext::tuple < ext::vector < SymbolType >, SymbolType, ext::vector < SymbolType > > & inner = symbols.template get < ext::tuple < ext::vector < SymbolType >, SymbolType, ext::vector < SymbolType > > > ( ); ext::tuple < ext::vector < SecondSymbolType >, ThirdSymbolType, ext::vector < FourthSymbolType > > & inner = symbols.template get < ext::tuple < ext::vector < FirstSymbolType >, SecondSymbolType, ext::vector < ThirdSymbolType > > > ( );
   
ext::vector < DefaultSymbolType > first = alphabet::SymbolNormalize::normalizeSymbols ( std::move ( std::get < 0 > ( inner ) ) ); ext::vector < DefaultSymbolType > first = alphabet::SymbolNormalize::normalizeSymbols ( std::move ( std::get < 0 > ( inner ) ) );
DefaultSymbolType second = alphabet::SymbolNormalize::normalizeSymbol ( std::move ( std::get < 1 > ( inner ) ) ); DefaultSymbolType second = alphabet::SymbolNormalize::normalizeSymbol ( std::move ( std::get < 1 > ( inner ) ) );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment