Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

INSTITUTE OF AERONAUTICAL ENGINEERING

(Autonomous)
Dundigal, Hyderabad - 500 043
COMPUTER SCIENCE ENGINEERING
QUESTION BANK

Course Title COMPILER DESIGN


Course Code ACSB11
Program B.Tech
Semester V CSE
Course Type Core
Regulation IARE-R18
Theory Practical
Course Structure Lecture Tutorials Credits Laboratory Credits
3 1 4 - -
Course Coordinator Mr.U Sivaji, Assistant Professor

COURSE OBJECTIVES:
The students will try to learn:

I The process of translating a high-level language to machine code required for


compiler construction.
II The Software tools and techniques used in compiler construction such as lexical
analyser and parser generators.
III The data structures used in compiler construction such as abstract syntax trees,
symbol tables, three-address code, and stack machines.
IV The deeper insights into the syntax and semantic aspects of programming
languages, dynamic memory allocation and code generation.

COURSE OUTCOMES:
After successful completion of the course, students should be able to:
CO 1 Summarize phases of a compiler in the construction of language Understand
processors.
CO 2 Make use of finite automata for designing a lexical analyzer for a Apply
specific programming language constructs.
CO 3 Choose top down, bottom up parsing methods for developing a Apply
parser with representation of a parse table or tree.
CO 4 Outline syntax directed translations, intermediate forms for Understand
performing semantic analysis along with code generation.
CO 5 Relate symbol table, type checking and storage allocation Understand
strategies used in run-time environment.
CO 6 Select code optimization techniques on intermediate code form for Apply
generating target code.

QUESTION BANK:
Q.No QUESTION Taxonomy How does this subsume CO’s
the level
MODULE I
INTRODUCTION TO COMPILERS
PART A-PROBLEM SOLVING AND CRITICAL THINKING QUESTIONS
1 Consider the following Apply This would require the CO 1
fragment of C code: learner to recall the various
float i, j; phases of compiler and
i = i*70+j+2; explain the task of each
Construct the output at all phase and apply the
phases of the compiler for concepts for the conversion
above C code of the input of each phase
for given expression.
2 Describe the languages Understand This would require the CO 2
denoted by the following learner to recallregular
regular expressions. expressions and explain the
i. (0+1)*0(0+1) languages for given
ii. 0*10*10*10* expression.
3 Explain how LEX program Understand This would require the CO 2
perform lexical analysis to learner to recall software
identify Identifiers, tool such LEX to
Comments, Numerical demonstrate a complete
constants, Keywords, compiler.
Arithmetic operators?
4 For the following expression Apply This would require the CO 1
total = count + rate * 5 learner to recall the various
Construct the output after phases of compiler and
each phase of compiler? explain the task of each
phase and apply the
concepts for the conversion
of the input of each phase
for given expression.

Page 2
5 Convert Regular Expression Understand This would require the CO 1
(b+aa)*a* to Finite learner to recall the finite
Automata. automata,regular
expressions and show the
steps for the conversion of
RE to FA.
6 Explain the DFA that will Understand This would require the CO 2
accept those words from learner to recall the finite
= {a, b} where the automata and show the
P
number of a s is divisible by steps for the writing DFA.
two and the number of b s
is divisible by three. Sketch
the transition table of the
finite automata
7 Convert Regular Expression Understand This would require the CO 2
(11+0)*(00+1)* to NFA. learner to recall the finite
automata, regular
expressions and show the
steps for the conversion of
RE to FA.
8 Convert the following NFA Understand This would require the CO 2
to DFA, as shown in fig. learner to recall the finite
below automata and show the
steps for the conversion of
NFA to DFA.

9 Convert NFA with  to NFA Understand


This would require the CO 2
for the following regular learner to recall the finite
expression a*b*. automata and show the
steps for the conversion of
NFA with  to NFA.
10 Explain Regular Understand This would require the CO 2
Expressions and outline the learner to recall the finite
transition diagrams for automata, regular
different programming Expressions, recognition of
constructs like identifier, tokens and write the RE,
number, relation operators. transition diagrams for
programming constructs.
PART-B LONG ANSWER QUESTIONS

Page 3
1 Define compiler? State Remember - CO 1
various phases of a compiler
and explain them in detail?
2 Explain the various phases Understand This would require the CO 1
of a compiler in detail. Also learner to recall the various
Write down the output for phases of compiler and
the following expression discuss the output of each
after each phase phase for given expression.
x: =a+b*c-d?
3 Explain the cousins of a Understand This would require the CO 1
Compiler? Explain them in learner to recall the
detail. different phases of compiler,
classify the cousins of
compiler.
4 Describe how various phases Remember - CO 1
could be combined as a pass
in compiler?
5 Convert Regular Expression Understand This would require the CO 2
(11+0)*(00+1)* to Finite learner to recall the finite
Automata. automata and show the
steps for the conversion of
NFA to DFA.
6 For the following expression Understand This would require the CO 1
Position:=initial+ learner to recall the various
rate*60,Show the output phases of compiler and
after each phase of demonstrate the output of
compiler? each phase for given
expression.
7 Explain the role and issues Understand This would require the CO 2
of Lexical Analyzer? learner to recall the
different phases of compiler,
classify the cousins of
compiler
8 Define Regular Expression Remember - CO 2
and its properties. Give
examples for Regular
Expressions for given Finite
Automatas.
9 Explain single pass and Understand This would require the CO 1
multi pass compiler with learner to recall the
example? different phases of compiler
classify the cousins of
compiler

