From caf45a77d00625c30944353b3741c756d0945f73 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Tue, 28 May 2019 10:36:45 +0200 Subject: [PATCH] make declaration definition naming match in FormalRegExp optimisation --- .../simplify/RegExpOptimizeFormalPart.hpp | 244 +++++++++--------- 1 file changed, 122 insertions(+), 122 deletions(-) diff --git a/alib2algo/src/regexp/simplify/RegExpOptimizeFormalPart.hpp b/alib2algo/src/regexp/simplify/RegExpOptimizeFormalPart.hpp index 5ea51c736b..70f1a90221 100644 --- a/alib2algo/src/regexp/simplify/RegExpOptimizeFormalPart.hpp +++ b/alib2algo/src/regexp/simplify/RegExpOptimizeFormalPart.hpp @@ -120,17 +120,17 @@ bool RegExpOptimize::S( FormalRegExpElement < SymbolType > * & node ) { * @return bool true if optimization applied else false */ template < class SymbolType > -bool RegExpOptimize::A1( FormalRegExpElement < SymbolType > * & n ) { - FormalRegExpAlternation < SymbolType > * node = dynamic_cast<FormalRegExpAlternation < SymbolType > *>( n ); - if( ! node ) return false; +bool RegExpOptimize::A1( FormalRegExpElement < SymbolType > * & node ) { + FormalRegExpAlternation < SymbolType > * n = dynamic_cast<FormalRegExpAlternation < SymbolType > *>( node ); + if( ! n ) return false; - if( dynamic_cast < FormalRegExpAlternation < SymbolType > * > ( & node->getLeft ( ) ) ) { - FormalRegExpAlternation < SymbolType > leftAlt ( std::move ( static_cast < FormalRegExpAlternation < SymbolType > & > ( node->getLeft ( ) ) ) ); + if( dynamic_cast < FormalRegExpAlternation < SymbolType > * > ( & n->getLeft ( ) ) ) { + FormalRegExpAlternation < SymbolType > leftAlt ( std::move ( static_cast < FormalRegExpAlternation < SymbolType > & > ( n->getLeft ( ) ) ) ); - node->setLeft ( std::move ( leftAlt.getLeft ( ) ) ); + n->setLeft ( std::move ( leftAlt.getLeft ( ) ) ); leftAlt.setLeft ( std::move ( leftAlt.getRight ( ) ) ); - leftAlt.setRight ( std::move ( node->getRight ( ) ) ); - node->setRight ( std::move ( leftAlt ) ); + leftAlt.setRight ( std::move ( n->getRight ( ) ) ); + n->setRight ( std::move ( leftAlt ) ); return true; } @@ -144,17 +144,17 @@ bool RegExpOptimize::A1( FormalRegExpElement < SymbolType > * & n ) { * @return bool true if optimization applied else false */ template < class SymbolType > -bool RegExpOptimize::A2 ( FormalRegExpElement < SymbolType > * & n ) { - FormalRegExpAlternation < SymbolType > * node = dynamic_cast<FormalRegExpAlternation < SymbolType > *>( n ); - if( ! node ) return false; +bool RegExpOptimize::A2 ( FormalRegExpElement < SymbolType > * & node ) { + FormalRegExpAlternation < SymbolType > * n = dynamic_cast<FormalRegExpAlternation < SymbolType > *>( node ); + if( ! n ) return false; - if ( dynamic_cast < FormalRegExpAlternation < SymbolType > * > ( & node->getRight ( ) ) ) { - FormalRegExpAlternation < SymbolType > & rightAlt = static_cast < FormalRegExpAlternation < SymbolType > & > ( node->getRight ( ) ); + if ( dynamic_cast < FormalRegExpAlternation < SymbolType > * > ( & n->getRight ( ) ) ) { + FormalRegExpAlternation < SymbolType > & rightAlt = static_cast < FormalRegExpAlternation < SymbolType > & > ( n->getRight ( ) ); - if ( node->getLeft ( ) > rightAlt.getLeft ( ) ) { - ext::ptr_value < FormalRegExpElement < SymbolType > > tmp ( std::move ( node->getLeft ( ) ) ); + if ( n->getLeft ( ) > rightAlt.getLeft ( ) ) { + ext::ptr_value < FormalRegExpElement < SymbolType > > tmp ( std::move ( n->getLeft ( ) ) ); - node->setLeft ( std::move ( rightAlt.getLeft ( ) ) ); + n->setLeft ( std::move ( rightAlt.getLeft ( ) ) ); rightAlt.setLeft ( std::move ( tmp ) ); return true; } else { @@ -171,21 +171,21 @@ bool RegExpOptimize::A2 ( FormalRegExpElement < SymbolType > * & n ) { * @return bool true if optimization applied else false */ template < class SymbolType > -bool RegExpOptimize::A3 ( FormalRegExpElement < SymbolType > * & n ) { - FormalRegExpAlternation < SymbolType > * node = dynamic_cast < FormalRegExpAlternation < SymbolType > * > ( n ); - if( ! node ) return false; +bool RegExpOptimize::A3 ( FormalRegExpElement < SymbolType > * & node ) { + FormalRegExpAlternation < SymbolType > * n = dynamic_cast < FormalRegExpAlternation < SymbolType > * > ( node ); + if( ! n ) return false; // input can be \0 + \0, so at least one element must be preserved - if ( dynamic_cast < FormalRegExpEmpty < SymbolType > * > ( & node->getRight ( ) ) ) { - n = std::move ( node->getLeft ( ) ).clone ( ); - delete node; + if ( dynamic_cast < FormalRegExpEmpty < SymbolType > * > ( & n->getRight ( ) ) ) { + node = std::move ( n->getLeft ( ) ).clone ( ); + delete n; return true; } - if ( dynamic_cast < FormalRegExpEmpty < SymbolType > * > ( & node->getLeft ( ) ) ) { - n = std::move ( node->getRight ( ) ).clone ( ); - delete node; + if ( dynamic_cast < FormalRegExpEmpty < SymbolType > * > ( & n->getLeft ( ) ) ) { + node = std::move ( n->getRight ( ) ).clone ( ); + delete n; return true; } @@ -198,7 +198,7 @@ bool RegExpOptimize::A3 ( FormalRegExpElement < SymbolType > * & n ) { * @return bool true if optimization applied else false */ template < class SymbolType > -bool RegExpOptimize::A4( FormalRegExpElement < SymbolType > * & n ) { +bool RegExpOptimize::A4( FormalRegExpElement < SymbolType > * & node ) { /* * two ways of implementing this opitimization: * - sort and call std::unique ( O(n lg n) + O(n) ), but it also sorts... @@ -207,11 +207,11 @@ bool RegExpOptimize::A4( FormalRegExpElement < SymbolType > * & n ) { * As we always sort in optimization, we can use the first version, but A4 must be __always__ called __after__ A2 */ - FormalRegExpAlternation < SymbolType > * node = dynamic_cast < FormalRegExpAlternation < SymbolType > * > ( n ); - if ( ! node ) return false; + FormalRegExpAlternation < SymbolType > * n = dynamic_cast < FormalRegExpAlternation < SymbolType > * > ( node ); + if ( ! n ) return false; - if ( node->getLeftElement() == node->getRightElement() ) { - n = std::move ( node->getRight ( ) ).clone ( ); + if ( n->getLeftElement() == n->getRightElement() ) { + node = std::move ( n->getRight ( ) ).clone ( ); delete node; return true; } @@ -225,17 +225,17 @@ bool RegExpOptimize::A4( FormalRegExpElement < SymbolType > * & n ) { * @return bool true if optimization applied else false */ template < class SymbolType > -bool RegExpOptimize::A5( FormalRegExpElement < SymbolType > * & n ) { - FormalRegExpConcatenation < SymbolType > * node = dynamic_cast<FormalRegExpConcatenation < SymbolType > *>( n ); +bool RegExpOptimize::A5( FormalRegExpElement < SymbolType > * & node ) { + FormalRegExpConcatenation < SymbolType > * n = dynamic_cast<FormalRegExpConcatenation < SymbolType > *>( node ); if( ! node ) return false; - if( dynamic_cast < FormalRegExpConcatenation < SymbolType > * > ( & node->getLeft ( ) ) ) { - FormalRegExpConcatenation < SymbolType > leftCon ( std::move ( static_cast < FormalRegExpConcatenation < SymbolType > & > ( node->getLeft ( ) ) ) ); + if( dynamic_cast < FormalRegExpConcatenation < SymbolType > * > ( & n->getLeft ( ) ) ) { + FormalRegExpConcatenation < SymbolType > leftCon ( std::move ( static_cast < FormalRegExpConcatenation < SymbolType > & > ( n->getLeft ( ) ) ) ); - node->setLeft ( std::move ( leftCon.getLeft ( ) ) ); + n->setLeft ( std::move ( leftCon.getLeft ( ) ) ); leftCon.setLeft ( std::move ( leftCon.getRight ( ) ) ); - leftCon.setRight ( std::move ( node->getRight ( ) ) ); - node->setRight ( std::move ( leftCon ) ); + leftCon.setRight ( std::move ( n->getRight ( ) ) ); + n->setRight ( std::move ( leftCon ) ); return true; } @@ -249,20 +249,20 @@ bool RegExpOptimize::A5( FormalRegExpElement < SymbolType > * & n ) { * @return bool true if optimization applied else false */ template < class SymbolType > -bool RegExpOptimize::A6( FormalRegExpElement < SymbolType > * & n ) { - FormalRegExpConcatenation < SymbolType > * node = dynamic_cast<FormalRegExpConcatenation < SymbolType > *>( n ); - if( ! node ) return false; +bool RegExpOptimize::A6( FormalRegExpElement < SymbolType > * & node ) { + FormalRegExpConcatenation < SymbolType > * n = dynamic_cast<FormalRegExpConcatenation < SymbolType > *>( node ); + if( ! n ) return false; // input can be \e + \e, so at least one element must be preserved - if ( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( & node->getRight ( ) ) ) { - n = std::move ( node->getLeft ( ) ).clone ( ); + if ( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( & n->getRight ( ) ) ) { + node = std::move ( n->getLeft ( ) ).clone ( ); delete node; return true; } - if ( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( & node->getLeft ( ) ) ) { - n = std::move ( node->getRight ( ) ).clone ( ); + if ( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( & n->getLeft ( ) ) ) { + node = std::move ( n->getRight ( ) ).clone ( ); delete node; return true; } @@ -276,13 +276,13 @@ bool RegExpOptimize::A6( FormalRegExpElement < SymbolType > * & n ) { * @return bool true if optimization applied else false */ template < class SymbolType > -bool RegExpOptimize::A7( FormalRegExpElement < SymbolType > * & n ) { - FormalRegExpConcatenation < SymbolType > * node = dynamic_cast<FormalRegExpConcatenation < SymbolType > *>( n ); - if( ! node ) return false; +bool RegExpOptimize::A7( FormalRegExpElement < SymbolType > * & node ) { + FormalRegExpConcatenation < SymbolType > * n = dynamic_cast<FormalRegExpConcatenation < SymbolType > *>( node ); + if( ! n ) return false; - if ( dynamic_cast < FormalRegExpEmpty < SymbolType > * > ( & node->getRight ( ) ) || dynamic_cast < FormalRegExpEmpty < SymbolType > * > ( & node->getLeft ( ) ) ) { - delete node; - n = new FormalRegExpEmpty < SymbolType > { }; + if ( dynamic_cast < FormalRegExpEmpty < SymbolType > * > ( & n->getRight ( ) ) || dynamic_cast < FormalRegExpEmpty < SymbolType > * > ( & n->getLeft ( ) ) ) { + delete n; + node = new FormalRegExpEmpty < SymbolType > { }; return true; } @@ -295,7 +295,7 @@ bool RegExpOptimize::A7( FormalRegExpElement < SymbolType > * & n ) { * @return bool true if optimization applied else false */ template < class SymbolType > -bool RegExpOptimize::A8( FormalRegExpElement < SymbolType > * & /* n */) { +bool RegExpOptimize::A8( FormalRegExpElement < SymbolType > * & /* node */) { return false; //TODO } @@ -305,7 +305,7 @@ bool RegExpOptimize::A8( FormalRegExpElement < SymbolType > * & /* n */) { * @return bool true if optimization applied else false */ template < class SymbolType > -bool RegExpOptimize::A9( FormalRegExpElement < SymbolType > * & /* n */) { +bool RegExpOptimize::A9( FormalRegExpElement < SymbolType > * & /* node */) { return false; //TODO } @@ -315,25 +315,25 @@ bool RegExpOptimize::A9( FormalRegExpElement < SymbolType > * & /* n */) { * @return bool true if optimization applied else false */ template < class SymbolType > -bool RegExpOptimize::A10( FormalRegExpElement < SymbolType > * & n ) { +bool RegExpOptimize::A10( FormalRegExpElement < SymbolType > * & node ) { /* * problem: * - \e + x*x = x* * - but if we do not have the eps, but we do have iteration, then \e \in h(iter), therefore \e in h(node). */ - FormalRegExpAlternation < SymbolType > * node = dynamic_cast<FormalRegExpAlternation < SymbolType > * > ( n ); - if ( ! node ) return false; + FormalRegExpAlternation < SymbolType > * n = dynamic_cast<FormalRegExpAlternation < SymbolType > * > ( node ); + if ( ! n ) return false; - if ( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( & node->getLeft ( ) ) ) { - FormalRegExpConcatenation < SymbolType > * rightCon = dynamic_cast < FormalRegExpConcatenation < SymbolType > * > ( & node->getRight ( ) ); + if ( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( & n->getLeft ( ) ) ) { + FormalRegExpConcatenation < SymbolType > * rightCon = dynamic_cast < FormalRegExpConcatenation < SymbolType > * > ( & n->getRight ( ) ); if ( ! rightCon ) return false; FormalRegExpIteration < SymbolType > * rightLeftIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & rightCon->getLeft ( ) ); if ( rightLeftIte ) { if ( rightLeftIte->getElement ( ) == rightCon->getRightElement ( ) ) { - n = std::move ( rightCon->getLeft ( ) ).clone ( ); - delete node; + node = std::move ( rightCon->getLeft ( ) ).clone ( ); + delete n; return true; } } @@ -341,22 +341,22 @@ bool RegExpOptimize::A10( FormalRegExpElement < SymbolType > * & n ) { FormalRegExpIteration < SymbolType > * rightRightIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & rightCon->getRight ( ) ); if ( rightRightIte ) { if ( rightRightIte->getElement ( ) == rightCon->getLeftElement ( ) ) { - n = std::move ( rightCon->getRight ( ) ).clone ( ); - delete node; + node = std::move ( rightCon->getRight ( ) ).clone ( ); + delete n; return true; } } } - if ( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( & node->getRight ( ) ) ) { - FormalRegExpConcatenation < SymbolType > * leftCon = dynamic_cast < FormalRegExpConcatenation < SymbolType > * > ( & node->getLeft ( ) ); + if ( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( & n->getRight ( ) ) ) { + FormalRegExpConcatenation < SymbolType > * leftCon = dynamic_cast < FormalRegExpConcatenation < SymbolType > * > ( & n->getLeft ( ) ); if ( ! leftCon ) return false; FormalRegExpIteration < SymbolType > * leftLeftIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & leftCon->getLeft ( ) ); if ( leftLeftIte ) { if ( leftLeftIte->getElement ( ) == leftCon->getRightElement ( ) ) { - n = std::move ( leftCon->getLeft ( ) ).clone ( ); - delete node; + node = std::move ( leftCon->getLeft ( ) ).clone ( ); + delete n; return true; } } @@ -364,8 +364,8 @@ bool RegExpOptimize::A10( FormalRegExpElement < SymbolType > * & n ) { FormalRegExpIteration < SymbolType > * leftRightIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & leftCon->getRight ( ) ); if ( leftRightIte ) { if ( leftRightIte->getElement ( ) == leftCon->getLeftElement ( ) ) { - n = std::move ( leftCon->getRight ( ) ).clone ( ); - delete node; + node = std::move ( leftCon->getRight ( ) ).clone ( ); + delete n; return true; } } @@ -380,18 +380,18 @@ bool RegExpOptimize::A10( FormalRegExpElement < SymbolType > * & n ) { * @return bool true if optimization applied else false */ template < class SymbolType > -bool RegExpOptimize::A11( FormalRegExpElement < SymbolType > * & n ) { - FormalRegExpIteration < SymbolType > * node = dynamic_cast<FormalRegExpIteration < SymbolType > *>( n ); - if( ! node ) return false; +bool RegExpOptimize::A11( FormalRegExpElement < SymbolType > * & node ) { + FormalRegExpIteration < SymbolType > * n = dynamic_cast<FormalRegExpIteration < SymbolType > *>( node ); + if( ! n ) return false; - FormalRegExpAlternation < SymbolType > * childAlt = dynamic_cast < FormalRegExpAlternation < SymbolType > * > ( & node->getChild ( ) ); + FormalRegExpAlternation < SymbolType > * childAlt = dynamic_cast < FormalRegExpAlternation < SymbolType > * > ( & n->getChild ( ) ); if ( childAlt ) { if ( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( & childAlt->getLeft ( ) ) ) { - node->setChild ( std::move ( childAlt->getRight ( ) ) ); + n->setChild ( std::move ( childAlt->getRight ( ) ) ); return true; } if ( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( & childAlt->getRight ( ) ) ) { - node->setChild ( std::move ( childAlt->getLeft ( ) ) ); + n->setChild ( std::move ( childAlt->getLeft ( ) ) ); return true; } } @@ -406,18 +406,18 @@ bool RegExpOptimize::A11( FormalRegExpElement < SymbolType > * & n ) { * @return bool true if optimization applied else false */ template < class SymbolType > -bool RegExpOptimize::V1( FormalRegExpElement < SymbolType > * & n ) { - FormalRegExpIteration < SymbolType > * node = dynamic_cast<FormalRegExpIteration < SymbolType > *>( n ); - if( ! node ) return false; +bool RegExpOptimize::V1( FormalRegExpElement < SymbolType > * & node ) { + FormalRegExpIteration < SymbolType > * n = dynamic_cast<FormalRegExpIteration < SymbolType > *>( node ); + if( ! n ) return false; - if ( dynamic_cast < FormalRegExpEmpty < SymbolType > * > ( & node->getChild ( ) ) ) { - delete node; - n = new FormalRegExpEpsilon < SymbolType > ( ); + if ( dynamic_cast < FormalRegExpEmpty < SymbolType > * > ( & n->getChild ( ) ) ) { + delete n; + node = new FormalRegExpEpsilon < SymbolType > ( ); return true; } - if ( dynamic_cast<FormalRegExpEpsilon < SymbolType > * > ( & node->getChild ( ) ) ) { - delete node; - n = new FormalRegExpEpsilon < SymbolType > ( ); + if ( dynamic_cast<FormalRegExpEpsilon < SymbolType > * > ( & n->getChild ( ) ) ) { + delete n; + node = new FormalRegExpEpsilon < SymbolType > ( ); return true; } return false; @@ -429,24 +429,24 @@ bool RegExpOptimize::V1( FormalRegExpElement < SymbolType > * & n ) { * @return bool true if optimization applied else false */ template < class SymbolType > -bool RegExpOptimize::V2( FormalRegExpElement < SymbolType > * & n ) { - FormalRegExpAlternation < SymbolType > * node = dynamic_cast<FormalRegExpAlternation < SymbolType > *>( n ); - if( ! node ) return false; +bool RegExpOptimize::V2( FormalRegExpElement < SymbolType > * & node ) { + FormalRegExpAlternation < SymbolType > * n = dynamic_cast<FormalRegExpAlternation < SymbolType > *>( node ); + if( ! n ) return false; - FormalRegExpIteration < SymbolType > * leftIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & node->getLeft ( ) ); + FormalRegExpIteration < SymbolType > * leftIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & n->getLeft ( ) ); if ( leftIte ) { - if ( leftIte->getElement ( ) == node->getRightElement ( ) ) { - n = std::move ( node->getLeft ( ) ).clone ( ); - delete node; + if ( leftIte->getElement ( ) == n->getRightElement ( ) ) { + node = std::move ( n->getLeft ( ) ).clone ( ); + delete n; return true; } } - FormalRegExpIteration < SymbolType > * rightIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & node->getRight ( ) ); + FormalRegExpIteration < SymbolType > * rightIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & n->getRight ( ) ); if ( rightIte ) { - if ( rightIte->getElement ( ) == node->getLeftElement ( ) ) { - n = std::move ( node->getRight ( ) ).clone ( ); - delete node; + if ( rightIte->getElement ( ) == n->getLeftElement ( ) ) { + node = std::move ( n->getRight ( ) ).clone ( ); + delete n; return true; } } @@ -460,13 +460,13 @@ bool RegExpOptimize::V2( FormalRegExpElement < SymbolType > * & n ) { * @return bool true if optimization applied else false */ template < class SymbolType > -bool RegExpOptimize::V3( FormalRegExpElement < SymbolType > * & n ) { - FormalRegExpIteration < SymbolType > * node = dynamic_cast<FormalRegExpIteration < SymbolType > *>( n ); - if( ! node ) return false; +bool RegExpOptimize::V3( FormalRegExpElement < SymbolType > * & node ) { + FormalRegExpIteration < SymbolType > * n = dynamic_cast<FormalRegExpIteration < SymbolType > *>( node ); + if( ! n ) return false; - FormalRegExpIteration < SymbolType > * childIter = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & node->getChild ( ) ); + FormalRegExpIteration < SymbolType > * childIter = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & n->getChild ( ) ); if( childIter ) { - node->setChild ( std::move ( childIter->getChild ( ) ) ); + n->setChild ( std::move ( childIter->getChild ( ) ) ); return true; } @@ -479,11 +479,11 @@ bool RegExpOptimize::V3( FormalRegExpElement < SymbolType > * & n ) { * @return bool true if optimization applied else false */ template < class SymbolType > -bool RegExpOptimize::V4( FormalRegExpElement < SymbolType > * & n ) { - FormalRegExpIteration < SymbolType > * node = dynamic_cast < FormalRegExpIteration < SymbolType > *>( n ); - if( ! node ) return false; +bool RegExpOptimize::V4( FormalRegExpElement < SymbolType > * & node ) { + FormalRegExpIteration < SymbolType > * n = dynamic_cast < FormalRegExpIteration < SymbolType > *>( node ); + if( ! n ) return false; - FormalRegExpConcatenation < SymbolType > * child = dynamic_cast < FormalRegExpConcatenation < SymbolType > * > ( & node->getChild ( ) ); + FormalRegExpConcatenation < SymbolType > * child = dynamic_cast < FormalRegExpConcatenation < SymbolType > * > ( & n->getChild ( ) ); if( ! child ) return false; FormalRegExpIteration < SymbolType > * leftIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & child->getLeft ( ) ); @@ -492,7 +492,7 @@ bool RegExpOptimize::V4( FormalRegExpElement < SymbolType > * & n ) { FormalRegExpIteration < SymbolType > * rightIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & child->getRight ( ) ); if( ! rightIte ) return false; - node->setChild ( FormalRegExpAlternation < SymbolType >( std::move ( leftIte->getElement ( ) ), std::move ( rightIte->getElement ( ) ) ) ); + n->setChild ( FormalRegExpAlternation < SymbolType >( std::move ( leftIte->getElement ( ) ), std::move ( rightIte->getElement ( ) ) ) ); return true; } @@ -503,7 +503,7 @@ bool RegExpOptimize::V4( FormalRegExpElement < SymbolType > * & n ) { * @return bool true if optimization applied else false */ template < class SymbolType > -bool RegExpOptimize::V5( FormalRegExpElement < SymbolType > * & /* n */) { +bool RegExpOptimize::V5( FormalRegExpElement < SymbolType > * & /* node */) { return false; //TODO } @@ -513,7 +513,7 @@ bool RegExpOptimize::V5( FormalRegExpElement < SymbolType > * & /* n */) { * @return bool true if optimization applied else false */ template < class SymbolType > -bool RegExpOptimize::V6( FormalRegExpElement < SymbolType > * & /* n */) { +bool RegExpOptimize::V6( FormalRegExpElement < SymbolType > * & /* node */) { return false; //TODO } @@ -523,7 +523,7 @@ bool RegExpOptimize::V6( FormalRegExpElement < SymbolType > * & /* n */) { * @return bool true if optimization applied else false */ template < class SymbolType > -bool RegExpOptimize::V8( FormalRegExpElement < SymbolType > * & /* n */) { +bool RegExpOptimize::V8( FormalRegExpElement < SymbolType > * & /* node */) { return false; //TODO } @@ -533,7 +533,7 @@ bool RegExpOptimize::V8( FormalRegExpElement < SymbolType > * & /* n */) { * @return bool true if optimization applied else false */ template < class SymbolType > -bool RegExpOptimize::V9( FormalRegExpElement < SymbolType > * & /* n */) { +bool RegExpOptimize::V9( FormalRegExpElement < SymbolType > * & /* node */) { return false; //TODO } @@ -543,11 +543,11 @@ bool RegExpOptimize::V9( FormalRegExpElement < SymbolType > * & /* n */) { * @return bool true if optimization applied else false */ template < class SymbolType > -bool RegExpOptimize::V10( FormalRegExpElement < SymbolType > * & n ) { - FormalRegExpIteration < SymbolType > * node = dynamic_cast < FormalRegExpIteration < SymbolType > *>( n ); - if( ! node ) return false; +bool RegExpOptimize::V10( FormalRegExpElement < SymbolType > * & node ) { + FormalRegExpIteration < SymbolType > * n = dynamic_cast < FormalRegExpIteration < SymbolType > *>( node ); + if( ! n ) return false; - FormalRegExpAlternation < SymbolType > * alt = dynamic_cast < FormalRegExpAlternation < SymbolType > * > ( & node->getChild ( ) ); + FormalRegExpAlternation < SymbolType > * alt = dynamic_cast < FormalRegExpAlternation < SymbolType > * > ( & n->getChild ( ) ); if( ! alt ) return false; FormalRegExpIteration < SymbolType > * leftIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & alt->getLeft ( ) ); @@ -568,24 +568,24 @@ bool RegExpOptimize::V10( FormalRegExpElement < SymbolType > * & n ) { * @return bool true if optimization applied else false */ template < class SymbolType > -bool RegExpOptimize::X1( FormalRegExpElement < SymbolType > * & n ) { - FormalRegExpAlternation < SymbolType > * node = dynamic_cast<FormalRegExpAlternation < SymbolType > *>( n ); - if( ! node ) return false; +bool RegExpOptimize::X1( FormalRegExpElement < SymbolType > * & node ) { + FormalRegExpAlternation < SymbolType > * n = dynamic_cast<FormalRegExpAlternation < SymbolType > *>( node ); + if( ! n ) return false; - FormalRegExpIteration < SymbolType > * leftIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & node->getLeft ( ) ); + FormalRegExpIteration < SymbolType > * leftIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & n->getLeft ( ) ); if ( leftIte ) { - if ( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( & node->getRight ( ) ) ) { - n = std::move ( node->getLeft ( ) ).clone ( ); - delete node; + if ( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( & n->getRight ( ) ) ) { + node = std::move ( n->getLeft ( ) ).clone ( ); + delete n; return true; } } - FormalRegExpIteration < SymbolType > * rightIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & node->getRight ( ) ); + FormalRegExpIteration < SymbolType > * rightIte = dynamic_cast < FormalRegExpIteration < SymbolType > * > ( & n->getRight ( ) ); if ( rightIte ) { - if ( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( & node->getLeft ( ) ) ) { - n = std::move ( node->getRight ( ) ).clone ( ); - delete node; + if ( dynamic_cast < FormalRegExpEpsilon < SymbolType > * > ( & n->getLeft ( ) ) ) { + node = std::move ( n->getRight ( ) ).clone ( ); + delete n; return true; } } -- GitLab