Re: [selectors3] nth grammar

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 UTC