## November 25, 2011

### COMPILER DESIGN JNTU previous years question papers

COMPILER DESIGN JNTU previous years question papers

Time: 3 hours Max Marks: 80

All Questions carry equal marks

1. (a) What is LEX? Explain, in detail, different sections of LEX program.
(b) Write regular expressions for the following patterns. Use auxiliary definitions wherever convenient.
i. the set of words having a,e,i,o,u appearing in that order, although not necessarily consecutively.

2. (a) What are the difficulties in top down parsing? Explain in detail.
(b) Consider the following grammar
S ! (L) |a
L ! L, S |S
Construct leftmost derivations and parse trees for the following sentences:
i. (a,(a,a))
ii. (a,((a,a),(a,a))). [8+8]
3. (a) Explain canonical LR parsing.

(b) Explain briefly, precedence functions. construct the precedence graph using the following prededence table. [8+8]
+ * ( ) id \$
f 2 3 0 4 4 0
g 1 3 5 0 5 0

4. (a) Write a S - attributed grammar to connect the fopllowing grammar with prefix rotator
L ! E
E ! E+T | E-T | T
T ! T*F | T/F | F
F ! P " F | P
P ! (E)
P ! id.
(b) Construct triples of an expression: a -(b + c). [8+8]

5. (a) What is heap storage allocation? Explain in detail.
(b) Explain about implicit and explicit storage requests. [8+8]

6. (a) Explain in detail the Optimization technique “strength reduction”.
(b) What is a DAG. Explain its applications. [8+8]

7. (a) What is an Induction variable? Explain with an example.
(b) Discuss how induction variables can be detected and how transformation can be applied. [8+8]

8. Generate code for the following ’C’ statements
(a) x = f(a) + f(a) + f(a)
(b) x = f(a) / g(b,c)
(c) x = f(f(a))
(d) x = ++f(a)