Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
UnboundedRegExpIteration.h
Go to the documentation of this file.
1
6/*
7 * This file is part of Algorithms library toolkit.
8 * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
9
10 * Algorithms library toolkit is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14
15 * Algorithms library toolkit is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19
20 * You should have received a copy of the GNU General Public License
21 * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24#pragma once
25
26
28
30
31namespace regexp {
32
42template < class SymbolType >
43class UnboundedRegExpIteration : public ext::UnaryNode < UnboundedRegExpElement < SymbolType > > {
47 void accept ( typename UnboundedRegExpElement < SymbolType >::Visitor & visitor ) const & override {
48 visitor.visit ( * this );
49 }
50
54 void accept ( typename UnboundedRegExpElement < SymbolType >::RvalueVisitor & visitor ) && override {
55 visitor.visit ( std::move ( * this ) );
56 }
57
58public:
65
72
77
82
86 ext::smart_ptr < FormalRegExpElement < SymbolType > > asFormal ( ) const override;
87
91 bool testSymbol ( const SymbolType & symbol ) const override;
92
96 void computeMinimalAlphabet ( ext::set < SymbolType > & alphabet ) const override;
97
101 bool checkAlphabet ( const ext::set < SymbolType > & alphabet ) const override;
102
108 const UnboundedRegExpElement < SymbolType > & getElement ( ) const;
109
116
122 void setElement ( UnboundedRegExpElement < SymbolType > && element );
123
129 void setElement ( const UnboundedRegExpElement < SymbolType > & element );
130
134 std::strong_ordering operator <=> ( const UnboundedRegExpElement < SymbolType > & other ) const override {
135 if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return * this <=> static_cast < decltype ( ( * this ) ) > ( other );
136
137 return ext::type_index ( typeid ( * this ) ) <=> ext::type_index ( typeid ( other ) );
138 }
139
147 std::strong_ordering operator <=> ( const UnboundedRegExpIteration < SymbolType > & ) const;
148
152 bool operator == ( const UnboundedRegExpElement < SymbolType > & other ) const override {
153 if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return * this == static_cast < decltype ( ( * this ) ) > ( other );
154
155 return false;
156 }
157
166
170 void operator >>( ext::ostream & out ) const override;
171
177 }
178};
179
180} /* namespace regexp */
181
182#include "UnboundedRegExpEmpty.h"
183#include "../formal/FormalRegExpIteration.h"
184
185namespace regexp {
186
187template < class SymbolType >
189}
190
191template < class SymbolType >
193}
194
195template < class SymbolType >
197 return this->getChild ( );
198}
199
200template < class SymbolType >
202 return this->getChild ( );
203}
204
205template < class SymbolType >
207 this->setChild ( std::move ( element ) );
208}
209
210template < class SymbolType >
212 setElement ( ext::move_copy ( element ) );
213}
214
215template < class SymbolType >
217 return new UnboundedRegExpIteration ( * this );
218}
219
220template < class SymbolType >
221UnboundedRegExpIteration < SymbolType > * UnboundedRegExpIteration < SymbolType >::clone ( ) && {
222 return new UnboundedRegExpIteration ( std::move ( * this ) );
223}
224
225template < class SymbolType >
227 return ext::smart_ptr < FormalRegExpElement < SymbolType > > ( new FormalRegExpIteration < SymbolType > ( std::move ( * getElement ( ).asFormal ( ) ) ) );
228}
229
230template < class SymbolType >
232 return getElement ( ) <=> other.getElement ( );
233}
234
235template < class SymbolType >
237 return getElement ( ) == other.getElement ( );
238}
239
240template < class SymbolType >
242 out << "(RegExpUnboundedRegExpIteration " << getElement ( ) << ")";
243}
244
245template < class SymbolType >
247 return getElement ( ).testSymbol ( symbol );
248}
249
250template < class SymbolType >
252 return getElement ( ).checkAlphabet ( alphabet );
253}
254
255template < class SymbolType >
257 getElement ( ).computeMinimalAlphabet ( alphabet );
258}
259
260} /* namespace regexp */
261
263
Unary node is specialisation of Anyary node to one child.
Definition: tree_base.hpp:377
Definition: ostream.h:14
Definition: set.hpp:44
Managed pointer simulating value like behavior.
Definition: memory.hpp:233
Definition: typeindex.h:37
Definition: FormalRegExpElement.h:62
Represents the iteration operator in the regular expression. The node has exactly one child.
Definition: FormalRegExpIteration.h:44
Definition: UnboundedRegExpElement.h:81
Definition: UnboundedRegExpElement.h:67
virtual void visit(const UnboundedRegExpAlternation< SymbolType > &)=0
Definition: UnboundedRegExpElement.h:62
Represents the iteration operator in the regular expression. The node has exactly one child.
Definition: UnboundedRegExpIteration.h:43
void computeMinimalAlphabet(ext::set< SymbolType > &alphabet) const override
Definition: UnboundedRegExpIteration.h:256
ext::smart_ptr< FormalRegExpElement< SymbolType > > asFormal() const override
Definition: UnboundedRegExpIteration.h:226
const UnboundedRegExpElement< SymbolType > & getElement() const
Definition: UnboundedRegExpIteration.h:196
bool checkAlphabet(const ext::set< SymbolType > &alphabet) const override
Definition: UnboundedRegExpIteration.h:251
bool operator==(const UnboundedRegExpElement< SymbolType > &other) const override
< SymbolType >::operator == ( const UnboundedRegExpElement < SymbolType > & other ) const;
Definition: UnboundedRegExpIteration.h:152
std::strong_ordering operator<=>(const UnboundedRegExpElement< SymbolType > &other) const override
< SymbolType >::operator <=> ( const UnboundedRegExpElement < SymbolType > & other ) const;
Definition: UnboundedRegExpIteration.h:134
void setElement(UnboundedRegExpElement< SymbolType > &&element)
Definition: UnboundedRegExpIteration.h:206
ext::smart_ptr< UnboundedRegExpElement< DefaultSymbolType > > normalize() &&override
< SymbolType >::normalize ( ) &&
Definition: UnboundedRegExpIteration.h:175
bool testSymbol(const SymbolType &symbol) const override
Definition: UnboundedRegExpIteration.h:246
UnboundedRegExpIteration(UnboundedRegExpElement< SymbolType > &&element)
Creates a new instance of the iteration node with explicit iterated element.
Definition: UnboundedRegExpIteration.h:188
void operator>>(ext::ostream &out) const override
< UnboundedRegExpElement < SymbolType > >::operator >> ( ext::ostream & )
Definition: UnboundedRegExpIteration.h:241
UnboundedRegExpIteration< SymbolType > * clone() const &override
( ) const &
Definition: BarSymbol.cpp:12
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
Definition: sigHandler.cpp:20
auto move_copy(const T &param)
Allow moving of copied instance of the source.
Definition: utility.hpp:45
Definition: ToAutomaton.h:15
Definition: FordFulkerson.hpp:16