DrawGrammar
DrawGrammar copied to clipboard
Extract inlined rules
Some grammars have repetitions. Here is a benign example extracted from the OCaml manual:
\begin{syntax}
typexpr:
'(' typexpr { ',' typexpr } ')' typeconstr
| '(' typexpr { ',' typexpr } ')' '#' class-path
\end{syntax}
the '(' typexpr { ',' typexpr } ')'
part is duplicated.
If the user adds a rule like:
\begin{syntax}
typexpr-tuple:
'(' typexpr { ',' typexpr } ')'
\end{syntax}
DrawGrammar could allow her to "outline" it, i.e. draw typeexpr
as if it was defined as:
\begin{syntax}
typexpr:
typexpr-tuple typeconstr
| typexpr-tuple '#' class-path
\end{syntax}
This is exactly the reverse of what we've done in #2.