CS3501 Compiler Design
CS3501 Compiler Design
QUESTION BANK
PART A
1. Define Compiler and what are the phases of compiler.
2. What are the functions performed in synthesis phase.
3. Differentiate analysis and synthesis phase.
4. Differentiate token,pattern,lexeme .
5. Define the following i) Preprocessor ii) Assembler iii) Loader and Linker
6. Define Lexical Analysis.
7. Rules of Minimizing DFA.
8. Structure of Lex tool.
9. Declaration of Lex tool.
10. Explain FA.
11. Define Input Buffering.
12. Role of LA.
PART B
1. What is Compiler? Design the Analysis and Synthesis Model of Compiler.
2. Write down the five properties of compiler.
3. What is translator? Write down the steps to execute a program.
4. Discuss all the phases of compiler with a with a diagram.
5. Write a short note on:
a. YACC
b. Pass
c. Bootstrapping
d. LEX Compiler
e. Tokens, Patterns and Lexemes
6. Write the steps to convert Non-Deterministic Finite Automata (NDFA) into
Deterministic Finite Automata (DFA).
7. Let M=({q0,q1}, {0,1}, ᵟ , q0, {q1}).
Be NFA where ᵟ (q0,0)={q0,q1}, ᵟ (q1,1) = {q1}
ᵟ (q1, 0)=ᵩ, ᵟ (q1, 1)={q0, q1}
Construct its equivalent DFA.
A -> a|aS|bAA
B -> b|bS|aBB
Drive the string aaabbabbba using the above grammar (using Left Most Derivation and
Right most Derivation).
UNIT II SYNTAX ANALYSIS
Role of Parser – Grammars – Context-free grammars – Writing a grammar Top Down Parsing –
General Strategies – Recursive Descent Parser Predictive Parser-LL(1) – Parser-Shift Reduce
Parser-LR Parser- LR (0)Item Construction of SLR Parsing Table – Introduction to LALR Parser –
Error Handling and Recovery in Syntax Analyzer-YACC tool – Design of a syntax Analyzer for a
Sample Language.
PART A
1. What is phrase level error recovery
2. Write down the necessary algorithms for FIRST and FOLLOW 4.
3. Explain the error recovery in predictive parsing
4. Define operator precedence grammer
5. Define augmented grammar Compare the LR Parsers.
6. Compare and contrast LR and LL Parsers Differentiate between top down parsers
7. Define Dead code elimination?
8. Mention the types of LR parser
9. Explain bottom up parsing method
PART B
B-> Be|b
B-> bB|b
E-> E+T|T
T-> T*F|F
F-> (E)|id
9. Write the algorithm to create Predictive parsing table with the scanning of input string.
10. Show the following
Grammar: S->
AaAb|BbBa
A-> €
B-> €
E-> E+E
E-> E*E
E->id
12. Write the properties of LR parser with its structure. Also explain the techniques of LR
parser.
13. Write a short note on:
a. Augmented grammar
b. Kernel items
c. Rules of closure operation and goto operation
d. Rules to construct the LR(0) items
14. Consider the following
grammar: S->
Aa|bAc|Bc|bBa
A-> d
B-> d
T-> TF|F
F-> F*|a|b
Construct the SLR parsing table and also parse the input “a*b+a”
grammar: S-> CC
C-> aC
C->d
grammar S-
>Aa|bAc|Bc|bBa
A->d
B->d
20. Write the comparison among SLR Parser, LALR parser and Canonical LR Parser.
UNIT III SYNTAX DIRECTED TRANSLATION & INTERMEDIATE CODE
GENERATION
PART A
1. Define Type Equivalence
2. Explain the role of intermediate code generator in compilation process
3. Define left most derivation and right most derivation with example
4. What are the various types of intermediate code representation?
5. Write a note on the specification of a simple type checker.
6. Explain intermediate code representations?
7. Define type expression with an example?
8. State general activation record?
9. Explain type expression and type systems
PART B
expression: (a*b)+(c-d)*(a*b)+b
-(a*b)+(c+d)-(a+b+c+d)
PART A
1. Write the quadruple for the following expression (x + y)∗(y + z) + (x + y + z) .
2. What is a DAG? Mention its applications.
3. What are Abstract Syntax trees?
4. Define address descriptor and register descriptor
5. Discuss about common sub expression elimination
6. What is a Flow graph? Define constant folding?
7. Define reduction in strength?
8. Explain Lazy-code motion problem with an algorithm
PART B
1. Write the definition of symbol table and procedure to store the names in symbol table.
2. What are the data structures used in symbol table?
3. What are the limitations of stack allocation?
4. Write two important points about heap management.
5. Write the comparison among Static allocation, Stack allocation and Heap Allocation
with their merits and limitations.
6. What is activation record? Write the various fields of Activation Record.
7. What are the functions of error handler?
8. Write a short note on Error Detection and Recovery.
9. Classify the errors and discuss the errors in each phase of Compiler.
10. Illustrate loop optimization with suitable example.
11. Explain various code optimization techniques in detai
UNIT V CODE OPTIMIZATION
PART A
1. What are the induction variables?
2. Explain about code motion.
3. What are induction variables?
4. What is induction variable elimination?
5. What is machine independent code optimization?
6. Write a short note on copy Propagation
7. What are the induction variables?
8. Write a short note on Flow graph.
PART B
1. What are the properties of code generation phase? Also explain the Design Issues of this
phase.
2. What are basic blocks? Write the algorithm for partitioning into Blocks.
3. Write a short note on:
a. Flow graph (with example)
b. Dominators
c. Natural loops
d. Inner loops
e. Reducible flow graphs
4. Consider the following program
code: Prod=0;
I=1;
Do{
Prod=prod+a[i]*b[
i]; I=i+1;
}while (i<=10);