Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions