Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
FormalRegExpIteration.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#include <ext/utility>
27
29
30#include "FormalRegExpElement.h"
31
32namespace regexp {
33
43template < class SymbolType >
44class FormalRegExpIteration : public ext::UnaryNode < FormalRegExpElement < SymbolType > > {
48 void accept ( typename FormalRegExpElement < SymbolType >::Visitor & visitor ) const override {
49 visitor.visit ( * this );
50 }
51
52public:
59
66
71
75 FormalRegExpIteration < SymbolType > * clone ( ) && override;
76
80 ext::smart_ptr < UnboundedRegExpElement < SymbolType > > asUnbounded ( ) const override;
81
85 bool testSymbol ( const SymbolType & symbol ) const override;
86
90 void computeMinimalAlphabet ( ext::set < SymbolType > & alphabet ) const override;
91
95 bool checkAlphabet ( const ext::set < SymbolType > & alphabet ) const override;
96
102 const FormalRegExpElement < SymbolType > & getElement ( ) const;
103
110
116 void setElement ( FormalRegExpElement < SymbolType > && element );
117
123 void setElement ( const FormalRegExpElement < SymbolType > & element );
124
128 std::strong_ordering operator <=> ( const FormalRegExpElement < SymbolType > & other ) const override {
129 if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return * this <=> static_cast < decltype ( ( * this ) ) > ( other );
130
131 return ext::type_index ( typeid ( * this ) ) <=> ext::type_index ( typeid ( other ) );
132 }
133
141 std::strong_ordering operator <=> ( const FormalRegExpIteration < SymbolType > & ) const;
142
146 bool operator == ( const FormalRegExpElement < SymbolType > & other ) const override {
147 if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return * this == static_cast < decltype ( ( * this ) ) > ( other );
148
149 return false;
150 }
151
160
164 void operator >>( ext::ostream & out ) const override;
165
171 }
172};
173
174} /* namespace regexp */
175
176#include "FormalRegExpEmpty.h"
177#include "../unbounded/UnboundedRegExpIteration.h"
178
179namespace regexp {
180
181template < class SymbolType >
183}
184
185template < class SymbolType >
187}
188
189template < class SymbolType >
191 return this->getChild ( );
192}
193
194template < class SymbolType >
196 return this->getChild ( );
197}
198
199template < class SymbolType >
201 this->setChild ( std::move ( element ) );
202}
203
204template < class SymbolType >
206 setElement ( ext::move_copy ( element ) );
207}
208
209template < class SymbolType >
211 return new FormalRegExpIteration ( * this );
212}
213
214template < class SymbolType >
215FormalRegExpIteration < SymbolType > * FormalRegExpIteration < SymbolType >::clone ( ) && {
216 return new FormalRegExpIteration ( std::move ( * this ) );
217}
218
219template < class SymbolType >
222}
223
224template < class SymbolType >
226 return getElement ( ) <=> other.getElement ( );
227}
228
229template < class SymbolType >
231 return getElement ( ) == other.getElement ( );
232}
233
234template < class SymbolType >
236 out << "(RegExpFormalRegExpIteration " << getElement ( ) << ")";
237}
238
239template < class SymbolType >
241 return getElement ( ).testSymbol ( symbol );
242}
243
244template < class SymbolType >
246 getElement ( ).computeMinimalAlphabet ( alphabet );
247}
248
249template < class SymbolType >
251 return getElement ( ).checkAlphabet ( alphabet );
252}
253
254} /* namespace regexp */
255
257
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:67
virtual void visit(const FormalRegExpAlternation< SymbolType > &)=0
Definition: FormalRegExpElement.h:62
Represents the iteration operator in the regular expression. The node has exactly one child.
Definition: FormalRegExpIteration.h:44
bool checkAlphabet(const ext::set< SymbolType > &alphabet) const override
Definition: FormalRegExpIteration.h:250
bool operator==(const FormalRegExpElement< SymbolType > &other) const override
< SymbolType >::operator == ( const FormalRegExpElement < SymbolType > & other ) const;
Definition: FormalRegExpIteration.h:146
bool testSymbol(const SymbolType &symbol) const override
Definition: FormalRegExpIteration.h:240
std::strong_ordering operator<=>(const FormalRegExpElement< SymbolType > &other) const override
< SymbolType >::operator <=> ( const FormalRegExpElement < SymbolType > & other ) const;
Definition: FormalRegExpIteration.h:128
FormalRegExpIteration< SymbolType > * clone() const &override
( ) const &
FormalRegExpIteration(FormalRegExpElement< SymbolType > &&)
Creates a new instance of the iteration node with explicit iterated element.
Definition: FormalRegExpIteration.h:182
void computeMinimalAlphabet(ext::set< SymbolType > &alphabet) const override
Definition: FormalRegExpIteration.h:245
ext::smart_ptr< UnboundedRegExpElement< SymbolType > > asUnbounded() const override
( ) const &
Definition: FormalRegExpIteration.h:220
void operator>>(ext::ostream &out) const override
< FormalRegExpElement < SymbolType > >::operator >> ( ext::ostream & )
Definition: FormalRegExpIteration.h:235
const FormalRegExpElement< SymbolType > & getElement() const
Definition: FormalRegExpIteration.h:190
ext::smart_ptr< FormalRegExpElement< DefaultSymbolType > > normalize() &&override
< SymbolType >::normalize ( ) &&
Definition: FormalRegExpIteration.h:169
void setElement(FormalRegExpElement< SymbolType > &&element)
Definition: FormalRegExpIteration.h:200
Definition: UnboundedRegExpElement.h:62
Represents the iteration operator in the regular expression. The node has exactly one child.
Definition: UnboundedRegExpIteration.h:43
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