Reputation: 1
Say there are two grammar rules
Rule 1 B -> aB | cB
and
Rule 2 B -> Ba | Bc
I'm a bit confused as the difference of these two. Would rule 1's expression be (a+c)* ? Then what would Rule 2's expression be?
Upvotes: 0
Views: 38
Reputation: 241971
Both of those grammars yield the empty language since there is no non-recursive rule, so no sentence consisting only of terminals can be derived.
If you add the production B→ε
, both grammars would yield the same language, equivalent to the regular expression (a+c)*
. However, the parse trees produced by the parse would be quite different.
Upvotes: 1