diff --git a/alib2data/src/regexp/formal/FormalRegExp.cpp b/alib2data/src/regexp/formal/FormalRegExp.cpp index 0fa43fa1f54c792b170e1473f33583b0c714ec0c..5f7c56badd6747c8ca4bb277853b8bab638965b0 100644 --- a/alib2data/src/regexp/formal/FormalRegExp.cpp +++ b/alib2data/src/regexp/formal/FormalRegExp.cpp @@ -25,39 +25,38 @@ namespace regexp { -FormalRegExp::FormalRegExp ( ) : alphabet::Alphabets < FormalRegExp, alphabet::Symbol, GeneralAlphabet > ( std::set< alphabet::Symbol > ( ) ), regExp ( NULL ) { - setRegExp ( FormalRegExpEmpty ( ) ); +FormalRegExp::FormalRegExp ( ) : FormalRegExp ( std::set < alphabet::Symbol > ( ), FormalRegExpEmpty ( ) ) { } -FormalRegExp::FormalRegExp ( const UnboundedRegExp & other ) : alphabet::Alphabets < FormalRegExp, alphabet::Symbol, GeneralAlphabet > ( other.getAlphabet( ) ), regExp ( NULL ) { +FormalRegExp::FormalRegExp ( const UnboundedRegExp & other ) : std::Components < FormalRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( other.getAlphabet ( ) ), std::tuple < > ( ) ), regExp ( NULL ) { FormalRegExpElement * element = other.getRegExp ( ).cloneAsFormal ( ); setRegExp ( std::move ( * element ) ); delete element; } -FormalRegExp::FormalRegExp ( std::set < alphabet::Symbol > alphabet, const FormalRegExpElement & regExp ) : alphabet::Alphabets < FormalRegExp, alphabet::Symbol, GeneralAlphabet > ( std::move ( alphabet ) ), regExp ( NULL ) { +FormalRegExp::FormalRegExp ( std::set < alphabet::Symbol > alphabet, const FormalRegExpElement & regExp ) : std::Components < FormalRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ), regExp ( NULL ) { setRegExp ( regExp ); } -FormalRegExp::FormalRegExp ( std::set < alphabet::Symbol > alphabet, FormalRegExpElement && regExp ) : alphabet::Alphabets < FormalRegExp, alphabet::Symbol, GeneralAlphabet > ( std::move ( alphabet ) ), regExp ( NULL ) { +FormalRegExp::FormalRegExp ( std::set < alphabet::Symbol > alphabet, FormalRegExpElement && regExp ) : std::Components < FormalRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ), regExp ( NULL ) { setRegExp ( std::move ( regExp ) ); } -FormalRegExp::FormalRegExp ( const FormalRegExpElement & regExp ) : alphabet::Alphabets < FormalRegExp, alphabet::Symbol, GeneralAlphabet > ( std::set< alphabet::Symbol > ( ) ), regExp ( NULL ) { - regExp.computeMinimalAlphabet ( accessAlphabet < GeneralAlphabet > ( ).get ( ) ); +FormalRegExp::FormalRegExp ( const FormalRegExpElement & regExp ) : std::Components < FormalRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::set< alphabet::Symbol > ( ) ), std::tuple < > ( ) ), regExp ( NULL ) { + regExp.computeMinimalAlphabet ( accessComponent < GeneralAlphabet > ( ).get ( ) ); setRegExp ( regExp ); } -FormalRegExp::FormalRegExp ( FormalRegExpElement && regExp ) : alphabet::Alphabets < FormalRegExp, alphabet::Symbol, GeneralAlphabet > ( std::set< alphabet::Symbol > ( ) ), regExp ( NULL ) { - regExp.computeMinimalAlphabet ( accessAlphabet < GeneralAlphabet > ( ).get ( ) ); +FormalRegExp::FormalRegExp ( FormalRegExpElement && regExp ) : std::Components < FormalRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::set< alphabet::Symbol > ( ) ), std::tuple < > ( ) ), regExp ( NULL ) { + regExp.computeMinimalAlphabet ( accessComponent < GeneralAlphabet > ( ).get ( ) ); setRegExp ( std::move ( regExp ) ); } -FormalRegExp::FormalRegExp ( const FormalRegExp & other ) : alphabet::Alphabets < FormalRegExp, alphabet::Symbol, GeneralAlphabet > ( other.getAlphabet ( ) ), regExp ( other.regExp->clone ( ) ) { +FormalRegExp::FormalRegExp ( const FormalRegExp & other ) : std::Components < FormalRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( other.getAlphabet ( ) ), std::tuple < > ( ) ), regExp ( other.regExp->clone ( ) ) { this->regExp->attachRegExp ( this ); } -FormalRegExp::FormalRegExp ( FormalRegExp && other ) noexcept : alphabet::Alphabets < FormalRegExp, alphabet::Symbol, GeneralAlphabet > ( other.getAlphabet ( ) ), regExp ( other.regExp ) { +FormalRegExp::FormalRegExp ( FormalRegExp && other ) noexcept : std::Components < FormalRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( other.getAlphabet ( ) ) ), std::tuple < > ( ) ), regExp ( other.regExp ) { this->regExp->attachRegExp ( this ); other.regExp = NULL; } @@ -81,7 +80,7 @@ FormalRegExp & FormalRegExp::operator =( const FormalRegExp & other ) { FormalRegExp & FormalRegExp::operator =( FormalRegExp && other ) noexcept { std::swap ( this->regExp, other.regExp ); - std::swap ( accessAlphabet < GeneralAlphabet > ( ).get ( ), other.accessAlphabet < GeneralAlphabet > ( ).get ( ) ); + std::swap ( accessComponent < GeneralAlphabet > ( ).get ( ), other.accessComponent < GeneralAlphabet > ( ).get ( ) ); return * this; } @@ -142,7 +141,7 @@ FormalRegExp FormalRegExp::parse ( std::deque < sax::Token >::iterator & input ) std::set < alphabet::Symbol > alphabet = RegExpFromXMLParser::parseAlphabet ( input ); - FormalRegExpElement * element = alib::xmlApi < regexp::FormalRegExpElement * >::parse ( input ); + FormalRegExpElement * element = alib::xmlApi < regexp::FormalRegExpElement >::parse ( input ); FormalRegExp regexp ( std::move ( alphabet ), std::move ( * element ) ); delete element; @@ -154,29 +153,29 @@ FormalRegExp FormalRegExp::parse ( std::deque < sax::Token >::iterator & input ) void FormalRegExp::compose ( std::deque < sax::Token > & out ) const { out.emplace_back ( FormalRegExp::XML_TAG_NAME, sax::Token::TokenType::START_ELEMENT ); RegExpToXMLComposer::composeAlphabet ( out, getAlphabet ( ) ); - alib::xmlApi < FormalRegExpElement * >::compose ( out, & this->getRegExp ( ) ); + alib::xmlApi < FormalRegExpElement >::compose ( out, this->getRegExp ( ) ); out.emplace_back ( FormalRegExp::XML_TAG_NAME, sax::Token::TokenType::END_ELEMENT ); } } /* namespace regexp */ -namespace alphabet { +namespace std { template < > -bool regexp::FormalRegExp::Alphabet < regexp::FormalRegExp, alphabet::Symbol, regexp::GeneralAlphabet >::used ( const alphabet::Symbol & symbol ) const { +bool regexp::FormalRegExp::Component < regexp::FormalRegExp, alphabet::Symbol, regexp::GeneralAlphabet >::used ( const alphabet::Symbol & symbol ) const { return static_cast < const regexp::FormalRegExp * > ( this )->getRegExp ( ).testSymbol ( symbol ); } template < > -bool regexp::FormalRegExp::Alphabet < regexp::FormalRegExp, alphabet::Symbol, regexp::GeneralAlphabet >::available ( const alphabet::Symbol & ) const { +bool regexp::FormalRegExp::Component < regexp::FormalRegExp, alphabet::Symbol, regexp::GeneralAlphabet >::available ( const alphabet::Symbol & ) const { return true; } template < > -void regexp::FormalRegExp::Alphabet < regexp::FormalRegExp, alphabet::Symbol, regexp::GeneralAlphabet >::valid ( const alphabet::Symbol & ) const { +void regexp::FormalRegExp::Component < regexp::FormalRegExp, alphabet::Symbol, regexp::GeneralAlphabet >::valid ( const alphabet::Symbol & ) const { } -} /* namespace alphabet */ +} /* namespace std */ namespace alib { diff --git a/alib2data/src/regexp/formal/FormalRegExp.h b/alib2data/src/regexp/formal/FormalRegExp.h index bbe8d3335ab0f8a17289dee4fd152d0615b62cf5..b27d5ad64c36877184a9a545672ee76b79b25734 100644 --- a/alib2data/src/regexp/formal/FormalRegExp.h +++ b/alib2data/src/regexp/formal/FormalRegExp.h @@ -10,9 +10,9 @@ #include <string> #include <set> +#include <core/components.hpp> #include "../RegExpBase.h" #include "../../alphabet/Symbol.h" -#include "../../alphabet/Alphabet.hpp" namespace regexp { @@ -24,7 +24,7 @@ class GeneralAlphabet; * Represents regular expression parsed from the XML. Regular expression is stored * as a tree of RegExpElement. */ -class FormalRegExp : public RegExpBase, public alphabet::Alphabets < FormalRegExp, alphabet::Symbol, GeneralAlphabet > { +class FormalRegExp : public RegExpBase, public std::Components < FormalRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > { protected: FormalRegExpElement * regExp; @@ -79,7 +79,7 @@ public: void setRegExp ( FormalRegExpElement && regExp ); virtual const std::set < alphabet::Symbol > & getAlphabet ( ) const { - return accessAlphabet < GeneralAlphabet > ( ).get ( ); + return accessComponent < GeneralAlphabet > ( ).get ( ); } /** diff --git a/alib2data/src/regexp/formal/FormalRegExpAlternation.h b/alib2data/src/regexp/formal/FormalRegExpAlternation.h index 52d3e44857eefb8c939133cb9b2cfce270b58016..bcf75bf4f0bc7744a7cc1db58980c03baaf3b965 100644 --- a/alib2data/src/regexp/formal/FormalRegExpAlternation.h +++ b/alib2data/src/regexp/formal/FormalRegExpAlternation.h @@ -25,29 +25,14 @@ class RegExpOptimize; */ class FormalRegExpAlternation : public FormalRegExpElement { protected: - /** - * @copydoc FormalRegExpElement::clone() const - */ - virtual UnboundedRegExpElement * cloneAsUnbounded ( ) const; - FormalRegExpElement * left; FormalRegExpElement * right; - /** - * @copydoc FormalRegExpElement::testSymbol() const - */ - virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; - /** * @copydoc FormalRegExpElement::attachRegExp() */ virtual bool attachRegExp ( const FormalRegExp * regexp ); - /** - * @copydoc FormalRegExpElement::computeMinimalAlphabet() - */ - virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; - public: void Accept ( void * userData, const FormalRegExpElementVisitor & visitor ) const { visitor.Visit ( userData, * this ); @@ -73,6 +58,21 @@ public: */ virtual FormalRegExpElement * plunder ( ) &&; + /** + * @copydoc FormalRegExpElement::clone() const + */ + virtual UnboundedRegExpElement * cloneAsUnbounded ( ) const; + + /** + * @copydoc FormalRegExpElement::testSymbol() const + */ + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; + + /** + * @copydoc FormalRegExpElement::computeMinimalAlphabet() + */ + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; + /** * @return elements */ diff --git a/alib2data/src/regexp/formal/FormalRegExpConcatenation.h b/alib2data/src/regexp/formal/FormalRegExpConcatenation.h index ebe527e57957b506adc8cfa228a66c782c7c0381..23c950e030f0b66608c96dbbf5baafa9ebf60b92 100644 --- a/alib2data/src/regexp/formal/FormalRegExpConcatenation.h +++ b/alib2data/src/regexp/formal/FormalRegExpConcatenation.h @@ -26,29 +26,14 @@ class RegExpOptimize; */ class FormalRegExpConcatenation : public FormalRegExpElement { protected: - /** - * @copydoc FormalRegExpElement::clone() const - */ - virtual UnboundedRegExpElement * cloneAsUnbounded ( ) const; - FormalRegExpElement * left; FormalRegExpElement * right; - /** - * @copydoc FormalRegExpElement::testSymbol() const - */ - virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; - /** * @copydoc FormalRegExpElement::attachRegExp() */ virtual bool attachRegExp ( const FormalRegExp * regexp ); - /** - * @copydoc FormalRegExpElement::computeMinimalAlphabet() - */ - virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; - public: void Accept ( void * userData, const FormalRegExpElementVisitor & visitor ) const { visitor.Visit ( userData, * this ); @@ -73,6 +58,21 @@ public: */ virtual FormalRegExpElement * plunder ( ) &&; + /** + * @copydoc FormalRegExpElement::clone() const + */ + virtual UnboundedRegExpElement * cloneAsUnbounded ( ) const; + + /** + * @copydoc FormalRegExpElement::testSymbol() const + */ + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; + + /** + * @copydoc FormalRegExpElement::computeMinimalAlphabet() + */ + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; + /** * @return elements */ diff --git a/alib2data/src/regexp/formal/FormalRegExpElement.cpp b/alib2data/src/regexp/formal/FormalRegExpElement.cpp index 3384219405bda7e1be36f38725c35cc1a2904b35..58d8a3dcd25af0db1d6afa9321d61f91e6003bd8 100644 --- a/alib2data/src/regexp/formal/FormalRegExpElement.cpp +++ b/alib2data/src/regexp/formal/FormalRegExpElement.cpp @@ -23,20 +23,16 @@ FormalRegExpElement::FormalRegExpElement ( ) : parentRegExp ( NULL ) { namespace alib { -regexp::FormalRegExpElement * xmlApi < regexp::FormalRegExpElement * >::parse ( std::deque < sax::Token >::iterator & input ) { +regexp::FormalRegExpElement * xmlApi < regexp::FormalRegExpElement >::parse ( std::deque < sax::Token >::iterator & input ) { return regexp::RegExpFromXMLParser::parseFormalRegExpElement ( input ); } -bool xmlApi < regexp::FormalRegExpElement * >::first ( const std::deque < sax::Token >::const_iterator & ) { +bool xmlApi < regexp::FormalRegExpElement >::first ( const std::deque < sax::Token >::const_iterator & ) { throw exception::CommonException ( "Unimplemented" ); } -void xmlApi < regexp::FormalRegExpElement * >::compose ( std::deque < sax::Token > & output, const regexp::FormalRegExpElement * const & data ) { - data->Accept ( ( void * ) & output, regexp::RegExpToXMLComposer::REGEXP_TO_XML_COMPOSER ); -} - -void xmlApi < const regexp::FormalRegExpElement * >::compose ( std::deque < sax::Token > & output, const regexp::FormalRegExpElement * const & data ) { - data->Accept ( ( void * ) & output, regexp::RegExpToXMLComposer::REGEXP_TO_XML_COMPOSER ); +void xmlApi < regexp::FormalRegExpElement >::compose ( std::deque < sax::Token > & output, const regexp::FormalRegExpElement & data ) { + data.Accept ( ( void * ) & output, regexp::RegExpToXMLComposer::REGEXP_TO_XML_COMPOSER ); } } /* namespace alib */ diff --git a/alib2data/src/regexp/formal/FormalRegExpElement.h b/alib2data/src/regexp/formal/FormalRegExpElement.h index 0f16158382758b28d4ae695d18252dceaaa74e5d..fa1c06195bf520633f6c24b300886c582a03648e 100644 --- a/alib2data/src/regexp/formal/FormalRegExpElement.h +++ b/alib2data/src/regexp/formal/FormalRegExpElement.h @@ -52,14 +52,6 @@ protected: */ virtual bool attachRegExp ( const FormalRegExp * regexp ) = 0; - /** - * Traverses the regexp tree computing minimal alphabet needed by regexp - * - * @param alphabet All alphabet symbols encountered are added into this set - * @return true if symbol is used by the element and its successor - */ - virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const = 0; - public: virtual void Accept ( void * userData, const FormalRegExpElementVisitor & visitor ) const = 0; @@ -79,6 +71,14 @@ public: */ virtual bool testSymbol ( const alphabet::Symbol & symbol ) const = 0; + /** + * Traverses the regexp tree computing minimal alphabet needed by regexp + * + * @param alphabet All alphabet symbols encountered are added into this set + * @return true if symbol is used by the element and its successor + */ + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const = 0; + friend class FormalRegExp; friend class FormalRegExpAlternation; @@ -94,15 +94,10 @@ public: namespace alib { template < > -struct xmlApi < regexp::FormalRegExpElement * > { +struct xmlApi < regexp::FormalRegExpElement > { static regexp::FormalRegExpElement * parse ( std::deque < sax::Token >::iterator & input ); static bool first ( const std::deque < sax::Token >::const_iterator & input ); - static void compose ( std::deque < sax::Token > & output, const regexp::FormalRegExpElement * const & data ); -}; - -template < > -struct xmlApi < const regexp::FormalRegExpElement * > { - static void compose ( std::deque < sax::Token > & output, const regexp::FormalRegExpElement * const & data ); + static void compose ( std::deque < sax::Token > & output, const regexp::FormalRegExpElement & data ); }; } /* namespace alib */ diff --git a/alib2data/src/regexp/formal/FormalRegExpEmpty.h b/alib2data/src/regexp/formal/FormalRegExpEmpty.h index 73a153c2e0b05c08eab2a2fd74694cc8182417ae..35c6af242d9dcbd2b86e56c23c3f0d0dcb4b09dc 100644 --- a/alib2data/src/regexp/formal/FormalRegExpEmpty.h +++ b/alib2data/src/regexp/formal/FormalRegExpEmpty.h @@ -18,26 +18,11 @@ namespace regexp { */ class FormalRegExpEmpty : public FormalRegExpElement { protected: - /** - * @copydoc FormalRegExpElement::clone() const - */ - virtual UnboundedRegExpElement * cloneAsUnbounded ( ) const; - - /** - * @copydoc FormalRegExpElement::testSymbol() const - */ - virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; - /** * @copydoc FormalRegExpElement::attachRegExp() */ virtual bool attachRegExp ( const FormalRegExp * regexp ); - /** - * @copydoc RegExpElement::computeMinimalAlphabet() - */ - virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; - public: void Accept ( void * userData, const FormalRegExpElementVisitor & visitor ) const { visitor.Visit ( userData, * this ); @@ -59,6 +44,21 @@ public: */ virtual FormalRegExpElement * plunder ( ) &&; + /** + * @copydoc FormalRegExpElement::clone() const + */ + virtual UnboundedRegExpElement * cloneAsUnbounded ( ) const; + + /** + * @copydoc FormalRegExpElement::testSymbol() const + */ + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; + + /** + * @copydoc RegExpElement::computeMinimalAlphabet() + */ + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; + virtual int compare ( const FormalRegExpElement & other ) const { if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); diff --git a/alib2data/src/regexp/formal/FormalRegExpEpsilon.h b/alib2data/src/regexp/formal/FormalRegExpEpsilon.h index 9fb1bdffb241536d1bf7ac103b82e2e662ef3b3c..6724fc680bee5bf3a5f3baa26edfc4404806f67c 100644 --- a/alib2data/src/regexp/formal/FormalRegExpEpsilon.h +++ b/alib2data/src/regexp/formal/FormalRegExpEpsilon.h @@ -18,26 +18,11 @@ namespace regexp { */ class FormalRegExpEpsilon : public FormalRegExpElement { protected: - /** - * @copydoc FormalRegExpElement::clone() const - */ - virtual UnboundedRegExpElement * cloneAsUnbounded ( ) const; - - /** - * @copydoc FormalRegExpElement::testSymbol() const - */ - virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; - /** * @copydoc FormalRegExpElement::attachRegExp() */ virtual bool attachRegExp ( const FormalRegExp * regexp ); - /** - * @copydoc FormalRegExpElement::computeMinimalAlphabet() - */ - virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; - public: void Accept ( void * userData, const FormalRegExpElementVisitor & visitor ) const { visitor.Visit ( userData, * this ); @@ -59,6 +44,21 @@ public: */ virtual FormalRegExpElement * plunder ( ) &&; + /** + * @copydoc FormalRegExpElement::clone() const + */ + virtual UnboundedRegExpElement * cloneAsUnbounded ( ) const; + + /** + * @copydoc FormalRegExpElement::testSymbol() const + */ + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; + + /** + * @copydoc FormalRegExpElement::computeMinimalAlphabet() + */ + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; + virtual int compare ( const FormalRegExpElement & other ) const { if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); diff --git a/alib2data/src/regexp/formal/FormalRegExpIteration.h b/alib2data/src/regexp/formal/FormalRegExpIteration.h index e2c1babb9e9f2821f13465b053963c86a799d060..bc12ec45af8cc849e86c5cf9edd56f5007f9fe4c 100644 --- a/alib2data/src/regexp/formal/FormalRegExpIteration.h +++ b/alib2data/src/regexp/formal/FormalRegExpIteration.h @@ -27,26 +27,11 @@ class FormalRegExpIteration : public FormalRegExpElement { protected: FormalRegExpElement * element; - /** - * @copydoc FormalRegExpElement::clone() const - */ - virtual UnboundedRegExpElement * cloneAsUnbounded ( ) const; - - /** - * @copydoc FormalRegExpElement::testSymbol() const - */ - virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; - /** * @copydoc FormalRegExpElement::attachRegExp() */ virtual bool attachRegExp ( const FormalRegExp * regexp ); - /** - * @copydoc FormalRegExpElement::computeMinimalAlphabet() - */ - virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; - public: void Accept ( void * userData, const FormalRegExpElementVisitor & visitor ) const { visitor.Visit ( userData, * this ); @@ -71,6 +56,21 @@ public: */ virtual FormalRegExpElement * plunder ( ) &&; + /** + * @copydoc FormalRegExpElement::clone() const + */ + virtual UnboundedRegExpElement * cloneAsUnbounded ( ) const; + + /** + * @copydoc FormalRegExpElement::testSymbol() const + */ + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; + + /** + * @copydoc FormalRegExpElement::computeMinimalAlphabet() + */ + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; + /** * @return element */ diff --git a/alib2data/src/regexp/formal/FormalRegExpSymbol.h b/alib2data/src/regexp/formal/FormalRegExpSymbol.h index 63439268023a52a41eabd260bf17a1c3dda26800..a95d248cdb472b04abe8d019ce83d668235a0f63 100644 --- a/alib2data/src/regexp/formal/FormalRegExpSymbol.h +++ b/alib2data/src/regexp/formal/FormalRegExpSymbol.h @@ -20,26 +20,11 @@ class FormalRegExpSymbol : public FormalRegExpElement { protected: alphabet::Symbol symbol; - /** - * @copydoc FormalRegExpElement::clone() const - */ - virtual UnboundedRegExpElement * cloneAsUnbounded ( ) const; - - /** - * @copydoc FormalRegExpElement::testSymbol() const - */ - virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; - /** * @copydoc FormalRegExpElement::attachRegExp() */ virtual bool attachRegExp ( const FormalRegExp * regexp ); - /** - * @copydoc FormalRegExpElement::computeMinimalAlphabet() - */ - virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; - public: void Accept ( void * userData, const FormalRegExpElementVisitor & visitor ) const { visitor.Visit ( userData, * this ); @@ -67,6 +52,21 @@ public: */ virtual FormalRegExpElement * plunder ( ) &&; + /** + * @copydoc FormalRegExpElement::clone() const + */ + virtual UnboundedRegExpElement * cloneAsUnbounded ( ) const; + + /** + * @copydoc FormalRegExpElement::testSymbol() const + */ + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; + + /** + * @copydoc FormalRegExpElement::computeMinimalAlphabet() + */ + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; + bool operator ==( const alphabet::Symbol & ) const; friend bool operator ==( const alphabet::Symbol &, const FormalRegExpSymbol & ); diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExp.cpp b/alib2data/src/regexp/unbounded/UnboundedRegExp.cpp index 600612b4feb5cda89636d2c8022e713039e8d0d0..9591e72fabb1b5f15ebde36df1a2277513ee980d 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExp.cpp +++ b/alib2data/src/regexp/unbounded/UnboundedRegExp.cpp @@ -25,39 +25,38 @@ namespace regexp { -UnboundedRegExp::UnboundedRegExp ( ) : alphabet::Alphabets < UnboundedRegExp, alphabet::Symbol, GeneralAlphabet > ( std::set< alphabet::Symbol > ( ) ), regExp ( NULL ) { - setRegExp ( UnboundedRegExpEmpty ( ) ); +UnboundedRegExp::UnboundedRegExp ( ) : UnboundedRegExp ( std::set < alphabet::Symbol > ( ), UnboundedRegExpEmpty ( ) ) { } -UnboundedRegExp::UnboundedRegExp ( const FormalRegExp & other ) : alphabet::Alphabets < UnboundedRegExp, alphabet::Symbol, GeneralAlphabet > ( other.getAlphabet( ) ), regExp ( NULL ) { +UnboundedRegExp::UnboundedRegExp ( const FormalRegExp & other ) : std::Components < UnboundedRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( other.getAlphabet ( ) ), std::tuple < > ( ) ), regExp ( NULL ) { UnboundedRegExpElement * element = other.getRegExp ( ).cloneAsUnbounded ( ); setRegExp ( std::move ( * element ) ); delete element; } -UnboundedRegExp::UnboundedRegExp ( std::set < alphabet::Symbol > alphabet, const UnboundedRegExpElement & regExp ) : alphabet::Alphabets < UnboundedRegExp, alphabet::Symbol, GeneralAlphabet > ( std::move ( alphabet ) ), regExp ( NULL ) { +UnboundedRegExp::UnboundedRegExp ( std::set < alphabet::Symbol > alphabet, const UnboundedRegExpElement & regExp ) : std::Components < UnboundedRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ), regExp ( NULL ) { setRegExp ( regExp ); } -UnboundedRegExp::UnboundedRegExp ( std::set < alphabet::Symbol > alphabet, UnboundedRegExpElement && regExp ) : alphabet::Alphabets < UnboundedRegExp, alphabet::Symbol, GeneralAlphabet > ( std::move ( alphabet ) ), regExp ( NULL ) { +UnboundedRegExp::UnboundedRegExp ( std::set < alphabet::Symbol > alphabet, UnboundedRegExpElement && regExp ) : std::Components < UnboundedRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ), regExp ( NULL ) { setRegExp ( std::move ( regExp ) ); } -UnboundedRegExp::UnboundedRegExp ( const UnboundedRegExpElement & regExp ) : alphabet::Alphabets < UnboundedRegExp, alphabet::Symbol, GeneralAlphabet > ( std::set< alphabet::Symbol > ( ) ), regExp ( NULL ) { - regExp.computeMinimalAlphabet ( accessAlphabet < GeneralAlphabet > ( ).get ( ) ); +UnboundedRegExp::UnboundedRegExp ( const UnboundedRegExpElement & regExp ) : std::Components < UnboundedRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::set< alphabet::Symbol > ( ) ), std::tuple < > ( ) ), regExp ( NULL ) { + regExp.computeMinimalAlphabet ( accessComponent < GeneralAlphabet > ( ).get ( ) ); setRegExp ( regExp ); } -UnboundedRegExp::UnboundedRegExp ( UnboundedRegExpElement && regExp ) : alphabet::Alphabets < UnboundedRegExp, alphabet::Symbol, GeneralAlphabet > ( std::set< alphabet::Symbol > ( ) ), regExp ( NULL ) { - regExp.computeMinimalAlphabet ( accessAlphabet < GeneralAlphabet > ( ).get ( ) ); +UnboundedRegExp::UnboundedRegExp ( UnboundedRegExpElement && regExp ) : std::Components < UnboundedRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::set< alphabet::Symbol > ( ) ), std::tuple < > ( ) ), regExp ( NULL ) { + regExp.computeMinimalAlphabet ( accessComponent < GeneralAlphabet > ( ).get ( ) ); setRegExp ( std::move ( regExp ) ); } -UnboundedRegExp::UnboundedRegExp ( const UnboundedRegExp & other ) : alphabet::Alphabets < UnboundedRegExp, alphabet::Symbol, GeneralAlphabet > ( other.getAlphabet ( ) ), regExp ( other.regExp->clone ( ) ) { +UnboundedRegExp::UnboundedRegExp ( const UnboundedRegExp & other ) : std::Components < UnboundedRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( other.getAlphabet ( ) ), std::tuple < > ( ) ), regExp ( other.regExp->clone ( ) ) { this->regExp->attachRegExp ( this ); } -UnboundedRegExp::UnboundedRegExp ( UnboundedRegExp && other ) noexcept : alphabet::Alphabets < UnboundedRegExp, alphabet::Symbol, GeneralAlphabet > ( other.getAlphabet ( ) ), regExp ( other.regExp ) { +UnboundedRegExp::UnboundedRegExp ( UnboundedRegExp && other ) noexcept : std::Components < UnboundedRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( other.getAlphabet ( ) ) ), std::tuple < > ( ) ), regExp ( other.regExp ) { this->regExp->attachRegExp ( this ); other.regExp = NULL; } @@ -81,7 +80,7 @@ UnboundedRegExp & UnboundedRegExp::operator =( const UnboundedRegExp & other ) { UnboundedRegExp & UnboundedRegExp::operator =( UnboundedRegExp && other ) noexcept { std::swap ( this->regExp, other.regExp ); - std::swap ( accessAlphabet < GeneralAlphabet > ( ).get ( ), other.accessAlphabet < GeneralAlphabet > ( ).get ( ) ); + std::swap ( accessComponent < GeneralAlphabet > ( ).get ( ), other.accessComponent < GeneralAlphabet > ( ).get ( ) ); return * this; } @@ -142,7 +141,7 @@ UnboundedRegExp UnboundedRegExp::parse ( std::deque < sax::Token >::iterator & i std::set < alphabet::Symbol > alphabet = RegExpFromXMLParser::parseAlphabet ( input ); - UnboundedRegExpElement * element = alib::xmlApi < regexp::UnboundedRegExpElement * >::parse ( input ); + UnboundedRegExpElement * element = alib::xmlApi < regexp::UnboundedRegExpElement >::parse ( input ); UnboundedRegExp regexp ( std::move ( alphabet ), std::move ( * element ) ); delete element; @@ -154,29 +153,29 @@ UnboundedRegExp UnboundedRegExp::parse ( std::deque < sax::Token >::iterator & i void UnboundedRegExp::compose ( std::deque < sax::Token > & out ) const { out.emplace_back ( UnboundedRegExp::XML_TAG_NAME, sax::Token::TokenType::START_ELEMENT ); RegExpToXMLComposer::composeAlphabet ( out, this->getAlphabet ( ) ); - alib::xmlApi < UnboundedRegExpElement * >::compose ( out, & this->getRegExp ( ) ); + alib::xmlApi < UnboundedRegExpElement >::compose ( out, this->getRegExp ( ) ); out.emplace_back ( UnboundedRegExp::XML_TAG_NAME, sax::Token::TokenType::END_ELEMENT ); } } /* namespace regexp */ -namespace alphabet { +namespace std { template < > -bool regexp::UnboundedRegExp::Alphabet < regexp::UnboundedRegExp, alphabet::Symbol, regexp::GeneralAlphabet >::used ( const alphabet::Symbol & symbol ) const { +bool regexp::UnboundedRegExp::Component < regexp::UnboundedRegExp, alphabet::Symbol, regexp::GeneralAlphabet >::used ( const alphabet::Symbol & symbol ) const { return static_cast < const regexp::UnboundedRegExp * > ( this )->getRegExp ( ).testSymbol ( symbol ); } template < > -bool regexp::UnboundedRegExp::Alphabet < regexp::UnboundedRegExp, alphabet::Symbol, regexp::GeneralAlphabet >::available ( const alphabet::Symbol & ) const { +bool regexp::UnboundedRegExp::Component < regexp::UnboundedRegExp, alphabet::Symbol, regexp::GeneralAlphabet >::available ( const alphabet::Symbol & ) const { return true; } template < > -void regexp::UnboundedRegExp::Alphabet < regexp::UnboundedRegExp, alphabet::Symbol, regexp::GeneralAlphabet >::valid ( const alphabet::Symbol & ) const { +void regexp::UnboundedRegExp::Component < regexp::UnboundedRegExp, alphabet::Symbol, regexp::GeneralAlphabet >::valid ( const alphabet::Symbol & ) const { } -} /* namespace alphabet */ +} /* namespace std */ namespace alib { diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExp.h b/alib2data/src/regexp/unbounded/UnboundedRegExp.h index 34c40442f6ea93d22fb263f9e74c0704b05e057b..0a10b2874e340d7283648b2b2dfc275e6577aa5b 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExp.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExp.h @@ -10,9 +10,9 @@ #include <string> #include <set> +#include <core/components.hpp> #include "../RegExpBase.h" #include "../../alphabet/Symbol.h" -#include "../../alphabet/Alphabet.hpp" namespace regexp { @@ -24,7 +24,7 @@ class GeneralAlphabet; * Represents regular expression parsed from the XML. Regular expression is stored * as a tree of RegExpElement. */ -class UnboundedRegExp : public RegExpBase, public alphabet::Alphabets < UnboundedRegExp, alphabet::Symbol, GeneralAlphabet > { +class UnboundedRegExp : public RegExpBase, public std::Components < UnboundedRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > { protected: UnboundedRegExpElement * regExp; @@ -79,7 +79,7 @@ public: void setRegExp ( UnboundedRegExpElement && regExp ); virtual const std::set < alphabet::Symbol > & getAlphabet ( ) const { - return accessAlphabet < GeneralAlphabet > ( ).get ( ); + return accessComponent < GeneralAlphabet > ( ).get ( ); } /** diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpAlternation.h b/alib2data/src/regexp/unbounded/UnboundedRegExpAlternation.h index 5213939fe7eb9ad2bfafe434eb5b8b7e1890d06e..3b49959b162fff34a99a7975512db903f8d97a54 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpAlternation.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpAlternation.h @@ -25,28 +25,13 @@ class RegExpOptimize; */ class UnboundedRegExpAlternation : public UnboundedRegExpElement { protected: - /** - * @copydoc UnboundedRegExpElement::cloneAsFormal() const - */ - virtual FormalRegExpElement * cloneAsFormal ( ) const; - std::vector < UnboundedRegExpElement * > elements; - /** - * @copydoc UnboundedRegExpElement::testSymbol() const - */ - virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; - /** * @copydoc UnboundedRegExpElement::attachRegExp() */ virtual bool attachRegExp ( const UnboundedRegExp * regexp ); - /** - * @copydoc UnboundedRegExpElement::computeMinimalAlphabet() - */ - virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; - public: void Accept ( void * userData, const UnboundedRegExpElementVisitor & visitor ) const { visitor.Visit ( userData, * this ); @@ -70,6 +55,21 @@ public: */ virtual UnboundedRegExpElement * plunder ( ) &&; + /** + * @copydoc UnboundedRegExpElement::cloneAsFormal() const + */ + virtual FormalRegExpElement * cloneAsFormal ( ) const; + + /** + * @copydoc UnboundedRegExpElement::testSymbol() const + */ + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; + + /** + * @copydoc UnboundedRegExpElement::computeMinimalAlphabet() + */ + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; + /** * @return elements */ diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpConcatenation.h b/alib2data/src/regexp/unbounded/UnboundedRegExpConcatenation.h index 5324fd3c215c3b030916c8ae70325801be1e0ded..f5518480063161cf328cdbc85d00206503fd7df5 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpConcatenation.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpConcatenation.h @@ -25,28 +25,13 @@ class RegExpOptimize; */ class UnboundedRegExpConcatenation : public UnboundedRegExpElement { protected: - /** - * @copydoc UnboundedRegExpElement::cloneAsFormal() const - */ - virtual FormalRegExpElement * cloneAsFormal ( ) const; - std::vector < UnboundedRegExpElement * > elements; - /** - * @copydoc UnboundedRegExpElement::testSymbol() const - */ - virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; - /** * @copydoc UnboundedRegExpElement::attachRegExp() */ virtual bool attachRegExp ( const UnboundedRegExp * regexp ); - /** - * @copydoc UnboundedRegExpElement::computeMinimalAlphabet() - */ - virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; - public: void Accept ( void * userData, const UnboundedRegExpElementVisitor & visitor ) const { visitor.Visit ( userData, * this ); @@ -70,6 +55,21 @@ public: */ virtual UnboundedRegExpElement * plunder ( ) &&; + /** + * @copydoc UnboundedRegExpElement::cloneAsFormal() const + */ + virtual FormalRegExpElement * cloneAsFormal ( ) const; + + /** + * @copydoc UnboundedRegExpElement::testSymbol() const + */ + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; + + /** + * @copydoc UnboundedRegExpElement::computeMinimalAlphabet() + */ + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; + /** * @return elements */ diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpElement.cpp b/alib2data/src/regexp/unbounded/UnboundedRegExpElement.cpp index ebbaebeba49fcf931290dc6287a18c643a53993f..b39136bb05977cd448604cd9b6297a741ef1ac76 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpElement.cpp +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpElement.cpp @@ -23,20 +23,16 @@ UnboundedRegExpElement::UnboundedRegExpElement ( ) : parentRegExp ( NULL ) { namespace alib { -regexp::UnboundedRegExpElement * xmlApi < regexp::UnboundedRegExpElement * >::parse ( std::deque < sax::Token >::iterator & input ) { +regexp::UnboundedRegExpElement * xmlApi < regexp::UnboundedRegExpElement >::parse ( std::deque < sax::Token >::iterator & input ) { return regexp::RegExpFromXMLParser::parseUnboundedRegExpElement ( input ); } -bool xmlApi < regexp::UnboundedRegExpElement * >::first ( const std::deque < sax::Token >::const_iterator & ) { +bool xmlApi < regexp::UnboundedRegExpElement >::first ( const std::deque < sax::Token >::const_iterator & ) { throw exception::CommonException ( "Unimplemented" ); } -void xmlApi < regexp::UnboundedRegExpElement * >::compose ( std::deque < sax::Token > & output, const regexp::UnboundedRegExpElement * const & data ) { - data->Accept ( ( void * ) & output, regexp::RegExpToXMLComposer::REGEXP_TO_XML_COMPOSER ); -} - -void xmlApi < const regexp::UnboundedRegExpElement * >::compose ( std::deque < sax::Token > & output, const regexp::UnboundedRegExpElement * const & data ) { - data->Accept ( ( void * ) & output, regexp::RegExpToXMLComposer::REGEXP_TO_XML_COMPOSER ); +void xmlApi < regexp::UnboundedRegExpElement >::compose ( std::deque < sax::Token > & output, const regexp::UnboundedRegExpElement & data ) { + data.Accept ( ( void * ) & output, regexp::RegExpToXMLComposer::REGEXP_TO_XML_COMPOSER ); } } /* namespace alib */ diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpElement.h b/alib2data/src/regexp/unbounded/UnboundedRegExpElement.h index 75eb61666dc9c2715e25ec49a8e50325a0783b9c..e01f056109f226c3fad7d8997735d0cc46715425 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpElement.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpElement.h @@ -52,14 +52,6 @@ protected: */ virtual bool attachRegExp ( const UnboundedRegExp * regexp ) = 0; - /** - * Traverses the regexp tree computing minimal alphabet needed by regexp - * - * @param alphabet All alphabet symbols encountered are added into this set - * @return true if symbol is used by the element and its successor - */ - virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const = 0; - public: virtual void Accept ( void * userData, const UnboundedRegExpElementVisitor & visitor ) const = 0; @@ -79,6 +71,14 @@ public: */ virtual bool testSymbol ( const alphabet::Symbol & symbol ) const = 0; + /** + * Traverses the regexp tree computing minimal alphabet needed by regexp + * + * @param alphabet All alphabet symbols encountered are added into this set + * @return true if symbol is used by the element and its successor + */ + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const = 0; + friend class UnboundedRegExp; friend class UnboundedRegExpAlternation; @@ -94,15 +94,10 @@ public: namespace alib { template < > -struct xmlApi < regexp::UnboundedRegExpElement * > { +struct xmlApi < regexp::UnboundedRegExpElement > { static regexp::UnboundedRegExpElement * parse ( std::deque < sax::Token >::iterator & input ); static bool first ( const std::deque < sax::Token >::const_iterator & input ); - static void compose ( std::deque < sax::Token > & output, const regexp::UnboundedRegExpElement * const & data ); -}; - -template < > -struct xmlApi < const regexp::UnboundedRegExpElement * > { - static void compose ( std::deque < sax::Token > & output, const regexp::UnboundedRegExpElement * const & data ); + static void compose ( std::deque < sax::Token > & output, const regexp::UnboundedRegExpElement & data ); }; } /* namespace alib */ diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpEmpty.h b/alib2data/src/regexp/unbounded/UnboundedRegExpEmpty.h index 27cc6334bdc60050251d58226b40778d48177de1..8a5825237f532d91b420f71d8425400674a2e12a 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpEmpty.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpEmpty.h @@ -17,26 +17,11 @@ namespace regexp { */ class UnboundedRegExpEmpty : public UnboundedRegExpElement { protected: - /** - * @copydoc UnboundedRegExpElement::cloneAsFormal() const - */ - virtual FormalRegExpElement * cloneAsFormal ( ) const; - - /** - * @copydoc UnboundedRegExpElement::testSymbol() const - */ - virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; - /** * @copydoc UnboundedRegExpElement::attachRegExp() */ virtual bool attachRegExp ( const UnboundedRegExp * regexp ); - /** - * @copydoc RegExpElement::computeMinimalAlphabet() - */ - virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; - public: void Accept ( void * userData, const UnboundedRegExpElementVisitor & visitor ) const { visitor.Visit ( userData, * this ); @@ -58,6 +43,21 @@ public: */ virtual UnboundedRegExpElement * plunder ( ) &&; + /** + * @copydoc UnboundedRegExpElement::cloneAsFormal() const + */ + virtual FormalRegExpElement * cloneAsFormal ( ) const; + + /** + * @copydoc UnboundedRegExpElement::testSymbol() const + */ + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; + + /** + * @copydoc RegExpElement::computeMinimalAlphabet() + */ + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; + virtual int compare ( const UnboundedRegExpElement & other ) const { if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpEpsilon.h b/alib2data/src/regexp/unbounded/UnboundedRegExpEpsilon.h index a3ac03faf46a17da8b661b27d38fd40d1464136a..8803da4442d9be7b91c3aa523055db137b67a02c 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpEpsilon.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpEpsilon.h @@ -17,26 +17,11 @@ namespace regexp { */ class UnboundedRegExpEpsilon : public UnboundedRegExpElement { protected: - /** - * @copydoc UnboundedRegExpElement::cloneAsFormal() const - */ - virtual FormalRegExpElement * cloneAsFormal ( ) const; - - /** - * @copydoc UnboundedRegExpElement::testSymbol() const - */ - virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; - /** * @copydoc UnboundedRegExpElement::attachRegExp() */ virtual bool attachRegExp ( const UnboundedRegExp * regexp ); - /** - * @copydoc UnboundedRegExpElement::computeMinimalAlphabet() - */ - virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; - public: void Accept ( void * userData, const UnboundedRegExpElementVisitor & visitor ) const { visitor.Visit ( userData, * this ); @@ -58,6 +43,21 @@ public: */ virtual UnboundedRegExpElement * plunder ( ) &&; + /** + * @copydoc UnboundedRegExpElement::cloneAsFormal() const + */ + virtual FormalRegExpElement * cloneAsFormal ( ) const; + + /** + * @copydoc UnboundedRegExpElement::testSymbol() const + */ + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; + + /** + * @copydoc UnboundedRegExpElement::computeMinimalAlphabet() + */ + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; + virtual int compare ( const UnboundedRegExpElement & other ) const { if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpIteration.h b/alib2data/src/regexp/unbounded/UnboundedRegExpIteration.h index 7e047c21d25272a168fc9b20f9e78f85126b84bd..7be9f45c651d8b65c9a8ad79dda4ff38812fb94e 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpIteration.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpIteration.h @@ -27,26 +27,11 @@ class UnboundedRegExpIteration : public UnboundedRegExpElement { protected: UnboundedRegExpElement * element; - /** - * @copydoc UnboundedRegExpElement::cloneAsFormal() const - */ - virtual FormalRegExpElement * cloneAsFormal ( ) const; - - /** - * @copydoc UnboundedRegExpElement::testSymbol() const - */ - virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; - /** * @copydoc UnboundedRegExpElement::attachRegExp() */ virtual bool attachRegExp ( const UnboundedRegExp * regexp ); - /** - * @copydoc UnboundedRegExpElement::computeMinimalAlphabet() - */ - virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; - public: void Accept ( void * userData, const UnboundedRegExpElementVisitor & visitor ) const { visitor.Visit ( userData, * this ); @@ -71,6 +56,21 @@ public: */ virtual UnboundedRegExpElement * plunder ( ) &&; + /** + * @copydoc UnboundedRegExpElement::cloneAsFormal() const + */ + virtual FormalRegExpElement * cloneAsFormal ( ) const; + + /** + * @copydoc UnboundedRegExpElement::testSymbol() const + */ + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; + + /** + * @copydoc UnboundedRegExpElement::computeMinimalAlphabet() + */ + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; + /** * @return element */ diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpSymbol.h b/alib2data/src/regexp/unbounded/UnboundedRegExpSymbol.h index 04a5794fe53721550dad714090d50a8c8efcb294..5a71ae519a7b001dbb42ed2594661da766e90296 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpSymbol.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpSymbol.h @@ -20,26 +20,11 @@ class UnboundedRegExpSymbol : public UnboundedRegExpElement { protected: alphabet::Symbol symbol; - /** - * @copydoc UnboundedRegExpElement::cloneAsFormal() const - */ - virtual FormalRegExpElement * cloneAsFormal ( ) const; - - /** - * @copydoc UnboundedRegExpElement::testSymbol() const - */ - virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; - /** * @copydoc UnboundedRegExpElement::attachRegExp() */ virtual bool attachRegExp ( const UnboundedRegExp * regexp ); - /** - * @copydoc UnboundedRegExpElement::computeMinimalAlphabet() - */ - virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; - public: void Accept ( void * userData, const UnboundedRegExpElementVisitor & visitor ) const { visitor.Visit ( userData, * this ); @@ -67,6 +52,21 @@ public: */ virtual UnboundedRegExpElement * plunder ( ) &&; + /** + * @copydoc UnboundedRegExpElement::cloneAsFormal() const + */ + virtual FormalRegExpElement * cloneAsFormal ( ) const; + + /** + * @copydoc UnboundedRegExpElement::testSymbol() const + */ + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; + + /** + * @copydoc UnboundedRegExpElement::computeMinimalAlphabet() + */ + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; + bool operator ==( const alphabet::Symbol & ) const; friend bool operator ==( const alphabet::Symbol &, const UnboundedRegExpSymbol & ); diff --git a/astat2/src/RegExpStat.cpp b/astat2/src/RegExpStat.cpp index bc102f3f791b543a12dcf860225b630f22ebdd29..f33b235855f2c3454d3480758b5dacbe4fcf83cb 100644 --- a/astat2/src/RegExpStat.cpp +++ b/astat2/src/RegExpStat.cpp @@ -28,7 +28,7 @@ void RegExpStat::stat ( const regexp::FormalRegExp & regexp, const RegExpSetting switch ( settings.nodes ) { case PrintingOptions::PRINT: - alib::XmlDataFactory::toStdout ( & regexp.getRegExp ( ) ); + alib::XmlDataFactory::toStdout ( regexp.getRegExp ( ) ); break; case PrintingOptions::SIZE: @@ -36,7 +36,7 @@ void RegExpStat::stat ( const regexp::FormalRegExp & regexp, const RegExpSetting break; case PrintingOptions::BOTH: - alib::XmlDataFactory::toStdout ( & regexp.getRegExp ( ) ); + alib::XmlDataFactory::toStdout ( regexp.getRegExp ( ) ); std::cout << countNodes ( regexp.getRegExp ( ) ) << std::endl; break; @@ -56,7 +56,7 @@ void RegExpStat::stat ( const regexp::UnboundedRegExp & regexp, const RegExpSett switch ( settings.nodes ) { case PrintingOptions::PRINT: - alib::XmlDataFactory::toStdout ( & regexp.getRegExp ( ) ); + alib::XmlDataFactory::toStdout ( regexp.getRegExp ( ) ); break; case PrintingOptions::SIZE: @@ -64,7 +64,7 @@ void RegExpStat::stat ( const regexp::UnboundedRegExp & regexp, const RegExpSett break; case PrintingOptions::BOTH: - alib::XmlDataFactory::toStdout ( & regexp.getRegExp ( ) ); + alib::XmlDataFactory::toStdout ( regexp.getRegExp ( ) ); std::cout << countNodes ( regexp.getRegExp ( ) ) << std::endl; break;