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; }
  1. (A) 45
  2. (B) 50
  3. (C) 55
  4. (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