Mercurial > hg > Applications > Grep
changeset 241:87ad91af8a15
turn initialization in charclasswalk
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 20 Jan 2016 20:28:40 +0900 |
parents | 6ed6f385205e |
children | 6aebc4d7dd75 |
files | regexParser/Makefile regexParser/generateSequentialSearch.cc regexParser/subsetConstruction.cc |
diffstat | 3 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/regexParser/Makefile Wed Jan 20 18:20:48 2016 +0900 +++ b/regexParser/Makefile Wed Jan 20 20:28:40 2016 +0900 @@ -3,7 +3,7 @@ CC= clang++ SRCS_TMP = $(wildcard *.cc) -SRCS_EXCLUDE = sequentialSearch.cc +SRCS_EXCLUDE = sequentialSearch.cc state.cc SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP)) OBJS = $(SRCS:.cc=.o)
--- a/regexParser/generateSequentialSearch.cc Wed Jan 20 18:20:48 2016 +0900 +++ b/regexParser/generateSequentialSearch.cc Wed Jan 20 20:28:40 2016 +0900 @@ -1,4 +1,5 @@ #include <stdio.h> +#include <stdlib.h> #include "generateSequentialSearch.h" #include "subsetConstruction.h" @@ -6,6 +7,11 @@ void exportState(TransitionGeneratorPtr tg) { StatePtr state = tg->stateList; FILE *fp = fopen("state.cc","w"); + if (fp==NULL) { + perror(""); + fprintf(stderr,"cannot write state.cc\n"); + exit(1); + } for (;state;state = state->next) { fprintf(fp,"void state%lx(Buffer buff);\n",state->bitState.bitContainer); } @@ -37,7 +43,8 @@ fprintf(fp," else if (c<='%c') state%lx(buff);\n",(unsigned char)end, bi.bitContainer); } } - if (state->bitState.bitContainer == 2) { + free(ccw); + if (state->bitState.bitContainer & 2) { fprintf(fp," else stateMatch(buff);\n"); } else { fprintf(fp," else stateSkip(buff);\n");
--- a/regexParser/subsetConstruction.cc Wed Jan 20 18:20:48 2016 +0900 +++ b/regexParser/subsetConstruction.cc Wed Jan 20 20:28:40 2016 +0900 @@ -124,6 +124,7 @@ CharClassWalkerPtr walk = NEW(CharClassWalker); walk->next = NULL; walk->stack = NULL; + walk->turn = LEFT; if (!next) return walk; findLeftMost(next,walk); return walk; @@ -225,6 +226,7 @@ if (n->tokenType == '+') { TGValue tgvLeft = tgv; tgvLeft.endState = n->right->state; + if (pass==2) n->right->state->accept = tgv.endState->accept; tgvLeft.asterisk = NULL; tgvLeft = generateTransition(n->left,tgvLeft,pass); TGValue tgvRight = tgv; @@ -393,6 +395,7 @@ s->cc = merge; } } + free(cw); } return scv; }