R: S ---> aSb
S ---> SS
S ---> ε
How should I write the grammar for these expressions?
Is it true to writing like this?
G = ({S}, {a, b}, {S ---> aSb, S ---> SS, S ---> ε}, {S})
or like this (adding epsilon to terminals):
G = ({S}, {a, b, ε}, {S ---> aSb, S ---> SS, S ---> ε}, {S})
which is the correct one?
ε is a way to make a zero- length sequence visible. It is not a grammar symbol.
The actual production is:
S →
— that is,S
can produce nothing — but the invisibility of nothing makes it hard to read. So we usually write ε, which is more legible. You should read it as nothing, though.