Mercurial > hg > Members > masakoha > testcode
diff regexParser/subsetConstruction.cc @ 239:f5931151d70c
add accept flag
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 20 Jan 2016 18:05:19 +0900 |
parents | 5d66672e5029 |
children | 87ad91af8a15 |
line wrap: on
line diff
--- a/regexParser/subsetConstruction.cc Wed Jan 20 08:58:35 2016 +0900 +++ b/regexParser/subsetConstruction.cc Wed Jan 20 18:05:19 2016 +0900 @@ -204,6 +204,7 @@ s->node = n; BitVector bi = createBitVector(n->stateNum); s->bitState = bi; + s->accept = false; tgv.tg->totalStateCount++; s->cc = n->cc; return s; @@ -251,6 +252,7 @@ } else if (n->tokenType == '*') { TGValue tgvAstah = tgv; tgvAstah.endState = tgvAstah.startState; + if (pass==2) tgvAstah.endState->accept = tgv.endState->accept; tgvAstah = generateTransition(n->left,tgvAstah,pass); tgvAstah.asterisk = tgvAstah.startState; return tgvAstah; @@ -264,6 +266,7 @@ n->nextStateNum = nextState; n->nextState = tgv.endState; BitVector bi = createBitVector(nextState); + if (n->nextState->accept) bi = bitSet(bi,1); setState(n->cc,bi); tgv1.startState->cc = mergeTransition(tgv1.startState,n->cc); } @@ -296,6 +299,7 @@ StatePtr startState = tgv.startState = createState(tgv,n); NodePtr eof = createNode(NULL,'e',NULL,NULL,NULL); StatePtr endState = tgv.endState = createState(tgv,eof); + endState->accept = true; tgv.startState = startState; tgv.endState = endState; tgv = generateTransition(n,tgv,1);