Consider the grammar G2 that is shown below:
G2: <pet> ::= <mammal> |
<reptile>
<mammal> ::= cat | dog |
<empty>
<reptile> ::= turtle | snake |
<empty>
Using the grammar given above, answer the following
questions:
(5 points) Show that the above grammar is
ambiguous.
(5 points) Give an unambiguous grammar for the same
language generated by the grammar above.
Consider the grammar G2 that is shown below: G2: ::= | ::= cat | dog |
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am