Consider the grammar: S → AB | C A → aAb | ab B → cBd | cd C → aCd | aDd D → bDc | bc Show in particular that the string aa bb cc dd: (i) Parse tree; (ii) Leftmost derivation; (iii) Right most derivation; (iv) Is the grammar is ambiguous or not?




The string aa bb cc dd has two left most derivation and the two parse left most derivation and the two parse tree:
(i&ii)
S ⇒ AB
L.M.D
→ aAbB
→ aabbB
→ aabb CBd
→ aabb CCdd
Parse tree →

And,
S ⇒ C
L.M.D
→ aCd
→ aaDdd
→ aab Dcdd
→ aabbcdd
Parse tree →

(iii) Right most derivation:
S ⇒ AB
R.M.D
→ AcBd
→ Accdd
→ aAb ccdd
→ aabb ccdd
(iv) Yes, the grammar is ambiguous.

No comments

Dear Members, Thanks for Your Comments. We must be reply your comment answer as soon as possible. Please Stay with us.....

Theme images by ideabug. Powered by Blogger.