

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

From: Peter Moulder <peter.moulder@monash.edu>
Date: Sat, 05 Mar 2011 01:39:04 +1100
To: www-style@w3.org
Message-id: <20110304143904.GA9812@bowman.infotech.monash.edu.au>
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:

    : [namespace_prefix]? '|'
    : namespace_prefix? '|'
    | '*' '|'

where namespace_prefix is defined in section 3.1 as:

    : 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 '|'.

Received on Friday, 4 March 2011 14:39:35 GMT
