Reg.No.:{ blo 1 [0 [5 |t [o [lolol
T 3185
B.E/B.Tech, DEGREE EXAMINATION, APRIL/MAY 2008.
Sixth Semester
(Regulation 2004)
Computer Science and Engineering
CS 1352 — PRINCIPLES OF COMPILER DESIGN
(Common to BE. (Part-Time) Fifth Semester Regulation 2005)
‘Time : Three hours Maximum : 100 marks
10,
Answer ALL questions.
PART A — (10 x 2 = 20 marks)
Differentiate compiler and interpreter.
Write short notes on buffer pair.
Construct a parse tree of (a +b)'e for the grammar E> E+E/E EI(E) lid.
Eliminate immediate left recursion for the following grammar
E>E+TIT,T>T RiFF > (Eid
‘Write short notes on global data flow analysis,
Define back patching with an example.
Give syntax directed translation for the following statement
Call pl (int a, int b).
How can you find the leaders in basic block?
Define Code motion.
Define basie block and flow graph.ate
12.
13.
(a)
(b)
(a)
(b)
(@)
(b)
PART B — (5 x 16 = 80 marks)
(i) Explain the phases of compiler, with the neat schematic. (12)
(ii) Write short notes on compiler construction tools. 4)
Or
(Explain grouping of phases ®
(ii) Explain specification of tokens. )
Find the SLR parsing table for the given grammar and parse the
sentence (a+b)'¢ E> E+E/EEAE)id .
Or
Find the predictive parser for the given grammar and parse the sentence
(a+bye E>E+T/T,P>TFIF,P> (BVid.
Generate intermediate code for the following code segment along with the
required syntax directed translation scheme = (8)
@ iffa>b)
x=atb
else
x=a-b
where a & x are of real and b of int type data
Gi) inta,b; (8)
float ¢ ;
a=10;
swith (a)
{ease 10:
case 20:¢=
1
Or
(i) Generate intermediate code for the following code segment along
with the required syntax directed translation scheme : (8)
i=1;s=0;
while (i <= 10)
s=s+alil bil fi)
isiel
i) Write short notes on back-patching, ®)
2 T3185CO
14 (a) G)__ Explain the various issues in the design of code generation, (6)
Gi) Explain code generation phase with sian ple code generation
algorithm, 10)
Or
(b) (Generate DAG representation of the following code and list out the
applications of DAG representation <2)
1;s=0;
while (é <= 10)
+a [il [i]
init
() "Write short notes on next-use information with suitable example.
w
19. (a) G) Explain — principle sources of optimization 3)
(i) Write short notes on : 8)
() Storage organization
(2) Parameter passing.
or
(») @) Optimize the following code using various optimization technique :
12)
=1;s=0;
for i= 1;i<=8; i++)
for j= 15; j<=3; j++)
lil GI = cli) + afi) + obi
ci) Write short notes on access to non-local names (4)
3 T3185