Language generated by context free grammar

58 Views Asked by At

I studied about CFG and one point confused my mind. If rules of grammar given like that;

$S \to AB\ |\ C$

then continue with rules of $A$, $B$, $C$ or other nonterminals. Should we define $L(G)$ like that;

$L(G) = \{a^nb^n \cup c^m: n,m \geq 0 \}$ where $AB = \{a^nb^n: n \geq 0 \}$ and $C = \{C^m:m \geq 0 \}$

I assumed $L(G)$ like that and I only try to ask should we combine $AB$ and $C$ in the definition of the language like above?

1

There are 1 best solutions below

0
On

Yes, it's possible, such that :

$A→\in$

$B→aBb|\in$

$C→cC|\in$


Or,

$B→\in$

$A→aAb|\in$

$C→cC|\in$