W3C home > Mailing lists > Public > www-validator-css@w3.org > November 2007

Validating media queries in Java

From: Henri Sivonen <hsivonen@iki.fi>
Date: Fri, 16 Nov 2007 17:11:44 +0200
Message-Id: <72C13F5E-3BF3-4052-A058-FA0B5EB3DD5C@iki.fi>
To: www-validator-css@w3.org

(I first sent this to www-style but was advised to resend here.)

I'm trying to validate CSS Media Queries as HTML5 attribute values.  
I'm using Java.

I first thought that media queries would be syntactically very simple-- 
something for which importing the W3C CSS Validator or a parser  
generator as a project dependency would be and overkill. I have since  
learned that most of the complications are hiding inside <value> and  
the language is nowhere near as simple as the pseudo-BNF in the Media  
Queries spec makes it appear. In particular, even traditional CSS  
lengths make the states in the parser balloon and support for calc()  
would make things much, much more complex.

I'm now considering abandoning my hand-rolled code in favor of either  
a customized generated parser or a generic CSS parser that someone has  
already written. I checked out the W3C CSS Validator source today.  
Unfortunately, it seems that it doesn't have an entry point for  
parsing media queries in isolation and the JavaCC grammar it uses is  
tightly coupled with the program internals.

I'd appreciate advice:
Is there some Open Source work that I'm missing but could use? Other  
recommendations on how to proceed?

-- 
Henri Sivonen
hsivonen@iki.fi
http://hsivonen.iki.fi/
Received on Friday, 16 November 2007 15:11:59 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 27 June 2012 00:14:19 GMT