Compiler Design Final Question Bank

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Name of the Subject: Compiler Design

Unit-I

Q.
Questions
No
A) Explain the phases of a compiler? Differentiate between compiler and interpreter.
1
B) Explain the role of symbol table in compiler design.
Contrast a source language statement a= b*c - 2, where a, b and c are float variables, * and –
2 represents multiplication and subtraction on same data types, show the input and output at each
of the compiler phases. .
A) Design the DFA for the regular expression (a | b)* (abb | a+ b).
3 B) Explain how the regular expressions and finite state automata are used for the
specification and recognition of tokens?.
4 Explain the process of optimization of DFA based pattern matchers.

Explain the process of design of lexical analyzer generator with neat diagram.
5
A) Distinguish between Assembly language and Machine language.
6
B) Explain the structure of LEX program. What is the purpose of transition diagram?

A) Explain the possible error recovery actions taken by lexical analyzer.


7
B) Explain the Input Buffering technique in compiler design.

A) Explain the characteristics of a high-level programming language.


8
B) Explain about lexical analyzer and its role in detail.

Classify and Conversion from Regular Expression into NFA equivalent to DFA for
9
below expression. 10+(0+11)0*1.
A) Define Finite automata with example. How DFA is different with NFA.
10
B) Explain the hierarchy of programming elements. What are the two parts of
compilation?

Unit-II

Q.
Questions
No
Construct the LL(1) predictive parser for the following grammar
E ->TE’
E-> +TE’ | ε
1 T ->FT’
T-> *FT’ | ε
F-> (E) | id
A) Consider the CFG S -> SS+|SS*|a . Derive the string aa+a* from the given CFG and
2 construct aparse tree for this string.
B) Consider the context free grammar S->aSbS | bSaS | € Check whether the grammar
is ambiguous or not.

Construct SLR(1) parsing table for the following grammar


1. E-> E+T
2. E-> T
3 3. T-> T*F
4. T-> F
5. F-> (E)
6. F-> id
A)Design a recursive descent parser for the grammar
E->E + T | T
4 T->T*F | F
F->(E) | id
B) Distinguish between top-down parsing and bottom-up parsing.
Construct CLR(1) canonical set of items for the following grammar
S' -> S
5
S -> CC
C ->aC/ d
A) Find the FIRST and FOLLOW of the non-terminals in the grammar
S->aABe
A->Abc|b
6
B->d
B) What is left recursive grammar? Give an example. What are the steps in removing
left recursion?
A) What are the differences between LL (1) Parsing and LR(k) Parsing.
7 B) Define LR(k) and Draw the parse tree for the arithmetic expression
id + (id * id).
Construct the collection of LR (0) item sets and draw the goto operation for the
following grammar
8 S -> AA
A-> aA | b.
Indicate the conflicts (if any) in the various states of the SLR parser.
A) Evaluate and Remove left recursion in the following grammar.
S→AS | b
A→SA | a
9 B) Evaluate and Remove left factoring in the following grammar.
A ->aBcC | aBb | aB | a
B -> ε
C -> ε
A) Explain the steps for efficient construction of LALR parsing table.
10
B) Explain the process of handling “Dangling-ELSE” ambiguity.

Unit-III

Q.
Questions
No
A) What do you mean by intermediate code? Explain the role of intermediate code in
compiler design
1
B) Explain how DAGs help in intermediate code generation with an example?

A) What are L-attributed definitions and S-attributed definitions in a syntax directed


2
translation scheme?
B) Explain the syntax directed definition of a simple desk calculator.

A) Construct the DAG and three address code for the expression a+a*(b-c)+(b-c)*d.

3
B) Implement Quadruple, triple and indirect triple for following expression
a+a*(b+c)+(b+c)*d.
A) Construct SDD for constructing syntax tree for expression a-b+c for following
grammar
4 E -> E + T | E – T | T
T -> (E) | id | num
B) Explain how to convert an infix expression to postfix expression using SDT.

A) Construct syntax tree and postfix notation for Expression (a+ (b*c))/d-e/(f+g).
5
B) Define Type Checker. Write down the specification of a simple Type Checker.

A) Explain in detail how an L-attributed grammar can be converted into a Translation


6 scheme.
B) Construct the assignment x: = A[y,z] into three address statement.
A) What are different rules for 3-address code and differences between S-attributed
grammar and L-attributed Grammar.
7
B) What is Direct Acyclic Graph and the functions used to create the nodes of syntax
trees?
A) Construct the expression id=id to postfix notation using following SDT?
S->L=R
S->R
L->*R
8
L->id
R->L

B) What are the benefits of intermediate code generation? Write the need the Semantic
analysis?
A) Explain how to convert an infix expression to postfix expression using SDT and
9 write the different applications of SDT?
B) Explain the terms of dependency graph and evaluation order.
A) Construct parse tree and the annotated parse tree for the expression: 1*2*3*(4+5) n.
10
B) Explain the translation scheme for Boolean expression using the back patching
technique.

Unit-IV

Q.
Questions
No
Explain in detail about Basic blocks and flow graphs with an example.
1
Classify the issues to be considered while applying the techniques for code optimization
2
and explain about dead code elimination.
A) What are the principle sources of optimization? Give the classification of code
Optimization.
3
B) Explain the role of semantic preserving transformations and dominators in code
Optimization.
4
Explain the Data flow Analysis and its role in code optimization.

A) Explain the following loop optimization techniques with examples:


5
(i) Code motion (ii) Induction variable elimination and (iii) strength reduction.

B) Explain storage allocation and heap allocation strategies.


Explain in detail about Constant propagation in Machine-Independent optimizations.
6

A) What is runtime environment in symbol table? Explain about Activation record?


7
B) Explain method for handling fixed length data and variable length data.
A) Explain in detail about the Reference counting garbage collectors.
8
B) Explain the introduction to trace-based collection.
A) Explain different stack allocation strategies with suitable examples.
9 B) Explain different code optimization techniques available in local and global
optimizations?
Explain the interprocedural optimization and Explain the different local optimizations
10
with an example.

Unit-V

Q.
Questions
No
Explain the Issues in the design of a Code Generator.
1
Explain the Peephole optimization in Machine-dependent Optimizations with an
2 example.

3
Explain with an example Dynamic Programming code generation.

4
Explain in detail about simple code generation algorithm in Target Code Generation.
Explain the application of peephole? What kinds of peephole techniques can be used to
5
perform machine-dependent optimizations?
Why optimization is often required in the code generated by simple code generator and
6
explains the unreachable code optimization.
Generate the target code from sequence of three address statements using simple code
7
generator algorithm.
8 Explain the process of addresses in the target code?

Explain in detail about the Register allocation and assignment in Machine-dependent


9
Optimizations.
Explain the Code Generation Algorithm and write the getreg function.
10

You might also like