Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
RegExpEpsilon.h
Go to the documentation of this file.
1
6#pragma once
7
12
13namespace regexp {
14
15namespace properties {
16
22public:
32 template < class SymbolType >
34
38 template < class SymbolType >
40
44 template < class SymbolType >
46
50 template < class SymbolType >
52
56 template < class SymbolType >
58
62 template < class SymbolType >
64
65 template < class SymbolType >
66 class Unbounded {
67 public:
68 static bool visit(const regexp::UnboundedRegExpAlternation < SymbolType > & alternation);
69 static bool visit(const regexp::UnboundedRegExpConcatenation < SymbolType > & concatenation);
70 static bool visit(const regexp::UnboundedRegExpIteration < SymbolType > & iteration);
71 static bool visit(const regexp::UnboundedRegExpSymbol < SymbolType > & symbol);
72 static bool visit(const regexp::UnboundedRegExpEmpty < SymbolType > & empty);
73 static bool visit(const regexp::UnboundedRegExpEpsilon < SymbolType > & epsilon);
74 };
75
76 template < class SymbolType >
77 class Formal {
78 public:
79 static bool visit(const regexp::FormalRegExpAlternation < SymbolType > & alternation);
80 static bool visit(const regexp::FormalRegExpConcatenation < SymbolType > & concatenation);
81 static bool visit(const regexp::FormalRegExpIteration < SymbolType > & iteration);
82 static bool visit(const regexp::FormalRegExpSymbol < SymbolType > & symbol);
83 static bool visit(const regexp::FormalRegExpEmpty < SymbolType > & empty);
84 static bool visit(const regexp::FormalRegExpEpsilon < SymbolType > & epsilon);
85 };
86};
87
88// ----------------------------------------------------------------------------
89
90template < class SymbolType >
92 return regexp.template accept<bool, RegExpEpsilon::Formal < SymbolType >>();
93}
94
95template < class SymbolType >
97 return languageContainsEpsilon(regexp.getStructure());
98}
99
100template < class SymbolType >
102 return languageContainsEpsilon(regexp.getRegExp());
103}
104
105// ----------------------------------------------------------------------------
106
107template < class SymbolType >
109 return regexp.template accept<bool, RegExpEpsilon::Unbounded < SymbolType >>();
110}
111
112template < class SymbolType >
114 return languageContainsEpsilon(regexp.getStructure());
115}
116
117template < class SymbolType >
119 return languageContainsEpsilon(regexp.getRegExp());
120}
121
122// ---------------------------------------------------------------------------
123
124template < class SymbolType >
126 return std::any_of ( alternation.getElements ( ).begin ( ), alternation.getElements ( ).end ( ), [ ] ( const UnboundedRegExpElement < SymbolType > & element ) {
127 return element.template accept < bool, RegExpEpsilon::Unbounded < SymbolType > > ( );
128 } );
129}
130
131template < class SymbolType >
133 return std::all_of ( concatenation.getElements ( ).begin ( ), concatenation.getElements ( ).end ( ), [ ] ( const UnboundedRegExpElement < SymbolType > & element ) {
134 return element.template accept < bool, RegExpEpsilon::Unbounded < SymbolType > > ( );
135 } );
136}
137
138template < class SymbolType >
140 return true;
141}
142
143template < class SymbolType >
145 return false;
146}
147
148template < class SymbolType >
150 return true;
151}
152
153template < class SymbolType >
155 return false;
156}
157
158// ----------------------------------------------------------------------------
159
160template < class SymbolType >
162 return alternation.getLeftElement().template accept<bool, RegExpEpsilon::Formal < SymbolType >>() || alternation.getRightElement().template accept<bool, RegExpEpsilon::Formal < SymbolType >>();
163}
164
165template < class SymbolType >
167 return concatenation.getLeftElement().template accept<bool, RegExpEpsilon::Formal < SymbolType >>() && concatenation.getRightElement().template accept<bool, RegExpEpsilon::Formal < SymbolType >>();
168}
169
170template < class SymbolType >
172 return true;
173}
174
175template < class SymbolType >
177 return false;
178}
179
180template < class SymbolType >
182 return false;
183}
184
185template < class SymbolType >
187 return true;
188}
189
190} /* namespace properties */
191
192} /* namespace regexp */
193
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
Definition: FormalRegExpElement.h:62
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 formal regular expression structure. Regular expression is stored as a tree of FormalRegEx...
Definition: FormalRegExpStructure.h:45
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
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 unbounded regular expression structure. Regular expression is stored as a tree of Unbounde...
Definition: UnboundedRegExpStructure.h:47
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
Definition: RegExpEpsilon.h:77
static bool visit(const regexp::FormalRegExpAlternation< SymbolType > &alternation)
Definition: RegExpEpsilon.h:161
Definition: RegExpEpsilon.h:66
static bool visit(const regexp::UnboundedRegExpAlternation< SymbolType > &alternation)
Definition: RegExpEpsilon.h:125
Definition: RegExpEpsilon.h:21
static bool languageContainsEpsilon(const regexp::FormalRegExpElement< SymbolType > &regexp)
Definition: RegExpEpsilon.h:91
all_of(T &&...) -> all_of< T... >
any_of(T &&...) -> any_of< T... >
Definition: ToAutomaton.h:15