GATE CS 2023 · Question 60 · Compiler Design · Numerical answer (NAT) · 2 marks · no negative marks

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. I₁ and F₁ denote occurrences of I and F on the right hand side of a production, respectively. For the tokens 0 and 1, 0.val = 0 and 1.val = 1.
N, →, I # F, N.val = I.val + F.val; I, →, I₁ B, I.val = (2 I₁.val) + B.val; I, →, B, I.val = B.val; F, →, B F₁, F.val = 1/2(B.val + F₁.val); F, →, B, F.val = 1/2 B.val; B, →, 0, B.val = 0.val; B, →, 1, B.val = 1.val
The value computed by the translation scheme for the input string
10#011
is ______. (Rounded off to three decimal places)

Answer

Answer between 2.374 and 2.376 (any value in this range is right)

Answer from the official GATE CS 2023 answer key.

The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes