Let G = (V,,R, hSTMTi) be the following grammar. G is a natural-looking grammar for a fragment

Question:

Let G = (V,,R, hSTMTi) be the following grammar.

 (STMT) → (ASSIGN) | (IF-THEN) | (IF-THEN-ELSE) (IF-THEN) if condition then (STMT) (IF-THEN-ELSE) → if condition then (STMT) else (STMT) (ASSIGN) → a:=1 E= {if, condition, then, else, a:=1} V = {{STMT), (IF-THEN), (IF-THEN-ELSE), (ASSIGN)}


G is a natural-looking grammar for a fragment of a programming language, but G is ambiguous.

a. Show that G is ambiguous.

b. Give a new unambiguous grammar for the same language.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: