0% found this document useful (0 votes)
39 views4 pages

QP CD Model Set2 Asec

Uploaded by

parvathy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views4 pages

QP CD Model Set2 Asec

Uploaded by

parvathy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

SET II

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.

K1 – Remembering K2 – Understanding. K3 – Applying.


K4 – Analyzing. K5 – Evaluating. K6 – Creating

COURSE CODE COURSE OUTCOMES (COs)


C302.1 Understand the techniques in different phases of a compiler.
Design a lexical analyzer for a sample language and learn to use the LEX
C302.2
tool.
Apply different parsing algorithms to develop a parser and learn to use
C302.3
YACC tool
Understand semantics rules (SDT), intermediate code generation and run-
C302.4
time environment.
C302.5 Implement code generation and apply code optimization techniques.

Answer all the questions


Part- A (10 X 2 = 20 Marks)

1. Programmer A has written a program that needs to be modified very [CO1,LOT,K5]


frequently. Which of the two languages, Visual Basic or C++, can be used
for his programming? Justify in two sentences.

2. What is a symbol table? [CO1,LOT,K1]


3. Write down the CFG for the set of odd length strings in {a,b}* whose first, [CO2,LOT,K5]
middle, and last symbols are same.
4. List out the steps for performing LR parsing. [CO2,LOT,K1]
5. What do you mean by Syntax Directed Translation (SDT)? [CO3,LOT,K1]
6. Convert the following statements into three address code format [CO3,LOT,K5]
X=a+(b*-c)+(d*-e).

7. When do you call a variable to be syntactically live at a point? [CO4,LOT,K3]


8. What does dangling references mean? [CO4,LOT,K1]
9. Define constant folding. [CO5,LOT,K1]
10. List the advantages and applications of DAG. [CO5,LOT,K2]
Part – B (5 X 13 = 65 Marks)

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)

b. Check whether the following grammar can be implemented using [CO2,HOT,K5]


CLR. Check whether the string “wxynzs” is accepted or not using
CLR parsing.
A->BCD|Ab|c
B->w|Bx
C->yCz|n
D->DB|s
13.a. Explain type checking and type conversion. Explain with an [CO3,HOT,K5]
example of converting the operands of the same type.
(or)

b. Write the syntax directed translation for the following


piece of code. [CO3,HOT,K5]

14.a. Elaborate the issues in developing a code generator. [CO4,HOT,K4]

(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)

You might also like