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

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

#include <regex.h>

Classes

class  DecodedStream
 
struct  Frag
 
struct  Range
 
struct  State
 

Public Types

typedef Encoding::Ch Ch
 

Public Member Functions

 GenericRegex (const Ch *source, Allocator *allocator=0)
 
 ~GenericRegex ()
 
bool IsValid () const
 
template<typename InputStream >
bool Match (InputStream &is) const
 
bool Match (const Ch *s) const
 
template<typename InputStream >
bool Search (InputStream &is) const
 
bool Search (const Ch *s) 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 > &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 > &ds, unsigned *u)
 
template<typename InputStream >
bool ParseRange (DecodedStream< InputStream > &ds, SizeType *range)
 
SizeType NewRange (unsigned codepoint)
 
template<typename InputStream >
bool CharacterEscape (DecodedStream< InputStream > &ds, unsigned *escapedCodepoint)
 
template<typename InputStream >
bool SearchWithAnchoring (InputStream &is, bool anchorBegin, bool anchorEnd) const
 
size_t GetStateSetSize () const
 
bool AddState (Stack< Allocator > &l, SizeType index) const
 
bool MatchRange (SizeType rangeIndex, unsigned codepoint) const
 

Static Private Member Functions

static SizeType Min (SizeType a, SizeType b)
 

Private Attributes

Stack< Allocator > states_
 
Stack< Allocator > ranges_
 
SizeType root_
 
SizeType stateCount_
 
SizeType rangeCount_
 
uint32_tstateSet_
 
Stack< Allocator > state0_
 
Stack< Allocator > state1_
 
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
 

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

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
Here is the call graph for this function:

◆ ~GenericRegex()

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

Member Function Documentation

◆ AddState()

template<typename Encoding , typename Allocator = CrtAllocator>
bool internal::GenericRegex< Encoding, Allocator >::AddState ( Stack< Allocator > &  l,
SizeType  index 
) const
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Append()

template<typename Encoding , typename Allocator = CrtAllocator>
SizeType internal::GenericRegex< Encoding, Allocator >::Append ( SizeType  l1,
SizeType  l2 
)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CharacterEscape()

template<typename Encoding , typename Allocator = CrtAllocator>
template<typename InputStream >
bool internal::GenericRegex< Encoding, Allocator >::CharacterEscape ( DecodedStream< InputStream > &  ds,
unsigned *  escapedCodepoint 
)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CloneTopOperand()

template<typename Encoding , typename Allocator = CrtAllocator>
void internal::GenericRegex< Encoding, Allocator >::CloneTopOperand ( Stack< Allocator > &  operandStack)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Eval()

template<typename Encoding , typename Allocator = CrtAllocator>
bool internal::GenericRegex< Encoding, Allocator >::Eval ( Stack< Allocator > &  operandStack,
Operator  op 
)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EvalQuantifier()

template<typename Encoding , typename Allocator = CrtAllocator>
bool internal::GenericRegex< Encoding, Allocator >::EvalQuantifier ( Stack< Allocator > &  operandStack,
unsigned  n,
unsigned  m 
)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetRange() [1/2]

template<typename Encoding , typename Allocator = CrtAllocator>
Range& internal::GenericRegex< Encoding, Allocator >::GetRange ( SizeType  index)
inlineprivate
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ GetState() [2/2]

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

◆ GetStateSetSize()

template<typename Encoding , typename Allocator = CrtAllocator>
size_t internal::GenericRegex< Encoding, Allocator >::GetStateSetSize ( ) const
inlineprivate
Here is the caller graph for this function:

◆ ImplicitConcatenation()

template<typename Encoding , typename Allocator = CrtAllocator>
void internal::GenericRegex< Encoding, Allocator >::ImplicitConcatenation ( Stack< Allocator > &  atomCountStack,
Stack< Allocator > &  operatorStack 
)
inlineprivate
Here is the caller graph for this function:

◆ IsValid()

template<typename Encoding , typename Allocator = CrtAllocator>
bool internal::GenericRegex< Encoding, Allocator >::IsValid ( ) const
inline
Here is the caller graph for this function:

◆ Match() [1/2]

template<typename Encoding , typename Allocator = CrtAllocator>
template<typename InputStream >
bool internal::GenericRegex< Encoding, Allocator >::Match ( InputStream &  is) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Match() [2/2]

template<typename Encoding , typename Allocator = CrtAllocator>
bool internal::GenericRegex< Encoding, Allocator >::Match ( const Ch s) const
inline
Here is the call graph for this function:

◆ MatchRange()

template<typename Encoding , typename Allocator = CrtAllocator>
bool internal::GenericRegex< Encoding, Allocator >::MatchRange ( SizeType  rangeIndex,
unsigned  codepoint 
) const
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Min()

template<typename Encoding , typename Allocator = CrtAllocator>
static SizeType internal::GenericRegex< Encoding, Allocator >::Min ( SizeType  a,
SizeType  b 
)
inlinestaticprivate
Here is the caller graph for this function:

◆ NewRange()

template<typename Encoding , typename Allocator = CrtAllocator>
SizeType internal::GenericRegex< Encoding, Allocator >::NewRange ( unsigned  codepoint)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ NewState()

template<typename Encoding , typename Allocator = CrtAllocator>
SizeType internal::GenericRegex< Encoding, Allocator >::NewState ( SizeType  out,
SizeType  out1,
unsigned  codepoint 
)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Parse()

template<typename Encoding , typename Allocator = CrtAllocator>
template<typename InputStream >
void internal::GenericRegex< Encoding, Allocator >::Parse ( DecodedStream< InputStream > &  ds)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ParseRange()

template<typename Encoding , typename Allocator = CrtAllocator>
template<typename InputStream >
bool internal::GenericRegex< Encoding, Allocator >::ParseRange ( DecodedStream< InputStream > &  ds,
SizeType range 
)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ParseUnsigned()

template<typename Encoding , typename Allocator = CrtAllocator>
template<typename InputStream >
bool internal::GenericRegex< Encoding, Allocator >::ParseUnsigned ( DecodedStream< InputStream > &  ds,
unsigned *  u 
)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Patch()

template<typename Encoding , typename Allocator = CrtAllocator>
void internal::GenericRegex< Encoding, Allocator >::Patch ( SizeType  l,
SizeType  s 
)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PushOperand()

template<typename Encoding , typename Allocator = CrtAllocator>
void internal::GenericRegex< Encoding, Allocator >::PushOperand ( Stack< Allocator > &  operandStack,
unsigned  codepoint 
)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Search() [1/2]

template<typename Encoding , typename Allocator = CrtAllocator>
template<typename InputStream >
bool internal::GenericRegex< Encoding, Allocator >::Search ( InputStream &  is) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Search() [2/2]

template<typename Encoding , typename Allocator = CrtAllocator>
bool internal::GenericRegex< Encoding, Allocator >::Search ( const Ch s) const
inline
Here is the call graph for this function:

◆ SearchWithAnchoring()

template<typename Encoding , typename Allocator = CrtAllocator>
template<typename InputStream >
bool internal::GenericRegex< Encoding, Allocator >::SearchWithAnchoring ( InputStream &  is,
bool  anchorBegin,
bool  anchorEnd 
) const
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

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

◆ state0_

template<typename Encoding , typename Allocator = CrtAllocator>
Stack<Allocator> internal::GenericRegex< Encoding, Allocator >::state0_
mutableprivate

◆ state1_

template<typename Encoding , typename Allocator = CrtAllocator>
Stack<Allocator> internal::GenericRegex< Encoding, Allocator >::state1_
mutableprivate

◆ 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

◆ stateSet_

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

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