# HG changeset patch # User Shinji KONO # Date 1451660482 -32400 # Node ID 4dc8d327cc7d7c3d8295935a8a0010dea015d3ff # Parent a8e477f1352d9a4a4e9a214678e00b34e3cdec9b subset construction worked how to handle EOF? diff -r a8e477f1352d -r 4dc8d327cc7d regexParser/regexParser.h --- 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; diff -r a8e477f1352d -r 4dc8d327cc7d regexParser/subsetConstruction.cc --- 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;