Semester : SEMESTER 6
Subject : Compiler Design
Year : 2018
Term : APRIL
Branch : COMPUTER SCIENCE AND ENGINEERING
Scheme : 2015 Full Time
Course Code : CS 304
Page:2
11
12
13
14
15
16
17
18
19
20
a)
b)
b)
B6815 Pages: 2
S>Bb/Cd . 8೨೩೫/೭ 02006
Demonstrate the identification of handles in operator precedence parsing? (3)
Design a Syntax Directed Definition for a Desk calculator that prints the result. (3)
Describe the type checking of functions. (3)
PART D
Answer any two full questions, each carries 9 marks.
Construct canonical LR(0) collection of items for the grammar below. (5)
5௮1, 5 1२
೩೨೩
L>*R
1. > id
ROL
Also identify a shift reduce conflict in the LR(0) collection constructed above.
Define S-attributed and L-attributed definitions. Give an example each. (4)
Explain bottom- up evaluation of S- attributed definitions. (5)
With an SDD for a desk calculator, give the appropriate code to be executed 9 (4)
each reduction in the LR parser designed for the calculator. Also give the
annotated parse tree for the expression (3*5) —2.
Construct LALR parse table for the grammar S->CC,C->cC|d (9)
PART E
Answer any four full questions, each carries 10 marks.
Write syntax directed definitions to construct syntax tree and three address code (10)
for assignment statements.
Explain quadruples and triples with an example each. (5)
Construct the syntax tree and then draw the DAG for the statement (5)
௦: (a*b) + (०-0) * (a*b)
Explain static allocation and heap allocation strategies. (10)
With an example each explain the following loop optimization techniques: (i) (10)
Code motion (ii) Induction variable elimination and (iii) strength reduction
Explain any two issues in the design of a code generator. (5)
Explain the optimization of basic blocks. (5)
Write the Code Generation Algorithm and explain the getreg function. (6)
Generate a code sequence for the assignment d=(a-b)+(a-c)+(a-c) (4)
೫ ೫ ಸೇ ೫
Page 2 of 2