W3C home > Mailing lists > Public > www-style@w3.org > December 2012

[css4-values] Make comma auto-optional in grammars?

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Tue, 18 Dec 2012 11:29:28 -0800
Message-ID: <CAAWBYDALrCbDcpjP-rAkuo0te=AiD8Hp5JwOQ7Df_Ke8LFuhyw@mail.gmail.com>
To: www-style list <www-style@w3.org>
This is something that's been bugging me for a while.

Most of the time, CSS just uses whitespace as a separator between
values.  This works great, because if a term is omitted, the implied
whitespace on either side just collapses into a single whitespace
block, so you don't have to worry about "too much" whitespace being
left around when a term is omitted.

Sometimes, though, we use a comma to separate terms, and it doesn't
have this behavior.  If a term is completely omitted, you have to
carefully construct the grammar to force an associated comma to also
be omitted.  This distorts a bunch of grammars, forcing a lot of extra
wrappers and duplication of terms, making them harder to read than
they should be.  One of the major purposes of our grammar is to be a
relatively easily-understandable description of the allowed values, so
this is a failure.

Could we perhaps define the use of the comma in grammars to have this
behavior automatically?  Here's some before/after examples of how this
would help.

 [ [ <shape> || <size> ] [ at <position> ]? , |
    at <position>,
[ <shape> || <size> ]? [ at <position> ]? <color-stop-list>

<image-tags>? [ <image-src> , ]* [ <image-src> | <color> ]
<image-tags>? <image-src># , <color>?

[ <image-set-decl>, ]* [ <image-set-decl> | <color>]
<image-set-decl># , <color>?

Specifically, the rule would be that, a comma must be omitted if,
ignoring whitespace and comments, it would be the first or last token
in the function/property value, or if the immediately preceding token
is also a comma.  Informally, commas must separate terms, so omit them
if they don't.

Received on Tuesday, 18 December 2012 19:30:14 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:24 UTC