diff options
author | Tucker Evans <tuckerevans24@gmail.com> | 2019-08-04 21:52:30 -0400 |
---|---|---|
committer | Tucker Evans <tuckerevans24@gmail.com> | 2019-08-04 21:52:30 -0400 |
commit | a359edde7c8806687c4f0307dbfc6f77077ba063 (patch) | |
tree | 8a06fa32ce403cb961b6a32ecce7c19d78c40fb1 | |
parent | 0caa6768c7055c3e3fb2f2ebeda2c35152ea011b (diff) |
Fix updating type on single variable declarations
-rw-r--r-- | main.c | 6 | ||||
-rw-r--r-- | node.c | 2 | ||||
-rw-r--r-- | pc.y | 2 | ||||
-rw-r--r-- | tree.c | 7 |
4 files changed, 13 insertions, 4 deletions
@@ -17,10 +17,10 @@ int t; { if (t == ARRAY) { return "ARRAY"; - } else if (t == INT - ARRAY) { - return "ARRAY of INT"; - } else if (t == INT - ARRAY) { + } else if (t == ARRAY - INT) { return "ARRAY of INT"; + } else if (t == ARRAY - REAL) { + return "ARRAY of REAL"; } else if (t == INT) { return "INT"; } else if (t == REAL) { @@ -15,6 +15,8 @@ char *str; p->name = strdup(str); p->next = NULL; + p->var_type = -1; + return p; } @@ -192,10 +192,12 @@ param_list :id_list ':' type { $$ = $1; + update_type_info($1, $3); } |param_list ';' id_list ':' type { $$ = mktree(LIST, $1, $3); + update_type_info($3, $5); } ; @@ -61,10 +61,15 @@ int type; ptree *list; { assert(list); + if (list->type == ID) { + list->attr.nval->var_type = type; + return; + } + while (list->r && list->r->type == ID) { /*Set type of right child through list*/ list->r->attr.nval->var_type = type; - + if (list->l) { if (list->l->type == LIST) { list = list->l; |