Validating media queries in Java

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 14:43:20 UTC