Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
GrammarNormalize.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <alib/vector>
9#include <alib/tuple>
10#include <alib/set>
11#include <alib/variant>
12
14
15namespace grammar {
16
21public:
22 template < class FirstSymbolType, class SecondSymbolType >
24
25 template < class FirstSymbolType, class SecondSymbolType, class ThirdSymbolType >
27
28 template < class FirstSymbolType, class SecondSymbolType, class ThirdSymbolType >
30
31 template < class FirstSymbolType, class SecondSymbolType, class ThirdSymbolType >
33
34 template < class FirstSymbolType, class SecondSymbolType, class ThirdSymbolType, class FourthSymbolType >
36
37};
38
39template < class FirstSymbolType, class SecondSymbolType >
41 return ext::make_pair ( alphabet::SymbolNormalize::normalizeSymbol ( std::move ( symbol.first ) ), alphabet::SymbolNormalize::normalizeSymbols ( std::move ( symbol.second ) ) );
42}
43
44template < class FirstSymbolType, class SecondSymbolType, class ThirdSymbolType >
46 if ( symbol.template is < FirstSymbolType > ( ) ) {
48 } else {
49 ext::pair < SecondSymbolType, ThirdSymbolType > & inner = symbol.template get < ext::pair < SecondSymbolType, ThirdSymbolType > > ( );
51 }
52}
53
54template < class FirstSymbolType, class SecondSymbolType, class ThirdSymbolType >
56 if ( symbol.template is < ext::vector < FirstSymbolType > > ( ) ) {
58 } else {
59 ext::pair < SecondSymbolType, ext::vector < ThirdSymbolType > > & inner = symbol.template get < ext::pair < SecondSymbolType, ext::vector < ThirdSymbolType > > > ( );
61 }
62}
63
64template < class FirstSymbolType, class SecondSymbolType, class ThirdSymbolType >
66 if ( symbol.template is < ext::vector < FirstSymbolType > > ( ) ) {
68 } else {
69 ext::pair < ext::vector < SecondSymbolType >, ThirdSymbolType > & inner = symbol.template get < ext::pair < ext::vector < SecondSymbolType >, ThirdSymbolType > > ( );
71 }
72}
73
74template < class FirstSymbolType, class SecondSymbolType, class ThirdSymbolType, class FourthSymbolType >
76 if ( symbols.template is < ext::vector < FirstSymbolType > > ( ) ) {
78 } else {
79 ext::tuple < ext::vector < SecondSymbolType >, ThirdSymbolType, ext::vector < FourthSymbolType > > & inner = symbols.template get < ext::tuple < ext::vector < FirstSymbolType >, SecondSymbolType, ext::vector < ThirdSymbolType > > > ( );
80
81 ext::vector < DefaultSymbolType > first = alphabet::SymbolNormalize::normalizeSymbols ( std::move ( std::get < 0 > ( inner ) ) );
82 DefaultSymbolType second = alphabet::SymbolNormalize::normalizeSymbol ( std::move ( std::get < 1 > ( inner ) ) );
83 ext::vector < DefaultSymbolType > third = alphabet::SymbolNormalize::normalizeSymbols ( std::move ( std::get < 2 > ( inner ) ) );
84
86 }
87}
88
89} /* namespace grammar */
90
static ext::vector< DefaultSymbolType > normalizeSymbols(ext::vector< SymbolType > &&symbols)
Definition: SymbolNormalize.h:86
static DefaultSymbolType normalizeSymbol(SymbolType &&symbol)
Definition: SymbolNormalize.h:68
Class extending the pair class from the standard library. Original reason is to allow printing of the...
Definition: pair.hpp:43
Class extending the tuple class from the standard library. Original reason is to allow printing of th...
Definition: tuple.hpp:42
Implementation of the variant class allowing to store any type of those listed in the template parame...
Definition: variant.hpp:98
Class extending the vector class from the standard library. Original reason is to allow printing of t...
Definition: vector.hpp:45
Definition: GrammarNormalize.h:20
static ext::pair< DefaultSymbolType, ext::vector< DefaultSymbolType > > normalizeRHS(ext::pair< FirstSymbolType, ext::vector< SecondSymbolType > > &&symbol)
Definition: GrammarNormalize.h:40
Definition: Object.h:16
object::Object DefaultSymbolType
Definition: DefaultSymbolType.h:10
p second
Definition: ToRegExpAlgebraic.h:126
constexpr auto make_tuple(Elements &&... args)
Helper of extended tuple construction. The tuple is constructed from values pack, types are deduced.
Definition: tuple.hpp:203
constexpr auto make_pair(T1 &&x, T2 &&y)
Definition: pair.hpp:79
Definition: ToAutomaton.h:24
auto & get(ext::ptr_array< Type, N > &tpl)
Specialisation of get function for pointer arrays.
Definition: ptr_array.hpp:693