Re: Package Proposal: PHP_Parser
| From: | Wolfram Kriesing | Date: | Tue, 08 Jul 2003 06:02:28 +0000 |
| Subject: | Re: Package Proposal: PHP_Parser | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-18082@lists.php.net to get a copy of this message | ||
+1
Greg Beaver wrote:
Hi all,
Some of you may remember that Alan proposed the PHP_Parser class a few weeks ago, an auto-generated parser for PHP. Since then, I've taken over the task of developing the parser so that it will work with PHP 5.
Well, I've now got a parser that works in both PHP 4 and PHP 5, and does some pretty cool stuff that makes it the obvious choice for phpDocumentor version 2.0. The question now is do you want a PHP Parser in PEAR that has these features:
PHP_Parser is a source code analysis tool based around a real Parser
generated by phpJay. The parser uses the same EBNF source that PHP
uses to parse itself, and it therefore as robust as PHP itself.
This version has full support for parsing out every re-usable element
in PHP 5 as of beta 1:
- classes
- abstract classes
- inheritance, implements
- interfaces
- methods
- exception parsing directly from source
- static variables declared
- global and superglobal ($_GET) variables used
and declared
- variables
- constants
- functions (same information as methods)
- defines
- global variables (with help of the Tokenizer Lexer)
- superglobal variables used in global code
- include statements
The output can be customized to return an array, return
objects of user-specified classes, and can also be
customized to publish each element as it is parsed, allowing
hooks into parsing to catch information.
This last part is the most important piece of information. What this means is that in many cases, the PHP_Parser class can be used without modification to the original source, or without the need to extend PHP_Parser_Core.
This also means using the parser to do things like beautify source code, or highlight and Xref source code will be possible in the 1.0 release, hence the proposal as a PEAR package
Source is available at:
http://cvs.phpdoc.org/cvs.php/phpdoc/PHP_Parser
Specifically, the generated parser is at:
http://cvs.phpdoc.org/co.php/phpdoc/PHP_Parser/Parser/Core.php?r=1.3
The Tokenizer (Lexer) is hand-coded by Alan and a little bit by me and is at:
http://cvs.phpdoc.org/co.php/phpdoc/PHP_Parser/Parser/Tokenizer.php?r=1.4
The base PHP/Parser.php class (which is hand-coded by Alan), is at
http://cvs.phpdoc.org/co.php/phpdoc/PHP_Parser/Parser.php?r=1.2
This package is not yet ready for a full release, the interface and the function names and even the class names may change, but the Core.php and Tokenizer.php files are relatively stable, so we would like to move to php.net's cvs in preparation for the imminent release and to get user feedback.
Thanks,
Greg
--
Wolfram
... opensource @ vision:produktion ...
http://opensource.visionp.de
... authentication system ....
http://sf.net/projects/auth