Page 4
10 Define bootstrapping Remember - CO 1
concept in brief?
11 Explain the general format Understand This would require the CO 2
of a LEX program with learner to recall software
example? tools such LEX to develop a
complete compiler and
explain with an example.
12 Explain and differentiate Understand This would require the CO 1
frontend and backend of a learner to recall the
compiler different phases of compiler
and discuss frontend and
backend.
13 For the following expression Understand This would require the CO 1
a[index]=4+2 learner to recall the various
Explain output after each phases of compiler and
phase of compiler? demonstrate the output of
each phase for given
expression.
14 Convert NFA for (0 + Understand This would require the CO 2
1)*(00 + 11)(0 + 1)* and learner to recall the finite
Convert to DFA. automata and show the
steps for the conversion of
NFA to DFA.
15 Convert Regular Expression Understand This would require the CO 2
01* + 1 to Finite Automata. learner to recall the finite
automata, regular
expressions and show the
steps for the conversion of
RE to FA.
16 Compare compiler and Understand recall components of a CO 1
interpreter. language processing system
for the convert high level
languages to machine level
languages.
17 Explain the properties of Understand This would require the CO 2
strings and languages. learner to recall the finite
automata and write about
strings and languages.
18 Compare lexical analyzer Understand This would require the CO 1
and syntax analyzer. learner to recall the various
phases of compiler and
discuss the lexical and
syntax analyzers.

Page 5
19 Explain the reasons for Understand This would require the CO 1
separating scanner from learner to recall the various
parser. phases of compiler and
discuss the scanner, parser
20 Compare the pass and phase Understand This would require the CO 1
in compiler construction? learner to recall the
different phases of compiler
classify the cousins of
compiler
PART-C SHORT ANSWER QUESTIONS
1 Name the cousins of Remember - CO 1
compiler?
2 Define the two main parts Remember - CO 1
of compilation? What they
perform?
3 How many phases does Remember - CO 1
analysis phase consists
define it?
4 Define and explain the Remember - CO 1
Loader?
5 Define preprocessor? Remember - CO 1
6 Define the general phases of Remember - CO 1
a compiler?
7 Define lexeme and token? Remember - CO 2
8 Write the issues of lexical Remember - CO 2
analyzer?
9 List some compiler Remember - CO 1
construction tools?
10 Define the term Symbol Remember - CO 1
table?
11 Define the term Interpreter? Remember - CO 1
12 Define an error Handler in Remember - CO 1
compiler?
13 Explain a translator and Understand recall components of a CO 1
types of translator? language processing system
for the convert high level
languages to machine level
languages.
14 Define parser and list its Remember - CO 1
types?

Page 6
15 Explain bootstrap? Understand This would require the CO 1
learner to recall
(knowledge) basic
components of a language
processing system to
construct tokens, lexemes,
different symbols and their
importance and
applicability in
implementing the lexical
analyser
16 Define pass? Remember - CO 1
17 Define phase? Remember - CO 1
18 What is cross compiler? Remember - CO 1
19 Define multi pass compiler? Remember - CO 1
20 Define DFA,NFA,Regular Remember - CO 2
Expressions.
MODULE II
SYNTAX ANALYSIS
PART-A PROBLEM SOLVING AND CRITICAL THINKING QUESTIONS
1 Consider the grammar given Apply This would require the CO 3
below. learner to recall the LR(0)
E → E+T | T , T → T*F | grammar and LR(1)
F ,F→ (E) | id. construct grammar, and demonstrate
LR parsing table for the the rules for given grammar
above grammar .Give the and to construct the LR
moves of LR parser on id * parsing table
id + id?
2 Identify whether the Understand This would require the CO 3
following grammar is LR(0) learner to recall the LR(0)
with reasons? grammar and demonstrate
S → xAy | xBy | xAz , the rules for given grammar
A → as | q , B → q and find out the grammar is
LR(0) or not with specific
reasons.
3 Construct CLR parsing Apply This would require the CO 3
table for the below learner to recall the CLR
grammar? parsing method and
S→ Aa | aAc | Bc |bBa , demonstrate the rules for
A→d, B →d given grammar and to
construct the CLR parsing
table

