GATE | GATE CS 2019 | Question 45
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 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?
(A) X1 = L, X2 = T, X3 = L1, X4 = L
(B) X1 = L, X2 = L, X3 = L1, X4 = T
(C) X1 = T, X2 = L, X3 = L1, X4 = T
(D) X1 = T, X2 = L, X3 = T, X4 = L1
Answer: (A)
Explanation: According to Inherited attribute definition, an attribute is inherited if the attribute value of a parse-tree node is determined from attribute values of its parent and siblings.
So, semantic rules should be as following below:
D → TL {L.idtype = T.stype}
T → int {T.stype = int}
T → float {T.stype = float}
L → L1, id {L1.itype = L.itype}
addtype(id.entry, L.itype)
L → id addtype(id.entry, L.itype)
Option (A) is correct.
Quiz of this Question
Recommended Posts:
- GATE | GATE CS 2019 | Question 40
- GATE | GATE CS 2019 | Question 41
- GATE | GATE CS 2019 | Question 31
- GATE | GATE CS 2019 | Question 32
- GATE | GATE CS 2019 | Question 31
- GATE | GATE CS 2019 | Question 30
- GATE | GATE CS 2019 | Question 29
- GATE | GATE CS 2019 | Question 29
- GATE | GATE CS 2019 | Question 28
- GATE | GATE CS 2019 | Question 27
- GATE | GATE CS 2019 | Question 26
- GATE | GATE CS 2019 | Question 32
- GATE | GATE CS 2019 | Question 33
- GATE | GATE CS 2019 | Question 40
- GATE | GATE CS 2019 | Question 39



