(25 points) The following grammar generates declarations for
a single identifier:
<stmt> -> declare <id> <option_list>
<option_list> -> <option_list> <option> | epsilon
<option> -> <mode> | <scale> | <precision> | <base>
<mode> -> real | complex
<scale> -> fixed | floating
<precision> -> single | double
<base> -> binary | decimal
where "epsilon" is the empty symbol.
As you can see, this grammar permits redundant or contradictory
declarations
such as:
declare zippy real fixed real floating
Our goal is to revise the grammar so that it forbids such obviously
incorrect declarations. Write a grammar for legal declarations, where
legal means each option appearing at most once (so there can be at most
one mode, one scale, one precision, and one base). It is legal to not
have anything specified for one or more (or all) of the options. So,
just
declare zippy
is legal.