in Compiler Design edited by
36,303 views
75 votes
75 votes

In a bottom-up evaluation of a syntax directed definition, inherited attributes can

  1. always be evaluated
  2. be evaluated only if the definition is L-attributed
  3. be evaluated only if the definition has synthesized attributes
  4. never be evaluated
in Compiler Design edited by
36.3k views

4 Comments

Read all the available solutions and still confused ?

Doubt :- for inherited attribute , defination must be L attributed. and if defination is L attributed then evaluation is done using depth first traversal (Left to right ).

and if it is S attributed then evaluation is done using Bottom Up parsing .

I know only these two points .

Can somebody plz explain this que in simple word ??
2
2
Please correct me if I am wrong I am completely confused by all the answers here is what I think,S-attributed SDT attributes are evaluated during Bottom Up parsing but since there is inheritance no chance of S-attribute and L-attributed is used for depth first,left to right making option D as the correct answer.Please Help
0
0

@sripo

check my comment on the answer of arjun sir

0
0

10 Answers

1 vote
1 vote

I’ll try to answer this. Let me know if there are any conflicts in this answer.

As every S attributed is L attributed, so if L attributed is not possible, then even S attributed is not possible. S -attributed definitions use synthesized attributes. L-attributed definitions use both inherited and synthesized attributes. S-attributed can be parsed by BUP, post order traversal, traversal of the parse-tree as S-attributes are computed from child nodes. Therefore, if the grammar is L attributed then there are possibilities that we can solve using BUP (provided it is S attributed too), while not all L attributed are solvable using BUP (as not all L attributed are S attributed). 

S-attributed uses synthesized attributes that can be traversed by BUP (True) and some L attributed definitions uses inherited (which cannot be traversed by BUP) and synthesized attributes (which can be traversed by BUP). So, option B seems to be the correct answer.

Some more info : 

  1. Inherited attributes cannot be always evaluated by a Pre-Order traversal of the parse-tree. 
  2. Inherited attributes that do not depend on the right children can be evaluated by a Pre-Order traversal.

Ref. http://cse.iitkgp.ac.in/~bivasm/notes/SDD.pdf

edited by

1 comment

Nice :)
0
0
0 votes
0 votes
Option b.
edited by
by

11 Comments

explain it....
0
0
Acc. To my reasoning it should be b option but then in the book which which i am solving its given c and the reasoning theve given is that it is a fact.
0
0
same here,,i too think so it should b (b)
0
0
But in previous paper soln. Gk publishers it is given c things are getting real confusing at the last moment.
0
0
yes it is getting but at this moment dont get confused,,

sometimes these sources too have mistake in there answeres,,so u b confident
0
0
reshown by
This tends to support b not d.
0
0
Inherited attributes can be evaluated by bottom up parsing of inherited attributes thats for sure
0
0
But in bottom up only Synthesized attribute is evaluated.... parents are created after all its children so is there any possibility to have inherited attribute?
0
0
edited by
L-r attributed grammar can evaluate inherited attributes using bottom up parsing.
0
0

It can be specification to ans B is..

A  S-attribute SDD can evaluate synthesized attributes only..

But a L-attribute SDD can evaluate both synthesized and inherited attribute..

0
0
0 votes
0 votes

 A Syntax Directed Definition (SDD) is called S Attributed if it has only synthesized attributes.

L-Attributed Definitions contain both synthesized and inherited attributes but do not need to build a dependency graph to evaluate them.

References:
http://cse.iitkgp.ac.in/~bivasm/notes/SDD.pdf

0 votes
0 votes

I think the solution can be reached using the following logic.

(1) No, it can’t be evaluated if inherits from the parent.

(3) No, because it can be evaluated if it depends upon the attributes of a left sibling which make it non-synthesized attribute.

(4) 3rd point’s logic makes this option wrong too.

Now coming to 2nd point. If it is not L-attributed then it is not even S-attributed. And we saw that there are only 2 possibilities to be able to parse in a BOTTOM-UP fashion (first is when attributes depend on the child’s attributes or when depends on a left sibling). Hence there are possibilities to be able to solve when grammar is L-attributed but not all L-attributed grammars can be solved using BUP.

Please correct me if my answer is wrong.

Answer:

Related questions