Mercurial > hg > Applications > Grep
diff regexParser/threadedSearch.cc @ 248:2b1fbfb92d54
implement tSearch
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 22 Jan 2016 20:09:42 +0900 |
parents | 96c2507fd22d |
children | e22e3475f664 |
line wrap: on
line diff
--- a/regexParser/threadedSearch.cc Fri Jan 22 18:37:04 2016 +0900 +++ b/regexParser/threadedSearch.cc Fri Jan 22 20:09:42 2016 +0900 @@ -4,39 +4,6 @@ #include "regexParser.h" #include "subsetConstruction.h" -struct tsValue; - -typedef struct ccv { - unsigned long begin; - unsigned long end; - BitVector state; - struct tState *tState; -} *CCV; - -void stateSkip(TSValue tsv); - -typedef struct tState { - State *state; - void stateSkip(tsValue); - int ccvSize; - CCV ccv; -} TState, *TStatePtr; - -typedef struct result { - unsigned char begin; - unsigned char end; - struct result *next; -} Result, *ResultPtr; - -typedef struct tsValue { - Buffer buff; - ResultPtr result; - State *stateArray; - TState *current; - TState *blockBegin; - TState *blockEnd; -} TSValue, *TSValuePtr; - void stateSkip(TSValue tsv) { tsv.buff.matchBegin = tsv.buff.buffptr; tsv.current->stateSkip(tsv); @@ -63,6 +30,7 @@ ccv->end = end; ccv->tState = NULL; ccv->state = cc->nextState; + ccv->w = cc->cond.w; } free(ccw); return tState; @@ -72,14 +40,32 @@ next: while (tsv.buff.buffptr < tsv.buff.buffend) { unsigned char c = *tsv.buff.buffptr++; for (int i = 0; i < tsv.current->ccvSize; i++) { - if (c<tsv.current->ccv[i].begin) tsv.current->stateSkip(tsv); - else if (c<=tsv.current->ccv[i].end) { - TStatePtr current = tsv.current->ccv[i].tState; + CCVPtr ccv = &tsv.current->ccv[i]; + if (c<ccv->begin) tsv.current->stateSkip(tsv); + else if (c<=ccv->end) { + // range matched. + if (ccv->w) { + // match the word. + // if (not match) continue; + } + TStatePtr current = ccv->tState; if (current == NULL) { - current = generateTState(tsv.stateArray[tsv.current->ccv[i].state.bitContainer]); - tsv.current->ccv[i].tState = current; + // create tSearch in next state. + StatePtr state = tsv.stateArray[ccv->state.bitContainer]; + if (state == NULL) { + // on the fly subset construction. + state = createState(tg,bi); + tg->stateArray[bi.bitContainer] = state; + determinize(state,tsv.tg); + } + if (state->tState == NULL) { + current = generateTState(state); + ccv->tState = current; + } else { + ccv->tState = state->tState; + } } - tsv.current = tsv.current->ccv[i].tState; + tsv.current = ccv->tState; goto next; } }