You are on page 1of 2

Reg. No.

B.E. DEGREE MODEL EXAMINATION, APRIL 2013


DATE : 17.04.2013

Sixth Semester
Computer Science and Engineering
CS2352 PRINCIPLES OF COMPILER DESIGN
Maximum : 100 marks
Answer ALL questions

Time : Three hours

Part A - (10 x 2 = 20)


1. Define a symbol table.
2. Write the advantage of using Input Buffering?
3. What is an ambiguous grammar? Give an example.
4. Write the properties of an Operator grammar. Give one example.
5. Write the important properties of Intermediate representation..
6. Why are quadruples preferred over triples in an optimizing Compiler?
7. State the parts of a YACC source program.
8. Draw the diagram of the general activation record and give the purpose of any two
fields.
9. Mention the criteria for code improving transformations.
10.

What is code motion? Give an example.


Part B - (5 x 16 = 80)

11. a) What is a compiler? Explain the various phases of compiler in detail with a
neat sketch.

(16)
Or

b) i) What are the possible error-recovery actions in lexical Analyzer? (4)


ii) Construct DFA for the regular expression (a | b)*a(a | b) using Thompson
construction method?
12.

(12)

a) Construct Predictive Parsing table for the following grammar:

(16)

S (L) | a
L L, S | S
and check whether the following sentences belong to that grammar or not.
(i) (a, (a, a))

(ii) (a, ((a, a), (a, a)))


Or

b) Construct SLR Parsing table for the following grammar


EE+T
ET
TT*F
TF
F(E)
Fid

(16)

Give the moves of LR parser for the string id +id* id


.
13.

(a) (i) Define three-address code. Describe the various methods of implementing threeaddress statements with an example.

(8)

(ii) Give the translation scheme for converting the assignments into three address code. (8)
Or
(b) (i) Discuss the various methods for translating Boolean expression.
(8)
(ii) Explain the process of generating the code for a Boolean expression in a single
pass using back patching.
14. (a) i) Explain the issues in design of code generator.
ii) Explain Simple Code Generator with Code Generation algorithm?

(8)
(8)

Or
(b) i) Define basic block. Write an algorithm to partition a sequence of three-address
statements into basic blocks
(10)
ii) What are the steps needed to compute the next-use information?
(6)

15. (a) Why do we need Code optimization? Explain the principle sources of
optimization.

(16)
Or

(b) i) Write an algorithm to construct the natural loop of a back edge


ii) Write algorithm and explain the following code-improving techniques:
a. Copy Propagation
b. Dead code Elimination
c. Code motion

(8)
(8)

You might also like