CS 340: Lab 4: Solution
CFG (start symbol is X):
X → ε
X → L
L → E
L → E L
E → a
E → ( E )
E → [ E ]
Derivation
String | Production |
---|---|
X | X → L |
L | L → E L |
E L | E → a |
a L | L → E L |
a E L | E → ( E ) |
a ( E ) L | E → ( E ) |
a ( ( E ) ) L | E → a |
a ( ( a ) ) L | L → E |
a ( ( a ) ) E | E → [ E ] |
a ( ( a ) ) [ E ] | E → a |
a ( ( a ) ) [ a ] |