GATE CS 2024, set 1 · Question 37 · Compiler Design · Multiple choice (MCQ) · 2 marks · −2/3 for a wrong answer
Consider the following syntax-directed definition (SDD).
Given "MMLK" as the input, which one of the following options is the CORRECT value computed by the SDD (in the attribute S.val)?
| S → DHTU | { S.val = D.val + H.val + T.val + U.val; } |
|---|---|
| D → "M"D₁ | { D.val = 5 + D₁.val; } |
| D → ε | { D.val = -5; } |
| H → "L"H₁ | { H.val = 5 ∗ 10 + H₁.val; } |
| H → ε | { H.val = -10; } |
| T → "C"T₁ | { T.val = 5 ∗ 100 + T₁.val; } |
| T → ε | { T.val = -5; } |
| U → "K" | { U.val = 5; } |
- (A) 45
- (B) 50
- (C) 55
- (D) 65
Answer
Answer (A)
Answer from the official GATE CS 2024 answer key.
The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes