SPPU Computer Engineering (Semester 7)
Principles of Modern Compiler Design
May 2014
Total marks: --
Total time: --
INSTRUCTIONS
(1) Assume appropriate data and state your reasons
(2) Marks are given to the right of every question
(3) Draw neat diagrams wherever necessary


Answer any one question from Q1 and Q2
1 (a) Explain the design of compiler with front end and back end arrangement. Clearly mention the advantages achieved.
6 M
1 (b) Check whether following grammar is LL(1). Also depict the moves by parser for input string 'ab'.
i) S -> aABb
A -> c|ε
B -> d|ε
8 M
1 (c) Define: Token, Lexical error, Regular Expression, Cross compiler.
4 M

2 (a) Compare SLR, LR (1) and LALR parser generation methods
6 M
2 (b) Construct LR(1) parsing table for following grammar:
S → Aa|bAc|Bc|bBa
A → d
B → d
8 M
2 (c) Explain the working of Operator Precedence parser.
4 M

Answer any one question from Q3 and Q4
3 (a) How do we evaluate synthesized and inherited attributes in the semantic rules during bottom-up parsing? Illustrate with example.
8 M
3 (b) What is type expression? Write type expression for following: An array of pointer to real where array index ranges from 1 to 50.
4 M
3 (c) What is semantic analysis? Give an example of error that is detected during semantic analysis.
4 M

4 (a) What is type casting? Explain implicit and explicit type casting with example. What changes should be made in semantic analyzer to add type casting.
8 M
4 (b) What is type checking?
2 M
4 (c) Construct a top-down parser for generating intermediate code for declarative statement in C language.
6 M

Answer any one question from Q5 and Q6
5 (a) Write CFG for following statement:
While condition do S. Write syntax directed translation to translate this statement in Three address code.
8 M
5 (b) Translate following statement into three address code:
C[i][j] = A[i][j] + B[i][j]
Assume suitable values.
6 M
5 (c) Compare triple and indirect triple.
2 M

6 (a) How is a switch case statement translated into three address code? Illustrate with an example.
8 M
6 (b) Discuss the advantages and disadvantages of short circuit evaluation of Boolean expression with example.
4 M
6 (c) Generate three address code in the form of Quadruple:
If (a < b) then
While (c > d) do x = p*q
4 M

Answer any one question from Q7 and Q8
7 (a) Discuss the need for symbol table with compiler. Explain different symbol table organizations.
8 M
7 (b) Define Activation record. Explain with example, the elements of activation record.
8 M

8 (a) Explain with example various parameter passing techniques.
8 M
8 (b) Compare and Contrast static storage management and dynamic storage management.
8 M

Answer any one question from Q9 and Q10
9 (a) Explain advantages of dividing the three address statements into basic blocks.
4 M
9 (b) With a proper example, explain algorithm for labelling a tree.
6 M
9 (c) What is register allocation and assignment problem?
6 M

10 (a) Discuss various issues in code generation.
4 M
10 (b) Explain: Dynamic programming algorithm for code generation.
8 M
10 (c) What is peephole optimization?
4 M

Answer any one question from Q11 and Q12
11 (a) What is copy propagation? Illustrate how copy propagation facilitates other optimization opportunities.
6 M
11 (b) Draw a sample flow graph. Explain generation and killing of expressions with respect to the flow graph.
6 M
11 (c) What are induction variables? Explain with example how induction variables help in loop optimization?
6 M

12 (a) Consider following basic blocks:
i) T1b+c
T2=d*c
T3=b+c

T4=T2*T3
T5=T4*f
x=T1-T5
Which of the local optimization techniques are possible to be carried out with above basic block?
6 M
12 (b) Compare quadruples, triples and indirect triples with respect to their use in code optimization.
6 M
12 (c) Explain following terms:
Available expression
Reaching definition
Live variable
6 M



More question papers from Principles of Modern Compiler Design
SPONSORED ADVERTISEMENTS