You are on page 1of 1

Homework 2

Individual Effort
Due Date: April 8, 2023
Write or type neatly. The solution should be clearly visible and easily readable.
Submit a single PDF file as: Name_ID_HW2.pdf

For each of the following grammars, determine the First and Follow sets after left-factoring and/or eliminating left-
recursion first. Show whether LL(1) property holds for each of the grammar.
First Production has the start symbol on LHS. Uppercase letters are non-terminals, while lowercase letters are terminal.

1) S → aABC | ℰ 5) S → MNOPQ
A → a | bbD M→m|ℰ
B→a|ℰ N→n|ℰ
C→b|ℰ O→o|ℰ
D→c|ℰ P→p|ℰ
Q→q|ℰ
2) A → BCc | eDB
B → ℰ | bCD 6) S → A
C → DaB | ca A → aB | Ad
D → ℰ | dD B→b
C→g
3) S → (X | E] | F)
X → E) | F] 7) S → AaAb | BbBa
E→A A→ℰ
F→A B→ℰ
A→ℰ

4) S → Xb | Yd
X → aX | ℰ
Y → cY | ℰ

Left-factor and eliminate the left-recursion from the following grammar.

E→E+T T→T*F F → id
E→E–T T→T/F F → num
E→T T→F F→(E)

Prove that the following grammars are ambiguous or un-ambiguous.

1) S → a | aAb | abSb
A → aAAb | bS

2) S → AB | aaaB
A → a | Aa
B→b

3) S → xyXxX | xyXyy | yy
X → xxX | yy | xx

You might also like