Page 7
4 Identify whether the Understand This would require the CO 3
following grammar is SLR learner to recall the LR(0)
or not with reasons. grammar and demonstrate
S→ L = R , S→ R , L→ * the rules for given grammar
R , L→ id , R → L. and find out the grammar is
SLR or not with specific
reasons.
5 Identify whether the Understand This would require the CO 3
following grammar is CLR learner to recall the LR(1)
or not with reasons? grammar and demonstrate
S→ AA , A →aA | b the rules for given grammar
and find out the grammar is
CLR(1) or not with specific
reasons.
6 Construct SLR parsing Apply This would require the CO 3
table for the below learner to recall the LR(0)
grammar? grammar and demonstrate
E → E+T |T T → T*F | F the rules for given grammar
F→ (E) |id. and to construct the SLR
parsing table.
7 The following grammar for Understand This would require the CO 3
if-then-else statements is learner to recall bottom up
proposed to remedy the parsing technique and
dangling-else ambiguity: explain the procedure to
Stmt → if Expr then Stmt | handle the ambiguous
if Expr then Stmt else Stmt grammar.
| other
Show that how shift and
reduce conflicts can be
handled in ambiguous
grammar.
8 Construct LALR (1) Apply This would require the CO 3
Parsing table for following learner to recall the LR(1)
grammar? grammar and demonstrate
S → Aa |aAc | Bc |bBa , A the rules for given grammar
→d , B →d and to construct the
LALR parsing table

Page 8
9 Consider the grammar Apply This would require the CO 3
S→ aSbS | bSaS|  learner to recall context
a) Construct the free grammars and explain
corresponding leftmost the procedure to construct
derivation and rightmost derivations.
derivation For abab.
b) Construct the
corresponding parse trees
for abab and identify
whether the grammar is
ambiguous or not.
10 Construct the FIRST and Apply This would require the CO 3
FOLLOW sets for following learner to recall the top
grammar down parsing methods and
S→ aBDh , B → cC , C → demonstrate the rules for
bC /  , D → EF , E → g / given grammar and to
,F→f/ construct the FIRST and
FOLLOW.
PART-B LONG ANSWER QUESTIONS
1 List the FIRST and Remember - CO 3
FOLLOW sets for following
grammar? S → ACB / CbB
/ Ba, A → da / BC, B → g
/ , C → h / 
2 Explain the common Understand This would require the CO 3
conflicts that can be learner to recall bottom
encountered in a up parsing technique and
shift-reduce parser? explain the common
conflicts encountered in
shift reduce parser and also
explain the conflicts with
suitable grammar.
3 Explain handle pruning in Understand This would require the CO 3
detail with example? learner to recall bottom
up parsing technique and
explain the term handle
pruning with example
grammar

Page 9
4 Consider the grammar Understand This would require the CO 3
E → E + E | E *E | (E) | id learner to recall bottom up
Show the sequence of moves parsing technique and
made by the shift-reduce explain the acceptance of
parser on the input the string
(id1+id2)*id3 and
determine whether the given
string is accepted by the
parser or not
5 Explain the role of stack in Understand This would require the CO 3
shift reduce parsing learner to recall bottom up
method? parsing technique and
explain role of stake in
shift reduce parsing method.
6 Explain YACC-automatic Understand This would require the CO 3
parser generator. learner to recall context
free grammar and explain
how CFG is represented in
YACC
7 State the difference between Remember - CO 3
SLR,CLR and LALR
parsers in detail?
8 Explain briefly about panic Remember - CO 3
mode and phrase level error
recovery techniques?
9 Explain how to handle the Understand This would require the CO 3
error in ambiguous learner to recall context
grammar with example? free grammar and explain
how to handle error in
ambiguous grammar with
example grammar.
10 Outline the LR Parsing Understand This would require the CO 3
model and write the LR learner to recall bottom up
parsing algorithm for parsing technique and
constructing the parsing explain the components in
table? the LR parsing diagram.
11 Consider the grammar Remember - CO 3
P→ E, E → E+T, E→T,
T→ id(E) T→id And, state
whether the following
grammar is LR(0) or not?

Page 10
12 Write shift reduce parsing Understand This would require the CO 3
algorithm and show shift learner to recall bottom up
and reduce moves with an parsing technique and
example? explain the shift reduce
parsing method.
13 Explain the following terms Understand This would require the CO 3
i)Canonical collection of learner to recall bottom up
items ii) Augmented parsing technique and
Grammar iii) Closure and explainoperations
go to Operation performed on LR parsing
techniques such as
Augmented grammar,
closure and goto operations
along with LR(0) items.
14 Consider the grammar Remember - CO 3
P→ E, E → E+T, E→ T
T→id (E) T→ id
And, State whether the
following grammar is
SLR(1) or not?
15 Outline the CLR Parsing Understand This would require the CO 3
model and write the CLR learner to recall bottom
parsing algorithm for up parsing technique and
constructing the parsing explain the steps in
table? algorithm for the
construction of CLR parsing
tabl
16 Explain the SLR(1) parsing Understand This would require the CO 3
table for the following learner to recall bottom
grammar S→ Aa | up parsing technique and
bAc|dc|bd , A→d explain the steps in
algorithm for the
construction of SLR parsing
table
17 Compare LR parsers in Understand TThis would require the CO 3
detail? learner to recall bottom
up parsing technique and
compare the LR parsing
methods.
18 Consider the grammar Understand This would require the CO 3
S→ AS| b, A → SA| a learner to recall bottom
Explain the collection of up parsing technique and
sets of LR(0) items for this explain the steps in
grammar? algorithm for writing the
LR items

