Re: Issue in CSS21 grammar?

On Tuesday 10 February 2009, Yves Lafon wrote:
> On Mon, 9 Feb 2009, fantasai wrote:
> > Yves Lafon wrote:
> >> So the text and the grammar are not synchronized.
> >>
> >> Shouldn't selector use a production capturing those requirements,
> >> (something along the line of HASHIDENT = '#' IDENT) instead of
> >> HASH?
> >
> > The grammar in general is a lot more lax than what CSS2.1 requires.
> > Bert will have to give you the long explanation, syntax isn't my
> > specialty. :)
>
> I completely agree that a grammar is not the place to enforce all the
> special cases of the specification, there are constraints that can't
> be expressed in the grammar, but in this specific case, I can't
> imagine a selector being a HASH and not a HASHIDENT (as specified by
> '#' IDENT )
>
> If HASHIDENT is not needed, then IDENT is not needed, and we should
> move all the IDENT to NAME and put the constraint in the text of the
> spec :) Cheers,

It's probably an improvement to add "except for IDs" to 4.1.3[1], 
changing the text in the second bullet from

    they cannot start with a digit, or a hyphen followed by a digit.
to
    except for IDs, they cannot start with a digit, or a hyphen followed
    by a digit.

Why should UAs reject "#-2bar"? It is just extra work. Especially if you 
consider the following rule:

    #112233, p { color: #112233 }

which the UA would have to reject, because the first HASH tokens is used 
in the role of an ID.

I believe the intention of the text in that 2nd bullet of 4.1.3 was 
simply to explain the meaning of the grammar, not to impose extra 
parsing rules. My change (above) tries to make it so.

[1] http://www.w3.org/TR/2007/CR-CSS21-20070719/syndata.html#characters



Bert
-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos                               W3C/ERCIM
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France

Received on Tuesday, 24 February 2009 19:57:33 UTC