GATEverse
← GATE CSE 2023

Q50

NAT2 marks

Consider the syntax directed translation given by the following grammar and semantic rules. Here N,I,FN, I, F and BB are non-terminals. NN is the starting non-terminal, and #,0\#, \mathbf{0} and 1\mathbf{1} are lexical tokens corresponding to input letters \text{“#", “0" and “1"}, respectively. X.valX.val denotes the synthesized attribute (a numeric value) associated with a non-terminal X.  I1X. \;I_{1} and F1F_{1} denote occurrences of II and FF on the right hand side of a production, respectively. For the tokens 0\mathbf{0} and 1,0.val=0\mathbf{1}, \mathbf{0} . v a l=0 and 1.val=1\mathbf{1}.val =1.

N→I#FN.val=I.val+F.valI→I1BI.val=(2I1.val)+B.valI→BI.val= B.val F→BF1F.val=12(B.val+F1.val)F→B F.val =12B.valB→0B.val=0.valB→1B.val=1.val\begin{array}{ll} N \rightarrow I \# F & N.val =I . v a l+F . v a l \\ I\rightarrow I_{1} B & I.val =\left(2 I_{1} . v a l\right)+B.val \\ I \rightarrow B & I.val =\text { B.val } \\ F \rightarrow B F_{1} & F.val =\frac{1}{2}\left(B . v a l+F_{1} . v a l\right) \\ F \rightarrow B & \text { F.val }=\frac{1}{2} B.val \\ B \rightarrow \mathbf{0} & B . v a l=\mathbf{0} . v a l \\ B \rightarrow \mathbf{1} & B . v a l=\mathbf{1} . v a l \\ \end{array}

The value computed by the translation scheme for the input string

10#01110\#011

is ____________. (Rounded off to three decimal places)

Sign in to save attempts.

Loading…