From ec05778d5718a7912e506764d443a78d6a6179e3 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 5 Nov 2012 22:41:51 +0000 Subject: Converted tabs to spaces with tabconv. --- src/experimental/regexengine.h | 260 ++++++++++++++++++++--------------------- 1 file changed, 130 insertions(+), 130 deletions(-) (limited to 'src/experimental/regexengine.h') diff --git a/src/experimental/regexengine.h b/src/experimental/regexengine.h index ec181c1..133d418 100644 --- a/src/experimental/regexengine.h +++ b/src/experimental/regexengine.h @@ -7,136 +7,136 @@ namespace Bu { - template class RegExEngine; - - template - class RegExEngineCore - { - friend class RegExEngine; - friend class SharedCore, RegExEngineCore >; - private: - RegExEngineCore() - { - } - - virtual ~RegExEngineCore() - { - } - - class Range - { - public: - Range( chr cLower, chr cUpper, int iTrgState ) : - cLower( cLower ), cUpper( cUpper ), iTrgState( iTrgState ) - { - } - - chr cLower; - chr cUpper; - int iTrgState; - }; - - class State - { - public: - Bu::Array aRange; - }; - - int addState() - { - aState.append( State() ); - return aState.getSize()-1; - } - - void addCompletion( int iState, chr cLower, chr cUpper, int iTrgState ) - { - aState[iState].aRange.append( Range( cLower, cUpper, iTrgState ) ); - } - - template - bool match( const str &sIn, int &iSize, int &iCompletion ) - { - bool bMatch; - int iState = 0; - iSize = 0; - for( typename str::const_iterator i = sIn.begin(); i; i++ ) - { - Bu::sio << "Finding char " << *i << " in state " << iState - << ":" << Bu::sio.nl; - bMatch = false; - for( typename Bu::Array::iterator j = - aState[iState].aRange.begin(); j; j++ ) - { - Bu::sio << " Testing range " << (*j).cLower << " - " << (*j).cUpper << Bu::sio.nl; - if( *i >= (*j).cLower && *i <= (*j).cUpper ) - { - iState = (*j).iTrgState; - bMatch = true; - iSize++; - if( iState < 0 ) - { - iCompletion = iState; - return true; - } - } - } - if( bMatch == false ) - { - return false; - } - } - - iCompletion = 0; - return true; - } - - typedef Bu::Array StateArray; - StateArray aState; - }; - - template - class RegExEngine : public SharedCore, - RegExEngineCore > - { - private: - typedef class RegExEngine MyType; - typedef class RegExEngineCore Core; - typedef class Core::Range Range; - typedef class Core::State State; - - protected: - using SharedCore::core; - using SharedCore::_hardCopy; - using SharedCore::_resetCore; - using SharedCore::_allocateCore; - - public: - RegExEngine() - { - } - - virtual ~RegExEngine() - { - } - - int addState() - { - return core->addState(); - } - - void addCompletion( int iState, chr cLower, chr cUpper, int iTrgState ) - { - core->addCompletion( iState, cLower, cUpper, iTrgState ); - } - - template - bool match( const str &sIn, int &iSize, int &iCompletion ) - { - return core->match( sIn, iSize, iCompletion ); - } - - private: - }; + template class RegExEngine; + + template + class RegExEngineCore + { + friend class RegExEngine; + friend class SharedCore, RegExEngineCore >; + private: + RegExEngineCore() + { + } + + virtual ~RegExEngineCore() + { + } + + class Range + { + public: + Range( chr cLower, chr cUpper, int iTrgState ) : + cLower( cLower ), cUpper( cUpper ), iTrgState( iTrgState ) + { + } + + chr cLower; + chr cUpper; + int iTrgState; + }; + + class State + { + public: + Bu::Array aRange; + }; + + int addState() + { + aState.append( State() ); + return aState.getSize()-1; + } + + void addCompletion( int iState, chr cLower, chr cUpper, int iTrgState ) + { + aState[iState].aRange.append( Range( cLower, cUpper, iTrgState ) ); + } + + template + bool match( const str &sIn, int &iSize, int &iCompletion ) + { + bool bMatch; + int iState = 0; + iSize = 0; + for( typename str::const_iterator i = sIn.begin(); i; i++ ) + { + Bu::sio << "Finding char " << *i << " in state " << iState + << ":" << Bu::sio.nl; + bMatch = false; + for( typename Bu::Array::iterator j = + aState[iState].aRange.begin(); j; j++ ) + { + Bu::sio << " Testing range " << (*j).cLower << " - " << (*j).cUpper << Bu::sio.nl; + if( *i >= (*j).cLower && *i <= (*j).cUpper ) + { + iState = (*j).iTrgState; + bMatch = true; + iSize++; + if( iState < 0 ) + { + iCompletion = iState; + return true; + } + } + } + if( bMatch == false ) + { + return false; + } + } + + iCompletion = 0; + return true; + } + + typedef Bu::Array StateArray; + StateArray aState; + }; + + template + class RegExEngine : public SharedCore, + RegExEngineCore > + { + private: + typedef class RegExEngine MyType; + typedef class RegExEngineCore Core; + typedef class Core::Range Range; + typedef class Core::State State; + + protected: + using SharedCore::core; + using SharedCore::_hardCopy; + using SharedCore::_resetCore; + using SharedCore::_allocateCore; + + public: + RegExEngine() + { + } + + virtual ~RegExEngine() + { + } + + int addState() + { + return core->addState(); + } + + void addCompletion( int iState, chr cLower, chr cUpper, int iTrgState ) + { + core->addCompletion( iState, cLower, cUpper, iTrgState ); + } + + template + bool match( const str &sIn, int &iSize, int &iCompletion ) + { + return core->match( sIn, iSize, iCompletion ); + } + + private: + }; }; #endif -- cgit v1.2.3