Mercurial > hg > Members > masakoha > testcode
changeset 288:f2491681914e
special state for start search
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 01 Feb 2016 01:35:12 +0900 |
parents | 2f3e7bba038e |
children | 20ed7536784f |
files | regexParser/cerium/CeriumMain.cc regexParser/cerium/ppe/Exec.cc regexParser/generateSequentialSearch.cc regexParser/regexParser.h regexParser/threadedSearch.cc |
diffstat | 5 files changed, 18 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/regexParser/cerium/CeriumMain.cc Sun Jan 31 22:59:59 2016 +0900 +++ b/regexParser/cerium/CeriumMain.cc Mon Feb 01 01:35:12 2016 +0900 @@ -29,7 +29,7 @@ static TSValue stateSkip(TSValue tsv) { - tsv.current = tsv.tg->stateList->tState; + tsv.current = tsv.tg->stateStart->tState; tsv.buff.matchBegin = tsv.buff.buffptr; return tsv; } @@ -43,7 +43,6 @@ *tsv.resultEnd = r; r->next = NULL; tsv.resultEnd = &r->next; - tsv.current = tsv.tg->stateList->tState; tsv.buff.buffptr--; tsv = stateSkip(tsv); return tsv; @@ -63,7 +62,8 @@ return prev; } -void ceriumCreateAnyState(TransitionGeneratorPtr tg) { +void +ceriumCreateAnyState(TransitionGeneratorPtr tg) { tg->stateSkip = stateSkip; tg->stateMatch = stateMatch; tg->stateNothing = stateNothing; @@ -71,6 +71,10 @@ generateTState(tg->anyState,tg); // generateTState for startState. It is used in stateMatch. generateTState(tg->stateList,tg); + tg->stateStart = NEW(State); + *tg->stateStart = *tg->stateList; + tg->stateStart->accept = false; // Start state never accept + generateTState(tg->stateStart,tg); } int
--- a/regexParser/cerium/ppe/Exec.cc Sun Jan 31 22:59:59 2016 +0900 +++ b/regexParser/cerium/ppe/Exec.cc Mon Feb 01 01:35:12 2016 +0900 @@ -15,7 +15,7 @@ tsv.buff = buff; tsv.tg = tg; if (task_spawned == 0) { - tsv.current = tg->stateList->tState; + tsv.current = tg->stateStart->tState; } else { tsv.current = tg->anyState->tState; }
--- a/regexParser/generateSequentialSearch.cc Sun Jan 31 22:59:59 2016 +0900 +++ b/regexParser/generateSequentialSearch.cc Mon Feb 01 01:35:12 2016 +0900 @@ -39,7 +39,7 @@ if (begin == end) { fprintf(fp,"if (c=='%c') state%lx(buff);\n",(unsigned char)begin, bi.bitContainer); } else { - if (state->bitState.bitContainer & 2) { + if (state->accept) { fprintf(fp,"if (c<'%c') stateMatch(buff);\n",(unsigned char)begin); } else { fprintf(fp,"if (c<'%c') stateSkip(buff);\n",(unsigned char)begin);
--- a/regexParser/regexParser.h Sun Jan 31 22:59:59 2016 +0900 +++ b/regexParser/regexParser.h Mon Feb 01 01:35:12 2016 +0900 @@ -94,6 +94,7 @@ long totalBasicState; StateStackPtr stack; StatePtr stateEnd; + StatePtr stateStart; // start state without accept flag StatePtr *stateArray; StatePtr stateList; StatePtr anyState; @@ -121,7 +122,7 @@ typedef struct tgValue { StatePtr asterisk; // last * state of the expression - StatePtr startState; + StatePtr startState; // startState of the expression StatePtr endState; TransitionGeneratorPtr tg; } TGValue, *TGValuePtr;
--- a/regexParser/threadedSearch.cc Sun Jan 31 22:59:59 2016 +0900 +++ b/regexParser/threadedSearch.cc Mon Feb 01 01:35:12 2016 +0900 @@ -12,7 +12,7 @@ static TSValue stateSkip(TSValue tsv) { - tsv.current = tsv.tg->stateList->tState; + tsv.current = tsv.tg->stateStart->tState; tsv.buff.matchBegin = tsv.buff.buffptr; return tsv; } @@ -21,7 +21,6 @@ TSValue stateMatch(TSValue tsv) { fwrite(tsv.buff.matchBegin,tsv.buff.buffptr-tsv.buff.matchBegin-1,1,stdout); puts(""); - tsv.current = tsv.tg->stateList->tState; tsv.buff.buffptr--; tsv = stateSkip(tsv); return tsv; @@ -37,7 +36,7 @@ ccvSize++; } tState->ccvSize = ccvSize; - if (state->accept) { + if (state->accept && state != tg->stateList ) { tState->stateSkip = tg->stateMatch; tState->stateContinue = tg->stateNothing; } else { @@ -123,5 +122,10 @@ tsv.tg->stateMatch = stateMatch; tsv.tg->stateNothing = stateNothing; tsv.current = generateTState(tg->stateList,tg); + tg->stateStart = NEW(State); + *tg->stateStart = *tg->stateList; + tg->stateStart->accept = false; // Start state never accept + generateTState(tg->stateStart,tg); + tSearch(tsv); }