I'd like to represent a grammar where rules are numbered (for example, the following grammar: http://en.wikipedia.org/wiki/LR_parser#Additional_Example_1.2B1), in order to refer to those rules later in an action table. However, I don't find any way to do this properly. Ideally, the rules numbers would be right-aligned, like in a alignat environment.
Currently, I simply put the numbers directly in the grammar, and the output is not really readable.
My code:
\documentclass[11pt]{article}
\usepackage{syntax}
\begin{document}
\setlength{\grammarparsep}{20pt plus 1pt minus 1pt}
\setlength{\grammarindent}{12em}
\begin{grammar}
<E> ::= <E> \lit{*} <B> (1)
\alt <E> \lit{+} <B> (2)
\alt <B> (3)
<B> ::= \lit{0} (4)
\alt \lit{1} (5)
\end{grammar}
\end{document}
(note that the E and B were between 'less than' and 'greater than' symbols, I removed them from the listing because they seem to badly interact with stackexchange).
