Mercurial > hg > Applications > Grep
annotate c/regexParser/subsetConstraction.cc @ 156:b5ecfc008bcf pairPro
impl charClassMerge(not working)
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 18 Dec 2015 17:59:16 +0900 |
parents | 6cd0141bed6c |
children | dcd751ba7103 |
rev | line source |
---|---|
96
b807383bcc43
add createBitVectorList.cc
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 #include <stdio.h> |
b807383bcc43
add createBitVectorList.cc
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 #include <stdlib.h> |
101 | 3 #include <ctype.h> |
117
166136236891
add header files
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
116
diff
changeset
|
4 #include "subsetConstraction.h" |
96
b807383bcc43
add createBitVectorList.cc
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 |
144
d8a4922eceae
remove some errors (not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
143
diff
changeset
|
6 CharClassPtr createCharClassWord(unsigned char *w, CharClassPtr cc1, CharClassPtr cc2) { |
146 | 7 CharClassPtr cc = NEW(CharClass); |
154 | 8 return cc; |
144
d8a4922eceae
remove some errors (not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
143
diff
changeset
|
9 } |
d8a4922eceae
remove some errors (not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
143
diff
changeset
|
10 |
152 | 11 CharClassPtr charClassMerge(CharClassPtr cc,unsigned long begin, unsigned long end, BitVector nextState) { |
143 | 12 // 重なっているccの領域を分割する |
13 // 必要ならばnextStateを重ねあわせる | |
14 // 変更があった場合は新しくリストを作って返す | |
152 | 15 if (end < cc->cond.range.begin ) { // 1 |
16 if (cc->left) { | |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
17 return createCharClassRange(cc->cond.range.begin,cc->cond.range.end,charClassMerge(cc->left,begin,end,nextState),cc->right); |
152 | 18 } else { |
155 | 19 CharClassPtr cc1 = createCharClassRange(begin,end,NULL,cc); |
20 cc1->nextState = nextState; | |
152 | 21 return cc1; |
22 } | |
23 } else if (end == cc->cond.range.begin ) { // 2 | |
155 | 24 CharClassPtr cc1; |
25 if (cc->left) { | |
26 cc1 = charClassMerge(cc->left,begin,end-1,nextState); | |
152 | 27 } else { |
155 | 28 cc1 = createCharClassRange(begin,end-1,NULL,NULL); |
29 cc1->nextState = nextState; | |
30 } | |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
31 if (cc->cond.range.begin == cc->cond.range.end) { |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
32 CharClassPtr cc2 = createCharClassRange(cc->cond.range.begin,cc->cond.range.end,cc1,cc->right); |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
33 cc2->nextState.bitContainer = cc->nextState.bitContainer | nextState.bitContainer; |
155 | 34 return cc2; |
35 } | |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
36 CharClassPtr cc3 = createCharClassRange(cc->cond.range.begin+1,cc->cond.range.end,cc->left,cc->right); |
155 | 37 cc3->nextState = cc->nextState; |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
38 CharClassPtr cc2 = createCharClassRange(cc->cond.range.begin,cc->cond.range.begin,cc1,cc3); |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
39 cc2->nextState.bitContainer = cc->nextState.bitContainer | nextState.bitContainer; |
155 | 40 return cc2; |
41 } else if (end < cc->cond.range.end) { | |
42 if (begin < cc->cond.range.begin) { // 3 | |
43 CharClassPtr cc1; | |
44 if (cc->left) { | |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
45 cc1 = charClassMerge(cc->left,begin,cc->cond.range.begin-1,nextState); |
155 | 46 } else { |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
47 cc1 = createCharClassRange(begin,cc->cond.range.begin-1,NULL,NULL); |
155 | 48 cc1->nextState = nextState; |
49 } | |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
50 CharClassPtr cc3 = createCharClassRange(end+1,cc->cond.range.end,cc->left,cc->right); |
155 | 51 cc3->nextState = cc->nextState; |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
52 CharClassPtr cc2 = createCharClassRange(cc->cond.range.begin,end,cc1,cc3); |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
53 cc2->nextState.bitContainer = cc->nextState.bitContainer | nextState.bitContainer; |
155 | 54 return cc2; |
152 | 55 } |
155 | 56 if (begin == cc->cond.range.begin) { // 6 |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
57 CharClassPtr cc2 = createCharClassRange(end,cc->cond.range.end,NULL,cc->right); |
155 | 58 cc2->nextState = cc->nextState; |
59 CharClassPtr cc1 = createCharClassRange(begin,end,cc->left,cc2); | |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
60 cc1->nextState.bitContainer = cc->nextState.bitContainer | nextState.bitContainer; |
155 | 61 return cc1; |
62 } | |
63 // 9 | |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
64 CharClassPtr cc2 = createCharClassRange(cc->cond.range.begin,begin-1,cc->left,NULL); |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
65 cc2->nextState = cc2->nextState; |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
66 CharClassPtr cc3 = createCharClassRange(end+1,cc->cond.range.end,NULL,cc->right); |
155 | 67 cc3->nextState = cc->nextState; |
68 CharClassPtr cc1 = createCharClassRange(begin,end,cc2,cc3); | |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
69 cc1->nextState.bitContainer = cc->nextState.bitContainer | nextState.bitContainer; |
155 | 70 return cc1; |
71 } else if (end == cc->cond.range.end) { | |
72 if (begin == cc->cond.range.begin) { // 7 | |
73 CharClassPtr cc1 = createCharClassRange(begin,end,cc->left,cc->right); | |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
74 cc1->nextState.bitContainer = cc->nextState.bitContainer | nextState.bitContainer; |
155 | 75 return cc1; |
76 } else if (begin < cc->cond.range.begin) { // 4 | |
77 CharClassPtr cc1; | |
78 if (cc->left) { | |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
79 cc1 = charClassMerge(cc->left,begin,cc->cond.range.begin-1,nextState); |
155 | 80 } else { |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
81 cc1 = createCharClassRange(begin,cc->cond.range.begin-1,NULL,NULL); |
155 | 82 cc1->nextState = nextState; |
83 } | |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
84 CharClassPtr cc3 = createCharClassRange(cc->cond.range.begin,end,cc1,cc->right); |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
85 cc3->nextState.bitContainer = cc->nextState.bitContainer | nextState.bitContainer; |
155 | 86 return cc3; |
87 } | |
88 // 10 | |
89 CharClassPtr cc2 = createCharClassRange(begin,cc->cond.range.end,NULL,cc->right); | |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
90 cc2->nextState.bitContainer = cc->nextState.bitContainer | nextState.bitContainer; |
155 | 91 CharClassPtr cc1 = createCharClassRange(cc->cond.range.begin,begin-1,NULL,NULL); |
92 cc1->nextState = cc->nextState; | |
93 return cc1; | |
143 | 94 } |
155 | 95 if (begin > cc->cond.range.end ) { // 13 |
96 if (cc->right) { | |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
97 return createCharClassRange(cc->cond.range.begin,cc->cond.range.end,cc->left,charClassMerge(cc->right,begin,end,nextState)); |
155 | 98 } else { |
99 CharClassPtr cc1 = createCharClassRange(begin,end,cc,NULL); | |
100 cc1->nextState = nextState; | |
101 return cc1; | |
102 } | |
152 | 103 } |
155 | 104 if (begin >= cc->cond.range.begin && begin <= cc->cond.range.end) { |
105 if (end > cc->cond.range.end) { | |
106 if (begin == cc->cond.range.begin) { // 8 | |
107 CharClassPtr cc1; | |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
108 if (cc->right) { |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
109 cc1 = charClassMerge(cc->right,begin,cc->cond.range.end,nextState); |
155 | 110 } else { |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
111 cc1 = createCharClassRange(begin,cc->cond.range.end,NULL,NULL); |
155 | 112 cc1->nextState = nextState; |
113 } | |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
114 CharClassPtr cc3 = createCharClassRange(cc->cond.range.end+1,end,cc->left,cc1); |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
115 cc3->nextState.bitContainer = cc->nextState.bitContainer | nextState.bitContainer; |
155 | 116 return cc3; |
117 } | |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
118 |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
119 if (begin > cc->cond.range.begin) { // 11 |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
120 CharClassPtr cc1; |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
121 if (cc->right) { |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
122 cc1 = charClassMerge(cc->right,cc->cond.range.end+1,end,nextState); |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
123 } else { |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
124 cc1 = createCharClassRange(cc->cond.range.end+1,end,NULL,NULL); |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
125 cc1->nextState = nextState; |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
126 } |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
127 CharClassPtr cc3 = createCharClassRange(cc->cond.range.begin,begin-1,cc->left,cc->right); |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
128 cc3->nextState = cc->nextState; |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
129 CharClassPtr cc2 = createCharClassRange(begin,cc->cond.range.end,cc3,cc1); |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
130 cc2->nextState.bitContainer = cc->nextState.bitContainer | nextState.bitContainer; |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
131 return cc2; |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
132 } |
155 | 133 } |
134 // 12 | |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
135 if (begin == cc->cond.range.end) { |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
136 CharClassPtr cc1; |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
137 if (cc->right) { |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
138 cc1 = charClassMerge(cc->right,begin+1,end,nextState); |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
139 } else { |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
140 cc1 = createCharClassRange(begin+1,end,NULL,NULL); |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
141 cc1->nextState = nextState; |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
142 } |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
143 if (cc->cond.range.begin == cc->cond.range.end) { |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
144 CharClassPtr cc2 = createCharClassRange(cc->cond.range.begin,cc->cond.range.end,cc1,cc->right); |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
145 cc2->nextState.bitContainer = cc->nextState.bitContainer | nextState.bitContainer; |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
146 return cc2; |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
147 } |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
148 CharClassPtr cc3; |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
149 createCharClassRange(cc->cond.range.begin,cc->cond.range.end-1,cc->left,cc->right); |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
150 cc3->nextState = cc->nextState; |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
151 CharClassPtr cc2 = createCharClassRange(cc->cond.range.end,cc->cond.range.end,cc1,cc3); |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
152 cc2->nextState.bitContainer = cc->nextState.bitContainer | nextState.bitContainer; |
155 | 153 return cc2; |
154 } | |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
155 |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
156 } else if (begin < cc->cond.range.begin) { // 5 |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
157 CharClassPtr cc2 = createCharClassRange(cc->cond.range.begin,begin-1,cc->left,NULL); |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
158 cc2->nextState = cc1->nextState; |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
159 CharClassPtr cc3 = createCharClassRange(end+1,cc->cond.range.end,NULL,cc->right); |
155 | 160 cc3->nextState = cc->nextState; |
156
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
161 CharClassPtr cc1 = createCharClassRange(cc->cond.range.begin,cc->cond.range.end,cc2,cc3); |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
162 cc1->nextState.bitContainer = cc->nextState.bitContainer | nextState.bitContainer; |
b5ecfc008bcf
impl charClassMerge(not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
155
diff
changeset
|
163 return cc1; |
152 | 164 } else { |
165 printf("charClassMerge Error : begin %lu end %lu cc->begin %lu cc->end %lu\n", begin,end,cc->cond.range.begin,cc->cond.range.end); | |
166 } | |
167 return cc; | |
143 | 168 } |
169 | |
142 | 170 TGValue generateTransition(NodePtr n,TransitionGenerator tg) { |
154 | 171 TGValue tgv2; |
141
71f36a59cf6a
add appendState
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
139
diff
changeset
|
172 if (n->tokenType == '+') { |
142 | 173 TGValue tgv = generateTransition(n->left,tg); |
174 if (tgv.asterisk) { | |
175 TGValue tgv1 = generateTransition(n->right,tg); | |
153 | 176 tgv.ts->nextState->bitContainer |= tgv1.ts->nextState->bitContainer; |
142 | 177 return tgv; |
178 } | |
153 | 179 TGValue tgv1 = generateTransition(n->right,tg); |
180 tgv.ts->nextState = tgv1.ts->nextState; | |
142 | 181 return tgv; |
141
71f36a59cf6a
add appendState
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
139
diff
changeset
|
182 } else if (n->tokenType == '|') { |
153 | 183 TGValue tgv = generateTransition(n->left,tg); |
184 TGValue tgv1 = generateTransition(n->right,tg); | |
185 tgv.ts = appendTransition(tgv.ts,tgv1.ts); | |
186 return tgv; | |
141
71f36a59cf6a
add appendState
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
139
diff
changeset
|
187 } else if (n->tokenType == '*') { |
153 | 188 TGValue tgv = generateTransition(n->left,tg); |
189 tgv.asterisk = true; | |
190 return tgv; | |
144
d8a4922eceae
remove some errors (not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
143
diff
changeset
|
191 } else if (n->tokenType == 'c'){ |
154 | 192 return tgv2; |
144
d8a4922eceae
remove some errors (not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
143
diff
changeset
|
193 } else if (n->tokenType == 'a'){ |
153 | 194 TGValue tgv; |
195 tgv.ts = (TransitionPtr)malloc(sizeof(Transition)); | |
196 tgv.ts->condition = n->cc; | |
197 tgv.ts->nextState = (BitVectorPtr)malloc(sizeof(BitVector)); | |
198 bitSet(tgv.ts->nextState,n->nodeNumber); | |
199 tg.ts = appendTransition(tg.ts,tgv.ts); | |
200 return tgv; | |
141
71f36a59cf6a
add appendState
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
139
diff
changeset
|
201 } else { |
144
d8a4922eceae
remove some errors (not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
143
diff
changeset
|
202 // error |
141
71f36a59cf6a
add appendState
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
139
diff
changeset
|
203 } |
154 | 204 return tgv2; |
141
71f36a59cf6a
add appendState
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
139
diff
changeset
|
205 } |
71f36a59cf6a
add appendState
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
139
diff
changeset
|
206 |
153 | 207 void printTransitionList(TransitionPtr ts) { |
208 for (;ts;ts = ts->next) { | |
209 printf("\n"); | |
210 } | |
211 } | |
212 | |
144
d8a4922eceae
remove some errors (not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
143
diff
changeset
|
213 TransitionGenerator generateTransitionList(NodePtr n) { |
d8a4922eceae
remove some errors (not working)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
143
diff
changeset
|
214 TransitionGenerator tg; |
153 | 215 tg.ts = (TransitionPtr)malloc(sizeof(Transition)); |
141
71f36a59cf6a
add appendState
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
139
diff
changeset
|
216 generateTransition(n,tg); |
153 | 217 printTransitionList(tg.ts); |
141
71f36a59cf6a
add appendState
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
139
diff
changeset
|
218 return tg; |
71f36a59cf6a
add appendState
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
139
diff
changeset
|
219 } |