Você está na página 1de 4

Department of CS/IT

THEORY ASSIGNMENT Branch: CSE(7th sem) Subject: COMPILER DESIGN


GROUP A- (0502CS091001 0502CS091007)

QUESTION NUMBER 1. 2. 3. 4. 5.

QUESTION
What is compiler? Why do we need compiler? What is Interpreter? .Explain the role of lexical analyzer, syntax analyzer and semantic analyzer in detail. Write a CFG, which generate string of balanced parenthesis. Consider the CFG SXX X XXX/ bX/ Xb/a Find the parse tree for the string bbaaaab What do you understand by Parse Tree? What is left most derivation? What is right most derivation? 1. Finding leading and trailing for the following grammer. EE+T | E TT*F | T F(E) | id Design operator precedence parser for the above grammar. What is syntax directed translator? Find the postfix notation for the following: 1) a + b*(c+d)e/f*(g/h)-i 2) -(a+b)*cd+e/(a+b+cd)-g+h/i Construct syntax tree for the following: 1)a + b*(c+d)e/f*(g/h) -i 2)-(a+b)*cd+e/(a+b+cd) -g+h/i Write three address code for a + b*(c+d)e/f*(g/h) -i Quadruple Tripple Indirect Tripple

UNIT 1 1 1 2 2

6. 7.

2 3

8. 9. 10. 11.
i) ii)

3 3 4 4 4

12.

13. 14. 15.

1. Construct DAG for the following a+b*(c+d)e/f(g/h)-i What is DAG? Write an algorithm to find basic building block.

5 5 5

GROUP B(0502CS091008-0502CS091016)

QUESTION NUMBER 1. 2. 3. 4. 5.

QUESTION
What is assembler? Explain the phases of compiler. Explain the difference between compiler and interpreter. Write a CFG, which generate string of balanced parenthesis. Consider the CFG SaAS/a ASbA/SS/ba Show that Saabbaa What do you understand by Parse Tree? 1. Annotate the following grammer to count how many reduction are to be performed for the string id+id*id: EE+T | E TT*F | T F(E) | id What is dynamic storage allocation? Discuss the following storage allocation strategies: Stack allocation Heap allocation What is Peep Hole Optimization? Translate the given expression, by three address code and also give quaruple.a:= -b * (c+d) Write the intermediate code for While(A<C) and B>D { If(A=1) Then C=C+1 Else While(A<=D) { A=A+B }} What is brute force parsing technique? What is recursive descent parser. What are the major issues for code generation? What is the register allocation?

UNIT 1 1 1 2 2

6. 7.

2 3

8. 9. 10. 11. 12.


2.

3 3 4 4 4

13. 14. 15.

5 5 5

GROUP C(0502CS091017-0502CS091020) QUESTION NUMBER 1. 2. 3. 4. QUESTION


What are the advantage and disadvantages for both single pass and multi-pass compiler? What are the issues in lexical analyzer? What is porting? Consider a CFG SAB/a Ab Identified and eliminate useless symbols. Find the reduced grammar that is equivalent to the CFG SaC/Sb AbSCa BaSB/bBC CaBC/ad Remove the left recursion from the following grammar: S SSa/Ab/c A AAb/d Write the syntax directed translation to go alongwith the LR parser for the following: S AE ADS while Ddo Consider the following syntax directed translation E E1 * T {E.val=E1.val* T. val} E T {E.val=T.val } T T1 F {T.val=T1.val-F.val} T F {T.val=F.val} F 2 {F.val=2} F 4 {F.val=4} Using the above SDTS, construct a parse tree for the expression: 4 2 4 * 2 also compute its E. val What are the advanced type checking? Consider the foolowing grammar: E E + T E T T T* F T F Fid And write the intermediate code for expression a + b * c as: i) Postfix representation ii) Syntax tree representation For the following program fragment: Sum=0 For ( j=1 ; j <=10 ; j++) Sum = sum + a[j] + b[j] Generate the three address code. There are 8-byte per word.

UNIT 1 1 1 2

5.

6. 7.

2 3

8.

9. 10.

3 4

11.

12.

13. 14. 15.

Consider the following switch statement: Switch ( i+j) { Case 1: x=y+z Default: p=q+r Case 2: u=v+w } And write the translation scheme to translate the above program fragment into three address code. What is Loop optimization? When dangling references What do you mean by dead code ?

5 5 5

Você também pode gostar