W3C home > Mailing lists > Public > public-css-testsuite@w3.org > August 2007

Re: problem with t040103-ident-03-c.htm?

From: Stewart Brodie <stewart.brodie@antplc.com>
Date: Wed, 22 Aug 2007 18:19:24 +0100
To: fantasai <fantasai.lists@inkedblade.net>
Cc: public-css-testsuite@w3.org, www-style@w3.org
Message-ID: <a9bfcd6f880602770efb0d1deedcb3ac4d5f126d@localhost>

fantasai <fantasai.lists@inkedblade.net> wrote:

> Stewart Brodie wrote:
> > fantasai wrote:
> >> According to
> >>    http://www.w3.org/TR/CSS21/selector.html#id-selectors
> > > an ID selector is an identifier, and these are not allowed to start
> > > with a hyphen plus a number. I just checked with Bert, and he agrees
> > > the test is correct.
> > 
> > OK.  Given that it must be an identifier, is there are reason why the
> > rule in the grammar (in both specifications) should not be corrected to:
> > 
> > "#"{ident}   { return HASH;}
> > 
> > and delete the definition of 'name' completely?  This would make the
> > grammar agree with the prose.  Apart from preventing "#-<digit>" being a
> > HASH token, it would also prevent "#--" from generating a HASH token -
> > also a correct change, I believe.
> > 
> > On reflection, this would have a knock-on effect in parsers that expect
> > a HASH token for the value of a color property, of course.  Is that the
> > reason why the grammar is still as it is?  If it is, I think that
> > inserting a comment at the top of the lexical scanner would be a
> > worthwhile addition.
> 
> Yeah, using the same token for both colors and IDs was imho not a very
> good idea. If you write up the exact changes necessary to split them, I
> can add this to the issues list. :)
> 
> ~fantasai

It can be done a couple of different ways, I think.  The simplest way to
change it would be to ensure that idents are no longer valid names.  Change
the definition of name such that the first character after the optional
hyphen cannot come from the intersection of nmstart and nmchar.  The way to
do this would be the same for both specs:

name       [-]?[0-9-]{nmchar}*

%%

"#"{ident}      return HASH
"#"{name}       return HASHNAME


and then in the CSS2.1 spec:

hexcolor:
    [ HASH | HASHNAME ] S*

[Actually, it would be better for the CSS2.1 to actually tie down the rules
for hexcolor to be 1 or 2 instances of a group of three hexadecimal digits,
but it's probably not worth going to that extreme?]

There is no ABNF definition (that I can find) for CSS3 colour values in
either CSS3 Values & Units Module or in CSS3 Color Module: it is merely
explained in the prose as a hash character followed by 3 or 6 hexadecimal
digits, so no change would be required there (the parser writer just has to
find a way of examining the token stream to determine the value)

Even that is insufficient as web browsers have quirks mode issues where they
have to deal with a string of hexadecimal characters *without* the leading #
character!

Something that looks even simpler, but doesn't work, would be to do without
the redefinition of 'name', but that would lead to tokenisation problems
(because all idents are valid names in the existing specs).

If you don't mind the CSS2.1 and CSS3 Selectors diverging, you could simply
change the Selectors spec to make the HASH token be "#"{ident} and then
delete name altogether, since the specification is only concerned with the
grammar of selectors and then it becomes the Color module's problem.  I'm
not sure I like the idea of divergence, though.


-- 
Stewart Brodie
Software Engineer
ANT Software Limited
Received on Wednesday, 22 August 2007 17:19:31 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 20 September 2010 17:51:55 GMT