W3C home > Mailing lists > Public > www-style@w3.org > May 2010

Re: [selectors3] nth grammar

From: Rune Lillesveen <rune@opera.com>
Date: Wed, 12 May 2010 14:38:14 +0300
To: www-style@w3.org
Message-ID: <op.vclep0hy8isf1p@id-c0585.oslo.osa>
On Wed, 12 May 2010 15:22:19 +0300, Anne van Kesteren <annevk@opera.com>  
wrote:

> The grammar in http://dev.w3.org/csswg/selectors3/#nth-child-pseudo
>
> nth
>    : S* [ ['-'|'+']? INTEGER? {N} [ S* ['-'|'+'] S* INTEGER ]? |
>           ['-'|'+']? INTEGER | {O}{D}{D} | {E}{V}{E}{N} ] S*
>    ;
>
> could probably use some additional explanation or revision. E.g.  
> "2/*comment*/n" parses as what is stated there but "2n" will parse as  
> DIMENSION. It also seems to imply that "ev/*comment*/en" matches  
> {E}{V}{E}{N} which is probably not intended.
>
> I recall this being discussed before, but I cannot find anything in the  
> draft that clarifies things.

This odd mix of an imprecise lexer and grammar spec will cause  
incompatible implementations and should be dropped. You have a few  
alternatives:

1. Write up a proper grammar using the existing tokens from the lexer spec  
(Will look ugly).
2. Introduce a context sensitive lexer that tokenizes differently for  
nth-expressions.
3. Write the spec in prose only.

-- 
Rune Lillesveen
Senior Core Developer
Opera Software ASA
Received on Wednesday, 12 May 2010 12:38:51 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:27 GMT