Processes a right parenthesis in the input.
| 674 | |
| 675 | // Processes a right parenthesis in the input. |
| 676 | bool 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. |
| 715 | Regexp* Regexp::ParseState::DoFinish() { |
no test coverage detected