Monero
Loading...
Searching...
No Matches
internal::GenericRegex< Encoding, Allocator > Class Template Reference

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

#include <regex.h>

Collaboration diagram for internal::GenericRegex< Encoding, Allocator >:

Classes

struct  Range
struct  State
struct  Frag

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

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

Static Private Attributes

static const unsigned kAnyCharacterClass = 0xFFFFFFFF
 For '.'.
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:

  • ab Concatenation
  • a|b Alternation
  • a? Zero or one
  • a* Zero or more
  • a+ One or more
  • a{3} Exactly 3 times
  • a{3,} At least 3 times
  • a{3,5} 3 to 5 times
  • (ab) Grouping
  • ^a At the beginning
  • a$ At the end
  • . Any character
  • [abc] Character classes
  • [a-c] Character class range
  • [a-z0-9_] Character class combination
  • [^abc] Negated character classes
  • [^a-c] Negated character class range
  • [] Backspace (U+0008)
  • \| \\ ... Escape characters
  • \f Form feed (U+000C)
  • \n Line feed (U+000A)
  • \r Carriage return (U+000D)
  • \t Tab (U+0009)
  • \v Vertical tab (U+000B)
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>
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

◆ GenericRegexSearch

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

Member Data Documentation

◆ 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

◆ 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: