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)?
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2024 Set 1 · Q37
Time

Select one answerSingle correct
Solution
Official answer: A) 45
Syntax-Directed TranslationTo find for the input string "MMLK", we parse the input according to the grammar [cite: 7]:
Evaluating for substring "MM":
Evaluating for substring "L":
Evaluating for substring :
Evaluating for substring "K":
Evaluating :
Therefore, the correct option is (A).
Try the question first, then check your work.
Examiner trap
Break down the input string "MMLK" into sub-derivations for , , , and , then compute the synthesized attributes bottom-up.
This Syntax-Directed Translation previous year question is Q37 of the GATE CSE 2024 Set 1 paper. Find more GATE CSE PYQs on Syntax-Directed Translation in Compiler Design, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Syntax-Directed Translation PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Syntax-Directed Translation has 9 GATE CSE PYQs across 9 papers from 2016 to 2026. 4 of them are 2-mark MCQs like this one, and it is the only one in GATE CSE 2024 Set 1.
How GATE tests Syntax-Directed TranslationIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.