You are on page 1of 3

Gandhi Engineering College,

Bhubaneswar
Faculty Name: Mohini P. Mishra
Department: CSE

Regd.No
Year
Semester
rd
3
6th
Subject: Compiler
Design

Branch
CSE
Code:

Date of Examination:
Course Name: B.Tech
[Question No. 1 is compulsory and answer any 5 from rest.]
Time : 3 Hours
1.

Full Mark : 70
[2 X 10=20]

i)

Explain why lexical analysis is usually a relatively slow phase of the compilation process.

ii)

What is cross compiler? How is the bootstrapping of compiler done to second machine.

iii)

Explain why an ambiguous cannot be LL(1).

iv)

What is back end of a compiler?

v)

Write down advantages of LR parsing.

vi)

What data structure we use for LR parsing.

Vii)

What is the role of regular expression in Lexical analysis.

viii)

List all the LR(0) items of the following grammar.


S AS | b , A SA | a

ix)

What is necessity of dead code elimination?

x)

Remove left recursion from the following grammar.


A Ac | Ad | a | b | c

2.(a) How SLR parser different from LR parser? Construct SLR parse table for the following grammar.[8]
A(A)|b
Show the parsing action for the string ( ( b ) ).
(b) Identify lexemes and suggest reasonable attribute values for tokens.

[2]

int main( )
{

return ( i>j ? I : j ) ;

}
3. (a) Compute FIRST and FOLLOW set for all the non-terminals of the following grammar.

[5]

SP$
P{D;C}
Dd,D|d
Cc,C|c
(b) Discuss different symbol table organization. Explain how scope rules and the block structure of the
programming language influence the symbol table organization.
4.a) Show that following grammar is LL(1)

[5]
[8]

SA
A aB
B bBC | f
Cg
(b) Write quadruple,Triple and Indirect Triple representation for the following expression.

[2]

( I ) X[ i ] = y
( ii ) x = Y[ i ]
5.a)

What are the different techniques used for code optimization in compilation process to generate [ 5 ]
optimized code.

b) Generate DAG for following 3-address codes.

[5]

c=X[i]
X[i]=d
e=X[j]
6. Discuss the structure of LALR parser. What do you mean by single symbol lookahead? Design an
LALR parser for the following grammar.
SB
B begin DA end
D Dd; |
A A;E | E

[ 10 ]

EB|S
7.

What are the objectives of Intermediate Code Generation? What is the different form of

intermediate code generated by Intermediate Code Generation phase? Generate 3-address codes for the
following code Segments.

[ 10 ]

main( )
{
int a = 1, z = 0 ;
int b[ 10 ];
while ( a <= 10 )
{
b[ a ] = 2 *a ;
z = b[ a ] + a ;
}
8. Write short notes on :
( a ) 3-address codes
( b ) Syntax Directed Translation

[5X2]

You might also like