Mercurial > hg > Applications > Grep
changeset 172:540fc12871d9 pairPro
remove some warnings and errors (not working)
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Dec 2015 15:56:33 +0900 |
parents | 684363c44d6f |
children | cca8bb5aeded |
files | regexParser/subsetConstraction.cc regexParser/transition.cc regexParser/transition.h |
diffstat | 3 files changed, 15 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/regexParser/subsetConstraction.cc Mon Dec 21 17:37:41 2015 +0900 +++ b/regexParser/subsetConstraction.cc Tue Dec 22 15:56:33 2015 +0900 @@ -112,17 +112,17 @@ return cc; } -CharClassWalkerPtr findLeftMost(CharClassPtr next,CharClassWalker walk) { +CharClassWalkerPtr findLeftMost(CharClassPtr next,CharClassWalkerPtr walk) { while (next->left) { CharClassStackPtr ccs = NEW(CharClassStack); - ccs->next = &walk.stack; + ccs->next = &walk->stack; ccs->left = false; ccs->cc = next; - walk.stack = *ccs; + walk->stack = *ccs; next = next->left; } - walk.next = next; - return &walk; + walk->next = next; + return walk; } CharClassWalkerPtr createCharClassWalker (CharClassPtr next) { @@ -133,7 +133,7 @@ walk->next = next; return walk; } - walk = findLeftMost(next,*walk); + walk = findLeftMost(next,walk); return walk; } @@ -145,7 +145,7 @@ CharClassPtr current = walk->next; if (walk->next->left && current->right) { walk->stack.left = true; - CharClassPtr next = findLeftMost(current->right,*walk)->next; + CharClassPtr next = findLeftMost(current->right,walk)->next; walk->next = next; } else { TransitionPtr tsOld = ts; @@ -162,13 +162,14 @@ TransitionPtr mergeTransition(TransitionPtr x,TransitionPtr y) { CharClassWalkerPtr walk = createCharClassWalker(x->condition); CharClassPtr ccy = y->condition; + BitVector bi; for (CharClassPtr cc = getNext(walk); hasNext(walk); cc=getNext(walk)) { unsigned long begin = cc->cond.range.begin; unsigned long end = cc->cond.range.end; - BitVector bi = cc->nextState; + bi = cc->nextState; ccy = charClassMerge(ccy,begin,end,bi); } - TransitionPtr z = createTransition(ccy); + TransitionPtr z = createTransition(ccy,&bi); free(walk); return z; } @@ -195,7 +196,7 @@ tgv.asterisk = true; return tgv; } else if (n->tokenType == 'c'){ - tgv2.ts = createTransition(n->cc); + tgv2.ts = createTransition(n->cc,0); return tgv2; } else if (n->tokenType == 'a'){ TGValue tgv;
--- a/regexParser/transition.cc Mon Dec 21 17:37:41 2015 +0900 +++ b/regexParser/transition.cc Tue Dec 22 15:56:33 2015 +0900 @@ -1,38 +1,10 @@ #include <stdlib.h> #include "transition.h" -StatePtr createState(BitVectorPtr bi, TransitionPtr ts, StatePtr next) { - StatePtr s = (StatePtr)malloc(sizeof(State)); - s->bitState = bi; - s->transition = ts; - s->next = next; - return s; -} - -StatePtr appendState(StatePtr x, StatePtr y) { - if (x == NULL) { - x = createState(y->bitState,y->transition,y->next); - return x; - } - - StatePtr x0 = createState(x->bitState, x->transition, x->next); - StatePtr x1 = x0; - for(;;) { - if (x->next == NULL) { - x1->next = y; - return x0; - } - x = x->next; - x1->next = createState(x->bitState, x->transition, x->next); - x1 = x1->next; - } - return x0; -} - TransitionPtr createTransition(CharClassPtr cc, BitVectorPtr state) { TransitionPtr transition = (TransitionPtr)malloc(sizeof(Transition)); transition->condition = cc; - transition->nextState = state; + transition->condition->nextState = *state; return transition; } @@ -48,7 +20,7 @@ } TransitionPtr appendTransition(TransitionPtr x, TransitionPtr y) { - TransitionPtr x0 = createTransition(x->condition, x->nextState); + TransitionPtr x0 = createTransition(x->condition, &x->condition->nextState); TransitionPtr x1 = x0; for(;;) { if (x->next == NULL) { @@ -56,7 +28,7 @@ return x0; } x = x->next; - x1->next = createTransition(x->condition, x->nextState); + x1->next = createTransition(x->condition, &x->condition->nextState); x1 = x1->next; } return x0;
--- a/regexParser/transition.h Mon Dec 21 17:37:41 2015 +0900 +++ b/regexParser/transition.h Tue Dec 22 15:56:33 2015 +0900 @@ -10,9 +10,7 @@ struct state *next; } State, *StatePtr; -StatePtr createState(BitVectorPtr bi, TransitionPtr ts, StatePtr next); -StatePtr appendState(StatePtr x, StatePtr y); -TransitionPtr createTransition(CharClassPtr cc); +TransitionPtr createTransition(CharClassPtr cc, BitVectorPtr state); TransitionPtr appendTransition0(TransitionPtr curr,TransitionPtr next); TransitionPtr appendTransition(TransitionPtr curr,TransitionPtr next);