First time here? Checkout the FAQ!
+4 votes

how many Synthesized attributes are present in the given Syntax directed Definition?


(Answer key says only 2 Synthesized attributes are present. How to find them? Any idea?)

asked in Compiler Design by Veteran (27k points)  
edited by | 380 views
@Kapil just make parse tree and check Suppose Take Ex:"(1+4)" .
@manojk sir, see the answer
then L and T will be synthesized , rt?

E also taking value from it's parent
Sorry I think each attribute is synthesized here .Since value are computed in children node.

Sir, plz check this .....

2 Answers

+3 votes
Best answer

It has 4 synthesized attribute which are 

E has the synthesized attributed  E.val and T the synthesized attribute  T.val

and F has the synthesized attribute F.val and digit has the synthesized attribute digit . lexval which is applied by the lexical analyzer .

Also , only semantic rule with side effect is  print(E.val) .

Refer ===>

    answered by Veteran (47.4k points)  
    selected by

    yes sir

    i reconsidered your option of F.val=digit.val

    @Kapil what about L?
    @ srestha

    it is just a side effect,

    semantic rules which do printing have no effect on attributes


    For input "3*5+4n"

    $6$ should be right??
    0 votes
    I think it is 7.

    As Synthesized attribute is used by parent node which takes value from its child. In given semantic rules if you see everytime when right hand side of production is reduced to  nonterminal there is some semantic action which has ti performed at everynode. Each parent is using value from its child.

    Plz Correct me if i am wrong.
    answered by Loyal (2.5k points)  

    Top Users Jun 2017
    1. Bikram

      3704 Points

    2. Hemant Parihar

      1484 Points

    3. junaid ahmad

      1432 Points

    4. Arnab Bhadra

      1408 Points

    5. Niraj Singh 2

      1311 Points

    6. Rupendra Choudhary

      1194 Points

    7. rahul sharma 5

      1120 Points

    8. Arjun

      930 Points

    9. srestha

      928 Points

    10. Debashish Deka

      896 Points

    Monthly Topper: Rs. 500 gift card
    Top Users 2017 Jun 19 - 25
    1. Bikram

      1960 Points

    2. Niraj Singh 2

      1306 Points

    3. junaid ahmad

      502 Points

    4. sudsho

      410 Points

    5. akankshadewangan24

      388 Points

    23,355 questions
    30,065 answers
    28,382 users