Page 11
19 Show that the following Understand This would require the CO 3
grammar learner to recall bottom up
S→ AaAb | BbBa parsing technique and
A→ explain the steps in
B→ algorithm for the
is SLR(1) or not? construction of SLR parsing
table and specify is SLR or
not.

20 Consider the grammar Understand This would require the CO 3


bexpr→bexpr or bterm | learner to recall bottom
btermbterm→bterm and up parsing technique and
bfactor | bfactor explain the procedure to
bfactor→notbfactor | check the grammar is CLR
(bexpr) |true | false. or not.
Explain whether the
grammar is CLR or not?
PART-C SHORT ANSWER QUESTIONS
1 Define about FIRST and Remember - CO 3
state its rules?
2 Define about FOLLOW and Remember - CO 3
state its rules?
3 Define LR(0) items in Remember - CO 3
bottom up parsing?
4 What LR(k) parsing stands Remember - CO 3
for?
5 List types of bottom up Remember - CO 3
parsing techniques?
6 Define goto function and Remember - CO 3
closure function in LR
parser?
7 Why SLR and LALR are Remember - CO 3
more economical to
construct Canonical LR?
8 Tell about handle pruning? Remember - CO 3
9 What are error recovery Remember - CO 3
types?
10 List down the conflicts Remember - CO 3
during shift-reduce parsing.
11 List out the types LR(0) Remember - CO 3
and LR(1) parsers?

Page 12
12 Describe about shift reduce Understand This would require the CO 3
parsing?. learner to recall bottom up
parsing technique and
explain basic idea of shift
reduce parsing.
13 Define YACC parser? Remember CO 3
14 Compare CLR and LALR? Understand This would require the CO 3
learner to recall bottom up
parsing technique and
compare between two
bottom up parsing
techniques CLR and LALR
15 Define an augmented Remember - CO 3
grammar?
16 Define shift action? Remember - CO 3
17 Define Reduce action?. Remember - CO 3
18 Is left recursion elimination Understand This would require the CO 3
is required in bottom up learner to recall bottom up
parsing ?justify. parsing technique and
explain the left recursion
and then justify whether
left recursion elimination is
required for bottom up
parsing or not.
19 List out differences between Remember - CO 3
LL and LR parsers?
20 List out the operations of Remember - CO 3
shift reduce parsing?
MODULE III
SYNTAX-DIRECTED TRANSLATION AND INTERMEDIATE CODE GENERATION
PART A-PROBLEM SOLVING AND CRITICAL THINKING QUESTIONS
1 Construct production rules Apply This would require the CO 4
and semantic actions for learner to recall
S-attributed grammar for Syntax-Directed Translation
the following grammar and explain the rules for the
along with syntax tree and conversions and Construct
annotated parse tree for the the S-attributed grammar.
given string a*b-c/d+e?
L→E
E→ E+T | E-T|T
T→ T*F | T/F |F
F→ P-F | P
P→(E)
P→ID

Page 13
2 Construct production rules Apply This would require the CO 4
and semantic actions for the learner to recall
following grammar along Syntax-Directed Translation
with annotated parse tree and explain the rules for
for the string 9-5+4? the conversions and
expr→ expr + term Construct the parse tree.
| expr – term | term
term→0|1|2|3|4|5|6|7|8|9
3 Construct production rules Apply This would require the CO 4
and semantic actions for the learner to recall
following grammar along Syntax-Directed Translation
with annotated parse tree and explain the rules for
for the expression: “int a, b, the conversions and
c”? Construct the parse tree.
D →T L
T →int
T → float; L→ L1,id L → id
4 Construct production rules Apply This would require the CO 4
and semantic actions for the learner to recall
following grammar along Syntax-Directed Translation
with annotated parse tree and explain the rules for
for the string (3+4)*(5+6)? the conversions and
L→E Construct the parse tree
E→ T E→E1+T
T→ F T→ T1*F F→ (E)
F→ digit
5 Construct production rules Apply This would require the CO 4
and semantic actions for the learner to recall
following grammar along Syntax-Directed Translation
with annotated parse tree and explain the rules for
for the string a- 4+c? the conversions and
E→E1+T Construct the parse tree
E→E1-T
E→T T→(E)
T→id
T→ num
6 Construct the three address Apply This would require the CO 4
code and draw the abstract recall Intermediate Code
tree for the following Generation and explain the
expressions? concepts to construct the
a) (x-y)*z+m-n three address code.
b) a+(b-c)+(b+c)*(a*e)

