i'm looking for a ready-made grammar and parser for php (at least 5.2), ideally an utility/library that can parse php code into a readable AST, e.g. xml. The parser itself doesn't have to be written in php, the source language doesn't matter much.
The PHP compiler is open source. Goto http://php.net and dowload the latest version of the source tree. You will find the parser in there.
Our DMS Software Reengineering Toolkit is generalized compiler technology used to parse/analyzer/transform arbitrary computer langauges. It parses to ASTs, and has support for building symbol tables, and various types of flow graphs.
It has a PHP Front End that is fully PHP 5.x compliant, automatically builds full ASTs, using DMS as a foundation. It can export XML, but our experience (and the design of DMS) says you get a lot more milage by staying "inside" DMS with the AST data structure, doing your work there, with DMS's huge library of AST manipulation and pattern matching facilities, and then generating your result, rather than trying to handle the huge amounts of XML that you will get.
This front end has been used in a number of production tools.
To answer my own question I've managed to compile phc on my OSX box, the parser part seems to work well
phc --dump-xml=ast foo.php > bar.xml
creates an xml representation of the AST.