Initialise a new parser instance with the specified options
Usage :
var parser = require('php-parser');
var instance = new parser({
parser: {
extractDoc: true,
suppressErrors: true,
php7: 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
options
Object List of options
Properties
lexer
Lexerparser
Parserast
ASTtokens
Object
Parse an evaluating mode string (no need to open php tags)
Parameters
buffer
String
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
buffer
String
Returns Array<String> Each item can be a string or an array with following informations [token_name, text, line_number]
Check if the inpyt is a buffer or a string
Parameters
Returns String Returns the string from input