NDDEM
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
internal::GenericRegex< Encoding, Allocator > Class Template Reference

Regular expression engine with subset of ECMAscript grammar. More...

#include <regex.h>

Classes

struct  Frag
 
struct  Range
 
struct  State
 

Public Types

typedef Encoding EncodingType
 
typedef Encoding::Ch Ch
 

Public Member Functions

 GenericRegex (const Ch *source, Allocator *allocator=0)
 
 ~GenericRegex ()
 
bool IsValid () const
 

Private Types

enum  Operator {
  kZeroOrOne , kZeroOrMore , kOneOrMore , kConcatenation ,
  kAlternation , kLeftParenthesis
}
 

Private Member Functions

StateGetState (SizeType index)
 
const StateGetState (SizeType index) const
 
RangeGetRange (SizeType index)
 
const RangeGetRange (SizeType index) const
 
template<typename InputStream >
void Parse (DecodedStream< InputStream, Encoding > &ds)
 
SizeType NewState (SizeType out, SizeType out1, unsigned codepoint)
 
void PushOperand (Stack< Allocator > &operandStack, unsigned codepoint)
 
void ImplicitConcatenation (Stack< Allocator > &atomCountStack, Stack< Allocator > &operatorStack)
 
SizeType Append (SizeType l1, SizeType l2)
 
void Patch (SizeType l, SizeType s)
 
bool Eval (Stack< Allocator > &operandStack, Operator op)
 
bool EvalQuantifier (Stack< Allocator > &operandStack, unsigned n, unsigned m)
 
void CloneTopOperand (Stack< Allocator > &operandStack)
 
template<typename InputStream >
bool ParseUnsigned (DecodedStream< InputStream, Encoding > &ds, unsigned *u)
 
template<typename InputStream >
bool ParseRange (DecodedStream< InputStream, Encoding > &ds, SizeType *range)
 
SizeType NewRange (unsigned codepoint)
 
template<typename InputStream >
bool CharacterEscape (DecodedStream< InputStream, Encoding > &ds, unsigned *escapedCodepoint)
 

Static Private Member Functions

static SizeType Min (SizeType a, SizeType b)
 

Private Attributes

AllocatorownAllocator_
 
Allocatorallocator_
 
Stack< Allocatorstates_
 
Stack< Allocatorranges_
 
SizeType root_
 
SizeType stateCount_
 
SizeType rangeCount_
 
bool anchorBegin_
 
bool anchorEnd_
 

Static Private Attributes

static const unsigned kAnyCharacterClass = 0xFFFFFFFF
 For '.'. More...
 
static const unsigned kRangeCharacterClass = 0xFFFFFFFE
 
static const unsigned kRangeNegationFlag = 0x80000000
 
static const unsigned kInfinityQuantifier = ~0u
 

Friends

template<typename , typename >
class GenericRegexSearch
 

Detailed Description

template<typename Encoding, typename Allocator = CrtAllocator>
class internal::GenericRegex< Encoding, Allocator >

Regular expression engine with subset of ECMAscript grammar.

Supported regular expression syntax:

Note
This is a Thompson NFA engine, implemented with reference to Cox, Russ. "Regular Expression Matching Can Be Simple And Fast (but is slow in Java, Perl, PHP, Python, Ruby,...).", https://swtch.com/~rsc/regexp/regexp1.html

Member Typedef Documentation

◆ Ch

template<typename Encoding , typename Allocator = CrtAllocator>
typedef Encoding::Ch internal::GenericRegex< Encoding, Allocator >::Ch

◆ EncodingType

template<typename Encoding , typename Allocator = CrtAllocator>
typedef Encoding internal::GenericRegex< Encoding, Allocator >::EncodingType

Member Enumeration Documentation

◆ Operator

template<typename Encoding , typename Allocator = CrtAllocator>
enum internal::GenericRegex::Operator
private
Enumerator
kZeroOrOne 
kZeroOrMore 
kOneOrMore 
kConcatenation 
kAlternation 
kLeftParenthesis 

