summaryrefslogtreecommitdiff
path: root/info/ltx3pub/vt11d01.tex
blob: 83fb8bc4bf10e9b73f63fd8e578121733ab22034 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
%%% ====================================================================
%%%  @LaTeX3-article{ LaTeX3-VT11-01,
%%%  filename        = "vt11d01.tex",
%%%  archived        = "ctan:/tex-archive/info/ltx3pub/",
%%%  author          = "Mike Piff",
%%%  doc-group       = "Volunteer task VT11",
%%%  title           = "Backus-Naur form in {\LaTeX3}",
%%%  version         = "1.03",
%%%  date            = "02 April 1993",
%%%  time            = "22:49:47 GMT",
%%%  status          = "public, contributed.",
%%%  author-email    = "M.Piff@sheffield.ac.uk",
%%%  author-address  = "Department of Pure Mathematics \\
%%%                     University of Sheffield        \\
%%%                     Hicks Building                 \\
%%%                     Hounsfield Road                \\
%%%                     SHEFFIELD S3 7RH               \\
%%%                     England",
%%%  abstract        = "",
%%%  keywords        = "",
%%%  project-address = "LaTeX3 Project            \\
%%%                     c/o Dr. Chris Rowley      \\
%%%                     The Open University       \\
%%%                     Parsifal College          \\
%%%                     Finchley Road             \\
%%%                     London NW3 7BG, England, UK",
%%%  project-tel     = "+44 171 794 0575",
%%%  project-FAX     = "+44 171 433 6196",
%%%  project-email   = "LTX3-Mgr@SHSU.edu",
%%%  copyright       = "Copyright (C) 1993 LaTeX3 Project
%%%                     and Mike Piff.
%%%                     All rights reserved.
%%%
%%%                     Permission is granted to make and distribute
%%%                     verbatim copies of this publication or of
%%%                     coherent parts from this publication provided
%%%                     this copyright notice and this permission
%%%                     notice are preserved on all copies.
%%%
%%%                     Permission is granted to copy and distribute
%%%                     translations of this publication or of
%%%                     individual items from this publication into
%%%                     another language provided that the translation
%%%                     is approved by the original copyright holders.
%%%
%%%                     No other permissions to copy or distribute this
%%%                     publication in any form are granted and in
%%%                     particular no permission to copy parts of it
%%%                     in such a way as to materially change its
%%%                     meaning.",
%%%  generalinfo     = "To subscribe to the LaTeX3 discussion list:
%%%
%%%                      Send mail to listserv@vm.urz.uni-heidelberg.de
%%%                      with the following line as the body of the
%%%                      message (substituting your own name):
%%%
%%%                        subscribe LaTeX-L First-name Surname
%%%
%%%                     To find out about volunteer work:
%%%
%%%                      look at the document vol-task.tex which can
%%%                      be obtained electronically, see below.
%%%
%%%                     To retrieve project publications electronically:
%%%
%%%                      Project publications are available for
%%%                      retrieval by anonymous ftp from ctan hosts:
%%%                          ftp.tex.ac.uk
%%%                          ftp.dante.de
%%%                          ftp.shsu.edu
%%%                      in the directory /tex-archive/info/ltx3pub.
%%%
%%%                      The file ltx3pub.bib in that directory gives
%%%                      full bibliographical information including
%%%                      abstracts in BibTeX format.  A brief history
%%%                      of the project and a description of its aims
%%%                      is contained in l3d001.tex.
%%%
%%%                     If you only have access to email, and not ftp
%%%                      You may use the ftpmail service.
%%%                      Send a message just containg the word
%%%                          help
%%%                      to ftpmail@ftp.shsu.edu
%%%                      for more information about this service.
%%%
%%%                     For offers of financial contributions or
%%%                      contributions of computing equipment or
%%%                      software, contact the project at the above
%%%                      address, or the TeX Users Group.
%%%
%%%                     For offers of technical assistance, contact the
%%%                      project at the above address.
%%%
%%%                     For technical enquiries and suggestions, send
%%%                      e-mail to the latex-l list or contact the
%%%                      project at the above address.",
%%%  checksum        = "60525 218 1235 10548",
%%%  docstring       = "The checksum field above contains a CRC-16
%%%                     checksum as the first value, followed by the
%%%                     equivalent of the standard UNIX wc (word
%%%                     count) utility output of lines, words, and
%%%                     characters.  This is produced by Robert
%%%                     Solovay's checksum utility.",
%%%  }
%%% ====================================================================
\documentstyle[bnf]{l3ms001}
%% This needs the style option bnf.sty
%% Latest version         1.05
%% Date            09 Feb 1993
%%
\begin{document}
\title{Backus-Naur form in \LaTeX3}
\author{Coordinator: Mike Piff}
\date{02 April 1993 \\
Version 1.03}
\maketitle
\begin{bnf}
\section*{Objectives}
\begin{enumerate}
   \item Create environments and commands to produce the symbolism of
      BNF notation in mathematics.
   \item Provide easy mechanisms for customizing this notation.
   \item Provide short forms which are close to the teletype way of
      representing BNF, by means of a $"bnf"$ environment.
   \item Try not to disable too many features of \LaTeX\ when the short
      forms are in operation.
