0% found this document useful (0 votes)
11 views9 pages

Compiler Design

The document contains important questions related to compiler design, including topics such as symbol tables, activation records, error types, code generation, and optimization techniques. It covers various aspects of syntax-directed translation, intermediate code generation, and data flow analysis. Additionally, it includes numerical examples and tasks related to constructing directed acyclic graphs and generating three-address code.

Uploaded by

Priyanshu Rajput
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)
11 views9 pages

Compiler Design

The document contains important questions related to compiler design, including topics such as symbol tables, activation records, error types, code generation, and optimization techniques. It covers various aspects of syntax-directed translation, intermediate code generation, and data flow analysis. Additionally, it includes numerical examples and tasks related to constructing directed acyclic graphs and generating three-address code.

Uploaded by

Priyanshu Rajput
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/ 9

Click to edit Master title style

COMPILER DESIGN
I M P O R TA N T Q U E S T I O N S ( A K T U )

1
Click to edit Master title UNIT
style - 4

Q1: Define Symbol table ? Explain about the data structures used for symbol table.(M.M.I)
Q2: What is an activation record ? Draw diagram of general activation record and explain the
purpose of different fields of an activation record.(M.M.I)
Q3: Error. Explain lexical , syntax, semantic phase error in detail. And syntactic error? Also suggest
methods for recovery of errors(M.M.I)

[Less Important]

Q4: Difference between stack allocation and heap allocation.


Q5: Distinguish between static scope and dynamic scope. Briefly explain access to non local names
in static scope.
Q6: How do we represent the scope information? Explain scope by number and scope by location.

2 2
Click to edit Master title UNIT
style - 5
Q1: Explain the role of a code generator in a compiler. Discuss its responsibilities and how it translates
intermediate code into the target code.
Q2: Explain in the DAG representation of the basic block with example: + (Numerical) + Example +
Advantages.
(i) Construct a Directed Acyclic graph(DAG) for expression:
1. x = a+b
2. y = c-b
3. z = x*y
(ii) Construct a DAG For Expresssion : p+p*(q-r)+(q-r)*s
(iii) Construct a DAG and write the sequence of instructions for the expression: a+a*(b-c)+(b-c)*d.
(iv) a:=b*-c+b*-c
Q3: Basic Blocks: +(Numerical) + example.
(i) Consider a basic block with the following three instructions.
1. x=a+b
2. y=x*c
3. z=y-d 3 3

Apply common sub expression elimination to optimize basic block.


Click to edit Master title UNIT
style - 5
Q4: Write Short Notes on following with the help of example.
(i) Loop unrolling (ii) Loop Jamming (iii) Loop Optimization (Numerical) (iv) Dead – code
Elimination (v) code motion (vi) Induction variable (vii) Reduction in Strength. (viii) Next use
information
Q5: Flow Graph + (Numerical) + Example
(i) Construct the flow graph for the following code segment:
fact(n)
{
int f = 1;
for(i=2; i<=n ; i++)
f=f*i;
return f;
}
Q6: Global data flow analysis? How does it use in code optimization?
4 4
UNIT - 3
Click to edit Master title style
Q1: Explain the concepts of Quadruples, Triples, and Indirect Triples in the context of Syntax-Directed
Translation. How do they represent intermediate code and support various optimization techniques in
compiler design? + (Numerical)
(i) Write quadruple , triple , Indirected triple for the following expression
(a) (x + y)*(y + z) + (x + y + z)
(b) x=y*z + y*-z
(c) a=-b*(c+d)+b
(d) a = b * – c + b * – c.
Q2: Back patching and sematic rules for Bolean expresion. Generate three address code for the
following Bolean expresion using back patching.
a < b or c > d and e < f
Q3: Syntax directed definition(SDD) + Example + Numerical
(i) Write Syntax directed definition for a given assigment statement : (SDD)
S → id=E
E → E+E
E → E*E
E→ -E
E → (E) 5 5

E→ id
UNIT - 3
Click to edit Master title style
(ii) Consider the following grammar and give the syntax directed definition to construct parse tree for
the input expression 4*7+3*9. Also construct an annotated parse tree according to your syntax directed
definition. E→E+T|T, T→T*F|F, F→num
(iii) Construct an annotated parse tree for the expression (4 * 7 + 1) * 2, using the simple desk calculator
grammar.
Q4: Syntax Direct Translation and Implementation +(Numerical)
(i)What is postfix notations ? translate (C+D)*(E+Y) into postfix using syntax directed translation
scheme(STDS)
Q5: Intermediate code
(i) Write SDD to produce three-address code for Boolean expressions and obtain the three-address
code for the statement given below:
while a < b do
if c < d then
x=y*z
else
6 6
x=y+z
UNIT - 3
(ii) Generate three address code for the following code:
Click
Switch p+q to edit Master title style
{
case 1: x=x+1
case 2: y=y+2
case 3: z=z+3
default: c=c-1
}
(iii) Generate the three-address code for the following code fragment.
while(a > b)
{
if(c < d)
x = y + z;
else
x = y - z;
}
(iv)Generate three address code for C[A[I, j] ] = B[I ,j]+C[A[ I , j ] ]+D[ I + j ] (You can assume any dat
a for solving question , if needed) Assuming that all array elements are integer. Let A and B a 10 X 720 a
7
rray with low1 =low2=1.
UNIT - 3
Click to edit Master title style
Q6: Discuss how induction variables can be detected and eliminated from the given intermediate code
B2: i:= i+1
t1:=4*j
t2:=a[t1]
if t2<10 goto B2
Q7: Syntax Tree(short)

8 8
UNIT - 1
Click to edit Master title style

9 9

You might also like