Constructor & Destructor Documentation

◆ GenericRegex()

template<typename Encoding , typename Allocator = CrtAllocator>
internal::GenericRegex< Encoding, Allocator >::GenericRegex ( const Ch source,
Allocator allocator = 0 
)
inline

◆ ~GenericRegex()

template<typename Encoding , typename Allocator = CrtAllocator>
internal::GenericRegex< Encoding, Allocator >::~GenericRegex ( )
inline

Member Function Documentation

◆ Append()

template<typename Encoding , typename Allocator = CrtAllocator>
SizeType internal::GenericRegex< Encoding, Allocator >::Append ( SizeType  l1,
SizeType  l2 
)
inlineprivate

◆ CharacterEscape()

template<typename Encoding , typename Allocator = CrtAllocator>
template<typename InputStream >
bool internal::GenericRegex< Encoding, Allocator >::CharacterEscape ( DecodedStream< InputStream, Encoding > &  ds,
unsigned *  escapedCodepoint 
)
inlineprivate

◆ CloneTopOperand()

template<typename Encoding , typename Allocator = CrtAllocator>
void internal::GenericRegex< Encoding, Allocator >::CloneTopOperand ( Stack< Allocator > &  operandStack)
inlineprivate

◆ Eval()

template<typename Encoding , typename Allocator = CrtAllocator>
bool internal::GenericRegex< Encoding, Allocator >::Eval ( Stack< Allocator > &  operandStack,
Operator  op 
)
inlineprivate

◆ EvalQuantifier()

template<typename Encoding , typename Allocator = CrtAllocator>
bool internal::GenericRegex< Encoding, Allocator >::EvalQuantifier ( Stack< Allocator > &  operandStack,
unsigned  n,
unsigned  m 
)
inlineprivate

◆ GetRange() [1/2]

template<typename Encoding , typename Allocator = CrtAllocator>
Range& internal::GenericRegex< Encoding, Allocator >::GetRange ( SizeType  index)
inlineprivate

◆ GetRange() [2/2]

template<typename Encoding , typename Allocator = CrtAllocator>
const Range& internal::GenericRegex< Encoding, Allocator >::GetRange ( SizeType  index) const
inlineprivate

◆ GetState() [1/2]

template<typename Encoding , typename Allocator = CrtAllocator>
State& internal::GenericRegex< Encoding, Allocator >::GetState ( SizeType  index)
inlineprivate

◆ GetState() [2/2]

template<typename Encoding , typename Allocator = CrtAllocator>
const State& internal::GenericRegex< Encoding, Allocator >::GetState ( SizeType  index) const
inlineprivate

◆ ImplicitConcatenation()

template<typename Encoding , typename Allocator = CrtAllocator>
void internal::GenericRegex< Encoding, Allocator >::ImplicitConcatenation ( Stack< Allocator > &  atomCountStack,
Stack< Allocator > &  operatorStack 
)
inlineprivate

◆ IsValid()

template<typename Encoding , typename Allocator = CrtAllocator>
bool internal::GenericRegex< Encoding, Allocator >::IsValid ( ) const
inline

◆ Min()

template<typename Encoding , typename Allocator = CrtAllocator>
static SizeType internal::GenericRegex< Encoding, Allocator >::Min ( SizeType  a,
SizeType  b 
)
inlinestaticprivate

◆ NewRange()

template<typename Encoding , typename Allocator = CrtAllocator>
SizeType internal::GenericRegex< Encoding, Allocator >::NewRange ( unsigned  codepoint)
inlineprivate

◆ NewState()

template<typename Encoding , typename Allocator = CrtAllocator>
SizeType internal::GenericRegex< Encoding, Allocator >::NewState ( SizeType  out,
SizeType  out1,
unsigned  codepoint 
)
inlineprivate

◆ Parse()

