

Public Methods | |
| cmt_zero_more (cmt_node* n) | |
| const cmt_regexp::iterator | match (const cmt_string& text, int pos) const |
|
|
Definition at line 511 of file cmt_regexp.cxx. 00511 : cmt_many_node (n) 00512 { 00513 } |
|
|
Reimplemented from cmt_node. Definition at line 515 of file cmt_regexp.cxx. 00517 {
00518 if ((pos < 0) || (pos > text.size ()))
00519 {
00520 return (cmt_regexp::iterator::null ());
00521 }
00522
00523 int total = 0;
00524
00525 //
00526 // we are at : x*y
00527 //
00528
00529 int saved_pos = -1;
00530 int saved_total = -1;
00531
00532 do
00533 {
00534 const cmt_regexp::iterator itx = _node->match (text, pos);
00535 const cmt_regexp::iterator ity = _follower.match (text, pos);
00536
00537 if ((itx == cmt_regexp::iterator::null ()) &&
00538 (ity == cmt_regexp::iterator::null ()))
00539 {
00540 //
00541 // There is neither x nor y. We move back to the last
00542 // succesful match for y.
00543 //
00544 if (saved_pos >= 0)
00545 {
00546 //
00547 // We had once a y.
00548 //
00549 pos = saved_pos;
00550 total = saved_total;
00551 }
00552 else
00553 {
00554 //
00555 // We never had any y !
00556 //
00557 return (cmt_regexp::iterator::null ());
00558 }
00559
00560 break;
00561 }
00562
00563 if (itx == cmt_regexp::iterator::null ())
00564 {
00565 //
00566 // There is a y but no x anymore, fine, we can quit.
00567 //
00568 total += ity._length;
00569 pos += ity._length;
00570 break;
00571 }
00572
00573 if (ity != cmt_regexp::iterator::null ())
00574 {
00575 //
00576 // We have both x and y. We save the current pos and total,
00577 // and then skip this x.
00578 //
00579 saved_total = total + ity._length;
00580 saved_pos = pos + ity._length;
00581 }
00582 total += itx._length;
00583 pos += itx._length;
00584 } while (true);
00585
00586 return (cmt_regexp::iterator (pos, total));
00587 }
|
1.2.3 written by Dimitri van Heesch,
© 1997-2000