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 (30.2k points) 108 371 691
edited by | 418 views
E is reducing to F, which means E is a child and F is a parent.

what is think is F.val = digit.val is not a synthesized atthribute
Suppose production E→T. and <T.val=E.val> then what you do say ?
Then here child(T) is taking the value of parent(E) hence inherited attributes
@ManojK...but here we should check semantic rules for corresponding production na ??
yes , in semantic , values move from right to left side
@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 (50.4k points) 22 90 410
    selected by
    is E synthesized?

    just see the first link

    see this line from that link "the value of a synthesized attribute is computed from the values of the attributes of the children of the node."

    E -> E1+T

    F ->(E) , in both cases it violating that rule. rt?

    @Kapil Here the logic you are applying is not valid .

    See this input string “ (3+4) * (5+6)"  and parse tree.


    no it is not, E1 + T will be reduced to E , so synthesized attributes work in a bottom up fashion
    @manojk sir

    just see the first link. it has the same question.

    example 3
    Ohh now you changed the answer ? I am talking about the case of F.val=digit.val ? Even all are synthesized attribute .

    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 Boss (5.1k points) 2 34 83

    Related questions

    +1 vote
    2 answers
    asked in Compiler Design by Purple Loyal (4.1k points) 17 68 129 | 288 views
    0 votes
    2 answers

    Quick search syntax
    tags tag:apple
    author user:martin
    title title:apple
    content content:apple
    exclude -tag:apple
    force match +apple
    views views:100
    score score:10
    answers answers:2
    is accepted isaccepted:true
    is closed isclosed:true
    Top Users Oct 2017
    1. Arjun

      23346 Points

    2. Bikram

      17058 Points

    3. Habibkhan

      8142 Points

    4. srestha

      6254 Points

    5. Debashish Deka

      5438 Points

    6. jothee

      4968 Points

    7. Sachin Mittal 1

      4772 Points

    8. joshi_nitish

      4298 Points

    9. sushmita

      3964 Points

    10. Rishi yadav

      3794 Points

    Recent Badges

    Notable Question Sandeep Suri
    100 Club stdntlfe
    Nice Question thor
    100 Club Vamp thehacker
    Popular Question LavTheRawkstar
    Notable Question shubham vashishtha
    Nice Answer Habibkhan
    Good Question jenny101
    Regular Ashish Subscription
    Famous Question Akash Kanase
    27,301 questions
    35,155 answers
    33,244 users