Mercurial > hg > Applications > Grep
changeset 224:474fc9f844db
fix exportState()
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 15 Jan 2016 16:12:19 +0900 |
parents | e430b7d0b33d |
children | 0c28ff35b4f0 |
files | regexParser/subsetConstruction.cc |
diffstat | 1 files changed, 18 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/regexParser/subsetConstruction.cc Fri Jan 15 15:57:22 2016 +0900 +++ b/regexParser/subsetConstruction.cc Fri Jan 15 16:12:19 2016 +0900 @@ -322,16 +322,22 @@ for (;state;state = state->next) { sprintf(s,"void state%lx() {\n",state->bitState.bitContainer); fputs(s,fp); - fputs(" unsigned char c = *buffptr++;\n",fp); - CharClassWalkerPtr ccw = createCharClassWalker(state->cc); - while (hasNext(ccw)) { - CharClassPtr cc = getNext(ccw); - unsigned long begin = cc->cond.range.begin; - unsigned long end = cc->cond.range.end; - BitVector bi = cc->nextState; - if (bi.bitContainer == 2) { - fputs(" // Accept\n",fp); - } else { + if (state->bitState.bitContainer == 2) { // Accept + fputs(" // Accept\n",fp); + } else { // not Accept + fputs(" unsigned char c = *buffptr++;\n",fp); + CharClassWalkerPtr ccw = createCharClassWalker(state->cc); + bool flag = true; + while (hasNext(ccw)) { + CharClassPtr cc = getNext(ccw); + unsigned long begin = cc->cond.range.begin; + unsigned long end = cc->cond.range.end; + BitVector bi = cc->nextState; + if (flag) { + flag = false; + } else { + fputs(" else ",fp); + } if (begin == end) { sprintf(s," if (c=='%c') state%lu();\n",(unsigned char)begin, bi.bitContainer); fputs(s,fp); @@ -342,9 +348,9 @@ fputs(s,fp); } } + sprintf(s," else state1();\n"); + fputs(s,fp); } - sprintf(s," state1();\n"); - fputs(s,fp); fputs("}\n\n",fp); } fclose(fp);