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

Printed Page:- Subject Code:- ACSBS0502

Roll. No:

NOIDA INSTITUTE OF ENGINEERING AND TECHNOLOGY, GREATER NOIDA


(An Autonomous Institute Affiliated to AKTU, Lucknow)
B.Tech.
SEM: V - THEORY EXAMINATION (2022 - 2023)
Subject: Compiler Design
Time: 3 Hours Max. Marks: 100
General Instructions:
IMP: Verify that you have received the question paper with the correct course, code, branch etc.
1. This Question paper comprises of three Sections -A, B, & C. It consists of Multiple Choice Questions
(MCQ’s) & Subjective type questions.
2. Maximum marks for each question are indicated on right -hand side of each question.
3. Illustrate your answers with neat sketches wherever necessary.
4. Assume suitable data if necessary.
5. Preferably, write the answers in sequential order.
6. No sheet should be left blank. Any written material after a blank sheet will not be evaluated/checked.

SECTION A 20

1. Attempt all parts:-

1-a. Lexical analysis is about breaking a sequence of characters into ________________ . 1


(CO1)

(a) Tokens
(b) Lines
(c) Groups
(d) Packets

1-b. ______ is/are parts of the compiler. (CO1) 1

(a) Execution part


(b) Analysis part
(c) Synthesis part
(d) Both Analysis part and Synthesis part

1-c. CLR parsing is a type of __________________ . (CO2) 1

(a) Bottom-Up
(b) Top-Down

Page 1 of 4
(c) Both Bottom Up and Top Down Parsing
(d) None of above

1-d. In which derivation, the Right-most non-terminal symbol is replaced at each step. (CO2) 1

(a) Rightmost derivation


(b) Leftmost derivation
(c) Both Rightmost and Leftmost Derivation
(d) None of above

1-e. Who is responsible for the creation of the symbol table? (CO3) 1

(a) Assembler
(b) Compiler
(c) Interpreter
(d) None of above

1-f. Full form of SDD is ____________ . (CO3) 1

(a) Syntax Directed Definition


(b) Syntax Directed Dictionary
(c) Both Syntax Directed Definition and Syntax Directed Dictionary
(d) None of the above

1-g. Peephole optimization is _______________ . (CO4) 1

(a) Time Optimization


(b) Code Optimization
(c) Machine Code
(d) None of above

1-h. Which of the following is Three address code form ? (CO4) 1

(a) Quadruples
(b) Triples
(c) Indirect Triples
(d) All of the above.

1-i. Code generation can be considered as the ____________ . (CO5) 1

(a) first phase of compilation


(b) second phase of compilation
(c) third phase of compilation

Page 2 of 4
(d) final phase of compilation

1-j. In Directed Acyclic Graph, Leaf nodes represented by ___________ . (CO5) 1

(a) Identifiers
(b) Names
(c) Constants
(d) All of the above

2. Attempt all parts:-

2.a. Differentiate between Analysis and Synthesis phase. (CO1) 2

2.b. Define a context free grammar. (CO2) 2

2.c. Define Inherited attribute with example. (CO3) 2

2.d. Define Basic Block and flow graph. (CO4) 2

2.e. What are the advantages and disadvantages of register allocation and assignments? 2
(CO5)

SECTION B 30

3. Answer any five of the following:-

3-a. Analyze the given expressions a:= b*c-d with different phases of the compiler. (CO1) 6

3-b. Explain Language Processing System with neat diagram. (CO1) 6

3-c. Write a short note on: (CO2) 6


(i) Ambiguity (with example),
(ii) Recursive Descent Parser
(iii) Handle pruning.

3-d. Explain Operator Precedence Parsing with example. (CO2) 6

3.e. Draw the format of activation record in stack allocation and Explain each field in it. (CO3) 6

3.f. Write the Quadruples, Triples for the following expression (x + y)*(y + z) + (x + y + z) . 6
(CO4)

3.g. Write briefly about various loop optimization techniques. (CO5) 6

SECTION C 50

4. Answer any one of the following:-

4-a. What are the phases of compiler? Explain in detail. (CO1) 10

4-b. Define Lex and Lex specifications. How lexical analyzer is constructed using lex? Give an 10
example. (CO1)

Page 3 of 4
5. Answer any one of the following:-

5-a. What is the difference between CLR and LALR parsing? Explain using an example. 10
(CO2)

5-b. What do you understand by left factoring and left recursion and how it is eliminated? 10
(CO2)

6. Answer any one of the following:-

6-a. Consider the following Syntax Directed Translation Scheme (SDTS) using below SDTS 10
construct parse tree and annotated parse tree for the expression:
"S = 2+3*4." (CO3)
E->E+T { E.val = E.val + T.val }
E -> T { E.val = T.val }
T -> T*F { T.val = T.val * F.val }
T -> F { T.val = F.val }
F -> INTLIT { F.val = INTLIT.lexval }

6-b. What is the role of symbol table ? Discuss different data structures used for symbol table. 10
(CO3)

7. Answer any one of the following:-

7-a. Write short notes on: (CO4) 10


a) Code motion
b) Induction-variable elimination
c) Strength reduction

7-b. Explain what constitute a loop in a flow graph and how will you do loop optimizations in 10
code optimization of a compiler? (CO4)

8. Answer any one of the following:-

8-a. Define Directed Acyclic Graph. Write the Algorithm for Construction of DAG. For the 10
following Basic Block , Construct DAG. (CO5)
d = b * c;
e = a * b;
b = b + c;
c = b * c;

8-b. Describe Following Concepts in Compilation: (CO5) 10


(i) Object-Oriented features,
(ii) Data abstraction
(iii) Register allocation

Page 4 of 4

You might also like