You are on page 1of 2

Bangladesh University of Business & Technology (BUBT)

Department of Computer Science and Engineering


Mid-Term Examination: Fall 2021-22
Course Code: CSE 323 │Course Title: Compiler Design
Intake: 42, Program: BSc. in CSE

Time: 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 = (a+b) * (c/d) - (e/f)
[Here, replace c with the last digit of your ID and replace e with the
first letter of your name (in lowercase letter).]
CO1 (b) Palindrome strings are defined as follows: 4

S1 = x;
S2 = y;
Sk = Sk-2Sk-1 Sk-1Sk-2; where k > 2
For example, S3=xyyx.
Define failure function and compute the failure function for S4.
CO1 2. (a) Consider the following grammar: 5
S → aSd | ptr | xt
T → TaW | xy|W| fW| dcW
W → WRa | R | bc
R → Rb | c | d | mnz | Wd

Is the grammar left recursive? Why or why not? What problem does
it create if there is any left recursion in a grammar? Explain Briefly.
Eliminate left recursion from the given grammar (if there is any).
CO1 (b) Draw the transition diagram of how a lexical analyzer will 5

detect all the positive or negative integers and floating point

Page | 1
numbers (eg. -5, 1.5, -0.45, 2, – 98.6 , 6.71 etc.).
CO2 3. (a) Consider the following grammar:
4
S → A$
A → -AB | idCD
B → -B | +
C → +| - | .id
D → x| y| _id
Show the simulation of Recursive Descent Parsing using the above
grammar for the input string: id . id _ id $
CO2 (b) Identify if the following grammar is LL(1) or not. 6

A→ Acd | BaBb | CbCa


B→bx | by
C→a| Ɛ
Show the simulation of Table-Driven Predictive Parsing using the
above grammar for the input string “babb”, if possible.

Page | 2

You might also like