Time Left - 10:00 mins

GATE CS 2018 - Compiler Design Boost_Up Quiz (RE, ICG)

Attempt now to get your rank among 456 students!

Question 1

The least number of temporary variables required to create a three-address code in static single assignment form for the expression q + r / 3 + st * 5 + u * v /wis _____________.

Question 2

Consider the intermediate code given below.
(1) i = 1
(2) j = 1
(3) t1 = 5 i
(4) t2 = t1 + j
(5) t3 = 4 t2
(6) t4 = t3
(7) a[t4] = -1
(8) j = j + 1
(9) if j<=5 goto (3)
(10) i=i+1
(11) if i<5 goto (2)
The number of nodes and edges in the control-flow-graph constructed for the above code, respectively, are

Question 3

Consider the following class definitions in a hypothetical Object Oriented language that supports inheritance and uses dynamic binding. The language should not be assumed to be either Java or C++, though the syntax is similar.
Class P { Class Q subclass of P {
void f(int i) { void f(int i) {
print(i); print(2*i);
} }
} }
Now consider the following program fragment:
Px = new Q()
Qy = new Q();
Pz = new Q();
x.f(1); ((P)y).f(1); z.f(1);
Here ((P)y) denotes a typecast of y to P. The output produced by executing the above program fragment will be

Question 4

The syntax of the repeat-until statement is given by the following grammar
S repeat S1 until E
Where E stands for expressions, S and S1 stand for statement. The non-terminals S and S1 have an attribute code that represents generated code. The nonterminal E has two attributes. The attribute code represents generated code to evaluate the expression and store its truth value in a distinct variable, and the attribute varName contains the name of the variable in which the truth value is stored? The truth-value stored in the variable is 1 if E is true, -2/3 if E is false. Give a syntax-directed definition to generate three-address code for the repeat-until statement. Assume that you can call a function new label( ) that returns a distinct label for a statement. Use the operator ‘\\’ to concatenate two strings and the function gen(s) to generate a line containing the string s.

Question 5

Which of the following statements is FALSE?

Question 6

Which of the following are true?
I. A programming language which does not permit global variables of any kind and has no nesting of procedures/functions, but permits recursion can be implemented with static storage allocation.
II. Multi–level access link (or display) arrangement is needed to arrange activation records only if the programming language being implemented has nesting of procedures/functions.
III. Recursion in programming languages cannot be implemented with dynamic storage allocation.
IV. Nesting of procedures/functions and recursion require a dynamic heap allocation scheme and cannot be implemented with a stack–based allocation scheme for activation records.
V. Programming languages which permit a function to return a function as its result cannot be implemented with a stack–based storage allocation scheme for activation records

Question 7

Match list-I with list-II and select the correct answer using the codes given below the lists:
List-I
A- Link-time
B- Load-time
C- Compile-time
D- Run-time
List-II
1- Resolving references
2- Relocation
3- Token recognition
4- Activation record
  • 456 attempts
  • 1 upvote
  • 2 comments
Aug 18GATE & PSU CS