Consider the following grammar and the semantic actions to support the inherited type declaration attributes. Let X1,X2,X3,X4,X5 and X6 be the place holders for the non-terminals D, T, L or L1 in the following table:
Production rule | Semantic action |
D→TL | X1.type=X2.type |
T→int | T.type = int |
T→Float | T.type = float |
L→L1.id | X3.type=X4.type add Type (id.entry, X5. type) |
L→id | add Type (id. entry, X6. type) |