File grammar.y changed (mode: 100644) (index ef9c482..51f20ef) |
... |
... |
expr: intexpr { $$.ty = gInteger; } |
199 |
199 |
if (fd == NULL) { |
if (fd == NULL) { |
200 |
200 |
char ebuf[1024]; |
char ebuf[1024]; |
201 |
201 |
snprintf(ebuf, 1024, "Undefined function %s", $2.str); |
snprintf(ebuf, 1024, "Undefined function %s", $2.str); |
202 |
|
//getsuggestions($2.str, ebuf, 1, &functions); |
|
|
202 |
|
getsuggestions($2.str, ebuf, 1, &functions); |
203 |
203 |
yyerrorex(3, ebuf); |
yyerrorex(3, ebuf); |
204 |
204 |
$$.ty = gCode; |
$$.ty = gCode; |
205 |
205 |
} else { |
} else { |
|
... |
... |
funccall: rid LPAREN exprlistcompl RPAREN { |
289 |
289 |
if (fd == NULL) { |
if (fd == NULL) { |
290 |
290 |
char ebuf[1024]; |
char ebuf[1024]; |
291 |
291 |
snprintf(ebuf, 1024, "Undeclared function %s", $1.str); |
snprintf(ebuf, 1024, "Undeclared function %s", $1.str); |
292 |
|
//getsuggestions($1.str, ebuf, 1, &functions); |
|
|
292 |
|
getsuggestions($1.str, ebuf, 1, &functions); |
293 |
293 |
yyerrorex(3, ebuf); |
yyerrorex(3, ebuf); |
294 |
294 |
$$.ty = gAny; |
$$.ty = gAny; |
295 |
295 |
} else { |
} else { |
|
... |
... |
funccall: rid LPAREN exprlistcompl RPAREN { |
310 |
310 |
if (fd == NULL) { |
if (fd == NULL) { |
311 |
311 |
char ebuf[1024]; |
char ebuf[1024]; |
312 |
312 |
snprintf(ebuf, 1024, "Undeclared function %s", $1.str); |
snprintf(ebuf, 1024, "Undeclared function %s", $1.str); |
313 |
|
//getsuggestions($1.str, ebuf, 1, &functions); |
|
|
313 |
|
getsuggestions($1.str, ebuf, 1, &functions); |
314 |
314 |
yyerrorex(3, ebuf); |
yyerrorex(3, ebuf); |
315 |
315 |
$$.ty = gAny; |
$$.ty = gAny; |
316 |
316 |
} else if (inconstant && !(fd->isconst)) { |
} else if (inconstant && !(fd->isconst)) { |
|
... |
... |
type: primtype { $$.ty = $1.ty; } |
826 |
826 |
if (lookup(&types, $1.str) == NULL) { |
if (lookup(&types, $1.str) == NULL) { |
827 |
827 |
char buf[1024]; |
char buf[1024]; |
828 |
828 |
snprintf(buf, 1024, "Undefined type %s", $1.str); |
snprintf(buf, 1024, "Undefined type %s", $1.str); |
829 |
|
//getsuggestions($1.str, buf, 1, &types); |
|
|
829 |
|
getsuggestions($1.str, buf, 1, &types); |
830 |
830 |
yyerrorex(3, buf); |
yyerrorex(3, buf); |
831 |
831 |
$$.ty = gAny; |
$$.ty = gAny; |
832 |
832 |
} |
} |
File misc.c changed (mode: 100644) (index 2c63c5b..b88e689) |
... |
... |
int editdistance(const char *s, const char *t, int cutoff){ |
156 |
156 |
free(v[i]); |
free(v[i]); |
157 |
157 |
return d; |
return d; |
158 |
158 |
} |
} |
159 |
|
#if 0 |
|
|
159 |
|
|
160 |
160 |
void getsuggestions(const char *name, char *buff, int nTables, ...){ |
void getsuggestions(const char *name, char *buff, int nTables, ...){ |
161 |
|
return; |
|
162 |
161 |
int i; |
int i; |
163 |
162 |
va_list ap; |
va_list ap; |
164 |
163 |
|
|
|
... |
... |
void getsuggestions(const char *name, char *buff, int nTables, ...){ |
171 |
170 |
suggestions[i].distance = INT_MAX; |
suggestions[i].distance = INT_MAX; |
172 |
171 |
suggestions[i].name = NULL; |
suggestions[i].name = NULL; |
173 |
172 |
} |
} |
174 |
|
/* |
|
|
173 |
|
|
175 |
174 |
va_start(ap, nTables); |
va_start(ap, nTables); |
176 |
175 |
for(i = 0; i != nTables; i++){ |
for(i = 0; i != nTables; i++){ |
177 |
176 |
struct hashtable *ht = va_arg(ap, struct hashtable*); |
struct hashtable *ht = va_arg(ap, struct hashtable*); |
|
... |
... |
void getsuggestions(const char *name, char *buff, int nTables, ...){ |
181 |
180 |
struct hashnode *hn; |
struct hashnode *hn; |
182 |
181 |
hn = ht->h[x]; |
hn = ht->h[x]; |
183 |
182 |
while (hn) { |
while (hn) { |
184 |
|
int dist = 0;//editdistance(hn->name, name, cutoff); |
|
|
183 |
|
int dist = editdistance(hn->name, name, cutoff); |
185 |
184 |
if(dist <= cutoff){ |
if(dist <= cutoff){ |
186 |
|
//printf("Possible suggestion for %s: %s\n", name, hn->name); |
|
187 |
|
|
|
188 |
185 |
count++; |
count++; |
189 |
186 |
int j; |
int j; |
190 |
187 |
for(j = 0; j != 3; j++){ |
for(j = 0; j != 3; j++){ |
|
... |
... |
void getsuggestions(const char *name, char *buff, int nTables, ...){ |
209 |
206 |
|
|
210 |
207 |
} |
} |
211 |
208 |
va_end(ap); |
va_end(ap); |
212 |
|
*/ |
|
213 |
209 |
|
|
214 |
210 |
if(count==0) |
if(count==0) |
215 |
211 |
return; |
return; |
|
... |
... |
void getsuggestions(const char *name, char *buff, int nTables, ...){ |
226 |
222 |
} |
} |
227 |
223 |
} |
} |
228 |
224 |
} |
} |
229 |
|
#endif |
|
|
225 |
|
|
230 |
226 |
|
|
231 |
227 |
const struct typeandname *getVariable(const char *varname) |
const struct typeandname *getVariable(const char *varname) |
232 |
228 |
{ |
{ |
|
... |
... |
const struct typeandname *getVariable(const char *varname) |
239 |
235 |
result = lookup(&globals, varname); |
result = lookup(&globals, varname); |
240 |
236 |
if (result) return result; |
if (result) return result; |
241 |
237 |
snprintf(ebuf, 1024, "Undeclared variable %s", varname); |
snprintf(ebuf, 1024, "Undeclared variable %s", varname); |
242 |
|
//getsuggestions(varname, ebuf, 3, &locals, ¶ms, &globals); |
|
|
238 |
|
getsuggestions(varname, ebuf, 3, &locals, ¶ms, &globals); |
243 |
239 |
yyerrorline(2, islinebreak ? lineno - 1 : lineno, ebuf); |
yyerrorline(2, islinebreak ? lineno - 1 : lineno, ebuf); |
244 |
240 |
// Store it as unidentified variable |
// Store it as unidentified variable |
245 |
241 |
put(curtab, varname, newtypeandname(gAny, varname)); |
put(curtab, varname, newtypeandname(gAny, varname)); |
File misc.h changed (mode: 100644) (index 306abf4..71dc23c) |
... |
... |
struct hashtable { |
59 |
59 |
struct hashnode *h[BUCKETS]; |
struct hashnode *h[BUCKETS]; |
60 |
60 |
}; |
}; |
61 |
61 |
|
|
62 |
|
//void getsuggestions(const char*, char*, int, ...); |
|
|
62 |
|
void getsuggestions(const char*, char*, int, ...); |
63 |
63 |
void *lookup(struct hashtable *h, const char *name); |
void *lookup(struct hashtable *h, const char *name); |
64 |
64 |
void put(struct hashtable *h, const char *name, void *val); |
void put(struct hashtable *h, const char *name, void *val); |
65 |
65 |
void clear(struct hashtable *h); |
void clear(struct hashtable *h); |