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

Cse 323 Mid

This document contains a mid-term examination for a Compiler Design course. It includes 3 questions assessing different course outcomes related to compiler design concepts. Question 1 has two parts asking the student to (a) convert a high-level language statement to low-level language and identify lexical errors in a code block, and (b) perform left factoring on two context-free grammars and explain its purpose. Question 2 asks the student to (b) write a regular expression and transition diagram for detecting floating point numbers. Question 3 asks the student to (a) simulate recursive descent parsing on an input string using a grammar and (b) determine if another grammar is LL(1) and simulate table-driven predictive parsing if possible

Uploaded by

BD Entertainment
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)
91 views3 pages

Cse 323 Mid

This document contains a mid-term examination for a Compiler Design course. It includes 3 questions assessing different course outcomes related to compiler design concepts. Question 1 has two parts asking the student to (a) convert a high-level language statement to low-level language and identify lexical errors in a code block, and (b) perform left factoring on two context-free grammars and explain its purpose. Question 2 asks the student to (b) write a regular expression and transition diagram for detecting floating point numbers. Question 3 asks the student to (a) simulate recursive descent parsing on an input string using a grammar and (b) determine if another grammar is LL(1) and simulate table-driven predictive parsing if possible

Uploaded by

BD Entertainment
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

Bangladesh University of Business & Technology (BUBT)

Department of Computer Science and Engineering


Mid-Term Examination: Summer 2021
Course Code: CSE 323 │Course Title: Compiler Design
Intake: 43, Shift: Day

Time: 2 hrs. Marks – 30


[Answer all the questions]

Outcome SLN Questions Marks


CO1 1. (a) Explain how a compiler converts the following high-level 6
language statement into a statement of low level language:
z = (n/a) * (r+a) / (p – q)
[Here, replace r with the last digit of your ID and replace p with the
first letter of your name (in lowercase letter).]
CO1 (b) Consider the following block of code: 4

int n=10, i, @sum = 0;


printf("Sum is:);
//calculation is done here
fro (i = 1; i <= n; I++) {
sum += i
)
.................

There are some errors in the given block of code. Which of the
errors will be found by the lexical analyzer and which will not?
Correct only the lexical errors. Then convert the corrected block of
code into stream of tokens.

Page | 1
CO1 2. (a) Consider the following context free grammars (CFG): 5
i. ii.
B→ dBb | bBd | dCb E→FG
C→aC | Ɛ F→ fgFg | fgGg | f
G→ g

Do left factoring of the above grammars (if necessary).


Why is it needed to do left factoring of a grammar? Explain with
proper example.

CO1 (b) Write down the regular expression and draw the transition 5

diagram of how a lexical analyzer will detect all the positive or


negative floating point numbers (eg. 1.5, .45, 2. , – 98. , – 6.71,– .39
etc.).
CO2 3. (a) Consider the following grammar:
4
S→ 1PQ | P1Q
P→0P | Ɛ
Q→ 0Q | 1Q | Ɛ
Show the simulation of Recursive Descent Parsing using the above
grammar for the input string: 0110

CO2 (b) Identify if the following grammar is LL(1) or not. 6

X→ Xcd | Yb | Zc
Y→b
Z→a| Ɛ
Show the simulation of Table-Driven Predictive Parsing using the
above grammar for the input string “bbcd”, if possible.
[Here, replace c in every case with the first letter of your name (in

Page | 2
lowercase character)]

Page | 3

You might also like