0

I am writing this CFG to solve the problem:

$S \to ASBSC$

$A \to aAe ~|~ ε$

$B \to aBd ~|~ ε$

$C \to bcC ~|~ ε$

Is this correct or not?

Kai
  • 925
  • 5
  • 16
Yousaf
  • 1
  • 1

1 Answers1

0

Strings in your grammar could potentially terminate with a sequence of $bc$s because of the following, which is not desired.

$S \rightarrow ASBSC$

$C \rightarrow bcC \ | \ \epsilon$


The correct grammar in this case would be:

$S \rightarrow aSe \ | \ A \ | \ \epsilon$

$A \rightarrow aAd \ | \ B \ | \ \epsilon$

$B \rightarrow bBc \ | \ \epsilon$

ihsingh2
  • 35
  • 6