- From: Bert Bos <bert@w3.org>
- Date: Wed, 6 Feb 2008 23:08:21 +0100
- To: W3C Style List <www-style@w3.org>
- Message-Id: <200802062308.21748.bert@w3.org>
The grammar I gave was missing a "?" after [ONLY | NOT] and the definition of "value" cannot be copied exactly from CSS 2.1, because the new tokens NOT, ONLY, AND and ',' must be added to it. The complete grammar is: media_query_list : S* media_query [ ',' S* media_query]* ; media_query : [ONLY | NOT]? S* media_type [ AND S* expression ]* | expression [ AND S* expression ]* ; media_type : IDENT S* ; expression : '(' S* media_feature [':' S* value]? ')' S* ; media_feature : IDENT S* ; value : [ any | block | ATKEYWORD S* ]+ ; any : [ NOT | ONLY | AND | ',' | IDENT | NUMBER | PERCENTAGE | DIMENSION | STRING | DELIM | URI | HASH | UNICODE-RANGE | INCLUDES | DASHMATCH | FUNCTION S* any* ')' | '(' S* any* ')' | '[' S* any* ']' ] S* ; block : '{' S* [ any | block | ATKEYWORD S* | ';' S* ]* '}' S* ; Attached are an equivalent Bison grammar and a Flex tokenizer. When compiled, they yield a program that either "normalizes" the input or prints an error. The program also checks the semantics of the media queries to a certain extent: If a media query is syntactically valid, but contains an unknown media type or unknown media features, the media query is printed as "NOT all" (i.e., a query that never applies). Checking that the value of each media feature is valid is left as an exercise for the reader :-) Bert -- Bert Bos ( W 3 C ) http://www.w3.org/ http://www.w3.org/people/bos W3C/ERCIM bert@w3.org 2004 Rt des Lucioles / BP 93 +33 (0)4 92 38 76 92 06902 Sophia Antipolis Cedex, France
Attachments
Received on Wednesday, 6 February 2008 22:08:35 UTC