Mercurial > hg > Applications > Grep
diff regexParser/threadedSearch.cc @ 293:948428caf616
NFA maximum match worked
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 02 Feb 2016 10:38:45 +0900 |
parents | 868f01f1ba8e |
children | 63213964502a |
line wrap: on
line diff
--- a/regexParser/threadedSearch.cc Mon Feb 01 21:52:57 2016 +0900 +++ b/regexParser/threadedSearch.cc Tue Feb 02 10:38:45 2016 +0900 @@ -82,8 +82,12 @@ return state->tState; } +#define DEBUG 0 + TSValue tSearch(TSValue tsv) { - TSValuePtr tsvp = &tsv; +#if DEBUG + TSValuePtr tsvp = &tsv; // make tsv visible in lldb +#endif next: while (tsv.buff.buffptr < tsv.buff.buffend) { unsigned char c = *tsv.buff.buffptr++; // printState(tsv.current->state); @@ -99,21 +103,25 @@ // match the word. // if (not match) continue; } + tsv = tsv.current->stateMatch(tsv); if (ccv->tState) { tsv.current = ccv->tState; } else { tsv.current = nextTState(ccv->state,tsv.tg); ccv->tState = tsv.current; } - tsv = tsv.current->stateMatch(tsv); goto next; } } tsv = tsv.current->stateSkip(tsv); tsv.matchBegin = tsv.buff.buffptr; } +#if DEBUG *tsvp = tsv; return *tsvp; +#else + return tsv; +#endif } void threadedSearch(TransitionGeneratorPtr tg, Buffer buff) { @@ -124,7 +132,8 @@ tsv.tg->stateSkip = stateSkip; tsv.tg->stateMatch = stateMatch; tsv.tg->stateNothing = stateNothing; - tsv.matchBegin = tsv.matchEnd = NULL; + tsv.matchBegin = buff.buffptr; + tsv.matchEnd = NULL; tsv.current = generateTState(tg->stateList,tg); tg->stateStart = NEW(State); *tg->stateStart = *tg->stateList;