Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
RTEFromXmlParser.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <alib/set>
9#include <alib/deque>
10#include <sax/Token.h>
12#include <core/xmlApi.hpp>
13
15
17
18
19namespace rte {
20
25public:
26 template < class SymbolType >
27 static std::pair < ext::set < common::ranked_symbol < SymbolType > >, ext::set < common::ranked_symbol < SymbolType > > > parseAlphabet ( ext::deque < sax::Token >::iterator & input );
28
29 template < class SymbolType >
31
32 template < class SymbolType >
34 template < class SymbolType >
36 template < class SymbolType >
38 template < class SymbolType >
40 template < class SymbolType >
42 template < class SymbolType >
44};
45
46template < class SymbolType >
47std::pair < ext::set < common::ranked_symbol < SymbolType > >, ext::set < common::ranked_symbol < SymbolType > > > RTEFromXmlParser::parseAlphabet ( ext::deque < sax::Token >::iterator & input ) {
50
52
54 alphabetF.insert ( core::xmlApi < common::ranked_symbol < SymbolType > >::parse ( input ) );
55
57
59
61 alphabetK.insert ( core::xmlApi < common::ranked_symbol < SymbolType > >::parse ( input ) );
62
64
65 return std::make_pair ( alphabetF, alphabetK );
66}
67
68template < class SymbolType >
71 return parseFormalRTEEmpty < SymbolType > ( input );
73 return parseFormalRTEIteration < SymbolType > ( input );
75 return parseFormalRTEAlternation < SymbolType > ( input );
77 return parseFormalRTESubstitution < SymbolType > ( input );
79 return parseFormalRTESymbolAlphabet < SymbolType > ( input );
80 else
81 return parseFormalRTESymbolSubst < SymbolType > ( input );
82}
83
84template < class SymbolType >
87
88 ext::ptr_value < FormalRTEElement < SymbolType > > element1 = parseFormalRTEElement < SymbolType > ( input );
89 ext::ptr_value < FormalRTEElement < SymbolType > > element2 = parseFormalRTEElement < SymbolType > ( input );
90
91 ext::ptr_value < FormalRTEAlternation < SymbolType > > alternation ( FormalRTEAlternation < SymbolType > ( std::move ( element1 ), std::move ( element2 ) ) );
92
94 return alternation;
95}
96
97template < class SymbolType >
100
102 ext::ptr_value < FormalRTEElement < SymbolType > > element1 = parseFormalRTEElement < SymbolType > ( input );
103 ext::ptr_value < FormalRTEElement < SymbolType > > element2 = parseFormalRTEElement < SymbolType > ( input );
104
105 ext::ptr_value < FormalRTESubstitution < SymbolType > > substitution ( FormalRTESubstitution < SymbolType > ( std::move ( element1 ), std::move ( element2 ), std::move ( ssymb ) ) );
106
108 return substitution;
109}
110
111template < class SymbolType >
114
116 ext::ptr_value < FormalRTEElement < SymbolType > > element = parseFormalRTEElement < SymbolType > ( input );
117 ext::ptr_value < FormalRTEIteration < SymbolType > > iteration ( FormalRTEIteration < SymbolType > ( std::move ( element ), std::move ( ssymb ) ) );
118
120 return iteration;
121}
122
123template < class SymbolType >
126
128
130
131 return empty;
132}
133
134template < class SymbolType >
139
141 elements.push_back ( static_cast < FormalRTEElement < SymbolType > && > ( parseFormalRTEElement < SymbolType > ( input ) ) );
142
144
146
147 return ret;
148}
149
150template < class SymbolType >
154
156
158
159 return ret;
160}
161
162} /* namespace rte */
163
Definition: ranked_symbol.hpp:20
Class extending the deque class from the standard library. Original reason is to allow printing of th...
Definition: deque.hpp:44
Class representing wrapper of dynamically allocated object behaving like rvalue reference.
Definition: ptr_value.hpp:40
Implementation of vector storing dynamicaly allocated instances of given type. The class mimicks the ...
Definition: ptr_vector.hpp:44
void push_back(R &&value)
Appends a new value at the end of the container.
Definition: ptr_vector.hpp:1228
Definition: set.hpp:44
Represents the alternation operator in the regular tree expression. The node must have exactly two ch...
Definition: FormalRTEAlternation.h:44
Definition: FormalRTEElement.h:54
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
Definition: RTEFromXmlParser.h:24
static ext::ptr_value< FormalRTESymbolSubst< SymbolType > > parseFormalRTESymbolSubst(ext::deque< sax::Token >::iterator &input)
Definition: RTEFromXmlParser.h:151
static std::pair< ext::set< common::ranked_symbol< SymbolType > >, ext::set< common::ranked_symbol< SymbolType > > > parseAlphabet(ext::deque< sax::Token >::iterator &input)
Definition: RTEFromXmlParser.h:47
static ext::ptr_value< FormalRTESymbolAlphabet< SymbolType > > parseFormalRTESymbolAlphabet(ext::deque< sax::Token >::iterator &input)
Definition: RTEFromXmlParser.h:135
static ext::ptr_value< FormalRTEElement< SymbolType > > parseFormalRTEElement(ext::deque< sax::Token >::iterator &input)
Definition: RTEFromXmlParser.h:69
static ext::ptr_value< FormalRTEEmpty< SymbolType > > parseFormalRTEEmpty(ext::deque< sax::Token >::iterator &input)
Definition: RTEFromXmlParser.h:124
static ext::ptr_value< FormalRTEIteration< SymbolType > > parseFormalRTEIteration(ext::deque< sax::Token >::iterator &input)
Definition: RTEFromXmlParser.h:112
static ext::ptr_value< FormalRTESubstitution< SymbolType > > parseFormalRTESubstitution(ext::deque< sax::Token >::iterator &input)
Definition: RTEFromXmlParser.h:98
static ext::ptr_value< FormalRTEAlternation< SymbolType > > parseFormalRTEAlternation(ext::deque< sax::Token >::iterator &input)
Definition: RTEFromXmlParser.h:85
static void popToken(ext::deque< Token >::iterator &input, Token::TokenType type, const std::string &data)
Definition: FromXMLParserHelper.cpp:39
static bool isToken(ext::deque< Token >::const_iterator input, Token::TokenType type, const std::string &data)
Definition: FromXMLParserHelper.cpp:29
static bool isTokenType(ext::deque< Token >::const_iterator input, Token::TokenType type)
Definition: FromXMLParserHelper.cpp:34
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
constexpr auto make_pair(T1 &&x, T2 &&y)
Definition: pair.hpp:79
Definition: ToFTAGlushkov.h:22
Definition: xmlApi.hpp:27