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::Ch Ch
 
typedef Encoding EncodingType
 

Public Member Functions

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

Private Types

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

Private Member Functions

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

Static Private Member Functions

static SizeType Min (SizeType a, SizeType b)
 

Private Attributes

Allocator * allocator_
 
bool anchorBegin_
 
bool anchorEnd_
 
Allocator * ownAllocator_
 
SizeType rangeCount_
 
Stack< Allocator > ranges_
 
SizeType root_
 
SizeType stateCount_
 
Stack< Allocator > states_
 

Static Private Attributes

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

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

Definition at line 125 of file regex.h.

Member Typedef Documentation

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

Definition at line 129 of file regex.h.

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

Definition at line 128 of file regex.h.

Member Enumeration Documentation

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

Definition at line 160 of file regex.h.

Constructor & Destructor Documentation

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

Definition at line 133 of file regex.h.

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

Definition at line 149 of file regex.h.

Member Function Documentation

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

Definition at line 381 of file regex.h.

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

Definition at line 632 of file regex.h.

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

Definition at line 510 of file regex.h.

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

Definition at line 399 of file regex.h.

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

Definition at line 462 of file regex.h.

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

Definition at line 211 of file regex.h.

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

Definition at line 217 of file regex.h.

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

Definition at line 199 of file regex.h.

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

Definition at line 205 of file regex.h.

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

Definition at line 374 of file regex.h.

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

Definition at line 154 of file regex.h.

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

Definition at line 505 of file regex.h.

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

Definition at line 623 of file regex.h.

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

Definition at line 358 of file regex.h.

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

Definition at line 224 of file regex.h.

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

Definition at line 544 of file regex.h.

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

Definition at line 528 of file regex.h.

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

Definition at line 390 of file regex.h.

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

Definition at line 368 of file regex.h.

Friends And Related Function Documentation

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

Definition at line 131 of file regex.h.

Member Data Documentation

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

Definition at line 674 of file regex.h.

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

Definition at line 684 of file regex.h.

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

Definition at line 685 of file regex.h.

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

For '.'.

Definition at line 170 of file regex.h.

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

Definition at line 681 of file regex.h.

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

Definition at line 171 of file regex.h.

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

Definition at line 172 of file regex.h.

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

Definition at line 673 of file regex.h.

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

Definition at line 679 of file regex.h.

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

Definition at line 676 of file regex.h.

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

Definition at line 677 of file regex.h.

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

Definition at line 678 of file regex.h.

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

Definition at line 675 of file regex.h.


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


xbot_talker
Author(s): wangxiaoyun
autogenerated on Sat Oct 10 2020 03:27:54