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

allow another regexp optimization rule

parent 69893f61
No related branches found
No related tags found
No related merge requests found
...@@ -441,7 +441,7 @@ bool RegExpOptimize::Unbounded < SymbolType >::V1( UnboundedRegExpIteration < Sy ...@@ -441,7 +441,7 @@ bool RegExpOptimize::Unbounded < SymbolType >::V1( UnboundedRegExpIteration < Sy
* @return bool true if optimization applied else false * @return bool true if optimization applied else false
*/ */
template < class SymbolType > template < class SymbolType >
bool RegExpOptimize::Unbounded < SymbolType >::V2( UnboundedRegExpAlternation < SymbolType > & /* node */ ) { bool RegExpOptimize::Unbounded < SymbolType >::V2( UnboundedRegExpAlternation < SymbolType > & node ) {
bool optimized = false; bool optimized = false;
   
/* /*
...@@ -449,7 +449,7 @@ bool RegExpOptimize::Unbounded < SymbolType >::V2( UnboundedRegExpAlternation < ...@@ -449,7 +449,7 @@ bool RegExpOptimize::Unbounded < SymbolType >::V2( UnboundedRegExpAlternation <
* We need also to cover the cases like ( a + b + d )* + ( e )* + a + b + c + e = ( a + b + d )* + ( e )* + c * We need also to cover the cases like ( a + b + d )* + ( e )* + a + b + c + e = ( a + b + d )* + ( e )* + c
*/ */
   
/*ext::vector < const UnboundedRegExpElement < SymbolType > * > iterElements; ext::vector < const UnboundedRegExpElement < SymbolType > * > iterElements;
// cache iter elements because of operator invalidation after erase // cache iter elements because of operator invalidation after erase
for( const UnboundedRegExpElement < SymbolType > & n : node.getElements ( ) ) { for( const UnboundedRegExpElement < SymbolType > & n : node.getElements ( ) ) {
const UnboundedRegExpIteration < SymbolType > * iter = dynamic_cast < const UnboundedRegExpIteration < SymbolType > * > ( & n ); const UnboundedRegExpIteration < SymbolType > * iter = dynamic_cast < const UnboundedRegExpIteration < SymbolType > * > ( & n );
...@@ -469,13 +469,13 @@ bool RegExpOptimize::Unbounded < SymbolType >::V2( UnboundedRegExpAlternation < ...@@ -469,13 +469,13 @@ bool RegExpOptimize::Unbounded < SymbolType >::V2( UnboundedRegExpAlternation <
return a == *n; return a == *n;
}); });
   
if( it == node.getChildren().end() ) { if( it == node.getChildren ( ).end ( ) ) {
continue; continue;
} }
   
optimized = true; optimized = true;
node.getChildren ( ).erase( it ); node.erase( it );
}*/ }
   
return optimized; return optimized;
} }
......
...@@ -20,7 +20,8 @@ TEST_CASE ( "RegExp Optimize", "[unit][algo][regexp][simplify]" ) { ...@@ -20,7 +20,8 @@ TEST_CASE ( "RegExp Optimize", "[unit][algo][regexp][simplify]" ) {
std::make_pair ( "(a*b*)*", "(a+b)*" ), std::make_pair ( "(a*b*)*", "(a+b)*" ),
std::make_pair ( "#0*+a*", "a*" ), std::make_pair ( "#0*+a*", "a*" ),
std::make_pair ( "a+(a+a)", "a" ), std::make_pair ( "a+(a+a)", "a" ),
std::make_pair ( "(a+b*)(a+b*)*", "(a+b)*" ) // implemented but skipped because ( a + b* )* gets simplified to ( a + b )* FIXME std::make_pair ( "(a+b*)(a+b*)*", "(a+b)*" ),
std::make_pair ( "(a+b+d)*+e*+a+b+c+e", "c+e*+(a+b+d)*" )
// std::make_pair ( "(x y)*x", "x(y x)*" ), // std::make_pair ( "(x y)*x", "x(y x)*" ),
); );
   
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment