Topics in Syntax Directed Translation

Filter by year

Syntax Directed Translation questions

Q37

GATE CS 2024 CS-1Syntax Directed TranslationMCQ2 marks−2/3 if wrong
Consider the following syntax-directed definition (SDD).
S→DHTU{S.val=D.val+H.val+T.val+U.val;}S \to DHTU \{ S.val = D.val + H.val + T.val + U.val; \}
D→"M"D1{D.val=5+D1.val;}D \to \text{"M"}D_1 \{ D.val = 5 + D_1.val; \}
D→ϵ{D.val=−5;}D \to \epsilon \{ D.val = -5; \}
H→"L"H1{H.val=5∗10+H1.val;}H \to \text{"L"}H_1 \{ H.val = 5 * 10 + H_1.val; \}
H→ϵ{H.val=−10;}H \to \epsilon \{ H.val = -10; \}
T→"C"T1{T.val=5∗100+T1.val;}T \to \text{"C"}T_1 \{ T.val = 5 * 100 + T_1.val; \}
T→ϵ{T.val=−5;}T \to \epsilon \{ T.val = -5; \}
U→"K"{U.val=5;}U \to \text{"K"} \{ U.val = 5; \}
Given "MMLK" as the input, which one of the following options is the CORRECT value computed by the SDD (in the attribute S.valS.val)?
Show answer without attempting

Answer: A

Q29

GATE CS 2024 CS-2Syntax Directed TranslationMSQ1 mark
Which of the following statements is/are FALSE?
More than one option can be correct.
Show answer without attempting

Answer: B, D

0/20 correct0 marks

Related topics in Compiler Design