MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / PushRepetition

Method PushRepetition

extern/re2/re2/parse.cc:568–601  ·  view source on GitHub ↗

Pushes a repetition regexp onto the stack. A valid argument for the operator must already be on the stack.

Source from the content-addressed store, hash-verified

566// Pushes a repetition regexp onto the stack.
567// A valid argument for the operator must already be on the stack.
568bool Regexp::ParseState::PushRepetition(int min, int max,
569 const StringPiece& s,
570 bool nongreedy) {
571 if ((max != -1 && max < min) || min > kMaxRepeat || max > kMaxRepeat) {
572 status_->set_code(kRegexpRepeatSize);
573 status_->set_error_arg(s);
574 return false;
575 }
576 if (stacktop_ == NULL || IsMarker(stacktop_->op())) {
577 status_->set_code(kRegexpRepeatArgument);
578 status_->set_error_arg(s);
579 return false;
580 }
581 Regexp::ParseFlags fl = flags_;
582 if (nongreedy)
583 fl = fl ^ NonGreedy;
584 Regexp* re = new Regexp(kRegexpRepeat, fl);
585 re->min_ = min;
586 re->max_ = max;
587 re->AllocSub(1);
588 re->down_ = stacktop_->down_;
589 re->sub()[0] = FinishRegexp(stacktop_);
590 re->simple_ = re->ComputeSimple();
591 stacktop_ = re;
592 if (min >= 2 || max >= 2) {
593 RepetitionWalker w;
594 if (w.Walk(stacktop_, kMaxRepeat) == 0) {
595 status_->set_code(kRegexpRepeatSize);
596 status_->set_error_arg(s);
597 return false;
598 }
599 }
600 return true;
601}
602
603// Checks whether a particular regexp op is a marker.
604bool Regexp::ParseState::IsMarker(RegexpOp op) {

Callers 1

ParseMethod · 0.80

Calls 7

set_codeMethod · 0.80
set_error_argMethod · 0.80
AllocSubMethod · 0.80
ComputeSimpleMethod · 0.80
WalkMethod · 0.80
opMethod · 0.45
subMethod · 0.45

Tested by

no test coverage detected