A context-free grammar that derives the same word by different derivation trees, or equivalently by different derivation sequences. A familiar programming language example is:
S → if C then S else S
S → if C then S
where S and C stand for statement and condition. This grammar is ambiguous since the following compound statement
if c1 then if c2 then s2 else s1
has two interpretations, corresponding with two derivation trees, as shown in the diagram. See also inherently ambiguous language.
Ambiguous grammar. Two derivation trees in an ambiguous grammar