in Compiler Design edited by
6,938 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)
in Compiler Design edited by
by
6.9k views

4 Comments

input string is $10\#011$ and third production rule will be $I\rightarrow B$
1
1
Am I only one who remember that the given string was 01#011 🤕
1
1
Yes🤣
0
0

Question Corrected.

Answer: SDT Question: String 10#011

0
0

2 Answers

12 votes
12 votes

 

The correct answer is $2.375$

0 votes
0 votes

The correct answer is $2.375$

1 comment

edited by
just solve in the form of binary numbers =  1*2^1 + 0*2^0 + 0*2^-1 + 1*2^-2 + 1*2^-3 = 2.375
1
1
Answer:

Related questions