// import necessary libraries
const acorn = require('acorn/dist/acorn');
const acorn_loose = require('acorn/dist/acorn_loose');
const aux = require('./aux');
const types = require('./domains/types');
const context = require('./domains/context');
const status = require('./domains/status');
const varBlock = require('./varBlock');
const cGen = require('./constraint/cGen');
const varRefs = require('./varrefs');
const retOccur = require('./retOccur');
const thisOccur = require('./thisOccur');
const myWalker = require('./util/myWalker');

function analyze(input, retAll) {
    // the Scope object for global scope
    // scope.Scope.globalScope = new scope.Scope(null);

    // parsing input program
    var ast;
    try {
        ast = acorn.parse(input);
    } catch (e) {
        ast = acorn_loose.parse_dammit(input);
    }

    var nodeArrayIndexedByList = aux.getNodeList(ast);

    // Show AST before scope resolution
    // aux.showUnfolded(ast);

    varBlock.annotateBlockInfo(ast);
    var gBlock = ast['@block'];
    var initialContext = new context.CallSiteContext;
    var gScope = gBlock.getScopeInstance(null, initialContext);
    var gObject = types.mkObjFromGlobalScope(gScope);
    var initStatus = new status.Status(
        gObject,
        types.AValNull,
        types.AValNull,
        initialContext,
        gScope);
    // the prototype object of Object
    var ObjProto = new types.ObjType(null, 'Object.prototype');
    var rtCX = {
        globalObject: gObject,
        // temporal
        protos: {
            Object: ObjProto,
            Function: new types.ObjType(new types.AVal(ObjProto), 'Function.prototype'),
            Array: new types.ObjType(new types.AVal(ObjProto), 'Array.prototype'),
            RegExp: new types.ObjType(new types.AVal(ObjProto), 'RegExp.prototype'),
            String: new types.ObjType(new types.AVal(ObjProto), 'String.prototype'),
            Number: new types.ObjType(new types.AVal(ObjProto), 'Number.prototype'),
            Boolean: new types.ObjType(new types.AVal(ObjProto), 'Boolean.prototype')
        },
        Ĉ: new types.AbsCache()
    };
    cGen.addConstraints(ast, initStatus, rtCX);
    var constraints = cGen.constraints;
    //aux.showUnfolded(gBlockAndAnnotatedAST.ast);
    // aux.showUnfolded(constraints);
    // aux.showUnfolded(gBlock);
    // console.log(util.inspect(gBlock, {depth: 10}));
    if (retAll) {
        return {
            gObject: gObject,
            AST: ast,
            gBlock: gBlock,
            gScope: gScope,
            Ĉ: rtCX.Ĉ
        };
    } else {
        return gObject;
    }
}

exports.analyze = analyze;
exports.findIdentifierAt = varRefs.findIdentifierAt;
exports.findVarRefsAt = varRefs.findVarRefsAt;
exports.onFunctionOrReturnKeyword = retOccur.onFunctionOrReturnKeyword;
exports.findReturnStatements = retOccur.findReturnStatements;
exports.onThisKeyword = thisOccur.onThisKeyword;
exports.findThisExpressions = thisOccur.findThisExpressions;
exports.findSurroundingNode = myWalker.findSurroundingNode;
@@ -706,16 +706,59 @@
 ar ast;%0A
+    const acornOptions = %7BecmaVersion: 6%7D;%0A
     try 
@@ -786,24 +786,38 @@
 .parse(input
+, acornOptions
 );%0A    %7D cat
@@ -869,16 +869,30 @@
 it(input
+, acornOptions
 );%0A    %7D

Use acorn with option ecmaVersion6