[Gd-hackers] Bug in the Dylan Reference Manual?
Markus Fenske
iblue at gmx.net
Thu Jun 7 03:27:36 CEST 2007
2007/6/6, Chris Page <chris at chris-page.org>:
> On Jun 3, 2007, at 14:08 PM, Markus Fenske wrote:
>
> > So either "#-word" should be uppercase in
> > http://www.opendylan.org/books/drm/Lexical_Grammar and
> > http://www.opendylan.org/books/drm/Phrase_Grammar or it should be
> > defined in
> > http://www.opendylan.org/books/drm/Phrase_Grammar before beeing used.
>
> I'm not certain what the answer should be here. It seems that #-word
> is only in the lexical grammar because it is referenced by TOKEN, but
> TOKEN isn't referenced anywhere in the phrase grammar, despite being
> in all-caps. In fact, TOKEN isn't referenced anywhere in the BNF;
> "token" is mentioned only informally in the text.
Right. Characters and character sequences like "(", ")", "::", "==", ...
are directly exported to the phrase grammar and not converted to
"TOKEN". They are just mentioned because they are allowed.
It would be logical to write "token" in small caps.
> I think it's clear that the BNF appendix isn't a strict, minimal
> grammar, and it contains some informally worded parts that are there
> primarily to aid the expositive text. It may be that "#-word" is
> explicitly not all-caps, despite the comment in the BNF General
> Notes, since it's mentioned in the text as "#-word".
If you'd write a compiler for Dylan, you'd first take a look in the DRM,
find
the BNF, and try to implement a lexer and a parser based on this. Then,
you'd see that the lexical grammar has lots of errors and that the phrase
grammar contains about 50 parsing conflicts (see the "substitution"-token
in the phrase grammar, the third line: "?? NAME separator_opt ...".
The opendylan parser implements this as "?? NAME", because it collides
with the "template-element" token.
So, in conclusion, I agree that the BNF appendix is not the strict, minimal
grammar
it should be, but one big parsing conflict. It is almost useless.
> If "#-word" were changed to "#-WORD" in the BNF, the next question
> is: How does this affect references to "#-word" in the text? Should
> it be changed to "#-WORD" or even "#-WORD(BNF)"? (Where "(BNF)" is
> "BNF" in all-caps, subscripted, as is done in a number of places in
> the DRM.)
I think I've found the correction:
Replace TOKEN by token, because it's not exported. In the Lexical Grammar,
define:
#-word:
one of #next #rest #key #all-keys #include
boolean:
one of #t #f
Then add to the Phrase Grammar:
#-word:
one of #next #rest #key #all-keys #include
#next, #rest, #key, #all-keys and the #-word token are used directly in the
phrase grammar, as well as #t and #f.
Are #t and #f #-words in the usual sense? Or are they literals?
The phrase grammar allows this:
> let handler ([type], [symbol] [#-word], [symbol] [#-word], ...) =
[expression];
So, this is *syntactically* correct?:
> let handler (<foobar>, foo: #f, bar: #t) = [expression];
Or this?:
> let handler (<foobar>, foo: #key, bar: #rest) = [expression];
More information about the hackers
mailing list