Professional Documents
Culture Documents
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)
iv)
v)
vi)
Vii)
viii)
ix)
x)
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.
[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]