You are on page 1of 6

SAL EDUCATION CAMPUS

SAL INSTITUTE OF TECHNOLOGY AND


ENGINEERING RESEARCH

COMPUTER ENGINEERING DEPARTMENT

3170701 COMPILER DESIGN

Question Bank
Year: 2023-2024
UNIT-1(CO-1)

Sr. Question Marks


No.
1 What is the difference between compiler and interpreter? 3
2 Explain analysis phase of the source program with example 4
3 What is a pass in a compiler? What is the effect of reducing the 3
number of passes?
4 Explain buffer pairs and sentinels. 4
5 Translate the arithmetic expression a*-(b+c) into 1. Syntax tree 2. 3
Postfix notation 3. Three address code
6 List the cousins of compiler and explain the role of any one of them. 3
7 Write a brief note on input buffering techniques. 4
8 Explain front end and back end of compiler in detail. 7
9 Define cross compiler, token and handle. 3
10 Explain phases of compiler with example. 7
11 What is symbol table? For what purpose , compiler uses symbol 3
table? 7
12 Explain various data structures used in symbol table management. 7

UNIT-2(CO-1)
Sr. Question Marks
No.
1 Write an algorithm for Thompson’s construction method. Apply the 7
algorithm to construct NFA for following regular expression.(a | b)*abb.
2 What is operator grammar? Generate precedence function table for 7
following grammar.
E -> EAE | id
A -> + | *
3 Explain role of lexical analyzer 4
4 Construct NFA for following regular expression using Thompson’s 7
notation and then convert it into DFA. (a/b)*abb#
5 Draw transition diagram for relational operators. 4
6 Explain subset construction method with example. 7
7 Draw DFA for the following regular expression using firstpos( ), 7
lastpos ( ) and followpos ( ) functions. ( a | b) * a
8 Construct DFA for following regular expression without constructing 7
NFA and
optimize the same.
( a | ε )* a b ( a | b )* #
9 Construct a DFA without constructing NFA for the following regular 7
expression.
a(a | b )*ab
UNIT-3(CO-2)

Sr. Question Marks


No.
1 Define handle and handle pruning. Explain the stack implementation 7
of shift reduce parser with the help of example.
2 Give the translation scheme that converts infix to postfix notation. 3
Generate the annotated parse tree for input string 3-5+4. 7
3 Check given grammar is LL(1) but not SLR(1). 7
S -> AaAb | BbBa
A -> €
B -> €
4 What is left factoring and left recursion? Explain it with suitable 7
example.
5 Define syntax tree. What is s-attributed definition? Explain 7
construction of syntax tree for the expression a-4+c using SD
Explain parameter passing techniques for procedure. 3
6 4
4
Construct LL(1) parsing table for the following Grammar: 7
E -> E+T | T
T -> T*F | F
F -> (E) | a
OR
Check following grammar is LL (1) or
not? S -> aB | €
B -> bC | €
C -> cS | €
or
S -> aAC | bB
A -> Abc | Abd | e
B -> f | g
C -> h |i
or
S → iEtS | iEtSeS | a
E→ b
8 Define the following terms and give suitable example for it. 3
1) Augmented Grammar 2) LR(0) Item 3) LR(1) Item
9 Differentiate Top Down Parsing and Bottom up parsing 4
10 Construct SLR parsing table for the following grammar : 7
S ->(L)|a
L->L,S|S
or
S -> aAb | bB
A -> Aa | ε
B -> Bb |ε
11 Give the difference between SLR and CLR Parser. 3
12 List the different conflicts that occur in Bottom up parsing and give 4
examples for that.
13 Implement the following grammar using Recursive Descent Parser. 7
S -> Aa | bAc | bBa
A -> d
B -> d
14 What is Ambiguous Grammar? Describe with example. 3
15 Give the difference between synthesized attributes and inherited 4
attributes
16 Construct CLR parsing table for the following grammar : 7
S ->AA
A->aA|b
or
S -> aSA | €
A -> bS | c
17 Give the translation scheme that converts infix to postfix expression 4
for the following grammar and also generate the annotated parse tree
for input string “id+id*id”
E -> E+T |
T T -> T*F |
F
F -> id
18 What is operator grammar? Check the following grammar is 4
operator or not. Justify your answer.
E-> EOE
E-> id
O-> * | + | -
OR
Define operator precedence grammar. Construct precedence matrix and
precedence graph for arithmetic grammar as shown below:
E -> E + T | T
T -> T * F | F
F -> (E) | id
19 Check the following grammar is left recursive or not. Justify your 4
answer. If Left recursive then make grammar as non-left recursive.
S-> ( L ) | a
L-> L , S | S
20 Consider the following grammar and construct the corresponding 3
left most and right most derivations for the sentence abab.
SaSbS | bSaS | ε
21 Find out FIRST and FOLLOW for the following grammar. 4
S->1AB | ε
A-> 1AC | 0C
B-> 0S
C-> 1
22 Develop a syntax directed definition for following grammar. 7
E -> TE’
E’ -> +TE’ | €
T -> ( E )
T -> id
23 Construct the LALR parsing table for the following grammar. 7
S -> CC
C -> aC
C -> d
24 Explain Operator precedence Parsing technique in detail. 7
25 Explain working of non-Recursive Predictive Parser with diagram. 7
26 What do you mean by ambiguous grammar? Show that following is an 7
ambiguous grammar.
E→E+E | E*E | E-E | E/E | (E) | id
UNIT-4(CO-3)

Sr. Question Marks


No.
1 Explain error recovery strategies used by parser. 4
7
2 Explain panic mode recovery strategy 4
1 Write Syntax Directed Definition to produce three address code for the 4
expression containing the operators := , + , - (unary minus), ( ) and id.
2 What is importance of intermediate code? Discuss various 7
representations of three address code using the given expression. a = b
* -c + b * -c . or
a + a * (b- c) + (b – c) * d.
3 Explain Quadruple, triple and indirect triple with suitable example 7
4 What is intermediate code? Explain different types of intermediate 7
coderepresentations. Also discuss importance of intermediate code.
UNIT-5(CO-3)
Sr. Question Marks
No.

1 What is activation record? Explain stack allocation of activation 7


records using example.
2 What is activation tree? 3

3 What is an activation record? Explain how they are used to access local 7
and global variables.
4 Explain activation tree, control stack, the Scope of Declaration and 7
Bindings of Names.
UNIT-6(CO-3)
Sr. Question Marks
No.

1 Explain three loop optimization techniques with example. 7

2 What is code optimization? Explain data flow equation. 4


3 Explain any three code optimization methods 7
4 Describe code generator design issues. 4
5 Define following : DAG, Basic Blocks, Flow graph 7
6 Explain peephole optimization 4
7 List the different issues in code generation phase and describe any two 3
issue
8 Draw syntax tree and DAG for the statement
x=(a+b)*(a+b+c)*(a+b+c+d) 4
Draw a DAG for expression: a + a * (b – c) + (b – c) * d.
Or
d: = b * c
e: = a + b
b: = b * c
a: = e – d
9 Explain dynamic memory allocation strategy. OR 4
Compare: Static v/s Dynamic Memory Allocation.
10 Write difference(s) between stack and heap memory allocation 3
11 Write a grammar to declare variables with data type int or float or char. 7
Also develop a syntax directed definition for that. Draw the
dependency graph for same
12 Discuss various Storage allocation strategies in detail. 7

You might also like