Prove that the following grammar is ambiguous a b
Prove that the following grammar is ambiguous:
<exp> ::= <exp> + <exp>
| <exp> * <exp>
| ( <exp> )
| a | b | c
Solution
exp => exp + exp
=>exp * exp + exp ( exp -> exp*exp)
=>a * exp + exp (exp ->a)
=>a*b+exp (exp->b)
=> a*b+c (exp->c)
exp =>exp + exp
=>exp+exp * exp (exp->exp * exp)
=>a +exp * exp (exp->a)
=>a+b*exp (exp->b)
=>a+b*c (exp->c)
 
 thus this grammer defines two different derivations / parse trees.
 So that it is said ambiguouse grammer.

