comparison regexParser/transition.cc @ 190:3e8e5780ad4a pairPro

change node::State to State
author Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
date Fri, 25 Dec 2015 15:30:52 +0900
parents ef798db705e9
children
comparison
equal deleted inserted replaced
189:fccf7941ecc2 190:3e8e5780ad4a
1 #include <stdlib.h> 1 #include <stdlib.h>
2 #include "transition.h" 2 #include "transition.h"
3 3
4 node::StatePtr searchState(node::StatePtr stateArray, node::StatePtr state) { 4 StatePtr searchState(StatePtr stateArray, StatePtr state) {
5 while(stateArray) { 5 while(stateArray) {
6 if (stateArray->bitState.bitContainer == state->bitState.bitContainer) { 6 if (stateArray->bitState.bitContainer == state->bitState.bitContainer) {
7 return stateArray; 7 return stateArray;
8 } 8 }
9 if (stateArray->next == NULL) { 9 if (stateArray->next == NULL) {
10 node::StatePtr s = createState(state->bitState); 10 StatePtr s = createState(state->bitState);
11 stateArray = appendState(stateArray,s); 11 stateArray = appendState(stateArray,s);
12 return stateArray; 12 return stateArray;
13 } 13 }
14 stateArray = stateArray->next; 14 stateArray = stateArray->next;
15 } 15 }
16 return stateArray; 16 return stateArray;
17 } 17 }
18 18
19 node::StatePtr createState(BitVector bi) { 19 StatePtr createState(BitVector bi) {
20 node::StatePtr state = NEW(node::State); 20 StatePtr state = NEW(State);
21 state->bitState = bi; 21 state->bitState = bi;
22 state->node = NEW(Node); 22 state->node = NEW(Node);
23 return state; 23 return state;
24 } 24 }
25 25
26 node::StatePtr appendState(node::StatePtr x,node::StatePtr y) { 26 StatePtr appendState(StatePtr x,StatePtr y) {
27 node::StatePtr x0 = createState(x->bitState); 27 StatePtr x0 = createState(x->bitState);
28 node::StatePtr x1 = x0; 28 StatePtr x1 = x0;
29 for(;;) { 29 for(;;) {
30 if (x->next == NULL) { 30 if (x->next == NULL) {
31 x1->next = y; 31 x1->next = y;
32 return x0; 32 return x0;
33 } 33 }