# Pune University BE Compiler Design Question Papers

## (2008 Pattern) (Elective – I) (Sem. – I)

Time : 3 Hours]                                                                                            [Max. Marks : 100

Instructions to the candidates:

1)         Answer three questions from each section.

2)         Answer to the two sections should be written in separate answer-books.

3)          Neat diagrams must be drawn whenever necessary.

4)          Pigures to the right indicate full marks.

5)         Assume suitable data, if necessary.

SECTION – I

QI) a) What is a pass in the compiler? What factors influence the number of passes of a compiler? Explain how you can group the difference phases of the compiler into passes.                              

b) Explain in detail the process of compilation. Explain the output of each phase for the following statement V4 = V3 + 34 – (45*V1 – V2); where V4 and V2 are float and V3 and VI are integer.       

OR

Q2) a) Differentiate between :                                                                                                                                                                                                                                                         

i)                 Lexeme and token.

ii)                Interpreter and compiler.

b) Explain in detail the various phases of a compiler, describe the output for the following expression after each phase.

V4 = V3 + 34 – (45*V1 – V2);

Where + and – has equal precedence and * has higher precedence over + and – .                                                                                                                                    

QQA a) Describe the role of lexical analyzer and describe role of regular expression in lexical analysis phase of compiler.                                                                                                                 

b) In words, describe the languages denoted by following regular expressions :                                                                                                                                                   

i)                 0*10*10*10*

ii)                (0|1)*0(0|1) (0|1)

iii)               @0)*11(0|1) (00)*

and the example of such strings which will be represented by the given regular expression.

OR

Q4) a) Explain the need for a look ahead operator in the lexical analysis phase of compiler with example.                                                                                                                                       

b) Specify the lexical form (regular definition and DFA) of numerical constants, identifiers and keywords in the ‘C’ programming language. 

Q5) a) Explain the steps to calculate the FIRST and FOLLOW set in the predictive parser use the same steps to design the predictive parser table for the following Grammar.                                

S ^ a | a | (T)

T ^ T, S | S

b) What is left recursion? How can it be eliminated? Give suitable example. 

OR

Q6) a) Consider the following grammar :                                                                                                                                                                                                                                 

S       ^ L = R|R L ^ * R|id R ^ L

i)                 Construct a predictive parse table for above mention grammar.

ii)                Show the actions of the parser for the input string “id = *id”.

b) What is left factoring? Explain with suitable example.                                                                                                                                                                                          

SECTION – II

Q7) a) What are the different fields in activation record? How these fields help to handle the procedure calls? Explain with suitable example.  b) Give the parse tree and translations for the expression (\$*7 + 19)*2 according to syntax directed translation scheme.                                                                                                                                                                                                                                                           

OR

Q8) a) Discuss the importance of symbol table in compiler design. How is the symbol table manipulated at various phases of compilation?                                                                                    

b) Give the output of the following program using the following parameter passing methods :                                                                                                                             

i)                 Pass by value.

ii)                Pass by reference.

iii)               Pass by name.

iv)               Pass by value result.

#include<stdio.h>

int i = 0;

Void p(int x, int y)

{

x + = I; i + = I; y + = I;

}

Main()

{

int a = {I, I} p(a[i],a[i]);

printf(“% d %d\n”, a,a[l]);

Return 0 ;

}

Q9) a) Consider the following code that produces a 10*10 identity matrix.  Int z;

Int func (int sel, int a, int b)

{

Switch(sel)

{

Case 5:

Z = a+b;

Break;

Default:

Z = a-b;

Break;

}

Z = z + b;

}

Construct the

ii)            basic blocks

iii)            flow graph

b) How can three address code implemented in a compiler? Describe triples and indirect triples method of three address code.                                                                                    

OR

QI 0) a) Generate three address code and quadruple for following C program main()

{_ int i;

int a ; while(i<=10)

a[i] = add _ fun(int c, int d);

}

{

Int e;

E = c+d;

Return(E);

}

b) What is type systems and type checking? What are the type checking functions?                                                                                                                                                 

QII) a) How are the obj ect layout is maintain in Multilevel inheritance and hybrid inheritance (give example)? How compiler handle this inheritance.  b) What is constructor in object oriented programming? What is default constructor and parameterized constructor? What is their significance? Explain with suitable example.                                                                                                                                              

OR

Q12) a) Compare the concept of object and classes of object oriented programming languages with structure of procedural languages? How compilers handle objects, classes and structures?      

b) What is constructor and destructor in object oriented programming? What is their significance? Explain with suitable example.