Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
AutomatonFromXMLParser.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <alib/deque>
9#include <alib/set>
10#include <alib/multiset>
11#include <alib/vector>
12#include <alib/map>
13
15#include <sax/ParserException.h>
16#include <core/xmlApi.hpp>
17
22
23namespace automaton {
24
29public:
30 template<class T>
32
33 template < class StateType >
35 template < class SymbolType >
37 template < class SymbolType >
39 template < class SymbolType >
41 template < class SymbolType >
43 template < class SymbolType >
45 template < class SymbolType >
47 template < class SymbolType >
49 template < class SymbolType >
51 template < class SymbolType >
53 template < class SymbolType >
55 template < class StateType >
57 template < class StateType >
59 template < class StateType >
61 template < class SymbolType >
63 template < class SymbolType >
65 template < class InputSymbolType, class PushdownStoreSymbolType >
67
68 template < class StateType >
70 template < class StateType >
72 template < class StateType >
74 template < class StateType >
76 template < class SymbolType >
78 template < class SymbolType >
80 template < class SymbolType >
82 template < class SymbolType >
84
85 template < class SymbolType >
87 template < class SymbolType >
89
90 template < class SymbolType >
92 template < class SymbolType >
94
97
98 std::string data;
101
102 Shift shift ( shiftFromString ( data ) );
103
105
106 return shift;
107 }
108
109 template < class SymbolType >
111};
112
113template<class T>
118 }
120}
121
122template < class StateType >
126
128 states.insert ( core::xmlApi < StateType >::parse ( input ) );
129
131 return states;
132}
133
134template < class SymbolType >
136 ext::set < SymbolType > inputSymbols;
138
140 inputSymbols.insert ( core::xmlApi < SymbolType >::parse ( input ) );
141
143 return inputSymbols;
144}
145
146template < class SymbolType >
148 ext::set < SymbolType > inputSymbols;
150
152 inputSymbols.insert ( core::xmlApi < SymbolType >::parse ( input ) );
153
155 return inputSymbols;
156}
157
158template < class SymbolType >
160 ext::set < SymbolType > inputSymbols;
162
164 inputSymbols.insert ( core::xmlApi < SymbolType >::parse ( input ) );
165
167 return inputSymbols;
168}
169
170template < class SymbolType >
172 ext::set < SymbolType > inputSymbols;
174
176 inputSymbols.insert ( core::xmlApi < SymbolType >::parse ( input ) );
177
179 return inputSymbols;
180}
181
182template < class SymbolType >
184 ext::set < SymbolType > inputSymbols;
186
188 inputSymbols.insert ( core::xmlApi < SymbolType >::parse ( input ) );
189
191 return inputSymbols;
192}
193
194template < class StateType >
199
200 return state;
201}
202
203template < class StateType >
205 ext::set < StateType > initialStates;
207
209 initialStates.insert ( core::xmlApi < StateType >::parse ( input ) );
210
212 return initialStates;
213}
214
215template < class StateType >
217 ext::set < StateType > finalStates;
219
221 finalStates.insert ( core::xmlApi < StateType >::parse ( input ) );
222
224 return finalStates;
225}
226
227template < class SymbolType >
229 ext::set < SymbolType > stackSymbols;
231
233 stackSymbols.insert ( core::xmlApi < SymbolType >::parse ( input ) );
234
236 return stackSymbols;
237}
238
239template < class SymbolType >
241 ext::set < SymbolType > initialSymbols;
242 sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "initialPushdownStoreSymbols" );
243
245 initialSymbols.insert ( core::xmlApi < SymbolType >::parse ( input ) );
246
247 sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, "initialPushdownStoreSymbols" );
248 return initialSymbols;
249}
250
251template < class SymbolType >
253 ext::set < SymbolType > outputSymbols;
255
257 outputSymbols.insert ( core::xmlApi < SymbolType >::parse ( input ) );
258
260 return outputSymbols;
261}
262
263template < class SymbolType >
265 sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "initialPushdownStoreSymbol" );
266 SymbolType initialSymbol ( core::xmlApi < SymbolType >::parse ( input ) );
267 sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, "initialPushdownStoreSymbol" );
268
269 return initialSymbol;
270}
271
272template < class SymbolType >
274 ext::set < SymbolType > tapeSymbols;
276
278 tapeSymbols.insert ( core::xmlApi < SymbolType >::parse ( input ) );
279
281 return tapeSymbols;
282}
283
284template < class SymbolType >
289
290 return blank;
291}
292
293template < class SymbolType >
298
299 return blank;
300}
301
302template < class InputSymbolType, class PushdownStoreSymbolType >
305
306 sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "inputToPushdownStoreOperations" );
307
310
311 InputSymbolType inputSymbol ( core::xmlApi < InputSymbolType >::parse ( input ) );
312
313 ext::vector < PushdownStoreSymbolType > pop = parseTransitionPop < PushdownStoreSymbolType > ( input );
314 ext::vector < PushdownStoreSymbolType > push = parseTransitionPush < PushdownStoreSymbolType > ( input );
315
316 operations.insert ( std::move ( inputSymbol ), ext::make_pair ( std::move ( pop ), std::move ( push ) ) );
317
319 }
320
321 sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, "inputToPushdownStoreOperations" );
322 return operations;
323}
324
325template < class StateType >
330
331 return state;
332}
333
334template < class StateType >
339
340 return state;
341}
342
343template < class StateType >
347
349 states.push_back ( core::xmlApi < StateType >::parse ( input ) );
350
352 return states;
353}
354
355template < class StateType >
359
361 states.insert ( core::xmlApi < StateType >::parse ( input ) );
362
364 return states;
365}
366
367template < class SymbolType >
371
373 pops.push_back ( core::xmlApi < SymbolType >::parse ( input ) );
374
376 return pops;
377}
378
379template < class SymbolType >
384
385 return pop;
386}
387
388template < class SymbolType >
392
394 pushes.push_back ( core::xmlApi < SymbolType >::parse ( input ) );
395
397 return pushes;
398}
399
400template < class SymbolType >
405
406 return push;
407}
408
409template < class SymbolType >
414
415 return result;
416}
417
418template < class SymbolType >
423
424 return result;
425}
426
427template < class SymbolType >
429 ext::vector < SymbolType > inputSymbols;
431
433 inputSymbols.push_back ( core::xmlApi < SymbolType >::parse ( input ) );
434
436 return inputSymbols;
437}
438
439template < class SymbolType >
441 ext::vector < SymbolType > outputSymbols;
443
445 outputSymbols.push_back ( core::xmlApi < SymbolType >::parse ( input ) );
446
448 return outputSymbols;
449}
450
451template < class SymbolType >
456
457 return result;
458}
459
460} /* namespace automaton */
461
462
Definition: AutomatonFromXMLParser.h:28
static SymbolType parseBottomOfTheStackSymbol(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:294
static SymbolType parseTransitionOutputSymbol(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:419
static SymbolType parseBlankSymbol(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:285
static SymbolType parseTransitionInputSymbol(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:410
static ext::set< SymbolType > parseOutputAlphabet(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:252
static SymbolType parseTransitionSinglePush(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:401
static ext::set< StateType > parseStates(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:123
static Shift parseTransitionShift(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:95
static SymbolType parseInitialPushdownStoreSymbol(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:264
static StateType parseInitialState(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:195
static ext::set< SymbolType > parseRankedInputAlphabet(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:183
static ext::set< SymbolType > parseTapeAlphabet(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:273
static ext::multiset< StateType > parseTransitionFromMultiset(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:356
static ext::vector< SymbolType > parseTransitionInputSymbolMultiple(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:428
static SymbolType parseTransitionSinglePop(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:380
static ext::set< SymbolType > parseReturnInputAlphabet(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:147
static void parseTransitions(ext::deque< sax::Token >::iterator &input, T &automaton)
Definition: AutomatonFromXMLParser.h:114
static StateType parseTransitionTo(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:326
static ext::set< SymbolType > parseInputAlphabet(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:171
static ext::set< SymbolType > parseLocalInputAlphabet(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:159
static ext::set< StateType > parseFinalStates(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:216
static regexp::UnboundedRegExpStructure< SymbolType > parseTransitionInputRegexp(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:452
static ext::set< SymbolType > parsePushdownStoreAlphabet(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:228
static ext::set< SymbolType > parseInitialPushdownStoreSymbols(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:240
static ext::map< InputSymbolType, ext::pair< ext::vector< PushdownStoreSymbolType >, ext::vector< PushdownStoreSymbolType > > > parseInputToPushdownStoreOperation(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:303
static StateType parseTransitionFrom(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:335
static ext::vector< SymbolType > parseTransitionOutputSymbolMultiple(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:440
static ext::vector< SymbolType > parseTransitionPush(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:389
static ext::set< StateType > parseInitialStates(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:204
static ext::set< SymbolType > parseCallInputAlphabet(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:135
static ext::vector< StateType > parseTransitionFromMultiple(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:344
static ext::vector< SymbolType > parseTransitionPop(ext::deque< sax::Token >::iterator &input)
Definition: AutomatonFromXMLParser.h:368
Class extending the deque class from the standard library. Original reason is to allow printing of th...
Definition: deque.hpp:44
Class extending the map class from the standard library. Original reason is to allow printing of the ...
Definition: map.hpp:48
std::pair< iterator, bool > insert(const T &key, const R &value)
Insert variant with explicit key and value parameters.
Definition: map.hpp:118
Definition: multiset.hpp:44
Definition: set.hpp:44
Class extending the vector class from the standard library. Original reason is to allow printing of t...
Definition: vector.hpp:45
Represents unbounded regular expression structure. Regular expression is stored as a tree of Unbounde...
Definition: UnboundedRegExpStructure.h:47
static void popToken(ext::deque< Token >::iterator &input, Token::TokenType type, const std::string &data)
Definition: FromXMLParserHelper.cpp:39
static std::string popTokenData(ext::deque< Token >::iterator &input, Token::TokenType type)
Definition: FromXMLParserHelper.cpp:48
static bool isTokenType(ext::deque< Token >::const_iterator input, Token::TokenType type)
Definition: FromXMLParserHelper.cpp:34
typename T::StateType StateType
Definition: ToGrammarLeftRG.h:64
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
for(const StateType &state :fsm.getStates()) renamingData.insert(std Rename::RenamedAutomaton< T > result(renamingData.at(fsm.getInitialState()))
Definition: Rename.h:253
Definition: ToGrammar.h:31
Shift
Definition: Shift.h:15
automaton::Shift shiftFromString(const std::string &shift)
Definition: Shift.cpp:11
constexpr auto make_pair(T1 &&x, T2 &&y)
Definition: pair.hpp:79
Definition: xmlApi.hpp:27