src/index.js
function(options) {
  if (typeof this === "function") {
    return new this(options);
  }
  this.tokens = tokens;
  this.lexer = new lexer(this);
  this.ast = new AST();
  this.parser = new parser(this.lexer, this.ast);
  if (options && typeof options === "object") {
    // disable php7 from lexer if already disabled from parser
    if (options.parser && options.parser.php7 === false) {
      if (!options.lexer) {
        options.lexer = {};
      }
      options.lexer.php7 = false;
    }
    combine(options, this);
  }
}
function(options) {
  if (typeof this === "function") {
    return new this(options);
  }
  this.tokens = tokens;
  this.lexer = new lexer(this);
  this.ast = new AST();
  this.parser = new parser(this.lexer, this.ast);
  if (options && typeof options === "object") {
    // disable php7 from lexer if already disabled from parser
    if (options.parser && options.parser.php7 === false) {
      if (!options.lexer) {
        options.lexer = {};
      }
      options.lexer.php7 = false;
    }
    combine(options, this);
  }
}
function ( options ) { if ( typeof this === "function" ) { return new this ( options ) ; } this . tokens = tokens ; this . lexer = new lexer ( this ) ; this . ast = new AST ( ) ; this . parser = new parser ( this . lexer , this . ast ) ; if ( options && typeof options === "object" ) { // disable php7 from lexer if already disabled from parser if ( options . parser && options . parser . php7 === false ) { if ( ! options . lexer ) { options . lexer = { } ; } options . lexer . php7 = false ; } combine ( options , this ) ; } }
Initialise a new parser instance with the specified options

@class
@tutorial Engine
@example
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');

@param {Object} options - List of options
@property {Lexer} lexer
@property {Parser} parser
@property {AST} ast
@property {Object} tokens
Initialise a new parser instance with the specified options