GATE CSE
First time here? Checkout the FAQ!
x
+4 votes
374 views

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 (26.6k points)  
edited by | 374 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.
@Arjun

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 ===>

http://www.csd.uwo.ca/~moreno//CS447/Lectures/Translation.html/node1.html

http://dragonbook.stanford.edu/lecture-notes/Columbia-COMS-W4115/08-03-24.html

www.cse.iitm.ac.in/~krishna/cs3300/lecture4.pdf

    answered by Veteran (47.2k 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

    @srestha

    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 May 2017
    1. akash.dinkar12

      3154 Points

    2. pawan kumarln

      1636 Points

    3. sh!va

      1590 Points

    4. Arjun

      1350 Points

    5. Bikram

      1298 Points

    6. Devshree Dubey

      1246 Points

    7. Angkit

      1044 Points

    8. Debashish Deka

      1042 Points

    9. LeenSharma

      880 Points

    10. srestha

      706 Points

    Monthly Topper: Rs. 500 gift card
    Top Users 2017 May 22 - 28
    1. Bikram

      384 Points

    2. pawan kumarln

      262 Points

    3. Ahwan

      236 Points

    4. Arnab Bhadra

      136 Points

    5. LeenSharma

      118 Points


    22,770 questions
    29,090 answers
    65,119 comments
    27,635 users