aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c6
-rw-r--r--node.c2
-rw-r--r--pc.y2
-rw-r--r--tree.c7
4 files changed, 13 insertions, 4 deletions
diff --git a/main.c b/main.c
index dba3b7f..6ded432 100644
--- a/main.c
+++ b/main.c
@@ -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) {
diff --git a/node.c b/node.c
index 586ed52..0e87370 100644
--- a/node.c
+++ b/node.c
@@ -15,6 +15,8 @@ char *str;
p->name = strdup(str);
p->next = NULL;
+ p->var_type = -1;
+
return p;
}
diff --git a/pc.y b/pc.y
index 92a1f0c..81cb69b 100644
--- a/pc.y
+++ b/pc.y
@@ -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);
}
;
diff --git a/tree.c b/tree.c
index e0216fd..71feb5b 100644
--- a/tree.c
+++ b/tree.c
@@ -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;