in Compiler Design retagged by
1,118 views
0 votes
0 votes

I know that every S attributed grammar is L attributed but not vice versa. Can anybody give example of the case if i print the semantic rules using L attributed the result will be different from the S attributed evaluation ? And how should i print the rules in both cases.

Explain both case in this example :

 

in Compiler Design retagged by
by
1.1k views

3 Comments

L- attributed evaluation is like, on first time you are seeing it, evaluate its semantic rule.

S- attributed evaluation is like, on last time you are seeing it, evaluate its semantic rule.

but in this example, there is no L-attribute or S- attribute ===> just use Post order traversal or Depth first search from left to right ===> 9 5 + 2 +
0
0
So brother are u saying that in L attributed the moment I hit the production execute its semantic rule and in S attributed when the reduction occurs then execute the rule?

Brother are u sure because I feel its the other way around (not sure though).

Can you please verify once :)
0
0
L attributed means, it can take values from it's left side and parent ===> when you first time hit it, then you already completed it's parent and left side variable.
0
0

1 Answer

0 votes
0 votes
B is the ans

1 comment

What is the difference between S attributed and L attributed evaluation ?. if a grammar is L attributed i can simply solve it and thats would also be the result if S attributed were perfomed. But if i grammar is S attributed then how its solved ?
0
0

Related questions