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

On Wed, Apr 23, 2014 at 4:25 PM, Brad Kemper <brad.kemper@gmail.com> wrote:
>> On Apr 17, 2014, at 5:27 PM, "Tab Atkins Jr." <jackalmage@gmail.com> wrote:
>> 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.
>>
>> For example, the syntax for background-position-x takes a side keyword
>> and/or a length/percentage.  You can specify either or both, but can't
>> specify none.  Today, that requires writing something like:
>>
>> [left | right] |
>> [left | right]? [<length> | <percentage>]
>>
>> I don't know about you, but I don't see that as saying "a keyword
>> and/or a length/percentage".  It's hard to read, and means we're
>> duplicating terms in the grammar, making it larger and even harder to
>> read, or else requiring indirection through an intermediate grammar
>> production.
>
> How about this:
>
> [left | right] | [<length> | <percentage>]{1}
>
> ...and we say that when a {positive number} or '+' appears after the square brackets, that you cannot legally less than one of those words.

That's changing the meaning of both the | combinator and the {N}
multiplier, though, in ways that aren't consistent with how they're
used otherwise.  The code you wrote above is already technically
legal:  "[A | B]{1}" means the same as "A | B".

~TJ

Received on Thursday, 24 April 2014 01:44:22 UTC