Compiler Design KCS 502 2020

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Printed Page: 1 of 2

Subject Code: KCS502


0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0

B TECH
(SEM-V) THEORY EXAMINATION 2020-21
COMPILER DESIGN
Time: 3 Hours Total Marks: 100
Note: 1. Attempt all Sections. If require any missing data; then choose suitably.
SECTION A

1. Attempt all questions in brief. 2 x 10 = 20


Qno. Question Marks CO
a. What is YACC? Discuss about it. 2 CO 1
b. Design a DFA for the following regular expression: 2 CO 1
(x+y)*xyy
c. Consider the following grammar: 2 CO 2
S→B|SabS, B→bB| ε
Compute FOLLOW(B)
d. Discuss about shift-reduce parsing. 2 CO 2
e. Find the postfix notation for the following expression: 2 CO 3
(a+b+c)*(c+q)

P
f. Discuss about non-linear type intermediate code. 2 CO 3
0Q

1
g. Write short note on “Activation Record” 2 CO 4

13
29

h. Discuss about hash table. 2 CO 4

2.
i. Discus about constant folding. 2 CO 5
0E

24
j. Discuss about designing issues of code generator. 2 CO 5
P2

SECTION B

5.
_Q

.5
2. Attempt any three of the following: 17 3 x 10 = 30
TU

Qno. Question Marks CO


|1

a. Explain in detail the process of compilation for the statement 10 CO 1


AK

a=b+c*70.
4 8

b. Construct the CLR(1) parsing table for the following grammar: 10 CO 2


8:

S→AA, A→aA|b
:1

c. Consider the following grammar and give the syntax directed 10 CO 3


09

definition to construct parse tree for the input expression 4*7+3*9.


Also construct an annotated parse tree according to your syntax
1

directed definition.
02

E→E+T|T, T→T*F|F, F→num.


2

d. Explain lexical, syntax, semantic phase errors in detail. 10 CO 4


b-

e. Explain in detail about loop optimization. 10 CO 5


Fe

SECTION C
5-

3. Attempt any one part of the following:


|2

Qno. Question Marks CO


a. (i). Write a regular expression to represent a language consisting of 10 CO 1
strings made up of odd number of a & odd number of b.
(ii). Write a CFG to represent the language L={an+mbn|m,n≥1}.
b. (i). Check whether given grammar is ambiguous or not. If ambiguous 10 CO 1
then convert it into unambiguous grammar:
E→E+E|E*E|id
(ii). Discuss about cross compiler.
1|Page
AKTU_QP20E290QP | 25-Feb-2021 09:18:48 | 117.55.242.131
Printed Page: 2 of 2
Subject Code: KCS502
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0

4. Attempt any one part of the following:


Qno. Question Marks CO
a. Check whether the given grammar is LR(0) or not: 10 CO 2
S→PQy, P→Sy|x, Q→yS
b. Find the precedence and function table of the following grammar by 10 CO 2
using operator precedence technique.
P→SR|S, R→bSR|bS, S→WbS|W, W→L*W|L, L→id

5. Attempt any one part of the following:


Qno. Question Marks CO
a. Translate the following arithmetic expression into quadruples and 10 CO 3
triples:
(i). x=y*z+y*-z
(ii). a=-b*(c+d)+b
b. Generate three address code for the following code: 10 CO 3
Switch p+q
{

P
case 1: x=x+1
0Q

1
case 2: y=y+2

13
29

case 3: z=z+3

2.
default: c=c-1
0E

24
P2

5.
_Q

6. Attempt any one part of the following:


.5
17
TU

Qno. Question Marks CO


|1
AK

a. What is symbol table? Explain various data structures used for 10 CO 4


8

symbol table.
4

b. (i). Explain the function of error handling phase of a compiler. 10 CO 4


8:

(ii). Write short note on scoping.


:1
09

7. Attempt any one part of the following:


1
02

Qno. Question Marks CO


a. Construct the flow graph for the following code segment: 10 CO 5
2
b-

fact(n)
Fe

{
int f=1;
5-

for(i=2; i≤n; i++)


|2

f=f*i;
return f;
}
b. Define a DAG. Construct a DAG for the expression: 10 CO 5
p+p*(q-r)+(q-r)*s

2|Page
AKTU_QP20E290QP | 25-Feb-2021 09:18:48 | 117.55.242.131

You might also like