Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
GlushkovFirst.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 > >, GlushkovFirst::Unbounded < SymbolType > > ( );
71}
72
73template < class SymbolType >
77
78 for ( const UnboundedRegExpElement < SymbolType > & element : node.getElements ( ) ) {
79 tmp = element.template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovFirst::Unbounded < SymbolType > > ( );
80 ret.insert ( tmp.begin ( ), tmp.end ( ) );
81 }
82
83 return ret;
84}
85
86template < class SymbolType >
90
91 for ( const UnboundedRegExpElement < SymbolType > & element : node.getElements ( ) ) {
92 tmp = element.template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovFirst::Unbounded < SymbolType > > ( );
93 ret.insert ( tmp.begin ( ), tmp.end ( ) );
94
95 if ( ! regexp::properties::RegExpEpsilon::languageContainsEpsilon ( element ) ) // If regexp of this subtree can match epsilon, then we need to add next subtree
96 break;
97 }
98
99 return ret;
100}
101
102template < class SymbolType >
104 return node.getElement ( ).template accept < ext::set < regexp::UnboundedRegExpSymbol < SymbolType > >, GlushkovFirst::Unbounded < SymbolType > > ( );
105}
106
107template < class SymbolType >
110}
111
112template < class SymbolType >
115}
116
117template < class SymbolType >
120}
121
122template < class SymbolType >
124 return re.getRegExp ( ).getStructure ( ).template accept < ext::set < regexp::FormalRegExpSymbol < SymbolType > >, GlushkovFirst::Formal < SymbolType > > ( );
125}
126
127template < class SymbolType >
129 ext::set < regexp::FormalRegExpSymbol < SymbolType > > left = node.getLeftElement ( ).template accept < ext::set < regexp::FormalRegExpSymbol < SymbolType > >, GlushkovFirst::Formal < SymbolType > > ( );
130 ext::set < regexp::FormalRegExpSymbol < SymbolType > > right = node.getRightElement ( ).template accept < ext::set < regexp::FormalRegExpSymbol < SymbolType > >, GlushkovFirst::Formal < SymbolType > > ( );
131 left.insert ( right.begin ( ), right.end ( ) );
132 return left;
133}
134
135template < class SymbolType >
137 ext::set < regexp::FormalRegExpSymbol < SymbolType > > left = node.getLeftElement ( ).template accept < ext::set < regexp::FormalRegExpSymbol < SymbolType > >, GlushkovFirst::Formal < SymbolType > > ( );
138 if ( ! regexp::properties::RegExpEpsilon::languageContainsEpsilon ( node.getLeftElement ( ) ) ) // If regexp of this subtree can match epsilon, then we need to add next subtree
139 return left;
140 ext::set < regexp::FormalRegExpSymbol < SymbolType > > right = node.getRightElement ( ).template accept < ext::set < regexp::FormalRegExpSymbol < SymbolType > >, GlushkovFirst::Formal < SymbolType > > ( );
141 left.insert ( right.begin ( ), right.end ( ) );
142 return left;
143}
144
145template < class SymbolType >
147 return node.getElement ( ).template accept < ext::set < regexp::FormalRegExpSymbol < SymbolType > >, GlushkovFirst::Formal < SymbolType > > ( );
148}
149
150template < class SymbolType >
153}
154
155template < class SymbolType >
158}
159
160template < class SymbolType >
163}
164
165} /* namespace regexp */
166
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: GlushkovFirst.h:57
static ext::set< regexp::FormalRegExpSymbol< SymbolType > > visit(const regexp::FormalRegExpAlternation< SymbolType > &node)
Definition: GlushkovFirst.h:128
Definition: GlushkovFirst.h:39
static ext::set< regexp::UnboundedRegExpSymbol< SymbolType > > visit(const regexp::UnboundedRegExpAlternation< SymbolType > &node)
Definition: GlushkovFirst.h:74
Definition: GlushkovFirst.h:29
static ext::set< UnboundedRegExpSymbol< SymbolType > > first(const regexp::UnboundedRegExp< SymbolType > &re)
Definition: GlushkovFirst.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
Definition: Node.cpp:11
Definition: ToAutomaton.h:15