doc/refintro.tex: Explain what parentheses mean in production rules.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 20 Aug 2019 11:27:30 +0000 (12:27 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 20 Aug 2019 11:29:51 +0000 (12:29 +0100)
They're used in the actual grammar, so this is probably a good idea.

doc/refintro.tex

index 6689505..349f7b0 100644 (file)
@@ -99,6 +99,32 @@ The letter $\epsilon$ denotes the empty nonterminal
 \end{quote}
 
 
+\subsection{Parentheses}
+
+Parentheses are used for grouping of alternatives within the right-hand side
+of a production rule.  Specifically, a right-hand side
+\begin{quote}
+  \syntax{$\alpha$ @($\beta_1$ @! $\beta_2$ $| \cdots |$ $\beta_n$@) $\gamma$}
+\end{quote}
+where $\alpha$, $\beta_i$, and $\gamma$ are any sequence of nonterminal
+symbols or parenthesized groups, is equivalent to the right-hand side
+\begin{quote}
+  \syntax{$\alpha$ $b$ $\gamma$}
+\end{quote}
+together with the new production
+\begin{quote}
+  \syntax{$b$ ::= $\beta_1$ @! $\beta_2$ $| \cdots |$ $\beta_n$}
+\end{quote}
+where $b$ is a new nonterminal symbol.
+
+Given the indexed-nonterminal notation described below, one might consider a
+group \syntax{@($\beta_1$ @! $\beta_2$ $| \cdots |$ $\beta_n$@)} equivalent
+to \syntax{<group>@[$\beta_1$ @! $\beta_2$ $| \cdots |$ $\beta_n$@]}, where
+\begin{quote}
+  \syntax{<group>@[$x$@] ::= $x$}
+\end{quote}
+
+
 \subsection{Indexed nonterminals}
 
 Anywhere a simple nonterminal name $x$ may appear in the grammar, an