From 960dc1bc49cbc2abcfcd7bf319c80375750ce6b4 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Tue, 10 Apr 2018 11:48:30 +0200 Subject: [PATCH] push xml api of regexps to separate files --- .../regexp/transform/RegExpDerivationTest.cpp | 1 + alib2data/src/automaton/FSM/ExtendedNFA.h | 1 + alib2data/src/regexp/RegExpBase.h | 26 -------- alib2data/src/regexp/formal/FormalRegExp.cpp | 9 --- alib2data/src/regexp/formal/FormalRegExp.h | 56 +--------------- .../src/regexp/formal/FormalRegExpStructure.h | 32 ---------- .../src/regexp/unbounded/UnboundedRegExp.cpp | 9 --- .../src/regexp/unbounded/UnboundedRegExp.h | 56 +--------------- .../unbounded/UnboundedRegExpStructure.h | 32 ---------- alib2data/src/regexp/xml/FormalRegExp.cpp | 23 +++++++ alib2data/src/regexp/xml/FormalRegExp.h | 64 +++++++++++++++++++ .../src/regexp/xml/FormalRegExpStructure.h | 41 ++++++++++++ alib2data/src/regexp/xml/UnboundedRegExp.cpp | 23 +++++++ alib2data/src/regexp/xml/UnboundedRegExp.h | 64 +++++++++++++++++++ .../src/regexp/xml/UnboundedRegExpStructure.h | 57 +++++++++++++++++ .../common/RegExpFromXmlParser.h} | 36 +++++------ .../common/RegExpToXmlComposer.h} | 52 +++++++-------- alib2str/src/regexp/string/FormalRegExp.h | 1 + alib2str/src/regexp/string/UnboundedRegExp.h | 1 + 19 files changed, 322 insertions(+), 262 deletions(-) create mode 100644 alib2data/src/regexp/xml/FormalRegExp.cpp create mode 100644 alib2data/src/regexp/xml/FormalRegExp.h create mode 100644 alib2data/src/regexp/xml/FormalRegExpStructure.h create mode 100644 alib2data/src/regexp/xml/UnboundedRegExp.cpp create mode 100644 alib2data/src/regexp/xml/UnboundedRegExp.h create mode 100644 alib2data/src/regexp/xml/UnboundedRegExpStructure.h rename alib2data/src/regexp/{common/RegExpFromXMLParser.h => xml/common/RegExpFromXmlParser.h} (91%) rename alib2data/src/regexp/{common/RegExpToXMLComposer.h => xml/common/RegExpToXmlComposer.h} (79%) diff --git a/alib2algo/test-src/regexp/transform/RegExpDerivationTest.cpp b/alib2algo/test-src/regexp/transform/RegExpDerivationTest.cpp index 933c305831..726d9e4b6c 100644 --- a/alib2algo/test-src/regexp/transform/RegExpDerivationTest.cpp +++ b/alib2algo/test-src/regexp/transform/RegExpDerivationTest.cpp @@ -7,6 +7,7 @@ #include <factory/StringDataFactory.hpp> #include "factory/XmlDataFactory.hpp" #include <regexp/string/UnboundedRegExp.h> +#include <regexp/xml/UnboundedRegExp.h> CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( RegExpDerivationTest, "regexp" ); CPPUNIT_TEST_SUITE_REGISTRATION( RegExpDerivationTest ); diff --git a/alib2data/src/automaton/FSM/ExtendedNFA.h b/alib2data/src/automaton/FSM/ExtendedNFA.h index ad840db8a6..071b315e1a 100644 --- a/alib2data/src/automaton/FSM/ExtendedNFA.h +++ b/alib2data/src/automaton/FSM/ExtendedNFA.h @@ -31,6 +31,7 @@ #include <sstream> #include <sax/FromXMLParserHelper.h> +#include <regexp/xml/UnboundedRegExpStructure.h> #include <core/components.hpp> #include <common/createUnique.hpp> #include <object/UniqueObject.h> diff --git a/alib2data/src/regexp/RegExpBase.h b/alib2data/src/regexp/RegExpBase.h index f76f606cd2..0b70bf8583 100644 --- a/alib2data/src/regexp/RegExpBase.h +++ b/alib2data/src/regexp/RegExpBase.h @@ -10,8 +10,6 @@ #include <object/ObjectBase.h> -#include <core/xmlApi.hpp> - namespace regexp { /** @@ -25,28 +23,4 @@ public: } /* namespace regexp */ -namespace core { - -template < typename Type > -struct xmlApi < Type, typename std::enable_if < std::is_base_of < regexp::RegExpBase, Type >::value >::type > { - static Type parse ( ext::deque < sax::Token >::iterator & input ) { - return Type::parse ( input ); - } - - static bool first ( const ext::deque < sax::Token >::const_iterator & input ) { - return sax::FromXMLParserHelper::isToken ( input, sax::Token::TokenType::START_ELEMENT, xmlTagName() ); - } - - static std::string xmlTagName ( ) { - return Type::getXmlTagName(); - } - - static void compose ( ext::deque < sax::Token > & output, const Type & data ) { - Type::compose ( output, data ); - } - -}; - -} /* namespace core */ - #endif /* REG_EXP_BASE_H_ */ diff --git a/alib2data/src/regexp/formal/FormalRegExp.cpp b/alib2data/src/regexp/formal/FormalRegExp.cpp index 4bcf93d895..3223b06f52 100644 --- a/alib2data/src/regexp/formal/FormalRegExp.cpp +++ b/alib2data/src/regexp/formal/FormalRegExp.cpp @@ -6,12 +6,9 @@ */ #include "FormalRegExp.h" -#include <regexp/RegExp.h> -#include <object/Object.h> #include <registration/CastRegistration.hpp> #include <registration/ValuePrinterRegistration.hpp> -#include <registration/XmlRegistration.hpp> namespace { @@ -19,10 +16,4 @@ static auto formalRegExpFromUnboundedRegExp = registration::CastRegister < regex static auto valuePrinter = registration::ValuePrinterRegister < regexp::FormalRegExp < > > ( ); -static auto xmlWrite = registration::XmlWriterRegister < regexp::FormalRegExp < > > ( ); -static auto xmlRead = registration::XmlReaderRegister < regexp::FormalRegExp < > > ( ); - -static auto xmlGroup1 = registration::XmlRegisterTypeInGroup < regexp::RegExp, regexp::FormalRegExp < > > ( ); -static auto xmlGroup2 = registration::XmlRegisterTypeInGroup < object::Object, regexp::FormalRegExp < > > ( ); - } /* namespace */ diff --git a/alib2data/src/regexp/formal/FormalRegExp.h b/alib2data/src/regexp/formal/FormalRegExp.h index 130688af27..1b10693d48 100644 --- a/alib2data/src/regexp/formal/FormalRegExp.h +++ b/alib2data/src/regexp/formal/FormalRegExp.h @@ -31,14 +31,12 @@ #include <sstream> #include <core/components.hpp> -#include <sax/FromXMLParserHelper.h> #include <object/UniqueObject.h> #include <exception/CommonException.h> +#include <alphabet/common/SymbolNormalize.h> #include "../RegExpBase.h" #include "../RegExpFeatures.h" -#include "../common/RegExpFromXMLParser.h" -#include "../common/RegExpToXMLComposer.h" #include "FormalRegExpStructure.h" @@ -170,36 +168,6 @@ public: */ virtual explicit operator std::string ( ) const override; - /** - * \brief The XML tag name of class. - * - * \details Intentionaly a static member function to be safe in the initialisation before the main function starts. - * - * \returns string representing the XML tag name of the class - */ - static const std::string & getXmlTagName() { - static std::string xmlTagName = "FormalRegExp"; - - return xmlTagName; - } - - /** - * Parsing from a sequence of xml tokens helper. - * - * \params input the iterator to sequence of xml tokens to parse from - * - * \returns the new instance of the expression - */ - static FormalRegExp parse ( ext::deque < sax::Token >::iterator & input ); - - /** - * Composing to a sequence of xml tokens helper. - * - * \param out the sink for new xml tokens representing the expression - * \param regexp the expression to compose - */ - static void compose ( ext::deque < sax::Token > & out, const FormalRegExp & regexp ); - /** * @copydoc alib::GrammarBase::inc() */ @@ -285,28 +253,6 @@ FormalRegExp < SymbolType >::operator std::string ( ) const { return ss.str ( ); } -template < class SymbolType > -FormalRegExp < SymbolType > FormalRegExp < SymbolType >::parse ( ext::deque < sax::Token >::iterator & input ) { - sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, FormalRegExp::getXmlTagName() ); - - ext::set < SymbolType > alphabet = RegExpFromXMLParser::parseAlphabet < SymbolType > ( input ); - - FormalRegExpStructure < SymbolType > element ( core::xmlApi < regexp::FormalRegExpStructure < SymbolType > >::parse ( input ) ); - FormalRegExp < SymbolType > regexp ( std::move ( alphabet ), std::move ( element ) ); - - sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, FormalRegExp::getXmlTagName() ); - - return regexp; -} - -template < class SymbolType > -void FormalRegExp < SymbolType >::compose ( ext::deque < sax::Token > & out, const FormalRegExp & regexp ) { - out.emplace_back ( FormalRegExp::getXmlTagName(), sax::Token::TokenType::START_ELEMENT ); - RegExpToXMLComposer::composeAlphabet ( out, regexp.getAlphabet ( ) ); - core::xmlApi < FormalRegExpStructure < SymbolType > >::compose ( out, regexp.getRegExp ( ) ); - out.emplace_back ( FormalRegExp::getXmlTagName(), sax::Token::TokenType::END_ELEMENT ); -} - template < class SymbolType > object::ObjectBase* FormalRegExp < SymbolType >::inc() && { return new object::UniqueObject(object::Object(std::move(*this)), primitive::Integer(0)); diff --git a/alib2data/src/regexp/formal/FormalRegExpStructure.h b/alib2data/src/regexp/formal/FormalRegExpStructure.h index 90f0f600da..cba07fb0e1 100644 --- a/alib2data/src/regexp/formal/FormalRegExpStructure.h +++ b/alib2data/src/regexp/formal/FormalRegExpStructure.h @@ -11,8 +11,6 @@ #include <exception/CommonException.h> #include "../RegExpFeatures.h" -#include "../common/RegExpFromXMLParser.h" -#include "../common/RegExpToXMLComposer.h" #include "FormalRegExpEmpty.h" @@ -71,17 +69,6 @@ public: } /* namespace regexp */ -namespace core { - -template < class SymbolType > -struct xmlApi < regexp::FormalRegExpStructure < SymbolType > > { - static regexp::FormalRegExpStructure < SymbolType > parse ( ext::deque < sax::Token >::iterator & input ); - static bool first ( const ext::deque < sax::Token >::const_iterator & input ); - static void compose ( ext::deque < sax::Token > & output, const regexp::FormalRegExpStructure < SymbolType > & data ); -}; - -} /* namespace core */ - namespace ext { template < class SymbolType > @@ -136,23 +123,4 @@ void FormalRegExpStructure < SymbolType >::setStructure ( FormalRegExpElement < } /* namespace regexp */ -namespace core { - -template < class SymbolType > -regexp::FormalRegExpStructure < SymbolType > xmlApi < regexp::FormalRegExpStructure < SymbolType > >::parse ( ext::deque < sax::Token >::iterator & input ) { - return regexp::FormalRegExpStructure < SymbolType > ( regexp::RegExpFromXMLParser::parseFormalRegExpElement < SymbolType > ( input ) ); -} - -template < class SymbolType > -bool xmlApi < regexp::FormalRegExpStructure < SymbolType > >::first ( const ext::deque < sax::Token >::const_iterator & ) { - throw exception::CommonException ( "Unimplemented" ); -} - -template < class SymbolType > -void xmlApi < regexp::FormalRegExpStructure < SymbolType > >::compose ( ext::deque < sax::Token > & output, const regexp::FormalRegExpStructure < SymbolType > & data ) { - data.getStructure ( ).template accept < void, regexp::RegExpToXMLComposer::Formal > ( output ); -} - -} /* namespace core */ - #endif /* FORMAL_REG_EXP_STRUCTURE_H_ */ diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExp.cpp b/alib2data/src/regexp/unbounded/UnboundedRegExp.cpp index f6f41c4b99..2c0bc565f9 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExp.cpp +++ b/alib2data/src/regexp/unbounded/UnboundedRegExp.cpp @@ -6,12 +6,9 @@ */ #include "UnboundedRegExp.h" -#include <regexp/RegExp.h> -#include <object/Object.h> #include <registration/CastRegistration.hpp> #include <registration/ValuePrinterRegistration.hpp> -#include <registration/XmlRegistration.hpp> namespace { @@ -19,10 +16,4 @@ static auto unboundedRegExpFromFormalRegExp = registration::CastRegister < regex static auto valuePrinter = registration::ValuePrinterRegister < regexp::UnboundedRegExp < > > ( ); -static auto xmlWrite = registration::XmlWriterRegister < regexp::UnboundedRegExp < > > ( ); -static auto xmlRead = registration::XmlReaderRegister < regexp::UnboundedRegExp < > > ( ); - -static auto xmlGroup1 = registration::XmlRegisterTypeInGroup < regexp::RegExp, regexp::UnboundedRegExp < > > ( ); -static auto xmlGroup2 = registration::XmlRegisterTypeInGroup < object::Object, regexp::UnboundedRegExp < > > ( ); - } /* namespace */ diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExp.h b/alib2data/src/regexp/unbounded/UnboundedRegExp.h index 4264bc6b4d..a094fdb5b5 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExp.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExp.h @@ -31,14 +31,12 @@ #include <sstream> #include <core/components.hpp> -#include <sax/FromXMLParserHelper.h> #include <object/UniqueObject.h> #include <exception/CommonException.h> +#include <alphabet/common/SymbolNormalize.h> #include "../RegExpBase.h" #include "../RegExpFeatures.h" -#include "../common/RegExpFromXMLParser.h" -#include "../common/RegExpToXMLComposer.h" #include "UnboundedRegExpStructure.h" @@ -170,36 +168,6 @@ public: */ virtual explicit operator std::string ( ) const override; - /** - * \brief The XML tag name of class. - * - * \details Intentionaly a static member function to be safe in the initialisation before the main function starts. - * - * \returns string representing the XML tag name of the class - */ - static const std::string & getXmlTagName() { - static std::string xmlTagName = "UnboundedRegExp"; - - return xmlTagName; - } - - /** - * Parsing from a sequence of xml tokens helper. - * - * \params input the iterator to sequence of xml tokens to parse from - * - * \returns the new instance of the expression - */ - static UnboundedRegExp parse ( ext::deque < sax::Token >::iterator & input ); - - /** - * Composing to a sequence of xml tokens helper. - * - * \param out the sink for new xml tokens representing the expression - * \param regexp the expression to compose - */ - static void compose ( ext::deque < sax::Token > & out, const UnboundedRegExp & regexp ); - /** * @copydoc alib::GrammarBase::inc() */ @@ -285,28 +253,6 @@ UnboundedRegExp < SymbolType >::operator std::string ( ) const { return ss.str ( ); } -template < class SymbolType > -UnboundedRegExp < SymbolType > UnboundedRegExp < SymbolType >::parse ( ext::deque < sax::Token >::iterator & input ) { - sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, UnboundedRegExp::getXmlTagName() ); - - ext::set < SymbolType > alphabet = RegExpFromXMLParser::parseAlphabet < SymbolType > ( input ); - - UnboundedRegExpStructure < SymbolType > structure ( core::xmlApi < regexp::UnboundedRegExpStructure < SymbolType > >::parse ( input ) ); - UnboundedRegExp < SymbolType > regexp ( std::move ( alphabet ), std::move ( structure ) ); - - sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, UnboundedRegExp::getXmlTagName() ); - - return regexp; -} - -template < class SymbolType > -void UnboundedRegExp < SymbolType >::compose ( ext::deque < sax::Token > & out, const UnboundedRegExp & regexp ) { - out.emplace_back ( UnboundedRegExp::getXmlTagName(), sax::Token::TokenType::START_ELEMENT ); - RegExpToXMLComposer::composeAlphabet ( out, regexp.getAlphabet ( ) ); - core::xmlApi < UnboundedRegExpStructure < SymbolType > >::compose ( out, regexp.getRegExp ( ) ); - out.emplace_back ( UnboundedRegExp::getXmlTagName(), sax::Token::TokenType::END_ELEMENT ); -} - template < class SymbolType > object::ObjectBase* UnboundedRegExp < SymbolType >::inc() && { return new object::UniqueObject(object::Object(std::move(*this)), primitive::Integer(0)); diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpStructure.h b/alib2data/src/regexp/unbounded/UnboundedRegExpStructure.h index 4f75745bb8..0d18e4a567 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpStructure.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpStructure.h @@ -27,8 +27,6 @@ #include <exception/CommonException.h> #include "../RegExpFeatures.h" -#include "../common/RegExpFromXMLParser.h" -#include "../common/RegExpToXMLComposer.h" #include "UnboundedRegExpEmpty.h" @@ -148,17 +146,6 @@ public: } /* namespace regexp */ -namespace core { - -template < class SymbolType > -struct xmlApi < regexp::UnboundedRegExpStructure < SymbolType > > { - static regexp::UnboundedRegExpStructure < SymbolType > parse ( ext::deque < sax::Token >::iterator & input ); - static bool first ( const ext::deque < sax::Token >::const_iterator & input ); - static void compose ( ext::deque < sax::Token > & output, const regexp::UnboundedRegExpStructure < SymbolType > & data ); -}; - -} /* namespace core */ - namespace ext { template < class SymbolType > @@ -213,23 +200,4 @@ void UnboundedRegExpStructure < SymbolType >::setStructure ( UnboundedRegExpElem } /* namespace regexp */ -namespace core { - -template < class SymbolType > -regexp::UnboundedRegExpStructure < SymbolType > xmlApi < regexp::UnboundedRegExpStructure < SymbolType > >::parse ( ext::deque < sax::Token >::iterator & input ) { - return regexp::UnboundedRegExpStructure < SymbolType > ( regexp::RegExpFromXMLParser::parseUnboundedRegExpElement < SymbolType > ( input ) ); -} - -template < class SymbolType > -bool xmlApi < regexp::UnboundedRegExpStructure < SymbolType > >::first ( const ext::deque < sax::Token >::const_iterator & ) { - throw exception::CommonException ( "Unimplemented" ); -} - -template < class SymbolType > -void xmlApi < regexp::UnboundedRegExpStructure < SymbolType > >::compose ( ext::deque < sax::Token > & output, const regexp::UnboundedRegExpStructure < SymbolType > & data ) { - data.getStructure ( ).template accept < void, regexp::RegExpToXMLComposer::Unbounded > ( output ); -} - -} /* namespace core */ - #endif /* UNBOUNDED_REG_EXP_STRUCTURE_H_ */ diff --git a/alib2data/src/regexp/xml/FormalRegExp.cpp b/alib2data/src/regexp/xml/FormalRegExp.cpp new file mode 100644 index 0000000000..6ec29d674b --- /dev/null +++ b/alib2data/src/regexp/xml/FormalRegExp.cpp @@ -0,0 +1,23 @@ +/* + * FormalRegExp.cpp + * + * Created on: Jan 30, 2014 + * Author: Jan Travnicek + */ + +#include <regexp/xml/FormalRegExp.h> + +#include <regexp/RegExp.h> +#include <object/Object.h> + +#include <registration/XmlRegistration.hpp> + +namespace { + +static auto xmlWrite = registration::XmlWriterRegister < regexp::FormalRegExp < > > ( ); +static auto xmlRead = registration::XmlReaderRegister < regexp::FormalRegExp < > > ( ); + +static auto xmlGroup1 = registration::XmlRegisterTypeInGroup < regexp::RegExp, regexp::FormalRegExp < > > ( ); +static auto xmlGroup2 = registration::XmlRegisterTypeInGroup < object::Object, regexp::FormalRegExp < > > ( ); + +} /* namespace */ diff --git a/alib2data/src/regexp/xml/FormalRegExp.h b/alib2data/src/regexp/xml/FormalRegExp.h new file mode 100644 index 0000000000..65a222d591 --- /dev/null +++ b/alib2data/src/regexp/xml/FormalRegExp.h @@ -0,0 +1,64 @@ +/* + * FormalRegExp.h + * + * Created on: Dec 1, 2017 + * Author: Jan Travnicek + */ + +#ifndef _XML_FORMAL_REGEXP_H_ +#define _XML_FORMAL_REGEXP_H_ + +#include <regexp/formal/FormalRegExp.h> +#include <regexp/xml/FormalRegExpStructure.h> +#include <core/xmlApi.hpp> + +#include <regexp/xml/common/RegExpFromXmlParser.h> +#include <regexp/xml/common/RegExpToXmlComposer.h> + +namespace core { + +template < typename SymbolType > +struct xmlApi < regexp::FormalRegExp < SymbolType > > { + static regexp::FormalRegExp < SymbolType > parse ( ext::deque < sax::Token >::iterator & input ); + static bool first ( const ext::deque < sax::Token >::const_iterator & input ); + static const std::string & xmlTagName ( ); + static void compose ( ext::deque < sax::Token > & output, const regexp::FormalRegExp < SymbolType > & data ); +}; + +template < typename SymbolType > +regexp::FormalRegExp < SymbolType > xmlApi < regexp::FormalRegExp < SymbolType > >::parse ( ext::deque < sax::Token >::iterator & input ) { + sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, xmlTagName() ); + + ext::set < SymbolType > alphabet = regexp::RegExpFromXmlParser::parseAlphabet < SymbolType > ( input ); + + regexp::FormalRegExpStructure < SymbolType > element ( core::xmlApi < regexp::FormalRegExpStructure < SymbolType > >::parse ( input ) ); + regexp::FormalRegExp < SymbolType > regexp ( std::move ( alphabet ), std::move ( element ) ); + + sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, xmlTagName() ); + + return regexp; +} + +template < typename SymbolType > +bool xmlApi < regexp::FormalRegExp < SymbolType > >::first ( const ext::deque < sax::Token >::const_iterator & input ) { + return sax::FromXMLParserHelper::isToken ( input, sax::Token::TokenType::START_ELEMENT, xmlTagName ( ) ); +} + +template < typename SymbolType > +const std::string & xmlApi < regexp::FormalRegExp < SymbolType > >::xmlTagName ( ) { + static std::string xmlTagName = "FormalRegExp"; + + return xmlTagName; +} + +template < typename SymbolType > +void xmlApi < regexp::FormalRegExp < SymbolType > >::compose ( ext::deque < sax::Token > & output, const regexp::FormalRegExp < SymbolType > & input ) { + output.emplace_back ( xmlTagName(), sax::Token::TokenType::START_ELEMENT ); + regexp::RegExpToXmlComposer::composeAlphabet ( output, input.getAlphabet ( ) ); + core::xmlApi < regexp::FormalRegExpStructure < SymbolType > >::compose ( output, input.getRegExp ( ) ); + output.emplace_back ( xmlTagName(), sax::Token::TokenType::END_ELEMENT ); +} + +} /* namespace core */ + +#endif /* _XML_FORMAL_REGEXP_H_ */ diff --git a/alib2data/src/regexp/xml/FormalRegExpStructure.h b/alib2data/src/regexp/xml/FormalRegExpStructure.h new file mode 100644 index 0000000000..837d4e5932 --- /dev/null +++ b/alib2data/src/regexp/xml/FormalRegExpStructure.h @@ -0,0 +1,41 @@ +/* + * FormalRegExpStructure.h + * + * Created on: Oct 20, 2016 + * Author: Jan Travnicek + */ + +#ifndef _XML_FORMAL_REG_EXP_STRUCTURE_H_ +#define _XML_FORMAL_REG_EXP_STRUCTURE_H_ + +#include <regexp/formal/FormalRegExpStructure.h> +#include <regexp/xml/common/RegExpFromXmlParser.h> +#include <regexp/xml/common/RegExpToXmlComposer.h> + +namespace core { + +template < class SymbolType > +struct xmlApi < regexp::FormalRegExpStructure < SymbolType > > { + static regexp::FormalRegExpStructure < SymbolType > parse ( ext::deque < sax::Token >::iterator & input ); + static bool first ( const ext::deque < sax::Token >::const_iterator & input ); + static void compose ( ext::deque < sax::Token > & output, const regexp::FormalRegExpStructure < SymbolType > & data ); +}; + +template < class SymbolType > +regexp::FormalRegExpStructure < SymbolType > xmlApi < regexp::FormalRegExpStructure < SymbolType > >::parse ( ext::deque < sax::Token >::iterator & input ) { + return regexp::FormalRegExpStructure < SymbolType > ( regexp::RegExpFromXmlParser::parseFormalRegExpElement < SymbolType > ( input ) ); +} + +template < class SymbolType > +bool xmlApi < regexp::FormalRegExpStructure < SymbolType > >::first ( const ext::deque < sax::Token >::const_iterator & ) { + throw exception::CommonException ( "Unimplemented" ); +} + +template < class SymbolType > +void xmlApi < regexp::FormalRegExpStructure < SymbolType > >::compose ( ext::deque < sax::Token > & output, const regexp::FormalRegExpStructure < SymbolType > & input ) { + input.getStructure ( ).template accept < void, regexp::RegExpToXmlComposer::Formal > ( output ); +} + +} /* namespace core */ + +#endif /* _XML_FORMAL_REG_EXP_STRUCTURE_H_ */ diff --git a/alib2data/src/regexp/xml/UnboundedRegExp.cpp b/alib2data/src/regexp/xml/UnboundedRegExp.cpp new file mode 100644 index 0000000000..015feae5f0 --- /dev/null +++ b/alib2data/src/regexp/xml/UnboundedRegExp.cpp @@ -0,0 +1,23 @@ +/* + * UnboundedRegExp.cpp + * + * Created on: Jan 30, 2014 + * Author: Jan Travnicek + */ + +#include <regexp/xml/UnboundedRegExp.h> + +#include <regexp/RegExp.h> +#include <object/Object.h> + +#include <registration/XmlRegistration.hpp> + +namespace { + +static auto xmlWrite = registration::XmlWriterRegister < regexp::UnboundedRegExp < > > ( ); +static auto xmlRead = registration::XmlReaderRegister < regexp::UnboundedRegExp < > > ( ); + +static auto xmlGroup1 = registration::XmlRegisterTypeInGroup < regexp::RegExp, regexp::UnboundedRegExp < > > ( ); +static auto xmlGroup2 = registration::XmlRegisterTypeInGroup < object::Object, regexp::UnboundedRegExp < > > ( ); + +} /* namespace */ diff --git a/alib2data/src/regexp/xml/UnboundedRegExp.h b/alib2data/src/regexp/xml/UnboundedRegExp.h new file mode 100644 index 0000000000..8b791e5cd6 --- /dev/null +++ b/alib2data/src/regexp/xml/UnboundedRegExp.h @@ -0,0 +1,64 @@ +/* + * UnboundedRegExp.h + * + * Created on: Dec 1, 2017 + * Author: Jan Travnicek + */ + +#ifndef _XML_UNBOUNDED_REGEXP_H_ +#define _XML_UNBOUNDED_REGEXP_H_ + +#include <regexp/unbounded/UnboundedRegExp.h> +#include <regexp/xml/UnboundedRegExpStructure.h> +#include <core/xmlApi.hpp> + +#include <regexp/xml/common/RegExpFromXmlParser.h> +#include <regexp/xml/common/RegExpToXmlComposer.h> + +namespace core { + +template < typename SymbolType > +struct xmlApi < regexp::UnboundedRegExp < SymbolType > > { + static regexp::UnboundedRegExp < SymbolType > parse ( ext::deque < sax::Token >::iterator & input ); + static bool first ( const ext::deque < sax::Token >::const_iterator & input ); + static const std::string & xmlTagName ( ); + static void compose ( ext::deque < sax::Token > & output, const regexp::UnboundedRegExp < SymbolType > & data ); +}; + +template < typename SymbolType > +regexp::UnboundedRegExp < SymbolType > xmlApi < regexp::UnboundedRegExp < SymbolType > >::parse ( ext::deque < sax::Token >::iterator & input ) { + sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, xmlTagName() ); + + ext::set < SymbolType > alphabet = regexp::RegExpFromXmlParser::parseAlphabet < SymbolType > ( input ); + + regexp::UnboundedRegExpStructure < SymbolType > structure ( core::xmlApi < regexp::UnboundedRegExpStructure < SymbolType > >::parse ( input ) ); + regexp::UnboundedRegExp < SymbolType > regexp ( std::move ( alphabet ), std::move ( structure ) ); + + sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, xmlTagName() ); + + return regexp; +} + +template < typename SymbolType > +bool xmlApi < regexp::UnboundedRegExp < SymbolType > >::first ( const ext::deque < sax::Token >::const_iterator & input ) { + return sax::FromXMLParserHelper::isToken ( input, sax::Token::TokenType::START_ELEMENT, xmlTagName ( ) ); +} + +template < typename SymbolType > +const std::string & xmlApi < regexp::UnboundedRegExp < SymbolType > >::xmlTagName ( ) { + static std::string xmlTagName = "UnboundedRegExp"; + + return xmlTagName; +} + +template < typename SymbolType > +void xmlApi < regexp::UnboundedRegExp < SymbolType > >::compose ( ext::deque < sax::Token > & output, const regexp::UnboundedRegExp < SymbolType > & input ) { + output.emplace_back ( xmlTagName(), sax::Token::TokenType::START_ELEMENT ); + regexp::RegExpToXmlComposer::composeAlphabet ( output, input.getAlphabet ( ) ); + core::xmlApi < regexp::UnboundedRegExpStructure < SymbolType > >::compose ( output, input.getRegExp ( ) ); + output.emplace_back ( xmlTagName(), sax::Token::TokenType::END_ELEMENT ); +} + +} /* namespace core */ + +#endif /* _XML_UNBOUNDED_REGEXP_H_ */ diff --git a/alib2data/src/regexp/xml/UnboundedRegExpStructure.h b/alib2data/src/regexp/xml/UnboundedRegExpStructure.h new file mode 100644 index 0000000000..88ae61ccc3 --- /dev/null +++ b/alib2data/src/regexp/xml/UnboundedRegExpStructure.h @@ -0,0 +1,57 @@ +/* + * UnboundedRegExpStructure.h + * + * This file is part of Algorithms library toolkit. + * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz) + + * Algorithms library toolkit is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * Algorithms library toolkit is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>. + * + * Created on: Oct 20, 2016 + * Author: Jan Travnicek + */ + +#ifndef _XML_UNBOUNDED_REG_EXP_STRUCTURE_H_ +#define _XML_UNBOUNDED_REG_EXP_STRUCTURE_H_ + +#include <regexp/unbounded/UnboundedRegExpStructure.h> +#include <regexp/xml/common/RegExpFromXmlParser.h> +#include <regexp/xml/common/RegExpToXmlComposer.h> + +namespace core { + +template < class SymbolType > +struct xmlApi < regexp::UnboundedRegExpStructure < SymbolType > > { + static regexp::UnboundedRegExpStructure < SymbolType > parse ( ext::deque < sax::Token >::iterator & input ); + static bool first ( const ext::deque < sax::Token >::const_iterator & input ); + static void compose ( ext::deque < sax::Token > & output, const regexp::UnboundedRegExpStructure < SymbolType > & data ); +}; + +template < class SymbolType > +regexp::UnboundedRegExpStructure < SymbolType > xmlApi < regexp::UnboundedRegExpStructure < SymbolType > >::parse ( ext::deque < sax::Token >::iterator & input ) { + return regexp::UnboundedRegExpStructure < SymbolType > ( regexp::RegExpFromXmlParser::parseUnboundedRegExpElement < SymbolType > ( input ) ); +} + +template < class SymbolType > +bool xmlApi < regexp::UnboundedRegExpStructure < SymbolType > >::first ( const ext::deque < sax::Token >::const_iterator & ) { + throw exception::CommonException ( "Unimplemented" ); +} + +template < class SymbolType > +void xmlApi < regexp::UnboundedRegExpStructure < SymbolType > >::compose ( ext::deque < sax::Token > & output, const regexp::UnboundedRegExpStructure < SymbolType > & input ) { + input.getStructure ( ).template accept < void, regexp::RegExpToXmlComposer::Unbounded > ( output ); +} + +} /* namespace core */ + +#endif /* _XML_UNBOUNDED_REG_EXP_STRUCTURE_H_ */ diff --git a/alib2data/src/regexp/common/RegExpFromXMLParser.h b/alib2data/src/regexp/xml/common/RegExpFromXmlParser.h similarity index 91% rename from alib2data/src/regexp/common/RegExpFromXMLParser.h rename to alib2data/src/regexp/xml/common/RegExpFromXmlParser.h index f2f6704a40..0d240c9b78 100644 --- a/alib2data/src/regexp/common/RegExpFromXMLParser.h +++ b/alib2data/src/regexp/xml/common/RegExpFromXmlParser.h @@ -1,5 +1,5 @@ /* - * RegExpFromXMLParser.h + * RegExpFromXmlParser.h * * Created on: Nov 23, 2013 * Author: Martin Zak @@ -10,13 +10,13 @@ #include <alib/set> #include <alib/deque> -#include "../RegExpFeatures.h" +#include <regexp/RegExpFeatures.h> #include <sax/Token.h> #include <sax/FromXMLParserHelper.h> -#include "../unbounded/UnboundedRegExpElements.h" -#include "../formal/FormalRegExpElements.h" +#include <regexp/unbounded/UnboundedRegExpElements.h> +#include <regexp/formal/FormalRegExpElements.h> #include <core/xmlApi.hpp> namespace regexp { @@ -24,7 +24,7 @@ namespace regexp { /** * Parser used to get RegExp from XML parsed into list of tokens. */ -class RegExpFromXMLParser { +class RegExpFromXmlParser { public: template < class SymbolType > static ext::set < SymbolType > parseAlphabet ( ext::deque < sax::Token >::iterator & input ); @@ -59,7 +59,7 @@ public: }; template < class SymbolType > -ext::set < SymbolType > RegExpFromXMLParser::parseAlphabet ( ext::deque < sax::Token >::iterator & input ) { +ext::set < SymbolType > RegExpFromXmlParser::parseAlphabet ( ext::deque < sax::Token >::iterator & input ) { ext::set < SymbolType > alphabet; sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "alphabet" ); @@ -71,7 +71,7 @@ ext::set < SymbolType > RegExpFromXMLParser::parseAlphabet ( ext::deque < sax::T } template < class SymbolType > -ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > RegExpFromXMLParser::parseUnboundedRegExpElement ( ext::deque < sax::Token >::iterator & input ) { +ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > RegExpFromXmlParser::parseUnboundedRegExpElement ( ext::deque < sax::Token >::iterator & input ) { if ( sax::FromXMLParserHelper::isToken ( input, sax::Token::TokenType::START_ELEMENT, "empty" ) ) return parseUnboundedRegExpEmpty < SymbolType > ( input ); else if ( sax::FromXMLParserHelper::isToken ( input, sax::Token::TokenType::START_ELEMENT, "epsilon" ) ) @@ -87,7 +87,7 @@ ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > RegExpFromXMLParser::p } template < class SymbolType > -ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > RegExpFromXMLParser::parseUnboundedRegExpAlternation ( ext::deque < sax::Token >::iterator & input ) { +ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > RegExpFromXmlParser::parseUnboundedRegExpAlternation ( ext::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "alternation" ); UnboundedRegExpAlternation < SymbolType > * alternation = new UnboundedRegExpAlternation < SymbolType > ( ); @@ -100,7 +100,7 @@ ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > RegExpFromXMLParser::p } template < class SymbolType > -ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > RegExpFromXMLParser::parseUnboundedRegExpConcatenation ( ext::deque < sax::Token >::iterator & input ) { +ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > RegExpFromXmlParser::parseUnboundedRegExpConcatenation ( ext::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "concatenation" ); UnboundedRegExpConcatenation < SymbolType > * concatenation = new UnboundedRegExpConcatenation < SymbolType > ( ); @@ -113,7 +113,7 @@ ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > RegExpFromXMLParser::p } template < class SymbolType > -ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > RegExpFromXMLParser::parseUnboundedRegExpIteration ( ext::deque < sax::Token >::iterator & input ) { +ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > RegExpFromXmlParser::parseUnboundedRegExpIteration ( ext::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "iteration" ); ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > iteration ( new UnboundedRegExpIteration < SymbolType > ( parseUnboundedRegExpElement < SymbolType > ( input ) ) ); @@ -124,7 +124,7 @@ ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > RegExpFromXMLParser::p } template < class SymbolType > -ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > RegExpFromXMLParser::parseUnboundedRegExpEpsilon ( ext::deque < sax::Token >::iterator & input ) { +ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > RegExpFromXmlParser::parseUnboundedRegExpEpsilon ( ext::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "epsilon" ); ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > epsilon ( new UnboundedRegExpEpsilon < SymbolType > ( ) ); @@ -135,7 +135,7 @@ ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > RegExpFromXMLParser::p } template < class SymbolType > -ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > RegExpFromXMLParser::parseUnboundedRegExpEmpty ( ext::deque < sax::Token >::iterator & input ) { +ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > RegExpFromXmlParser::parseUnboundedRegExpEmpty ( ext::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "empty" ); ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > empty ( new UnboundedRegExpEmpty < SymbolType > ( ) ); @@ -146,7 +146,7 @@ ext::rvalue_ref < UnboundedRegExpElement < SymbolType > > RegExpFromXMLParser::p } template < class SymbolType > -ext::rvalue_ref < FormalRegExpElement < SymbolType > > RegExpFromXMLParser::parseFormalRegExpElement ( ext::deque < sax::Token >::iterator & input ) { +ext::rvalue_ref < FormalRegExpElement < SymbolType > > RegExpFromXmlParser::parseFormalRegExpElement ( ext::deque < sax::Token >::iterator & input ) { if ( sax::FromXMLParserHelper::isToken ( input, sax::Token::TokenType::START_ELEMENT, "empty" ) ) return parseFormalRegExpEmpty < SymbolType > ( input ); else if ( sax::FromXMLParserHelper::isToken ( input, sax::Token::TokenType::START_ELEMENT, "epsilon" ) ) @@ -162,7 +162,7 @@ ext::rvalue_ref < FormalRegExpElement < SymbolType > > RegExpFromXMLParser::pars } template < class SymbolType > -ext::rvalue_ref < FormalRegExpElement < SymbolType > > RegExpFromXMLParser::parseFormalRegExpAlternation ( ext::deque < sax::Token >::iterator & input ) { +ext::rvalue_ref < FormalRegExpElement < SymbolType > > RegExpFromXmlParser::parseFormalRegExpAlternation ( ext::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "alternation" ); ext::rvalue_ref < FormalRegExpElement < SymbolType > > element1 = parseFormalRegExpElement < SymbolType > ( input ); @@ -176,7 +176,7 @@ ext::rvalue_ref < FormalRegExpElement < SymbolType > > RegExpFromXMLParser::pars } template < class SymbolType > -ext::rvalue_ref < FormalRegExpElement < SymbolType > > RegExpFromXMLParser::parseFormalRegExpConcatenation ( ext::deque < sax::Token >::iterator & input ) { +ext::rvalue_ref < FormalRegExpElement < SymbolType > > RegExpFromXmlParser::parseFormalRegExpConcatenation ( ext::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "concatenation" ); ext::rvalue_ref < FormalRegExpElement < SymbolType > > element1 = parseFormalRegExpElement < SymbolType > ( input ); @@ -190,7 +190,7 @@ ext::rvalue_ref < FormalRegExpElement < SymbolType > > RegExpFromXMLParser::pars } template < class SymbolType > -ext::rvalue_ref < FormalRegExpElement < SymbolType > > RegExpFromXMLParser::parseFormalRegExpIteration ( ext::deque < sax::Token >::iterator & input ) { +ext::rvalue_ref < FormalRegExpElement < SymbolType > > RegExpFromXmlParser::parseFormalRegExpIteration ( ext::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "iteration" ); ext::rvalue_ref < FormalRegExpElement < SymbolType > > iteration ( new FormalRegExpIteration < SymbolType > ( parseFormalRegExpElement < SymbolType > ( input ) ) ); @@ -201,7 +201,7 @@ ext::rvalue_ref < FormalRegExpElement < SymbolType > > RegExpFromXMLParser::pars } template < class SymbolType > -ext::rvalue_ref < FormalRegExpElement < SymbolType > > RegExpFromXMLParser::parseFormalRegExpEpsilon ( ext::deque < sax::Token >::iterator & input ) { +ext::rvalue_ref < FormalRegExpElement < SymbolType > > RegExpFromXmlParser::parseFormalRegExpEpsilon ( ext::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "epsilon" ); ext::rvalue_ref < FormalRegExpElement < SymbolType > > epsilon ( new FormalRegExpEpsilon < SymbolType > ( ) ); @@ -212,7 +212,7 @@ ext::rvalue_ref < FormalRegExpElement < SymbolType > > RegExpFromXMLParser::pars } template < class SymbolType > -ext::rvalue_ref < FormalRegExpElement < SymbolType > > RegExpFromXMLParser::parseFormalRegExpEmpty ( ext::deque < sax::Token >::iterator & input ) { +ext::rvalue_ref < FormalRegExpElement < SymbolType > > RegExpFromXmlParser::parseFormalRegExpEmpty ( ext::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "empty" ); ext::rvalue_ref < FormalRegExpElement < SymbolType > > empty ( new FormalRegExpEmpty < SymbolType > ( ) ); diff --git a/alib2data/src/regexp/common/RegExpToXMLComposer.h b/alib2data/src/regexp/xml/common/RegExpToXmlComposer.h similarity index 79% rename from alib2data/src/regexp/common/RegExpToXMLComposer.h rename to alib2data/src/regexp/xml/common/RegExpToXmlComposer.h index 6da5d8f598..791431b1d3 100644 --- a/alib2data/src/regexp/common/RegExpToXMLComposer.h +++ b/alib2data/src/regexp/xml/common/RegExpToXmlComposer.h @@ -1,5 +1,5 @@ /* - * RegExpToXMLComposer.h + * RegExpToXmlComposer.h * * Created on: Nov 23, 2013 * Author: Martin Zak @@ -9,9 +9,9 @@ #define REG_EXP_TO_XML_COMPOSER_H_ #include <alib/deque> -#include "../RegExpFeatures.h" -#include "../unbounded/UnboundedRegExpElement.h" -#include "../formal/FormalRegExpElement.h" +#include <regexp/RegExpFeatures.h> +#include <regexp/unbounded/UnboundedRegExpElement.h> +#include <regexp/formal/FormalRegExpElement.h> #include <sax/Token.h> #include <core/xmlApi.hpp> @@ -21,7 +21,7 @@ namespace regexp { /** * This class contains methods to print XML representation of regular expression to the output stream. */ -class RegExpToXMLComposer { +class RegExpToXmlComposer { public: template < class SymbolType > static void composeAlphabet(ext::deque<sax::Token>& out, const ext::set<SymbolType>& alphabet); @@ -60,89 +60,89 @@ public: }; template < class SymbolType > -void RegExpToXMLComposer::Unbounded::visit(const UnboundedRegExpAlternation < SymbolType > & alternation, ext::deque<sax::Token>& out) { +void RegExpToXmlComposer::Unbounded::visit(const UnboundedRegExpAlternation < SymbolType > & alternation, ext::deque<sax::Token>& out) { out.emplace_back("alternation", sax::Token::TokenType::START_ELEMENT); for (const auto& element : alternation.getElements()) { - element->template accept < void, RegExpToXMLComposer::Unbounded > ( out ); + element->template accept < void, RegExpToXmlComposer::Unbounded > ( out ); } out.emplace_back("alternation", sax::Token::TokenType::END_ELEMENT); } template < class SymbolType > -void RegExpToXMLComposer::Unbounded::visit(const UnboundedRegExpConcatenation < SymbolType > & concatenation, ext::deque<sax::Token>& out) { +void RegExpToXmlComposer::Unbounded::visit(const UnboundedRegExpConcatenation < SymbolType > & concatenation, ext::deque<sax::Token>& out) { out.emplace_back("concatenation", sax::Token::TokenType::START_ELEMENT); for (auto element : concatenation.getElements()) { - element->template accept < void, RegExpToXMLComposer::Unbounded > ( out ); + element->template accept < void, RegExpToXmlComposer::Unbounded > ( out ); } out.emplace_back("concatenation", sax::Token::TokenType::END_ELEMENT); } template < class SymbolType > -void RegExpToXMLComposer::Unbounded::visit(const UnboundedRegExpIteration < SymbolType > & iteration, ext::deque<sax::Token>& out) { +void RegExpToXmlComposer::Unbounded::visit(const UnboundedRegExpIteration < SymbolType > & iteration, ext::deque<sax::Token>& out) { out.emplace_back("iteration", sax::Token::TokenType::START_ELEMENT); - iteration.getElement().template accept < void, RegExpToXMLComposer::Unbounded > ( out ); + iteration.getElement().template accept < void, RegExpToXmlComposer::Unbounded > ( out ); out.emplace_back("iteration", sax::Token::TokenType::END_ELEMENT); } template < class SymbolType > -void RegExpToXMLComposer::Unbounded::visit(const UnboundedRegExpSymbol < SymbolType > & symbol, ext::deque<sax::Token>& out) { +void RegExpToXmlComposer::Unbounded::visit(const UnboundedRegExpSymbol < SymbolType > & symbol, ext::deque<sax::Token>& out) { core::xmlApi<SymbolType>::compose(out, symbol.getSymbol()); } template < class SymbolType > -void RegExpToXMLComposer::Unbounded::visit(const UnboundedRegExpEpsilon < SymbolType > &, ext::deque<sax::Token>& out) { +void RegExpToXmlComposer::Unbounded::visit(const UnboundedRegExpEpsilon < SymbolType > &, ext::deque<sax::Token>& out) { out.emplace_back("epsilon", sax::Token::TokenType::START_ELEMENT); out.emplace_back("epsilon", sax::Token::TokenType::END_ELEMENT); } template < class SymbolType > -void RegExpToXMLComposer::Unbounded::visit(const UnboundedRegExpEmpty < SymbolType > &, ext::deque<sax::Token>& out) { +void RegExpToXmlComposer::Unbounded::visit(const UnboundedRegExpEmpty < SymbolType > &, ext::deque<sax::Token>& out) { out.emplace_back("empty", sax::Token::TokenType::START_ELEMENT); out.emplace_back("empty", sax::Token::TokenType::END_ELEMENT); } template < class SymbolType > -void RegExpToXMLComposer::Formal::visit(const FormalRegExpAlternation < SymbolType > & alternation, ext::deque<sax::Token>& out) { +void RegExpToXmlComposer::Formal::visit(const FormalRegExpAlternation < SymbolType > & alternation, ext::deque<sax::Token>& out) { out.emplace_back("alternation", sax::Token::TokenType::START_ELEMENT); - alternation.getLeftElement().template accept < void, RegExpToXMLComposer::Formal > ( out ); - alternation.getRightElement().template accept < void, RegExpToXMLComposer::Formal > ( out ); + alternation.getLeftElement().template accept < void, RegExpToXmlComposer::Formal > ( out ); + alternation.getRightElement().template accept < void, RegExpToXmlComposer::Formal > ( out ); out.emplace_back("alternation", sax::Token::TokenType::END_ELEMENT); } template < class SymbolType > -void RegExpToXMLComposer::Formal::visit(const FormalRegExpConcatenation < SymbolType > & concatenation, ext::deque<sax::Token>& out) { +void RegExpToXmlComposer::Formal::visit(const FormalRegExpConcatenation < SymbolType > & concatenation, ext::deque<sax::Token>& out) { out.emplace_back("concatenation", sax::Token::TokenType::START_ELEMENT); - concatenation.getLeftElement().template accept < void, RegExpToXMLComposer::Formal > ( out ); - concatenation.getRightElement().template accept < void, RegExpToXMLComposer::Formal > ( out ); + concatenation.getLeftElement().template accept < void, RegExpToXmlComposer::Formal > ( out ); + concatenation.getRightElement().template accept < void, RegExpToXmlComposer::Formal > ( out ); out.emplace_back("concatenation", sax::Token::TokenType::END_ELEMENT); } template < class SymbolType > -void RegExpToXMLComposer::Formal::visit(const FormalRegExpIteration < SymbolType > & iteration, ext::deque<sax::Token>& out) { +void RegExpToXmlComposer::Formal::visit(const FormalRegExpIteration < SymbolType > & iteration, ext::deque<sax::Token>& out) { out.emplace_back("iteration", sax::Token::TokenType::START_ELEMENT); - iteration.getElement().template accept < void, RegExpToXMLComposer::Formal > ( out ); + iteration.getElement().template accept < void, RegExpToXmlComposer::Formal > ( out ); out.emplace_back("iteration", sax::Token::TokenType::END_ELEMENT); } template < class SymbolType > -void RegExpToXMLComposer::Formal::visit(const FormalRegExpSymbol < SymbolType > & symbol, ext::deque<sax::Token>& out) { +void RegExpToXmlComposer::Formal::visit(const FormalRegExpSymbol < SymbolType > & symbol, ext::deque<sax::Token>& out) { core::xmlApi<SymbolType>::compose(out, symbol.getSymbol()); } template < class SymbolType > -void RegExpToXMLComposer::Formal::visit(const FormalRegExpEpsilon < SymbolType > &, ext::deque<sax::Token>& out) { +void RegExpToXmlComposer::Formal::visit(const FormalRegExpEpsilon < SymbolType > &, ext::deque<sax::Token>& out) { out.emplace_back("epsilon", sax::Token::TokenType::START_ELEMENT); out.emplace_back("epsilon", sax::Token::TokenType::END_ELEMENT); } template < class SymbolType > -void RegExpToXMLComposer::Formal::visit(const FormalRegExpEmpty < SymbolType > &, ext::deque<sax::Token>& out) { +void RegExpToXmlComposer::Formal::visit(const FormalRegExpEmpty < SymbolType > &, ext::deque<sax::Token>& out) { out.emplace_back("empty", sax::Token::TokenType::START_ELEMENT); out.emplace_back("empty", sax::Token::TokenType::END_ELEMENT); } template < class SymbolType > -void RegExpToXMLComposer::composeAlphabet(ext::deque<sax::Token>& out, const ext::set<SymbolType>& alphabet) { +void RegExpToXmlComposer::composeAlphabet(ext::deque<sax::Token>& out, const ext::set<SymbolType>& alphabet) { out.emplace_back("alphabet", sax::Token::TokenType::START_ELEMENT); for (const auto& symbol : alphabet) { core::xmlApi<SymbolType>::compose(out, symbol); diff --git a/alib2str/src/regexp/string/FormalRegExp.h b/alib2str/src/regexp/string/FormalRegExp.h index 7763a14a82..885c40c17c 100644 --- a/alib2str/src/regexp/string/FormalRegExp.h +++ b/alib2str/src/regexp/string/FormalRegExp.h @@ -8,6 +8,7 @@ #ifndef _STRING_FORMAL_REG_EXP_H_ #define _STRING_FORMAL_REG_EXP_H_ +#include <regexp/formal/FormalRegExpElements.h> #include <regexp/formal/FormalRegExpStructure.h> #include <regexp/formal/FormalRegExp.h> #include <core/stringApi.hpp> diff --git a/alib2str/src/regexp/string/UnboundedRegExp.h b/alib2str/src/regexp/string/UnboundedRegExp.h index a9cbb1c38e..8435c828cf 100644 --- a/alib2str/src/regexp/string/UnboundedRegExp.h +++ b/alib2str/src/regexp/string/UnboundedRegExp.h @@ -11,6 +11,7 @@ #include <alib/memory> #include <alib/utility> +#include <regexp/unbounded/UnboundedRegExpElements.h> #include <regexp/unbounded/UnboundedRegExpStructure.h> #include <regexp/unbounded/UnboundedRegExp.h> #include <core/stringApi.hpp> -- GitLab