Re: [css-mediaqueries] whitespace handling

On Wed, 10 Jul 2013 01:32:01 +0200, L. David Baron <dbaron@dbaron.org> wrote:
> media_query
>    : [ONLY | NOT]? S+ media_type [ S+ AND S+ expression ]* S*
>      | expression [ S+ AND S+ expression ]* S*
>    ;

With this grammar, media_query needs to begin with at least one S if
neither ONLY nor NOT is used.
I guess what we are expecting would be like:

media_query
   : [ ONLY S+ | NOT S+ ]? media_type [ S+ AND S+ expression ]* S*
     | expression [ S+ AND S+ expression ]* S*
   ;

Right?

 - Shiki

2013/7/11 Florian Rivoal <florian@rivoal.net>:
> On Wed, 10 Jul 2013 01:32:01 +0200, L. David Baron <dbaron@dbaron.org>
> wrote:
>
>> On Monday 2013-07-08 12:35 +0200, Florian Rivoal wrote:
>>>
>>> media_query
>>>    : [ONLY | NOT]? S+ media_type S* [S AND S+ expression ]*
>>>      | expression [ S AND S+ expression ]*
>>>    ;
>>
>>
>> So you don't want occurrences of "S" without a * or a +, and I think
>> you also don't want to write the grammar such that you have to read
>> backwards (e.g., "S* S", which requires working backwards to figure
>> out which part of the whitespace matches the S*).
>>
>> So I think it would be better to write:
>>
>> media_query
>>    : [ONLY | NOT]? S+ media_type [ S+ AND S+ expression ]* S*
>>      | expression [ S+ AND S+ expression ]* S*
>>    ;
>>
>> and then remove the trailing "S*" in expression so that it is:
>>
>> expression
>>    : '(' S* media_feature S* [ ':' S* expr ]? ')'
>>    ;
>
>
> Thanks, that does sound better indeed.
>
>  - Florian
>

Received on Friday, 30 August 2013 11:55:36 UTC