Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Concepts
RegExpEmpty.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// ----------------------------------------------------------------------------
90
91template < class SymbolType >
93 return regexp.template accept < bool, RegExpEmpty::Formal < SymbolType > > ( );
94}
95
96template < class SymbolType >
98 return languageIsEmpty(regexp.getStructure());
99}
100
101template < class SymbolType >
103 return languageIsEmpty(regexp.getRegExp());
104}
105
106// ----------------------------------------------------------------------------
107
108template < class SymbolType >
110 return regexp.template accept < bool, RegExpEmpty::Unbounded < SymbolType > > ( );
111}
112
113template < class SymbolType >
115 return languageIsEmpty(regexp.getStructure());
116}
117
118template < class SymbolType >
120 return languageIsEmpty(regexp.getRegExp());
121}
122
123// ----------------------------------------------------------------------------
124
125template < class SymbolType >
127 return std::all_of ( alternation.getElements ( ).begin ( ), alternation.getElements ( ).end ( ), [ ] ( const UnboundedRegExpElement < SymbolType > & element ) {
128 return element.template accept < bool, RegExpEmpty::Unbounded < SymbolType > > ( );
129 } );
130}
131
132template < class SymbolType >
134 return std::any_of ( concatenation.getElements ( ).begin ( ), concatenation.getElements ( ).end ( ), [ ] ( const UnboundedRegExpElement < SymbolType > & element ) {
135 return element.template accept < bool, RegExpEmpty::Unbounded < SymbolType > > ( );
136 } );
137}
138
139template < class SymbolType >
141 return false;
142}
143
144template < class SymbolType >
146 return false;
147}
148
149template < class SymbolType >
151 return true;
152}
153
154template < class SymbolType >
156 return false;
157}
158
159// ----------------------------------------------------------------------------
160
161template < class SymbolType >
163 return alternation.getLeftElement().template accept < bool, RegExpEmpty::Formal < SymbolType > > ( ) && alternation.getRightElement().template accept < bool, RegExpEmpty::Formal < SymbolType > > ( );
164}
165
166template < class SymbolType >
168 return concatenation.getLeftElement().template accept < bool, RegExpEmpty::Formal < SymbolType > > ( ) || concatenation.getRightElement().template accept < bool, RegExpEmpty::Formal < SymbolType > > ( );
169}
170
171template < class SymbolType >
173 return false;
174}
175
176template < class SymbolType >
178 return false;
179}
180
181template < class SymbolType >
183 return true;
184}
185
186template < class SymbolType >
188 return false;
189}
190
191} /* namespace properties */
192
193} /* namespace regexp */
194
Represents the alternation operator in the regular expression. The node must have exactly two childre...
Definition: FormalRegExpAlternation.h:44
const FormalRegExpElement< SymbolType > & getLeftElement() const
Definition: FormalRegExpAlternation.h:219
const FormalRegExpElement< SymbolType > & getRightElement() const
Definition: FormalRegExpAlternation.h:224
Represents the concatenation operator in the regular expression. The node must have exactly two child...
Definition: FormalRegExpConcatenation.h:44
const FormalRegExpElement< SymbolType > & getRightElement() const
Definition: FormalRegExpConcatenation.h:224
const FormalRegExpElement< SymbolType > & getLeftElement() const
Definition: FormalRegExpConcatenation.h:219
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
const ext::ptr_vector< UnboundedRegExpElement< SymbolType > > & getElements() const
Definition: UnboundedRegExpAlternation.h:185
Represents the concatenation operator in the regular expression. The node can have 0 to n children in...
Definition: UnboundedRegExpConcatenation.h:44
const ext::ptr_vector< UnboundedRegExpElement< SymbolType > > & getElements() const
Definition: UnboundedRegExpConcatenation.h:185
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: RegExpEmpty.h:77
static bool visit(const regexp::FormalRegExpAlternation< SymbolType > &alternation)
Definition: RegExpEmpty.h:162
Definition: RegExpEmpty.h:66
static bool visit(const regexp::UnboundedRegExpAlternation< SymbolType > &alternation)
Definition: RegExpEmpty.h:126
Definition: RegExpEmpty.h:21
static bool languageIsEmpty(const regexp::FormalRegExpElement< SymbolType > &regexp)
Definition: RegExpEmpty.h:92
all_of(T &&...) -> all_of< T... >
any_of(T &&...) -> any_of< T... >
Definition: ToAutomaton.h:15