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

fantasai <> wrote:

> Stewart Brodie wrote:
> > References: <>
> > 
> > CVS revision 1.4 of test case t040103-ident-03-c.xht
> > 
> > I've been looking at this test that was recently much enhanced to test
> > valid and invalid class and ID selectors more thoroughly and fix issues
> > with the earlier revisions, but I believe that there is still a problem
> > with test case 4.  This is the case of the selector that is:
> > 
> > #-1ident, .four { color:red }
> > 
> > The lexical scanners in the CSS2.1 (19 July 2007) and CSS3's Selectors
> > (15 December 2005) specifications both agree that this selector is
> > valid.  This is because both of them define names the same way:
> > 
> > name   {nmchar}+
> > nmchar [_a-z0-9-]|{nonascii}|{escape}
> > 
> > %%
> > 
> > "#"{name}   { return HASH;}
> > 
> > 
> > Is this an incorrect test case or are the specifications themselves not
> > describing the intended scanner?  I'm not particularly bothered either
> > way, but the inconsistency needs to be resolved.
> In a lot of cases the grammar is more permissive than the prose. In these
> cases the prose takes precedence.
> According to
> 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.

Stewart Brodie
Software Engineer
ANT Software Limited

Received on Wednesday, 22 August 2007 14:37:48 UTC