JNTU B.Tech II Semester Examinations, COMPILER DESIGN, Apr/May 2008

JNTU B.Tech II Semester Examinations, COMPILER DESIGN, Apr/May 2008

(Computer Science & Engineering)

Time: 3 hours Max Marks: 80

Answer any FIVE Questions

All Questions carry equal marks


1. (a) Explain the different phases of a compiler, showing the output of each phase,

using the example of the following statement:

position : = initial + rate * 60

(b) Compare compiler and interpreter with suitable diagrams. [10+6]


2. (a) What is recursive descent parser? Construct recursive descent parser for the

following grammar.

E ! E + T|T

T ! TF|F

F ! F_|a|b

(b) What is ambiguous grammar? Eliminate ambiguities for the grammar:

E ! E + E|E_E|(E)|id. [8+8]

3. Construct SLR parsing table for the following grammar.

S ! AS|b

A ! SA|a [16]


4. (a) Write the quadruple, triple, indirect triple for the statement a := b_ ? c + b_ ? c.

(b) Explain the role of intermediate code generator in compilation process. [8+8]


5. Write an algorithm to perform the table lookup and insertion operation for hashed

symbol table. [16]


6. (a) What is code optimization? What are its advantages?

(b) Explain briefly about folding.

(c) What are the problems in optimizing compiler design? [5+5+6]


7. (a) Explain reducible and non-reducible flow graphs with an example.

(b) Explain natural loops and inner loops of a flow graph with an example. [8+8]


8. (a) Explain the concept of object code forms.

(b) Generate optimal machine code for the following C program. [6+10]


{int i, a[10];

while (i<=10) a[i] =0}

Leave a Comment