Pune University BE Compiler Design Question Papers

Pune University BE Compiler Design Question Papers

B.E. (Information Technology) COMPILER DESIGN

(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.


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.                              [6]

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.       [10]


Q2) a) Differentiate between :                                                                                                                                                                                                                                                         [6]

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 – .                                                                                                                                    [10]

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


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

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.


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

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

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.                                [12]

S ^ a | a | (T)

T ^ T, S | S

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


Q6) a) Consider the following grammar :                                                                                                                                                                                                                                 [12]

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.                                                                                                                                                                                          [6]


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


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

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

i)                 Pass by value.

ii)                Pass by reference.

iii)               Pass by name.

iv)               Pass by value result.


int i = 0;

Void p(int x, int y)


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




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

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

Return 0 ;


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

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




Case 5:

Z = a+b;



Z = a-b;



Z = z + b;


Construct the

i)             three address code

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.                                                                                    [4]


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

{_ int i;

int a [10]; while(i<=10)

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


Int add_fun(int c, int d)


Int e;

E = c+d;



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

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


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?      [10]

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

Leave a Comment