Noida Institute of Engineering and Technology, Greater Noida

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

Noida Institute of Engineering and Technology, Greater Noida

Printed Page :- Sub Code: KCS 502


Paper Id: Roll
No.:

Pre-University Test (Online)

B. TECH.
(Semester- V) THEORY EXAMINATION 2020-21
Sub Name: Compiler Design

Time: 3 Hours Total Marks:100

Note: 1. Attempt all Sections. If require any missing date; then choose suitably.

SECTION-A

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

Q. No. Question Marks CO


a. Write a short note on Activation Record. 2 CO4
b. Define peephole optimization. 2 CO5
c. Eliminate left recursion from the following grammar: 2 CO2
A → Bd | Aff | CB
B → Bd | Bf | df
C→h|g
d. How a program executes in the language processing system? Draw only diagram. 2 CO1
e. Explain some problems associated with Top-Down Parsing. 2 CO2
f. List various different error recovery strategies in syntactic analysis phase. 2 CO4
g. List all the design issues in code generation phase. 2 CO5
h. What are Synthesized and Inherited Attributes? 2 CO3
i. Explain the following functions: 2 CO3
i) makelist(i)
ii) merge(p1,p2)
iii) backpatch(p,i)
j. Develop a compiler for language S on machine B with the help of an existing 2 CO1
compiler of language other than S on machine M.

SECTION-B

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

Q.No. Question Marks CO

1|Page
a. Discuss the various data structures used for symbol table with suitable example. 10 CO4
b. Explain in detail the process of compilation. Illustrate the output of each phase of 10 CO1
compilation of the input a=(b+c)* (b+c)*2
c. Write short Note on: 10 CO5

i) Loop Unrolling
ii) Loop Jamming
iii) Cross Compiler
iv) YACC Parser
v) LEX Parser
d. Consider the following grammar- 10 CO2
E → E + E | E x E | id
Construct Operator Precedence Parser and also find the Operator Precedence
Functions.
e. Write quadruple, triples and indirect triples for following expression: 10 CO3
(a + b) * (b + c) + (a + b + c)

SECTION-C

3. Attempt any one part of the following: 1 x 10 = 10

Q.No. Question Marks CO


a. Design DFA corresponding to the given RE using the direct method. Regular 10 CO1
Expression- ( a | b)* a b*

b. Convert regular expression- p q* ( p | q) to DFA by using Thompson’s construction 10 CO1


method and subset construction method

4. Attempt any one part of the following: 1 x 10 = 10

Q.No. Question Marks CO


a. Construct SLR parsing table for the following grammar and show the string 10 CO2
parsing for the input string- “yzxx”

S→AxB|Bc
A→yA|z
B→xB|ϵ

b. Write an algorithm for construction of predictive parsing table. Consider the 10 CO2
following grammar and construct predictive parsing table.

S → iEtS / iEtSeS / a
E→b

2|Page
5. Attempt any one part of the following: 1 x 10 = 10

Q.No. Question Marks CO


a. How DAG is different from syntax tree? Construct the DAG for the following 10 CO5
basic block.
a := b + c
b := b - d
c :=c + d
e :=b + c
Also explain the key application of DAG.
b. Write an algorithm to partition a sequence of statements into basic block. Apply 10 CO5
partition algorithm on below three address code and convert them into basic block.

1) i=1
2) j=1
3) t1 = 10 * i
4) t2 = t1 + j
5) t3 = 8 * t2
6) t4 = t3 - 88
7) a[t4] = 0.0
8) j = j + 1
9) if j <= goto (3)
10) i = i + 1
11) if i <= 10 goto (2)
12) i = 1
13) t5 = i - 1
14) t6 = 88 * t5
15) a[t6] = 1.0
16) i = i + 1
17) if i <= 10 goto (13)

6. Attempt any one part of the following: 1 x 10 = 10

Q.No. Question Marks CO

a. Define syntax directed translation. Construct an annotated parse tree for the 10 CO3
expression (4 * 7 + 1 ) * 2, using the simple desk calculator grammar.

b. Generate the three-address code for the given switch-case statement. 10 CO3
switch (a+b)
begin
case1: c=d+1
case2: c=d+2
default: c=d+3
end

3|Page
7. Attempt any one part of the following: 1 x 10 = 10

Q.No. Question Marks CO


a. How to sub-divide a run time memory into code and data areas. Explain. 10 CO4
b. What are lexical phase errors, syntactic phase errors and semantic phase errors? 10 CO4
Explain with suitable example.

4|Page

You might also like