user187291 user187291 - 1 year ago 134
PHP Question

standalone grammar and parser for php

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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download