Compiler design 2.O
Compiler design 2.O
A (1st Sem)
COMPILER DESIGN
SHORT QUESTIONS
✓ What are the two types of conflicts in shift reduce parsing? Give example.
✓ ab-c+b-c
✓ What is bootstrapping?
Unit-1
1. (a) Explain the problems faced by a one-pass assembler. Draw and explain the detailed
flowchart for pass-2 of a two-pass assembler.
(b) What are different loading schemes? Explain absolute loader scheme with its advantages
and disadvantages.
2. (a) What are the basic functions of loaders? Differentiate absolute, relative and bootstrap
loader.
(b) State the basic tasks a macro instruction processor performs. Explain how the nested
macro calls are executed with example?
3. (a) Explain the problems faced by a one-pass assembler. Draw and explain the detailed
flowchart for pass-2 of a two-pass assembler.
(b) What are different loading schemes? Explain absolute loader scheme with its advantages
and disadvantages.
(b) What are various loading schemes? Explain bootstrap loader with its merits and demerits.
5. (a) What are the problems faced by a one-pass assembler? Draw and explain the detailed
flowchart for pass-2 of a two-pass assembler.
(b) What is loader? Discuss different loading schemes. Explain reallocating loader scheme
with its advantages and disadvantages.
6. (a) What are the basic functions of loaders? Differentiate absolute, relative and linking
loader.
(b) Discuss the basic tasks a macro instruction processor performs. Explain how the
nested macro calls are executed with example.
Unit-2
1. (a) Differentiate between:
(b) Construct the canonical LR(1) item sets for the following grammar:
S → AA
A → aA/b
2. (a) Compare and contrast SLR with LALR. Define Kernel items and non-kernel items.
s->Aa|bAc | de | bda
A->d
(b) What are the problems with top-down parsing? Write the algorithm to remove left
recursion from a grammar with example.
3. (a) Write an algorithm to convert NFA to DFA and minimize DFA. Discuss with example.
(b) Explain the non-recursive implementation of predictive parsers with the help of grammar.
E -> E+T|T
T -> T * F|F
F -> (E) | i d
4. (a) Generate SLR parsing table for following
grammar:
S → Aa|bAc| Bc |bBa
A -> d
B -> d
(b) What is the role of code Optimizer in compiler? Is it a mandatory phase? Discuss.
S→aAb
A→cd/C
Show that recursive descent parsing fails for input string "acdb", also explain Recursive
Descent Algorithm.
(b) List out the functions of a Lexical Analyzer? State the reasons for the Separation of
Analysis programs into Lexical, Syntax and Semantic Analysis.
Unit-3
1. (a) Explain quadruples and triples with example.
a+a* (b-c)+(b-c) * d
(b). With a neat diagram explain the format of the Symbol Table. And discuss the tree
structures representation of scope information.
2. (a) Explain various data structure used for implementing symbol table and compare them.
(b) What are different intermediate code forms? Discuss different Three Address code types
and implementations of Three Address statements.
a+a * (b - c) +(b-c) * d
4. (a) Construct a syntax directed definition for constructing a syntax tree for assignment
statements.
S→ id : = E
E→ E1+E2
E →E1 * E2
E → E1
E →(E1)
E →id
(b) Give the general structure of activation record. Explain the purpose of each
component.
5. (a) Give the general structure of activation record. Explain the purpose of each component.
(b) What do you mean by attributed grammars? Discuss the translation scheme for converting
an infix expression to its equivalent postfix form.
6. (a) Explain the use of symbol table in compilation process. List out the various attributes
for implementing the symbol table.
(b) Generate the three-address code for the following code fragments:
while (a>b)
{If (c<d)
x=y+z;
else
x=y-z; }
Unit-4
1. (a) Explain the main issues of code generation in detail.
1. Constant propagation
2. Strength reduction.
3. Code Motion
5. (a) Explain various code optimization techniques. Discuss the strategies for loop
optimization and dead code elimination.
b) Explain why next-use information is required for generating object code? Explain the main
issues in code generation.
(b) 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 <10goto B2