Mercurial > hg > Members > masakoha > testcode
changeset 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 |
files | regexParser/main.cc regexParser/node.cc regexParser/regexParser.cc regexParser/regexParser.h regexParser/subsetConstraction.cc |
diffstat | 5 files changed, 13 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/regexParser/main.cc Mon Dec 28 19:02:14 2015 +0900 +++ b/regexParser/main.cc Mon Dec 28 20:32:36 2015 +0900 @@ -16,6 +16,7 @@ } printf("regex : %s\n",ri.ptr); NodePtr n = regex(&ri); + printTree(n); TransitionGeneratorPtr tg = generateTransitionList(n); printTree(n); printState(tg);
--- a/regexParser/node.cc Mon Dec 28 19:02:14 2015 +0900 +++ b/regexParser/node.cc Mon Dec 28 20:32:36 2015 +0900 @@ -17,7 +17,7 @@ break; } } - printf("(%d)\n",cc->stateNum); + printf("(%lx)\n",cc->nextState.bitContainer); if (cc->right) { printCharacterClass(cc->right,nodeNumber,d+1); } @@ -33,7 +33,9 @@ for (int i = 0; i < n->cc->cond.w.length; i++) { putchar(n->cc->cond.w.word[i]); } - printf("(%ld)\n",n->state->bitState.bitContainer); + if (n->state) { + printf("(%ld)\n",n->state->bitState.bitContainer); + } } else if (n->tokenType == 'c') { printCharacterClass(n->cc,n->stateNum,d); } else if (n->tokenType == 'a') {
--- a/regexParser/regexParser.cc Mon Dec 28 19:02:14 2015 +0900 +++ b/regexParser/regexParser.cc Mon Dec 28 20:32:36 2015 +0900 @@ -127,7 +127,6 @@ cc->left = NULL; cc->right = NULL; cc->stateNum = 0; - cc->state = NULL; RangeListPtr rangeList = &cc->cond.range; rangeList->begin = *ri->ptr; rangeList->end = *ri->ptr;
--- a/regexParser/regexParser.h Mon Dec 28 19:02:14 2015 +0900 +++ b/regexParser/regexParser.h Mon Dec 28 20:32:36 2015 +0900 @@ -24,15 +24,12 @@ Word w; } Condition, *ConditionList; -struct state; - typedef struct charClass { unsigned char type; struct charClass *left; struct charClass *right; Condition cond; int stateNum; - struct state *state; BitVector nextState; } CharClass, *CharClassPtr;
--- 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);