• edited by
1,550 views
1 1 vote

Consider the following translation rules:
\[
\begin{array}{l}
\mathrm{S} \rightarrow \mathrm{~A} \quad\{\mathrm{~A} . \text { val }=0\} \\
\mathrm{A} \rightarrow \mathrm{~A}_{1} 1 \quad\left\{\mathrm{~A} \cdot \text { val }=\mathrm{A}_{1} \cdot \text { val }+1\right\} \\
\mathrm{A} \rightarrow \mathrm{~A}_{1} 0 \quad\left\{\mathrm{~A} . \operatorname{val}=\mathrm{A}_{1} \cdot \text { val }\right\} \\
\mathrm{A} \rightarrow \mathrm{~B} \quad\{\text { print }(\mathrm{A} . \text { val })\}
\end{array}
\]

The number of inherited attributes are

  1. 0
  2. 1
  3. 2
  4. 3

1 Answer

2 2 votes
i think 0

none of the SDTs is deriving values from his siblings..only parent is derving from children....so no inherited attributes are present here
Position:
Show:

Related questions

4 4 votes
2 answers 2 answers
5.2k
5.2k views
Purple asked Jan 27, 2016
5,202 views
How to solve this question?Attributes calculated from children are synthesized, while attributes calculated from parents and/or siblings is inherited. And S-attributed ar...
1 1 vote
1 answers 1 answer
4.6k
4.6k views
iita asked Dec 20, 2016
4,578 views
0 0 votes
0 0 answers
1.2k
1.2k views
sidlewis asked Sep 2, 2018
1,176 views
Write semantic rules for the grammar below to compute the Boolean attribute A. evenx, which is true iff the sentence parsed has an even number of $x$ 's.\[\begin{array}{c...
0 0 votes
2 2 answers
804
804 views
Shivani gaikawad asked Jun 3, 2018
804 views
Consider the following Syntax directed Defination and identify which type of grammar it is:Var $\rightarrow$ IntConstant $\{$ IntConstant. wal $=$ Var.val ; \}Expr $\righ...