Starting from:

$24.99

CS320 Assignment 6-Context Free Grammars Solution

⟨id⟩ ::= a | b | c | ... | z
⟨dig⟩ ::= 0 | 1 | 2 | ... | 9
⟨expr⟩ ::= () | ⟨dig⟩ | ⟨id⟩
| let ⟨id⟩ = ⟨expr⟩ in ⟨expr⟩
| ⟨expr⟩ ; ⟨expr⟩
| begin ⟨expr⟩ end
Demonstrate the grammar above is ambiguous.
1
2. Modify the grammar (reproduced below) to be unambiguous. Hint: There is not just one way.
⟨id⟩ ::= a | b | c | ... | z
⟨dig⟩ ::= 0 | 1 | 2 | ... | 9
⟨expr⟩ ::= () | ⟨dig⟩ | ⟨id⟩
| let ⟨id⟩ = ⟨expr⟩ in ⟨expr⟩
| ⟨expr⟩ ; ⟨expr⟩
| begin ⟨expr⟩ end
Page 2
3. Demonstrate your modified grammar fixes the previously shown ambiguity.
Page 3

More products