diff options
author | Tucker Evans <tuckerevans24@gmail.com> | 2019-08-29 11:57:55 -0400 |
---|---|---|
committer | Tucker Evans <tuckerevans24@gmail.com> | 2019-08-29 11:57:55 -0400 |
commit | 389c2765afebb0b6112493e53117405488a4f3f1 (patch) | |
tree | dd7c2a94fb92cfc619d6ac49bb94d7bd5d1fe418 | |
parent | 6f3310ddead0a00c6b8c1d2085fd0e83a1ada827 (diff) |
Add for loop type checking
-rw-r--r-- | sem_check.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/sem_check.c b/sem_check.c index 88f41ad..773c70a 100644 --- a/sem_check.c +++ b/sem_check.c @@ -141,7 +141,27 @@ ptree *t; yyerror("If condition must be of type BOOL\n"); return 1; case FOR: - /*TODO add for type checking after parsing is correct*/ + /* + FOR (0) + / \ + TD(0) STATEMENT(0) + / \ + ASSIGNOP(0) INUM(INT) + */ + if (!(t->r && t->l)) + yyerror("Missing nodes\n"); + if (t->l->ret_type == 1 && t->r->ret_type == 1) + return 1; + snprintf(buf, 100, "Incorrect types in for statement...\n"); + break; + case TO: + case DT: + if (!(t->r && t->l)) + yyerror("Missing nodes\n"); + + if (t->l->ret_type == 1 && t->r->ret_type == INT) + return 1; + snprintf(buf, 100, "Incorrect types HERE...\n"); break; default: return -200; |