Aspire's Library

A Place for Latest Exam wise Questions, Videos, Previous Year Papers,
Study Stuff for MCA Examinations - NIMCET

Previous Year Question (PYQs)



The following code:

stmt → if expr then stmt else stmt
      | if expr then stmt

suffers from:





Solution

This grammar produces the dangling-else problem.

In such cases the else can be associated with more than one if, producing more than one parse tree.


Thus the grammar is ambiguous.



Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More

Ask Your Question or Put Your Review.

loading...