0% found this document useful (0 votes)
42 views3 pages

Set-1 Ese Dec22 B Tech (Cse+Ai&Ml) B Tech (Cse+Ai&Ml) (Hons.) V Cseg3015 Compiler Design

The document outlines the End Semester Examination for the Compiler Design course at the University of Petroleum and Energy Studies, detailing the structure of the exam including sections A, B, and C with specific questions and marks allocation. It covers various topics such as syntax-directed definitions, error handling in parsing, code optimization, and parsing tables. The exam is designed for BTech CSE students and includes both theoretical and practical components.

Uploaded by

Manjari Yagnik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views3 pages

Set-1 Ese Dec22 B Tech (Cse+Ai&Ml) B Tech (Cse+Ai&Ml) (Hons.) V Cseg3015 Compiler Design

The document outlines the End Semester Examination for the Compiler Design course at the University of Petroleum and Energy Studies, detailing the structure of the exam including sections A, B, and C with specific questions and marks allocation. It covers various topics such as syntax-directed definitions, error handling in parsing, code optimization, and parsing tables. The exam is designed for BTech CSE students and includes both theoretical and practical components.

Uploaded by

Manjari Yagnik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Name:

Enrolment No:

UNIVERSITY OF PETROLEUM AND ENERGY STUDIES


End Semester Examination, December 2022
Course: Compiler Design Semester: V
Program: BTech CSE (All Branches) Time : 03 hrs.
Course Code: CSEG3015 Max. Marks: 100

Instructions: Attempt all Questions


SECTION A
(5Qx4M=20Marks)
S. No. Marks CO
Q1 Give the syntax-directed definition for if-else statement. 4 CO1
Q2 Discuss the error handling mechanism in Parsing Phase. 4 CO2
Q3 Draw a DAG for the expression a + a*(b-c) +(b-c) *d 4 CO3
Q4 Mention the issues to be considered while applying the techniques for
4 CO4
code optimization.
Q5 Illustrate the properties of optimizing compiler. 4 CO1
SECTION B
(4Qx10M= 40 Marks)
Q6 Construct SLR (1) Parsing table for the given grammar.
S→P
P → (P)P
P→ε
10 CO2
Also identify at least one entry in the Parsing table that would be a
Shift/Reduce or Reduce/Reduce Conflict.

Q7 Give a CFG for the language {0i1j2k | i+j > 2k} 10 CO3
OR
Q7 Consider the CFG given below: -
S → EN
E→E+T|E–T|T
T→T*F|T/F|F 10 CO3
F → (E) | digit
N→;
(a) Obtain the Syntax Directed Definition for the above grammar.
(b) Construct the annotated parse tree for the input string 5*6 +7.

Q8 Demonstrate activation trees. Construct an activation tree for quick sort. 10 CO4
Q9 Programming languages are usually compiled into the machine code of
the target computer, but sometimes an interpretive system is used.
Discuss the relative merits of these two approaches.
10 CO1
Outline the key features of the design of an interpretive code that would
be suitable for an implementation of the C programming language and
describe the overall structure of an interpreter for it.

SECTION-C
(2Qx20M=40 Marks)
Q 10 Suppose that we want to describe Java style class declarations like these
using a grammar:

class Car extends Vehicle


public class JavaIsCrazy implements Factory, Builder, Listener
public final class President extends Person implements Official

One such grammar for this is


(1) C → P F class identifier X Y
(2) P → public
(3) P → ε
(4) F → final
(5) F → ε 20 CO2
(6) X → extends identifier
(7) X → ε
(8) Y → implements I
(9) Y → ε
(10) I → identifier J
(11) J →, I (note the comma before the I)
(12) J → ε

Construct an LL (1) parser table for this grammar. When indicating


which productions should be performed, use the numbering system from
above.

Q 11 Construct SLR (1) Parsing table for the grammar given below:
S→R
R → RR
20 CO3
R→R|R (note that | is a terminal symbol in the grammar)
R → R*
R→ε (note that ε is a terminal symbol in the grammar)
R→a
R → (R)

Resolve the conflicts (if any) by using precedence rules for regular
expressions. LR (1) is a much stronger parsing algorithm than SLR (1).
Would using an LR (1) parser instead of the SLR (1) parser resolve the
ambiguities? Why or why not?

OR

Q 11 Identify the basic blocks, draw a flow graph, and identify the loop
invariant statement for the following code snippet.

for ( i = 1 to n ) 20 CO3
{ a[i] =0;
}

You might also like