QP CD Model Set2 Asec
QP CD Model Set2 Asec
Roll No.
ARASU ENGINEERING COLLEGE, KUMBAKONAM-612 501
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
MODEL EXAMINATION
Year/Sem./Branch : III / V / CSE-A Max. Marks : 100
Sub. Code & Name : CS3501 – COMPILER DESIGN Duration : 3 hours
Date & Session : 11.11.2024 & AN
The Model Examination is used to assess the course outcomes CO1 to CO5, Lower Order Thinking
(LOT) and Higher Order Thinking (HOT) of the course.
11.a. Elaborate on the different phases of compiler with a neat sketch. [CO1,HOT,K5]
Show the output of each phase of the compiler when the following
statement is parsed.
SI=(p*n*r)/100
where n should only be an integer, p and r could be floating point
numbers.
(or)
b. Convert the following NFA to DFA.
[CO1,HOT,K6]
12.a. Check whether the following grammar can be implemented using [CO2,HOT,K5]
predictive parser. Check whether the string “abfg” is accepted or not
using predictive parsing.
A->A
A->aB|Ad
B->bBC|f
C->g
(or)
(or)
b. Construct the basic blocks and flow graph for the
following piece of code. [CO4,HOT,K6]
15.a. Discuss the DAG representation of the basic block with an example. [CO5,HOT,K6]
(or)
b. Explain peephole optimization with suitable examples.
[CO5,HOT,K5]
Part – C (1 X 15 = 15 Marks)
16.a. Construct LR(1) items for the following grammar and draw the transition [CO2,HOT,K6]
diagram representing the transitions among CLR items.
S->CC
C->cC
C->d
Show whether the string “cdcd” is accepted by this grammar or not.
(or)
b. Consider the following basic block, in which all variables are integers and [CO5,HOT,K6]
** denotes exponentiation.
a := x**2
b := 3
c := x
d := c*c
e := b*2
f := a+d
g :=e*f
Apply the following optimization techniques to this basic block, in order to
compute the result of each transformation.
i) Algebraic simplification (3)
ii) Copy propagation (3)
iii) Constant folding (3)
iv) Dead code elimination (3)
v) Common sub expression elimination (3)