Mercurial > hg > Members > masakoha > testcode
comparison regexParser/threadedSearch.cc @ 263:292753bb31e4
fix Makefile
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 27 Jan 2016 16:37:42 +0900 |
parents | 157f6886ba55 |
children | ef95a7f1bc03 |
comparison
equal
deleted
inserted
replaced
262:157f6886ba55 | 263:292753bb31e4 |
---|---|
7 | 7 |
8 void tSearch(TSValue tsv); | 8 void tSearch(TSValue tsv); |
9 | 9 |
10 void stateSkip(TSValue tsv) { | 10 void stateSkip(TSValue tsv) { |
11 tsv.buff.matchBegin = tsv.buff.buffptr; | 11 tsv.buff.matchBegin = tsv.buff.buffptr; |
12 tSearch(tsv); | |
13 } | 12 } |
14 | 13 |
15 void stateMatch(TSValue tsv) { | 14 void stateMatch(TSValue tsv) { |
16 fwrite(tsv.buff.matchBegin,tsv.buff.buffptr-tsv.buff.matchBegin,1,stdout); | 15 fwrite(tsv.buff.matchBegin,tsv.buff.buffptr-tsv.buff.matchBegin-1,1,stdout); |
17 puts("\n"); | 16 puts("\n"); |
18 stateSkip(tsv); | |
19 } | 17 } |
20 | 18 |
21 TStatePtr generateTState(StatePtr state) { | 19 TStatePtr generateTState(StatePtr state) { |
22 TStatePtr tState = NEW(TState); | 20 TStatePtr tState = NEW(TState); |
23 int ccvSize = 0; | 21 int ccvSize = 0; |
24 CharClassWalkerPtr ccw = createCharClassWalker(state->cc); | 22 CharClassWalkerPtr ccw = createCharClassWalker(state->cc); |
25 while (hasNext(ccw)) { | 23 while (hasNext(ccw)) { |
24 getNext(ccw); | |
26 ccvSize++; | 25 ccvSize++; |
27 } | 26 } |
27 tState->ccvSize = ccvSize; | |
28 if (ccvSize == 0) return tState; | 28 if (ccvSize == 0) return tState; |
29 else tState->ccv = (ccv*)malloc(sizeof(ccv)*ccvSize); | 29 else tState->ccv = (ccv*)malloc(sizeof(ccv)*ccvSize); |
30 ccw = createCharClassWalker(state->cc); | 30 ccw = createCharClassWalker(state->cc); |
31 int i = 0; | 31 int i = 0; |
32 while (hasNext(ccw)) { | 32 while (hasNext(ccw)) { |
39 ccv->tState = NULL; | 39 ccv->tState = NULL; |
40 ccv->state = cc->nextState; | 40 ccv->state = cc->nextState; |
41 ccv->w = cc->cond.w; | 41 ccv->w = cc->cond.w; |
42 } | 42 } |
43 free(ccw); | 43 free(ccw); |
44 if (state->accept) { | |
45 tState->stateSkip = stateMatch; | |
46 tState->stateMatch = stateSkip; | |
47 } else { | |
48 tState->stateSkip = stateSkip; | |
49 tState->stateMatch = stateMatch; | |
50 } | |
44 return tState; | 51 return tState; |
45 } | 52 } |
46 | 53 |
47 void tSearch(TSValue tsv) { | 54 void tSearch(TSValue tsv) { |
48 next: while (tsv.buff.buffptr < tsv.buff.buffend) { | 55 next: while (tsv.buff.buffptr < tsv.buff.buffend) { |
89 void threadedSearch(TransitionGeneratorPtr tg, Buffer buff) { | 96 void threadedSearch(TransitionGeneratorPtr tg, Buffer buff) { |
90 TSValue tsv; | 97 TSValue tsv; |
91 tsv.buff = buff; | 98 tsv.buff = buff; |
92 tsv.tg = tg; | 99 tsv.tg = tg; |
93 tsv.current = generateTState(tg->stateList); | 100 tsv.current = generateTState(tg->stateList); |
94 stateSkip(tsv); | 101 tSearch(tsv); |
95 } | 102 } |