Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
GlushkovLast.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <alib/set>
9
11
19
21
22namespace regexp {
23
30public:
35 template < class SymbolType >
37
38 template < class SymbolType >
39 class Unbounded {
40 public:
47 };
48
53 template < class SymbolType >
55
56 template < class SymbolType >
57 class Formal {
58 public:
65 };
66};
67
68template < class SymbolType >
70 return re.getRegExp ( ).getStructure ( ).template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovLast::Unbounded < SymbolType > > ( );
71}
72
73template < class SymbolType >
76
77 for ( const UnboundedRegExpElement < SymbolType > & element : node.getElements ( ) ) {
78 ext::set < regexp::UnboundedRegExpSymbol < SymbolType > > tmp = element.template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovLast::Unbounded < SymbolType > > ( );
79 ret.insert ( tmp.begin ( ), tmp.end ( ) );
80 }
81
82 return ret;
83}
84
85template < class SymbolType >
88
89 for ( const UnboundedRegExpElement < SymbolType > & element : ext::make_reverse ( node.getElements ( ) ) ) {
90 ext::set < regexp::UnboundedRegExpSymbol < SymbolType > > tmp = element.template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovLast::Unbounded < SymbolType > > ( );
91 ret.insert ( tmp.begin ( ), tmp.end ( ) );
92
94 break;
95 }
96
97 return ret;
98}
99
100template < class SymbolType >
102 return node.getElement ( ).template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovLast::Unbounded < SymbolType > > ( );
103}
104
105template < class SymbolType >
108}
109
110template < class SymbolType >
113}
114
115template < class SymbolType >
118}
119
120template < class SymbolType >
122 return re.getRegExp ( ).getStructure ( ).template accept < ext::set < regexp::FormalRegExpSymbol < SymbolType > >, GlushkovLast::Formal < SymbolType > > ( );
123}
124
125template < class SymbolType >
127 ext::set < regexp::FormalRegExpSymbol < SymbolType > > left = node.getLeftElement ( ).template accept < ext::set < regexp::FormalRegExpSymbol < SymbolType > >, GlushkovLast::Formal < SymbolType > > ( );
128 ext::set < regexp::FormalRegExpSymbol < SymbolType > > right = node.getRightElement ( ).template accept < ext::set < regexp::FormalRegExpSymbol < SymbolType > >, GlushkovLast::Formal < SymbolType > > ( );
129 left.insert ( right.begin ( ), right.end ( ) );
130 return left;
131}
132
133template < class SymbolType >
135 ext::set < regexp::FormalRegExpSymbol < SymbolType > > right = node.getRightElement ( ).template accept < ext::set < regexp::FormalRegExpSymbol < SymbolType > >, GlushkovLast::Formal < SymbolType > > ( );
136 if ( ! regexp::properties::RegExpEpsilon::languageContainsEpsilon ( node.getRightElement ( ) ) ) // If regexp of this subtree can match epsilon, then we need to add next subtree
137 return right;
138 ext::set < regexp::FormalRegExpSymbol < SymbolType > > left = node.getLeftElement ( ).template accept < ext::set < regexp::FormalRegExpSymbol < SymbolType > >, GlushkovLast::Formal < SymbolType > > ( );
139 right.insert ( left.begin ( ), left.end ( ) );
140 return right;
141}
142
143template < class SymbolType >
145 return node.getElement ( ).template accept < ext::set < regexp::FormalRegExpSymbol < SymbolType > >, GlushkovLast::Formal < SymbolType > > ( );
146}
147
148template < class SymbolType >
151}
152
153template < class SymbolType >
156}
157
158template < class SymbolType >
161}
162
163} /* namespace regexp */
164
Definition: set.hpp:44
auto begin() &
Inherited behavior of begin for non-const instance.
Definition: set.hpp:99
auto end() &
Inherited behavior of end for non-const instance.
Definition: set.hpp:129
Represents the alternation operator in the regular expression. The node must have exactly two childre...
Definition: FormalRegExpAlternation.h:44
Represents the concatenation operator in the regular expression. The node must have exactly two child...
Definition: FormalRegExpConcatenation.h:44
Represents the empty expression in the regular expression. The node can't have any children.
Definition: FormalRegExpEmpty.h:41
Represents the epsilon expression in the regular expression. The node can't have any children.
Definition: FormalRegExpEpsilon.h:41
Represents the iteration operator in the regular expression. The node has exactly one child.
Definition: FormalRegExpIteration.h:44
Represents the symbol in the regular expression. The can't have any children.
Definition: FormalRegExpSymbol.h:42
Formal regular expression represents regular expression. It describes regular languages....
Definition: FormalRegExp.h:78
const FormalRegExpStructure< SymbolType > & getRegExp() const &
Definition: FormalRegExp.h:208
Definition: GlushkovLast.h:57
static ext::set< regexp::FormalRegExpSymbol< SymbolType > > visit(const regexp::FormalRegExpAlternation< SymbolType > &node)
Definition: GlushkovLast.h:126
Definition: GlushkovLast.h:39
static ext::set< regexp::UnboundedRegExpSymbol< SymbolType > > visit(const regexp::UnboundedRegExpAlternation< SymbolType > &node)
Definition: GlushkovLast.h:74
Definition: GlushkovLast.h:29
static ext::set< UnboundedRegExpSymbol< SymbolType > > last(const regexp::UnboundedRegExp< SymbolType > &re)
Definition: GlushkovLast.h:69
Represents the alternation operator in the regular expression. The node can have 0 to n children in l...
Definition: UnboundedRegExpAlternation.h:44
Represents the concatenation operator in the regular expression. The node can have 0 to n children in...
Definition: UnboundedRegExpConcatenation.h:44
Definition: UnboundedRegExpElement.h:62
Represents the empty expression in the regular expression. The node can't have any children.
Definition: UnboundedRegExpEmpty.h:41
Represents the epsilon expression in the regular expression. The node can't have any children.
Definition: UnboundedRegExpEpsilon.h:41
Represents the iteration operator in the regular expression. The node has exactly one child.
Definition: UnboundedRegExpIteration.h:43
Represents the symbol in the regular expression. The can't have any children.
Definition: UnboundedRegExpSymbol.h:42
Unbounded regular expression represents regular expression. It describes regular languages....
Definition: UnboundedRegExp.h:80
const UnboundedRegExpStructure< SymbolType > & getRegExp() const &
Definition: UnboundedRegExp.h:210
static bool languageContainsEpsilon(const regexp::FormalRegExpElement< SymbolType > &regexp)
Definition: RegExpEpsilon.h:91
ext::set< ext::pair< StateType, StateType > > ret(const ext::set< ext::pair< StateType, StateType > > &S, const DeterministicPushdownStoreSymbolType &pdaSymbol, const InputSymbolType &input, const N &nondeterministic)
Definition: RHDPDACommon.h:57
reverser< T > make_reverse(T &&container)
Reverese adaptor construction function.
Definition: iterator.hpp:544
Definition: Node.cpp:11
Definition: ToAutomaton.h:15