Public Member Functions | |
cmt_zero_more (cmt_regexp_node *n) | |
const cmt_regexp::iterator | match (const cmt_string &text, int pos) const |
void | dump () const |
|
Definition at line 621 of file cmt_regexp.cxx.
00621 : cmt_many_node (n) 00622 { 00623 } |
|
Reimplemented from cmt_many_node. Definition at line 699 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 625 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().
00627 { 00628 if ((pos < 0) || (pos > text.size ())) 00629 { 00630 return (cmt_regexp::iterator::null ()); 00631 } 00632 00633 int total = 0; 00634 00635 // 00636 // we are at : x*y 00637 // 00638 00639 int saved_pos = -1; 00640 int saved_total = -1; 00641 00642 do 00643 { 00644 const cmt_regexp::iterator itx = _node->match (text, pos); 00645 const cmt_regexp::iterator ity = _follower.match (text, pos); 00646 00647 if ((itx == cmt_regexp::iterator::null ()) && 00648 (ity == cmt_regexp::iterator::null ())) 00649 { 00650 // 00651 // There is neither x nor y. We move back to the last 00652 // succesful match for y. 00653 // 00654 if (saved_pos >= 0) 00655 { 00656 // 00657 // We had once a y. 00658 // 00659 pos = saved_pos; 00660 total = saved_total; 00661 } 00662 else 00663 { 00664 // 00665 // We never had any y ! 00666 // 00667 return (cmt_regexp::iterator::null ()); 00668 } 00669 00670 break; 00671 } 00672 00673 if (itx == cmt_regexp::iterator::null ()) 00674 { 00675 // 00676 // There is a y but no x anymore, fine, we can quit. 00677 // 00678 total += ity._length; 00679 pos += ity._length; 00680 break; 00681 } 00682 00683 if (ity != cmt_regexp::iterator::null ()) 00684 { 00685 // 00686 // We have both x and y. We save the current pos and total, 00687 // and then skip this x. 00688 // 00689 saved_total = total + ity._length; 00690 saved_pos = pos + ity._length; 00691 } 00692 total += itx._length; 00693 pos += itx._length; 00694 } while (true); 00695 00696 return (cmt_regexp::iterator (pos, total)); 00697 } |