A PHP parser written in PHP
Go to file
nikic df82e3db45 Replace yydebug flag with separate debug parser "ParserDebug"
Debugging shouldn't be necessairy normally, but carries a 25% performance overhead.
2011-05-29 20:51:15 +02:00
grammar Replace yydebug flag with separate debug parser "ParserDebug" 2011-05-29 20:51:15 +02:00
lib Replace yydebug flag with separate debug parser "ParserDebug" 2011-05-29 20:51:15 +02:00
test Fix some prettyprinting issues 2011-05-29 20:38:36 +02:00
LICENSE Add LICENSE (BSD) 2011-05-27 18:54:01 +02:00
README Slightly optimize the parser and improve the API 2011-04-29 21:06:11 +02:00
test.php Replace yydebug flag with separate debug parser "ParserDebug" 2011-05-29 20:51:15 +02:00

This is a PHP parser written in PHP.

This project is work in progress, but it basically works and was tested on a large code base.

Usage:

    $parser = new Parser();
    $stmts = $parser->yyparse(
        new Lexer('<?php // some code'),
        function($msg) {
            // this is the error callback, which is fired in case of
            // a parse error. It is passed the error message.
            echo $msg, "\n";
        }
    );

    // the return value of Parser->yyparse will either be false (which
    // signifies that an error occured) or an array of statements (Nodes)
    if (false !== $stmts) {
        // dump the AST
        foreach ($stmts as $stmt) {
            echo $stmt, "\n";
        }
    }