diff --git a/alib2data/src/alphabet/BarSymbol.h b/alib2data/src/alphabet/BarSymbol.h index 5b2b5a50211109794f6d27d4c288e32799cf7221..cc8dd94291ea1c416ccebbf48a7c3a6a348d7b26 100644 --- a/alib2data/src/alphabet/BarSymbol.h +++ b/alib2data/src/alphabet/BarSymbol.h @@ -56,6 +56,10 @@ public: void compose ( std::deque < sax::Token > & out ) const; virtual SymbolBase * inc ( ) &&; + + virtual SymbolBase * normalize ( ) && { + return this; + } }; template < typename Base > diff --git a/alib2data/src/alphabet/BlankSymbol.h b/alib2data/src/alphabet/BlankSymbol.h index 0d45eca1e82e8020ed579c07ef26a6064ffc16a2..5da1f16cef9543173309fe30f8bd3666b28619c6 100644 --- a/alib2data/src/alphabet/BlankSymbol.h +++ b/alib2data/src/alphabet/BlankSymbol.h @@ -56,6 +56,10 @@ public: void compose ( std::deque < sax::Token > & out ) const; virtual SymbolBase * inc ( ) &&; + + virtual SymbolBase * normalize ( ) && { + return this; + } }; template < typename Base > diff --git a/alib2data/src/alphabet/BottomOfTheStackSymbol.h b/alib2data/src/alphabet/BottomOfTheStackSymbol.h index 9bbef8270351a53d3769da2e360c33ab8687ab68..2846eb61ce34b8c6403bc66be623e06a8588d717 100644 --- a/alib2data/src/alphabet/BottomOfTheStackSymbol.h +++ b/alib2data/src/alphabet/BottomOfTheStackSymbol.h @@ -56,6 +56,10 @@ public: void compose ( std::deque < sax::Token > & out ) const; virtual SymbolBase * inc ( ) &&; + + virtual SymbolBase * normalize ( ) && { + return this; + } }; template < typename Base > diff --git a/alib2data/src/alphabet/EndSymbol.h b/alib2data/src/alphabet/EndSymbol.h index a5f9fca8f80edeef375badade339ec0ad9e9b0b6..b2d4968ab0e71e3e900809b2cec6f77fc0569540 100644 --- a/alib2data/src/alphabet/EndSymbol.h +++ b/alib2data/src/alphabet/EndSymbol.h @@ -56,6 +56,10 @@ public: void compose ( std::deque < sax::Token > & out ) const; virtual SymbolBase * inc ( ) &&; + + virtual SymbolBase * normalize ( ) && { + return this; + } }; template < typename Base > diff --git a/alib2data/src/alphabet/InitialSymbol.h b/alib2data/src/alphabet/InitialSymbol.h index c619b99ad1ba983bd612bb55629c9af0cb0dc2ac..937d4be94f4106e86b7f6873ae067f545deb0a29 100644 --- a/alib2data/src/alphabet/InitialSymbol.h +++ b/alib2data/src/alphabet/InitialSymbol.h @@ -57,6 +57,10 @@ public: void compose ( std::deque < sax::Token > & out ) const; virtual SymbolBase * inc ( ) &&; + + virtual SymbolBase * normalize ( ) && { + return this; + } }; template < typename Base > diff --git a/alib2data/src/alphabet/LabeledSymbol.h b/alib2data/src/alphabet/LabeledSymbol.h index 0e209446bba67a34c706de52e47e5d88d356b501..11dbad4b0388287c9dfd3b18481f83c4d3bc65aa 100644 --- a/alib2data/src/alphabet/LabeledSymbol.h +++ b/alib2data/src/alphabet/LabeledSymbol.h @@ -64,6 +64,10 @@ public: void compose ( std::deque < sax::Token > & out ) const; virtual SymbolBase * inc ( ) &&; + + virtual SymbolBase * normalize ( ) && { + return this; + } }; } /* namespace alphabet */ diff --git a/alib2data/src/alphabet/NonlinearVariableSymbol.h b/alib2data/src/alphabet/NonlinearVariableSymbol.h index 288c01e75def7ae93c37a94ee5007e4cee592ab6..c48604641c0ef79d74d85ea2a705d1602a2c382a 100644 --- a/alib2data/src/alphabet/NonlinearVariableSymbol.h +++ b/alib2data/src/alphabet/NonlinearVariableSymbol.h @@ -14,6 +14,8 @@ #include "SymbolFeatures.h" #include "UniqueSymbol.h" +#include <object/AnyObject.h> + namespace alphabet { /** @@ -43,6 +45,11 @@ public: */ const SymbolType & getSymbol ( ) const; + /** + * @return name of the symbol + */ + SymbolType & getSymbol ( ); + virtual int compare ( const ObjectBase & other ) const { if ( std::type_index ( typeid ( * this ) ) == std::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); @@ -66,6 +73,10 @@ public: void compose ( std::deque < sax::Token > & out ) const; virtual SymbolBase * inc ( ) &&; + + virtual SymbolBase * normalize ( ) && { + return new NonlinearVariableSymbol < > ( DefaultSymbolType ( alib::AnyObject < SymbolType > ( std::move ( this->getSymbol ( ) ) ) ) ); + } }; template < class SymbolType > @@ -99,6 +110,11 @@ const SymbolType& NonlinearVariableSymbol < SymbolType >::getSymbol() const { return m_symbol; } +template < class SymbolType > +SymbolType & NonlinearVariableSymbol < SymbolType >::getSymbol() { + return m_symbol; +} + template < class SymbolType > int NonlinearVariableSymbol < SymbolType >::compare ( const NonlinearVariableSymbol & other ) const { static std::compare < decltype ( m_symbol ) > comp; diff --git a/alib2data/src/alphabet/RankedSymbol.h b/alib2data/src/alphabet/RankedSymbol.h index 9a527bb2ababa5cb47d6354ccc9b139447cda920..99073b4940f3a76e319d30ed4436a85d3d27fcde 100644 --- a/alib2data/src/alphabet/RankedSymbol.h +++ b/alib2data/src/alphabet/RankedSymbol.h @@ -15,6 +15,8 @@ #include "SymbolFeatures.h" #include "ranked_symbol.hpp" +#include <object/AnyObject.h> + namespace alphabet { /** @@ -63,6 +65,14 @@ public: static void compose ( std::deque < sax::Token > & out, const std::ranked_symbol < SymbolType, RankType > & input ); virtual SymbolBase * inc ( ) &&; + + std::ranked_symbol < DefaultSymbolType, DefaultRankType > normalizeRaw ( std::ranked_symbol < SymbolType, RankType > && source ) { + return std::ranked_symbol < DefaultSymbolType, DefaultRankType > ( DefaultSymbolType ( alib::AnyObject < SymbolType > ( std::move ( source.getSymbol ( ) ) ) ), DefaultRankType ( std::move ( source.getRank ( ) ) ) ); + } + + virtual SymbolBase * normalize ( ) && { + return new RankedSymbol < > ( normalizeRaw ( std::move ( *this ) ) ); + } }; template < class SymbolType, class RankType > diff --git a/alib2data/src/alphabet/StartSymbol.h b/alib2data/src/alphabet/StartSymbol.h index b3ab08c1304df457a869b7a16e4099a1a94b4d4b..44a830518e5d2e93dc4ee4bcc5f878a2475f1608 100644 --- a/alib2data/src/alphabet/StartSymbol.h +++ b/alib2data/src/alphabet/StartSymbol.h @@ -56,6 +56,10 @@ public: void compose ( std::deque < sax::Token > & out ) const; virtual SymbolBase * inc ( ) &&; + + virtual SymbolBase * normalize ( ) && { + return this; + } }; template < typename Base > diff --git a/alib2data/src/alphabet/SubtreeWildcardSymbol.h b/alib2data/src/alphabet/SubtreeWildcardSymbol.h index 6fcee7dadc73f5c334ef11e88f76af81e21c46fc..b7067cbeec3cf4ffffdd2ce316ff436f5957d3cd 100644 --- a/alib2data/src/alphabet/SubtreeWildcardSymbol.h +++ b/alib2data/src/alphabet/SubtreeWildcardSymbol.h @@ -57,6 +57,10 @@ public: void compose ( std::deque < sax::Token > & out ) const; virtual SymbolBase * inc ( ) &&; + + virtual SymbolBase * normalize ( ) && { + return this; + } }; template < typename Base > diff --git a/alib2data/src/alphabet/UniqueSymbol.h b/alib2data/src/alphabet/UniqueSymbol.h index fbd2ee13fd52247aa8a0bc5b9a72bf49878f6ae0..7570222bfe3e0d197381b5bfd696d620df08f1b7 100644 --- a/alib2data/src/alphabet/UniqueSymbol.h +++ b/alib2data/src/alphabet/UniqueSymbol.h @@ -64,6 +64,10 @@ public: void compose ( std::deque < sax::Token > & out ) const; virtual SymbolBase * inc ( ) &&; + + virtual SymbolBase * normalize ( ) && { + return this; + } }; } /* namespace alphabet */ diff --git a/alib2data/src/alphabet/VariablesBarSymbol.h b/alib2data/src/alphabet/VariablesBarSymbol.h index 78c82b8625305787e759cd66ef610e71964a5a34..a2f530cd84bdea11afbe20dd8e856426d7f06006 100644 --- a/alib2data/src/alphabet/VariablesBarSymbol.h +++ b/alib2data/src/alphabet/VariablesBarSymbol.h @@ -57,6 +57,10 @@ public: void compose ( std::deque < sax::Token > & out ) const; virtual SymbolBase * inc ( ) &&; + + virtual SymbolBase * normalize ( ) && { + return this; + } }; template < typename Base > diff --git a/alib2data/src/alphabet/ranked_symbol.hpp b/alib2data/src/alphabet/ranked_symbol.hpp index 5f8f2ebff73613f2429fd9c07f373be79f709279..1df0fe23aa98e2518cb07c024ad980d88ea0a973 100644 --- a/alib2data/src/alphabet/ranked_symbol.hpp +++ b/alib2data/src/alphabet/ranked_symbol.hpp @@ -41,11 +41,21 @@ public: */ const SymbolType & getSymbol ( ) const; + /** + * @return name of the symbol + */ + SymbolType & getSymbol ( ); + /** * @return rank of the symbol */ const RankType & getRank ( ) const; + /** + * @return rank of the symbol + */ + RankType & getRank ( ); + int compare ( const ranked_symbol & other ) const; explicit operator std::string ( ) const; @@ -105,11 +115,21 @@ const SymbolType& ranked_symbol < SymbolType, RankType >::getSymbol() const { return m_symbol; } +template < class SymbolType, class RankType > +SymbolType& ranked_symbol < SymbolType, RankType >::getSymbol() { + return m_symbol; +} + template < class SymbolType, class RankType > const RankType& ranked_symbol < SymbolType, RankType >::getRank() const { return m_rank; } +template < class SymbolType, class RankType > +RankType& ranked_symbol < SymbolType, RankType >::getRank() { + return m_rank; +} + template < class SymbolType, class RankType > int ranked_symbol < SymbolType, RankType >::compare(const ranked_symbol& other) const { auto first = std::tie ( m_symbol, m_rank );