Debian Codegraph @

texmf-dist/source/latex/backnaur/backnaur.dtx

raw
1 % \iffalse meta-comment
2 %
3 % backnaur.dtx
4 % 7 June 2019
5 %
6 % Documented LaTeX file for the backnaur package.
7 %
8 % Run LaTeX on backnaur.ins to make the package's
9 % backnaur.sty file.
10 %
11 % Run LaTeX on this file to produce the package
12 % documentation.
13 %
14 % Copyright (C) 2019 by Adrian P Robson
15 % [email protected]
16 %
17 % This work may be distributed and/or modified under the
18 % conditions of the LaTeX Project Public License, either
19 % version 1.3c of this license or (at your option) any later
20 % version. The latest version of this license is in
21 % http://www.latex-project.org/lppl.txt
22 %
23 % This work has the LPPL maintenance status `maintained'.
24 %
25 % The Current Maintainer of this work is Adrian Robson.
26 %
27 % This work consists of the files backnaur.dtx and
28 % backnaur.ins
29 % and the derived files backnaur.sty and
30 % backnaur.pdf
31 % -----------------------------------------------------------
32 % \fi
33 %
34 % \iffalse
35 %<package>\NeedsTeXFormat{LaTeX2e}[2011/06/27]
36 %<package>\ProvidesPackage{backnaur}
37 %<package>[2019/06/18 3.1 Typesetting for Backus-Naur Form (BNF) definitions]
38 %<*driver>
39 \documentclass[10pt,a4paper]{ltxdoc}
40 \usepackage{backnaur}
41 \usepackage[T1]{fontenc}
42 \usepackage{lmodern}
43 \usepackage{textcomp}
44 \usepackage{bigstrut}
45 \EnableCrossrefs
46 \CodelineIndex
47 \RecordChanges
48 \OnlyDescription % comment out for code implementation
49 \begin{document}
50 \DocInput{backnaur.dtx}
51 \end{document}
52 %</driver>
53 % \fi
54 %
55 %^^A-------------------------------------------------------------------
56 %^^A Change log...
57 %^^A--------------
58 %^^A
59 %^^A 15 November 2012
60 %^^A The original was based on a non-packaged version that was used
61 %^^A in 2008 for the LaTeX editions of the author's foggy times
62 %^^A reports.
63 % \changes{v1.0}{2012/11/15}
64 % {Initial version of the package.}
65 %^^A
66 %^^A 3 December 2012
67 %^^A Add tstt option and generally rewrite documentation.
68 % \changes{v1.1}{2012/12/12}
69 % {Updated and improved documentation.}
70 %
71 %^^A
72 %^^A 7 June 2019
73 %^^A Remove tstt option, add line number management, add altpo option
74 %^^A and updated and improve documentation.
75 % \changes{v3.0}{2019/06/07}
76 % {Updated and improved documentation.}
77 %
78 %^^A-------------------------------------------------------------------
79 %
80 % \CheckSum{0} %^^A no checksum for development
81 %^^A \CheckSum{80}
82 %
83 % \CharacterTable
84 % {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
85 % 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
86 % Digits \0\1\2\3\4\5\6\7\8\9
87 % Exclamation \! Double quote \" Hash (number) \#
88 % Dollar \$ Percent \% Ampersand \&
89 % Acute accent \' Left paren \( Right paren \)
90 % Asterisk \* Plus \+ Comma \,
91 % Minus \- Point \. Solidus \/
92 % Colon \: Semicolon \; Less than \<
93 % Equals \= Greater than \> Question mark \?
94 % Commercial at \@ Left bracket \[ Backslash \\
95 % Right bracket \] Circumflex \^ Underscore \_
96 % Grave accent \` Left brace \{ Vertical bar \|
97 % Right brace \} Tilde \~}
98 %
99 % \GetFileInfo{backnaur.sty}
100 %
101 % \title{The \texttt{backnaur} package}
102 % \author{Adrian P. Robson\thanks{\texttt{[email protected]}}}
103 % \date{Version 3.1\\[0.5ex]18 June 2019}
104 %
105 % \maketitle
106 %
107 %^^A-------------------------------------------------------------------
108 %^^A Start report body
109 %^^A-------------------------------------------------------------------
110 %
111 % \section{Introduction}
112 %
113 % The \texttt{backnaur} package typesets Backus-Naur Form (BNF) definitions.
114 % It creates aligned lists of productions, with numbers if required.
115 % It can also print in line BNF expressions using math mode.
116 %
117 % Backus-Naur Form is a notation for defining context free grammars.
118 % It is used to describe such things as programming languages, communication protocols
119 % and command syntaxes, but it can be useful whenever a rigorous definition of language is needed.
120 %
121 % \section{BNF Definitions}
122 %
123 % The following is a BNF definition of a semicolon separated list:
124 % \begin{bnf*}
125 % \bnfprod{list}
126 % {\bnfpn{listitems} \bnfor \bnfes}\\
127 % \bnfprod{listitems}
128 % {\bnfpn{item} \bnfor \bnfpn{item}
129 % \bnfsp \bnfts{;} \bnfsp \bnfpn{listitems}}\\
130 % \bnfprod{item}
131 % { \bnftd{description of item}}
132 % \end{bnf*}
133 %
134 % \noindent
135 % Here, $\bnfpo$ signifies \emph{produces}, $\mid$ is an \emph{or} operator, $\langle$...$\rangle$
136 % are \emph{production names},
137 % and $\bnfes$ represents the \emph{empty string}.
138 % However, some BNF users prefer alternative terminologies,
139 % where $\bnfpo$ stands for \emph{is defined as},
140 % $\langle$...$\rangle$ is a \emph{category name} or \emph{nonterminal},
141 % and $\bnfes$ is refered to as \emph{null} or \emph{empty}.
142 %
143 % The above definition was created with the following code:
144 %
145 %\begin{verbatim}
146 %\usepackage{backnaur}
147 %...
148 %\begin{bnf*}
149 % \bnfprod{list}
150 % {\bnfpn{listitems} \bnfor \bnfes}\\
151 % \bnfprod{listitems}
152 % {\bnfpn{item} \bnfor \bnfpn{item}
153 % \bnfsp \bnfts{;} \bnfsp \bnfpn{listitems}}\\
154 % \bnfprod{item}
155 % {\bnftd{description of item}}
156 %\end{bnf*}
157 %
158 %\end{verbatim}
159 %
160 % \noindent
161 % Each BNF production is defined by a |\bnfprod| command, which has two arguments
162 % giving its left and right sides.
163 % The right hand side of each production is specified with the commands described in
164 % \S\ref{prodef} below.
165 % Terminal (|\bnfts{;}|) and nonterminal (|\bnfpn{item}|), elements are separated
166 % by spaces (|\bnfsp|) and OR symbols (|\bnfor|).
167 % The |\bnfes| command gives the symbol for the empty string.
168 %
169 % \section{Package Commands}\label{commandDesc}
170 %
171 % \subsection{Loading and options}\label{packopts}
172 %
173 % The package is loaded with
174 %
175 % \medskip\noindent
176 % \hspace{2.5em}|\usepackage{backnaur}| \\
177 % or\\
178 % \hspace*{2.5em}|\usepackage[|<options>|]{backnaur}|
179 % \medskip
180 %
181 % \noindent
182 % Possible options are
183 %
184 % \vspace{-1.5ex}
185 % \begin{tabbing}
186 % xxxxxxxxx \=\kill
187 % |perp| \>The empty string symbol is $\perp$\\
188 % |epsilon| \> The empty string symbol is $\epsilon$\\
189 % |tsrm| \> Terminal string typeface is roman\\
190 % |altpo| \> Production operator is $::=$
191 %^^A |tstt| \> Terminal string typeface is typewriter (default)
192 % \end{tabbing}
193 % \vspace{-1ex}
194 %
195 % \noindent
196 % The defaults are: the empty string symbol is $\lambda$,
197 % the production operator is $\models$,
198 % and the terminal string typeface is typewriter.
199 %
200 % \subsection{Environments}
201 %
202 % \DescribeEnv{bnf}
203 % BNF productions are defined in a |bnf| or |bnf*| environment,
204 % which respectively give numbered or unnumbered lists of productions.
205 % \DescribeEnv{bnf*}
206 % \begin{quote}
207 % \begin{minipage}{0.5\linewidth}
208 % |\begin{bnf}|\\
209 % \hspace*{1em}<list of productions>\\
210 % |\end{bnf}|
211 % \end{minipage}
212 % \begin{minipage}{0.45\linewidth}
213 % |\begin{bnf*}|\\
214 % \hspace*{1em}<list of productions>\\
215 % |\end{bnf*}|
216 % \end{minipage}
217 % \end{quote}
218 %
219 % \subsection{Productions}
220 %
221 % \DescribeMacro{\bnfprod}
222 % \DescribeMacro{\bnfprod*}
223 % A production is defined by |\bnfprod| or |\bnfprod*|,
224 % which respectively give a numbered or unnumbered line in the {\tt bnf} environment.
225 % They have identical unnumbered behaviour in the {\tt bnf*} enviromment.
226 % They take two arguments:
227 % \begin{quote}
228 % |\bnfprod{|<production name>|}{|<production definition>|}|\\
229 % |\bnfprod*{|<production name>|}{|<production definition>|}|
230 % \end{quote}
231 %
232 % \DescribeMacro{\bnfmore}
233 % \DescribeMacro{\bnfmore*}
234 % A production can be continued on addition lines by |\bnfmore| or |\bnfmore*|,
235 % which respectively give a numbered or unnumbered line in the {\tt bnf} environment.
236 % They are treated the same in the {\tt bnf*} environment.
237 % They take one arguments:
238 % \begin{quote}
239 % |\bnfmore{|<production definition>|}|\\
240 % |\bnfmore*{|<production definition>|}|
241 % \end{quote}
242 %
243 % \subsection{Production definitions}\label{prodef}
244 %
245 % The following commands are used to compose the right hand side of a production.
246 % They are deployed in the second argument of the |\bnfprod| command.
247 %
248 % \DescribeMacro{\bnfpn}
249 % The |\bnfpn| command generates a production name.
250 % It takes a single argument that is the name.
251 % It is used as follows:
252 % \begin{quote}
253 % \begin{minipage}{0.6\linewidth}
254 % |\bnfpn{list item}|
255 % \end{minipage}
256 % \begin{minipage}{0.3\linewidth}
257 % $\bnfpn{list item}$
258 % \end{minipage}
259 % \end{quote}
260 %
261 % There are three types of terminal item: a literal string, a descriptive phrase and an empty string.
262 % \DescribeMacro{\bnftm}
263 % A literal terminal string is specified by the |\bnftm| command, which takes a single argument.
264 % By default literal terminal strings are printed in typewriter font, but this can be changed as a package option (see \S\ref{packopts}).
265 % \DescribeMacro{\bnftd}
266 % The |\bnftd| command generates a descriptive phrase, as an alternative to a literal string.
267 % \DescribeMacro{\bnfes}
268 % The |\bnfes| command generates a token that represents the empty string.
269 % This is normally $\bnfes$, but it can be changed to $\epsilon$ or $\perp$ as a package option
270 % (see \S\ref{packopts}).
271 % \begin{quote}
272 % \begin{minipage}{0.6\linewidth}
273 % |\bnfts{terminal}|\\
274 % |\bnftd{description}|\\
275 % |\bnfes|
276 % \end{minipage}
277 % \begin{minipage}{0.3\linewidth}
278 % $\bnfts{terminal}$\\
279 % $\bnftd{description}$\\
280 % $\bnfes$
281 % \end{minipage}
282 % \end{quote}
283 %
284 % \DescribeMacro{\bnfsk}
285 % Some literal terminal strings can be abbreviated with the `skip' token,
286 % which is generated by the |\bnfsk| command.
287 % This substitutes for a sequence of terminal characters.
288 % It is used like this:
289 % \begin{quote}
290 % \begin{minipage}{0.6\linewidth}
291 % |\bnfts{A} \bnfsk \bnfts{Z}|
292 % \end{minipage}
293 % \begin{minipage}{0.3\linewidth}
294 % $\bnfts{A} \bnfsk \bnfts{Z}$
295 % \end{minipage}
296 % \end{quote}
297 %
298 % \DescribeMacro{\bnfor}
299 % All items should be separated by an OR or a space.
300 % The |\bnfor| command generates the OR symbol, and the |\bnfsp| command introduces a space.
301 % \DescribeMacro{\bnfsp}
302 % A space can be considered equivalent to an AND operator.
303 % \begin{quote}
304 % \begin{minipage}{0.6\linewidth}
305 % |\bnfpn{abc} \bnfor \bnfts{xzy}|\\
306 % |\bnfpn{abc} \bnfsp \bnfts{xzy}|
307 % \end{minipage}
308 % \begin{minipage}{0.3\linewidth}
309 % $\bnfpn{abc} \bnfor \bnfts{xzy}$\\
310 % $\bnfpn{abc} \bnfsp \bnfts{xzy}$
311 % \end{minipage}
312 % \end{quote}
313 %
314 % \subsection{Inline expressions}
315 % The |\bnfprod| and |\bnfmore| macros cannot be used inline, so the |\bnfpn| and |\bnfpo| macros
316 % are provided to support typeseting productions inline using maths mode.
317 % \DescribeMacro{\bnfpn}
318 % \DescribeMacro{\bnfpo}
319 % The production's name can be typeset with |\bnfpn{name}| and the production operator with
320 % |\bnfpo|.
321 % By default the production operator is $\bnfpo$, but it can be changed to $::=$ with
322 % a package option (see \S\ref{packopts}).
323 % The right side of the production can be defined with the usual macros (see \S\ref{prodef}).
324 % So |$\bnfpn{name} \bnfpo \bnftd{description}$| gives $\bnfpn{name} \bnfpo \bnftd{description}$.
325 %
326 % \subsection{Command summary}
327 %
328 % The commands that can be used to define a BNF production in a |bnf| or |bnf*| environment
329 % are as follows:
330 %
331 % \begin{center}
332 % \begin{tabular}{lll}
333 % \hline
334 % Command & Operator & Outcome \bigstrut \\
335 % \hline
336 % |\bnprod| & production line & <name> $\bnfpo$ {\it def} \bigstrut[t] \\
337 % |\bnmore| & extra line & \hspace{38.8pt} $\bnfpo$ {\it def} \\[1ex]
338 % |\bnfor| & OR operator & $\bnfor$ \\
339 % |\bnfsk| & skip & $\bnfsk$ \\
340 % |\bnfsp| & space/AND operator & $\bnfsp$ \\
341 % |\bnfes| & empty string & $\bnfes$ \\
342 % |\bnfts{}| & terminal string & $\bnfts{terminal}$ \\
343 % |\bnftd{}| & terminal description & $\bnftd{description}$ \\[1ex]
344 % |\bnfpn{}| & production name & $\bnfpn{name}$ \\
345 % |\bnfpo| & production operator & $\bnfpo$ \bigstrut[b] \\
346 % \hline
347 % \end{tabular}
348 % \end{center}
349 %
350 % \section{Example}\label{example}
351 %
352 % A more significant example is the following definition of a $\bnfpn{sentence}$,
353 % where $\bnfpn{cchar}$ are countable characters, and $\bnfpn{ichar}$ are characters
354 % that should be ignored:
355 %
356 % \begin{samepage}
357 % \small
358 %\begin{verbatim}
359 %\begin{bnf*}
360 % \bnfprod{sentence}
361 % {\bnfpn{start} \bnfsp \bnfpn{rest} \bnfsp \bnfts{.}}\\
362 % \bnfprod{start}
363 % {\bnfpn{space} \bnfor \bnfes}\\
364 % \bnfprod{rest}
365 % {\bnfpn{word} \bnfsp \bnfpn{space} \bnfsp \bnfpn{rest}
366 % \bnfor \bnfpn{word} \bnfor \bnfes}\\
367 % \bnfprod{word}
368 % {\bnfpn{wchar} \bnfsp \bnfpn{word} \bnfor \bnfpn{wchar}}\\
369 % \bnfprod{space}
370 % {\bnfpn{schar} \bnfsp \bnfpn{space} \bnfor \bnfpn{schar}}\\
371 % \bnfprod{wchar}
372 % {\bnfpn{cchar} \bnfor \bnfpn{ichar} }\\
373 % \bnfprod{cchar}
374 % {\bnfts{A} \bnfsk \bnfts{Z} \bnfor \bnfts{a} \bnfsk
375 % \bnfts{z} \bnfor \bnfts{0} \bnfsk \bnfts{9} \bnfor
376 % \bnfts{\textquotesingle}}\\
377 % \bnfprod{ichar}
378 % {\bnfts{-}}
379 % \bnfprod{schar}
380 % {\bnfts{`\hspace{1em}'} \bnfor \bnfts{!} \bnfor \bnfts{"}
381 % \bnfor \bnfts{(} \bnfor \bnfts{)} \bnfor \bnfts{\{}
382 % \bnfor \bnfts{\}} \bnfor }\\
383 % \bnfmore{\bnfts{:} \bnfor \bnfts{;} \bnfor \bnfts{?} \bnfor
384 % \bnfts{,} }
385 %\end{bnf*}
386 %\end{verbatim}
387 % \end{samepage}
388 %
389 % \noindent
390 % This creates the following BNF definition:
391 %\begin{bnf}
392 % \bnfprod{sentence}
393 % {\bnfpn{start} \bnfsp \bnfpn{rest} \bnfsp \bnfts{.}}\\
394 % \bnfprod{start}
395 % {\bnfpn{space} \bnfor \bnfes}\\
396 % \bnfprod{rest}
397 % {\bnfpn{word} \bnfsp \bnfpn{space} \bnfsp \bnfpn{rest}
398 % \bnfor \bnfpn{word} \bnfor \bnfes }\\
399 % \bnfprod{word}
400 % {\bnfpn{wchar} \bnfsp \bnfpn{word} \bnfor \bnfpn{wchar}}\\
401 % \bnfprod{space}
402 % {\bnfpn{schar} \bnfsp \bnfpn{space} \bnfor \bnfpn{schar}}\\
403 % \bnfprod{wchar}
404 % {\bnfpn{cchar} \bnfor \bnfpn{ichar} }\\
405 % \bnfprod{cchar}
406 % {\bnfts{A} \bnfsk \bnfts{Z} \bnfor \bnfts{a} \bnfsk
407 % \bnfts{z} \bnfor \bnfts{0} \bnfsk \bnfts{9} \bnfor
408 % \bnfts{\textquotesingle} }\\
409 % \bnfprod{ichar}
410 % {\bnfts{-}}\\
411 % \bnfprod*{schar}
412 % {\textrm{`\hspace{1em}'} \bnfor \bnfts{!} \bnfor \bnfts{"}
413 % \bnfor \bnfts{(} \bnfor \bnfts{)} \bnfor \bnfts{\{}
414 % \bnfor \bnfts{\}} \bnfor }\\
415 % \bnfmore{\bnfts{:} \bnfor \bnfts{;} \bnfor \bnfts{?} \bnfor
416 % \bnfts{,} }
417 %\end{bnf}
418 %
419 % \noindent
420 %^^A Notice the kludge in production 9: \verb|\textrm{`\hspace{1em}'}|.
421 % Notice the kludge in production 9.
422 % We use \verb|\textrm{`\hspace{1em}'}| to typeset a representation for a space
423 % character.
424 % This is needed because we do not want to print in typewriter font,
425 % which would imply the quotes were part of an actual terminal string.
426 % The \verb|\textrm| is needed because are in maths mode.
427 %
428 %^^AT \appendix
429 % \section{Terminal string characters}
430 %
431 % The characters used with \verb|\bnfts{}| (terminal string) are just standard
432 % LaTeX that is typeset in either a roman or typewriter font.
433 % This means we might have to use some escape pairs and a few special characters.
434 % Apostrophes and speech marks can be confusing. There are some of the possibilities:
435 %
436 % \begin{tabbing}
437 % xxxxxxxx \= xxxxxxxxxxxxxxxxxxxxxxxxxx \= xxxxxxxxxxxxxxxxx\= \kill
438 % alpha \> \verb|\bnfts{abcdABCD}| \> $\texttt{abcdABCD}$ \> $\textrm{abcdABCD}$\\
439 % numeric \> \verb|\bnfts{01234}| \> $\texttt{01234}$ \> $\textrm{01234}$\\
440 %
441 % simple \> \verb|\bnfts{<>[]()*+-=}| \> $\texttt{<>[]()*+-=}$ \> $\textrm{<>[]()*+-=}$\\
442 % simple \> \verb|\bnfts{@!?/,.;:}| \> $\texttt{@!?/,.;:}$ \> $\textrm{@!?/,.;:}$\\
443 %
444 % escaped \> \verb|\bnfts{\{\}\$\%\&\_\#}| \> $\texttt{\{\}\$\%\&\_\#}$
445 % \> $\textrm{\{\}\$\%\&\_\#}$\\
446 %
447 % quotes \> \verb|\bnfts{' ` " `` ''}| \> $\texttt{' ` " `` ''}$
448 % \> $\textrm{' ` " `` ''}$\\
449 % quotes \> \verb|\bnfts{\textquotesingle}| \> $\texttt{\textquotesingle}$
450 % \> $\textrm{\textquotesingle}$\\
451 %
452 % pound \> \verb|\bnfts{\pounds}| \> $\texttt{\pounds}$ \> $\textrm{\pounds}$\\
453 % hat \> \verb|\bnfts{\textasciicircum}| \> $\texttt{\textasciicircum}$
454 % \> $\textrm{\textasciicircum}$\\
455 % backslash \> \verb|\bnfts{\textbackslash}| \> $\texttt{\textbackslash}$
456 % \> $\textrm{\textbackslash}$\\
457 % tilde \> \verb|\bnfts{\textasciitilde}| \> $\texttt{\textasciitilde}$ \>
458 % $\textrm{\textasciitilde}$
459 % \end{tabbing}
460 %
461 %
462 % \noindent
463 % The \verb|\textquotesingle| symbol needs the {\tt textcomp} package, which provides
464 % lots of other interesting symbols. Consult the excellent \emph{The Comprehensive LATEX Symbol List} by Scott Pakin for more information.
465 %
466 %^^A-------------------------------------------------------------------
467 %^^A Start code implementation
468 %^^A-------------------------------------------------------------------
469 %
470 %^^A \StopEventually{}
471 % \StopEventually{\PrintChanges}
472 %^^A -> Run pdfLaTeX backnaur.dtx
473 %^^A makeindex -s gglo.ist -o backnaur.gls backnaur.glo
474 %^^A pdfLaTeX backnaur.dtx
475 %^^A \StopEventually{\PrintIndex}
476 %^^A -> Run pdfLaTeX backnaur.dtx
477 %^^A makeindex -s gind.ist -o backnaur.ind backnaur.idx
478 %^^A pdfLaTeX backnaur.dtx
479 %
480 % \newpage
481 % \section{Implementation}
482 %
483 % The implementation of |backnaur.sty| uses only \LaTeX{} commands.
484 %
485 % \subsection{Environments}\label{environ}
486 %
487 % There are two environments defined:
488 %
489 % \begin{environment}{bnf}
490 % A production list with numbers. It is simply implemented as an |eqnarray|.
491 % Surplus space is removed with an |\ignorespacesafterend| and |%| characters.
492 % \begin{macrocode}
493 \newenvironment{bnf}%
494 {\begin{eqnarray}}%
495 {\end{eqnarray}\ignorespacesafterend}
496 % \end{macrocode}
497 % \end{environment}
498 %
499 % \begin{environment}{bnf*}
500 % A lists without numbers. It is implemented with an |eqnarray*|,
501 % and extra space is removed as in the |bnf| environment above.
502 % \begin{macrocode}
503 \newenvironment{bnf*}%
504 {\begin{eqnarray*}}%
505 {\end{eqnarray*}\ignorespacesafterend}
506 % \end{macrocode}
507 % \end{environment}
508 %
509 % \subsection{Definition Commands}
510 %
511 % All of these commands run in the math mode supplied by the
512 % |bnf| and |bnf*| environments (see \S\ref{environ}).
513 %
514 % \begin{macro}{\bnfpn}
515 % Production name / nonterminal.
516 % \changes{v3.1}{2019/06/18}{Fix font handling}
517 % \begin{macrocode}
518 \newcommand{\bnfpn}[1]{\langle \textrm{#1} \rangle}
519 % \end{macrocode}
520 % \end{macro}
521 %
522 % \begin{macro}{\bnfor}
523 % OR operator.
524 % \begin{macrocode}
525 \newcommand{\bnfor}{\; \mid \;}
526 % \end{macrocode}
527 % \end{macro}
528 %
529 % \begin{macro}{\bnfsp}
530 % Space or AND operator.
531 % \begin{macrocode}
532 \newcommand{\bnfsp}{\;}
533 % \end{macrocode}
534 % \end{macro}
535 %
536 % \begin{macro}{\bnfes}
537 % Empty string symbol. This is the default if no package options are given.
538 % \begin{macrocode}
539 \newcommand{\bnfes}{\lambda}
540 % \end{macrocode}
541 % \end{macro}
542 %
543 % \begin{macro}{\bnfts}\label{codebnfts}
544 % \changes{v1.1}{2012/12/12}{Support for {\tt tstt} option added}
545 % \changes{v3.1}{2019/06/18}{Fix font handling}
546 % \begin{macro}{\bnf@tsfont}
547 % Terminal string. The font is controlled by the |\bnf@tsfont| macro,
548 % and this macro can be redefined by the |tsrm| option (see \S\ref{codeoptions}).
549 % The default is typewriter font.
550 % \begin{macrocode}
551 \newcommand{\bnf@tsfont}[1]{\texttt{#1}}
552 \newcommand{\bnfts}[1]{\bnf@tsfont{#1}}
553 % \end{macrocode}
554 % \end{macro}
555 % \end{macro}
556 %
557 % \begin{macro}{\bnfpo}
558 % Terminal description.
559 % \changes{v3.1}{2019/06/18}{Fix font handling}
560 % \begin{macrocode}
561 \newcommand{\bnftd}[1]{\textit{#1}}
562 % \end{macrocode}
563 % \end{macro}
564 %
565 % \begin{macro}{\bnfsk}
566 % Skip symbol.
567 % \begin{macrocode}
568 \newcommand{\bnfsk}{\dots}
569 % \end{macrocode}
570 % \end{macro}
571 %
572 % \begin{macro}{\bnfpo}
573 % Production operator.
574 % \begin{macrocode}
575 \newcommand{\bnfpo}{\models}
576 % \end{macrocode}
577 % \end{macro}
578 %
579 % \subsection{Production Commands}
580 %
581 %^^A \newcommand{\bnfprod}{\@ifstar{\bnf@prodnn}{\bnf@prodyn}}
582 %^^A \newcommand{\bnf@prodyn}[2]{\bnfpn{#1} & \bnfpo & #2}
583 %^^A \newcommand{\bnf@prodnn}[2]{\nonumber \bnfpn{#1} & \bnfpo & #2}
584 %^^A \newcommand{\bnfmore}{\@ifstar{\bnf@morenn}{\bnf@moreyn}}
585 %^^A \newcommand{\bnf@moreyn}[1]{ & & #1}
586 %^^A \newcommand{\bnf@morenn}[1]{\nonumber & & #1}
587 %
588 % \begin{macro}{\bnfprod}
589 % \begin{macro}{\bnfprod*}
590 % \changes{v3.0}{2019/06/07}{Added {\tt *} version of the macro.}
591 % \begin{macro}{\bnf@prodyn}
592 % \begin{macro}{\bnf@prodnn}
593 % A Backus-Naur Form production.
594 % This command is designed to exploit the behaviour the |equarray| used in
595 % the |bnf| and |bnf*| environments.
596 % In particular, the |\bnfpo| character will be vertically aligned.
597 % The {\tt *} version suppresses the line number% \begin{macrocode}
598 \newcommand{\bnfprod}{\@ifstar{\bnf@prodnn}{\bnf@prodyn}}
599 \newcommand{\bnf@prodyn}[2]{\bnfpn{#1} & \bnfpo & #2}
600 \newcommand{\bnf@prodnn}[2]{\nonumber \bnfpn{#1} & \bnfpo & #2}
601 % \end{macrocode}
602 % \end{macro}
603 % \end{macro}
604 % \end{macro}
605 % \end{macro}
606 %
607 % \begin{macro}{\bnfmore}
608 % \changes{v2.0}{2019/04/07}{Added macro.}
609 % \begin{macro}{\bnfmore*}
610 % \changes{v3.0}{2019/06/07}{Added {\tt *} version of the macro.}
611 % \begin{macro}{\bnf@moreyn}
612 % \begin{macro}{\bnf@morenn}
613 % A continuation of a Backus-Naur Form production.
614 % This command is designed to exploit the behaviour the |equarray| used in
615 % the |bnf| and |bnf*| environments to correctly align with preceding
616 % |\bnfprod| and |\bnfmore| macros.
617 % The {\tt *} version suppresses the line number.
618 % \begin{macrocode}
619 \newcommand{\bnfmore}{\@ifstar{\bnf@morenn}{\bnf@moreyn}}
620 \newcommand{\bnf@moreyn}[1]{ & & #1}
621 \newcommand{\bnf@morenn}[1]{\nonumber & & #1}
622 % \end{macrocode}
623 % \end{macro}
624 % \end{macro}
625 % \end{macro}
626 % \end{macro}
627 %
628 % \subsection{Options}\label{codeoptions}
629 %
630 %\begin{macro}{tstt}
631 % \changes{v1.1}{2012/12/12}{New option}
632 % \changes{v2.0}{2019/04/14}{Changed to be default}
633 % \changes{v3.0}{2019/06/07}{Option removed but still default}
634 % The |tstt| option is depreciated and can no longer be used.
635 % Nevertheless, typewriter font for terminal stings, which it selected,
636 % is still the package's default.
637 %\end{macro}
638 %
639 % \begin{macro}{tsrm}
640 % \changes{v2.0}{2019/04/14}{New option}
641 % \begin{macro}{\bnf@tsfont}
642 % The |tsrm| option redefines |\bnf@tsfont| to change the
643 % terminal string font used in the |\bnfts| command (see \S\ref{codebnfts}) to roman font.
644 % \begin{macrocode}
645 \DeclareOption{tsrm}{\renewcommand{\bnf@tsfont}[1]{\textrm{#1}}}
646 % \end{macrocode}
647 % \end{macro}
648 % \end{macro}
649 %
650 % \begin{macro}{perp}
651 % \begin{macro}{epsilon}
652 % \begin{macro}{\bnfes}
653 % The |perp| and |epsilon| options redefine |\bnfes|,
654 % which is the empty string command:
655 % \begin{macrocode}
656 \DeclareOption{perp}{\renewcommand{\bnfes}{\perp}}
657 \DeclareOption{epsilon}{\renewcommand{\bnfes}{\epsilon}}
658 % \end{macrocode}
659 % \end{macro}
660 % \end{macro}
661 % \end{macro}
662 %
663 % \begin{macro}{altpo}
664 % \changes{v3.0}{2019/06/07}{New option}
665 % \begin{macro}{\bnfpo}
666 % The |altpo| option redefines |\bnfpo|
667 % which prints the production operator:
668 % \begin{macrocode}
669 \DeclareOption{altpo}{\renewcommand{\bnfpo}{::=}}
670 % \end{macrocode}
671 % \end{macro}
672 % \end{macro}
673 %\noindent
674 % Finally, the options that have been selected are executed:
675 % \begin{macrocode}
676 \ProcessOptions\relax
677 % \end{macrocode}
678 %
679 % \Finale
680 \endinput