9A05504 Compiler Design

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Code: 9A05504

1
(Computer Science and Engineering)

B.Tech III Year I Semester (R09) Regular & Supplementary Examinations December/January 2013/14 COMPILER DESIGN Time: 3 hours Answer any FIVE questions All questions carry equal marks ***** 1 (a) (b) 2 Explain with an example about the procedure of translation of a statement. Differentiate pass and phase in compiler. Find the predictive parser for the following grammar and parse the sentence (a+b) *c. E E+T|T T T*F|F F (E)| id Write a brief note on bottom up parsing. Define handle. Explain about handle pruning. Generate intermediate code generation for the following code along with the required translation scheme. int a,b; float c; a=10; switch(a) { case 10:c=1; case 20:c=2; } What is a symbol table? What are the contents of a symbol table? Explain briefly the data structures for symbol table. List the criteria to the selection of optimizing transformations. Write note on symbolic debugging of optimized code. Algebraic identities are important class of optimization on basic blocks. Explain. What are basic blocks and flow graphs? Explain with example. Define induction variable. Give examples. Explain its use. Explain code generation algorithm. Write a note on application of directed acyclic graph in code generation. Max Marks: 70

3 (a) (b) 4

6 (a) (b) (c) 7 (a) (b) 8 (a) (b)

*****

Code: 9A05504

2
(Computer Science and Engineering)

B.Tech III Year I Semester (R09) Regular & Supplementary Examinations December/January 2013/14 COMPILER DESIGN Time: 3 hours Answer any FIVE questions All questions carry equal marks ***** 1 (a) (b) 2 (a) (b) 3 (a) (b) Explain format for the input or source file of LEX. Discuss in detail about lexical errors. Explain recursive descent parsing. Write an algorithm for construction of predictive parsing table. What are the rules for Closure operation in SLR parsing? Explain the rules for GOTO operation in LR parsing. Explain the need of augmentation. How will you change the given grammar to an augmented grammar? Give example. How do you check the expressions in polymorphic functions? Explain through an example. Consider the following declarations type link = cell; var next : link; last : link; p : cell; q,r : cell; Which the following expressions are structurally equivalent? Which are name equivalent? Justify your answer. link pointer(cell) pointer(link) pointer(record((info X integer) X (next X pointer(cell))) Explain the various data structures used for implementing the symbol table and compare them. Define code optimization. What are the principle sources of optimization? Explain in detail. Explain about peep hole optimization in detail. Explain how data-flow information is maintained after code motion. Explain heuristic ordering for DAG? What is meant by register descriptor and address descriptor? Explain. Max Marks: 70

4 (a) (b)

6 (a) (b) 7 8 (a) (b)

*****

Code: 9A05504

3
(Computer Science and Engineering)

B.Tech III Year I Semester (R09) Regular & Supplementary Examinations December/January 2013/14 COMPILER DESIGN Time: 3 hours Answer any FIVE questions All questions carry equal marks ***** 1 (a) (b) 2 Draw a block diagram of phases of a compiler and indicate the main functions of each phase. Write the chief difference between compiler and interpreter. Consider the following grammar E TE E +TE| T FT T*FT| F(E)|id Consider the predictive parsing table and show the stack implementation for the input string id+id * id. Consider the following augmented grammar SE1 E1T3E1|T1 E2T3E2|T2 T1 a$|(E2$ T2 a)|(E2) T3 a+|(E2+ Find the canonical sets of items. What is a three address code? What are its types? How it is implemented? Explain how declarations are done in a procedure using syntax directed translation. Explain one method of hash function. What do you mean by dangling reference? Explain with example. What is DAG and Flow graph? Explain their role in compilation process. What is meant by strength reduction? Explain it in detail. What is meant by alias? Explain how it is computed. What is register-interference graph? Explain its role in code generation. Max Marks: 70

4 (a) (b) 5 (a) (b) 6 7 (a) (b) 8

*****

Code: 9A05504

4
(Computer Science and Engineering)

B.Tech III Year I Semester (R09) Regular & Supplementary Examinations December/January 2013/14 COMPILER DESIGN Time: 3 hours Answer any FIVE questions All questions carry equal marks ***** 1 (a) (b) Write about lexical analyzer generator. Construct minimum state DFAs for the following regular expressions. (i) (a+b)* a (a+b) (ii) (a+b)* a (a+b) (a+b) (iii) (a/b)* a (a/b)(a/b)(a/b). Discuss in detail about recursive descent parsing. Explain about derivation tree with an example. Consider the following augmented grammar S S SAS|b ASA|a (i) List all the LR(0) items for the above grammar. (ii) Construct the DFA whose states are the canonical collection of LR(0) items. (iii) Construct the SLR parsing table. List out some typical semantic errors. Explain how they can be rectified. What is static checking? Give some examples of static checks. Differentiate between static and dynamic scope rules. What is meant by copy restores? Explain it with example. Explain briefly the following code optimization techniques: Folding. Strength reduction. Write notes on: Induction variable elimination. Inherited and synthesized translation. Explain the translation of assignment statements. What do you mean postfix translations? Max Marks: 70

2 (a) (b) 3

4 (a) (b) 5 (a) (b) 6 (a) (b) 7 (a) (b) 8 (a) (b)

*****

You might also like