Sie sind auf Seite 1von 8

Code No: R05320502

Set No. 1

III B.Tech II Semester Regular Examinations, Apr/May 2009 COMPILER DESIGN (Computer Science & Engineering) Time: 3 hours Max Marks: 80 Answer any FIVE Questions All Questions carry equal marks 1. (a) Explain the dierent phases of a compiler, showing the output of each phase, using the example of the following statement: position : = initial + rate * 60 (b) Compare compiler and interpreter with suitable diagrams. 2. (a) Consider the grammar given below. E E+E | E-E | E*E | E/E | a | b obtain left most and right most derivation for the string a+b * a+b. (b) Explain back tracking with example. 3. Construct SLR parsing table for the following grammar. S AS|b A SA|a 4. Write type expressions for the following types. (a) An array of pointers to reals, where array index ranages from 1 to 100. (b) A two dimensional array of integers (i.e. an array of array) whose rows are indexed from 0 to 9 and whose columns are indexed from -10 to 10. (c) Functions whose domains are functions from integers to pointers to integers and whose ranges are records consisting of an integer and a character. [5+5+6] 5. Explain the following with an example. (a) Indirection in symbol table entries (b) Self organizing symbol tables. 6. (a) What is DAG? Construct the DAG for the following basic block D := B C E :=A+B B := B+C A := E-D (b) What are the legal evaluation orders and names for the values at the nodes for the DAG of problem (a). i. Assuming A, B and C are alive at the end of the basic block? ii. Assuming only A is live at the end? [6+10] [8+8] [8+8] [10+6]

[16]

7. (a) Explain in detail the procedure that eliminate global common sub - expression. 1 of 2

Code No: R05320502 (b) What are the applications of du and ud chains.

Set No. 1
[8+8]

8. (a) What are the various addressing modes available? GIve some example machine instructions which reduces memory access time. (b) Explain the concept of label tree of code generation. [8+8]

2 of 2

Code No: R05320502

Set No. 2

III B.Tech II Semester Regular Examinations, Apr/May 2009 COMPILER DESIGN (Computer Science & Engineering) Time: 3 hours Max Marks: 80 Answer any FIVE Questions All Questions carry equal marks 1. (a) Write a short notes on token specication. (b) Draw a NFA for a * | b *. [8+8]

2. (a) What is recursive descent parser? Construct recursive descent parser for the following grammar. E E + T|T T TF|F F F |a|b (b) What is ambiguous grammar? Eliminate ambiguities for the grammar: E E + E|E E|(E)|id. [8+8] 3. Construct LALR parsing table for the following grammar S CC C cC|d

[16]

4. (a) Which of the following recursive type expressions are equivalent? Justify your answer? e1 =integer e1 ; e2 =integer ( integer e2 ); e3 =integer ( integer e1 ). (b) Suppose that the type of each identier is a sub range of integers for expressions with the operators +,-,*,div and mod as in pascal. Write type-checking rules that assign to each sub expression, the subrange its value must lie in. [8+8] 5. Draw and explain the symbol table organization for C language with a program block. [16] 6. Explain dierent principal sources of optimization technique with suitable examples. [16] 7. Consider the following program which counts the primes form 2 to n using the sieve method on a suitably large array begin read n for i : = 2 to n do a[i] : = true / * initialize */ count: = 0; 1 of 2

Code No: R05320502 for i : 2 to n ** .5 do if a [i] then /* i is a prime */ begin count := count +1 for j : = 2 * i to n by i do a[j] : =false / * j is divisible by i */ end ; print count end (a) Propagate out copy statements wherever possible. (b) Is loop jumping possible? If so, do it.

Set No. 2

(c) Eliminate the induction variables wherever possible.

[5+5+6]

8. (a) What are the various addressing modes available? GIve some example machine instructions which reduces memory access time. (b) Explain the concept of label tree of code generation. [8+8]

2 of 2

Code No: R05320502

Set No. 3

III B.Tech II Semester Regular Examinations, Apr/May 2009 COMPILER DESIGN (Computer Science & Engineering) Time: 3 hours Max Marks: 80 Answer any FIVE Questions All Questions carry equal marks 1. (a) Construct a DFA for (a * + b *) abb. (b) Write a lex program to identify comments in the program. 2. (a) Construct predictive parse table for the following grammar. E E + T|T T T F|F F F |a |b (b) What are the limitations of recursive descent porser. [8+8] [8+8]

3. (a) What are the common conicts that can be encountered in shift - reduce parser. (b) Construct SLR parsing table for the following grammar. R R | R |RR |R |(R) |a |b [8+8]

4. (a) What is a syntax tree? Write syntax directed denition for constructing a syntax tree for an expression. The grammar for an expression is given below. E E + T |E T |T T (E) |id |num (b) Write a detail notes on type conversion. 5. Explain the importance of the following attributes of a symbol table. (a) Variable name (b) Object time address (c) Type of a symbol table (d) Link eld. 6. (a) Write the three-address code for the following code. begin PROD: = 0; I: =1; do begin PROD:=PROD + A[I] B[I]; I:=I+1; End while I<=20 end 1 of 2 [16] [8+8]

Code No: R05320502

Set No. 3

(b) Write an algorithm for partition of basic blocks and apply it on the above derived three-address code. [8+8] 7. (a) Generate the ow-graphs for the following expressions: S-> id: = E |S; S| if E then S else S | do S while E E-> id + id |id (b) Mention data-ow equations for reaching denitions for the above expressions. [8+8] 8. State and explain dierent machine dependent code optimization techniques. [16]

2 of 2

Code No: R05320502

Set No. 4

III B.Tech II Semester Regular Examinations, Apr/May 2009 COMPILER DESIGN (Computer Science & Engineering) Time: 3 hours Max Marks: 80 Answer any FIVE Questions All Questions carry equal marks 1. (a) What is LEX? Explain, in detail, dierent sections of LEX program. (b) Write regular expressions for the following patterns. Use auxiliary denitions wherever convenient. i. the set of words having a,e,i,o,u appearing in that order, although not necessarily consecutively. ii. comments in C. [8+8] 2. (a) What are the diculties in top down parsing? Explain in detail. (b) Consider the following grammar S (L) |a L L, S |S Construct leftmost derivations and parse trees for the following sentences: i. (a,(a,a)) ii. (a,((a,a),(a,a))). 3. (a) Explain canonical LR parsing. (b) Explain briey, precedence functions. construct the precedence graph using the following prededence table. [8+8] + * ( ) id $ f 2 3 0 4 4 0 g 1 3 5 0 5 0 4. (a) Write a S - attributed grammar to connect the fopllowing grammar with prex rotator LE E E+T | E-T | T T T*F | T/F | F FPF|P P (E) P id. (b) Construct triples of an expression: a (b + c). 5. (a) What is heap storage allocation? Explain in detail. (b) Explain about implicit and explicit storage requests. 6. (a) Explain in detail the Optimization technique strength reduction. 1 of 2 [8+8] [8+8] [8+8]

Code No: R05320502 (b) What is a DAG. Explain its applications.

Set No. 4
[8+8]

7. (a) What is an Induction variable? Explain with an example. (b) Discuss how induction variables can be detected and how transformation can be applied. [8+8] 8. Generate code for the following C statements (a) x = f(a) + f(a) + f(a) (b) x = f(a) / g(b,c) (c) x = f(f(a)) (d) x = ++f(a) [16]

2 of 2

Das könnte Ihnen auch gefallen