Similarly, meaning is assigned to programming language constructs based on their syntax. We prefer, therefore that programming language grammars describe programs unambiguously.
A sentence is ambiguous if there is more than one distinct derivation. If a sentence is ambiguous, then the parse tree is not unique; we can create more than one parse tree for the same sentence.
A grammar is ambiguous if it can generate even one ambiguous sentence.
Ambiguous grammar for Expressions
Ambiguous grammar for IF-THEN-ELSE
Send questions and comments to: Karen Lemone