When is a SAX Parser not a SAX Parser?
I was talking to someone about ANT the other day and we got onto it bad points, to which, being written in XML came up. This lead me to think about how you could rewrite ANT to not use XML, as a simple solution.
After a quick bit of investigation, I realized that ANT uses SAX for parsing the build.xml file. SAX is just a set of interfaces that a parser must use in the parsing of XML, but there is no requirement that what it is parsing is XML (from a technical point of view). So, why not write a parser that can respond in an intelligent way to the interfaces while parsing something else?
After a day's worth of work, I now have a naive parser that parses something that isn't XML. The easy part was writing the parser, thanks to JavaCC. The language at the moment just uses identifiers for tag names followed by identifiers and string literals for tag attributes and either a body or a semicolon. Bodies start with { and end with } and can include more tags recursively. I'm also toying with the idea of using a lisp list syntax. Just for fun...
The really hard part is getting my head around JAXP and how ANT gets a parse from it. I've got the bare bone basics started, but I ran out of time. I'm hopeful that given another day or two, I'll have a naive SAX parser that will allow me to use something other than XML to define ANT builds. I'm tentatively calling this project Clarinet. 8)
After this is successful, I can then fine tune the parser to be specific for ANT and lose some of the XML generality. There's no guarantee that I'll get this far or even take another step beyond where I currently am, but I haven't had a good excuse to play with JavaCC in a long time and I am enjoying myself...
And all this takes me back to when I tried building a tool that would allow the definition of GUI with XML files. That is, an application that would dynamically produce GUI's from definition at run time. Now I'm thinking that I might be better served to scrap the XML from the whole idea and just do it with JavaCC. So many things to do and so little time.

0 Comments:
Post a Comment
Links to this post:
Create a Link
<< Home