diff --git a/aconversions/src/re2fa/Brzozowski.cpp b/aconversions/src/re2fa/Brzozowski.cpp index f1fb9f587e6debcc3c0dcc809701eca02b378efd..42beed5d6e6743e27b1a36fa46a7cdd1c5dcd7c3 100644 --- a/aconversions/src/re2fa/Brzozowski.cpp +++ b/aconversions/src/re2fa/Brzozowski.cpp @@ -6,6 +6,7 @@ */ #include "Brzozowski.h" +#include <iostream> using namespace alib; using namespace automaton; @@ -68,10 +69,7 @@ FSM Brzozowski::convert( void ) } } - // FIXME sometimes crashes upon regexp comparsion - ?? issue #22 - // Q.insert( Qi.at( i ).begin( ), Qi.at( i ).end( ) ); - for( const auto & r : Qi.at( i ) ) - Q.insert( r ); + Q.insert( Qi.at( i ).begin( ), Qi.at( i ).end( ) ); i += 1; } @@ -129,11 +127,9 @@ Brzozowski::StateBuilder::StateBuilder( const set<RegExp> & Q ) const State & Brzozowski::StateBuilder::getState( const RegExp & re ) const { - // FIXME map::find() does not work! see gitlab issue #12 - for( const auto & kv : m_states ) - if( kv.first == re ) - return kv.second; - + auto state = m_states.find( re ); + if( state != m_states.end() ) return state->second; + throw AlibException( "Brzozowski::StateBuilder - Regular expression not found!" ); } diff --git a/alib/src/regexp/Alternation.cpp b/alib/src/regexp/Alternation.cpp index 180d2413f4e6058b7849209301ea624f7b3ddab9..aac9219f55ed47a13bc213dfcab3fb030db76925 100644 --- a/alib/src/regexp/Alternation.cpp +++ b/alib/src/regexp/Alternation.cpp @@ -80,10 +80,11 @@ bool Alternation::operator<(const Alternation& other) const { auto thisIter = this->elements.begin(); auto otherIter = other.elements.begin(); for(; thisIter != this->elements.end(); thisIter++, otherIter++) { - if(**thisIter < **otherIter) return true; + if(**thisIter != **otherIter) break; } + if(thisIter == this->elements.end()) return false; - return false; + return **thisIter < **otherIter; } bool Alternation::operator==(const Alternation& other) const { @@ -103,7 +104,7 @@ bool Alternation::containsEmptyString() const { if(e->containsEmptyString()) return true; - return false; + return false; // alternation of zero regexps is empty } bool Alternation::isEmpty() const { @@ -111,7 +112,7 @@ bool Alternation::isEmpty() const { if(!e->isEmpty()) return false; - return true; + return true; // alternation of zero regexps is empty } } /* namespace regexp */ diff --git a/alib/src/regexp/Concatenation.cpp b/alib/src/regexp/Concatenation.cpp index d06806fcf2ee4a33a5d6e7a8c7f2d22611c69e17..087f14074e913757b1e5df8eb53da2c03c3532b8 100644 --- a/alib/src/regexp/Concatenation.cpp +++ b/alib/src/regexp/Concatenation.cpp @@ -76,10 +76,11 @@ bool Concatenation::operator<(const Concatenation& other) const { auto thisIter = this->elements.begin(); auto otherIter = other.elements.begin(); for(; thisIter != this->elements.end(); thisIter++, otherIter++) { - if(**thisIter < **otherIter) return true; + if(**thisIter != **otherIter) break; } + if(thisIter == this->elements.end()) return false; - return false; + return **thisIter < **otherIter; } bool Concatenation::operator==(const Concatenation& other) const { @@ -99,7 +100,7 @@ bool Concatenation::containsEmptyString() const { if( ! e->containsEmptyString()) return false; - return true; + return true; // concatenation of zero regexps is epsilon } bool Concatenation::isEmpty() const { @@ -107,7 +108,7 @@ bool Concatenation::isEmpty() const { if(e->isEmpty()) return true; - return false; + return false; // concatenation of zero regexps is epsilon } } /* namespace regexp */