In the last post, We saw 2 possible parse trees for a+a+a. How many are there for a+a+a+a?
There are 5 possible parses:
(a)+((a+a)+a),
(a)+(a+(a+a)),
(a+a)+(a+a),
((a+a)+a)+(a),
(a+(a+a))+(a)
While in general it may be difficult to prove a grammar is ambiguous, the demonstration of two distinct parse trees for the same terminal string is sufficient proof that a grammar is ambiguous.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment