Sei sulla pagina 1di 6

QUESTION BANK

Subject : Compiler Construction Type: Long Answer Questions


----------------------------------------------------------------------------------------------------
Note :1. The questions marked as * are frequently repeated.

2. The one marked as Q can just be refered.

UNIT –V CODE GENERATION

1.*Explain Peephole optimization.

2.***Explain the principal sources of optimization with examples.

3. *What is code optimization? What are its advantages and give a detailed
description on loop optimization techniques?

4. ***Explain the different issues in the design of code generator.

5.Explain machine independent optimization techniques.

6. Explain machine dependent and machine independent optimizations in detail.

7. **Write Short note on Basic blocks and their construction.

8. Write Short note on Register allocation and assignment strategies

9. Write about Code generation from DAGs.(OR)

Write an algorithm for simple code generator

10. ****Write about data flow analysis.


OR
***Explain how to compute data flow equations using live variable analysis by
considering any flow graph

11.Construct a DAG for the given block:


a:=b+c b:=a-d c:=b+c d:=a-d

Q. Consider the following piece of code and covert in to three address code, Basic
block and Flow graph.

while (a < c and B > b) do


if a = 1 then
c = c+1
else
while a<=d do
a = a+3
Q. Generate code for the following sequence assuming x,y,z are in memory
locations.
if x < y go to L1 z = 0 go to L2 L1 : z = 1
Q. Write three address code and P-code for the following control statements:

(i) if (E) S1else S2 (ii) while (E) S

ERROR RECOVERY

12. Explain Error recovery in syntax analysis.

13. Error recovery in top down parsers

UNIT –IV INTERMEDIATE CODE GENERATOR

1. ***Write short notesThree Address Code

OR Various forms of three-address code with an example.

2. **Translate the assignment statement a[i] = b⋆c – b⋆d into quadruples, triples and
indirect triples.

3. What is a syntax tree? Write syntax directed definition for constructing a


syntax tree
for an expression. The grammar for an expression is given below.

E->E+T|E-T|T T->T*F|F F->(E)|id|num

4. What is DAG and construct syntax tree and DAG for the given expression?
a+a*(b-c)+(b-c)*d.
5. Write quadruple, triple, indirect triple for the statement a*-(b+c).

6. What is a type expression? Explain the equivalence of type expression with an


appropriate example.

7. Explain type checking and type conversions.

8. Write short notes on Rules for type checking.


STOGAGE ORGANIZATION

9. ****Discuss about the storage allocation strategies.


10.Discuss and analyze all the allocation strategies in run time environment.
11.Explain the process of access non local data on a stack.
12.Distinguish between static and dynamic storage allocations of a Language.
13.Write about the performance metrics used in the design of a Garbage Collector
14.Explain different parameter passing mechanisms?
UNIT –III---SDT

1. Write the differences between synthesized and inherited attributes with


example.
2. What are synthesized attributes and inherited attributes? Explain with a
suitable CFG.

3. Write SDD notations for the desktop calculator


E E+T | T
T T∗F | F
F (E) | id

4. Write the SDD for the given context free grammar given below and design
the dependency graph and explain the evolution order for that.
S TL
T int
T float
T char
L L, id
L id
5. Write about syntax directed definitions.

6. Write about Syntax directed translation

7. Write the attribute grammar for the following grammar and also draw the
parse tree for the string w = float x, y.
decl -> type var-list
Type-> int / float
var-list -> id, var-list / id

8. Write the syntax directed definition for the following grammar and also
draw the annotated parsetree for the input string 3∗5+4n
L En
E E+T | T
T T∗F | F
F (E) | digit

SYMBOL TABLE ORGANIZATION

1. **Explain symbol table organization.


2. ***Explain data structures for implementing symbol tables.
3. Explain how a hash table can be used to implement a symbol table
4. Write applications of Block structured languages.
5. Explain non block structured languages.
6. Compare and contrast symbol table organization of block structured and
unblock structured languages.
UNIT –II---SYNTAX ANALYSIS

1. Write an algorithm to construct first and follow set.

2. *Compute the FIRST and FOLLOW sets for the following grammar.
S->iEtSS’/a
S’->eS/E
E->b

3. Check whether the following grammar is LL(1) or not


S->iEtS| iEtSeS|a
E->b
4. Find out FIRST and FOLLOW for the following grammar:
S ACB / Ba / Cd
A e t / 
B g h / d
C d / e / 

5. Explain recursive descent parser with an example

6. **What is Recursive Descent Parser? Construct a Recursive Descent Parser for


the following grammar
F E + T / T
T TF / F
F F* / a / b
7. Write the algorithm for the construction of predictive parsing table.

8. **Construct the predictive parser for the following grammar .Show the
moves made by the parser on the input i*i$
E TE’
E’ +TE’ | ε
TFT’
T’ *FT’ | ε
F (E) | id
Q.Construct LL(1) parsing table for the following grammar:
exp ->exp addop term / term
addop-> +/-
term ->term mulop factor / factor
mulop-> *
factor -> (exp) / number.

9. Construct SLR parser for the following grammar


E->E*B|E+B|B
B->0|1

10.Consider the following grammar


S A S | b
A S A | a
Construct the SLR Parsing table for this grammar and show all moves for the
parsing of the input string “abab” using table.

11.Construct the SLR parsing table for the given grammar.


E->E + T|T
T->T*F|F
F->(E)|id

12.Explain the construction of SLR parse table for the following grammar and
show the moves made by parser on input i + i $
E E + T | T
T T F | F
F (E) | i

Q.Construct SLR (1) parsing table for the following grammar:


S -> I / other
I-> if S / if S else S

13. Construct the SLR parsing table for the given grammar.
S->L=R/R L->*R/id R->L

14.Explain the process of shift-reduce parsing on the i/p string id1*id2 for the
following grammar.
E E + T / T
T T∗F / F
F (E) / id

15. Construct CLR parsing table for the below grammar.


S AA
A Aa|b
16.Construct LALR for the following grammar.
E E + T / T
T T * F / F
F (E) / i d

17.Construct LALR for the following grammar.


S->CC C->ta|d

18.Construct CLR parser for the following grammar


S → AaAb | BbBa
A→ε
B→ ε

19.**Short notes on a) Parser generator YACC


OR Give specifications of YACC.
20.*Write short note on Conflicts in shift-reduce parsing.

UNIT –I---INTRODUCTION& LEXICAL ANALYSIS

1. *****Show the translation process of compiler for the given expression

a)Position: = initial + rate*60

b)Success : = Hard work + luck

c)Success: = effort + IQ ∗100

d) a [index] = 5 + 2 ;

2. ****Explain the different phases of a compiler with a neat diagram, showing the

output of each phase, with an example.

3.***Explain about various data structures used in a compiler. Specify where they
are used.

4. What are the basic functions of a language translator?

5. **How input buffering can increase the efficiency of compilation?

6. Explain boot strapping and porting?

7. ***Give a brief description about lex.

8. Explain how lex program performs lexical analysis of identifiers, keywords,


constant,and relop.

9. Write a LEX program to count the number of words, characters, blank

spaces and lines.

Potrebbero piacerti anche