Synthesized-and-L-Attribute
Question 1 |
Consider the following grammar and the semantic actions to support the inheritance type declaration attributes. Let X1, X2, X3, X4, X5 and X6 be the placeholders for the non-terminals D, T, L or L1 in the following table:

Which one of the following are the appropriate choices for X1, X2, X3 and X4?
X1 = L, X2 = L, X3 = L1, X4 = T | |
X1 = L, X2 = T, X3 = L1, X4 = L | |
X1 = T, X2 = L, X3 = L1, X4 = T | |
X1 = T, X2 = L, X3 = T, X4 = L1 |
Question 1 Explanation:
Since the production,
L → L1, id {X3.type = X4.type } , this production has L and L1, hence X3 and X4 cannot be T.
So option 1, 3 and 4 cannot be correct.
Hence, 2 is correct answer.
L → L1, id {X3.type = X4.type } , this production has L and L1, hence X3 and X4 cannot be T.
So option 1, 3 and 4 cannot be correct.
Hence, 2 is correct answer.