a)
b)
The assignment is type correct.
Traversing the parse tree would lead to the following reductions:
Reduction | <E>.actualType |
E->ident(b) | int |
E->ident(c) | int |
E->ident(d) | float |
E->E+E | int and float = float |
E->(E) | float |
E->E*E | int * float = float |
A->ident = E | float |
In the last production A->ident(a) = E, since typeLookUp(a) = float, so <E>.permitableTypes appears to be {int,float}, and on traversing the parse tree by the above reductions, the type of <E> also comes out to be float, hence the assignment is type correct.
Each numbered item has approximately the same weight. There are a few extra points built into the scoring system. Partial credit is available. Show all work! Answers without adequate support wi...