You are on page 1of 4

Institute of Technology & Science, Mohan Nagar, Ghaziabad

Compiler Design

Model Questions

Unit-1

1. Define and differentiate between DFA and NFA with an example.


2. Describe the languages denoted by the following regular expressions:
i) 0(0|1)*  0
ii) C(|0|*) *
iii) (0|1)*0(0|1)(0|1)
iv) a*|0*|0*|0*
3. Following are the sequence of auxiliary definitions:
A =a/b
0

A =A A
1 0 0

A =A A
2 1 1

.
.
.
.
A =A A
n n-1 n-1

Followed by a pattern A n

a. Describe the set of strings denoted by the pattern (as a function of n)


b. If we substitute out all auxiliary definition in the pattern, how long is the regular
expression?
c. If you convert the regular expression from (b) into an NFA, How many states are
there.
4. Define the following:
i) Regular Expression
ii) Regular Grammar
iii) Context Free Grammar
iv) Context Sensitive Grammar
5. Mention the various notational shorthand’s for representing regular expressions.

Unit-2

1. What do you understand by single pass and multi pass compiler. Discuss their merits
and demerits also.
2. Describe the basic structure of compiler. OR Describe the functionality of each phase of
compiler with appropriate diagram.
3. Differentiate between the following:
a. Compiler and interpreter
b. Preprocessor and Micro
4. What do you understand by Boot Strapping? Explain with the help of example.
5. What is translator? Classify the translators.
6. Discuss the role of compiler writing tools. Describe various writing tools.
7. What is translator? Classify the translators.
8. Discuss important data structures which are used in implementing symbol table.
9. Explain the terms token, lexeme and pattern.
10. What is symbol table? Explain in detail. Explain the use of symbol table.

11. How lexical Analyzer removes white spaces from the source file? Explain the buffer input
scheme for scanning the source program.

Unit-3
1. Explain about basic parsing techniques. What is top down parsing? Explain in
detail.
2. Write the algorithm for FIRST and FOLLOW.
3. Palindromes can’t be recognized by any FSA(Finite State Automata) Why?
4. What are kernels and non kernel items?
5. What is phrase level error recovery?
6. List the advantages and disadvantages of operator precedence parsing.
7. Explain in detail:
1. Lexical phase Errors
2. Syntactic Phase Errors
3. Semantic Phase Errors
8. What do you mean by left recursion and left factoring? How are these eliminated?
Explain with the help of example.
9. Consider the following:

E→T+E|T
T→V*T|V
V→id
Write down the procedures for the non terminals of the grammar to make a recursive
descent parser.
10. What is LR parser? How it is different from SLR? Construct LALR table for    (2015
S→S
S→aAd|bBd|aBc|bAc
11. Differentiate between top down and bottom up parser. Under which conditions
predictive parsing can be constructed for a grammar?(2015,
12. Eliminate left recursion and left factor from the following grammar.
E→aba|abba|Eb|EbE (2015,
13. Eliminate left recursion in more than one level.(2015,
S→Aa|b
A→Ac|Sd|∈
14. Construct the SLR parsing table for the following grammar:
E→E+T
E→T
T→T*F
T→F
F→id
L→L,E|E (2015,
15. Find the canonical collection of sets of LR(1) items:
S→AaAb
A→BbBa
A→ϵ
B→ϵ
16. Consider the following grammar
S→S=R
S→R
L→*R
L→id
R→L
Write the algorithm for FOLLOW. And find the FIRST and FOLLOW for the given
grammar.( 2010,
17. Explain the following in brief:
a. YACC
b. Parse Tree
18. Consider the following grammar:
E→E+E
E→E*E
E→(E)
E→id
Using the above grammar for the input string id1+id2*id3 show the stack implementation
for Shift Reduce parsing.(2010,
19. What is operator precedence parsing?
E→EAE|(E)|-E|id
A→+|-|*|/|↑
Is the above grammar Operator Precedence Grammar? If yes then why if not convert
into operator precedence grammar.
Unit-4

1. Discuss the role of syntax directed translation scheme.


2. What are various methods for implementing three address code statements? What are
the problems with top down parsing?
3. Write the procedure to generate a*(b+c)/(d+e) TAC( Three Address Code)
4. Give Syntax Directed definition for id- else statement
5. What is the objective of intermediate code generation? What is the different form of
intermediate code generated by intermediate code generation phase?
Generate the three address code for the following code segment:
main()
{
Int a=1;
Int b[10];
while(a<=10)
b[a]=2**a;
}
6. Give quadruple representation for the given statements:
a. A=-B*(C+D)
b. -(a+b)*(c+d)-(a+b+c)
6. What is three address code? Explain in brief.
7. For the following statements:
a) A[I]=B
b) A=B[I]
Give triple representation.
Unit-5

1. What is DAG? Discuss it.Explain the algorithm of constructing DAG with the help of an
example.
2. Define various code optimization techniques in detail.
3. Explain the implementation of simple stack allocation scheme while on runtime
administration.
4. What is code motion? Also state the properties of optimizing compiler.
5. Write a short note on:
1. Principle source of optimization
2. Problems in code generation
3. Error recovery schemes
a. What is activation record ? Explain its organization. Also discuss various storage
allocation strategies.
b. Discuss the role of Data Flow Analysis.
c. What is the use of run time storage administrator? What is the difference between static
and dynamic allocation? How static scope rules are defined using stack.
d. Discuss principal sources of optimization.
e. Write down the algorithm for code generation for three address code.
f. Write short note on the following:
1. A. Problem in code generation
B. Local and loop optimization
C. Run time storage management
b. Describe various code optimization techniques in detail.
c. How registers are allocated in code generation? Differentiate between source code,
intermediate code and object code.

You might also like