Uttar Pradesh Technical University (UPTU) 2007 B.E Computer Science COMPILER CONSTRUCTION - Question Paper
COMPILER CONSTRUCTION
CS - 604
* V - 1 0 3 8 *
Printed Pages : 4
(Following Paper ID and Roll No. to be filled in your Answer Book)
PAPER ID: 1038
(SEM. VI) EXAMINATION, 2007 COMPILER CONSTRUCTION
Time : 3 Hours] [Total Marks : 100
Note : Attempt all questions.
1 Attempt any four parts of the following : 5x4=20
(a) Discuss how YACC can be used to generate a parser. Also, explain the format of its input specification file.
(b) Prove that regular sets are closed under intersection. Present a method for constructing a DFA with an intersection of two regular sets.
(c) Construct a finite automata that will accept those strings of a binary number that are divisibe by three.
(d) Find the DFA recognizing the language described by the regular expression.
a\abb\a*b+
(e) Find the reduced grammar that is equivalent to the CFG given below :
SaC\SB A bSCa B -> aSB | bBC C aBC | ad
(f) What is the language accepted by the finite automata whose transition diagram is given below : (Fig. 1).
2 Attempt any two parts of the following : 10x2=20
(a) Construct the LALR passing table for the following grammar :
(b) Construct a predictive parsing table for the following grammar where S| is a start symbols and # is the end marker.
S\-S# S qABC A a|bbD B |e |e D |e
(c) Consider the grammar and test whether the grammar is LL(1) or not.
S->|AS|g A \AC\OC BOS C > 1
3 Attempt any two parts of the following : 10x2=20
(a) Generate three address code for the following code :
switch a + b {
case 1 : x = x +1 case 2 : y = y+2 case 3 : z = z + 3 default : c = c -1
}
(b) Construct an SLR(l) parsing table for the following grammar :
A)
AA,P) (P, P P {num, num}
(c) Transform the following NFA into an optimal/minimal state DFA :
0 |
1 |
G | |
A |
A,C |
B |
D |
B |
B |
D |
C |
C |
C |
A, C |
D |
D |
D |
A |
- |
Attempt any two parts of the following : 10x2=20
(a) Write the syntax directed translation to go along with the LR parser for the following:
A DS while
(b) For the grammar having productions :
Compute FIRST and FOLLOW set of A.
(c) A relation R on the set of integers defined as :
R = {(a, b) | a-bis even integer}
Show that R is equivalence.
Attempt any two parts of the following : 10x2=20
(a) Give three-address code for the following code fragment :
if a <b then
while c > d d x = x + y
else
do
while e <= f
(b) Construct an LALR(l) parsing table for the following grammar :
DL.T
LL,id\id
T integer
(c) Write a short note on code optimization.
V-1038] 4 [ 1195 ]
Attachment: |
Earning: Approval pending. |