Initialise a new parser instance with the specified options
Usage :
var parser = require('php-parser');
var instance = new parser({
parser: {
extractDoc: true,
suppressErrors: true
},
ast: {
withPositions: true
},
lexer: {
short_tags: true,
asp_tags: true
}
});
var evalAST = instance.parseEval('some php code');
var codeAST = instance.parseCode('<?php some php code', 'foo.php');
var tokens = instance.tokenGetAll('<?php some php code');Type: Engine
Parameters
optionsObject List of options
Properties
lexerLexerparserParserastASTtokensObject
Parse an evaluating mode string (no need to open php tags)
Parameters
bufferString
Returns Program
Function that parse a php code with open/close tags
Sample code :
<?php $x = 1;Usage :
var parser = require('php-parser');
var phpParser = new parser({
// some options
});
var ast = phpParser.parseCode('...php code...', 'foo.php');Parameters
Returns Program
Extract tokens from the specified buffer.
Note that the output tokens are STRICLY similar to PHP function
token_get_all
Parameters
bufferString
Returns Array<String> Each item can be a string or an array with following informations [token_name, text, line_number]