File grammar.y changed (mode: 100644) (index 9173202..91ce712) |
... |
... |
expr: intexpr { $$.ty = gInteger; } |
267 |
267 |
if(infunction && lookup(curtab, $1.str) && !lookup(&initialized, $1.str) ){ |
if(infunction && lookup(curtab, $1.str) && !lookup(&initialized, $1.str) ){ |
268 |
268 |
char ebuf[1024]; |
char ebuf[1024]; |
269 |
269 |
sprintf(ebuf, "Variable %s is uninitialized", $1.str); |
sprintf(ebuf, "Variable %s is uninitialized", $1.str); |
270 |
|
yyerrorex(3, ebuf); |
|
|
270 |
|
//yyerrorex(3, ebuf); |
|
271 |
|
yyerrorline(3, lineno - 1, ebuf); |
271 |
272 |
} |
} |
272 |
273 |
$$.ty = tan->ty; |
$$.ty = tan->ty; |
273 |
274 |
} |
} |
File misc.c changed (mode: 100644) (index d74f1c0..365c261) |
... |
... |
int min(int a, int b){ |
87 |
87 |
else return b; |
else return b; |
88 |
88 |
} |
} |
89 |
89 |
|
|
90 |
|
int editdistance(const char *s, const char *t){ |
|
|
90 |
|
int abs(int i){ |
|
91 |
|
if(i < 0) |
|
92 |
|
return -i; |
|
93 |
|
return i; |
|
94 |
|
} |
|
95 |
|
|
|
96 |
|
int editdistance(const char *s, const char *t, int cutoff){ |
91 |
97 |
if(!strcmp(s, t)) return 0; |
if(!strcmp(s, t)) return 0; |
92 |
98 |
|
|
93 |
99 |
int a = strlen(s); |
int a = strlen(s); |
|
... |
... |
int editdistance(const char *s, const char *t){ |
95 |
101 |
|
|
96 |
102 |
if(a==0) return b; |
if(a==0) return b; |
97 |
103 |
if(b==0) return a; |
if(b==0) return a; |
|
104 |
|
|
|
105 |
|
if(abs(a-b) > cutoff){ |
|
106 |
|
return cutoff + 1; |
|
107 |
|
} |
98 |
108 |
|
|
99 |
109 |
int *v[3]; |
int *v[3]; |
100 |
110 |
int i; |
int i; |
|
... |
... |
int editdistance(const char *s, const char *t){ |
115 |
125 |
if(ppcur < 0) ppcur += 3; |
if(ppcur < 0) ppcur += 3; |
116 |
126 |
|
|
117 |
127 |
v[cur][0] = i + 1; |
v[cur][0] = i + 1; |
|
128 |
|
|
|
129 |
|
int minDistance = INT_MAX; |
|
130 |
|
|
118 |
131 |
int j; |
int j; |
119 |
132 |
for(j = 0; j != b; j++){ |
for(j = 0; j != b; j++){ |
120 |
133 |
int cost = (s[i] == t[j]) ? 0 : 1; |
int cost = (s[i] == t[j]) ? 0 : 1; |
|
134 |
|
|
121 |
135 |
v[cur][j+1] = min(v[cur][j] + 1, min(v[pcur][j+1] + 1, v[pcur][j] + cost)); |
v[cur][j+1] = min(v[cur][j] + 1, min(v[pcur][j+1] + 1, v[pcur][j] + cost)); |
122 |
|
|
|
|
136 |
|
|
123 |
137 |
if(i > 0 && j > 0 && s[i] == t[j-1] && s[i-1] == t[j]){ |
if(i > 0 && j > 0 && s[i] == t[j-1] && s[i-1] == t[j]){ |
124 |
138 |
v[cur][j+1] = min(v[cur][j+1], v[ppcur][j-1] + cost); |
v[cur][j+1] = min(v[cur][j+1], v[ppcur][j-1] + cost); |
125 |
139 |
} |
} |
|
140 |
|
|
|
141 |
|
if(v[cur][j+1] < minDistance){ |
|
142 |
|
minDistance = v[cur][j+1]; |
|
143 |
|
} |
|
144 |
|
} |
|
145 |
|
|
|
146 |
|
if(minDistance > cutoff){ |
|
147 |
|
return cutoff + 1; |
126 |
148 |
} |
} |
127 |
149 |
} |
} |
128 |
150 |
pcur = cur -1; |
pcur = cur -1; |
|
... |
... |
void getsuggestions(const char *name, char *buff, int nTables, ...){ |
155 |
177 |
struct hashnode *hn; |
struct hashnode *hn; |
156 |
178 |
hn = ht->h[x]; |
hn = ht->h[x]; |
157 |
179 |
while (hn) { |
while (hn) { |
158 |
|
int dist = editdistance(hn->name, name); |
|
|
180 |
|
int dist = editdistance(hn->name, name, cutoff); |
159 |
181 |
if(dist <= cutoff){ |
if(dist <= cutoff){ |
160 |
182 |
count++; |
count++; |
161 |
183 |
int j; |
int j; |