comparison regexParser/cerium/CeriumMain.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
28 } 28 }
29 29
30 static 30 static
31 TSValue stateSkip(TSValue tsv) { 31 TSValue stateSkip(TSValue tsv) {
32 tsv.current = tsv.tg->stateStart->tState; 32 tsv.current = tsv.tg->stateStart->tState;
33 tsv.buff.matchBegin = tsv.buff.buffptr; 33 if (tsv.matchEnd) {
34 ResultPtr r = NEW(Result);
35 r->continued = false;
36 r->begin = tsv.matchBegin;
37 r->end = tsv.buff.buffptr;
38 *tsv.blk->resultEnd = r;
39 r->next = NULL;
40 tsv.blk->resultEnd = &r->next;
41 tsv.matchEnd=NULL;
42 }
34 return tsv; 43 return tsv;
35 } 44 }
36 45
37 static 46 static
38 TSValue stateMatch(TSValue tsv) { 47 TSValue stateMatch(TSValue tsv) {
39 ResultPtr r = NEW(Result); 48 tsv.matchEnd = tsv.buff.buffptr; // next char of the match
40 r->continued = false;
41 r->begin = tsv.buff.matchBegin;
42 r->end = tsv.buff.buffptr;
43 *tsv.resultEnd = r;
44 r->next = NULL;
45 tsv.resultEnd = &r->next;
46 tsv.buff.buffptr--;
47 tsv = stateSkip(tsv);
48 return tsv; 49 return tsv;
49 } 50 }
50 51
51 ResultPtr resultPrint(ResultPtr r,const char* comment) { 52 ResultPtr resultPrint(ResultPtr r,const char* comment) {
52 ResultPtr prev = NULL; 53 ResultPtr prev = NULL;
54 for (;r;r = r->next) { 55 for (;r;r = r->next) {
55 if (r->continued) { 56 if (r->continued) {
56 prev = r; 57 prev = r;
57 break; 58 break;
58 } 59 }
59 fwrite(r->begin,r->end - r->begin-1,1,stdout); 60 fwrite(r->begin,r->end - r->begin,1,stdout);
60 puts(""); 61 puts("");
61 } 62 }
62 return prev; 63 return prev;
63 } 64 }
64 65