Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
UnboundedRegExpEmpty.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
29namespace regexp {
30
40template < class SymbolType >
41class UnboundedRegExpEmpty : public ext::NullaryNode < UnboundedRegExpElement < SymbolType > > {
45 void accept ( typename UnboundedRegExpElement < SymbolType >::Visitor & visitor ) const & override {
46 visitor.visit ( * this );
47 }
48
52 void accept ( typename UnboundedRegExpElement < SymbolType >::RvalueVisitor & visitor ) && override {
53 visitor.visit ( std::move ( * this ) );
54 }
55
56public:
60 explicit UnboundedRegExpEmpty ( ) = default;
61
66
70 UnboundedRegExpEmpty < SymbolType > * clone ( ) && override;
71
75 ext::smart_ptr < FormalRegExpElement < SymbolType > > asFormal ( ) const override;
76
80 bool testSymbol ( const SymbolType & symbol ) const override;
81
85 void computeMinimalAlphabet ( ext::set < SymbolType > & alphabet ) const override;
86
90 bool checkAlphabet ( const ext::set < SymbolType > & alphabet ) const override;
91
95 std::strong_ordering operator <=> ( const UnboundedRegExpElement < SymbolType > & other ) const override {
96 if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return * this <=> static_cast < decltype ( ( * this ) ) > ( other );
97
98 return ext::type_index ( typeid ( * this ) ) <=> ext::type_index ( typeid ( other ) );
99 }
100
108 std::strong_ordering operator <=> ( const UnboundedRegExpEmpty < SymbolType > & ) const;
109
113 bool operator == ( const UnboundedRegExpElement < SymbolType > & other ) const override {
114 if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return * this == static_cast < decltype ( ( * this ) ) > ( other );
115
116 return false;
117 }
118
127
131 void operator >>( ext::ostream & out ) const override;
132
138 }
139};
140
141} /* namespace regexp */
142
143#include "../formal/FormalRegExpEmpty.h"
144
145namespace regexp {
146
147template < class SymbolType >
148UnboundedRegExpEmpty < SymbolType > * UnboundedRegExpEmpty < SymbolType >::clone ( ) const & {
149 return new UnboundedRegExpEmpty ( * this );
150}
151
152template < class SymbolType >
153UnboundedRegExpEmpty < SymbolType > * UnboundedRegExpEmpty < SymbolType >::clone ( ) && {
154 return new UnboundedRegExpEmpty ( std::move ( * this ) );
155}
156
157template < class SymbolType >
160}
161
162template < class SymbolType >
164 return std::strong_ordering::equal;
165}
166
167template < class SymbolType >
169 return true;
170}
171
172template < class SymbolType >
174 out << "(UnboundedRegExpEmpty)";
175}
176
177template < class SymbolType >
179 return false;
180}
181
182template < class SymbolType >
184 return true;
185}
186
187template < class SymbolType >
189}
190
191} /* namespace regexp */
192
194
Nullary node is specialisation of Anyary node to no children.
Definition: tree_base.hpp:358
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 empty expression in the regular expression. The node can't have any children.
Definition: FormalRegExpEmpty.h:41
Definition: UnboundedRegExpElement.h:81
Definition: UnboundedRegExpElement.h:67
virtual void visit(const UnboundedRegExpAlternation< SymbolType > &)=0
Definition: UnboundedRegExpElement.h:62
Represents the empty expression in the regular expression. The node can't have any children.
Definition: UnboundedRegExpEmpty.h:41
ext::smart_ptr< UnboundedRegExpElement< DefaultSymbolType > > normalize() &&override
< SymbolType >::normalize ( ) &&
Definition: UnboundedRegExpEmpty.h:136
void computeMinimalAlphabet(ext::set< SymbolType > &alphabet) const override
Definition: UnboundedRegExpEmpty.h:188
bool testSymbol(const SymbolType &symbol) const override
Definition: UnboundedRegExpEmpty.h:178
std::strong_ordering operator<=>(const UnboundedRegExpElement< SymbolType > &other) const override
< SymbolType >::operator <=> ( const UnboundedRegExpElement < SymbolType > & other ) const;
Definition: UnboundedRegExpEmpty.h:95
bool operator==(const UnboundedRegExpElement< SymbolType > &other) const override
< SymbolType >::operator == ( const UnboundedRegExpElement < SymbolType > & other ) const;
Definition: UnboundedRegExpEmpty.h:113
void operator>>(ext::ostream &out) const override
< UnboundedRegExpElement < SymbolType > >::operator >> ( ext::ostream & )
Definition: UnboundedRegExpEmpty.h:173
ext::smart_ptr< FormalRegExpElement< SymbolType > > asFormal() const override
Definition: UnboundedRegExpEmpty.h:158
bool checkAlphabet(const ext::set< SymbolType > &alphabet) const override
Definition: UnboundedRegExpEmpty.h:183
UnboundedRegExpEmpty()=default
Creates a new instance of the empty node.
UnboundedRegExpEmpty< SymbolType > * clone() const &override
( ) const &
Definition: BarSymbol.cpp:12
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
Definition: sigHandler.cpp:20
Definition: ToAutomaton.h:15
Definition: FordFulkerson.hpp:16