X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/7292d6e1bc85cca454f64353722ba78a9263f257..638cd32270bb6aa0596a594f590d2f093be5fd7a:/doc/refintro.tex

diff --git a/doc/refintro.tex b/doc/refintro.tex
index ead5ace..6f3938a 100644
--- a/doc/refintro.tex
+++ b/doc/refintro.tex
@@ -90,18 +90,68 @@ manual describes the base system as provided in the distribution.
 Fortunately, Sod is syntactically quite simple.  The notation is slightly
 unusual in order to make the presentation shorter and easier to read.
 
+
+\subsection{Empty production}
+
+The letter $\epsilon$ denotes the empty nonterminal
+\begin{quote}
+  \syntax{$\epsilon$ ::=}
+\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
 \emph{indexed} nonterminal $x[a_1, \ldots, a_n]$ may also appear.  On the
 left-hand side of a production rule, the indices $a_1$, \ldots, $a_n$ are
 variables which vary over all nonterminal and terminal symbols, and the
 variables may also appear on the right-hand side in place of a nonterminal.
-Such a rule stands for a family of rules, in each variable is replaced by
-each possible simple nonterminal or terminal symbol.
-
-The letter $\epsilon$ denotes the empty nonterminal
+Such a rule stands for a family of rules, in which each variable is replaced
+by each possible simple nonterminal or terminal symbol.
+
+As a notational convenience, where an indexed nonterminal appears on the
+right-hand side of a production rule, each actual argument may be a sequence
+of alternative right-hand sides, separated by `$|$', rather than a a simple
+terminal or nonterminal symbol.  A complex indexing of this form, say
+\syntax{$x$@[$\alpha_1^1$ | $\alpha_1^2$ | $\cdots$ | $\alpha_1^{m_1},
+\ldots,$ $\alpha_n^1$ | $\alpha_n^2$ | $\cdots$ | $\alpha_n^{m_n}$@]} means
+exactly the same as \syntax{$x$@[$a_1, \ldots, a_n$@]} with the additional
+rules
 \begin{quote}
-  \syntax{$\epsilon$ ::=}
+  \syntax{$a_1$ ::= $\alpha_1^1$ | $\alpha_1^2$ | $\cdots$ | $\alpha_1^{m_1}$} \\*
+  \hbox{}\qquad $\vdots$ \\*
+  \syntax{$a_n$ ::= $\alpha_n^1$ | $\alpha_n^2$ | $\cdots$ | $\alpha_1^{m_n}$}
 \end{quote}
+where $a_1$, \ldots, $a_n$ are new nonterminal symbols.
+
+
+\subsection{Common indexed productions}
 
 The following indexed productions are used throughout the grammar, some often
 enough that they deserve special notation.
@@ -109,13 +159,13 @@ enough that they deserve special notation.
 \item @[$x$@] abbreviates @<optional>$[x]$, denoting an optional occurrence
   of $x$:
   \begin{quote}
-    \syntax{@[$x$@] ::= <optional>$[x]$ ::= $\epsilon$ @! $x$}
+    \syntax{@[$x$@] ::= <optional>$[x]$ ::= $\epsilon$ | $x$}
   \end{quote}
 \item $x^*$ abbreviates @<zero-or-more>$[x]$, denoting a sequence of zero or
   more occurrences of $x$:
   \begin{quote}
     \syntax{$x^*$ ::= <zero-or-more>$[x]$ ::=
-      $\epsilon$ @! <zero-or-more>$[x]$ $x$}
+      $\epsilon$ | <zero-or-more>$[x]$ $x$}
   \end{quote}
 \item $x^+$ abbreviates @<one-or-more>$[x]$, denoting a sequence of one or
   more occurrences of $x$:
@@ -125,7 +175,7 @@ enough that they deserve special notation.
 \item @<list>$[x]$ denotes a sequence of one or more occurrences of $x$
   separated by commas:
   \begin{quote}
-    \syntax{<list>$[x]$ ::= $x$ @! <list>$[x]$ "," $x$}
+    \syntax{<list>$[x]$ ::= $x$ | <list>$[x]$ "," $x$}
   \end{quote}
 \end{itemize}
 
