File grammar.y changed (mode: 100644) (index 51f20ef..840e539) |
... |
... |
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, 1024, 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, 1024, 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, 1024, 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)) { |
|
... |
... |
statement: NEWLINE { $$.ty = gNone; } |
521 |
521 |
} |
} |
522 |
522 |
| SET rid LBRACKET expr RBRACKET EQUALS expr NEWLINE{ |
| SET rid LBRACKET expr RBRACKET EQUALS expr NEWLINE{ |
523 |
523 |
const struct typeandname *tan = getVariable($2.str); |
const struct typeandname *tan = getVariable($2.str); |
|
524 |
|
$$.ty = gNone; |
524 |
525 |
if (tan->ty != gAny) { |
if (tan->ty != gAny) { |
525 |
526 |
canconvert($4.ty, gInteger, -1); |
canconvert($4.ty, gInteger, -1); |
526 |
|
$$.ty = gNone; |
|
527 |
527 |
if (!tan->isarray) { |
if (!tan->isarray) { |
528 |
528 |
char ebuf[1024]; |
char ebuf[1024]; |
529 |
529 |
snprintf(ebuf, 1024, "%s is not an array", $2.str); |
snprintf(ebuf, 1024, "%s is not an array", $2.str); |
|
... |
... |
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, 1024, 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 b88e689..bbc8363) |
... |
... |
int editdistance(const char *s, const char *t, int cutoff){ |
157 |
157 |
return d; |
return d; |
158 |
158 |
} |
} |
159 |
159 |
|
|
160 |
|
void getsuggestions(const char *name, char *buff, int nTables, ...){ |
|
|
160 |
|
void getsuggestions(const char *name, char *buff, int buffsize, int nTables, ...){ |
161 |
161 |
int i; |
int i; |
162 |
162 |
va_list ap; |
va_list ap; |
163 |
163 |
|
|
|
... |
... |
void getsuggestions(const char *name, char *buff, int nTables, ...){ |
207 |
207 |
} |
} |
208 |
208 |
va_end(ap); |
va_end(ap); |
209 |
209 |
|
|
210 |
|
if(count==0) |
|
211 |
|
return; |
|
212 |
|
else if(count == 1){ |
|
213 |
|
char hbuff[1024]; |
|
|
210 |
|
char hbuff[1024]; |
|
211 |
|
if(count == 1){ |
214 |
212 |
snprintf(hbuff, 1024, ". Maybe you meant %s", suggestions[0].name); |
snprintf(hbuff, 1024, ". Maybe you meant %s", suggestions[0].name); |
215 |
|
strcat(buff, hbuff); |
|
216 |
|
}else{ |
|
217 |
|
strcat(buff, ". Maybe you meant "); |
|
218 |
|
for(i=0; suggestions[i].name; i++){ |
|
219 |
|
strcat(buff, suggestions[i].name); |
|
220 |
|
if(i!=2 && suggestions[i+1].name) |
|
221 |
|
strcat(buff, ", "); |
|
222 |
|
} |
|
|
213 |
|
strncat(buff, hbuff, buffsize); |
|
214 |
|
}else if(count == 2){ |
|
215 |
|
snprintf(hbuff, 1024, ". Maybe you meant %s or %s", suggestions[0].name, suggestions[1].name); |
|
216 |
|
strncat(buff, hbuff, buffsize); |
|
217 |
|
}else if(count >= 3){ |
|
218 |
|
snprintf(hbuff, 1024, ". Maybe you meant %s, %s or %s", suggestions[0].name, suggestions[1].name, suggestions[2].name); |
|
219 |
|
strncat(buff, hbuff, buffsize); |
223 |
220 |
} |
} |
224 |
221 |
} |
} |
225 |
222 |
|
|
|
... |
... |
const struct typeandname *getVariable(const char *varname) |
235 |
232 |
result = lookup(&globals, varname); |
result = lookup(&globals, varname); |
236 |
233 |
if (result) return result; |
if (result) return result; |
237 |
234 |
snprintf(ebuf, 1024, "Undeclared variable %s", varname); |
snprintf(ebuf, 1024, "Undeclared variable %s", varname); |
238 |
|
getsuggestions(varname, ebuf, 3, &locals, ¶ms, &globals); |
|
|
235 |
|
getsuggestions(varname, ebuf, 1024, 3, &locals, ¶ms, &globals); |
239 |
236 |
yyerrorline(2, islinebreak ? lineno - 1 : lineno, ebuf); |
yyerrorline(2, islinebreak ? lineno - 1 : lineno, ebuf); |
240 |
237 |
// Store it as unidentified variable |
// Store it as unidentified variable |
241 |
238 |
put(curtab, varname, newtypeandname(gAny, varname)); |
put(curtab, varname, newtypeandname(gAny, varname)); |
File misc.h changed (mode: 100644) (index 71dc23c..b2f8834) |
... |
... |
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, 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); |