DrawGrammar icon indicating copy to clipboard operation
DrawGrammar copied to clipboard

Extract inlined rules

Open jacquev6 opened this issue 7 years ago • 0 comments

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.

jacquev6 avatar Aug 20 '17 08:08 jacquev6