You are on page 1of 7

Code No: R05311201 Set No.

1
III B.Tech I Semester Regular Examinations, November 2008
AUTOMATA AND COMPILER DESIGN
( Common to Information Technology and Computer Science & Systems
Engineering)
Time: 3 hours Max Marks: 80
Answer any FIVE Questions
All Questions carry equal marks
⋆⋆⋆⋆⋆

1. (a) What are the closure properties of Regular sets? Explain.


(b) Briefly explain the logical phases of a compiler model. [8+8]

2. Compute the FIRST and FOLLOW sets of each of the non-terminals for the fol-
lowing grammar:
P → AQRbe | mn | DEi
A → ab |∈
Q → q1 q2 |∈
R → r1 r2 |∈
D→d
E → e. [16]

3. Consider the following grammar:


S′ → S
S → (S)S |∈

(a) Construct the LR(0) parser.


(b) Find the SLR(1) parse table.
(c) Find the moves made by the LR(0) parser on the input string: ( ( ) ( ) ).
[5+5+6]

4. (a) Explain Quadruples, Triples, and Indirect Triples.


(b) Construct Quadruples, Triples, and Indirect Triples of the following expres-
sion: (a + b) * (c + d) - (a + b + c). [6+10]

5. (a) what is type Checker? How does it work?


(b) Write short notes on Dynamic and Static type checking? [8+8]

6. (a) Write a notes on the static storage allocation strategy with example and dis-
cuss its limitations?
(b) Discuss about the stack allocation strategy of runtime environment with an
example? [8+8]

7. (a) What is flow-graph. Explain how given program can be converted into flow-
graph?
(b) Explain the loop optimization? [8+8]

1 of 2
Code No: R05311201 Set No. 1
8. Explain issues in the design of a code generator? [16]

⋆⋆⋆⋆⋆

2 of 2
Code No: R05311201 Set No. 2
III B.Tech I Semester Regular Examinations, November 2008
AUTOMATA AND COMPILER DESIGN
( Common to Information Technology and Computer Science & Systems
Engineering)
Time: 3 hours Max Marks: 80
Answer any FIVE Questions
All Questions carry equal marks
⋆⋆⋆⋆⋆

1. (a) Write a general format of the LEX program and give an example.
(b) Construct a DFA that accepts an identifier of a programming language.
(c) Explain the difference between the phase and pass of a compiler. [6+5+5]

2. (a) What is a recursive grammar? Explain.


(b) Consider the following recursive grammar:
i. S → Aa |b
ii. A → Ac |Sd
What is an equivalent grammar when the left recursion is removed? [6+10]

3. Consider the following grammar:


E → E + T |T
T → T ∗ F |F
F → (E) |a

(a) Construct the SLR parse table.


(b) Find the moves made by the parser on the input string: a + a * a. [10+6]

4. Consider the following grammar:


D → TL;
T → int |float
L → L, id |id

(a) Write the Syntax Directed Definitions to add the type of each identifier to its
entry in the symbol table during semantic analysis.
(b) Draw an annotated parse tree for the declaration: float id1, id2, id3; [8+8]

5. Explain the following:

(a) Type checking of Expressions


(b) Translation scheme for checking the type of statements. [8+8]

6. Explain about storage allocation strategies in Block-structured Languages? [16]

7. Explain about Data-Flow analysis of structured flow graphs. [16]

8. (a) Explain the concept of calculating cost of instructions

1 of 2
Code No: R05311201 Set No. 2
(b) Consider below addressing codes along with associated costs
Mode Added Cost
absolute 1
register 0
indexed 1
indirect register 0
indirect indexed 1
Compute cost of following set of statements
i. mov b, R0
Add c , R0
Mov R0,a
ii. add R2, R1
Mov R1,a
iii. Mov b , a
Add c , a. [8+8]

⋆⋆⋆⋆⋆

2 of 2
Code No: R05311201 Set No. 3
III B.Tech I Semester Regular Examinations, November 2008
AUTOMATA AND COMPILER DESIGN
( Common to Information Technology and Computer Science & Systems
Engineering)
Time: 3 hours Max Marks: 80
Answer any FIVE Questions
All Questions carry equal marks
⋆⋆⋆⋆⋆

1. (a) When are two Regular Expressions said to be equivalent? Explain with an
example.
(b) Construct DFA equivalent to the NFA as shown in figure 1b. [8+8]

Figure 1b
2. (a) Give the CFG generating the set of palindromes over an alphabet,
Σ = {a, b}.
(b) Consider the following recursive grammar: S → Sa | Sb | a |b
Obtain an equivalent grammar with NO left recursion. [8+8]

3. (a) What is LR parser? Compare and contrast the different types of LR parsers.
(b) Construct the CLR parse table for the following augmented grammar:
A′ → A
A → (A) |a [8+8]

4. Let synthesized attribute, Val give the value of the binary number generated by S
in the following grammar. For example, on input 101.101, S.Val = 5.625.
S → L • L |L
L → LB |B
B → 0 |1
Write synthesized attribute values corresponding to each of the productions to
determine the S.Val. [16]

5. (a) Discuss about the overloading of functions and operators with an example?
(b) What are the advantages and disadvantages of Name equivalence? Explain
with examples? [8+8]

1 of 2
Code No: R05311201 Set No. 3
6. Write and explain the following:

(a) Activation tree


(b) Activation record. [8+8]

7. Explain the machine independent Optimization in Detail? [16]

8. Write and Explain Heuristic Ordering algorithm for DAG with one example. [16]

⋆⋆⋆⋆⋆

2 of 2
Code No: R05311201 Set No. 4
III B.Tech I Semester Regular Examinations, November 2008
AUTOMATA AND COMPILER DESIGN
( Common to Information Technology and Computer Science & Systems
Engineering)
Time: 3 hours Max Marks: 80
Answer any FIVE Questions
All Questions carry equal marks
⋆⋆⋆⋆⋆

1. (a) Design a DFA that accepts the language over the alphabet, Σ = {0, 1, 2}
where the decimal equivalent of the language is divisible by 3.
(b) Compare compiler and an interpreter with the help of suitable examples. [8+8]

2. Construct the predictive parse table for the following grammar:


E → E + T|T
T → T ∗ F |F
F → (E) |xy |xz. [16]

3. Consider the following augmented grammar:


S→E
E → E + T |T
T → a |(E)

(a) Construct the DFA whose states are the canonical collection of LR(0) items.
(b) Construct the SLR(1) parse table. [8+8]

4. (a) What is a three-address code? Give an example.


(b) Describe various types of three address statements with an example of each.
[4+12]

5. (a) Explain Chomsky hierarchy of Languages?


(b) Give detail analysis on generic function and polymorphic function? [8+8]

6. Explain Hash table Organization of Symbol tables for block structured Languages?
[16]

7. Write and Explain about Peephole optimization? [16]

8. Write and explain about object code forms? [16]

⋆⋆⋆⋆⋆

1 of 1

You might also like