diff options
-rw-r--r-- | sem_check.c | 6 | ||||
-rw-r--r-- | tree.c | 9 |
2 files changed, 9 insertions, 6 deletions
diff --git a/sem_check.c b/sem_check.c index 3d42996..c5e9fb6 100644 --- a/sem_check.c +++ b/sem_check.c @@ -107,7 +107,7 @@ ptree *t; yyerror("Incomplete parse tree\n"); if (t->l->ret_type == t->r->ret_type) - return 0; + return 1; else { snprintf(buf, 100, "Mismached types: " "Cannot assign type %s " @@ -142,13 +142,13 @@ ptree *t; if (t->l->ret_type != BOOL) yyerror("If condition must be of type BOOL\n"); - return 0; + return 1; case FOR: /*TODO add for type checking after parsing is correct*/ break; default: return -200; - snprintf(buf, 101, "Unknown tree node: %d...\n", t->type); + snprintf(buf, 100, "Unknown tree node: %d...\n", t->type); yyerror(buf); } @@ -21,6 +21,7 @@ ptree *l, *r; t->type = type; t->l = l; t->r = r; + t->ret_type = 0; return t; } @@ -90,10 +91,12 @@ ptree *t; { if (!t) return; - - set_ret_type(t->l); - set_ret_type(t->r); + if (! (t->l && t->l->ret_type == 1)) + set_ret_type(t->l); + if (! (t->r && t->r->ret_type == 1)) + set_ret_type(t->r); + t->ret_type = check_ret_type(t); return; |