Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
RTEToXmlComposer.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <alib/deque>
10#include <sax/Token.h>
11#include <core/xmlApi.hpp>
12
14
15namespace rte {
16
21public:
22 template < class SymbolType >
24
25 class Formal {
26 public:
27 template < class SymbolType >
28 static void visit ( const FormalRTEAlternation < SymbolType > & alternation, ext::deque < sax::Token > & output );
29 template < class SymbolType >
30 static void visit ( const FormalRTEIteration < SymbolType > & iteration, ext::deque < sax::Token > & output );
31 template < class SymbolType >
32 static void visit ( const FormalRTESubstitution < SymbolType > & substitution, ext::deque < sax::Token > & output );
33 template < class SymbolType >
34 static void visit ( const FormalRTESymbolAlphabet < SymbolType > & symbol, ext::deque < sax::Token > & output );
35 template < class SymbolType >
36 static void visit ( const FormalRTESymbolSubst < SymbolType > & symbol, ext::deque < sax::Token > & output );
37 template < class SymbolType >
38 static void visit ( const FormalRTEEmpty < SymbolType > & empty, ext::deque < sax::Token > & output );
39 };
40};
41
42template < class SymbolType >
44 output.emplace_back ( "alternation", sax::Token::TokenType::START_ELEMENT );
45 alternation.getLeftElement ( ).template accept < void, RTEToXmlComposer::Formal > ( output );
46 alternation.getRightElement ( ).template accept < void, RTEToXmlComposer::Formal > ( output );
47 output.emplace_back ( "alternation", sax::Token::TokenType::END_ELEMENT );
48}
49
50template < class SymbolType >
52 output.emplace_back ( "substitution", sax::Token::TokenType::START_ELEMENT );
53
54 core::xmlApi < common::ranked_symbol < SymbolType > >::compose ( output, substitution.getSubstitutionSymbol ( ).getSymbol ( ) );
55 substitution.getLeftElement ( ).template accept < void, RTEToXmlComposer::Formal > ( output );
56 substitution.getRightElement ( ).template accept < void, RTEToXmlComposer::Formal > ( output );
57
58 output.emplace_back ( "substitution", sax::Token::TokenType::END_ELEMENT );
59}
60
61template < class SymbolType >
63 output.emplace_back ( "iteration", sax::Token::TokenType::START_ELEMENT );
64
65 core::xmlApi < common::ranked_symbol < SymbolType > >::compose ( output, iteration.getSubstitutionSymbol ( ).getSymbol ( ) );
66 iteration.getElement ( ).template accept < void, RTEToXmlComposer::Formal > ( output );
67
68 output.emplace_back ( "iteration", sax::Token::TokenType::END_ELEMENT );
69}
70
71template < class SymbolType >
73 output.emplace_back ( sax::Token ( "symbol", sax::Token::TokenType::START_ELEMENT ) );
74 core::xmlApi < common::ranked_symbol < SymbolType > >::compose ( output, symbol.getSymbol ( ) );
75
76 for ( const FormalRTEElement < SymbolType > & element : symbol.getElements ( ) )
77 element.template accept < void, RTEToXmlComposer::Formal > ( output );
78
79 output.emplace_back ( sax::Token ( "symbol", sax::Token::TokenType::END_ELEMENT ) );
80}
81
82template < class SymbolType >
84 output.emplace_back ( sax::Token ( "substSymbol", sax::Token::TokenType::START_ELEMENT ) );
85 core::xmlApi < common::ranked_symbol < SymbolType > >::compose ( output, symbol.getSymbol ( ) );
86
87 output.emplace_back ( sax::Token ( "substSymbol", sax::Token::TokenType::END_ELEMENT ) );
88}
89
90template < class SymbolType >
92 output.emplace_back ( "empty", sax::Token::TokenType::START_ELEMENT );
93 output.emplace_back ( "empty", sax::Token::TokenType::END_ELEMENT );
94}
95
96template < class SymbolType >
98 output.emplace_back ( "alphabet", sax::Token::TokenType::START_ELEMENT );
99
100 for ( const auto & symbol : alphabetF )
101 core::xmlApi < common::ranked_symbol < SymbolType > >::compose ( output, symbol );
102
103 output.emplace_back ( "alphabet", sax::Token::TokenType::END_ELEMENT );
104
105 output.emplace_back ( "substSymbolAlphabet", sax::Token::TokenType::START_ELEMENT );
106
107 for ( const auto & symbol : alphabetK )
108 core::xmlApi < common::ranked_symbol < SymbolType > >::compose ( output, symbol );
109
110 output.emplace_back ( "substSymbolAlphabet", sax::Token::TokenType::END_ELEMENT );
111}
112
113} /* namespace rte */
114
Definition: ranked_symbol.hpp:20
Definition: set.hpp:44
Represents the alternation operator in the regular tree expression. The node must have exactly two ch...
Definition: FormalRTEAlternation.h:44
const FormalRTEElement< SymbolType > & getRightElement() const
Definition: FormalRTEAlternation.h:220
const FormalRTEElement< SymbolType > & getLeftElement() const
Definition: FormalRTEAlternation.h:215
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
const FormalRTEElement< SymbolType > & getElement() const
Definition: FormalRTEIteration.h:215
const FormalRTESymbolSubst< SymbolType > & getSubstitutionSymbol() const
Definition: FormalRTEIteration.h:225
Represents the concatenation operator in the regular tree expression. The node must have exactly two ...
Definition: FormalRTESubstitution.h:44
const FormalRTESymbolSubst< SymbolType > & getSubstitutionSymbol() const
Definition: FormalRTESubstitution.h:254
const FormalRTEElement< SymbolType > & getLeftElement() const
Definition: FormalRTESubstitution.h:244
const FormalRTEElement< SymbolType > & getRightElement() const
Definition: FormalRTESubstitution.h:249
Represents the terminal symbol in the regular tree expression. The number of children must be the sam...
Definition: FormalRTESymbolAlphabet.h:44
const ext::ptr_vector< FormalRTEElement< SymbolType > > & getElements() const
Definition: FormalRTESymbolAlphabet.h:207
Represents the substitution symbol in the regular tree expression. The node can't have any children.
Definition: FormalRTESymbolSubst.h:43
const common::ranked_symbol< SymbolType > & getSymbol() const &
Definition: FormalRTESymbol.h:71
Definition: RTEToXmlComposer.h:25
static void visit(const FormalRTEAlternation< SymbolType > &alternation, ext::deque< sax::Token > &output)
Definition: RTEToXmlComposer.h:43
Definition: RTEToXmlComposer.h:20
static void composeAlphabet(ext::deque< sax::Token > &output, const ext::set< common::ranked_symbol< SymbolType > > &alphabetF, const ext::set< common::ranked_symbol< SymbolType > > &alphabetK)
Definition: RTEToXmlComposer.h:97
Definition: Token.h:17
Definition: ToFTAGlushkov.h:22
Definition: xmlApi.hpp:27