Question: The grammar G 2 is ambiguous. Give a string having two different parse trees in G 2 . For each of these parse trees, write

The grammar G2 is ambiguous. Give a string having two different parse trees in G2. For each of these parse trees, write down a derivation for the string.
Suppose we adopt the following disambiguating rule used in most languages: match each else with the closest previous unmatched then.
Using this disambiguating rule, write an unambiguous grammar that is equivalent to grammar G2.
Consider the following BNF grammar G2 used in the next two questions if expr then
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
