100% found this document useful (2 votes)
1K views6 pages

r05320502 Compiler Design

Describe with an example, how LEX program performs lexical analysis for the following patterns in java code. Describe, how addressing modes can be used for reducing the memory access time.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
1K views6 pages

r05320502 Compiler Design

Describe with an example, how LEX program performs lexical analysis for the following patterns in java code. Describe, how addressing modes can be used for reducing the memory access time.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Code No: R05320502 Set No.

1
III B.Tech Supplimentary Examinations, Aug/Sep 2008
COMPILER DESIGN
(Computer Science & Engineering)
Time: 3 hours Max Marks: 80
Answer any FIVE Questions
All Questions carry equal marks
⋆⋆⋆⋆⋆

1. (a) Explain the bootstrapping process with suitable diagrams.


(b) Explain how input buffering helps lexical analyzer in compilation process.[8+8]

2. (a) What is recursive descent parser? Construct recursive descent parser for the
following grammar.
E → E + T|T
T → TF|F
F → F∗ |a|b
(b) What is ambiguous grammar? Eliminate ambiguities for the grammar:
E → E + E|E∗ E|(E)|id. [8+8]

3. (a) What is an operator grammar? Give an example.


(b) Write an operator precedence parsing algorithm. [6+10]

4. Write short notes on the following:

(a) S-attributed definitions.


(b) L-attributed definitions.
(c) Dependency graph. [6+6+4]

5. What are the various operations performed on the symbol table? Explain each of
them in detail. [16]

6. Explain different principal sources of optimization technique with suitable exam-


ples. [16]

7. (a) Explain reducible and non-reducible flow graphs with an example.


(b) Explain natural loops and inner loops of a flow graph with an example. [8+8]

8. (a) Describe, how addressing modes can be used for reducing the memory access
time
(b) Generate the code sequence using Code generation algorithm for the following
expression [8+8]
W:=(A-B)+(A-C)+(A-C)

⋆⋆⋆⋆⋆

1 of 1
Code No: R05320502 Set No. 2
III B.Tech Supplimentary Examinations, Aug/Sep 2008
COMPILER DESIGN
(Computer Science & Engineering)
Time: 3 hours Max Marks: 80
Answer any FIVE Questions
All Questions carry equal marks
⋆⋆⋆⋆⋆

1. Explain with an example, how LEX program performs lexical analysis for the fol-
lowing patterns in C :
identifier, comments, constants, and arithmetic operators.
[16]

2. (a) Consider the following grammar.


S → 0A|1 B|0| 1
A → 0S|1 B| 1
B → 0 A|1 S
Construct leftmost derivations and parse trees for the following sentences
i. 0101
ii. 1100101
(b) Consider the following grammar
E → T + E|T
T → V∗ T|V
V → id
Write down the procedures for the nonterminals of the grammar to make a
recursive descent parser. [8+8]

3. Define precedence functions. Construct precedence table and directed graph rep-
resenting precedence functions for operators +, *, id, $. [16]

4. (a) Describe the overloading of functions and operators with suitable examples.
(b) Write a note on polymorphic functions. [8+8]

5. (a) What is an ordered and unordered symbol table? What is the function of
symbol table in the compliation process? Explain.
(b) What are the various attributes of a Symbol Table? [10+6]

6. (a) What is code optimization? What are its advantages?


(b) Explain briefly about folding.
(c) What are the problems in optimizing compiler design? [5+5+6]

7. Consider the following matrix multiplication Program


begin
for i := 1 to n do
for j:=1 to n do

1 of 2
Code No: R05320502 Set No. 2
c[i, j] :=0;

for i := 1 to n do
for j:=1 to n do
for k :=1 to n do
c[i, j] :=c[i , j] +a[i ,k] *b [k ,j]
end

(a) Assuming a, b, and c are allocated static storage and there are four bytes per
word in a byte-addressed memory, produce three-address statements for the
above program.
(b) Find the induction variables of each loop and eliminate them wherever possible
[8+8]

