111
|
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 }
|