GATEverse Practice, past papers & mock tests
GATE 2023 · CS - Forenoon
Compiler DesignParsing TechniqueshardNAT2 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. I1 and F1 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.

GRAMMAR RULES
NI # F { N.val = I.val + F.val }
II1 B { I.val = (2 * I1.val) + B.val }
IB { I.val = B.val }
FB F1 { F.val = (1/2) * (B.val + F1.val) }
FB { F.val = (1/2) * B.val }
B0 { B.val = 0.val }
B1 { B.val = 1.val } The value computed by the translation scheme for the input string 10#011 is __________. (Rounded off to three decimal places)
Save your progress

Related Compiler Design PYQs