Page 14
7 Construct the three-address Apply This would require the CO 4
code for the following C recall Intermediate Code
program fragment? Generation and explain the
while(a >b) concepts to construct the
{ three address code.
if (c <d) x = y +z;
else
x = y -z;
}
8 Construct triples, Indirect Apply This would require the CO 4
and quadruples of an recall Intermediate Code
expression: Generation and explain the
a = b * - c + b * - c? concepts to construct the
triples, Indirect and
quadruples.
9 Construct triples, Indirect Apply This would require the CO 4
and quadruples of an recall Intermediate Code
expression : Generation and explain the
x = ( a + b )* - c/d? concepts to construct the
triples, Indirect and
quadruples.
10 Why are quadruples Remember – CO 4
preferred over triples in an
optimizing compiler with
example?
PART-B LONG ANSWER QUESTIONS
1 Explain briefly about syntax Understand This would require the CO 4
directed definition and it learner to recall
types? Syntax-Directed Translation
and explain the types of
SDD
2 Explain briefly about Understand This would require the CO 4
Synthesized and Inherited learner to recall
attribute in detail? Syntax-Directed Translation
and explain the attributes.
3 Define translation scheme Remember - CO 4
and write for a<b or b >c?
4 Explain briefly about Understand This would require the CO 4
S-attributed and L- learner to recall
attributed grammar in Syntax-Directed Translation
detail? and explain the attributes.

Page 15
5 Explain how declaration is Understand This would require the CO 4
done in a procedure using learner to recall
syntax directed translation? Syntax-Directed Translation
and explain the SDT for
procedure.
6 Explain briefly about Understand This would require the CO 4
postfix Translation Scheme? learner to recall
Syntax-Directed Translation
and explain the postfix
Translation Scheme
7 Describe the method of Remember - CO 4
generating syntax directed
definition for control
Statements?
8 Show SDT for the simple Understand This would require the CO 4
assignment statement with learner to recall
example? Syntax-Directed Translation
and explain the SDT for
simple assignment
statement
9 Explain the construction Understand This would require the CO 4
steps and construct the learner to recall
syntax tree for expression Syntax-Directed Translation
using functions? and explain the types of
(m * n + p) + ( m – n + three address code.
p)?
10 Explain briefly syntax Understand This would require the CO 4
directed translation into learner to recall
three address code with Syntax-Directed Translation
suitable example? and explain the conversion
of SDT to three address
code.
11 Explain three address codes Understand This would require the CO 4
and mention its types. How learner to recall
would you implement the Intermediate Code
three address statements? Generation and explain the
Explain with suitable three address code forms.
examples?

Page 16
12 Explain with an example to Understand This would require the CO 4
generate the intermediate learner to recall
code for the flow of control Intermediate Code
statements? Generation and explain the
generation of intermediate
code for the flow of control
statements.
13 Explain about Quadruple Understand This would require the CO 4
and Triple with its learner to recall
structure? Intermediate Code
Generation and explainthe
quadruple and triple.
14 Define and represent the Remember - CO 4
Triple, indirect triple and
quadruple for the
assignment statement?
x:= -b + d * -b+d
15 Translate the arithmetic Understand This would require the CO 4
expression a* - (b+c) into learner to recall
a) A syntax tree Intermediate Code
b) Postfix notation ? Generation and explain the
arithmetic expression
translation into syntax tree
and Postfix notation .
16 Translate the expression – Understand This would require the CO 4
(a + b) * (c + d) + ( a + b learner to recall
+c) into Intermediate Code
a) quadruples Generation and explain the
b) triples arithmetic expression
translation into triple,
indirect triple and
quadruple.
17 Show translation scheme for Understand This would require the CO 4
Boolean Expressions with learner to recall
example? Intermediate Code
Generation and explain the
Boolean Expression
translation scheme.
18 Show translation scheme for Understand This would require the CO 4
Control Flow with example? learner to recall
Intermediate Code
Generation and explain the
Control Flow.

Page 17
19 Translate the expression – Understand This would require the CO 4
(a + b) * (c + d) + ( a + b learner to recall
+c) into Intermediate Code
a) triples Generation and explain the
b) indirect triples. arithmetic expression
translation into triple,
indirect triple.
20 Explain the three address Understand This would require the CO 4
code and draw the abstract recall Intermediate Code
tree for the following Generation and explain the
expressions? three address code.
(a-b)*c+m-n
PART-C SHORT ANSWER QUESTIONS
1 What is the usage of syntax Remember - CO 4
directed definition?
2 Define Attribute Grammar? Remember - CO 4
3 List the types of Attribute Remember - CO 4
Grammar?
4 Explain syntax directed Understand This would require the CO 4
translation? learner to recall
Syntax-Directed Translation
and explain the
translations.
5 Compare synthesized and Understand This would require the CO 4
inherited attributes? learner to recall
Syntax-Directed Translation
and explain the synthesized
and inherited attributes.
6 Define L attributed Remember - CO 4
grammar?
7 Define S attribute Remember - CO 4
grammar?
8 show the Syntax tree for Remember - CO 4
Expression using functions?
(a + b) * ( b - c)
9 Explain the functions to Understand This would require the CO 4
create nodes of Syntax tree learner to recall
for expression? Syntax-Directed Translation
and explain the nodes of
Syntax tree.
10 Define syntax tree? Draw Remember - CO 4
the syntax tree for the
assignment statement?
a :=b * -c + b * -c.

