File grammar.y changed (mode: 100644) (index d443d63..cdb9431) |
... |
... |
funccall: rid LPAREN exprlistcompl RPAREN { |
293 |
293 |
sprintf(ebuf, "Call to non-constant function %s in constant function", $1.str); |
sprintf(ebuf, "Call to non-constant function %s in constant function", $1.str); |
294 |
294 |
yyerrorex(3, ebuf); |
yyerrorex(3, ebuf); |
295 |
295 |
} |
} |
|
296 |
|
if (fd == fCurrent && fCurrent) |
|
297 |
|
yyerrorex(3, "Recursive function calls are not permitted in local declarations"); |
296 |
298 |
checkParameters(fd->p, $3.pl, (fd==fFilter || fd==fCondition)); |
checkParameters(fd->p, $3.pl, (fd==fFilter || fd==fCondition)); |
297 |
299 |
$$.ty = fd->ret; |
$$.ty = fd->ret; |
298 |
300 |
} |
} |
299 |
301 |
} |
} |
300 |
|
| rid LPAREN exprlistcompl NEWLINE{ |
|
|
302 |
|
| rid LPAREN exprlistcompl NEWLINE { |
301 |
303 |
yyerrorex(0, "Missing ')'"); |
yyerrorex(0, "Missing ')'"); |
302 |
304 |
struct funcdecl *fd = lookup(&functions, $1.str); |
struct funcdecl *fd = lookup(&functions, $1.str); |
303 |
305 |
if (fd == NULL) { |
if (fd == NULL) { |
|
... |
... |
funccall: rid LPAREN exprlistcompl RPAREN { |
311 |
313 |
yyerrorex(3, ebuf); |
yyerrorex(3, ebuf); |
312 |
314 |
$$.ty = gNull; |
$$.ty = gNull; |
313 |
315 |
} else { |
} else { |
314 |
|
checkParameters(fd->p, $3.pl, (fd==fFilter || fd==fCondition)); |
|
315 |
|
$$.ty = fd->ret; |
|
|
316 |
|
if (fd == fCurrent && fCurrent) |
|
317 |
|
yyerrorex(3, "Recursive function calls are not permitted in local declarations"); |
|
318 |
|
checkParameters(fd->p, $3.pl, (fd==fFilter || fd==fCondition)); |
|
319 |
|
$$.ty = fd->ret; |
316 |
320 |
} |
} |
317 |
321 |
} |
} |
318 |
322 |
; |
; |
|
... |
... |
funcbegin: FUNCTION rid TAKES optparam_list returnorreturns opttype { |
409 |
413 |
$$.fd->ret = $6.ty; |
$$.fd->ret = $6.ty; |
410 |
414 |
$$.fd->isconst = 0; |
$$.fd->isconst = 0; |
411 |
415 |
put(&functions, $$.fd->name, $$.fd); |
put(&functions, $$.fd->name, $$.fd); |
|
416 |
|
fCurrent = lookup(&functions, $2.str); |
412 |
417 |
struct typeandname *tan = $4.pl->head; |
struct typeandname *tan = $4.pl->head; |
413 |
418 |
for (;tan; tan=tan->next) { |
for (;tan; tan=tan->next) { |
414 |
419 |
tan->lineno = lineno; |
tan->lineno = lineno; |
|
... |
... |
vartypedecl: type rid { |
706 |
711 |
put(curtab, "type", tan); } |
put(curtab, "type", tan); } |
707 |
712 |
; |
; |
708 |
713 |
|
|
709 |
|
localblock: /* empty */ |
|
|
714 |
|
localblock: endlocalsmarker |
710 |
715 |
| lvardecl localblock |
| lvardecl localblock |
711 |
716 |
| NEWLINE localblock |
| NEWLINE localblock |
712 |
717 |
; |
; |
713 |
718 |
|
|
|
719 |
|
endlocalsmarker: /* empty */ { fCurrent = 0; } |
|
720 |
|
; |
|
721 |
|
|
714 |
722 |
lvardecl: LOCAL vardecl { } |
lvardecl: LOCAL vardecl { } |
715 |
723 |
| CONSTANT LOCAL vardecl { yyerrorex(3, "Local variables can not be declared constant"); } |
| CONSTANT LOCAL vardecl { yyerrorex(3, "Local variables can not be declared constant"); } |
716 |
724 |
| typedef { yyerrorex(3,"Types can not be extended inside functions"); } |
| typedef { yyerrorex(3,"Types can not be extended inside functions"); } |
File misc.c changed (mode: 100644) (index f476144..88df964) |
11 |
11 |
#include "grammar.tab.h" |
#include "grammar.tab.h" |
12 |
12 |
#include "misc.h" |
#include "misc.h" |
13 |
13 |
|
|
14 |
|
#define VERSIONSTR "1.0i" |
|
|
14 |
|
#define VERSIONSTR "1.0j" |
15 |
15 |
#define ERRORLEVELNUM 4 |
#define ERRORLEVELNUM 4 |
16 |
16 |
|
|
17 |
17 |
int fno; |
int fno; |
|
... |
... |
struct hashtable *curtab; |
35 |
35 |
struct typenode *retval, *retcheck; |
struct typenode *retval, *retcheck; |
36 |
36 |
char *curfile; |
char *curfile; |
37 |
37 |
struct typenode *gInteger, *gReal, *gBoolean, *gString, *gCode, *gHandle, *gNothing, *gNull, *gAny, *gNone, *gCodeReturnsBoolean, *gCodeReturnsNoBoolean; |
struct typenode *gInteger, *gReal, *gBoolean, *gString, *gCode, *gHandle, *gNothing, *gNull, *gAny, *gNone, *gCodeReturnsBoolean, *gCodeReturnsNoBoolean; |
38 |
|
struct funcdecl *fFilter, *fCondition; |
|
|
38 |
|
struct funcdecl *fFilter, *fCondition, *fCurrent; |
39 |
39 |
|
|
40 |
40 |
void addPrimitiveType(const char *name, struct typenode **toSave) |
void addPrimitiveType(const char *name, struct typenode **toSave) |
41 |
41 |
{ |
{ |
|
... |
... |
void init(int argc, char **argv) |
66 |
66 |
inblock = 0; |
inblock = 0; |
67 |
67 |
isconstant = 0; |
isconstant = 0; |
68 |
68 |
inconstant = 0; |
inconstant = 0; |
|
69 |
|
fFilter = fCondition = fCurrent = 0; |
69 |
70 |
showerrorlevel = malloc(ERRORLEVELNUM*sizeof(int)); |
showerrorlevel = malloc(ERRORLEVELNUM*sizeof(int)); |
70 |
71 |
for(i=0;i<ERRORLEVELNUM;i++) |
for(i=0;i<ERRORLEVELNUM;i++) |
71 |
72 |
showerrorlevel[i] = 1; |
showerrorlevel[i] = 1; |
File misc.h changed (mode: 100644) (index 95d8bb6..e6ba873) |
... |
... |
extern int yydebug; |
92 |
92 |
int *showerrorlevel; |
int *showerrorlevel; |
93 |
93 |
extern struct hashtable functions, globals, locals, params, types, *curtab; |
extern struct hashtable functions, globals, locals, params, types, *curtab; |
94 |
94 |
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; |
95 |
|
extern struct funcdecl *fFilter, *fCondition; |
|
|
95 |
|
extern struct funcdecl *fFilter, *fCondition, *fCurrent; |
96 |
96 |
extern struct typenode *retval; |
extern struct typenode *retval; |
97 |
97 |
const struct typeandname *getVariable(const char *varname); |
const struct typeandname *getVariable(const char *varname); |
98 |
98 |
void isnumeric(const struct typenode *ty); |
void isnumeric(const struct typenode *ty); |