[mediaqueries] @media screen and (foo) or (baz)

MQ Level 4 extends the syntax to allow arbitrary nesting of "not", 
"and", and "or" boolean operators. It avoids the question of whether `A 
or B and C` should be interpreted as `A or (B and C)` or `(A or B) and 
C` by requiring the parentheses:

Extract of the grammar:

> <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> ]+
> <media-in-parens> = ( <media-condition> ) | <media-feature> | <general-enclosed>


However, there is one case left that may seem ambiguous. The 
<media-query> grammar:

> <media-query> = <media-condition>
>              | [ not | only ]? <media-type> [ and <media-condition> ]?

accepts `<media-type> and <media-or>`, e.g. `screen and (foo) or (bar)`.

The grammar makes it unambiguously the same as `screen and ((foo) or 
(bar))`, but that’s not obvious without referring to the spec.


Should the grammar be restricted to require parenthenses in this case as 
well?

-- 
Simon Sapin

Received on Monday, 23 March 2015 16:08:59 UTC