Mercurial > hg > Members > masakoha > testcode
changeset 220:4dc8d327cc7d
subset construction worked
how to handle EOF?
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 02 Jan 2016 00:01:22 +0900 |
parents | a8e477f1352d |
children | 78174ff2f338 |
files | regexParser/regexParser.h regexParser/subsetConstruction.cc |
diffstat | 2 files changed, 13 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/regexParser/regexParser.h Fri Jan 01 00:05:57 2016 +0900 +++ b/regexParser/regexParser.h Sat Jan 02 00:01:22 2016 +0900 @@ -66,10 +66,11 @@ StatePtr stateList; } TransitionGenerator, *TransitionGeneratorPtr; +// Value Container is passed directly in functions +// Don't use it's pointer typedef struct scValue { StatePtr stateTop; StatePtr stateEnd; - StatePtr *stateArray; TransitionGeneratorPtr tg; } SCValue, *SCValuePtr;
--- a/regexParser/subsetConstruction.cc Fri Jan 01 00:05:57 2016 +0900 +++ b/regexParser/subsetConstruction.cc Sat Jan 02 00:01:22 2016 +0900 @@ -335,6 +335,7 @@ SCValue createSCValue(TGValue tgv) { SCValue scv; + scv.tg = tgv.tg; scv.stateTop = tgv.tg->stateList; scv.stateEnd = scv.stateTop; while (scv.stateEnd->next) { @@ -368,21 +369,24 @@ while (hasNext(cw)) { CharClassPtr cc = getNext(cw); BitVector bi = cc->nextState; - if (scv.stateArray[bi.bitContainer]) continue; + if (scv.tg->stateArray[bi.bitContainer]) continue; // already done scv = createState(scv,bi); StatePtr s = scv.stateEnd; - for (;bi.bitContainer;) { + scv.tg->stateArray[bi.bitContainer] = s; + for (;;) { int bitPosition = searchBit(bi); - unsigned long baseNum = 1 << bitPosition; + if (!bitPosition) break; + unsigned long baseNum = 1 << (bitPosition-1); + // printf("bit %lx pos %d baseNum %lx\n",bi.bitContainer,bitPosition,baseNum); bi.bitContainer ^= baseNum; - StatePtr base = scv.stateArray[baseNum]; - if (base == NULL) {// error - continue; + if (baseNum==2) continue; // EOF case + StatePtr base = scv.tg->stateArray[baseNum]; + if (base == NULL) { + errorMassege("No base state",__LINE__,__FILE__); break; } CharClassPtr merge = mergeTransition(s,base->cc); s->cc = merge; } - scv.stateArray[bi.bitContainer] = s; } } return scv;