Page 18
11 Define Translation schemes? Remember - CO 4
12 Define Annotated Parse Remember - CO 4
Tree?
13 Explain the three kinds of Understand This would require the CO 4
intermediate representation? learner to recall
Intermediate Code
Generation and explain the
intermediate forms
14 What are the benefits of Remember - CO 4
using machine-independent
intermediate form?
15 What is postfix notation? Remember - CO 4
16 How can you generate Remember - CO 4
three-address code?
17 Translate x+y-(a*b)+c into Understand This would require the CO 4
three address code? learner to recall
Intermediate Code
Generation and convert to
the three address code form.
18 Discuss back-end and Understand This would require the CO 4
front-end? learner to recall phases of a
compiler and explain the
back-end and front-end.
19 Define abstract syntax tree? Remember - CO 4
20 List out types of three Remember - CO 4
address code?
MODULE IV
TYPE CHECKING AND RUN TIME ENVIRONMENT
PART A- PROBLEM SOLVING AND CRITICAL THINKING QUESTIONS
1 Suppose that the type of Understand This would require the CO 5
each identifier is a sub range learner to recall type
of integers, for expressions checking explain how type
with operators +, -, *, div checking rules implemented
and mod, as in Pascal. for each type of identifier
Explain type- checking rules
that assign to each sub
expression the sub range its
value must lie in?
2 Explain briefly about Understand This would require the CO 5
Source language issues? learner to recall type
checking explain about
Source language issues

Page 19
3 Explain briefly about Understand
This would require the CO 5
Activation record with block learner to recall run time
diagram? environment explain the
Activation record with block
diagram
4 Discuss about variable Understand This would require the CO 5
length data on stack with learner to recall run time
neat diagram? environment explain the
variable length data on
stack
5 Explain briefly about heap Understand This would require the CO 5
storage allocation with learner to recall run time
block diagram? environment explain the
heap storage allocation
6 Explain briefly about stack Understand This would require the CO 5
storage allocation with learner to recall run time
block diagram? environment explain the
stack storage allocation
7 Explain briefly about Understand This would require the CO 5
language facilities for learner to recall run time
dynamic storage allocation? environment explain the
language facilities for
dynamic storage allocation
8 Describe the parameter Understand This would require the CO 5
passing methods with learner to recall run time
examples? environment explain the
various parameter passing
methods.
9 Explain Over loading of Understand This would require the CO 5
Operators and Functions learner to recall run time
with examples? environment explain the
Over loading of Operators
and Functions
10 Differentiate the call by Understand This would require the CO 5
reference and call by copy learner to recall run time
restore with examples? environment explain the
call by reference and call by
copy restore.
PART-B LONG ANSWER QUESTIONS
1 Explain the specification of Understand This would require the CO 5
a simple type checker learner to recall type
checking and explain the
specification of a simple
type checker

Page 20
2 Define a type expression? Remember — CO 5
Explain the equivalence of
type expressions with an
appropriate example?
3 Explain about reusing the Understand This would require the CO 5
storage space for names? learner to recall Run Time
Environment and explain
the procedure for using
storage space efficiently.
4 Discuss about all allocation Understand This would require the CO 5
strategies in run-time learner to recall Run Time
storage environment? Environment and explain
the allocation strategies.
5 Explain the data structures Understand This would require the CO 5
used for implementing learner to recall Run Time
Symbol Table? Environment and explain
the Symbol Table
implementation
6 Explain Static and Dynamic Understand This would require the CO 5
Checking of types with learner to recall type
examples? checking and explain the
Static and Dynamic
Checking
7 Compare the call by value Understand This would require the CO 5
and call by name with learner to recall Run Time
examples? Environment and compare
the call by value and by
name
8 Distinguish between static Understand This would require the CO 5
and dynamic storage learner to recall Run
allocation? Time Environment and
explain the Static and
Dynamic storage allocation
9 Explain the type checking of Understand This would require the CO 5
expressions? learner to recall type
checking and explain the
procedure for expressions
10 Explain storage Understand This would require the CO 5
organization in runtime learner to recall Run Time
environment? Environment and explain
the storage organization

Page 21
11 Explain the types of storage Understand This would require the CO 5
allocations? learner to recall Run Time
Environment and explain
the storage allocations types
12 Describe the name and Understand This would require the CO 5
structure equivalence in learner to recall type
type expressions? checking and explain the
name and structure
equivalence in type
expressions
13 Explain the type checking of Understand This would require the CO 5
control flow statements? learner to recall type
checking and explain the
steps for control flow
statements
14 Explain briefly about Understand This would require the CO 5
storage allocation learner to recall Run Time
strategies? Environment and explain
the storage allocations
strategies
15 Describe the basic Understand This would require the CO 5
implementation techniques learner to recall Run Time
for symbol table? Environment and explain
the symbol table
implementation
16 Explain the calling Understand This would require the CO 5
sequences of activation learner to recall Run Time
record? Environment and explain
the calling sequences.
17 Differentiate ordered, Understand This would require the CO 5
unordered and binary search learner to the recall Run
tree in symbol table? Time Environment and
explain binary search tree
in symbol table
18 Explain briefly about static Understand This would require the CO 5
storage allocation with learner to recall Run Time
block diagram? Environment and explain
the static storage allocation
19 Differentiate explicit and Understand This would require the CO 5
implicit allocation of learner to recall Run Time
memory to variables? Environment and compare
the allocation types of
memory to variables

