Compiler Design
Compiler Design
Enrollment No:
SECTION A
1. Each Question carries 5 Marks.
2. Instruction: Write short notes / Select the correct answer(s).
S.No. CO
Q1 List down the fields in the activation record. CO4
Q2 Describe the role of symbol table in compiler CO4
Q3 State the problems with Top-Down Parsing. CO2
Q4 State the difference between synthesized attributes and inherited attributes. CO3
Q5 Which of the following is the most suitable alphabet for the language L = {SHAKTI, SHIVA,
RAM}
(a) {A, H, I, K, M, R, S, T, V, N}
CO1
(b) {A, H, I, K, M, R, S, T, V}
(c) {a, h, i, k, m, r, s, t, v}
(d) {a, h, k, k, m, R, S, t, v}
Q6 DAG representation of the basic block allows us to perform the following code improving
transformations:
(a) Eliminating local common subexpressions.
CO5
(b) Eliminating dead code.
(c) Restricting reordering of statements.
(d) Applying algebraic laws to reorder operands of three-address instructions.
SECTION B
1. Each question carries 10 marks.
2. Instruction: Write short/brief notes.
Q7 Translate the following expression into quadruple and triple representations:
x[ i ] = interest(p, n, r) + y[ i ]. CO3
Q8 Create a cross compiler for EQN using following compilers (i) C compiler, written in
CO1
PDP-11, producing code in PDP-11 (ii) An EQN language compiler producing code for text
Q9 Consider the following possible sets of LR(1) items in the states of a shift/reduce parser:
CO2
a) For the items in State 0, list any conflicts that exist and describe for what lookaheads
they occur.
b) For the items in State 1, list any conflicts that exist and describe for what lookaheads
they occur.
OR
Construct the operator precedence parsing table by computing leading and trailing for
every non-terminal in the following grammar: CO2
. S→N
N→V=E#
N→E
E→V
V → id
V→*E
SECTION C
1. Attempt any of the following. Each question carries 20 marks.
2. Instruction: Write long answer.
Q 12 Explain the different machine independent code optimization technique and apply those on the given
(A) Generate code for the following three-address statements assuming all variables are stored
in memory locations.
1. x=1
2. x=a
3. x=a+1
4. x=a+b
5. The two statements
(i) x = b * c
(ii) y = a + x
(B) Generate code for the following sequence assuming that x, y, and z are in memory
locations:
if x < y goto L1
z=0
goto L2
L1: z = 1