[mediaqueries] Editorial: <media-condition> grammar requires unbounded look-ahead

The grammar currently is:

> <media-condition> = <media-not> | <media-and> | <media-or> | <media-in-parens>
> <media-not> = not <media-in-parens>
> <media-and> = <media-in-parens> [ and <media-in-parens> ]+
> <media-or> = <media-in-parens> [ or <media-in-parens> ]+

When parsing <media-condition>, deciding which of the alternatives 
should be taken may require looking ahead by an unbounded amount.

To avoid this, it could be rewritten as:

<media-condition> = <media-not>
                   | <media-in-parens> [ <media-and>* | <media-or>* ]
<media-not> = not <media-in-parens>
<media-and> = and <media-in-parens>
<media-or> = or <media-in-parens>


Unfortunately that makes more awkward the definitions that follow

> Each of the major terms of <media-condition> is associated with a
> boolean result, as follows:


Note that we made a similar change to the @page grammar for this reason:

https://lists.w3.org/Archives/Public/www-style/2012Apr/0620.html

(Although the @page one is even more awkward, since we had to use 
recursion instead of repetition.)

-- 
Simon Sapin

Received on Monday, 23 March 2015 16:19:31 UTC