Re: [css3-namespace] grammar for toto|A, whitespace & comments

On 03/04/2011 06:39 AM, Peter Moulder wrote:
> Sections 3.1 and 4 give the following grammar fragments, each said to be
> using "the notation from the Grammar appendix of CSS 2.1".
>
> Section 4:
>
>    qname_prefix
>      : [namespace_prefix]? '|'
>      ;
>    wqname_prefix
>      : namespace_prefix? '|'
>      | '*' '|'
>      ;
>
> where namespace_prefix is defined in section 3.1 as:
>
>    namespace_prefix
>      : IDENT
>      ;
>
> (where it is used by the namespace production, which explicitly follows
> it with S*).
>
> Note that the Grammar appendix of CSS2.1 (as with the core grammar in
> CSS21/syndata.html) uses explicit S tokens for white space, but the lexer
> in the grammar appendix ignores comments.
>
> I believe this means that
>
>    toto/* comment */|/* comment */A    and
>    */* comment */|/* comment */A
>
> are syntactically valid, while
>
>    toto |A    and
>    * |A
>
> are not.
>
> (It isn't completely clear whether white space is allowed after the '|';
> though I'd tend to read it that space isn't allowed there.)
>
> This is surprising.
>
> I believe it is worth commenting explicitly on whether white space and/or
> comments can occur either side of the '|' token.
>
> At least in CSS 2.1 (including the core grammar), the set of places where
> comments can occur equals the set of places where S tokens can occur,
> namely before or after any other token [ignoring @charset issues].  I
> don't know if any other CSS modules require distinguishing between S and
> comment tokens; but on the basis of this limited knowledge of CSS
> modules, I would tend to suggest that if '|' is to be considered a
> separate token (which it is in the core grammar) then it would be good to
> allow UAs to accept white space and/or comments either side of the '|'.
> Of course that doesn't preclude making authoring/stylistic
> recommendations not to have any space or comments around the '|'.

We currently have three implementations (Webkit, Gecko, Opera) that
accept comments but not white space around the |. So I think that's
the behavior we ought to stick with.

I've appended to
   # The syntax uses notation from the Grammar appendix of CSS 2.1.
the following
   | Note this means that comments, but not white space, are implicitly
   | allowed between tokens.

Would that be a sufficient edit to clarify this situation, or would
there be other (or different) changes necessary?

~fantasai

Received on Thursday, 7 April 2011 05:19:15 UTC