internal::GenericRegex
Engine/source/persistence/rapidjson/internal/regex.h
Regular expression engine with subset of ECMAscript grammar.
Classes:
Private Types
enum
Operator { kZeroOrOne kZeroOrMore kOneOrMore kConcatenation kAlternation kLeftParenthesis }
Public Types
Encoding::Ch
Ch
EncodingType
Public Friends
class
Private Attributes
Public Functions
Private Functions
bool
CharacterEscape(DecodedStream< InputStream, Encoding > & ds, unsigned * escapedCodepoint)
CloneTopOperand(Stack< Allocator > & operandStack)
bool
EvalQuantifier(Stack< Allocator > & operandStack, unsigned n, unsigned m)
Parse(DecodedStream< InputStream, Encoding > & ds)
bool
ParseRange(DecodedStream< InputStream, Encoding > & ds, SizeType * range)
bool
ParseUnsigned(DecodedStream< InputStream, Encoding > & ds, unsigned * u)
PushOperand(Stack< Allocator > & operandStack, unsigned codepoint)
Detailed Description
Regular expression engine with subset of ECMAscript grammar.
Supported regular expression syntax:
ab
Concatenationa|b
Alternationa
? Zero or onea*
Zero or morea+
One or morea{3}
Exactly 3 timesa{3
,} At least 3 timesa{3
,5} 3 to 5 times- (ab) Grouping
^a
At the beginninga$
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
Private Types
Operator
Enumerator
- kZeroOrOne
- kZeroOrMore
- kOneOrMore
- kConcatenation
- kAlternation
- kLeftParenthesis
Public Types
typedef Encoding::Ch Ch
typedef Encoding EncodingType
Public Friends
Private Static Attributes
const unsigned kAnyCharacterClass
For '.'.
const unsigned kInfinityQuantifier
const unsigned kRangeCharacterClass
const unsigned kRangeNegationFlag
Private Attributes
Allocator * allocator_
bool anchorBegin_
bool anchorEnd_
Allocator * ownAllocator_
SizeType rangeCount_
Stack< Allocator > ranges_
SizeType root_
SizeType stateCount_
Stack< Allocator > states_
Public Functions
GenericRegex(const Ch * source, Allocator * allocator)
~GenericRegex()
IsValid()
Private Functions
Append(SizeType l1, SizeType l2)
CharacterEscape(DecodedStream< InputStream, Encoding > & ds, unsigned * escapedCodepoint)
CloneTopOperand(Stack< Allocator > & operandStack)
Eval(Stack< Allocator > & operandStack, Operator op)
EvalQuantifier(Stack< Allocator > & operandStack, unsigned n, unsigned m)
GetRange(SizeType index)
GetRange(SizeType index)
GetState(SizeType index)
GetState(SizeType index)
ImplicitConcatenation(Stack< Allocator > & atomCountStack, Stack< Allocator > & operatorStack)
NewRange(unsigned codepoint)
NewState(SizeType out, SizeType out1, unsigned codepoint)
Parse(DecodedStream< InputStream, Encoding > & ds)
ParseRange(DecodedStream< InputStream, Encoding > & ds, SizeType * range)
ParseUnsigned(DecodedStream< InputStream, Encoding > & ds, unsigned * u)
Patch(SizeType l, SizeType s)
PushOperand(Stack< Allocator > & operandStack, unsigned codepoint)