0% found this document useful (0 votes)
8 views2 pages

Compiler Put 2023

This document outlines the examination structure for the Compiler Design course at Krishna Institute of Technology, Kanpur, including various sections with questions on compiler concepts, grammar, parsing, and optimization techniques. It consists of multiple choice questions, short answer questions, and detailed problem-solving tasks related to compiler design. The exam is designed to assess students' understanding of key topics in compiler construction and theory.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Compiler Put 2023

This document outlines the examination structure for the Compiler Design course at Krishna Institute of Technology, Kanpur, including various sections with questions on compiler concepts, grammar, parsing, and optimization techniques. It consists of multiple choice questions, short answer questions, and detailed problem-solving tasks related to compiler design. The exam is designed to assess students' understanding of key topics in compiler construction and theory.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Roll No: ………………...

KRISHNA INSTITUTE OF TECHNOLOGY, KANPUR


Pre University Examination (Odd Semester) 2023-24
B.Tech -CSE-III YEAR (V SEMESTER)
COMPILER DESIGN (KCS-502)
Time: 3 Hours Max. Marks: 100
SECTION – A
1. Attempt all parts of the following. Be precise in your answers ( 2 x 10 = 20)

(a) Generate quadruples and triples for the expression : - ( a + b + c) * d / f


(b) What are lexemes and tokens?
(c) What is program structure of LEX ?
(d) Differentiate between LL (k) and LR (k) grammars.
(e) What is abstract syntax tree?
(f) What are synthesized and inherited attributes in formal grammars w.r.t Syntax Directed
Definition?
(g) Write the importance of symbol table in compiler design.
(h) What are data flow equations used in data flow analysis?
(i) Draw the DAG for the following basic block:

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 ;
}

4. Attempt any one part of the following: ( 10 x 1 = 10)

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

5. Attempt any one part of the following: ( 10 x 1 = 10)


(a) What is array reference? Generate three address code of the following expression :
A[ i , j] = B[ i , j] + C[A[ k , l ] ] + D[ i +j ] . Each 2-D array is of 10 x 20 dimensions, width of each
element is w = 2 bytes , lower bound of arrays = 1.

(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 ;}
}

6. Attempt any one part of the following: (10 x 1 = 10)

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

7. Attempt any one part of the following: ( 10 x 1 = 10)

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

You might also like