aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTucker Evans <tuckerevans24@gmail.com>2019-07-14 13:21:02 -0400
committerTucker Evans <tuckerevans24@gmail.com>2019-07-14 13:21:02 -0400
commit4c7b69798d350d99b7f97ced630050fbd63c804b (patch)
treeaaeb806d5c1dbec51b0946f9a2213f0bbf177593
parent1fdd25198b2e8fb055bab5d5aba8aacb422cadbc (diff)
Fix assigned types in rules
-rw-r--r--pc.y14
1 files changed, 8 insertions, 6 deletions
diff --git a/pc.y b/pc.y
index 53b1b6e..f6f4d33 100644
--- a/pc.y
+++ b/pc.y
@@ -107,7 +107,8 @@ id_list
var_declarations
:var_declarations VAR id_list ':' type ';'
{
- for(tmp = var_list; tmp != NULL; tmp = tmp->next) {
+ ptree *tmp;
+ for(tmp = $3; tmp; tmp = tmp->l) {
tmp->type = $5;
}
}
@@ -121,7 +122,7 @@ type
}
|ARRAY '[' INUM DOTS INUM ']' OF standard_type
{
- $$ = $ARRAY - $6;
+ $$ = ARRAY - $8;
}
;
@@ -180,6 +181,7 @@ compound_statement
:BEG opt_statements END
{
$$ = $2;
+ print_tree($$);
}
;
@@ -223,14 +225,14 @@ statement
}
|WHILE expr DO statement
{
- $$ = mktree(WHILE, $2, $4)
+ $$ = mktree(WHILE, $2, $4);
}
;
var
:ID
{
- $$ = mkid($1)
+ $$ = mkid($1);
}
|ID '[' expr ']'
{
@@ -285,7 +287,7 @@ simple_expr
term
:factor
{
- $$ = mktree(LIST, $1, $3);
+ $$ = $1;
}
|term MULOP factor
{
@@ -300,7 +302,7 @@ factor
}
|ID '[' expr ']'
{
- $$ = mktree(ARRAY_ACCESS, mkid($1), $3)
+ $$ = mktree(ARRAY_ACCESS, mkid($1), $3);
}
|ID '(' expr_list ')'
{