That's not true because there are other ambiguous grammars that don't have either of those rules.
For example cc
can be produced by A -> Bc -> cc
but also by A -> cC -> cc
in the following grammar:
A -> Bc | cC
B -> c
C -> c
Pregunta
In my notebook I wrote:
The necessary condition for grammar ambiguity is
A->BB
, where A and B are non-terminals.A->a|b
, where A is a non-terminal and {a,b} are terminals.Would you please confirm or refute this statement?
Solución
That's not true because there are other ambiguous grammars that don't have either of those rules.
For example cc
can be produced by A -> Bc -> cc
but also by A -> cC -> cc
in the following grammar:
A -> Bc | cC
B -> c
C -> c