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

Method DoRightParen

extern/re2/re2/parse.cc:676–712  ·  view source on GitHub ↗

Processes a right parenthesis in the input.

Source from the content-addressed store, hash-verified

674
675// Processes a right parenthesis in the input.
676bool Regexp::ParseState::DoRightParen() {
677 // Finish the current concatenation and alternation.
678 DoAlternation();
679
680 // The stack should be: LeftParen regexp
681 // Remove the LeftParen, leaving the regexp,
682 // parenthesized.
683 Regexp* r1;
684 Regexp* r2;
685 if ((r1 = stacktop_) == NULL ||
686 (r2 = r1->down_) == NULL ||
687 r2->op() != kLeftParen) {
688 status_->set_code(kRegexpUnexpectedParen);
689 status_->set_error_arg(whole_regexp_);
690 return false;
691 }
692
693 // Pop off r1, r2. Will Decref or reuse below.
694 stacktop_ = r2->down_;
695
696 // Restore flags from when paren opened.
697 Regexp* re = r2;
698 flags_ = re->parse_flags();
699
700 // Rewrite LeftParen as capture if needed.
701 if (re->cap_ > 0) {
702 re->op_ = kRegexpCapture;
703 // re->cap_ is already set
704 re->AllocSub(1);
705 re->sub()[0] = FinishRegexp(r1);
706 re->simple_ = re->ComputeSimple();
707 } else {
708 re->Decref();
709 re = r1;
710 }
711 return PushRegexp(re);
712}
713
714// Processes the end of input, returning the final regexp.
715Regexp* Regexp::ParseState::DoFinish() {

Callers 1

ParseMethod · 0.80

Calls 8

set_codeMethod · 0.80
set_error_argMethod · 0.80
parse_flagsMethod · 0.80
AllocSubMethod · 0.80
ComputeSimpleMethod · 0.80
opMethod · 0.45
subMethod · 0.45
DecrefMethod · 0.45

Tested by

no test coverage detected