in Compiler Design
269 views
0 votes
0 votes

 

 
4. Consider the following grammar and their syntax directed translation (SDT) rules.
S → S * A        {S.val = S.val x A. val}
S → A              {S.val = A.val}
A → A + B       {A.val = A.val – B.val}
B → (S)’           {B.val = 2}
A → B              {A.val = B.val}
B → id             {B.val = id.val}
 
Calculate the evaluation value of the expression 4 * 6 + 3 * 7. Is it 45 or 84?
 
 
in Compiler Design
by
269 views

3 Comments

Ans should be 84 , isn’t it?
1
1
Please explain your answer step by step
0
0

The syntax tree:

The expression will be evaluated as : (4* (6 – 3))* 7 = 84

0
0

Please log in or register to answer this question.

Related questions