X-Git-Url: https://git.distorted.org.uk/~mdw/mdwtools/blobdiff_plain/86f6a31e4b41acb71ba37f3838a9ce75f7743330..7b2adc290673aa432bbbecd130473d38408961e4:/syntax.dtx

diff --git a/syntax.dtx b/syntax.dtx
index 627f8c8..1b1965f 100644
--- a/syntax.dtx
+++ b/syntax.dtx
@@ -4,14 +4,14 @@
 %
 % Syntax typesetting package for LaTeX 2e
 %
-% (c) 1996 Mark Wooding
+% (c) 2003 Mark Wooding
 %
 % \end{meta-comment}
 %
 % \begin{meta-comment} <general public licence>
 %%
 %% syntax package -- typesetting syntax descriptions
-%% Copyright (c) 1996 Mark Wooding
+%% Copyright (c) 2003 Mark Wooding
 %%
 %% This program is free software; you can redistribute it and/or modify
 %% it under the terms of the GNU General Public License as published by
@@ -32,10 +32,10 @@
 % \begin{meta-comment} <Package preamble>
 %<+package>\NeedsTeXFormat{LaTeX2e}
 %<+package>\ProvidesPackage{syntax}
-%<+package>                [1996/05/17 1.07 Syntax typesetting (MDW)]
+%<+package>                [2003/08/25 1.08 Syntax typesetting (MDW)]
 % \end{meta-comment}
 %
-% ^^A \CheckSum{1504}
+% \CheckSum{1616}
 %% \CharacterTable
 %%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
 %%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
@@ -172,7 +172,7 @@
 % \begin{listing}
 %\def\<#1>{\synt{#1}}
 % \end{listing}
-% to allow you to type "\\<"<text>">" as an alternative to 
+% to allow you to type "\\<"<text>">" as an alternative to
 % "\\synt{"<text>"}".
 %
 % \DescribeMacro\lit
@@ -290,7 +290,7 @@
 % \DescribeMacro{\[[}
 % \DescribeMacro{\]]}
 % You can use syntax diagrams (see below) instead of a straight piece of BNF
-% by enclosing it in a |\[[| \dots |\]]| pair.  Note that you can't mix 
+% by enclosing it in a |\[[| \dots |\]]| pair.  Note that you can't mix
 % syntax diagrams and BNF in a production rule, and you will get something
 % which looks very strange if you try.
 %
@@ -445,7 +445,7 @@
 %
 % \DescribeMacro\tok
 % You can also include text using the |\tok| command.  The argument of this
-% command is typeset in \LaTeX's LR~mode and inserted into the diagram. 
+% command is typeset in \LaTeX's LR~mode and inserted into the diagram.
 % Syntax abbreviations are allowed within the argument, so you can, for
 % example, include textual descriptions like
 % \begin{listing}
@@ -473,7 +473,7 @@
 %
 % Note that items on the backwards arrow of a \env{rep} construction should
 % be displayed \emph{backwards}.  You must put the individual items in
-% reverse order when building this part of your diagrams.  \syn\ will 
+% reverse order when building this part of your diagrams.  \syn\ will
 % correctly reverse the arrows on \env{rep} structures, but apart from
 % this, you must cope on your own.  You are recommended to keep these parts
 % of your diagrams as simple as possible to avoid confusing readers.
@@ -604,7 +604,7 @@
 %
 % You can also alter the appearance of \env{stack}s and \env{rep}s by using
 % their optional positioning arguments.  By default, \env{stack}s descend
-% below the main line of the diagram, and \env{rep}s extend above it.  
+% below the main line of the diagram, and \env{rep}s extend above it.
 % Specifying an optional argument of |[b]| for either environment reverses
 % this, putting \env{stack}s above and \env{rep}s below the line.
 %
@@ -637,66 +637,6 @@
 % commands, in \env{grammar} environments, and in syntax diagrams.
 %
 %
