Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
FormalRTESymbolSubst.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 "FormalRTESymbol.h"
27
30
31namespace rte {
32
42template < class SymbolType >
43class FormalRTESymbolSubst : public FormalRTESymbol < SymbolType >, public ext::NullaryNode < FormalRTEElement < SymbolType > > {
47 void accept ( typename FormalRTEElement < SymbolType >::ConstVisitor & visitor ) const override {
48 visitor.visit ( * this );
49 }
50
54 void accept ( typename FormalRTEElement < SymbolType >::Visitor & visitor ) override {
55 visitor.visit ( * this );
56 }
57
58public:
65
70
74 FormalRTESymbolSubst < SymbolType > * clone ( ) && override;
75
79 bool testSymbol ( const common::ranked_symbol < SymbolType > & symbol ) const override;
80
84 void computeMinimalAlphabet ( ext::set < common::ranked_symbol < SymbolType > > & alphabetF, ext::set < common::ranked_symbol < SymbolType > > & alphabetK ) const override;
85
89 bool checkAlphabet ( const ext::set < common::ranked_symbol < SymbolType > > & alphabetF, const ext::set < common::ranked_symbol < SymbolType > > & alphabetK ) const override;
90
94 std::strong_ordering operator <=> ( const FormalRTEElement < SymbolType > & other ) const override {
95 if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return * this <=> static_cast < decltype ( ( * this ) ) > ( other );
96
97 return ext::type_index ( typeid ( * this ) ) <=> ext::type_index ( typeid ( other ) );
98 }
99
107 std::strong_ordering operator <=> ( const FormalRTESymbolSubst < SymbolType > & ) const;
108
112 bool operator == ( const FormalRTEElement < SymbolType > & other ) const override {
113 if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return * this == static_cast < decltype ( ( * this ) ) > ( other );
114
115 return false;
116 }
117
126
130 void operator >>( ext::ostream & out ) const override;
131
137 return ext::smart_ptr < FormalRTEElement < DefaultSymbolType > > ( std::move ( res ).clone ( ) );
138 }
139};
140
141template < class SymbolType >
143}
144
145template < class SymbolType >
147 return new FormalRTESymbolSubst ( * this );
148}
149
150template < class SymbolType >
151FormalRTESymbolSubst < SymbolType > * FormalRTESymbolSubst < SymbolType >::clone ( ) && {
152 return new FormalRTESymbolSubst ( std::move ( * this ) );
153}
154
155template < class SymbolType >
157 return this->getSymbol ( ) <=> other.getSymbol ( );
158}
159
160template < class SymbolType >
162 return this->getSymbol ( ) == other.getSymbol ( );
163}
164
165template < class SymbolType >
167 out << "(FormalRTESymbolSubst " << " symbol = " << this->getSymbol ( ) << "})";
168}
169
170template < class SymbolType >
172 return symbol == this->getSymbol ( );
173}
174
175template < class SymbolType >
177 alphabetK.insert ( this->getSymbol ( ) );
178}
179
180template < class SymbolType >
182 return alphabetK.count ( this->getSymbol ( ) ) > 0;
183}
184
185} /* namespace rte */
186
188
static common::ranked_symbol< DefaultSymbolType > normalizeRankedSymbol(common::ranked_symbol< SymbolType > &&symbol)
Definition: SymbolNormalize.h:81
Definition: ranked_symbol.hpp:20
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: FormalRTEElement.h:59
virtual void visit(const FormalRTEAlternation< SymbolType > &alternation)=0
Definition: FormalRTEElement.h:70
virtual void visit(FormalRTEAlternation< SymbolType > &alternation)=0
Definition: FormalRTEElement.h:54
Represents the substitution symbol in the regular tree expression. The node can't have any children.
Definition: FormalRTESymbolSubst.h:43
std::strong_ordering operator<=>(const FormalRTEElement< SymbolType > &other) const override
< SymbolType >::operator <=> ( const FormalRTEElement < SymbolType > & other ) const;
Definition: FormalRTESymbolSubst.h:94
FormalRTESymbolSubst(common::ranked_symbol< SymbolType > symbol)
Creates a new instance of the symbol node using the actual symbol to represent.
Definition: FormalRTESymbolSubst.h:142
ext::smart_ptr< FormalRTEElement< DefaultSymbolType > > normalize() &&override
< SymbolType >::normalize ( ) &&
Definition: FormalRTESymbolSubst.h:135
void operator>>(ext::ostream &out) const override
< FormalRTEElement < SymbolType > >::operator >> ( ext::ostream & ) const
Definition: FormalRTESymbolSubst.h:166
FormalRTESymbolSubst< SymbolType > * clone() const &override
< SymbolType >::clone ( ) const &
bool testSymbol(const common::ranked_symbol< SymbolType > &symbol) const override
< SymbolType >::testSymbol ( const common::ranked_symbol < SymbolType > & ) const
Definition: FormalRTESymbolSubst.h:171
bool operator==(const FormalRTEElement< SymbolType > &other) const override
< SymbolType >::operator == ( const FormalRTEElement < SymbolType > & other ) const;
Definition: FormalRTESymbolSubst.h:112
bool checkAlphabet(const ext::set< common::ranked_symbol< SymbolType > > &alphabetF, const ext::set< common::ranked_symbol< SymbolType > > &alphabetK) const override
< SymbolType >::checkAlphabet ( const ext::set < common::ranked_symbol < SymbolType > > &,...
Definition: FormalRTESymbolSubst.h:181
void computeMinimalAlphabet(ext::set< common::ranked_symbol< SymbolType > > &alphabetF, ext::set< common::ranked_symbol< SymbolType > > &alphabetK) const override
< SymbolType >::computeMinimalAlphabet ( ext::set < common::ranked_symbol < SymbolType > > &,...
Definition: FormalRTESymbolSubst.h:176
Represents the common part of SubstitutionSymbol and TerminalSymbol.
Definition: FormalRTESymbol.h:37
const common::ranked_symbol< SymbolType > & getSymbol() const &
Definition: FormalRTESymbol.h:71
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
return res
Definition: MinimizeByPartitioning.h:145
Definition: Permutation.hpp:18
Definition: sigHandler.cpp:20
Definition: ToFTAGlushkov.h:22
Definition: FordFulkerson.hpp:16