comparison regexParser/subsetConstruction.cc @ 241:87ad91af8a15

turn initialization in charclasswalk
author Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
date Wed, 20 Jan 2016 20:28:40 +0900
parents f5931151d70c
children 7189d24dd45e
comparison
equal deleted inserted replaced
240:6ed6f385205e 241:87ad91af8a15
122 122
123 CharClassWalkerPtr createCharClassWalker (CharClassPtr next) { 123 CharClassWalkerPtr createCharClassWalker (CharClassPtr next) {
124 CharClassWalkerPtr walk = NEW(CharClassWalker); 124 CharClassWalkerPtr walk = NEW(CharClassWalker);
125 walk->next = NULL; 125 walk->next = NULL;
126 walk->stack = NULL; 126 walk->stack = NULL;
127 walk->turn = LEFT;
127 if (!next) return walk; 128 if (!next) return walk;
128 findLeftMost(next,walk); 129 findLeftMost(next,walk);
129 return walk; 130 return walk;
130 } 131 }
131 132
223 */ 224 */
224 TGValue generateTransition(NodePtr n,TGValue tgv, int pass) { 225 TGValue generateTransition(NodePtr n,TGValue tgv, int pass) {
225 if (n->tokenType == '+') { 226 if (n->tokenType == '+') {
226 TGValue tgvLeft = tgv; 227 TGValue tgvLeft = tgv;
227 tgvLeft.endState = n->right->state; 228 tgvLeft.endState = n->right->state;
229 if (pass==2) n->right->state->accept = tgv.endState->accept;
228 tgvLeft.asterisk = NULL; 230 tgvLeft.asterisk = NULL;
229 tgvLeft = generateTransition(n->left,tgvLeft,pass); 231 tgvLeft = generateTransition(n->left,tgvLeft,pass);
230 TGValue tgvRight = tgv; 232 TGValue tgvRight = tgv;
231 if (tgvLeft.asterisk) { 233 if (tgvLeft.asterisk) {
232 n->right->state = tgv.endState; 234 n->right->state = tgv.endState;
391 } 393 }
392 CharClassPtr merge = mergeTransition(s,base->cc); 394 CharClassPtr merge = mergeTransition(s,base->cc);
393 s->cc = merge; 395 s->cc = merge;
394 } 396 }
395 } 397 }
398 free(cw);
396 } 399 }
397 return scv; 400 return scv;
398 } 401 }