-% \section{Change history}
-%
-% \subsection*{Version 1.07}
-%
-% \begin{itemize}
-% \item Fixed problem with underscore hacking in a \env{tabbing} environment.
-% \end{itemize}
-%
-% \subsection*{Version 1.06}
-%
-% \begin{itemize}
-% \item Added style hooks for syntax items.
-% \item Improved colour handling in syntax diagrams, thanks to the |\doafter|
-%       package.
-% \item Fixed some nasty bugs in the \env{grammar} environment which confused
-%       other lists and ruined the spacing.  The \env{grammar} handling is
-%       now much tidier in general.
-% \end{itemize}
-%
-% \subsection*{Version 1.05}
-%
-% \begin{itemize}
-% \item Fixed `the bug' in the syntax diagram typesetting.  It now breaks
-%       lines almost psychically, and doesn't break in the wrong places.
-% \item Almost rewrote the \env{grammar} environment.  It now does lots of
-%       the list handling itself, to allow more versatile typesetting of the
-%       left hand sides.  There's lots of evil in there now.
-% \item Added some more configurability.  In particular, two new settings
-%       have been added to control \env{grammar} environments, and a neat
-%       way of adding new syntax diagram structures has been introduced.
-% \end{itemize}
-%
-% \subsection*{Version 1.04}
-%
-% \begin{itemize}
-% \item Changed the vertical positioning of the rules, to make all the text
-%       line up properly.  While the old version was elegant and simple, it
-%       had the drawback of looking nasty.
-% \item Allow line breaks at underscores, but don't if there's another one
-%       afterwards.  Also, prevent losing following space if underscore is
-%       written to a file.
-% \end{itemize}
-%
-% \subsection*{Version 1.02}
-%
-% \begin{itemize}
-% \item Added support for rounded corners in syntax diagrams.
-% \item Changed lots of |\hskip| commands to |\kern|s, to prevent possible
-%       line breaks.
-% \end{itemize}
-%
-% \subsection*{Version 1.01}
-%
-% \begin{itemize}
-% \item Allowed disabling of underscore active character, to avoid messing
-%       up filenames.
-% \item Added |\grammarparsep| and |\grammarindent| length parameters to
-%       control the appearance of grammars.
-% \end{itemize}
-%
 % \implementation
 %
 % \section{Implementation of \syn}
@@ -1192,7 +1132,7 @@
 % characters through.  By default, we re-enable |\|, and make `\verb*" "'
 % typeset some space glue, rather than a space character.  A macro
 % `\verb*"\ "' is defined to actually print a space character, which yield
-% `\verb*" "' in the `|\tt|' font. 
+% `\verb*" "' in the `|\tt|' font.
 %
 % Finally, it defines a |\ch| command, which, given a single-character
 % control sequence as its argument, typesets the character.  This is useful,
@@ -1358,7 +1298,7 @@
   \addspecial\|%
   \addspecial\"%
   \catcode`\|\active%
-  \catcode`\<\active% 
+  \catcode`\<\active%
   \catcode`\"\active%
   \catcode`\`\active%
 }
@@ -1418,8 +1358,8 @@
 % commands.  Well, almost \dots
 %
 %    \begin{macrocode}
-\newcommand{\grammarlabel}[2]{%
-  \synt{#1} \hfill#2%
+\newcommand{\grammarlabel}[3][]{%
+  \synt{#2}#1 \hfill#3%
 }
 %    \end{macrocode}
 %
@@ -1432,8 +1372,8 @@
 % strut just makes sure that I know exactly how high the line is.
 %
 %    \begin{macrocode}
-\def\gr@implitem<#1> #2 {%
-  \sbox\z@{\hskip\labelsep\grammarlabel{#1}{#2}}%
+\def\gr@implitem<#1>#2 #3 {%
+  \sbox\z@{\hskip\labelsep\grammarlabel[{#2}]{#1}{#3}}%
   \strut\@@par%
   \vskip-\parskip%
   \vskip-\baselineskip%
@@ -1728,7 +1668,7 @@
 }
 \def\sd@leftarr{%
   \bgroup%
-  \raise\sd@mid\hbox{\@linefnt\char'33\kern-6\p@}%
+  \setbox\tw@\hbox{\@linefnt\char'33\kern-6\p@}%
   \sd@arrow%
 }
 %    \end{macrocode}
