CD Question Bank
CD Question Bank
1. a) Discuss the phases of a compiler indicating the inputs and outputs of each phase in
translating the statement “a=p+r*36.0”. [7M]
b) Discuss about the role of lexical analyzer. Explain with program. [7M]
2. a) Explain the boot strapping process with suitable examples and diagrams. [7M]
b) Construct an FA equivalent to the regular expression (0+1)*(00+11)(0+1)* [7M]
3. a) Explain various building blocks used to design a language translator. [7M]
b) Differentiate between
i) Phase and a pass ii) single-pass and multi-pass compiler. [7M]
4. a) Explain about input buffering schemes in lexical analysis. [7M]
b) Write a regular expression for identifiers and reserved words. Design the transition
diagrams for them. [7M]
5. a) Explain how lex program will perform the lexical analysis for the [7M]
following patterns in C: Identifiers, comments, numerical constants and arithmetic
operators.
b) Construct NFA equivalent to regular expression r= (a + b)* ab [7M]
(aa+bb) and convert it into DFA.
6. a) Explain various data structures used in lexical analysis. [7M]
b) Write a Regular Expression for identifier, reserved words & relation operators. [7M]
Design a transition diagram for each of them.
7. a ) Write about tokens generated by lexical analyzers. Describe the lexical errors [7M]
and various error recovery strategies with suitable examples.
b) Define Regular Expression. Explain the properties of Regular Expressions. [7M]
Discuss with suitable examples.
8. a) What is LEX? Discuss the usage of LEX in Lexical Analyzer generation. [7M]
b) Construct a Finite Automata and Scanning algorithm for recognizing [7M]
identifiers, numerical constants in C language.
9. a) Describe the need and functionality of linkers, assemblers and loaders. [7M]
b) State the steps to convert a regular expression to NFA. Explain with an [7M]
example.
10. a) How to generate object code for X=Y+Z*15 through different [10M]
phases of compiler?
b) Construct a Finite Automaton for the Regular Expression [4M]
(00+11)*010*10.
11. a) Define lexeme, token and pattern. Identify the lexemes that [7M]
make up the tokens in the following program segment. Indicate
corresponding token and pattern. void swap(inti, int j) { int t;
t=i; i=j; j=t; }
b) Write regular expressions for the following languages: Explain [7M]
operations on Regular expressions.
i) All strings over the English alphabet that contain the five
vowels in order.
ii) All strings of a’s and b’s that do not contain the subsequence
abb.
12. a) How to generate object code for X=Y+Z*15 through different [10M]
phases of compiler?
b) Construct a Finite Automaton for the Regular Expression [4M]
(00+11)*010*10.
UNIT-2
1. a) Define Context Free Grammar. Explain how it is suitable for parsing? Explain [7M]
S → AaAb | BbBb
A→e
two different left-most derivations with the help of parse trees for the string
3. a) What are the preprocessing steps required for constructing Predictive parsing [7M]
the Predictive parsing table for the grammar G: E → E+T |T, E →T*F |F, F →
4. a) What is an LL(1) grammar? Can you convert every context free grammar into [7M]
LL(1). How to check the grammar is LL(1) or not? Explain the rules,
E → T + E|T
T→V*T|V
V → id
Write down the procedures for the non-terminals of the grammar to make a
S → S S + \ S S * \ a.
b) Write about various types of top down parsing. Discuss about the error recover
E → E + T/T
T → T *F/F
F → F /a/b
E→E+T|T
T → T* F / F
F → (F) |a|b.
A d B d.
two different left-most derivations with the help of parse trees for the string
10. a) What are the preprocessing steps required for constructing Predictive parsing [7M]
the Predictive parsing table for the grammar G: E → E+T |T, E →T*F |F, F →
UNIT-3
1. a) Explain the structure of the LR Parsers and Difference between LR and LL [7M]
Parsers.
b) What is an LR(0) item? Construct an SLR parsing table for the grammar G: [7M]
2. a) What are different intermediate code forms? Discuss different Three Address [7M]
b) Write a note on simple type checker and list the different types of type [7M]
checking.
3. a) List and explain different types of LR Parsers. Differentiate LR(0) and LR(1) [7M]
b) Construct Canonical LR parsing table for the following grammar. S→L=R | R [7M]
L→*R | id
R→L
4. a) Define LR(k) parser. Explain the model of LR parser and various functions [7M]
5. a) Give syntax directed translation scheme for simple desk circulator. [7M]
S → Aa|bAc|Bc|bBa
A→d
B→d
6. a) Write the rules used to construct SLR Parser. Give example. [7M]
b) Generate the three address code for the following code fragment. [7M]
7. a) What is an LALR(1) grammar?. Construct LALR parsing table for the [7M]
8. a) Write the quadruple, triple, indirect triple for the expression - [7M]
(a*b) + (c+d)-(a+b+c+d).
expression E.
example.
T (E) | id | num.
10. a) Discuss the evolution order of SDTs. Also write its applications [7M]
b) Write the SDD for a simple type declaration and draw the [7M]
UNIT -4
1. a) What are the principles associated with designing calling sequences and the
2. a) Explain how data flow equations are set up and solved for improving code. [7M]
3. a) Give the general structure of an activation record? Explain the purpose of [7M]
4. a) Write a short note on peephole optimization and various operations used in it. [7M]
b) Describe Loop unrolling? Describe its advantage with your own examples. [7M]
b) Translate the arithmetic expression a[i]=b*c-b*d into a syntax tree, quadruples [7M]
and triples.
6. a) Write pseudocode for finding sum of ‘n’ numbers. And identify basic blocks [7M]
then construct the flow graph for it. Explain the rules used for this.
8. a) What is a leader of basic block? Write and explain the algorithm [7M]
elimination technique.
10. a) What is code optimization? Explain about various levels and [7M]
types of optimizations.
UNIT -5
1. a) Explain various storage allocation strategies with its merits and demerits. [7M]
allocation.
2. a) What is runtime stack? Explain the storage allocation strategies used for [7M]
b) What is a flow graph? Explain how flow graph can be constructed for a given
program.
Main()
{ int sum, n, i;
sum=0;
for i:=1 to n do
sum:=sum+i;
write(sum);
} [7M]
3. a) Give an example to show how DAG is used for register allocation. [7M]
4. a) Generate code for the following C program using any code generation [7M]
algorithm.
main()
int I;
int a[10];
while(i<=10)
a[i]=0;
b) Explain the main issues in code generation. How to handle them? Discuss. [7M]
5. a) Discuss about register allocation and assignment in target code generation. [7M]
b) Discuss how induction variables can be detected and eliminated from the given
intermediate code
t2:=a[t1]
9. a) Give an example to show how DAG is used for register allocation. [7M]
b) Generate code for the following C program using any code generation [7M]
algorithm.
main()
int I;
int a[10];
while(i<=10)
a[i]=0;
10. a) Explain various issues that affect the efficiency of generated [7M]
code.
b) What are the different object code forms in code generation and [7M]
explain.