Public Member Functions | |
cmt_one_more (cmt_regexp_node *n) | |
const cmt_regexp::iterator | match (const cmt_string &text, int pos) const |
void | dump () const |
|
Definition at line 714 of file cmt_regexp.cxx.
00714 : cmt_many_node (n) 00715 { 00716 } |
|
Reimplemented from cmt_many_node. Definition at line 798 of file cmt_regexp.cxx. References cmt_and_node::dump(), cmt_regexp_node::dump(), tab(), and tab_level.
|
|
Reimplemented from cmt_regexp_node. Definition at line 718 of file cmt_regexp.cxx. References cmt_regexp::iterator::_length, cmt_and_node::match(), cmt_regexp_node::match(), cmt_regexp::iterator::null(), and cmt_string::size().
00720 { 00721 if ((pos < 0) || (pos > text.size ())) 00722 { 00723 return (cmt_regexp::iterator::null ()); 00724 } 00725 00726 int total = 0; 00727 00728 // 00729 // we are at : x+y 00730 // 00731 00732 int saved_pos = -1; 00733 int saved_total = -1; 00734 bool at_least_one = false; 00735 00736 do 00737 { 00738 const cmt_regexp::iterator itx = _node->match (text, pos); 00739 const cmt_regexp::iterator ity = _follower.match (text, pos); 00740 00741 if ((itx == cmt_regexp::iterator::null ()) && 00742 (ity == cmt_regexp::iterator::null ())) 00743 { 00744 // 00745 // There is neither x nor y. We move back to the last 00746 // succesful match for y. 00747 // 00748 if (saved_pos >= 0) 00749 { 00750 // 00751 // We had once a y. 00752 // 00753 pos = saved_pos; 00754 total = saved_total; 00755 } 00756 else 00757 { 00758 // 00759 // We never had any y ! 00760 // 00761 return (cmt_regexp::iterator::null ()); 00762 } 00763 00764 break; 00765 } 00766 00767 if (itx == cmt_regexp::iterator::null ()) 00768 { 00769 // 00770 // There is a y but no x anymore, fine, we can quit. 00771 // 00772 total += ity._length; 00773 pos += ity._length; 00774 break; 00775 } 00776 00777 if (ity != cmt_regexp::iterator::null ()) 00778 { 00779 // 00780 // We have both x and y. We save the current pos and total, 00781 // and then skip this x. 00782 // 00783 saved_total = total + ity._length; 00784 saved_pos = pos + ity._length; 00785 } 00786 00787 total += itx._length; 00788 pos += itx._length; 00789 00790 at_least_one = true; 00791 } while (true); 00792 00793 if (!at_least_one) return (cmt_regexp::iterator::null ()); 00794 00795 return (cmt_regexp::iterator (pos, total)); 00796 } |