University of Delhi 2010-4th Sem M.C.A 2nd yr COMPUTER DESIGN-2 UNIVERSITY - Question Paper
[This question paper contains 6 printed pages ]
J
Your Roll No
6134-A
MCA/IV Sera.
MCA 401 - COMPILER DESIGN
(OC)
[This question paper contains 6 printed pages ]
J
Your Roll No
6134-A
Maximum Marks 60
Time 3 hours
(Write your Roll No on the top immediately on receipt of this question paper)
Attempt all questions Parts of a question must be answered together
1 (a) Describe the language denoted by the following regular expression
(2)
(0/1) * 0(0/l)(0/l)
(b) Write the regular expression for the following language
(i) All strings of 0s and ls that do not contain
the substring 011
(2)
(c) Construct a minimum - state DFA for the following regular expression
(a/b) * a(a/b)
(5)
bexpr bexpr or bterm/bterm bterm -> bterm and bfactor/bfactor bfactor -> not bfactor/( bexpr )/true/false
(i) What are terminals, nonterminals and start
symbol in the above grammar ?
(2)
(11) Construct the paise tree for the sentence not
(true or false).
(3)
(m) Is the above grammar ambiguous ? Why 9
(2)
(b) Consider the following grammar
E -> E + T/l T - TF/F F F * /a/b
(i) Is the above grammar LL(1)9 Prove or disprove (2)
(ii) Construct the SLR parsing table for this grammar (5)
3 (a) The following grammar generates expressions formed by applying an arithmetic operator + to integer and real constants. When two integers are added, the resulting type is integer, otherwise, it is real
E E + T/T T - num num/num
Give a syntax directed definition to determine the type of each subexpression (5)
(b) Suppose we have following C declaration
typedef struct { '
mt a, b,
} node, * head, node hst[100], head func (mt X, node Y)
Write type expressions for the types of list and func (2+3)
(c) Translate the following expression into qUadraples and indirect triples
a * (b + c) - (a + b + c) * d (2+2)
main( )
nit i,
int a{!0],
while (i < = 10) { a[i] = 0, = i+l
}
4 (a) What is printed by the following program assuming
(a) Call-by-value (b) Call-by-reference, (c) Copy-restore, (d) Call-by-name
Program main(mput, output), procedure p(x, y, z), begin
y = y + 1, Z - Z + X,
end,
begin
p(a+b, a, a), print a,
*
d = b * c
c = a + b
b = b * c
a = c-d (3)
5 (a) What is an activation record 9 What all field does it contain 9 Which of these field help to access local and global variables ? Explain with example (5)
(b) Consider the following 3-address code Partition it into Basic blocks Create a Flow graph and optimize it by removing common sub-expressions
(1) i = m - 1 (2) j = n
(3) t, = 4 * n (4) v = a[t,J
(5) i =i+I (6) t2 =4*i
(7) t3 = a[t2] (8) if t3<v goto(5)
(9) j -j-l (10) t4 = 4*j
(11) t5 = a[t4] (12) if t5>v goto(9)
(13) if i >j goto(23) (14) t6 =4*i
(15) x =a[t6] (16) t7 =4*i
6134-A 6
(19) a[t,J =t, (20) t10 - 4 i
(21) a[t10] =x (22) goto (5)
(23) |
tu |
4 * i |
(24) x. = a[tn] |
(25) |
<12 |
= 4*i |
(26) tu ~ 4 * n |
(27) |
*14 |
= *[*13] |
(28) a[t12] =tH |
(29) |
*i5 |
= 4 * n |
(30) a[tis] = x |
(1+2+2)
1
J
(100)****
Attachment: |
Earning: Approval pending. |