Page 22
20 Differentiate stack and heap Understand
This would require the CO 5
storage allocation learner to recall Run Time
strategies? Environment and explain
the stack and heap storage
allocation strategies.
PART-C SHORT ANSWER QUESTIONS
1 List different data Remember — CO 5
structures used for symbol
table?
2 Define Type checking? Remember — CO 5
3 List the different types of Remember — CO 5
type checking?
4 Define Type Expression? Remember — CO 5
5 Explain about the type Understand This would require the CO 5
systems? learner to recall type
checking and explain the
type systems
6 Show the Translation Remember — CO 5
scheme for checking the
type of Assignment
statement S− >id:=E
7 Explain Dynamic type Understand This would require the CO 5
checking? learner to recall type
checking and explain the
Dynamic type checking
8 Define Structural Remember — CO 5
Equivalence?
9 What is the Strongly typed Remember — CO 5
language?
10 Define Type error? Remember — CO 5
11 Write a short note on static Understand This would require the CO9
type checking? learner to recall type
checking and explainthe
static type checking
12 Show the Translation Remember — CO 5
scheme for checking the type
of Conditional statement -
S− >if E then S1
13 Show the Translation Remember — CO 5
scheme for checking the
type of while statement
S− >While E do S1
14 Define Type conversion? Remember — CO 5

Page 23
15 List the types of type Remember — CO 5
conversion?
16 Write about general Understand This would require the CO 5
activation record? learner to recall Run Time
Environment and explain
the general activation
record.
17 Define Symbol table? Remember — CO 5
18 Define Dynamic storage Remember — CO 5
allocation?
19 Write short note on Understand This would require the CO 5
procedures? learner to recall Run Time
Environment and explain
the procedures
20 Define Activation tree? Remember — CO 5
21 Define stack storage Remember — CO 5
allocation
22 Define static storage Remember — CO 5
allocation?
23 Define heap storage Remember — CO 5
allocation?
24 Write a short note on UnderstandThis would require the CO 5
parameter passing? learner to recall Run Time
Environment and explain
the parameter passing
25 Define Control stack? Remember — CO 5
MODULE V
CODE OPTIMIZATION AND CODE GENERATION
PART A-PROBLEM SOLVING AND CRITICAL THINKING QUESTIONS)
1 Construct the code sequence Apply This would require the CO 6
generated by the simple learner to recall code
code generation algorithm generation and explain the
for x*y+(m-k)-(g+b) procedure to Construct
the code sequence.
2 Construct target code for Apply This would require the CO 6
the given program segments: learner to recall code
main() generation and explain the
{ procedure to Construct
int i=4,j; j = i + 5; the target code.
}

Page 24
3 Consider the following basic Apply This would require the CO 6
block of 3-address learner to recall code
instructions .Construct generation and explain the
target code for the source procedure to Construct
language statement and the target code.
finds its cost.
a := b + c x := a + b
b := a- d c := b + c
d := a -d y := a -d
4 Identify the register Apply This would require the CO 6
descriptor target code for learner to recall code
the source language generation and explain the
Statement and its cost. procedure to Construct
(a-b) + (a-c) + (a-c) the target code.
5 Consider the following part Apply This would require the CO 6
of code. learner to recall code
int main() generation and explain the
{ int n,k=0; procedure to Construct
scanf(%d,&n); the basic blocks.
for(i=2;i<n;i++) {
if(n%I),==0)break; } k=1;
if(i==n)
printf(number is prime);
else
printf(number is not
printed); }
Identify the basic block in
the given program
6 Construct the DAG for the Apply This would require the CO 6
following basic block. learner to recall code
D:=B*C generation and explain the
E:=A+B procedure to Construct
B:=B+C A:=E-D the DAG.

