Mercurial > hg > Applications > Grep
diff regexParser/subsetConstraction.cc @ 213:11b6332f0a42
fix tgv.tg->totalStateCount increment
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 28 Dec 2015 19:02:14 +0900 |
parents | b0ae5273925c |
children | a94f57af1600 |
line wrap: on
line diff
--- a/regexParser/subsetConstraction.cc Mon Dec 28 16:42:02 2015 +0900 +++ b/regexParser/subsetConstraction.cc Mon Dec 28 19:02:14 2015 +0900 @@ -207,11 +207,11 @@ } CharClassPtr allocateCCState(CharClassPtr cc, TGValue tgv) { - if (cc->left != NULL) { + if (cc->left) { allocateCCState(cc->left,tgv); } cc->state = createCCState(cc,tgv); - if (cc->right != NULL) { + if (cc->right) { allocateCCState(cc->right,tgv); } return cc; @@ -219,14 +219,16 @@ StatePtr createState(TGValue tgv,NodePtr n) { StatePtr s = NEW(State); - s->stateNum = n->stateNum = ++tgv.tg->totalStateCount; + s->stateNum = n->stateNum = tgv.tg->totalStateCount; s->next = tgv.tg->stateList; tgv.tg->stateList = s; s->node = n; BitVector bi = createBitVector(n->stateNum); s->bitState = bi; if (n->cc) { - CharClassPtr cc = allocateCCState(n->cc,tgv); + allocateCCState(n->cc,tgv); + } else { + tgv.tg->totalStateCount++; } s->cc = n->cc; return s; @@ -267,7 +269,7 @@ tgv1.asterisk = false; n->stateNum = tgv.startState->stateNum; n->nextStateNum = tgv.endState->stateNum; - n->state = tgv.startState; + n->state = tgv.startState;; n->nextState = tgv.endState; return tgv1; } else { @@ -318,7 +320,7 @@ TransitionGeneratorPtr createTransitionGenerator() { TransitionGeneratorPtr tg = NEW(TransitionGenerator); - tg->totalStateCount = -1; + tg->totalStateCount = 0; tg->stack = NULL; tg->stateArray = NULL; tg->stateList = NULL; @@ -326,10 +328,11 @@ } TGValue createTGValue() { - TransitionGeneratorPtr tg = createTransitionGenerator(); TGValue tgv; + tgv.startState = NULL; + tgv.endState = NULL; tgv.asterisk = false; - tgv.tg = tg; + tgv.tg = createTransitionGenerator(); return tgv; }