Parse PHP code from NodeJS and convert it to AST. This library is a standalone module of a larger project named Glayzzle.
$ npm install php-parser --save
// initialize a new parser instance
var parser = require('php-parser').create();
// how to retrieve the AST
var AST = parser.parseEval('echo "Hello World";');
// how to list tokens
var tokens = parser.tokenGetAll('<?php echo "Hello World";');
For more details please visit he wiki.
[
'program', <-- program node
[
[ 'sys', <-- first child, typed system call
'echo', <-- operation echo
[
[ 'string', '"Hello World"' ] <-- first argument
]
]
]
]
Try it online (demo) : http://glayzzle.com/php-parser/#demo
If you want to contribute please visit this repository https://github.com/glayzzle/php-parser-dev.
This library is released under BSD-3 license clause.