You are on page 1of 2

Department of Computer Science and Engineering

Bangladesh University of Engineering and Technology


CSE 309 (Compiler)
Class Test: 2, Full Marks: 20, Time: 30 minutes
Wednesday 11th January, 2023

Student Number: Name:

Signature of Student:

There are 8 questions in 2 pages. Please make sure that you got all of them. Answer in the
space below each question, no extra paper shall be supplied.

1. Comment, with proper reasons, on the usability of the universal parsing methods in (1)
production compilers.

2. Eliminate left recursion from the grammar: S → Br | a, B → Cs | b, C → St | c. (4)

3. Left factor the grammar: S → aSSbS | aSaSb | abb | b. (2)

4. Consider the two grammars, Grammar 1: A → aA | bd, B → aB | cc and (2)


Grammar 2: A → aA | ad, B → bB | cc. Both of these grammars have at least two
bodies of the production rules beginning with an a. Explain in detail with proper
justifications why one of the grammars is LL(1) while the other is not.

Page 1 of 2
5. Create a predictive parsing table for the grammar: A → aB | b, B → baB | ϵ. (2)

6. Augment the grammar, S → S + V | V , V → a | b and hence construct the initial set (5)
of LR(0) items and the immediate sets of items generated from the initial set.

7. For the grammar in Question 6, write down the first two lines of the SLR parsing table. (3)

8. Write down the relationship between configuration lookahead and FOLLOW(A), (1)
where A is the nonterminal the handle will be reduced to in CLR.

Page 2 of 2

You might also like