Compiler Design GATE CS and IT previous year questions with answer


Ques 21 GATE 2014 SET-3


The primary reason of using intermediate code in compilers is to

A

make parsing and semantic analysis simpler.

B

improve error recovery and error reporting.

C

increase the chances of reusing the machine-independent code optimizer in other compilers.

D

improve the register allocation.



Ques 22 GATE 2014 SET-3


Which of the following statements are CORRECT?
1) Static allocation of all data areas by a compiler makes it impossible to implement recursion.
2) Automatic garbage collection is essential to implement recursion.
3) Dynamic allocation of activation records is essential to implement recursion.
4) Both heap and stack are essential to implement recursion.

A

1 and 2 only

B

2 and 3 only

C

3 and 4 only

D

1 and 3 only



Ques 23 GATE 2014 SET-3


Consider the basic block given below.
a = b + c
c = a + d
d = b + c
e = d – b
a = e + b
The minimum number of nodes and edges present in the DAG representation of the above basic block respectively are

A

6 and 6

B

8 and 10

C

9 and 12

D

4 and 4



Ques 24 GATE 2014 SET-1


A canonical set of items is given below:
S → L. > R
Q → R.
On input symbol <, the set has

A

a shift-reduce conflict and a reduce-reduce conflict.

B

a shift-reduce conflict but not a reduce-reduce conflict.

C

a reduce-reduce conflict but not a shift-reduce conflict.

D

neither a shift-reduce nor a reduce-reduce conflict.