Compiler Put 2023
Compiler Put 2023
a =b+c
b =a–d
c = b+c
d =a-d
(j) What is u-d chaining in global data flow analysis?
SECTION – B
2. Attempt any three parts of the following: ( 10 x 3 = 30)
(a) Explain cross compilers and boot strapping with suitable examples.
(b) Compute FIRST & FOLLOW for the below given grammar and construct Predictive Parsing Table.
S → ACB | CbB | Ba A → da | BC B→g|∈ C→h|∈
(b) The following grammar generates expressions formed by applying an arithmetic operator + to
integer and real constants.
Grammar Rules : E → E + T | T , T → num . num | num
(i) Give the syntax directed definition to determine the data type of each sub – expression.
(ii) Modify the SDD of part (i) to translate expression into postfix notation as well as
determine data types. Use the unary operator inttoreal to convert an integer value
into an equivalent real value , so that both operands of + in the postfix form have the same
data type.
(d) What is scope information in block structured programming? How compiler keeps track of
scope information of non-local data? Explain with an example.
(e) Explain various function preserving transformation techniques applied in code optimization
SECTION – C
3. Attempt any one part of the following: ( 10 x 1 = 10)
(a) Explain the working of lexical analysis phase with proper block diagram and example.
(b) What is activation record and activation tree? How it is used in run time storage organization?
Draw Activation tree and corresponding Control Stack for activation of f(5) in following
given code What does the stack and it’s activation record look ,when the fifth time f(1) is about
to return?
int f (int n)
{
int t , s ;
if (n< 2) return 1;
s = f (n-1) ;
t = f ( n-2) ;
return s + t ;
}
(a) Construct non empty sets of LR (1) items for the following grammar. Also verify whether it
CLR (1) or not ?
S →A A → AB | ε B → aB | b
(b) What are handles in bottom up parsing? Consider the following grammar-
S→TL; T → int | float L → L , id | id
Parse the input string : int id , id ; using stack operations of shift-reduce parser.
(b) What is Back-patching? Generate three address code for the following program segment using back
patching :
while ( a < c && b > d )
{ if (a = = 1)
c=c+1;
else
while (a < = d)
{ a=a+3 ;}
}
(a) Explain various types of errors encountered in any program with one example of each.
(b) Explain Stack Allocation and Heap Allocation strategies w.r.t run time environment.
(a) Define various loop optimization techniques applied in optimization of basic blocks. Generate three
address code of following given code and draw its control flow graph and perform optimization.
sum = 0 ;
; for (i=1 ; i<= 20 ; i++)
sum = sum + a[i] + b[i]
(Assume width of array elements = 4 bytes
and lower bound = 1)
(b) What is machine dependent code optimization? Explain peephole optimization.