192 Stack<Allocator> operandStack(&allocator, 256);
193 Stack<Allocator> operatorStack(&allocator, 256);
194 Stack<Allocator> atomCountStack(&allocator, 256);
196 *atomCountStack.template Push<unsigned>() = 0;
199 while (
ds.Peek() != 0) {
200 switch (codepoint =
ds.Take()) {
210 while (!operatorStack.Empty() && *operatorStack.template Top<Operator>() <
kAlternation)
211 if (!
Eval(operandStack, *operatorStack.template Pop<Operator>(1)))
213 *operatorStack.template Push<Operator>() =
kAlternation;
214 *atomCountStack.template Top<unsigned>() = 0;
219 *atomCountStack.template Push<unsigned>() = 0;
223 while (!operatorStack.Empty() && *operatorStack.template Top<Operator>() !=
kLeftParenthesis)
224 if (!
Eval(operandStack, *operatorStack.template Pop<Operator>(1)))
226 if (operatorStack.Empty())
228 operatorStack.template Pop<Operator>(1);
229 atomCountStack.template Pop<unsigned>(1);
254 if (
ds.Peek() ==
',') {
256 if (
ds.Peek() ==
'}')
282 *operandStack.template Push<Frag>() = Frag(s, s, s);
298 while (!operatorStack.Empty())
299 if (!
Eval(operandStack, *operatorStack.template Pop<Operator>(1)))
303 if (operandStack.GetSize() ==
sizeof(Frag)) {
304 Frag*
e = operandStack.template Pop<Frag>(1);
308 #if RAPIDJSON_REGEX_VERBOSE 309 printf(
"root: %d\n",
root_);
312 printf(
"[%2d] out: %2d out1: %2d c: '%c'\n", i, s.out, s.out1, (
char)s.codepoint);
bool Eval(Stack< Allocator > &operandStack, Operator op)
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
static const unsigned kInfinityQuantifier
SizeType NewState(SizeType out, SizeType out1, unsigned codepoint)
void PushOperand(Stack< Allocator > &operandStack, unsigned codepoint)
static const SizeType kRegexInvalidState
Represents an invalid index in GenericRegex::State::out, out1.
bool ParseRange(DecodedStream< InputStream, Encoding > &ds, SizeType *range)
State & GetState(SizeType index)
static const unsigned kRangeCharacterClass
static const unsigned kAnyCharacterClass
For '.'.
bool EvalQuantifier(Stack< Allocator > &operandStack, unsigned n, unsigned m)
void Patch(SizeType l, SizeType s)
bool ParseUnsigned(DecodedStream< InputStream, Encoding > &ds, unsigned *u)
bool CharacterEscape(DecodedStream< InputStream, Encoding > &ds, unsigned *escapedCodepoint)
void ImplicitConcatenation(Stack< Allocator > &atomCountStack, Stack< Allocator > &operatorStack)