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

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 | other expr : := true | false where other is a terminal that stands for any other kinds of statements, and is the start non-terminal

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!