comparison regexParser/threadedSearch.cc @ 251:e22e3475f664

fix
author Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
date Sat, 23 Jan 2016 14:10:28 +0900
parents 2b1fbfb92d54
children 2b276fdd99bd
comparison
equal deleted inserted replaced
250:e60dd2fa3409 251:e22e3475f664
7 void stateSkip(TSValue tsv) { 7 void stateSkip(TSValue tsv) {
8 tsv.buff.matchBegin = tsv.buff.buffptr; 8 tsv.buff.matchBegin = tsv.buff.buffptr;
9 tsv.current->stateSkip(tsv); 9 tsv.current->stateSkip(tsv);
10 } 10 }
11 11
12 TStatePtr generateTState(State state) { 12 TStatePtr generateTState(StatePtr state) {
13 TStatePtr tState = NEW(TState); 13 TStatePtr tState = NEW(TState);
14 int ccvSize = 0; 14 int ccvSize = 0;
15 CharClassWalkerPtr ccw = createCharClassWalker(state.cc); 15 CharClassWalkerPtr ccw = createCharClassWalker(state->cc);
16 while (hasNext(ccw)) { 16 while (hasNext(ccw)) {
17 CharClassPtr cc = getNext(ccw); 17 CharClassPtr cc = getNext(ccw);
18 ccvSize++; 18 ccvSize++;
19 } 19 }
20 if (ccvSize == 0) return tState; 20 if (ccvSize == 0) return tState;
21 else tState->ccv = (ccv*)malloc(sizeof(ccv)*ccvSize); 21 else tState->ccv = (ccv*)malloc(sizeof(ccv)*ccvSize);
22 ccw = createCharClassWalker(state.cc); 22 ccw = createCharClassWalker(state->cc);
23 int i = 0; 23 int i = 0;
24 while (hasNext(ccw)) { 24 while (hasNext(ccw)) {
25 CharClassPtr cc = getNext(ccw); 25 CharClassPtr cc = getNext(ccw);
26 unsigned long begin = cc->cond.range.begin; 26 unsigned long begin = cc->cond.range.begin;
27 unsigned long end = cc->cond.range.end; 27 unsigned long end = cc->cond.range.end;
42 for (int i = 0; i < tsv.current->ccvSize; i++) { 42 for (int i = 0; i < tsv.current->ccvSize; i++) {
43 CCVPtr ccv = &tsv.current->ccv[i]; 43 CCVPtr ccv = &tsv.current->ccv[i];
44 if (c<ccv->begin) tsv.current->stateSkip(tsv); 44 if (c<ccv->begin) tsv.current->stateSkip(tsv);
45 else if (c<=ccv->end) { 45 else if (c<=ccv->end) {
46 // range matched. 46 // range matched.
47 if (ccv->w) { 47 if (ccv->w.word) {
48 // match the word. 48 // match the word.
49 // if (not match) continue; 49 // if (not match) continue;
50 } 50 }
51 TStatePtr current = ccv->tState; 51 TStatePtr current = ccv->tState;
52 if (current == NULL) { 52 if (current == NULL) {
53 // create tSearch in next state. 53 // create tSearch in next state.
54 StatePtr state = tsv.stateArray[ccv->state.bitContainer]; 54 StatePtr state = tsv.tg->stateArray[ccv->state.bitContainer];
55 if (state == NULL) { 55 if (state == NULL) {
56 // on the fly subset construction. 56 // on the fly subset construction.
57 state = createState(tg,bi); 57 state = createState(tsv.tg,bi);
58 tg->stateArray[bi.bitContainer] = state; 58 tsv.tg->stateArray[bi.bitContainer] = state;
59 determinize(state,tsv.tg); 59 determinize(state,tsv.tg);
60 } 60 }
61 if (state->tState == NULL) { 61 if (state->tState == NULL) {
62 current = generateTState(state); 62 current = generateTState(state);
63 ccv->tState = current; 63 ccv->tState = current;