Question:medium

Consider the syntax-directed translation with non-terminals N, I, F, B and the rules:

\[ \begin{aligned} N &\to I\ \#\ F \qquad && N.val = I.val + F.val \\ I &\to I_1\ B \qquad && I.val = 2 \times I_1.val + B.val \\ I &\to B \qquad && I.val = B.val \\ F &\to B\ F_1 \qquad && F.val = \tfrac12 \big(B.val + F_1.val\big) \\ F &\to B \qquad && F.val = \tfrac12 B.val \\ B &\to 0 \qquad && B.val = 0 \\ B &\to 1 \qquad && B.val = 1 \end{aligned} \] Find the value computed for the input string 10#011 (rounded to three decimals).

Show Hint

The integer rule $I \to I B$ with $I.val=2\,I_1.val+B.val$ accumulates binary digits left-to-right. The fractional rule $F \to B F$ with $F.val=\tfrac12(B.val+F_1.val)$ yields $\sum b_i/2^i$ for bits after ``\#''.
Updated On: Jan 31, 2026
Show Solution

Correct Answer: 2.375

Solution and Explanation

Was this answer helpful?
0