Re: [css-variables] Syntax of custom property declarations

On Sun, Apr 14, 2013 at 7:00 AM, Simon Sapin <simon.sapin@exyr.org> wrote:
> Hi,
>
> The "Values" line for custom properties is defined as:
>
>   [ <value> | <CDO> | <CDC> ]+
>
> Where <value> is defined in the CSS 2.1 core grammar:
>
>> stylesheet  : [ CDO | CDC | S | statement ]*;
>> statement   : ruleset | at-rule;
>> at-rule     : ATKEYWORD S* any* [ block | ';' S* ];
>> block       : '{' S* [ any | block | ATKEYWORD S* | ';' S* ]* '}' S*;
>> ruleset     : selector? '{' S* declaration? [ ';' S* declaration? ]* '}'
>> S*;
>> selector    : any+;
>> declaration : property S* ':' S* value;
>> property    : IDENT;
>> value       : [ any | block | ATKEYWORD S* ]+;
>> any         : [ IDENT | NUMBER | PERCENTAGE | DIMENSION | STRING
>>               | DELIM | URI | HASH | UNICODE-RANGE | INCLUDES
>>               | DASHMATCH | ':' | FUNCTION S* [any|unused]* ')'
>>               | '(' S* [any|unused]* ')' | '[' S* [any|unused]* ']'
>>               ] S*;
>> unused      : block | ATKEYWORD S* | ';' S* | CDO S* | CDC S*;
>>
>> The "unused" production is not used in CSS and will not be used by
>> any future extension. It is included here only to help with error
>> handling.
>
>
> I’m a bit confused as to what this means exactly. Is <declaration> extended
> to allow CDO and CDC? Is <unused> allowed in spite of being … "not used"?
> Are CDO and CDC allowed inside a {} block? Is a declaration-level ';' token
> allowed?
>
>     var-foo: <!-- bar -->;
>     var-foo: [@bar];
>     var-foo: [{}];
>     var-foo: [;];
>     @supports (var-foo: bar;baz) {}
>     var-foo: [<!-- bar -->];
>     var-foo: {<!-- bar -->};
>     var-foo: /* unmatched */ )]};
>     var-foo: url("bar" bad url);
>     var-foo: bar "Bad string: unquoted newline
>       ;
>     var-foo: bar /* Bad comment not closed until EOF
>
> Even if such corner cases would never be valid in a "real" property through
> var(), they make a difference in which custom properties are available
> through CSSStyleDeclaration.
>
> I’d be more comfortable with a negative definition. Something like: "any
> sequence of tokens except BAD_STRING, BAD_URL, BAD_COMMENT[1], unmatched
> ')', unmatched ']', and unmatched '}'."
>
> [1] Not sure about BAD_COMMENT as Syntax 3 makes all comments valid, even
> unclosed.
>
> A definition based on Syntax 3 (which defines precisely how any character
> sequence is parsed into a tree of "component values") would be even better,
> but I understand that Syntax 3 might not be mature enough to be referenced
> from Variables which we want to progress fast.
>
> I’m not asking for a change here, only clarification. I hope this will not
> delay the spec going to LC and CR.

A Syntax-based definition of the value is simply "(anything, see
prose)", with the prose informatively explaining some of the implicit
restrictions that arise from the parser.

I'd be fine with switching over to that as soon as Syntax is approved
for FPWD (hopefully at the f2f).

~TJ

Received on Sunday, 19 May 2013 23:53:01 UTC