GATE CS 2023 (Forenoon) — Question 60

Compiler DesignSyntax-Directed Translation & Runtime EnvironmentsNAT2 marksHard

Consider the syntax directed translation given by the following grammar and semantic rules. Here N, I, F and B are non-terminals. N is the starting non-terminal, and #, 0 and 1 are lexical tokens corresponding to input letters "#", "0" and "1", respectively. X.val denotes the synthesized attribute (a numeric value) associated with a non-terminal X. \(\text{I}_1\) and \(\text{F}_1\) denote occurrences of I and F on the right hand side of a production, respectively. For the tokens 0 and 1, \(0\text{.val} = 0\) and \(1\text{.val} = 1\). \(\text{N} \rightarrow \text{I} \# \text{F}\) \(\text{N.val} = \text{I.val} + \text{F.val}\) \(\text{I} \rightarrow \text{I}_1 \text{B}\) \(\text{I.val} = (2 \text{I}_1\text{.val}) + \text{B.val}\) \(\text{I} \rightarrow \text{B}\) \(\text{I.val} = \text{B.val}\) \(\text{F} \rightarrow \text{B} \text{F}_1\) \(\text{F.val} = \frac{1}{2}(\text{B.val} + \text{F}_1\text{.val})\) \(\text{F} \rightarrow \text{B}\) \(\text{F.val} = \frac{1}{2}\text{B.val}\) \(\text{B} \rightarrow 0\) \(\text{B.val} = 0\text{.val}\) \(\text{B} \rightarrow 1\) \(\text{B.val} = 1\text{.val}\) The value computed by the translation scheme for the input string 10#011 is ________. (Rounded off to three decimal places)
Practise the full 2023-FN paper
Challenge a friend: WhatsApp Telegram
Recommended book · affiliate linkCompilers: Principles, Techniques & ToolsThe "Dragon Book" for parsing, syntax-directed translation and code generation.
Practise more on Syntax-Directed Translation & Runtime EnvironmentsTimed, in the real exam interface · free to start

A GATE question every morning

One real past-paper question every morning for your branch, answer hidden until you tap. Free on Telegram.

Join
Stuck? Ask in the student group