summaryrefslogtreecommitdiff
path: root/macros/latex209/contrib/tex-bnf/bnf.bugs
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex209/contrib/tex-bnf/bnf.bugs
Initial commit
Diffstat (limited to 'macros/latex209/contrib/tex-bnf/bnf.bugs')
-rw-r--r--macros/latex209/contrib/tex-bnf/bnf.bugs187
1 files changed, 187 insertions, 0 deletions
diff --git a/macros/latex209/contrib/tex-bnf/bnf.bugs b/macros/latex209/contrib/tex-bnf/bnf.bugs
new file mode 100644
index 0000000000..cde30e32a7
--- /dev/null
+++ b/macros/latex209/contrib/tex-bnf/bnf.bugs
@@ -0,0 +1,187 @@
+1). The BNF macros cannot deal with environments that are started by one of
+the optional parameters and ended by another. For example the following
+example (due to Florence Maraninchi of LGI-IMAG Campus, BP 53X, 38041
+Grenoble cedex, FRANCE) does not work.
+
+This is a structural problem, that I do not have time to consider at the
+moment. If anyone else solves it, will they please let me know?
+
+________________________________________________________________________________
+\newenvironment{tabu}{\begin{tabular}{ll}[t]}{\end{tabular}}
+
+\begin{grammar}
+ [(colon){\begin{tabu} : & }]
+ [(period){\end{tabu}}]
+ [(semicolon){\\ $\mid$ & }]
+ [(comma){ }]
+ [(quote){\begin{bf}}{\end{bf}}]
+
+ toto : expression.
+
+ expression: constante; idf;expression operateur expression.
+
+ operateur: "+" ; "-" ; "*" ; "/".
+
+ constante: "0" ; "1" ; "2" ; "3" ; "4".
+
+\end{grammar}
+
+________________________________________________________________________________
+
+2). The above example also made me aware of another problem that has
+not yet been reported. If you try and include a command with an optional
+parameter in one of the optional parameters of the grammar environment,
+LaTeX will get horribly confused. For example, a grammar environment
+such as
+
+--------------------------------------------------------------------------------
+
+\begin{grammar}
+ [(colon){\rule[.5\lineskip]{10pt}{\lineskip}}]
+ wrong : won't work.
+\end{grammar}
+
+won't work. This is due to TeX' macro expansion mechanism, and an
+elegant solution would require a fairly major overhaul, which I don't
+have time for at the moment.
+
+A hack is to change the syntax of the optional commands of the grammar
+environment so that the optional commands are delimited by some other
+symbol than "[" and "]". If, for example, we were to choose "!" as our
+(left _and_ right) delimiter, then lines 63, 65, 66 and 69 of the
+original BNF macros would have to be changed. They are currently
+...............................................................................
+
+\def\@dogrammarchars{
+ \@ifnextchar [{\@getchardef}{\@defaultchardefs}}
+
+\def\@getchardef[(#1)#2]{
+ \@dogrammarchar{#1}[#2]
+ \@dogrammarchars}
+
+\def\@dogrammarchar#1[#2]{
+ \csname if@#1\endcsname\else
+ \csname @def#1\endcsname{#2}\csname @#1true\endcsname\fi}
+...............................................................................
+
+and would have to become
+................................................................................
+
+\def\@dogrammarchars{
+ \@ifnextchar !{\@getchardef}{\@defaultchardefs}}
+% ^
+
+\def\@getchardef!(#1)#2!{
+% ^ ^
+ \@dogrammarchar{#1}!#2!
+% ^ ^
+ \@dogrammarchars}
+
+\def\@dogrammarchar#1!#2!{
+% ^ ^
+ \csname if@#1\endcsname\else
+ \csname @def#1\endcsname{#2}\csname @#1true\endcsname\fi}
+................................................................................
+
+(sorry to belabour the obvious, but to be on the safe side, the "^" are
+only to indicate where the changes have taken place)
+
+The optional parameters may not now contain any "!" symbols, or else
+we're back where we started from.
+
+3). Thanks to David Wright (wright@tasis.eecs.utas.edu.au) and Arto
+Viitanen (av@uta.fi) for the next one.
+
+I included a couple of spaces in the BNF macros, where I shouldn't have,
+which leads to spurious spaces being produced in the output. (Dave
+Wright's example was "->" appearing as "- >", and Arto Viitanen's was
+"<terminal>" appearing as "<terminal >". The solution is to remove the
+extra spaces, on lines 22 and 24. These were
+................................................................................
+ \catcode`\<\active
+ \def<{{\@deactifygrammarchars \@first#1}}
+% ^
+ \catcode`\>\active
+ \def>{{\@deactifygrammarchars \@second#1}}}
+% ^
+\endgroup
+................................................................................
+
+The "^" symbols indicate the spaces that should be removed.
+
+4) The following is due to Craig Brown (cmb@research.canon.oz.au) at
+Canon Information Systems Research Australia. This bug was the result
+of my ignorance of the subtleties of TeX's input mechanism.
+
+Just another comment regarding your Context Free Grammar.
+
+This works:
+
+\newenvironment{tligrammar}%
+{\begin{grammar}%
+[(nonterminal){\begin{bf}}{\end{bf}}]%
+[(colon){ ::=}]%
+[(comma){~}]%
+[(semicolon){ $|$}]}%
+{\end{grammar}}
+
+\begin{tligrammar}
+<A>: <B>, <C>, <D>.
+\end{tligrammar}
+
+and this does not:
+
+\begin{grammar}
+[(nonterminal){\begin{bf}}{\end{bf}}]
+[(colon){ ::=}]
+[(comma){~}]
+[(semicolon){ $|$}]
+<A>: <B>, <C>, <D>.
+\end{grammar}
+
+Conclusion: Latex is black magic!
+
+Regards, Craig Brown.
+
+Craig Brown | cmb@research.canon.oz.au
+Canon Information Systems Research Australia | Phone +61-2-805-2900
+PO Box 313 NORTH RYDE NSW 2113 | Fax +61-2-805-2929
+
+5) The following major bug (what an embarassment) was found by Mark van
+den Brand at the University of Nijmegen. I can't understand that nobody,
+including myself, found it earlier.
+
+If the left hand side is repeated in alternative production rules
+seperated by semicolons, the result is not what one would want.
+
+For example;
+
+\begin{grammar}
+rule:
+ first alternative;
+rule:
+ second alternative.
+\end{grammar}
+
+is printed more or less as
+
+rule:
+ first alternative;
+ rule:
+ second alternative.
+
+Although this sort of construction may not be used very often when
+writing context free grammars, it is more common in attribute grammars
+(different alternatives have different attributes) and unavoidable in
+affix grammars (some affixes are an inherent part of the left hand
+side). I'm afraid an ugly hack might be necessary to repair this.
+
+6) From Andreas Maassen (maassen@zeus.informatik.rwth-aachen.de)
+The default value for nonterminal didn't work. The problem was that an
+initial "<" was read before the default values were initialised, so that
+it was read as a character, and not as a command. This has now been
+repaired.
+
+I had also forgotten to put "$"'s round the default values, so rather
+than producing "<" and ">", the default was an upside down "!" and an
+upside down "?". This has also been repaired.