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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
2cc097419169 fix print
masasann
parents: 100
diff changeset
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
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 144
diff changeset
7 CharClassPtr cc = NEW(CharClass);
154
1fad21fd6028 remove errors and warnings
masa
parents: 153
diff changeset
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
1c9e8ba64f6a add implement charclassMerge (not working)
masa
parents: 148
diff changeset
11 CharClassPtr charClassMerge(CharClassPtr cc,unsigned long begin, unsigned long end, BitVector nextState) {
143
32977f5a2ed0 add charClassMerge
masa
parents: 142
diff changeset
12 // 重なっているccの領域を分割する
32977f5a2ed0 add charClassMerge
masa
parents: 142
diff changeset
13 // 必要ならばnextStateを重ねあわせる
32977f5a2ed0 add charClassMerge
masa
parents: 142
diff changeset
14 // 変更があった場合は新しくリストを作って返す
152
1c9e8ba64f6a add implement charclassMerge (not working)
masa
parents: 148
diff changeset
15 if (end < cc->cond.range.begin ) { // 1
1c9e8ba64f6a add implement charclassMerge (not working)
masa
parents: 148
diff changeset
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
1c9e8ba64f6a add implement charclassMerge (not working)
masa
parents: 148
diff changeset
18 } else {
155
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
19 CharClassPtr cc1 = createCharClassRange(begin,end,NULL,cc);
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
20 cc1->nextState = nextState;
152
1c9e8ba64f6a add implement charclassMerge (not working)
masa
parents: 148
diff changeset
21 return cc1;
1c9e8ba64f6a add implement charclassMerge (not working)
masa
parents: 148
diff changeset
22 }
1c9e8ba64f6a add implement charclassMerge (not working)
masa
parents: 148
diff changeset
23 } else if (end == cc->cond.range.begin ) { // 2
155
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
24 CharClassPtr cc1;
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
25 if (cc->left) {
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
26 cc1 = charClassMerge(cc->left,begin,end-1,nextState);
152
1c9e8ba64f6a add implement charclassMerge (not working)
masa
parents: 148
diff changeset
27 } else {
155
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
28 cc1 = createCharClassRange(begin,end-1,NULL,NULL);
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
29 cc1->nextState = nextState;
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
34 return cc2;
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
40 return cc2;
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
41 } else if (end < cc->cond.range.end) {
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
42 if (begin < cc->cond.range.begin) { // 3
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
43 CharClassPtr cc1;
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
48 cc1->nextState = nextState;
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
54 return cc2;
152
1c9e8ba64f6a add implement charclassMerge (not working)
masa
parents: 148
diff changeset
55 }
155
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
58 cc2->nextState = cc->nextState;
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
61 return cc1;
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
62 }
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
67 cc3->nextState = cc->nextState;
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
70 return cc1;
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
71 } else if (end == cc->cond.range.end) {
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
72 if (begin == cc->cond.range.begin) { // 7
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
75 return cc1;
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
76 } else if (begin < cc->cond.range.begin) { // 4
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
77 CharClassPtr cc1;
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
82 cc1->nextState = nextState;
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
86 return cc3;
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
87 }
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
88 // 10
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
91 CharClassPtr cc1 = createCharClassRange(cc->cond.range.begin,begin-1,NULL,NULL);
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
92 cc1->nextState = cc->nextState;
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
93 return cc1;
143
32977f5a2ed0 add charClassMerge
masa
parents: 142
diff changeset
94 }
155
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
95 if (begin > cc->cond.range.end ) { // 13
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
98 } else {
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
99 CharClassPtr cc1 = createCharClassRange(begin,end,cc,NULL);
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
100 cc1->nextState = nextState;
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
101 return cc1;
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
102 }
152
1c9e8ba64f6a add implement charclassMerge (not working)
masa
parents: 148
diff changeset
103 }
155
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
104 if (begin >= cc->cond.range.begin && begin <= cc->cond.range.end) {
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
105 if (end > cc->cond.range.end) {
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
106 if (begin == cc->cond.range.begin) { // 8
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
112 cc1->nextState = nextState;
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
116 return cc3;
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
133 }
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
153 return cc2;
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
6cd0141bed6c impl charClassMerge
masa
parents: 154
diff changeset
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
1c9e8ba64f6a add implement charclassMerge (not working)
masa
parents: 148
diff changeset
164 } else {
1c9e8ba64f6a add implement charclassMerge (not working)
masa
parents: 148
diff changeset
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);
1c9e8ba64f6a add implement charclassMerge (not working)
masa
parents: 148
diff changeset
166 }
1c9e8ba64f6a add implement charclassMerge (not working)
masa
parents: 148
diff changeset
167 return cc;
143
32977f5a2ed0 add charClassMerge
masa
parents: 142
diff changeset
168 }
32977f5a2ed0 add charClassMerge
masa
parents: 142
diff changeset
169
142
de0f332d560c insert charClassMerge function
masa
parents: 141
diff changeset
170 TGValue generateTransition(NodePtr n,TransitionGenerator tg) {
154
1fad21fd6028 remove errors and warnings
masa
parents: 153
diff changeset
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
de0f332d560c insert charClassMerge function
masa
parents: 141
diff changeset
173 TGValue tgv = generateTransition(n->left,tg);
de0f332d560c insert charClassMerge function
masa
parents: 141
diff changeset
174 if (tgv.asterisk) {
de0f332d560c insert charClassMerge function
masa
parents: 141
diff changeset
175 TGValue tgv1 = generateTransition(n->right,tg);
153
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
176 tgv.ts->nextState->bitContainer |= tgv1.ts->nextState->bitContainer;
142
de0f332d560c insert charClassMerge function
masa
parents: 141
diff changeset
177 return tgv;
de0f332d560c insert charClassMerge function
masa
parents: 141
diff changeset
178 }
153
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
179 TGValue tgv1 = generateTransition(n->right,tg);
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
180 tgv.ts->nextState = tgv1.ts->nextState;
142
de0f332d560c insert charClassMerge function
masa
parents: 141
diff changeset
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
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
183 TGValue tgv = generateTransition(n->left,tg);
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
184 TGValue tgv1 = generateTransition(n->right,tg);
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
185 tgv.ts = appendTransition(tgv.ts,tgv1.ts);
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
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
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
188 TGValue tgv = generateTransition(n->left,tg);
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
189 tgv.asterisk = true;
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
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
1fad21fd6028 remove errors and warnings
masa
parents: 153
diff changeset
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
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
194 TGValue tgv;
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
195 tgv.ts = (TransitionPtr)malloc(sizeof(Transition));
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
196 tgv.ts->condition = n->cc;
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
197 tgv.ts->nextState = (BitVectorPtr)malloc(sizeof(BitVector));
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
198 bitSet(tgv.ts->nextState,n->nodeNumber);
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
199 tg.ts = appendTransition(tg.ts,tgv.ts);
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
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
1fad21fd6028 remove errors and warnings
masa
parents: 153
diff changeset
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
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
207 void printTransitionList(TransitionPtr ts) {
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
208 for (;ts;ts = ts->next) {
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
209 printf("\n");
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
210 }
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
211 }
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
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
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
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
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 152
diff changeset
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 }