Public Member Functions | |
cmt_and_node () | |
cmt_and_node (cmt_regexp_node_set *father) | |
const cmt_regexp::iterator | match (const cmt_string &text, int pos) const |
void | reduce () |
void | fill (cmt_and_node &other, int start_index) |
void | dump () const |
|
Definition at line 957 of file cmt_regexp.cxx.
00957 : cmt_regexp_node_set () 00958 { 00959 } |
|
Definition at line 961 of file cmt_regexp.cxx.
00961 : cmt_regexp_node_set (father) 00962 { 00963 } |
|
Reimplemented from cmt_regexp_node_set. Definition at line 1084 of file cmt_regexp.cxx. References cmt_regexp_node_set::dump(). Referenced by cmt_one_more::dump(), cmt_zero_more::dump(), and cmt_many_node::dump().
01085 { 01086 cmt_regexp_node_set::dump ("and"); 01087 } |
|
Definition at line 1073 of file cmt_regexp.cxx. References cmt_regexp_node_set::_nodes, cmt_regexp_node_set::nodes(), and cmt_regexp_node_set::push(). Referenced by cmt_many_node::install().
01074 { 01075 if ((start_index < 0) || (start_index > other.nodes ())) return; 01076 01077 for (int i = start_index; i < other.nodes (); i++) 01078 { 01079 cmt_regexp_node* n = other._nodes[i]; 01080 push (n); 01081 } 01082 } |
|
Reimplemented from cmt_regexp_node. Definition at line 965 of file cmt_regexp.cxx. References cmt_regexp::iterator::_length, cmt_regexp::iterator::_pos, cmt_regexp_node::match(), cmt_regexp::iterator::null(), cmt_vector< cmt_regexp_node * >::size(), cmt_string::size(), tab(), tab_level, and CmtSystem::testenv(). Referenced by cmt_one_more::match(), and cmt_zero_more::match().
00967 { 00968 if ((pos < 0) || (pos > text.size ())) 00969 { 00970 return (cmt_regexp::iterator::null ()); 00971 } 00972 00973 if (_nodes.size () == 0) return (cmt_regexp::iterator (pos, 0)); 00974 00975 int i; 00976 int total = 0; 00977 int p = pos; 00978 00979 bool dbg = CmtSystem::testenv ("CMTTESTREGEXP"); 00980 if (dbg) {tab (); cout << "match and (" << this << ") pos=" << pos << endl;} 00981 00982 for (i = 0; i < _nodes.size (); i++) 00983 { 00984 cmt_regexp_node* n = _nodes[i]; 00985 00986 if (dbg) tab_level++; 00987 const cmt_regexp::iterator it = n->match (text, p); 00988 if (dbg) tab_level--; 00989 00990 if (dbg) {tab (); cout << " -> it(" << n << ") p=" << it._pos << " l=" << it._length << endl;} 00991 00992 if (it == cmt_regexp::iterator::null ()) return (it); 00993 00994 total += it._length; 00995 p += it._length; 00996 } 00997 00998 // All nodes match 00999 01000 return (cmt_regexp::iterator (pos, total)); 01001 } |
|
Reimplemented from cmt_regexp_node_set. Definition at line 1003 of file cmt_regexp.cxx. References cmt_many_node::install(), cmt_regexp_node::is_char(), cmt_regexp_node::is_many_node(), cmt_vector< T >::push_back(), cmt_many_node::reduce(), cmt_string::size(), and cmt_vector< cmt_regexp_node * >::size(). Referenced by cmt_many_node::reduce().
01004 { 01005 if (_nodes.size () < 2) return; 01006 01007 char c = ' '; 01008 cmt_string s = ""; 01009 cmt_vector<cmt_regexp_node*> new_nodes; 01010 01011 // 01012 // We loop once too much in order to finish the possibly accumulated 01013 // string at the end. 01014 // 01015 for (int i = 0; i <= _nodes.size (); i++) 01016 { 01017 cmt_regexp_node* n = 0; 01018 01019 if (i < _nodes.size ()) n = _nodes[i]; 01020 01021 if ((i >= _nodes.size ()) || (!n->is_char ())) 01022 { 01023 if (s.size () == 1) 01024 { 01025 // 01026 // Too bad there was only one char node to consider 01027 // let's put it back as a char node ! 01028 // 01029 new_nodes.push_back (new cmt_char_node (c)); 01030 s = ""; 01031 } 01032 else if (s.size () > 1) 01033 { 01034 // 01035 // We have real reduction here sonce there was several 01036 // consecutive char nodes. 01037 // 01038 new_nodes.push_back (new cmt_string_node (s)); 01039 s = ""; 01040 } 01041 01042 if (i >= _nodes.size ()) break; 01043 } 01044 01045 if (n->is_char ()) 01046 { 01047 // 01048 // We are now trying to compact those char nodes. 01049 // 01050 cmt_char_node& cn = *((cmt_char_node*) n); 01051 c = (char) cn; 01052 s += c; 01053 delete n; 01054 _nodes[i] = 0; 01055 } 01056 else if (n->is_many_node ()) 01057 { 01058 cmt_many_node& mn = *((cmt_many_node*) n); 01059 mn.install (*this, i + 1); 01060 mn.reduce (); 01061 new_nodes.push_back (n); 01062 break; 01063 } 01064 else 01065 { 01066 new_nodes.push_back (n); 01067 } 01068 } 01069 01070 _nodes = new_nodes; 01071 } |