Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
GlushkovFirst.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <alib/set>
10
12
13namespace rte {
14
16public:
21 template < class SymbolType >
23
24 template < class SymbolType >
25 class Formal {
26 public:
33 };
34};
35
36template < class SymbolType >
38 return rte.getRTE ( ).getStructure ( ).template accept < ext::set < common::ranked_symbol < SymbolType > >, GlushkovFirst::Formal < SymbolType > > ( );
39}
40
41template < class SymbolType >
45
46 tmp = node.getLeftElement ( ).template accept < ext::set < common::ranked_symbol < SymbolType > >, GlushkovFirst::Formal < SymbolType > > ( );
47 ret.insert ( tmp.begin ( ), tmp.end ( ) );
48
49 tmp = node.getRightElement ( ).template accept < ext::set < common::ranked_symbol < SymbolType > >, GlushkovFirst::Formal < SymbolType > > ( );
50 ret.insert ( tmp.begin ( ), tmp.end ( ) );
51
52 return ret;
53}
54
55template < class SymbolType >
59
60 tmp = node.getLeftElement ( ).template accept < ext::set < common::ranked_symbol < SymbolType > >, GlushkovFirst::Formal < SymbolType > > ( );
61 ret.insert ( tmp.begin ( ), tmp.end ( ) );
62
63 // First returns a set. hence only one occurrence.
64 auto it = std::find_if ( ret.begin ( ), ret.end ( ), [node] ( const common::ranked_symbol < SymbolType > & a ) {
65 return a == node.getSubstitutionSymbol ( ).getSymbol ( );
66 } );
67
68 if ( it != ret.end ( ) ) {
69 ret.erase ( it );
70 tmp = node.getRightElement ( ).template accept < ext::set < common::ranked_symbol < SymbolType > >, GlushkovFirst::Formal < SymbolType > > ( );
71 ret.insert ( tmp.begin ( ), tmp.end ( ) );
72 }
73
74 return ret;
75}
76
77template < class SymbolType >
80
81 ret = node.getElement ( ).template accept < ext::set < common::ranked_symbol < SymbolType > >, GlushkovFirst::Formal < SymbolType > > ( );
82 ret.insert ( node.getSubstitutionSymbol ( ).getSymbol ( ) );
83 return ret;
84}
85
86template < class SymbolType >
89}
90
91template < class SymbolType >
94}
95
96template < class SymbolType >
99}
100
101} /* namespace rte */
102
Definition: ranked_symbol.hpp:20
Definition: set.hpp:44
auto begin() &
Inherited behavior of begin for non-const instance.
Definition: set.hpp:99
auto end() &
Inherited behavior of end for non-const instance.
Definition: set.hpp:129
Represents the alternation operator in the regular tree expression. The node must have exactly two ch...
Definition: FormalRTEAlternation.h:44
Represents the empty expression in the regular tree expression. The node can't have any children.
Definition: FormalRTEEmpty.h:40
Represents the iteration operator in the regular tree expression. The node has exactly one child.
Definition: FormalRTEIteration.h:45
Represents the concatenation operator in the regular tree expression. The node must have exactly two ...
Definition: FormalRTESubstitution.h:44
Represents the terminal symbol in the regular tree expression. The number of children must be the sam...
Definition: FormalRTESymbolAlphabet.h:44
Represents the substitution symbol in the regular tree expression. The node can't have any children.
Definition: FormalRTESymbolSubst.h:43
Formal regular tree expression represents regular tree expression. It describes regular tree language...
Definition: FormalRTE.h:71
Definition: GlushkovFirst.h:25
static ext::set< common::ranked_symbol< SymbolType > > visit(const rte::FormalRTEAlternation< SymbolType > &node)
Definition: GlushkovFirst.h:42
Definition: GlushkovFirst.h:15
static ext::set< common::ranked_symbol< SymbolType > > first(const rte::FormalRTE< SymbolType > &rte)
Definition: GlushkovFirst.h:37
ext::set< ext::pair< StateType, StateType > > ret(const ext::set< ext::pair< StateType, StateType > > &S, const DeterministicPushdownStoreSymbolType &pdaSymbol, const InputSymbolType &input, const N &nondeterministic)
Definition: RHDPDACommon.h:57
Definition: Node.cpp:11
Definition: ToFTAGlushkov.h:22