Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Ce 705

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

Date:15/11/2022 Enrolment No.

:___________________

RK UNIVERSITY
B.TECH./SEM-VII/REGULAR/NOV-2022

CE705: COMPILER DESIGN

Time: 01:30 PM TO 04:30 PM Total Marks: 100

Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.
4. Programmable calculator is not permissible.

SECTION – I

Q.1 (a) Select the most appropriate option: (Each of one mark) 06
1. The total number of tokens that are present in the following
statement in C is:
printf(“i=%d, &i=%x”, i&i);
a. 6
b. 10
c. 9
d. 13
2. Look at the grammar A → AA | (A) | ε
It is not suitable for the process of predictive-parsing since the
grammar is:
a. an operator-grammar
b. right-recursive
c. left-recursive
d. ambiguous
3. What is the linker?
a. It is always used before the program execution.
b. It is required to create the load module
c. It is the same as the loader
d. None of these
4. Left factoring is the process of factoring out the common
a. Prefixes of alternates
b. Suffixes of alternates
c. Both a and b
d. None of these

Page 1 of 5
5. Which of the following component is important for semantic
analysis?
a. Yacc
b. Lex
c. Symbol Table
d. Type Checking
6. Which derivation uses a top-down parser while parsing some input
strings? Assume that the input is scanned in the order of left to
right.
a. The rightmost derivation that is traced out in reverse
b. The rightmost derivation
c. The leftmost derivation that is traced out in reverse
d. The leftmost derivation

(b) Answer following questions: (Each of two mark) 10


1. Write down the regular expression for:
1) String starts and ends with same character.
2) String of 0 and 1 end with 00
2. Write down 4 features of compiler.
3. S -> (S) | SS | ∈
Derive string “()(()(()))()”
4. State the role of lexical analyzer.
5. Write a brief note on 3 types of translators.

Q.2 (a) Design NFA for a regular expression r= ((a⋅ b)|c)*. Also, Convert 06
NFA into DFA.
(b) Explain phases of compiler using example of Position = initial + rate 05
* 60
(c) Construct LL(1) parsing table for the following grammar. 05
E -> E + T | T
T -> T * F | F
F ->(E) | a | b
Also parse the string id+id*id
OR
Q.2 (a) Consider the following grammar- 06

S→(L)|a

L→L,S|S

Construct the operator precedence parser and parse the string ( a , ( a ,


a ) ).

Page 2 of 5
(b) Discuss LR(0) parser for the grammar. Also Draw DFA and parsing 05
table.
1. S → AA
2. A → aA | b
(c) Consider the grammar 05
S –> S + S
S –> S * S
S –> id
Perform Shift Reduce parsing for input string “id + id + id”.

Q.3 (a) Discuss different types of parsing in detail. 06


(b) Find FIRST and FOLLOW function for following grammar. 06
S → (L) / a
L → SL’
L’ → ,SL’ / ∈
(c) Consider the grammar- 06
S → A1B
A → 0A / ∈
B → 0B / 1B / ∈
For the string w = 00101, find-
1. Leftmost derivation
2. Rightmost derivation
3. Parse Tree
OR
Q.3 (a) Construct CLR parsing table for 06
S → AA
A → aA
A→b
(b) S-> aSbS | bSaS | 06
Show that the string “abab” can be generated by the grammar.
Construct the parse tree for it. Is the grammar ambiguous? Justify.
(c) Describe about Syntax Directed Translation with suitable example. 06

SECTION – II

Q.4 (a) Select the most appropriate option: (Each of one mark) 06
1. Which is not True for Data flow Analysis.
a. Useful in register allocation
b. Dead code elimination is not possible
c. Eliminates common sub expression
d. Used in constant and variable propagation

Page 3 of 5
2. Which one of the following is FALSE?
a. A basic block is a sequence of instructions where control enters
the sequence at the beginning and exWhich one of the following
is FALSE?ists at the end
b. Available expression analysis can be used for common sub-
expression elimination
c. Live variable analysis can be used for dead code elimination
d. x=4 * 5=>x=20 is an example of common subexpression
elimination
3. Which is not the type of storage allocation strategies
a. Static allocation
b. Stack allocation
c. Heap allocation
d. memory allocation
4. Which of the following structure has four fields?
a. Parse Tree
b. Quadruples
c. Triples
d. Indirect Triples
5. Which of the following statements about peephole optimization is
False?
a. It is applied to a small part of the code
b. It can be used to optimize the Intermediate code
c. To get the best out of this,it has to be applied repeatedly.It can
be applied to the portion of the code that is not contiguous
d. It can be applied to the portion of the code that is not contiguos
6. DAG is an abbreviation of ?
a. Detecting Acyclic Graph
b. Data Acyclic Graph
c. Dynamic Acyclic Graph
d. Directed Acyclic Graph

(b) Answer following questions: (Each of two mark) 10


1. What is copy propagation?
2. Define the term data flow analysis.
3. What is heap allocation?
4. Construct a DAG for a:= b*- c+ b* - c
5. What is a Flow graph.?

Q.5 (a) Discuss different storage allocation strategies 10


(b) Write short notes on Activation trees 06
OR
Q.5 (a) Discuss- Quadruples,Triples and Indirect Triples with example 06
Page 4 of 5
(b) Discuss Register allocation 05
(c) Write notes on Peephole optimization 05

Q.6 (a) Explain the various issues in design of a code generator. 06


(b) Elaborate code generation algorithm 06
(c) Brief Next Use Information 06
OR
Q.6 (a) Write notes on Strength reduction 06
(b) Discuss about common sub- expression elimination with example 06
(c) Write notes on Data flow analysis 06

*************

Page 5 of 5

You might also like