Mercurial > hg > Applications > Grep
comparison c/regexParser/transition.cc @ 111:1d30f70702df pairPro
add determinize.cc and transition.cc
author | masa |
---|---|
date | Sat, 21 Nov 2015 18:04:25 +0900 |
parents | |
children | ec485345daf9 |
comparison
equal
deleted
inserted
replaced
110:a3adc5c24e19 | 111:1d30f70702df |
---|---|
1 #include "transition.h" | |
2 | |
3 TransitionPtr createTransition(CharClassPtr cc, BitVectorPtr state) { | |
4 TransitionPtr transition = (TransitionPtr)malloc(sizeof(Transition)); | |
5 transition->condition = cc; | |
6 transition->nextState = state; | |
7 return transition; | |
8 } | |
9 | |
10 TransitionPtr appendTransition0(TransitionPtr x, TransitionPtr y) { | |
11 TransitionPtr x0 = x; | |
12 for(;;) { | |
13 if (x->next == NULL) { | |
14 x->next = y | |
15 return x0; | |
16 } | |
17 } | |
18 return x; | |
19 } | |
20 | |
21 TransitionPtr appendTransition(TransitionPtr x, TransitionPtr y) { | |
22 TransitionPtr x0 = createTransition(x->condition, x->nextState); | |
23 TransitionPtr x1 = x0; | |
24 for(;;) { | |
25 if (x->next == NULL) { | |
26 x1->next = y; | |
27 return x0; | |
28 } | |
29 x = x->next; | |
30 x1->next = createTransition(x->condition, x->nextState); | |
31 x1 = x1->next; | |
32 } | |
33 return x0; | |
34 } |