due: Wednesday, September 18
Consider a simple markup language that uses tags. Its terminals are {<, >, /, =, word}. Every tag begins with < and ends with >. The first token in an open tag is a word representing its name, followed by an optional list of attributes which are pairs of words related by =. Every open tag must be paired with a close tag, which is a tag with / before the name and no attributes. Any number of words or tags may appear between and open and close tags. A sentence of the whole language consists of an arbitrary number of words and tags.
For example, here is a valid string from this grammar:
<word word=word word=word><word>word word word</word><word></word></word>
Consider the following grammar:
E → E op E | (E) | num
op → + | * | ^
This grammar is ambiguous; we would like the grammar to have parse trees in which exponentiation (^) has higher precedence than multiplication (*), and both have higher precedence than addition (+).