2 votes 2 votes Consider the following productions along with their semantic rules Here ⋅ i and ⋅ s corresponds to inherited and synthesized attributes respectively. The value for expression 3 ∗ 4 __________. Compiler Design compiler-design syntax-directed-translation expression-evaluation numerical-answers made-easy-test-series + – Jaspreet Kaur Bains asked Dec 6, 2017 edited Jun 23, 2022 by Lakshman Bhaiya Jaspreet Kaur Bains 1.1k views answer comment Share Follow See all 7 Comments See all 7 7 Comments reply Show 4 previous comments saxena0612 commented Dec 7, 2017 reply Follow Share I am getting 3 as final value? 0 votes 0 votes Jaspreet Kaur Bains commented Dec 7, 2017 reply Follow Share how?what is the role of synthesized and inherited attribute in this question? 0 votes 0 votes junk_mayavi commented Dec 23, 2017 i edited by junk_mayavi Dec 23, 2017 reply Follow Share @Jaspreet Kaur Bains once you draw the parse tree, to evaluate the semantic action associated with $T\rightarrow *FT'$, we will need the left-hand side of $*$ from the left child of root in the tree. This value has to be inherited during evaluation through the root. that is what they have denoted with $T_i$. I think they have mistakenly given $T'.s\ =\ T_1'.s$ . it should be $T'.s\ =\ T_1'.i$ and it makes sense. so we have inherited 3 from the left child of root and calculated $T.i$ at the right child of root to be $3+(2*4)$ . This value is then assigned to $T._s$ .Then the root will take this as its synthesized value from the child. hence answer is 11. Let me know if you are not clear on my explanation. I'll elaborate drawing the tree. 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes Is the answer 11<- 3+2*4=11 aik138463 answered Nov 15, 2016 aik138463 comment Share Follow See all 3 Comments See all 3 3 Comments reply thor commented Nov 15, 2016 reply Follow Share Yes, but please explain 0 votes 0 votes aik138463 commented Nov 15, 2016 reply Follow Share bro draw sdt tree and trace it finally on RST it will have 3+2*4=11 0 votes 0 votes thor commented Nov 15, 2016 reply Follow Share I know this but cannot do that. Please help. Confused as two sdt are given per production 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes $T\rightarrow$ $F(id\rightarrow {\textbf{3}})$ $T'({\textbf{*}}$$F(id\rightarrow{\textbf{4}})$ $T_{1}(T_{1}\rightarrow\epsilon))$ $It \ will \ make \ 1_{st} \ Fval=3 \ and \ therefore \ the \ inherited \\ T' \ will \ get \ 3 \ as \ value \ assigned \ to \ it.$ $Now \ the \ parent \ T \ which \ is \ root \ of \ this \ SDT \ will \ get \ value \ from \ the\ last \\ T'\ which \ is \ evaluated \ and \ therefore \ root \ will \ get \ 3 \ as \ final \ value .$ $ \\Other \ Translations \ are \ not \ working \ in \ this \ SDT$ saxena0612 answered Dec 7, 2017 saxena0612 comment Share Follow See 1 comment See all 1 1 comment reply junk_mayavi commented Dec 23, 2017 reply Follow Share I think there is a mistake in question. please see my comment above. 0 votes 0 votes Please log in or register to add a comment.