\end{enumerate}

\section*{Rationale}

The whole notation of Backus-Naur Form seems to  be
deeply mathematical. Some examples:
\begin{itemize}
   \item Use of $\lbrace$ and $\rbrace$, round and square brackets.
   \item Variable names such as $w$ for a word, $\cal A$ for an
         alphabet,  etc.
   \item Subscripting, eg, $w_1<X>w_2 -> w_1 w w_2$.
   \item Use of $\Production$, $\Yields$ and $\Yields^*$ for productions
      and yields, and $|$ for alternatives.
\end{itemize}
We should also consider the spacing problems that doing these
in text mode would entail.

The BNF notation is really part of the mathematical notation for
specifying a phrase structure grammar.  It is a means of simplifying
groups of productions into one compound production, and thus
decreasing the apparent complexity of its structure.  This is the
reason why things should be set up so that BNF is only available
within maths mode.

It is also perhaps true that BNF should not be considered in isolation
from the requirements of the body of mathematical notations into which
it fits. There is also a clear link with the task looking at short forms
in mathematics. One point which was discovered in writing a preliminary
version of the macros was the dangers involved in making $"-"$ active in
mathematics, because of the way long arrows had been defined in plain \TeX!

\section*{Specification}

The following should happen in maths mode.
   \begin{enumerate}
      \item The environment $"NonTerminal"$ should produce the text
         between $"\begin{NonTerminal}"$ and $"\end{NonTerminal}"$
         enclosed between angle brackets, thus:
         $$<enclosed text>.$$
         Spaces in the enclosed text should be respected, but not made
         visible. The maths font used between the angle brackets should
         be customizable through the command $"\NonTerminalStyle"$.
         The default should be $"fam0"$, that is, ordinary roman.
      \item The command $"\Terminal"<char>"string"<char>$  should produce
         the enclosed string exactly as if it had been produced by \LaTeX'
         $"\verb*"$ command, except that it is preceded and followed
         by the expansion of $"\PreTerminal"$ and $"\PostTerminal"$
         respectively.
      \item The environments $"Star"$, $"Optional"$ and $"Bracket"$
         should put paired braces, square brackets and round brackets
         respectively
         around the enclosed text.
         Spaces of $"\StarSpace"$, $"\OptionalSpace"$ and $"\BracketSpace"$
         respectively should precede and follow the environment.
      \item The commands $"\Production"$, $"\Yields"$ and $"\OR"$
         should produce the special symbols $->$, $=>$ and $|$
         respectively, the first two being relations and the last an
         operator. The $"\Empty"$ command should produce the
         symbol $\Empty$.
      \item A special environment $"bnf"$ should have the effect of making
         the short forms of these commands available in maths mode.
         This environment should be capable of spanning many paragraphs,
         and should only affect the meaning of certain symbols in maths
         mode. These are:
         $$"`",`"`,"(",")","<",">","[","]","-","=","|","@".$$
         The effects should be as follows.
         \begin{enumerate}
            \item $"`string`"$ and $`"string"`$ should produce the effect
               of a $"\Terminal"$ command.
            \item $"<"N">"$ should produce the effect of a $"NonTerminal"$
               environment.
               The following symbols should be rejected as part of
               $N$, so as to allow some error detection.
               $$"[","]","(",")","|","<","=".$$
               The symbol $"-"$ should be interpreted as a hyphen.

               The symbols $@<$ and $@>$ should be made available
               as $"\lt"$ and $"\gt"$, or alternatively as $"@<"$
               and $"@>"$.
            \item $"("E")"$ and $"["E"]"$ should produce the same effects as
               the $"Bracket"$ and $"Optional"$ environments.
            \item $"->"$ and $"=>"$ should produce $->$ and $=>$,
               otherwise $"-"$ and $"="$ should behave normally.
               $"|"$ should produce $|$.
            \item $"{@"E"}"$ should produce ${@E}$.
               It would be preferable for $"{"E"}"$ to produce this effect,
               but that would probably entail not allowing braces to appear
               in a $"bnf"$ environment other than for this purpose.
         \end{enumerate}
   \end{enumerate}
\end{bnf}
\end{document}