comparison regexParser/subsetConstraction.cc @ 181:3c4db09b8581 pairPro

change return value findLeftMost()
author Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
date Thu, 24 Dec 2015 18:00:55 +0900 (2015-12-24)
parents d97bcab546e8
children dbe004d03ef0
comparison
equal deleted inserted replaced
180:d97bcab546e8 181:3c4db09b8581
110 printf("charClassMerge Error : begin %lu end %lu cc->begin %lu cc->end %lu\n", begin,end,cc->cond.range.begin,cc->cond.range.end); 110 printf("charClassMerge Error : begin %lu end %lu cc->begin %lu cc->end %lu\n", begin,end,cc->cond.range.begin,cc->cond.range.end);
111 } 111 }
112 return cc; 112 return cc;
113 } 113 }
114 114
115 CharClassWalkerPtr findLeftMost(CharClassPtr next,CharClassWalkerPtr walk) { 115 void findLeftMost(CharClassPtr next,CharClassWalkerPtr walk) {
116 while (next->left) { 116 while (next->left) {
117 CharClassStackPtr ccs = NEW(CharClassStack); 117 CharClassStackPtr ccs = NEW(CharClassStack);
118 ccs->next = walk->stack; 118 ccs->next = walk->stack;
119 ccs->turn = LEFT; 119 ccs->turn = LEFT;
120 ccs->cc = next; 120 ccs->cc = next;
121 walk->stack = ccs; 121 walk->stack = ccs;
122 next = next->left; 122 next = next->left;
123 } 123 }
124 walk->next = next; 124 walk->next = next;
125 return walk;
126 } 125 }
127 126
128 CharClassWalkerPtr createCharClassWalker (CharClassPtr next) { 127 CharClassWalkerPtr createCharClassWalker (CharClassPtr next) {
129 CharClassWalkerPtr walk = NEW(CharClassWalker); 128 CharClassWalkerPtr walk = NEW(CharClassWalker);
130 walk->next = NULL; 129 walk->next = NULL;
132 if (!next) return walk; 131 if (!next) return walk;
133 if (!next->left) { 132 if (!next->left) {
134 walk->next = next; 133 walk->next = next;
135 return walk; 134 return walk;
136 } 135 }
137 walk = findLeftMost(next,walk); 136 findLeftMost(next,walk);
138 return walk; 137 return walk;
139 } 138 }
140 139
141 bool hasNext(CharClassWalkerPtr walk) { 140 bool hasNext(CharClassWalkerPtr walk) {
142 return walk->next != NULL; 141 return walk->next != NULL;
161 return current; 160 return current;
162 } 161 }
163 } 162 }
164 if (walk->stack->turn == LEFT) { 163 if (walk->stack->turn == LEFT) {
165 walk->next = walk->stack->cc; 164 walk->next = walk->stack->cc;
166 walk->stack->tuen == SELF; 165 walk->stack->turn = SELF;
167 return current; 166 return current;
168 } 167 }
169 if (current->right) { 168 if (current->right) {
170 walk->stack->turn = RIGHT; 169 walk->stack->turn = RIGHT;
171 walk->next = findLeftMost(current->right,walk); 170 findLeftMost(current->right,walk);
172 return current; 171 return current;
173 } 172 }
174 charClassStackPop(walk); 173 charClassStackPop(walk);
175 } 174 }
176 return current; 175 return current;