Mercurial > hg > Applications > Grep
comparison regexParser/transition.cc @ 172:540fc12871d9 pairPro
remove some warnings and errors (not working)
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Dec 2015 15:56:33 +0900 |
parents | 3bf2c6d6d53e |
children | 3be0fbcd4b52 |
comparison
equal
deleted
inserted
replaced
171:684363c44d6f | 172:540fc12871d9 |
---|---|
1 #include <stdlib.h> | 1 #include <stdlib.h> |
2 #include "transition.h" | 2 #include "transition.h" |
3 | |
4 StatePtr createState(BitVectorPtr bi, TransitionPtr ts, StatePtr next) { | |
5 StatePtr s = (StatePtr)malloc(sizeof(State)); | |
6 s->bitState = bi; | |
7 s->transition = ts; | |
8 s->next = next; | |
9 return s; | |
10 } | |
11 | |
12 StatePtr appendState(StatePtr x, StatePtr y) { | |
13 if (x == NULL) { | |
14 x = createState(y->bitState,y->transition,y->next); | |
15 return x; | |
16 } | |
17 | |
18 StatePtr x0 = createState(x->bitState, x->transition, x->next); | |
19 StatePtr x1 = x0; | |
20 for(;;) { | |
21 if (x->next == NULL) { | |
22 x1->next = y; | |
23 return x0; | |
24 } | |
25 x = x->next; | |
26 x1->next = createState(x->bitState, x->transition, x->next); | |
27 x1 = x1->next; | |
28 } | |
29 return x0; | |
30 } | |
31 | 3 |
32 TransitionPtr createTransition(CharClassPtr cc, BitVectorPtr state) { | 4 TransitionPtr createTransition(CharClassPtr cc, BitVectorPtr state) { |
33 TransitionPtr transition = (TransitionPtr)malloc(sizeof(Transition)); | 5 TransitionPtr transition = (TransitionPtr)malloc(sizeof(Transition)); |
34 transition->condition = cc; | 6 transition->condition = cc; |
35 transition->nextState = state; | 7 transition->condition->nextState = *state; |
36 return transition; | 8 return transition; |
37 } | 9 } |
38 | 10 |
39 TransitionPtr appendTransition0(TransitionPtr x, TransitionPtr y) { | 11 TransitionPtr appendTransition0(TransitionPtr x, TransitionPtr y) { |
40 TransitionPtr x0 = x; | 12 TransitionPtr x0 = x; |
46 } | 18 } |
47 return x; | 19 return x; |
48 } | 20 } |
49 | 21 |
50 TransitionPtr appendTransition(TransitionPtr x, TransitionPtr y) { | 22 TransitionPtr appendTransition(TransitionPtr x, TransitionPtr y) { |
51 TransitionPtr x0 = createTransition(x->condition, x->nextState); | 23 TransitionPtr x0 = createTransition(x->condition, &x->condition->nextState); |
52 TransitionPtr x1 = x0; | 24 TransitionPtr x1 = x0; |
53 for(;;) { | 25 for(;;) { |
54 if (x->next == NULL) { | 26 if (x->next == NULL) { |
55 x1->next = y; | 27 x1->next = y; |
56 return x0; | 28 return x0; |
57 } | 29 } |
58 x = x->next; | 30 x = x->next; |
59 x1->next = createTransition(x->condition, x->nextState); | 31 x1->next = createTransition(x->condition, &x->condition->nextState); |
60 x1 = x1->next; | 32 x1 = x1->next; |
61 } | 33 } |
62 return x0; | 34 return x0; |
63 } | 35 } |