Mercurial > hg > Members > masakoha > testcode
changeset 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 |
files | regexParser/subsetConstraction.cc regexParser/test/ccMerge.cc |
diffstat | 2 files changed, 15 insertions(+), 12 deletions(-) [+] |
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; }
--- a/regexParser/test/ccMerge.cc Mon Dec 28 16:42:02 2015 +0900 +++ b/regexParser/test/ccMerge.cc Mon Dec 28 19:02:14 2015 +0900 @@ -19,15 +19,15 @@ int main(int argc, char **argv) { - RegexInfo riRegex; + RegexInfo ri; NodePtr n = NULL; StatePtr s = NULL; TGValue tgv = createTGValue(); for (int i = 1; i < argc; i++) { if (strcmp(argv[i],"-regex") == 0) { - riRegex.ptr = (unsigned char*)argv[i+1]; i++; - printf("regex : %s\n",riRegex.ptr); - NodePtr nMerge = regex(&riRegex); + ri.ptr = (unsigned char*)argv[i+1]; i++; + printf("regex : %s\n",ri.ptr); + NodePtr nMerge = regex(&ri); StatePtr sMerge = createState(tgv,nMerge); setState(sMerge->cc,sMerge->bitState); if (s == NULL) {