Mercurial > hg > Members > masakoha > testcode
diff regexParser/subsetConstraction.cc @ 214:a94f57af1600
remove allocateCCstate createCCState
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 28 Dec 2015 20:32:36 +0900 |
parents | 11b6332f0a42 |
children | 63e9224c7b2b |
line wrap: on
line diff
--- a/regexParser/subsetConstraction.cc Mon Dec 28 19:02:14 2015 +0900 +++ b/regexParser/subsetConstraction.cc Mon Dec 28 20:32:36 2015 +0900 @@ -195,28 +195,6 @@ bitvector を index とした配列に BitVectorPtr を格納 state に対応する NodePtr を */ -StatePtr createCCState(CharClassPtr cc,TGValue tgv) { - StatePtr s = NEW(State); - s->stateNum = cc->stateNum = ++tgv.tg->totalStateCount; - s->next = tgv.tg->stateList; - tgv.tg->stateList = s; - BitVector bi = createBitVector(cc->stateNum); - s->bitState = bi; - s->cc = cc; - return s; -} - -CharClassPtr allocateCCState(CharClassPtr cc, TGValue tgv) { - if (cc->left) { - allocateCCState(cc->left,tgv); - } - cc->state = createCCState(cc,tgv); - if (cc->right) { - allocateCCState(cc->right,tgv); - } - return cc; -} - StatePtr createState(TGValue tgv,NodePtr n) { StatePtr s = NEW(State); s->stateNum = n->stateNum = tgv.tg->totalStateCount; @@ -225,11 +203,7 @@ s->node = n; BitVector bi = createBitVector(n->stateNum); s->bitState = bi; - if (n->cc) { - allocateCCState(n->cc,tgv); - } else { - tgv.tg->totalStateCount++; - } + tgv.tg->totalStateCount++; s->cc = n->cc; return s; } @@ -252,8 +226,9 @@ TGValue tgvRight = tgvLeft; n->right->state = createState(tgvRight,n->right); tgvRight.startState = n->right->state; - stateAllocate(n->right,tgvRight); - return tgvLeft; + tgvRight.asterisk = false; + tgvRight = stateAllocate(n->right,tgvRight); + return tgvRight; } else if (n->tokenType == '|') { TGValue tgv1 = stateAllocate(n->left,tgv); TGValue tgv2 = stateAllocate(n->right,tgv1); @@ -292,12 +267,13 @@ tgvRight.asterisk = true; return tgvRight; } + TGValue tgvRight = tgvLeft; StatePtr left = tgvLeft.startState; tgvLeft.startState = n->right->state; tgvLeft.tg->stateArray[tgvLeft.startState->bitState.bitContainer] = left; - TGValue tgv1 = generateTransition(n->right,tgvLeft); - tgv1.startState = left; - return tgv1; + tgvRight.asterisk = false; + tgvRight = generateTransition(n->right,tgvRight); + return tgvRight; } else if (n->tokenType == '|') { TGValue tgv1 = generateTransition(n->left,tgv); TGValue tgv2 = generateTransition(n->right,tgv1);