Mercurial > hg > Members > masakoha > testcode
view regexParser/transition.cc @ 177:8de9a33f6ae5 pairPro
change createState aug
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 23 Dec 2015 17:28:59 +0900 |
parents | c092dd0e1ae0 |
children | d97bcab546e8 |
line wrap: on
line source
#include <stdlib.h> #include "transition.h" StatePtr searchState(StatePtr stateArray, StatePtr state) { while(stateArray) { if (stateArray->bitState.bitContainer == state->bitState.bitContainer) { return stateArray; } if (stateArray->next == NULL) { StatePtr s = createState(state->bitState); stateArray = appendState(stateArray,s); return stateArray; } stateArray = stateArray->next; } return stateArray; } StatePtr createState(BitVector bi) { StatePtr state = NEW(State); state->bitState = bi; state->transition = NEW(Transition); state->nextNode = NEW(Node); return state; } StatePtr appendState(StatePtr x,StatePtr y) { StatePtr x0 = createState(x->bitState); StatePtr x1 = x0; for(;;) { if (x->next == NULL) { x1->next = y; return x0; } x = x->next; x1->next = createState(x->bitState); x1 = x1->next; } return x0; } TransitionPtr createTransition(CharClassPtr cc, BitVectorPtr state) { TransitionPtr transition = NEW(Transition); transition->condition = cc; transition->condition->nextState = *state; return transition; } TransitionPtr appendTransition0(TransitionPtr x, TransitionPtr y) { TransitionPtr x0 = x; for(;;) { if (x->next == NULL) { x->next = y; return x0; } } return x; } TransitionPtr appendTransition(TransitionPtr x, TransitionPtr y) { TransitionPtr x0 = createTransition(x->condition, &x->condition->nextState); TransitionPtr x1 = x0; for(;;) { if (x->next == NULL) { x1->next = y; return x0; } x = x->next; x1->next = createTransition(x->condition, &x->condition->nextState); x1 = x1->next; } return x0; }