Mercurial > hg > Applications > Grep
comparison regexParser/cerium/ppe/Exec.cc @ 292:868f01f1ba8e
maximum match
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 01 Feb 2016 21:52:57 +0900 |
parents | f2491681914e |
children | 948428caf616 |
comparison
equal
deleted
inserted
replaced
291:1b75546ff65f | 292:868f01f1ba8e |
---|---|
10 /* これは必須 */ | 10 /* これは必須 */ |
11 SchedDefineTask1(Exec,blockedGrep); | 11 SchedDefineTask1(Exec,blockedGrep); |
12 | 12 |
13 TSValue blockSearch(TransitionGeneratorPtr tg,Buffer buff,int task_spawned) { | 13 TSValue blockSearch(TransitionGeneratorPtr tg,Buffer buff,int task_spawned) { |
14 TSValue tsv; | 14 TSValue tsv; |
15 BlockOutput blk; | |
15 tsv.buff = buff; | 16 tsv.buff = buff; |
16 tsv.tg = tg; | 17 tsv.tg = tg; |
18 tsv.blk = &blk; | |
17 if (task_spawned == 0) { | 19 if (task_spawned == 0) { |
18 tsv.current = tg->stateStart->tState; | 20 tsv.current = tg->stateStart->tState; |
19 } else { | 21 } else { |
20 tsv.current = tg->anyState->tState; | 22 tsv.current = tg->anyState->tState; |
21 } | 23 } |
22 tsv.result = NULL; | 24 tsv.blk->result = NULL; |
23 ResultPtr result = NULL; | 25 ResultPtr result = NULL; |
24 tsv.resultEnd = &result; | 26 tsv.blk->resultEnd = &result; |
25 unsigned char *end = tsv.buff.buffend; | 27 unsigned char *end = tsv.buff.buffend; |
26 tsv.buff.buffend = tsv.buff.buff+1; | 28 tsv.buff.buffend = tsv.buff.buff+1; |
29 tsv.matchBegin = NULL; | |
30 tsv.matchEnd = NULL; | |
27 tsv = tSearch(tsv); | 31 tsv = tSearch(tsv); |
28 tsv.blockBegin = tsv.current; | 32 tsv.blk->blockBegin = tsv.current; |
29 tsv.buff.buffend = end; | 33 tsv.buff.buffend = end; |
30 tsv = tSearch(tsv); | 34 tsv = tSearch(tsv); |
31 tsv.blockEnd = tsv.current; | 35 tsv.blk->blockEnd = tsv.current; |
32 if (tsv.blockEnd->state->bitState.bitContainer != 1) { | 36 if (tsv.blk->blockEnd->state->bitState.bitContainer != 1) { |
33 if (tsv.buff.matchBegin != tsv.buff.buffptr) { | 37 if (tsv.matchBegin != tsv.buff.buffptr) { |
34 // partial match case at block end. | 38 // partial match case at block end. |
35 ResultPtr r = NEW(Result); | 39 ResultPtr r = NEW(Result); |
36 r->continued = true; | 40 r->continued = true; |
37 r->begin = tsv.buff.matchBegin; | 41 r->begin = tsv.matchBegin; |
38 r->end = tsv.buff.buffptr; | 42 r->end = tsv.buff.buffptr; |
39 *tsv.resultEnd = r; | 43 *tsv.blk->resultEnd = r; |
40 r->next = NULL; | 44 r->next = NULL; |
41 tsv.resultEnd = &r->next; | 45 tsv.blk->resultEnd = &r->next; |
42 // printf("Exec %lx r->begin : %p r->end : %p\n",tsv.blockEnd->state->bitState.bitContainer, r->begin,r->end); | 46 // printf("Exec %lx r->begin : %p r->end : %p\n",tsv.blockEnd->state->bitState.bitContainer, r->begin,r->end); |
43 } | 47 } |
44 } | 48 } |
45 tsv.result = result; | 49 tsv.blk->result = result; |
46 return tsv; | 50 return tsv; |
47 } | 51 } |
48 | 52 |
49 static int | 53 static int |
50 blockedGrep(SchedTask *s, void *rbuf, void *wbuf) | 54 blockedGrep(SchedTask *s, void *rbuf, void *wbuf) |
64 i_data = (unsigned char*)s->get_input(0); | 68 i_data = (unsigned char*)s->get_input(0); |
65 o_data = (unsigned long *)s->get_output(0); | 69 o_data = (unsigned long *)s->get_output(0); |
66 } | 70 } |
67 TransitionGeneratorPtr tg = (TransitionGeneratorPtr)w->global; | 71 TransitionGeneratorPtr tg = (TransitionGeneratorPtr)w->global; |
68 Buffer buff; | 72 Buffer buff; |
69 buff.buff = buff.buffptr = buff.matchBegin = i_data; | 73 buff.buff = buff.buffptr = i_data; |
70 buff.buffend = buff.buff + length; | 74 buff.buffend = buff.buff + length; |
71 TSValue tsv = blockSearch(tg,buff,task_spawned); | 75 TSValue tsv = blockSearch(tg,buff,task_spawned); |
72 // resultPrint(tsv.result,"Exec"); | 76 // resultPrint(tsv.result,"Exec"); |
73 o_data[0] = (unsigned long)tsv.result; | 77 o_data[0] = (unsigned long)tsv.blk->result; |
74 o_data[1] = (unsigned long)tsv.blockBegin->state; | 78 o_data[1] = (unsigned long)tsv.blk->blockBegin->state; |
75 o_data[2] = (unsigned long)tsv.blockEnd->state; | 79 o_data[2] = (unsigned long)tsv.blk->blockEnd->state; |
76 return 0; | 80 return 0; |
77 } | 81 } |