template<typename Encoding , typename Allocator = CrtAllocator>
template<typename InputStream >
void internal::GenericRegex< Encoding, Allocator >::Parse ( DecodedStream< InputStream, Encoding > &  ds)
inlineprivate

◆ ParseRange()

template<typename Encoding , typename Allocator = CrtAllocator>
template<typename InputStream >
bool internal::GenericRegex< Encoding, Allocator >::ParseRange ( DecodedStream< InputStream, Encoding > &  ds,
SizeType range 
)
inlineprivate

◆ ParseUnsigned()

template<typename Encoding , typename Allocator = CrtAllocator>
template<typename InputStream >
bool internal::GenericRegex< Encoding, Allocator >::ParseUnsigned ( DecodedStream< InputStream, Encoding > &  ds,
unsigned *  u 
)
inlineprivate

◆ Patch()

template<typename Encoding , typename Allocator = CrtAllocator>
void internal::GenericRegex< Encoding, Allocator >::Patch ( SizeType  l,
SizeType  s 
)
inlineprivate

◆ PushOperand()

template<typename Encoding , typename Allocator = CrtAllocator>
void internal::GenericRegex< Encoding, Allocator >::PushOperand ( Stack< Allocator > &  operandStack,
unsigned  codepoint 
)
inlineprivate

Friends And Related Function Documentation

◆ GenericRegexSearch

template<typename Encoding , typename Allocator = CrtAllocator>
template<typename , typename >
friend class GenericRegexSearch
friend

Member Data Documentation

◆ allocator_

template<typename Encoding , typename Allocator = CrtAllocator>
Allocator* internal::GenericRegex< Encoding, Allocator >::allocator_
private

◆ anchorBegin_

template<typename Encoding , typename Allocator = CrtAllocator>
bool internal::GenericRegex< Encoding, Allocator >::anchorBegin_
private

◆ anchorEnd_

template<typename Encoding , typename Allocator = CrtAllocator>
bool internal::GenericRegex< Encoding, Allocator >::anchorEnd_
private

◆ kAnyCharacterClass

template<typename Encoding , typename Allocator = CrtAllocator>
const unsigned internal::GenericRegex< Encoding, Allocator >::kAnyCharacterClass = 0xFFFFFFFF
staticprivate

For '.'.

◆ kInfinityQuantifier

template<typename Encoding , typename Allocator = CrtAllocator>
const unsigned internal::GenericRegex< Encoding, Allocator >::kInfinityQuantifier = ~0u
staticprivate

◆ kRangeCharacterClass

template<typename Encoding , typename Allocator = CrtAllocator>
const unsigned internal::GenericRegex< Encoding, Allocator >::kRangeCharacterClass = 0xFFFFFFFE
staticprivate

◆ kRangeNegationFlag

template<typename Encoding , typename Allocator = CrtAllocator>
const unsigned internal::GenericRegex< Encoding, Allocator >::kRangeNegationFlag = 0x80000000
staticprivate

◆ ownAllocator_

template<typename Encoding , typename Allocator = CrtAllocator>
Allocator* internal::GenericRegex< Encoding, Allocator >::ownAllocator_
private

◆ rangeCount_

template<typename Encoding , typename Allocator = CrtAllocator>
SizeType internal::GenericRegex< Encoding, Allocator >::rangeCount_
private

◆ ranges_

template<typename Encoding , typename Allocator = CrtAllocator>
Stack<Allocator> internal::GenericRegex< Encoding, Allocator >::ranges_
private

◆ root_

template<typename Encoding , typename Allocator = CrtAllocator>
SizeType internal::GenericRegex< Encoding, Allocator >::root_
private

◆ stateCount_

template<typename Encoding , typename Allocator = CrtAllocator>
SizeType internal::GenericRegex< Encoding, Allocator >::stateCount_
private

◆ states_

template<typename Encoding , typename Allocator = CrtAllocator>
Stack<Allocator> internal::GenericRegex< Encoding, Allocator >::states_
private

The documentation for this class was generated from the following file: