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

Consider the syntax directed definition shown below.$$\begin{array}{ll}
S \rightarrow \mathbf{ id :=} E&\qquad \{gen(\mathbf{ id}.place = E.place;);\}\\
E \rightarrow E_1 + E_2 &\qquad \{t = newtemp();\\
&\qquad gen(t = E_1.place + E_2.place;);\\
&\qquad E.place = t;\}\\
E \rightarrow id&\qquad \{E.place = \mathbf{id}.place;\}
\end{array}$$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$
in Compiler Design by Veteran (52.1k points)
edited by | 2.1k views

3 Answers

+23 votes
Best answer

Answer (B)

using given semantic rules.

by Veteran (62.2k points)
edited by
+2
prashant sir t1=y+z
+14 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
by Boss (30.9k points)
0
pooja mam u wrote operand in the place of operand and vice-versa
+6 votes
answer - B
by Loyal (8.7k points)
Answer:

Related questions

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
49,830 questions
54,809 answers
189,534 comments
80,845 users