File grammar.y changed (mode: 100644) (index 7bae07f..9173202) |
... |
... |
expr: intexpr { $$.ty = gInteger; } |
264 |
264 |
sprintf(ebuf, "Index missing for array variable %s", $1.str); |
sprintf(ebuf, "Index missing for array variable %s", $1.str); |
265 |
265 |
yyerrorex(3, ebuf); |
yyerrorex(3, ebuf); |
266 |
266 |
} |
} |
|
267 |
|
if(infunction && lookup(curtab, $1.str) && !lookup(&initialized, $1.str) ){ |
|
268 |
|
char ebuf[1024]; |
|
269 |
|
sprintf(ebuf, "Variable %s is uninitialized", $1.str); |
|
270 |
|
yyerrorex(3, ebuf); |
|
271 |
|
} |
267 |
272 |
$$.ty = tan->ty; |
$$.ty = tan->ty; |
268 |
273 |
} |
} |
269 |
274 |
| expr EQUALS expr {yyerrorex(0, "Single = in expression, should probably be =="); checkeqtest($1.ty, $3.ty); $$.ty = gBoolean;} |
| expr EQUALS expr {yyerrorex(0, "Single = in expression, should probably be =="); checkeqtest($1.ty, $3.ty); $$.ty = gBoolean;} |
|
... |
... |
funcdefn: NEWLINE |
388 |
393 |
; |
; |
389 |
394 |
|
|
390 |
395 |
funcdefncore: funcbegin localblock codeblock funcend { if(retval != gNothing) { if ($3.ty == gAny || $3.ty == gNone) yyerrorline(1, lineno - 1, "Missing return"); else if (returnbug) canconvertreturn($3.ty, retval, -1); } } |
funcdefncore: funcbegin localblock codeblock funcend { if(retval != gNothing) { if ($3.ty == gAny || $3.ty == gNone) yyerrorline(1, lineno - 1, "Missing return"); else if (returnbug) canconvertreturn($3.ty, retval, -1); } } |
391 |
|
| funcbegin localblock codeblock {yyerrorex(0, "Missing endfunction"); clear(¶ms); clear(&locals); curtab = &globals;} |
|
|
396 |
|
| funcbegin localblock codeblock {yyerrorex(0, "Missing endfunction"); clear(¶ms); clear(&locals); clear(&initialized); curtab = &globals;} |
392 |
397 |
; |
; |
393 |
398 |
|
|
394 |
|
funcend: ENDFUNCTION { clear(¶ms); clear(&locals); curtab = &globals; inblock = 0; inconstant = 0; } |
|
|
399 |
|
funcend: ENDFUNCTION { clear(¶ms); clear(&locals); clear(&initialized); curtab = &globals; inblock = 0; inconstant = 0; infunction = 0; } |
395 |
400 |
; |
; |
396 |
401 |
|
|
397 |
402 |
returnorreturns: RETURNS |
returnorreturns: RETURNS |
|
... |
... |
funcbegin: FUNCTION rid TAKES optparam_list returnorreturns opttype { |
409 |
414 |
yyerrorex(3, buf); |
yyerrorex(3, buf); |
410 |
415 |
} |
} |
411 |
416 |
inconstant = 0; |
inconstant = 0; |
|
417 |
|
infunction = 1; |
412 |
418 |
curtab = &locals; |
curtab = &locals; |
413 |
419 |
$$.fd = newfuncdecl(); |
$$.fd = newfuncdecl(); |
414 |
420 |
$$.fd->name = strdup($2.str); |
$$.fd->name = strdup($2.str); |
|
... |
... |
statement: NEWLINE {$$.ty = gAny;} |
498 |
504 |
} |
} |
499 |
505 |
if (inconstant) |
if (inconstant) |
500 |
506 |
validateGlobalAssignment($2.str); |
validateGlobalAssignment($2.str); |
|
507 |
|
if(!lookup(&initialized, $2.str)){ |
|
508 |
|
put(&initialized, $2.str, 1); |
|
509 |
|
} |
501 |
510 |
} |
} |
502 |
511 |
| SET rid LBRACKET expr RBRACKET EQUALS expr NEWLINE{ |
| SET rid LBRACKET expr RBRACKET EQUALS expr NEWLINE{ |
503 |
512 |
const struct typeandname *tan = getVariable($2.str); |
const struct typeandname *tan = getVariable($2.str); |
|
... |
... |
vardecl: vartypedecl NEWLINE { |
739 |
748 |
if (tan->isarray) { |
if (tan->isarray) { |
740 |
749 |
yyerrorex(3, "Arrays cannot be directly initialized"); |
yyerrorex(3, "Arrays cannot be directly initialized"); |
741 |
750 |
} |
} |
|
751 |
|
if(infunction && !lookup(&initialized, tan->name)){ |
|
752 |
|
put(&initialized, tan->name, 1); |
|
753 |
|
} |
742 |
754 |
canconvert($3.ty, tan->ty, -1); |
canconvert($3.ty, tan->ty, -1); |
743 |
755 |
$$.ty = gNothing; |
$$.ty = gNothing; |
744 |
756 |
} |
} |
File misc.c changed (mode: 100644) (index 78528ae..0319c74) |
... |
... |
int totlines; |
24 |
24 |
int islinebreak; |
int islinebreak; |
25 |
25 |
int isconstant; |
int isconstant; |
26 |
26 |
int inconstant; |
int inconstant; |
|
27 |
|
int infunction; |
27 |
28 |
int inblock; |
int inblock; |
28 |
29 |
int strict; |
int strict; |
29 |
30 |
int returnbug; |
int returnbug; |
|
... |
... |
int afterendglobals; |
33 |
34 |
int *showerrorlevel; |
int *showerrorlevel; |
34 |
35 |
|
|
35 |
36 |
int hashfunc(const char *name); |
int hashfunc(const char *name); |
36 |
|
struct hashtable functions, globals, locals, params, types; |
|
|
37 |
|
struct hashtable functions, globals, locals, params, types, initialized; |
37 |
38 |
struct hashtable *curtab; |
struct hashtable *curtab; |
38 |
39 |
struct typenode *retval, *retcheck; |
struct typenode *retval, *retcheck; |
39 |
40 |
char *curfile; |
char *curfile; |
|
... |
... |
void init(int argc, char **argv) |
70 |
71 |
inblock = 0; |
inblock = 0; |
71 |
72 |
isconstant = 0; |
isconstant = 0; |
72 |
73 |
inconstant = 0; |
inconstant = 0; |
|
74 |
|
infunction = 0; |
73 |
75 |
fFilter = fCondition = fCurrent = 0; |
fFilter = fCondition = fCurrent = 0; |
74 |
76 |
showerrorlevel = malloc(ERRORLEVELNUM*sizeof(int)); |
showerrorlevel = malloc(ERRORLEVELNUM*sizeof(int)); |
75 |
77 |
for(i=0;i<ERRORLEVELNUM;i++) |
for(i=0;i<ERRORLEVELNUM;i++) |
File misc.h changed (mode: 100644) (index 041ce5a..93bcd8f) |
... |
... |
void checkParameters(const struct paramlist *func, const struct paramlist *inp, |
83 |
83 |
void validateGlobalAssignment(const char *varname); |
void validateGlobalAssignment(const char *varname); |
84 |
84 |
void checkcomparisonsimple(const struct typenode *a); |
void checkcomparisonsimple(const struct typenode *a); |
85 |
85 |
|
|
86 |
|
extern int fno, lineno, totlines, islinebreak, isconstant, inblock, inconstant; |
|
|
86 |
|
extern int fno, lineno, totlines, islinebreak, isconstant, inblock, inconstant, infunction; |
87 |
87 |
extern int haderrors; |
extern int haderrors; |
88 |
88 |
extern int ignorederrors; |
extern int ignorederrors; |
89 |
89 |
extern int didparse; |
extern int didparse; |
|
... |
... |
extern int afterendglobals; |
94 |
94 |
extern char *yytext, *curfile; |
extern char *yytext, *curfile; |
95 |
95 |
extern int yydebug; |
extern int yydebug; |
96 |
96 |
int *showerrorlevel; |
int *showerrorlevel; |
97 |
|
extern struct hashtable functions, globals, locals, params, types, *curtab; |
|
|
97 |
|
extern struct hashtable functions, globals, locals, params, types, initialized, *curtab; |
98 |
98 |
extern struct typenode *gInteger, *gReal, *gBoolean, *gString, *gCode, *gHandle, *gNothing, *gNull, *gAny, *gNone, *gCodeReturnsBoolean, *gCodeReturnsNoBoolean; |
extern struct typenode *gInteger, *gReal, *gBoolean, *gString, *gCode, *gHandle, *gNothing, *gNull, *gAny, *gNone, *gCodeReturnsBoolean, *gCodeReturnsNoBoolean; |
99 |
99 |
extern struct funcdecl *fFilter, *fCondition, *fCurrent; |
extern struct funcdecl *fFilter, *fCondition, *fCurrent; |
100 |
100 |
extern struct typenode *retval; |
extern struct typenode *retval; |