Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

cmt_one_more Class Reference

Inheritance diagram for cmt_one_more:

Inheritance graph
[legend]
Collaboration diagram for cmt_one_more:

Collaboration graph
[legend]
List of all members.

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

Constructor & Destructor Documentation

cmt_one_more::cmt_one_more cmt_regexp_node n  ) 
 

Definition at line 714 of file cmt_regexp.cxx.

00714                                               : cmt_many_node (n)
00715 {
00716 }


Member Function Documentation

void cmt_one_more::dump  )  const [virtual]
 

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.

00799 {
00800   tab (); cout << "one_more (" << this << ") " << endl;
00801   if (_node != 0)
00802     {
00803       tab_level++;
00804       _node->dump ();
00805       tab_level--;
00806     }
00807   tab_level++;
00808   _follower.dump ();
00809   tab_level--;
00810 }

const cmt_regexp::iterator cmt_one_more::match const cmt_string text,
int  pos
const [virtual]
 

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 }


The documentation for this class was generated from the following file:
Generated on Mon May 2 10:25:30 2005 for CMT by doxygen 1.3.5