CD Q-Bank

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Department of CSE (Cyber Security) and AI&DS

Question Bank (2023-24)

Course: Compiler Design (R2031052) (III/I) JNTUK-R20

FACULTY: Mr. P V K KUMAR Format: 9002/0


Unit-I
1 Draw a block diagram of phases of a compiler and indicate the main functions CO1
of each phase.
(a) Define lexeme, token and pattern. Identify the lexemes that make up the
tokens in the following program segment. Indicate corresponding token and
2 pattern. CO1
void swap(int i, int j)
{int t; t=i; i=j; j=t;}
(b) What are the problems that might arise while recognizing the tokens?
3 Define Regular expression. With a suitable translation diagram explain CO1
recognition of keywords and identifiers
4 Explain the three general approaches for the implementation of a Lexical CO1
analyzer.
5 Differentiate between static and dynamic scoping. CO1

Define Regular Expression. Explain procedure for converting FA to RE and


6 CO1
RE to FA.

Unit-II
1 Construct the predictive parser for the following grammar. CO2
S -> (L) | a L ->L,S | S.
(a) Give the classification of parsing techniques and briefly explain each?
Explain Left Recursion and describe the algorithm for eliminating the Left
2 Recursion for the following Grammar CO2
EE+T/T TT*F/F F(E)/id
(b) Show that the grammar S -> 0S1| SS |€ is ambiguous.
What are the limitations of recursive descent parser? What is Left Factoring?
3 Write an algorithm for left factoring a grammar do left factorization for the CO2
following grammar
S iEtS | iEtSeS | a Eb
4 Verify whether the following grammar is LL(1) or not? CO2
E®E+T|T T ® T* F / F F ® (F) |a|b.
5 Design a non-recursive predictive parser for the following grammar. CO2
S -> AaAb | BbBb A -> e B -> e

Unit-III
Consider the following grammar SAS| b ASA|a Construct SLR parsing
1 table for the given grammar and show the actions for the parser for the input CO3
string “abab”.
2 Construct LALR parser for SAA AaA/b and parse the input “aabb” CO3

3 Write the steps for the construction of CLR parsing table. Construct CLR CO3
parser for the following grammar
SL=R | R L*R | id RL

4 Define Type Checker. Write down the specification of a simple Type Checker CO3

5 Write the quadruple, triple, indirect triple for the expression. CO3
-(a*b)+(c+d)-(a+b+c+d)
Give the syntax directed definition for a desk-calculator.
6 Explain in detail how an L-attributed grammar can be converted into a CO3
translation scheme.
7. Explain about Three-address code generation with its implementation. CO3

Implement the following expressions by using Quadruples, Triples and


8. Indirect triples CO3
(i) a+a*(b-c)+(b-c)*d (ii)-b+(b*b-4*a*c)/2*a
iii) While(A<B) do if (C<D) then X=Y+Z

Unit-IV
1 How symbol table can be managed? Explain CO4

2 Discuss storage allocation for block structured languages. CO4

Construct basic blocks, data flow graph and identify loop invariant
statements for the following.
for (i=1 to n)
3 { j=1; CO4
while (j<=n)
{ A=B*C/D;j=j+1;
}}
4 What is Peephole optimization? Explain its characteristics. CO4

5 Explain with an example optimization of Basic blocks. CO4

Unit-V
1 Explain in detail about inter procedural optimization with an example. CO5

2 Explain in detail about the instruction scheduling with an example. CO5

3 What are the principle sources of optimization? Give the classification CO5
of code Optimization.
4 Explain the role of semantic preserving transformations and CO5
dominators in code optimization.
5 Explain with suitable example various sources of loop optimization CO5
and dominators in code Optimization.

Faculty HOD

You might also like