Re: Error in the SRFI-30 formal specification Albion Petrofsky 12 Jan 2003 10:34 UTC

> >>>>> Almanac Petrofsky <xxxxxx@petrofsky.org> writes:

> > Actually, I think "the way" would be more like this:
>
> >   <comment> ---> ; <all subsequent characters up to a line break>
> >                | <srfi-30-comment>
>
> >   <srfi-30-comment> ---> #| <srfi-30-comment-body>* |#
>
> >   <srfi-30-comment-body> ---> <character sequence not containing #| or |#>
> >                             | <srfi-30-comment>
>
> > That eliminates the lopsidedness of srfi-30-comment, and also
> > eliminates the confusing use of parentheses to indicate a BNF grouping
> > rather than parentheses tokens (which is what they mean throughout
> > r5rs 7.1).

> From: Martin Gasbichler <xxxxxx@informatik.uni-tuebingen.de>

> But this eliminates the possibility to write
>
> #| foo #| bar |# baz |#
>
> i.e. the possibility to write "useful" nested comments.

It does allow that: " foo ", "#| bar |#", and " baz" are all valid
<srfi-30-comment-body>s.

Unfortunately, it also allows "#| #| |#", because " #" and "| " are
valid <srfi-30-comment-body>s.

> I agree that the use of parentheses is unfortunate but this can be
> fixed by a new non-terminal:
>
> <comment> ---> ; <all subsequent characters up to a line break>
>                | <srfi-30-comment>
>
> <srfi-30-comment> ---> #| <comment-text> <srfi-30-comment-and-text>* |#
>
> <srfi-30-comment-and-text> ---> <srfi-30-comment> <comment-text>
>
> <comment-text> ---> <character sequence not containing #| or |#>

A problem with that is that it allows "#| #|#", but your
implementation doesn't, and I don't think you want it to.  Man, these
multi-character undelimited tokens are tricky.

I think this corresponds to your implementation:

  <comment> ---> ; <all subsequent characters up to a line break>
               | <srfi-30-comment>

  <srfi-30-comment> ---> #| <srfi-30-comment-constituent>* |* |#

  <srfi-30-comment-constituent> ---> #* <srfi-30-ordinary-char>
                                   | |* <srfi-30-ordinary-char>
                                   | #* <srfi-30-comment>

  <srfi-30-ordinary-char> ---> <any character but # or |>

-al