You are on page 1of 2

AKGEC/CDT/FM/01

AJAY KUMAR GARG ENGINEERING COLLEGE


GHAZIABAD
Assignment-2
Session: 2015-2016

Course: B.Tech
Branch: IT
Subject Name: Compiler Design

Year & Semester: III & VI


Section: I, J
Subject Code: NCS-603

Note: Attempt all questions:


1. Differentiate between Syntax- directed definitions and Translation schemes, with the help of an
example.
2. What are synthesized and inherited attributes?
3. Write SDD for construction of syntax trees for arithmetic expressions.
4. Write quadruples, triples and indirected triples for the expression:
-(a b) * (c + d) (a+ b+ c)
5. Translate the following program into quadruples:
While A < c and B < D do
if A = 1 then C: = C+1
else while A <=D do A := A +2
6. How bottom up evaluation of S-attributed definitions is performed, illustrate with an example.
7. Write short notes on
(i)
Annotated parse tree
(ii)
Lattributed definitions
(iii)
Postfix notation
(iv)
Quadruples, triples and indirect triples
(v)
Three address code and types of three address statements
(vi)
Syntax trees
8. Let synthesized attribute val give the value of the binary number generated by S in the following
grammar. For example, on input 101.101 S.val = 5.625
S L.L| L
L LB | B
B 0 |1
Give SDTS to determine S.val
9. What are the benefits of using a machine independent intermediate form?
10. Give syntax directed translation into three address code for the following:
(i)
Assignment statements for arithmetic expressions
(ii)
Declarations
(iii)
Boolean expressions ( flow of control)
(iv)
Procedure calls

(v)
(vi)

Array references in arithmetic expressions


Case statements

11. Compare between the different methods for implementation of the three address codes.
12. Translate the following into three address code
A[I, J] = B[I, J] + C[A[K, L]] + D[I+J]
Assume bpw = 4.
13. What are the various storage management techniques available? What are their importance in
compiler design.
14. What are the various types of errors that may appear in compilation process? Explain the
function of Error Handling phase of a compiler.
15. Discuss the following parameter passing techniques with suitable example.
(a) Call by value
(b) Call by reference
(c) Call by name
16. For the construct a > b or c > d and e > f
(i)
The annotated parse tree
(ii)
Three address code
(iii) Stack implementation
17. Construct three address code A = -B * (C + D). also generate its quadruple representation
18. In C the for statement has the following form
For (e1; e2; e3) stmt
Construct a SDTS to translate into three address code
19. Discuss Error Detection and Recovery in
(i)
LR parsers
(ii)
LL(1) Parsers
(iii) OP Parsers
20. Discuss different methods of error detection (e.g. panic mode etc.)
21. Discuss the data structures used for symbol table management.
22. Explain the procedure for dynamic storage allocation.

You might also like