Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
FormalRegExpEmpty.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
27#include "FormalRegExpElement.h"
28
29namespace regexp {
30
40template < class SymbolType >
41class FormalRegExpEmpty : public ext::NullaryNode < FormalRegExpElement < SymbolType > > {
45 void accept ( typename FormalRegExpElement < SymbolType >::Visitor & visitor ) const override {
46 visitor.visit ( * this );
47 }
48
49public:
53 explicit FormalRegExpEmpty ( ) = default;
54
59
63 FormalRegExpEmpty < SymbolType > * clone ( ) && override;
64
68 ext::smart_ptr < UnboundedRegExpElement < SymbolType > > asUnbounded ( ) const override;
69
73 bool testSymbol ( const SymbolType & symbol ) const override;
74
78 void computeMinimalAlphabet ( ext::set < SymbolType > & alphabet ) const override;
79
83 bool checkAlphabet ( const ext::set < SymbolType > & alphabet ) const override;
84
88 std::strong_ordering operator <=> ( const FormalRegExpElement < SymbolType > & other ) const override {
89 if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return * this <=> static_cast < decltype ( ( * this ) ) > ( other );
90
91 return ext::type_index ( typeid ( * this ) ) <=> ext::type_index ( typeid ( other ) );
92 }
93
101 std::strong_ordering operator <=> ( const FormalRegExpEmpty < SymbolType > & ) const;
102
106 bool operator == ( const FormalRegExpElement < SymbolType > & other ) const override {
107 if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return * this == static_cast < decltype ( ( * this ) ) > ( other );
108
109 return false;
110 }
111
120
124 void operator >>( ext::ostream & out ) const override;
125
131 }
132};
133
134} /* namespace regexp */
135
136#include "../unbounded/UnboundedRegExpEmpty.h"
137
138namespace regexp {
139
140template < class SymbolType >
141FormalRegExpEmpty < SymbolType > * FormalRegExpEmpty < SymbolType >::clone ( ) const & {
142 return new FormalRegExpEmpty ( * this );
143}
144
145template < class SymbolType >
146FormalRegExpEmpty < SymbolType > * FormalRegExpEmpty < SymbolType >::clone ( ) && {
147 return new FormalRegExpEmpty ( std::move ( * this ) );
148}
149
150template < class SymbolType >
153}
154
155template < class SymbolType >
157 return std::strong_ordering::equal;
158}
159
160template < class SymbolType >
162 return true;
163}
164
165template < class SymbolType >
167 out << "(FormalRegExpEmpty)";
168}
169
170template < class SymbolType >
172 return false;
173}
174
175template < class SymbolType >
177}
178
179template < class SymbolType >
181 return true;
182}
183
184} /* namespace regexp */
185
187
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:67
virtual void visit(const FormalRegExpAlternation< SymbolType > &)=0
Definition: FormalRegExpElement.h:62
Represents the empty expression in the regular expression. The node can't have any children.
Definition: FormalRegExpEmpty.h:41
bool checkAlphabet(const ext::set< SymbolType > &alphabet) const override
Definition: FormalRegExpEmpty.h:180
FormalRegExpEmpty()=default
Creates a new instance of the empty node.
void computeMinimalAlphabet(ext::set< SymbolType > &alphabet) const override
Definition: FormalRegExpEmpty.h:176
std::strong_ordering operator<=>(const FormalRegExpElement< SymbolType > &other) const override
< SymbolType >::operator <=> ( const FormalRegExpElement < SymbolType > & other ) const;
Definition: FormalRegExpEmpty.h:88
void operator>>(ext::ostream &out) const override
< FormalRegExpElement < SymbolType > >::operator >> ( ext::ostream & )
Definition: FormalRegExpEmpty.h:166
bool testSymbol(const SymbolType &symbol) const override
Definition: FormalRegExpEmpty.h:171
ext::smart_ptr< UnboundedRegExpElement< SymbolType > > asUnbounded() const override
( ) const &
Definition: FormalRegExpEmpty.h:151
ext::smart_ptr< FormalRegExpElement< DefaultSymbolType > > normalize() &&override
< SymbolType >::normalize ( ) &&
Definition: FormalRegExpEmpty.h:129
FormalRegExpEmpty< SymbolType > * clone() const &override
( ) const &
bool operator==(const FormalRegExpElement< SymbolType > &other) const override
< SymbolType >::operator == ( const FormalRegExpElement < SymbolType > & other ) const;
Definition: FormalRegExpEmpty.h:106
Definition: UnboundedRegExpElement.h:62
Represents the empty expression in the regular expression. The node can't have any children.
Definition: UnboundedRegExpEmpty.h:41
Definition: BarSymbol.cpp:12
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
Definition: sigHandler.cpp:20
Definition: ToAutomaton.h:15
Definition: FordFulkerson.hpp:16