0

Hi I have the following CFG

S -> aA | bC | CC
A -> B
B -> S | epsilon
C -> A | S

I have managed to remove the epsilon resulting to:

S -> aA | bC | CC | a | b | C
A -> B
B -> S
C -> A | S

Im in the point of removing unit rules and it resulted in all nonterminals having the same result like:

S -> aA | bC | CC | a | b | C
A -> aA | bC | CC | a | b | C
B -> ...
C -> ...|...

My question is, is my elimination of epsilon correct? Is there anyway of doing it?

  • 1
    I'm voting to close this question as off-topic because it is not (yet) a programming question. – Raymond Chen Dec 12 '16 at 15:59
  • Since `S` can produce an empty string, it will not be possible to eliminate *all* epsilon rules, but it is usually considerable acceptable to leave the single rule `S → ε` – rici Dec 12 '16 at 18:51

0 Answers0