Re: [css-values] The last grammar combinator - 1+ in order

On Thu, Apr 17, 2014 at 5:27 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
> We're currently missing a grammar combinator in CSS's property grammar syntax.
>
> We can express "exactly one" as "a | b", and we can express 5 of the 6
> possibilities in {0+, 1+, all}×{in order, any order}* .  The one thing
> we're missing is "1+, in order", which we can't write without
> duplication and honestly confusing grammar.

More syntax possibilities:

* A // combinator - it looks similar to ||, which is good, because
they both occupy the "1+" row in the table.

* A way of indicating that something is "required", which means the
term inside can't disappear to nothingness.  I thought of using ! as a
counterpoint to ?, like "[A? B?]!".  fantasai indicated that she
doesn't like this, because it looks like a multiplier.

One wrinkle is that a combinator is not compatible with
comma-separation (or in general, any non-whitespace separator), which
makes it complicated to use with several of the things that we already
know we want to use it on, like image() and <picture>'s "sizes"
attribute.  zcorpan suggested that we could amend the existing
multi-choice combinators to allow a comma between the two characters,
to indicate that the choices are comma-separated, like "A |,| B |,| C"
allowing "A" or "A, C", or "C, A, B", etc.

Related to this wrinkle, the existing syntax for "0+, in order", which
is "A? B?", also isn't compatible with non-ws separators - you need a
comma if you include both, but not if you omit either.  I think we can
solve this without any new syntax, by just declaring that commas in
the grammar always get omitted if they're not separating anything.  I
think this would let us simplify a few grammars as well, where we're
currently required to do some complicated fiddling with brackets due
to the presence of commas.

~TJ

Received on Thursday, 24 April 2014 02:17:33 UTC