You are on page 1of 2

USN

10cs63
Max. Marks:100
Sixth Semester B.E. Degree Examination, Dec. 20l3lJan.2014
D.
,,,:'
tJ.
o
o
o
L
o
(.)
(.)
ox
d9
p,'
trca
.:N
(B+
69!
()E:
-c
o)
o=
;u
o()
-6
6
.!l
io
QO-
tra
oj
@=
lio
a tr=
E.<
LO
z.Y
v.
uoo
ECO
o=
o. :i
tr>
Xo
o-
U<
:'
-
o
o
Z
o
Time:3 hrs.
,
c. What are the key problem$'with
grarnmar :
S-+cAd A-+abla.
i
3 a. Given the gramrner :
A-+cle
B-+dfe
- --:;=
)'r:F
i) Compute FIRST and FOLLOW sets
ii) Construct the predictive parsing table
,,
iii) Show the moves made by predictive parser on the input
;
acdb.
Explain with a neat diagram, the model of a table driven predictive parser.
S-+SS+lSS*la.
a. Given the grammar :
S-+CC
C-+cCld
D
Obtain the sets of canonical collection of sets of valid LR(0) items
ii) Design SLR parsing table.
b.
Write an algorithm used to compute LR (1) sets of items.
c.
Write a note on the parser Generator
-
Yacc.
What is handle pruning? Give a bottom
-
up parse for the input : vsv
*
v-t-t and grammar :
top down parse? Write a recursive descent parser for the
(08 Marks)
(10 Marks)
(05 Marks)
(05 Marks)
(10 Marks)
(06 Marks)
(04 Marks)
Gomplier Design
Note: Answer FIVE
full
questions, selecting
utleast Tl,yO questions
from
each part.
PART
_
A
I a. Explain the various phases of complier. Show the translations for an assignment statement.
Position: initial * rate
+
60, clearly indicate the output of each phase.
,
(12 Marks)
b. Write thq.regular definition for an unsigned number. Also write the transition diagram.
(06 Marks)
::,,
(02 Marks)
c. What is printed by the following C code?
# define a (x +
l)
irrtx:2;
',
void b(
) {int
x
:l;
printf("oZd ln", a)'}
void c( ){printfl'"%d ln", a);
}
void main(
) {b( ) ;
c(
);}.
2 a. Describe an algorithm used for eliminating the Ieft recursion. Eliminate left recursion from
b.
Show that the following grammar,is ambiguous :
E -+ E + E
I
E
*
E
I
(E)
|
id. Write an equivalent unambiguous grammar for the same.
1 of2
For More Question Papers Visit - www.pediawikiblog.com
For More Question Papers Visit - www.pediawikiblog.com
w
w
w
.
p
e
d
i
a
w
i
k
i
b
l
o
g
.
c
o
m
Construct the
iarse
tree and annotated parse tree for the input string : 1 1001 . (05 Marks)
c.
Give a SDT for desktop calculator and show its parser stack implementation. (10 Marks)
a. Translate the arithmetiC.expression : a + - (b + c) into
dri;rr*r,
triples and indirect triples.
b. Give a semantic action i;",,S
-
if (B) Sr etse sz.
[3:ffifii
c' Develop SDD to produce directed a cyclic grrpt for an expression. Show the steps for
constructing the directedacyclic graph forthe expression : a-t a* (b-c) + (b-c) *
d.
PART
_
B
a. Explain the concept of syntax
-
directed definition.
b. The SDD to translate binary integer number into decimal is shown below
Productions Semantic rules
BN-+L BN.val: L. val
L-+LrB L. va
:2
xLl.val + B. val
L+B L.va
:
B .val
B-+0 B. va
:0
B-+1 B. va
:1
a. Discuss the issues in the design of a code generator.
b. Write the tree address code and construct the basic blocks for
segment.
sum: 0
;
for(i: 0; i
<:
10
;
i ++;
sum: sum +a[i]
;
c. Give the code generation process for operations.
lti.,
a. Describe the general structure of an aCtivation record. Explain the purpose
the activation record.
b. A C
-
code to compute Fiborthcci numbers recursively is shown below :
r0cs63
(05 Mark$,
::"",.
',..
"::
.
(08 Marks)
of each field in
(08 Marks)
(05 Marks)
(05 Marks)
int f(int n)
{intt.s:
if(n <:
2) retum I
;
s:f(n-l);
t:
fln
-2)
;
return (s,+ t); '),t,
,
I
f
i) Draw the activation tree for the call : (5)
it) W'hat is the largest number of activation records that ever appear together on the stack?
,,,,:, (06Marks)
c, ' Explain the performance metrics to be considered while designing a garbage .oll..jg]._
_ . .
'
(06 Marks)
(10 Marks)
the following program
,F*{<ik*
For More Question Papers Visit - www.pediawikiblog.com
For More Question Papers Visit - www.pediawikiblog.com
w
w
w
.
p
e
d
i
a
w
i
k
i
b
l
o
g
.
c
o
m

You might also like