Re: [css3-values] calc(), whitespace, and DIMENSION tokens

On Wednesday 12 March 2008 13:41, Andrei Polushin wrote:
> 2008/3/12, fantasai wrote:
> >  I'll note that
> >    3cm-2cm
> >  will be parsed as a single DIMENSION token

I seem to remember that we discussed this during some meeting and 
concluded that white space (or a comment) would indeed be needed 
between a dimension and the following minus sign and that we would just 
have to warn users about that...

> >  and 
> >    3cm -2cm
> >  will be parsed as two DIMENSION tokens. Is that what we want? Is
> > whitespace required around minus and plus signs to treat them like
> > operators or is tokenization different inside calc() like it is
> > inside :nth-child()?
> I propose changing the grammar around the {ident} as follows:
>   nmstart   [_a-z]|{nonascii}|{escape}
>   nmchar    [_a-z0-9-]|{nonascii}|{escape}
>   alpha     [a-z]|{nonascii}|{escape}
>   alnum     [_a-z0-9]|{nonascii}|{escape}
>   restrict  {alpha}{alnum}*
>   simple    {nmstart}{nmchar}*
>   prefixed  [_-]{restrict}[-]{simple}
>   ident     {simple}|{prefixed}
>   unit      {restrict}|{prefixed}
>   %%
>   {num}{unit}   {return DIMENSION;}
> That is, the unit name cannot contain '-', unless that unit name
> starts with either '-' or '_', as described by

That will indeed make "3n-1" parse as DIMEN(3n) + DELIM(-) + NUMBER(1), 
but parsers still have to check that the DIMEN is a whole number with 
an "n" or "N"; and "n-1" remains an IDENT. (Of course, "n-1" won't 
occur very often in practice. :-) )

So I think there is no benefit for nth-child.

It also doesn't remove the need for a space after 'mod' in 'calc(10% 
mod-2em)', although it avoids many other possible user errors: 

But it's a change to the core grammar, a very dangerous thing to do:

1) Are there any vendor extensions that we don't know about and that do 
not have a dash after the vendor prefix? CSS 2.1 currently says they 
*should* have a dash, but Andrei's patch makes that into a *must*.

2) Are there any languages that use the CSS syntax and that use units 
with a dash? CSS itself doesn't have such units, but we shouldn't break 
something that relies on our promise to not change the syntax.

3) Is CSS itself never going to add units with a dash?

  Bert Bos                                ( W 3 C )                               W3C/ERCIM                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France

Received on Monday, 17 March 2008 17:06:11 UTC