Skip to content
Snippets Groups Projects
Commit 1c379169 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

split visitors to separate classes II

parent 14ebda49
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,7 @@
 
namespace rte {
 
void RTEToXMLComposer::Visit ( void * userData, const FormalRTEAlternation & alternation ) const {
void RTEToXMLComposer::Formal::Visit ( void * userData, const FormalRTEAlternation & alternation ) const {
std::deque < sax::Token > & out = * ( ( std::deque < sax::Token > * )userData );
 
out.emplace_back ( "alternation", sax::Token::TokenType::START_ELEMENT );
......@@ -18,7 +18,7 @@ void RTEToXMLComposer::Visit ( void * userData, const FormalRTEAlternation & alt
out.emplace_back ( "alternation", sax::Token::TokenType::END_ELEMENT );
}
 
void RTEToXMLComposer::Visit ( void * userData, const FormalRTESubstitution & substitution ) const {
void RTEToXMLComposer::Formal::Visit ( void * userData, const FormalRTESubstitution & substitution ) const {
std::deque < sax::Token > & out = * ( ( std::deque < sax::Token > * )userData );
 
out.emplace_back ( "substitution", sax::Token::TokenType::START_ELEMENT );
......@@ -30,7 +30,7 @@ void RTEToXMLComposer::Visit ( void * userData, const FormalRTESubstitution & su
out.emplace_back ( "substitution", sax::Token::TokenType::END_ELEMENT );
}
 
void RTEToXMLComposer::Visit ( void * userData, const FormalRTEIteration & iteration ) const {
void RTEToXMLComposer::Formal::Visit ( void * userData, const FormalRTEIteration & iteration ) const {
std::deque < sax::Token > & out = * ( ( std::deque < sax::Token > * )userData );
 
out.emplace_back ( "iteration", sax::Token::TokenType::START_ELEMENT );
......@@ -41,7 +41,7 @@ void RTEToXMLComposer::Visit ( void * userData, const FormalRTEIteration & itera
out.emplace_back ( "iteration", sax::Token::TokenType::END_ELEMENT );
}
 
void RTEToXMLComposer::Visit ( void * userData, const FormalRTESymbolAlphabet & symbol ) const {
void RTEToXMLComposer::Formal::Visit ( void * userData, const FormalRTESymbolAlphabet & symbol ) const {
std::deque < sax::Token > & out = * ( ( std::deque < sax::Token > * )userData );
 
out.emplace_back ( sax::Token ( "symbol", sax::Token::TokenType::START_ELEMENT ) );
......@@ -53,7 +53,7 @@ void RTEToXMLComposer::Visit ( void * userData, const FormalRTESymbolAlphabet &
out.emplace_back ( sax::Token ( "symbol", sax::Token::TokenType::END_ELEMENT ) );
}
 
void RTEToXMLComposer::Visit ( void * userData, const FormalRTESymbolSubst & symbol ) const {
void RTEToXMLComposer::Formal::Visit ( void * userData, const FormalRTESymbolSubst & symbol ) const {
std::deque < sax::Token > & out = * ( ( std::deque < sax::Token > * )userData );
 
out.emplace_back ( sax::Token ( "substSymbol", sax::Token::TokenType::START_ELEMENT ) );
......@@ -62,7 +62,7 @@ void RTEToXMLComposer::Visit ( void * userData, const FormalRTESymbolSubst & sym
out.emplace_back ( sax::Token ( "substSymbol", sax::Token::TokenType::END_ELEMENT ) );
}
 
void RTEToXMLComposer::Visit ( void * userData, const FormalRTEEmpty & ) const {
void RTEToXMLComposer::Formal::Visit ( void * userData, const FormalRTEEmpty & ) const {
std::deque < sax::Token > & out = * ( ( std::deque < sax::Token > * )userData );
 
out.emplace_back ( "empty", sax::Token::TokenType::START_ELEMENT );
......@@ -85,6 +85,6 @@ void RTEToXMLComposer::composeAlphabet ( std::deque < sax::Token > & out, const
out.emplace_back ( "substSymbolAlphabet", sax::Token::TokenType::END_ELEMENT );
}
 
RTEToXMLComposer RTEToXMLComposer::RTE_TO_XML_COMPOSER;
const RTEToXMLComposer::Formal RTEToXMLComposer::Formal::FORMAL;
 
} /* namespace rte */
......@@ -13,21 +13,23 @@ namespace rte {
/**
* This class contains methods to print XML representation of regular tree expression to the output stream.
*/
class RTEToXMLComposer : public FormalRTEElementVisitor {
class RTEToXMLComposer {
public:
RTEToXMLComposer ( ) { }
static RTEToXMLComposer RTE_TO_XML_COMPOSER;
static void composeAlphabet ( std::deque < sax::Token > & out, const std::set < std::ranked_symbol < > > & alphabetF, const std::set < std::ranked_symbol < > > & alphabetK );
 
private:
void Visit ( void *, const FormalRTEAlternation & alternation ) const;
void Visit ( void *, const FormalRTEIteration & iteration ) const;
void Visit ( void *, const FormalRTESubstitution & concatenation ) const;
void Visit ( void *, const FormalRTESymbolAlphabet & symbol ) const;
void Visit ( void *, const FormalRTESymbolSubst & symbol ) const;
void Visit ( void *, const FormalRTEEmpty & empty ) const;
class Formal : public FormalRTEElement::Visitor {
public:
Formal ( ) { }
static const Formal FORMAL;
private:
void Visit ( void *, const FormalRTEAlternation & alternation ) const;
void Visit ( void *, const FormalRTEIteration & iteration ) const;
void Visit ( void *, const FormalRTESubstitution & concatenation ) const;
void Visit ( void *, const FormalRTESymbolAlphabet & symbol ) const;
void Visit ( void *, const FormalRTESymbolSubst & symbol ) const;
void Visit ( void *, const FormalRTEEmpty & empty ) const;
};
};
 
} /* namespace rte */
......
......@@ -11,7 +11,7 @@ namespace rte {
*/
class FormalRTEAlternation : public FormalRTEElement, public std::BinaryNode < std::smart_ptr < FormalRTEElement >, std::smart_ptr < FormalRTEElement >, FormalRTEAlternation > {
public:
void Accept ( void * userData, const FormalRTEElementVisitor & visitor ) const {
void Accept ( void * userData, const FormalRTEElement::Visitor & visitor ) const {
visitor.Visit ( userData, * this );
}
 
......
......@@ -19,19 +19,19 @@ class FormalRTEEmpty;
 
class FormalRTEElement;
 
class FormalRTEElementVisitor {
public:
virtual void Visit ( void *, const FormalRTEAlternation & alternation ) const = 0;
virtual void Visit ( void *, const FormalRTEIteration & iteration ) const = 0;
virtual void Visit ( void *, const FormalRTESubstitution & substitution ) const = 0;
virtual void Visit ( void *, const FormalRTESymbolAlphabet & symbol ) const = 0;
virtual void Visit ( void *, const FormalRTESymbolSubst & symbol ) const = 0;
virtual void Visit ( void *, const FormalRTEEmpty & empty ) const = 0;
};
class FormalRTEElement : public alib::CommonBase < FormalRTEElement >, public std::BaseNode < FormalRTEElement > {
public:
virtual void Accept ( void * userData, const FormalRTEElementVisitor & visitor ) const = 0;
class Visitor {
public:
virtual void Visit ( void *, const FormalRTEAlternation & alternation ) const = 0;
virtual void Visit ( void *, const FormalRTEIteration & iteration ) const = 0;
virtual void Visit ( void *, const FormalRTESubstitution & substitution ) const = 0;
virtual void Visit ( void *, const FormalRTESymbolAlphabet & symbol ) const = 0;
virtual void Visit ( void *, const FormalRTESymbolSubst & symbol ) const = 0;
virtual void Visit ( void *, const FormalRTEEmpty & empty ) const = 0;
};
virtual void Accept ( void * userData, const FormalRTEElement::Visitor & visitor ) const = 0;
 
/**
* Traverses the regexp tree looking if particular Symbol is used in the regexp.
......
......@@ -11,7 +11,7 @@ namespace rte {
*/
class FormalRTEEmpty : public FormalRTEElement {
public:
void Accept ( void * userData, const FormalRTEElementVisitor & visitor ) const {
void Accept ( void * userData, const FormalRTEElement::Visitor & visitor ) const {
visitor.Visit ( userData, * this );
}
 
......
......@@ -22,7 +22,7 @@ protected:
std::smart_ptr < FormalRTESymbolSubst > substitutionSymbol;
 
public:
void Accept ( void * userData, const FormalRTEElementVisitor & visitor ) const {
void Accept ( void * userData, const FormalRTEElement::Visitor & visitor ) const {
visitor.Visit ( userData, * this );
}
 
......
......@@ -53,7 +53,7 @@ bool xmlApi < rte::FormalRTEStructure >::first ( const std::deque < sax::Token >
}
 
void xmlApi < rte::FormalRTEStructure >::compose ( std::deque < sax::Token > & output, const rte::FormalRTEStructure & data ) {
data.getStructure ( ).Accept ( ( void * ) & output, rte::RTEToXMLComposer::RTE_TO_XML_COMPOSER );
data.getStructure ( ).Accept ( ( void * ) & output, rte::RTEToXMLComposer::Formal::FORMAL );
}
 
} /* namespace alib */
......@@ -16,7 +16,7 @@ protected:
std::smart_ptr < FormalRTESymbolSubst > substitutionSymbol; // substite this in left by right
 
public:
void Accept ( void * userData, const FormalRTEElementVisitor & visitor ) const {
void Accept ( void * userData, const FormalRTEElement::Visitor & visitor ) const {
visitor.Visit ( userData, * this );
}
 
......
......@@ -11,7 +11,7 @@ namespace rte {
*/
class FormalRTESymbolAlphabet : public FormalRTESymbol, public std::VararyNode < std::smart_ptr < FormalRTESymbol >, std::smart_ptr < const FormalRTESymbol >, FormalRTESymbolAlphabet > {
public:
void Accept ( void * userData, const FormalRTEElementVisitor & visitor ) const {
void Accept ( void * userData, const FormalRTEElement::Visitor & visitor ) const {
visitor.Visit ( userData, * this );
}
 
......
......@@ -11,7 +11,7 @@ namespace rte {
*/
class FormalRTESymbolSubst : public FormalRTESymbol, public std::NullaryNode < FormalRTESymbolSubst > {
public:
void Accept ( void * userData, const FormalRTEElementVisitor & visitor ) const {
void Accept ( void * userData, const FormalRTEElement::Visitor & visitor ) const {
visitor.Visit ( userData, * this );
}
 
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment