How To Exam?

a knowledge trading engine...


Biju Patnaik University of Technology 2008-7th Sem B.Tech (B Tech),ester compiler design - Question Paper

Thursday, 23 May 2013 02:45Web

BTch (BPUT) seventh semester ques. paper of compiler design.


IWL

Seventh Semester Examination *- 2008 COMPILER DESIGN

Full Marks -70

Time-3 Hours

Answer Question No. 1 which is compulsory and any five from the rest.

The figures in the right-hand margin indicate marks,

Ii i

1. Answer the fol lowing questions : 2x10

(a) What fS the front-end of a compiler ?

(tO What are the error recovery actions in a lexica! analyzer?

(c) What are the goafs of error handler in a parser ?

(d} What do you mean postfix transitions ?

(e)    Explain, why a common approach are being used lo design the Lexical analyzer for different compilers 7

(f)    What is basic biock in a code segment ?

(g)    Why do most compilers contain symbols tables ?

(h)    What is the need of attributed grammar and L-attributed grammar in semantic analysis ?

(i)    Suggest a efficient data structure to implement LR parsing table    IWL

(j) Define token and lexeme. Find out the tokens from the following code segment.


main()

{ =

int a = 5; int b[11 ]; while (a <= 5) b[a] = 3 - a;

}

(a)    Describe the basic differences between top-down and bottom-up parsing, if you had to write a parser by hand which approach would you use ? If you had to write a parser for a relatively complex language, which approach would yoy use ?

5

(b)    Show that the following is an SLR (1) grammar    5

e e ADD 111 t -> iMULf j f f-> VAR

(a)    What is the objective of Intermediate cods generation ? Write quadruples, Iriples and indirect triples for the following expression.

5

-<a + b)-(c + d)-(a + b + c)

(b)    Write tJhe role of a error detector in compilation process. Discuss different errors in Lexical-Phase.    5


4.    {a) Explain the difference between LALR

parsing tabte and canonical LR parsing table ?    5

(b; Write the algorithm to construct a canonical LR parsing table for the augment grammar,    5

5.    /(a) Consider the following context-free / gramma r. Where S is the start symbol.

S - A S II b

IWL


S-h (A)

A -* a SA

Construct an NFA whose sets are the LR(0) items of the given gram mar, Show that the canonical collection oi LR(Q) items for the grammar is the same as the states ot equivalent DFA.    5

(b) Discuss the importance of symbol table in compiler design. How is the symbol table manipulated during semantic analysis ph ase of compilation ?    5

6,    (a) What are the issues in the design of the

code generator ? Explain.    5

(b) What is D'AG ? Write an algorithm 1o construct DAG from the block of three address code. Explain the process with a relevant example.    5

7.    (a) What is a three address code ? What are kJ its types ? How it is implemented ?

Generator three address code for the following code segment,    5

main{)

{

int a 1; int b[10]; while (a <= 10) b[al = 2 *a:

(b) Discuss the structure of a symbol table. Explain how the symbol table is created for a block structured language.    5

8 (a) Write down the necessary algorithms and define FIRST and FOLLOW.    5


(i)    x = f(a) + f(a) + f(a)

(ii)    a[i] = b[j]

(iii)    a[i] = b[c[ij]

(iv)    a[i] = a[ij + b[j].


(b) Let the Target machine is a byte addressable machine with four bytes to a word and n general-purpose registers

IWL


r    R * It operates on tw

no* 1* 1n"1

address instruction of the form op source, destination; The op-codes are MOV, ADD, SUB.

i


Generate code for the following C

statements for a target tnachine described

r i

t

V

V*

X

7 lift'


above. Assume that three registers are

   5

available.

_ . .    R    Contd.

PECS 3404    6

PECS 3404    -C



Attachment:

( 0 Votes )

Add comment


Security code
Refresh

Earning:   Approval pending.
You are here: PAPER Biju Patnaik University of Technology 2008-7th Sem B.Tech (B Tech),ester compiler design - Question Paper