edited by
3,262 views
4 votes
4 votes

 

Consider the following grammar and their Syntax Directed Translation (SDT) rules.

 

(Here id represent a integer and id.val is value of that integer)

S1: Given SDT is L-attributed and using L-attributed evaluation the value of the expression 4 * 6 + 3 * 7 is 84.

S2: Given SDT is S-attributed and using S-attributed evaluation value of the expression 4 * 6 + 3 * 7 is 84.

 

Which of the above statements are true with respect to the above SDT.?

My doubt here: Is there any difference in the way of evaluation of L-attributed SDT and S-attributed SDT ?

edited by

1 Answer

0 votes
0 votes

As we can clearly see that S is taking value from its children and even A is doing the same so there is no doubt that the grammar is Synthesized i.e. S-attributed grammar. Now all S attributed grammars are L attributed Grammars as L attributed grammar= synthesized+inherited grammar.

So BOTH S1 and S2 are True

and the evaluation of expression is like-->4*(6+3)*7 =4*3*7 = 84


PS--> If in S1 we were given inherited instead of L attributed then it would have been only S2

Related questions

3 votes
3 votes
2 answers
3
Nymeria asked Jan 27, 2018
789 views
A) SDD is L attributed.B) SDD is not L attributed because of Rule 1.C) SDD is L attributed because of Rule 2.D) SDD is L attributed because of both Rule1 and Rule2.