Lexers and Parsers in PHP
I’ve spent the last hour looking into PHP_LexerGenerator and PHP_ParserGenerator. There seem to be docs for the lexer at the author’s PEAR instance (including an example), but I haven’t been able to turn up an example for the parser yet. It’s been ages since I looked at even yacc or bison, so I’m not quite ready to jump directly into trying to code something up.
I haven’t been able to find any examples of projects using either package. That may have something to do with the dearth of documentation.

Or, it may have something to do with PHP being a bad language for that sort of thing.