VTU Computer Science (Semester 6)
Compiler Design
December 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


1 (a) Explain with neat diagram, the phase of compiler with example.
10 M
1 (b) Construct a transition diagram for recognizing relational operators. Sketch the program segment to implement it, showing the first state and one final state.
10 M

2 (a) Briefly explain the problems associated with top down parser.
3 M
2 (b) Show that following grammar is ambiguous: S → S+S|S*S|id. Give an unambiguous grammar for the above grammar such that '+' has highest priority and * has less priority and both are left associative.
7 M
2 (c) Given the grammar A → (A)/a
i) Construct predictive parser table
ii) Check the grammar is LL(I) or not.
iii) Show the parser steps for the input ((a)).
10 M

3 (a) Obtain LR(0) items for the following grammar:
S→L→R| R L→* R| id R → L.
8 M
3 (b) Obtain FIRST and FALLOW sets for the grammar shown in Q3 (a) and obtain SLR parsing table. Is the grammar SLR?
12 M

4 (a) Given the grammar: A →CC C→aC|b
i) Construct sets of LR(1) items
ii) Construct canonical LR(1) parsing table.
12 M
4 (b) Write a note on the parse generator - YACC.
3 M
4 (c) Write the YACC specification of a simple desk calculator with following grammar for arithmetic expression:
E → E+T|T
T→T*F|F
F→(E)| digit where digit between 0 to 0.
5 M

5 (a) Explain type of attributes for non terminal with example.
4 M
5 (b) Write annotated parse tree for expression 5+4*3n where grammar is
L→En
E → E + T|T
T → T * F|F
F → (E) | digit
6 M
5 (c) How different classes of SDD's that guarantee evaluation order?
6 M
5 (d) Obtain postfix SDT for simple desk calculator.
4 M

6 (a) Obtain the directed a cyclic graph for the expression x+x*(y+z) + (y+z)=w.
6 M
6 (b) Explain the following with example:
i) Quadruples ii) Triples
iii) Indirect triples
6 M
6 (c) Explain SDT of switch statement.
8 M

7 (a) What is activation records? Explain structure and purpose of each field in the activation record.
6 M
7 (b) Explain tasks of caller and callee when procedure called and exit.
8 M
7 (c) Explain briefly the performance metric to be considered while designing garbage collector.
6 M

8 (a) Write intermediate code for the following source code:
for i from 1 to 10 do
for j from 1 to 10 do
a[i, j]=0.0;
for i from 1 to 10 do
a [i, j]=1.0;
and identify basic blocks.
10 M
8 (b) Discuss the issues in the design of a code generator.
10 M



More question papers from Compiler Design
SPONSORED ADVERTISEMENTS