Eliminating common prefix:
A -> bdA' | epsilon
A' -> c MidPart A' | epsilon (I've added the spaces only
for readability)
MidPart -> d | epsilon
2. terminals: text, <html>, </html>, <p>, </p>, <ul>,
</ul>, <li>, </li>,
<MD!name>, </MD>, <MU!name>, <B>, and </B>.
document :: <html> macro-decls body </html>
macro-decls :: <MD!name> body </MD> macro-decls | epsilon
body :: inner-scope body
| inner-command body
| text body
| epsilon
inner-scope :: <p> macro-decls body </p>
| <ul> macro-decls list-items </ul>
list-items :: <li> macro-decls body </li> list-items
| epsilon
inner-command :: <B> body </B> | <MU!name>