10cs63
USN
Sixth Semester B.E. Degree Examination, Dec.20l4lJan.20l5
Gompiler Design Time: 3 hrs.
Max. Marks:100 Note'. Answer finy
FIW fall
questions, selecting
o o o
g
PART _ A
C3
E
'€d) Cd
L
?a
la.
]
b.
-:>
2a.
;vf oo
ioo',
b.
i-I
(g$
--.
o
Y:J
w
-(J -+
..5
Explain with neat diagram. the phases of compiler with example. (10 Marks) Construct a transition diagram for recognizing relational operators. Sketch the nrosram ral segrnent to implement it, showing the frst state and one final state. (10 't Marks)
Bliefly explain the problems associated with top down parser. (03 Mafks) Showthatfollowinggrammdris'amb'guous: S-+S+SlSxsiid.Giveanunambigrious grammar lor the above grammar such that '*' has highest priority and x has less priority and
bbth are:left associative. Given the gran'.nar A -+ (A) i a ,' i), Construct predictive parser table. ii) Check the grammar is LL( I ) or not. iii) Show the parser steps for the inpur ((a)).
i
(.07
Marks)
(10 Ntarks)
oaJ
50i (dcd e^
>i: r'6
a. Obtain LR(0) items for the following grammar: .b' S-+L:R|R L-+*RiidR-+L. Obtain FIRST and FALLO* table. Is the grammar SLR?
a.
"a ,t .2 6: @LE !O
>-
,*
oeo
coa :iq e!
e< *(.l o
for the grammar shown in Q.3(a) and obtain SLR parsing (12 Marks)
''
Oj: ^X
,.r,
(08Marks)
b. c.
i.
1l
Given the grammar:
i
j
A-+CC C-+aC lb i), Construct sets of LR( I ) items. ii) Construct canonical LR(l) parsing'table. Write
a note on the parse generator '_
)i
, (12 Marks)
YACC.
(03 Marks)
W:ite the YACC specification of a simple desk calculator with fotlowing grammar, Ior arithnretic expression
:
"
E'-+E+TlT
T-+T*F lF F + (E) | digit
where digit between 0 to 9.
z 1rJ
p.
I of2
(05 Marks)
i
jr
PART-B
:
: ,l
i
i,
;t , ii ;,, i il
i :
,
i , ,i 'ii' a. Explarnitype of attributes f,or non terminal with example. i ; : .i,ti , ii,(uMark$).. --'-,;;;'.' I '.tt-, : L rr'.; I t, n i,l b. Write annotated' parde tree for expressionls + 4 x 3n where grimmar is ', .i ''il'jli q"lk;;', L-+Enl ..:,, I , 'li ":t :: I ' '' ',^E-EiTiT,' i; lI: .l ' .t
,i
i. :l
i I
I
:.,j i
:
:
i
i r
t
:l
:l
,i
{"i11
:
,,:i,",,,,
..i
,
,'.i. ir.il rs*J!,h.mjFtFi,l
:!i
ir fll-rieiei l,-trf ".*-j
r
'
i',
r
'
,
rr ,,,
1.
,
i;
,
, j idigit; i,; How q,l#Vlelrt ulassss rruw clisses ur of JLrl-, SDD'ss that tnat guarantee n+11-q,1]
{lfuent
obtain postfix SDT for simple desk 'I
i6 i
a.
:'
ii
,' i evaluation,order? evalUatlonr Ofd'ef'/
calculator.
:..-',' I' , .. ,i.u"
j ,
' : t
L,,',
fortheexpressionx*x the expression x + 4-g,(fi 4cyclic graph for agycJig (y+
Explain the followinf followin[ lvith ivith
:
.
What is activation record?
record.
:
,iifoouurt ,l(06 Marks) r) ,io+
uu.r.rj
i
I
z)+(y*z) x w.
T example: ; i) Quadqaples il hirpfpq iii;,rnAirect tripleg;t:, , c. Explain,SDT of switch statement.
a.
:,
I
* t,,, I:i.,,-*;1 , l'':"'g"r{i
:
""
tt-:: : Obtainthedirected Obtain the directed
:b.
iI .i., ;i I
(06Marks)
{
' ..'!'..,,.t:
nipp
i :
.
,
,1sr rvru.Lg
(08 Marks)
i
struqtdt"ahO purpose of each rfield in the activarion
b. Explain;tasks of callpr and callee *fidAi;dure called and exit. i, I .i c. Explaio;briefly the performance. rne{rics
" -:
[3:ffi:[]]
to be considered while desigiling garbage collector. (S6 Marks)
,,
8 a.
b.
i
'1,!
'"
,r,, ",..,
Write intermediate code for the following soui.."cod.' ,ill.i::r. ". for i from I to l0 do :i : , : .,,n,,rr. ' ::,,,',]:,] for i from I to l0 do ul' 'i a [i, j] : 0.0: for i froin I to t0 do a [i, i] : 1.0; and identify basic blocks. "'issues Discuss,,; in the design of a code generator. I ,:,
lt:;
(10 Marks)
:Y .:
(10 Marks)
"i,
!i .;l i
2 of2