6,682 views
3 votes
3 votes
Consider the following SDT.

A → BC *

(I) B.i = f(A.i)         (II) B.i = f(A.S)            (III) A.S = f(B.S)

which of the above is violating L – attributed definition?

(a) I only (b) II only (c) I, II (d) I, II, III

3 Answers

7 votes
7 votes

ans:(b) II only

A->BC*

(I) B.i = f(A.i)   //A is B's parent so Valid L Attributed rule

(III) A.S = f(B.S) //synthesized attribute so valid L attributed rule

as L attributed sdd can contain both left inherited and synthesized attributes

 (II) B.i = f(A.S) inherited attribute i is dependent on synthesized attribute s of A so its not a valid  L Attributed sdd rule 

//ur at B and want to calculate B.i but its dependent on A.s which will be calculated once u finish B and move up in syntax tree, so its a cycle.

also  a syntax-directed definition is Lattributed if each inherited attribute of Xj on the right side of A → X 1 X2 … Xn depends only on

1. the attributes of the symbols X 1, X2, …, Xj-1

2. the inherited attributes of A

reference:https://www.cs.fsu.edu/~engelen/courses/COP562107/Ch5a.pdf

1 votes
1 votes
I think its ii ...B is depending on A,S which in turn is depending on B and C synthesized ....so B is depending on C ,,,violating L attributed definition..IN l attributed definited inherited attribute can depend only on left silbling and not on right sibling
0 votes
0 votes
I feel option C both I AND II

as in both B is dependent on parent so it is inherited but A is to be synthesized from B and C hence it is eventualy B is inheriting from B and C and C is to right of it so BOTH i and ii are not L atributed

Related questions

1 votes
1 votes
3 answers
2
spriti1991 asked Mar 18, 2015
2,346 views
Consider the SDT , where S ->TR, R- +TR|empty {print ("+")} , And T- num {print(num)} And if the input is given "9+5+2" What is output ?