The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+14 votes
1.3k views

Consider the syntax directed definition shown below.

$S \rightarrow \mathbf{ id :=} E$ $\{gen(\mathbf{ id}.place = E.place;);\}$
$E \rightarrow E_1 + E_2$ $\{t = newtemp();$
  $gen(t = E_1.place + E_2.place;);$
  $E.place = t;\}$
$E \rightarrow id$ $\{E.place = \mathbf{id}.place;\}$

Here, $gen$ is a function that generates the output code, and $newtemp$ is a function that returns the name of a new temporary variable on every call. Assume that ti's are the temporary variable names generated by $newtemp$. For the statement ‘$X : = Y + Z$’, the $3$-address code sequence generated by this definition is

  1. $X = Y + Z$
  2. $t_1 = Y+Z; X=t_1$
  3. $t_1 =Y; t_2=t_1 +Z; X=t_2$
  4. $t_1 =Y; t_2=Z; t_3=t_1+t_2; X=t_3$
asked in Compiler Design by Veteran (59.4k points)
edited by | 1.3k views

3 Answers

+18 votes
Best answer

B)

using given semantic rules.

answered by Veteran (59.6k points)
edited by
+11 votes
x=y+z

three address code

 

operand op1 op2  result   

+           y      z      t1

=          t1              x

t1=y+z

x=t1

so ans is b
answered by Boss (31.4k points)
+6 votes
answer - B
answered by Loyal (9.2k points)


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

35,507 questions
42,829 answers
121,693 comments
42,183 users