GATE CS 2019 · Question 46 · Compiler Design · Multiple choice (MCQ) · 2 marks · −2/3 for a wrong answer
Consider the following grammar and the semantic actions to support the inherited type declaration attributes. Let X₁, X₂, X₃, X₄, X₅, and X₆ be the placeholders for the non-terminals D, T, L or L₁ in the following table:
Which one of the following are the appropriate choices for X₁, X₂, X₃ and X₄?
| Production rule | Semantic action |
|---|---|
| D → T L | X₁.type = X₂.type |
| T → int | T.type = int |
| T → float | T.type = float |
| L → L₁ , id | X₃.type = X₄.type; addType(id.entry, X₅.type) |
| L → id | addType(id.entry, X₆.type) |
- (A) X₁ = L, X₂ = T, X₃ = L₁, X₄ = L
- (B) X₁ = T, X₂ = L, X₃ = L₁, X₄ = T
- (C) X₁ = L, X₂ = L, X₃ = L₁, X₄ = T
- (D) X₁ = T, X₂ = L, X₃ = T, X₄ = L₁
Answer
Answer (A)
Answer from the official GATE CS 2019 answer key.
The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes