Code No: 115AP
R13
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD
B. Tech III Year I Semester Examinations, November - 2015
COMPILER DESIGN
(Computer Science and Engineering)
Time: 3 hours Max. Marks: 75
Note: This question paper contains two parts A and B.
Part A is compulsory which carries 25 marks. Answer all questions in Part A. Part B
consists of 5 Units. Answer any one full question from each unit. Each question carries
10 marks and may have a, b, c as sub questions.
PART - A (25 Marks)
1.a) Define Cross Compiler. [2]
b) Eliminate immediate left recursion for the following grammar:
E->E+T | T
T->T* F | F
F-> (E) | id [3]
c) List the rules for computing FOLLOW SET. [2]
d) Define CLOSURE (I). [3]
e) What is a symbol table? [2]
f) What does a semantic analysis do? [3]
g) Define basic block in a flow graph. [2]
h) What is a DAG? Mention its applications [3]
i) Generate a object code for following statements
a = b + c; d = a+e [2]
j) Mention the properties that a code generator should possess. [3]
PART - B (50 Marks)
2. What are the various phases of the compiler? Explain each phase in detail. [10]
OR
3. Construct the predictive parser for the following grammar: [10]
S->(L)/a
L->L,S/S
4. Find the SLR parsing table for the given grammar:
E->E+E | E*E | (E) | id.
And parse the sentence (a+b)*c. [10]
OR
5. Construct an LALR Parsing table for the following grammar: [10]
E-> E+T |T
T-> T*F|F
F->id
www.ManaResults.co.in
6. Generate intermediate code for the following code segment along with the required
syntax directed translation scheme:
if(a>b)
x=a+b
else
x=a-b
Where a and x are of real and b of int type data. [10]
OR
7. Give syntax directed translation scheme for simple desk circulator. [10]
8. Explain the following with an example:
a) Redundant sub expression elimination
b) Frequency reduction
c) Copy propagation. [3+3+4]
OR
9. Optimize the following code using various optimization techniques: [10]
i=1; s=0;
for (i=1; i<=3; i++)
for (j=1;j<=3;j++)
c[i][j]=c[i][j] + a[i][j] + b[i][j]
10. Explain in detail about machine dependent code optimization techniques. [10]
OR
11. Give an example to show how DAG is used for register allocation. [10]
–--ooOoo---
www.ManaResults.co.in