Mercurial > hg > Members > masakoha > testcode
changeset 223:e430b7d0b33d
fix exportState (not correct working)
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 15 Jan 2016 15:57:22 +0900 |
parents | c38a7b2dd996 |
children | 474fc9f844db |
files | regexParser/subsetConstruction.cc |
diffstat | 1 files changed, 21 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/regexParser/subsetConstruction.cc Thu Jan 14 21:46:35 2016 +0900 +++ b/regexParser/subsetConstruction.cc Fri Jan 15 15:57:22 2016 +0900 @@ -318,31 +318,34 @@ StatePtr state = tg->stateList; FILE *fp = fopen("state.cc","w"); char s[SIZE]; - fputs("unsigned char *buff, *buffptr, buffend;\n",fp); for (;state;state = state->next) { sprintf(s,"void state%lx() {\n",state->bitState.bitContainer); fputs(s,fp); - if (state->cc->cond.range.begin == state->cc->cond.range.end) { - if (state->cc) { // not Accept - fputs(" unsigned char c = *buffptr++;\n",fp); - sprintf(s," if (c='%c') state%lu();\n",(unsigned char)state->cc->cond.range.begin, state->cc->nextState.bitContainer); - fputs(s,fp); - } else { // Accept + 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->cc) { // not Accept - fputs(" unsigned char c = *buffptr++;\n",fp); - sprintf(s," if (c<'%c') state%lu();\n",(unsigned char)state->cc->cond.range.begin, state->cc->nextState.bitContainer); - fputs(s,fp); - sprintf(s," if (c<'%c') state%lu();\n",(unsigned char)state->cc->cond.range.end, state->cc->nextState.bitContainer); - fputs(s,fp); - } else { // Accept - fputs(" // Accept\n",fp); + } else { + if (begin == end) { + sprintf(s," if (c=='%c') state%lu();\n",(unsigned char)begin, bi.bitContainer); + fputs(s,fp); + } else { + sprintf(s," if (c<'%c') state1();\n",(unsigned char)begin); + fputs(s,fp); + sprintf(s," else if (c<='%c') state%lu();\n",(unsigned char)end, bi.bitContainer); + fputs(s,fp); + } } } - fputs("}\n",fp); + sprintf(s," state1();\n"); + fputs(s,fp); + fputs("}\n\n",fp); } fclose(fp); }