Lexers and Parsers

I finally took the plunge in the land of lexers and parsers. I’ve been meaning to learn about these for sometime as I have this little nagging feeling inside that the parser in SiteMesh is still not as fast as it could be.

If it was written by a compiler compiler it would be a lot more maintainable and faster. So I’ve been looking at the combinations of using JFlex and Cup (Java versions of Flex and Yacc) or the famous Antlr.

My first parser is for MockDoclet and is designed to be a really fast and lightweight parser for extracting JavaDoc comments and interface definitions from a Java source file (I was originally using JavaDoc for this, but it’s wayyy to slow - breaks my five second build patience tolerance barrier). I’m kind of enjoying it. It also opens up a new world of development opportunites for me - previously I’ve always relied on other people’s parsers so have been lumbered with things like XML as grammars, which may be easy to parse, but it’s a pain to write sometimes - too much typing.

Relying on other people’s parsers for your code? Have a go at building your own - it’s very liberating.