Mercurial > hg > Members > masakoha > testcode
view regexParser/transition.cc @ 180:d97bcab546e8 pairPro
implement getNext
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 24 Dec 2015 17:56:28 +0900 |
parents | 8de9a33f6ae5 |
children | ef798db705e9 |
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; }