Redirected
edited by
7,324 views
4 votes
4 votes
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 $\#, \mathbf{0}$ and $\mathbf{1}$ are lexical tokens corresponding to input letters $\text{“#", “0" and “1"},$ respectively. $X.val$ denotes the synthesized attribute (a numeric value) associated with a non-terminal $X. \;I_{1}$ and $F_{1}$ denote occurrences of $I$ and $F$ on the right hand side of a production, respectively. For the tokens $\mathbf{0}$ and $\mathbf{1}, \mathbf{0} . v a l=0$ and $\mathbf{1}.val =1$.
\[
\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\#011$$
is ____________. (Rounded off to three decimal places)
edited by

2 Answers

0 votes
0 votes

The correct answer is $2.375$

Answer:

Related questions

7 votes
7 votes
3 answers
3
Arjun asked Feb 15, 2022
5,952 views
Consider the following grammar along with translation rules.$$\begin{aligned} & S \rightarrow S_{1} \# T \qquad \{S._{\text{val}} =S_{1}. _{\text{val}} \; ^{\ast} T._{\te...