Page 25
7 Construct basic block for Apply This would require the CO 6
following code learner to recall code
void quicksort(m, n) generation and explain the
int m, n; procedure to Construct
{ int i, j; if (n <= m ) the basic blocks.
return; /* fragment begins
here */ i = m-1;
j = n;
v = a[n]; while(1)
{
do
i = i+1;
while( a[i] <v);
do
j = j-1;
while( a[j] >v ); if( i >= j )
break;
x = a[i];
a[i] = a[j];
a[j] =x; }
x = a[i]; a[i] = a[n];
a[n]= x; /* fragment ends
here */
quicksort(m, j);
quicksort(i+1, n);

8 Construct DAG and explain Apply This would require the CO 6
the procedure for the learner to recall code
conversion. generation and explain the
a+b*(a+b)+c+d procedure to Construct
the DAG.
9 Explain role of DAG Understand This would require the CO 6
representation in learner to recall code
optimization with example? generation and explain the
DAG and its role in
optimization.

Page 26
10 Construct the basic block Apply This would require the CO 6
and flow graph for the learner to recall code
following code generation and explain the
begin procedure to Construct
prod :=0; i:=1; the basic blocks.
do begin
prod :=prod+ a[i] * b[i];
i :=i+1;
end
while i <= 20 end

11 Construct optimal machine Apply This would require the CO 6


code for the following C learner to recall code
program. generation and explain the
main() { inti,a[10]; procedure to Construct
while(i<=10) the optimal machine code.
a[i]=0;
}
PART-B LONG ANSWER QUESTIONS
1 Explain the concept of Understand This would require the CO 6
Function-Preserving learner to recall code
Transformations? optimization and Explain
the transformations.
2 Explain Machine dependent Understand This would require the CO 6
code optimization in detail learner to recall code
with an example? optimization and Explain
the Machine dependent code
optimization.
3 Write about target code Understand This would require the CO 6
forms and Explain how the learner to recall code
instruction forms effect the optimization and Explain
computation time? the how the instruction
forms effect the
computation time
4 Explain about machine Understand This would require the CO 6
dependent and machine learner to recall code
independent optimization? optimization and Explain
the machine dependent and
machine independent
optimization

Page 27
5 Explain the role of code Understand This would require the CO 6
generator in a compiler? learner to recall code
generation and explain the
code generator in a
compiler.
6 Explain in detail the issues Understand This would require the CO 6
in the design of code learner to recall code
generator? generation and explain the
issues in the design of code
generator
7 Explain the instructions and Understand This would require the CO 6
address modes of the target learner to recall code
machine? generation and explain the
instructions and address
modes of the target machine
8 Explain the principle Understand This would require the CO 6
sources of code optimization learner to recall code
in detail? optimization and Explain
the sources of code
optimization
9 Explain the primary Understand This would require the CO 6
structure preserving learner to recall code
transformations on basic optimization and Explain
blocks? the structure preserving
transformations
10 Explain peephole Understand This would require the CO 6
optimization in detail? learner to recall code
optimization and Explain
the peephole optimization
11 Define the following Remember — CO 6
i. Copy propagation
ii. Dead code elimination
12 Explain in the DAG Understand This would require the CO 6
representation of the basic learner to recall DAG and
block with example? Explain the representation
of the basic blocks
13 Explain loop optimization Understand This would require the CO 6
in detail with example? learner to recall code
optimization and Explain
the loop optimizations
14 Explain various Global Understand This would require the CO 6
optimization techniques in learner to recall code
detail? optimization and Explain
the global optimizations

Page 28
15 Explain Loops in flow graph Understand This would require the CO 6
in detail with example? learner to recall code
optimization and Explain
the flow graphs
16 Explain Local optimization Understand This would require the CO 6
in detail with example? learner to recall code
optimization and Explain
the local optimization
17 Explain Understand This would require the CO 6
Redundant-instructions learner to recall code
elimination and optimization and Explain
Flow-of-control optimizations.
Optimizations?
18 Explain the simple code Understand This would require the CO 6
generator with a suitable learner to recall code
example? generation and explain the
simple example for code
generator.
19 Explain the procedure to Understand This would require the CO 6
detect induction variable learner to recall code
and dead code elimination optimization and Explain
with example? optimizations.
20 Explain briefly about Understand This would require the CO 6
register allocation and learner to recall code
assignment? generation and explain the
register allocation.
PART-C SHORT ANSWER QUESTIONS
1 List the principle sources of Remember — CO 6
optimization?
2 Define the 3 areas of code Remember — CO 6
optimization?
3 Explain the techniques used Understand This would require the CO 6
for loop optimization and learner to recall code
Reduction in strength? optimization and Explain
the loop optimization
methods.
4 Define constant folding? Remember — CO 6
5 Define Common Sub Remember — CO 6
expressions?
6 Explain Dead Code? Understand This would require the CO 6
learner to recall code
optimization and Explain
the concept of dead code.
7 Define local optimization? Remember — CO 6

Page 29
8 What is Register allocation Remember — CO 6
and assignment?
9 Define flow graph and basic Remember — CO 6
block?
10 Explain about inner loops? Understand This would require the CO 6
learner to recall code
optimization and Explain
the flow graph
representation to find the
inner loops.
11 Define a DAG? Mention its Remember — CO 6
Remember?
12 Define peephole Remember — CO 6
optimization?
13 Define the machine Remember — CO 6
instructions for operations
and copy statement?
14 Explain global data flow? Understand This would require the CO 6
learner to recall code
optimization and Explain
the global data flow.
15 Explain about live variable Understand This would require the CO 6
analysis? learner to recall code
optimization and Explain
the live variable analysis.
16 Define the term copy Remember — CO 6
propagation?
17 Define the term Code Remember — CO 6
motion?
18 What is induction variable? Remember — CO 6
19 How do you calculate the Remember — CO 6
cost of an instruction?
20 What is the Unreachable Remember — CO 6
Code?

PREPARED BY: HOD CSE


Mr.U Sivaj Assistant Professor

Page 30

You might also like