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

Re: [css3-values] Order-sensitive "one or more" component value combinator

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Fri, 20 Apr 2012 16:16:08 -0700
Message-ID: <CAAWBYDD0T_cTH5H5AHjLtz_O1L2s13rOMRjH_hJRhr4M5uqrGQ@mail.gmail.com>
To: fantasai <fantasai.lists@inkedblade.net>
Cc: "www-style@w3.org" <www-style@w3.org>
On Fri, Apr 20, 2012 at 3:04 PM, fantasai <fantasai.lists@inkedblade.net> wrote:
> There's a few places where our grammars would be much simpler (less
> repetition)
> if we had a combinator that meant "this or that or both, but in this order".
> (We have the double-bar, which means "this or that or both", but there's no
> ordering requirement there.)

Note that we already have a "zero or more of these, in order" pattern:

a? b? c?

It's just that implementing a "one or more of these, in order" pattern
requires some confusing grammar contortions:

  a b? c?
  b c?

This is obviously ugly, confusing, and repetitive.

However, the only place I know of that uses this pattern is the
radial-gradient() grammar.  This is an odd case because, while the
"one or more in order" combinator is a valid solution to the grammar
woes, the real problem there is simply that it's very awkward to deal
with comma-separated lists when some components may be omitted.

If I had an "comma if required" symbol, I wouldn't need the above
combinator for radial-gradient().

The "comma if required" symbol would also help with other grammar
issues, like the stacking brackets for optional arguments at the *end*
of a comma-separated list.  For example, I go through some contortions
in the grammar for the image() function:

image( [ <image-decl> , ]* [ <image-decl> | <color> ] )

This ensures that I can have (a) a list of <image-decls>, (b) a list
of <image-decls>s with a <color> at the end, and (c) a <color> all by

With maybe-comma, it could look like this:

image( <image-decl>#? MAYBECOMMA <color> )

And since I only say <image-decl> once now, I could potentially even
inline that definition (though I do use it in the prose below, so
maybe not).

So anyway, are there more places that would benefit from "one or more,
in this order" than radial-gradient()?

Received on Friday, 20 April 2012 23:16:57 UTC

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