Reading: Webster Ch. 3
Show that the following grammar is ambiguous. (To show this, you must demonstrate that it can generate two parse trees for the same string).
<exp> ::= <exp> + <exp>
| <exp> * <exp>
| ( <exp> )
| a | b | c
Redefine the following grammar to be unambiguous.
<exp> ::= <exp> + <exp>
| <exp> * <exp>
| ( <exp> )
| a | b | c
<exp> ::= <exp> + <rootexp> | <exp> * <rootexp> | <rootexp>
<rootexp> ::= ( <exp> ) | a | b | c
Show that the following grammar is ambiguous.
<s> ::= <round> <square> | <outer>
<round> ::= ( <round> ) | ()
<square> ::= [ <square> ] | []
<outer> ::= ( <outer> ] | ( <inner> ]
<inner> ::= ) <inner> [ | ) [