8. (a) Explain the different issues in the design of a code generator.


(b) Generate code for the following C statements:
i. x= f(a) + f(a) + f(a)
ii. x= f(a) /g(b,c)
iii. x= f(f(a))
iv. x= ++f(a) [8+8]

⋆⋆⋆⋆⋆

2 of 2
Code No: R05320502 Set No. 3
III B.Tech Supplimentary Examinations, Aug/Sep 2008
COMPILER DESIGN
(Computer Science & Engineering)
Time: 3 hours Max Marks: 80
Answer any FIVE Questions
All Questions carry equal marks
⋆⋆⋆⋆⋆

1. Explain with an example, how LEX program performs lexical analysis for the fol-
lowing patterns in C :
identifier, comments, constants, and arithmetic operators.
[16]
2. Construct predictive parsing table for the following grammar.
E → T E′
E′ → +T E′ |ε
T → F T′ [16]
T′ → ∗ F T′ |ε
F → (E)|id
3. (a) Explain the stack implementation of shift reduce parsing method with an
example.
(b) Define handle. Give suitable example. [10+6]
4. Write short notes on the following:
(a) S-attributed definitions.
(b) L-attributed definitions.
(c) Dependency graph. [6+6+4]
5. Only one occurrence of each object is allowable at a given moment during program
execution. Justify your answer with respect to static allocation. [16]
6. Explain different principal sources of optimization technique with suitable exam-
ples. [16]
7. Describe, how redundant expression elimination can be done in loop optimization
technique, during global optimization. [16]
8. (a) Explain the different issues in the design of a code generator.
(b) Generate code for the following C statements:
i. x= f(a) + f(a) + f(a)
ii. x= f(a) /g(b,c)
iii. x= f(f(a))
iv. x= ++f(a) [8+8]

⋆⋆⋆⋆⋆

1 of 1
Code No: R05320502 Set No. 4
III B.Tech Supplimentary Examinations, Aug/Sep 2008
COMPILER DESIGN
(Computer Science & Engineering)
Time: 3 hours Max Marks: 80
Answer any FIVE Questions
All Questions carry equal marks
⋆⋆⋆⋆⋆

1. (a) Explain the different phases of a compiler, showing the output of each phase,
using the example of the following statement:
position : = initial + rate * 60
(b) Compare compiler and interpreter with suitable diagrams. [10+6]

2. (a) Give the rules for computation of FIRST(X) and FOLLOW(X). Construct
FIRST and FOLLOW sets for the following grammar.
E → T E′
E′ → +T E′ |ε
T → F T′
T′ → ∗ F T′ |ε
F → (E)|id
(b) Write an algorithm for construction of predictive parsing table. [10+6]

3. (a) What is an operator grammar? Give an example.


(b) Write an operator precedence parsing algorithm. [6+10]

4. (a) Write a note on the specification of a simple type checker.


(b) What is a type expression? Explain the equivalence of type expressions with
an appropriate examples. [8+8]

5. (a) Explain the hash table with temporary and permanent storage.
(b) Reusing the storage space for names. [8+8]

6. (a) What is DAG? Construct the DAG for the following basic block
D := B∗ C
E :=A+B
B := B+C
A := E-D
(b) What are the legal evaluation orders and names for the values at the nodes
for the DAG of problem (a).
i. Assuming A, B and C are alive at the end of the basic block?
ii. Assuming only A is live at the end? [6+10]

7. (a) What is an Induction variable? Explain with an example.


(b) Discuss how induction variables can be detected and how transformation can
be applied. [8+8]

1 of 2
Code No: R05320502 Set No. 4
8. (a) Describe, how addressing modes can be used for reducing the memory access
time
(b) Generate the code sequence using Code generation algorithm for the following
expression [8+8]
W:=(A-B)+(A-C)+(A-C)

⋆⋆⋆⋆⋆

2 of 2

You might also like