Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
RegExpFromXmlParser.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>
11
13
16#include <core/xmlApi.hpp>
17
18namespace regexp {
19
24public:
25 template < class SymbolType >
27
28 template < class SymbolType >
30
31 template < class SymbolType >
33 template < class SymbolType >
35 template < class SymbolType >
37 template < class SymbolType >
39 template < class SymbolType >
41
42 template < class SymbolType >
44
45 template < class SymbolType >
47 template < class SymbolType >
49 template < class SymbolType >
51 template < class SymbolType >
53 template < class SymbolType >
55};
56
57template < class SymbolType >
61
64
66 return alphabet;
67}
68
69template < class SymbolType >
72 return parseUnboundedRegExpEmpty < SymbolType > ( input );
74 return parseUnboundedRegExpEpsilon < SymbolType > ( input );
76 return parseUnboundedRegExpIteration < SymbolType > ( input );
78 return parseUnboundedRegExpAlternation < SymbolType > ( input );
80 return parseUnboundedRegExpConcatenation < SymbolType > ( input );
81 else
83}
84
85template < class SymbolType >
88
90
92 alternation.appendElement ( parseUnboundedRegExpElement < SymbolType > ( input ) );
93
95 return ext::ptr_value < UnboundedRegExpElement < SymbolType > > ( std::move ( alternation ) );
96}
97
98template < class SymbolType >
101
103
105 concatenation.appendElement ( parseUnboundedRegExpElement < SymbolType > ( input ) );
106
108 return ext::ptr_value < UnboundedRegExpElement < SymbolType > > ( std::move ( concatenation ) );
109}
110
111template < class SymbolType >
114
115 ext::ptr_value < UnboundedRegExpElement < SymbolType > > iteration ( UnboundedRegExpIteration < SymbolType > ( parseUnboundedRegExpElement < SymbolType > ( input ) ) );
116
118
119 return iteration;
120}
121
122template < class SymbolType >
125
127
129
130 return epsilon;
131}
132
133template < class SymbolType >
136
138
140
141 return empty;
142}
143
144template < class SymbolType >
147 return parseFormalRegExpEmpty < SymbolType > ( input );
149 return parseFormalRegExpEpsilon < SymbolType > ( input );
151 return parseFormalRegExpIteration < SymbolType > ( input );
153 return parseFormalRegExpAlternation < SymbolType > ( input );
154 else if ( sax::FromXMLParserHelper::isToken ( input, sax::Token::TokenType::START_ELEMENT, "concatenation" ) )
155 return parseFormalRegExpConcatenation < SymbolType > ( input );
156 else
158}
159
160template < class SymbolType >
163
164 ext::ptr_value < FormalRegExpElement < SymbolType > > element1 = parseFormalRegExpElement < SymbolType > ( input );
165 ext::ptr_value < FormalRegExpElement < SymbolType > > element2 = parseFormalRegExpElement < SymbolType > ( input );
166
167 ext::ptr_value < FormalRegExpElement < SymbolType > > alternation ( FormalRegExpAlternation < SymbolType > ( std::move ( element1 ), std::move ( element2 ) ) );
168
170
171 return alternation;
172}
173
174template < class SymbolType >
177
178 ext::ptr_value < FormalRegExpElement < SymbolType > > element1 = parseFormalRegExpElement < SymbolType > ( input );
179 ext::ptr_value < FormalRegExpElement < SymbolType > > element2 = parseFormalRegExpElement < SymbolType > ( input );
180
181 ext::ptr_value < FormalRegExpElement < SymbolType > > concatenation ( FormalRegExpConcatenation < SymbolType > ( std::move ( element1 ), std::move ( element2 ) ) );
182
184
185 return concatenation;
186}
187
188template < class SymbolType >
191
192 ext::ptr_value < FormalRegExpElement < SymbolType > > iteration ( FormalRegExpIteration < SymbolType > ( parseFormalRegExpElement < SymbolType > ( input ) ) );
193
195
196 return iteration;
197}
198
199template < class SymbolType >
202
204
206
207 return epsilon;
208}
209
210template < class SymbolType >
213
215
217
218 return empty;
219}
220
221} /* namespace regexp */
222
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
Definition: set.hpp:44
Represents the alternation operator in the regular expression. The node must have exactly two childre...
Definition: FormalRegExpAlternation.h:44
Represents the concatenation operator in the regular expression. The node must have exactly two child...
Definition: FormalRegExpConcatenation.h:44
Represents the empty expression in the regular expression. The node can't have any children.
Definition: FormalRegExpEmpty.h:41
Represents the epsilon expression in the regular expression. The node can't have any children.
Definition: FormalRegExpEpsilon.h:41
Represents the iteration operator in the regular expression. The node has exactly one child.
Definition: FormalRegExpIteration.h:44
Represents the symbol in the regular expression. The can't have any children.
Definition: FormalRegExpSymbol.h:42
Definition: RegExpFromXmlParser.h:23
static ext::ptr_value< FormalRegExpElement< SymbolType > > parseFormalRegExpAlternation(ext::deque< sax::Token >::iterator &input)
Definition: RegExpFromXmlParser.h:161
static ext::ptr_value< UnboundedRegExpElement< SymbolType > > parseUnboundedRegExpAlternation(ext::deque< sax::Token >::iterator &input)
Definition: RegExpFromXmlParser.h:86
static ext::ptr_value< FormalRegExpElement< SymbolType > > parseFormalRegExpEpsilon(ext::deque< sax::Token >::iterator &input)
Definition: RegExpFromXmlParser.h:200
static ext::ptr_value< UnboundedRegExpElement< SymbolType > > parseUnboundedRegExpEmpty(ext::deque< sax::Token >::iterator &input)
Definition: RegExpFromXmlParser.h:134
static ext::ptr_value< FormalRegExpElement< SymbolType > > parseFormalRegExpEmpty(ext::deque< sax::Token >::iterator &input)
Definition: RegExpFromXmlParser.h:211
static ext::ptr_value< UnboundedRegExpElement< SymbolType > > parseUnboundedRegExpEpsilon(ext::deque< sax::Token >::iterator &input)
Definition: RegExpFromXmlParser.h:123
static ext::ptr_value< UnboundedRegExpElement< SymbolType > > parseUnboundedRegExpElement(ext::deque< sax::Token >::iterator &input)
Definition: RegExpFromXmlParser.h:70
static ext::set< SymbolType > parseAlphabet(ext::deque< sax::Token >::iterator &input)
Definition: RegExpFromXmlParser.h:58
static ext::ptr_value< FormalRegExpElement< SymbolType > > parseFormalRegExpConcatenation(ext::deque< sax::Token >::iterator &input)
Definition: RegExpFromXmlParser.h:175
static ext::ptr_value< FormalRegExpElement< SymbolType > > parseFormalRegExpIteration(ext::deque< sax::Token >::iterator &input)
Definition: RegExpFromXmlParser.h:189
static ext::ptr_value< UnboundedRegExpElement< SymbolType > > parseUnboundedRegExpIteration(ext::deque< sax::Token >::iterator &input)
Definition: RegExpFromXmlParser.h:112
static ext::ptr_value< FormalRegExpElement< SymbolType > > parseFormalRegExpElement(ext::deque< sax::Token >::iterator &input)
Definition: RegExpFromXmlParser.h:145
static ext::ptr_value< UnboundedRegExpElement< SymbolType > > parseUnboundedRegExpConcatenation(ext::deque< sax::Token >::iterator &input)
Definition: RegExpFromXmlParser.h:99
Represents the alternation operator in the regular expression. The node can have 0 to n children in l...
Definition: UnboundedRegExpAlternation.h:44
void appendElement(UnboundedRegExpElement< SymbolType > &&element)
Definition: UnboundedRegExpAlternation.h:195
Represents the concatenation operator in the regular expression. The node can have 0 to n children in...
Definition: UnboundedRegExpConcatenation.h:44
void appendElement(UnboundedRegExpElement< SymbolType > &&element)
Definition: UnboundedRegExpConcatenation.h:195
Represents the empty expression in the regular expression. The node can't have any children.
Definition: UnboundedRegExpEmpty.h:41
Represents the epsilon expression in the regular expression. The node can't have any children.
Definition: UnboundedRegExpEpsilon.h:41
Represents the iteration operator in the regular expression. The node has exactly one child.
Definition: UnboundedRegExpIteration.h:43
Represents the symbol in the regular expression. The can't have any children.
Definition: UnboundedRegExpSymbol.h:42
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
Definition: BarSymbol.cpp:12
Definition: ToAutomaton.h:15
Definition: xmlApi.hpp:27