%%% ==================================================================== %%% @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_1w_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: $$.$$ 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""string"$ 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}