Skip to content

Instantly share code, notes, and snippets.

@kumavis
Created April 24, 2015 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kumavis/eb3209704a44355f906b to your computer and use it in GitHub Desktop.
Save kumavis/eb3209704a44355f906b to your computer and use it in GitHub Desktop.
requirebin sketch
var escope = require('escope');
var esprima = require('esprima');
var estraverse = require('estraverse');
var treeify = require('treeify').asTree;
// var code = "var a = 1, b = 2; var c = 3; (function(){ var x=8, y=9; w = NaN; z })()"
// var code = "(x.y)()"
// var code = "(0,x.y)()"
//var code = "x.y.z.w()"
var code = "x.call()"
var ast = esprima.parse(code);
var scopeManager = escope.analyze(ast);
var currentScope = scopeManager.acquire(ast); // global scope
window.currentScope = currentScope
console.log(treeify(currentScope, true))
console.log(treeify(ast, true))
require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){(function clone(exports){"use strict";var Syntax,isArray,VisitorOption,VisitorKeys,objectCreate,objectKeys,BREAK,SKIP,REMOVE;function ignoreJSHintError(){}isArray=Array.isArray;if(!isArray){isArray=function isArray(array){return Object.prototype.toString.call(array)==="[object Array]"}}function deepCopy(obj){var ret={},key,val;for(key in obj){if(obj.hasOwnProperty(key)){val=obj[key];if(typeof val==="object"&&val!==null){ret[key]=deepCopy(val)}else{ret[key]=val}}}return ret}function shallowCopy(obj){var ret={},key;for(key in obj){if(obj.hasOwnProperty(key)){ret[key]=obj[key]}}return ret}ignoreJSHintError(shallowCopy);function upperBound(array,func){var diff,len,i,current;len=array.length;i=0;while(len){diff=len>>>1;current=i+diff;if(func(array[current])){len=diff}else{i=current+1;len-=diff+1}}return i}function lowerBound(array,func){var diff,len,i,current;len=array.length;i=0;while(len){diff=len>>>1;current=i+diff;if(func(array[current])){i=current+1;len-=diff+1}else{len=diff}}return i}ignoreJSHintError(lowerBound);objectCreate=Object.create||function(){function F(){}return function(o){F.prototype=o;return new F}}();objectKeys=Object.keys||function(o){var keys=[],key;for(key in o){keys.push(key)}return keys};function extend(to,from){var keys=objectKeys(from),key,i,len;for(i=0,len=keys.length;i<len;i+=1){key=keys[i];to[key]=from[key]}return to}Syntax={AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AwaitExpression:"AwaitExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ComprehensionBlock:"ComprehensionBlock",ComprehensionExpression:"ComprehensionExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DebuggerStatement:"DebuggerStatement",DirectiveStatement:"DirectiveStatement",DoWhileStatement:"DoWhileStatement",EmptyStatement:"EmptyStatement",ExportAllDeclaration:"ExportAllDeclaration",ExportDefaultDeclaration:"ExportDefaultDeclaration",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",ForOfStatement:"ForOfStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",GeneratorExpression:"GeneratorExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MethodDefinition:"MethodDefinition",ModuleSpecifier:"ModuleSpecifier",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",Program:"Program",Property:"Property",RestElement:"RestElement",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement",YieldExpression:"YieldExpression"};VisitorKeys={AssignmentExpression:["left","right"],AssignmentPattern:["left","right"],ArrayExpression:["elements"],ArrayPattern:["elements"],ArrowFunctionExpression:["params","defaults","rest","body"],AwaitExpression:["argument"],BlockStatement:["body"],BinaryExpression:["left","right"],BreakStatement:["label"],CallExpression:["callee","arguments"],CatchClause:["param","body"],ClassBody:["body"],ClassDeclaration:["id","superClass","body"],ClassExpression:["id","superClass","body"],ComprehensionBlock:["left","right"],ComprehensionExpression:["blocks","filter","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DirectiveStatement:[],DoWhileStatement:["body","test"],EmptyStatement:[],ExportAllDeclaration:["source"],ExportDefaultDeclaration:["declaration"],ExportNamedDeclaration:["declaration","specifiers","source"],ExportSpecifier:["exported","local"],ExpressionStatement:["expression"],ForStatement:["init","test","update","body"],ForInStatement:["left","right","body"],ForOfStatement:["left","right","body"],FunctionDeclaration:["id","params","defaults","rest","body"],FunctionExpression:["id","params","defaults","rest","body"],GeneratorExpression:["blocks","filter","body"],Identifier:[],IfStatement:["test","consequent","alternate"],ImportDeclaration:["specifiers","source"],ImportDefaultSpecifier:["local"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["imported","local"],Literal:[],LabeledStatement:["label","body"],LogicalExpression:["left","right"],MemberExpression:["object","property"],MethodDefinition:["key","value"],ModuleSpecifier:[],NewExpression:["callee","arguments"],ObjectExpression:["properties"],ObjectPattern:["properties"],Program:["body"],Property:["key","value"],RestElement:["argument"],ReturnStatement:["argument"],SequenceExpression:["expressions"],SpreadElement:["argument"],SwitchStatement:["discriminant","cases"],SwitchCase:["test","consequent"],TaggedTemplateExpression:["tag","quasi"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handlers","handler","guardedHandlers","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],YieldExpression:["argument"]};BREAK={};SKIP={};REMOVE={};VisitorOption={Break:BREAK,Skip:SKIP,Remove:REMOVE};function Reference(parent,key){this.parent=parent;this.key=key}Reference.prototype.replace=function replace(node){this.parent[this.key]=node};Reference.prototype.remove=function remove(){if(isArray(this.parent)){this.parent.splice(this.key,1);return true}else{this.replace(null);return false}};function Element(node,path,wrap,ref){this.node=node;this.path=path;this.wrap=wrap;this.ref=ref}function Controller(){}Controller.prototype.path=function path(){var i,iz,j,jz,result,element;function addToPath(result,path){if(isArray(path)){for(j=0,jz=path.length;j<jz;++j){result.push(path[j])}}else{result.push(path)}}if(!this.__current.path){return null}result=[];for(i=2,iz=this.__leavelist.length;i<iz;++i){element=this.__leavelist[i];addToPath(result,element.path)}addToPath(result,this.__current.path);return result};Controller.prototype.type=function(){var node=this.current();return node.type||this.__current.wrap};Controller.prototype.parents=function parents(){var i,iz,result;result=[];for(i=1,iz=this.__leavelist.length;i<iz;++i){result.push(this.__leavelist[i].node)}return result};Controller.prototype.current=function current(){return this.__current.node};Controller.prototype.__execute=function __execute(callback,element){var previous,result;result=undefined;previous=this.__current;this.__current=element;this.__state=null;if(callback){result=callback.call(this,element.node,this.__leavelist[this.__leavelist.length-1].node)}this.__current=previous;return result};Controller.prototype.notify=function notify(flag){this.__state=flag};Controller.prototype.skip=function(){this.notify(SKIP)};Controller.prototype["break"]=function(){this.notify(BREAK)};Controller.prototype.remove=function(){this.notify(REMOVE)};Controller.prototype.__initialize=function(root,visitor){this.visitor=visitor;this.root=root;this.__worklist=[];this.__leavelist=[];this.__current=null;this.__state=null;this.__fallback=visitor.fallback==="iteration";this.__keys=VisitorKeys;if(visitor.keys){this.__keys=extend(objectCreate(this.__keys),visitor.keys)}};function isNode(node){if(node==null){return false}return typeof node==="object"&&typeof node.type==="string"}function isProperty(nodeType,key){return(nodeType===Syntax.ObjectExpression||nodeType===Syntax.ObjectPattern)&&"properties"===key}Controller.prototype.traverse=function traverse(root,visitor){var worklist,leavelist,element,node,nodeType,ret,key,current,current2,candidates,candidate,sentinel;this.__initialize(root,visitor);sentinel={};worklist=this.__worklist;leavelist=this.__leavelist;worklist.push(new Element(root,null,null,null));leavelist.push(new Element(null,null,null,null));while(worklist.length){element=worklist.pop();if(element===sentinel){element=leavelist.pop();ret=this.__execute(visitor.leave,element);if(this.__state===BREAK||ret===BREAK){return}continue}if(element.node){ret=this.__execute(visitor.enter,element);if(this.__state===BREAK||ret===BREAK){return}worklist.push(sentinel);leavelist.push(element);if(this.__state===SKIP||ret===SKIP){continue}node=element.node;nodeType=element.wrap||node.type;candidates=this.__keys[nodeType];if(!candidates){if(this.__fallback){candidates=objectKeys(node)}else{throw new Error("Unknown node type "+nodeType+".")}}current=candidates.length;while((current-=1)>=0){key=candidates[current];candidate=node[key];if(!candidate){continue}if(isArray(candidate)){current2=candidate.length;while((current2-=1)>=0){if(!candidate[current2]){continue}if(isProperty(nodeType,candidates[current])){element=new Element(candidate[current2],[key,current2],"Property",null)}else if(isNode(candidate[current2])){element=new Element(candidate[current2],[key,current2],null,null)}else{continue}worklist.push(element)}}else if(isNode(candidate)){worklist.push(new Element(candidate,key,null,null))}}}}};Controller.prototype.replace=function replace(root,visitor){function removeElem(element){var i,key,nextElem,parent;if(element.ref.remove()){key=element.ref.key;parent=element.ref.parent;i=worklist.length;while(i--){nextElem=worklist[i];if(nextElem.ref&&nextElem.ref.parent===parent){if(nextElem.ref.key<key){break}--nextElem.ref.key}}}}var worklist,leavelist,node,nodeType,target,element,current,current2,candidates,candidate,sentinel,outer,key;this.__initialize(root,visitor);sentinel={};worklist=this.__worklist;leavelist=this.__leavelist;outer={root:root};element=new Element(root,null,null,new Reference(outer,"root"));worklist.push(element);leavelist.push(element);while(worklist.length){element=worklist.pop();if(element===sentinel){element=leavelist.pop();target=this.__execute(visitor.leave,element);if(target!==undefined&&target!==BREAK&&target!==SKIP&&target!==REMOVE){element.ref.replace(target)}if(this.__state===REMOVE||target===REMOVE){removeElem(element)}if(this.__state===BREAK||target===BREAK){return outer.root}continue}target=this.__execute(visitor.enter,element);if(target!==undefined&&target!==BREAK&&target!==SKIP&&target!==REMOVE){element.ref.replace(target);element.node=target}if(this.__state===REMOVE||target===REMOVE){removeElem(element);element.node=null}if(this.__state===BREAK||target===BREAK){return outer.root}node=element.node;if(!node){continue}worklist.push(sentinel);leavelist.push(element);if(this.__state===SKIP||target===SKIP){continue}nodeType=element.wrap||node.type;candidates=this.__keys[nodeType];if(!candidates){if(this.__fallback){candidates=objectKeys(node)}else{throw new Error("Unknown node type "+nodeType+".")}}current=candidates.length;while((current-=1)>=0){key=candidates[current];candidate=node[key];if(!candidate){continue}if(isArray(candidate)){current2=candidate.length;while((current2-=1)>=0){if(!candidate[current2]){continue}if(isProperty(nodeType,candidates[current])){element=new Element(candidate[current2],[key,current2],"Property",new Reference(candidate,current2))}else if(isNode(candidate[current2])){element=new Element(candidate[current2],[key,current2],null,new Reference(candidate,current2))}else{continue}worklist.push(element)}}else if(isNode(candidate)){worklist.push(new Element(candidate,key,null,new Reference(node,key)))}}}return outer.root};function traverse(root,visitor){var controller=new Controller;return controller.traverse(root,visitor)}function replace(root,visitor){var controller=new Controller;return controller.replace(root,visitor)}function extendCommentRange(comment,tokens){var target;target=upperBound(tokens,function search(token){return token.range[0]>comment.range[0]});comment.extendedRange=[comment.range[0],comment.range[1]];if(target!==tokens.length){comment.extendedRange[1]=tokens[target].range[0]}target-=1;if(target>=0){comment.extendedRange[0]=tokens[target].range[1]}return comment}function attachComments(tree,providedComments,tokens){var comments=[],comment,len,i,cursor;if(!tree.range){throw new Error("attachComments needs range information")}if(!tokens.length){if(providedComments.length){for(i=0,len=providedComments.length;i<len;i+=1){comment=deepCopy(providedComments[i]);comment.extendedRange=[0,tree.range[0]];comments.push(comment)}tree.leadingComments=comments}return tree}for(i=0,len=providedComments.length;i<len;i+=1){comments.push(extendCommentRange(deepCopy(providedComments[i]),tokens))}cursor=0;traverse(tree,{enter:function(node){var comment;while(cursor<comments.length){comment=comments[cursor];if(comment.extendedRange[1]>node.range[0]){break}if(comment.extendedRange[1]===node.range[0]){if(!node.leadingComments){node.leadingComments=[]}node.leadingComments.push(comment);comments.splice(cursor,1)}else{cursor+=1}}if(cursor===comments.length){return VisitorOption.Break}if(comments[cursor].extendedRange[0]>node.range[1]){return VisitorOption.Skip}}});cursor=0;traverse(tree,{leave:function(node){var comment;while(cursor<comments.length){comment=comments[cursor];if(node.range[1]<comment.extendedRange[0]){break}if(node.range[1]===comment.extendedRange[0]){if(!node.trailingComments){node.trailingComments=[]}node.trailingComments.push(comment);comments.splice(cursor,1)}else{cursor+=1}}if(cursor===comments.length){return VisitorOption.Break}if(comments[cursor].extendedRange[0]>node.range[1]){return VisitorOption.Skip}}});return tree}exports.version=require("./package.json").version;exports.Syntax=Syntax;exports.traverse=traverse;exports.replace=replace;exports.attachComments=attachComments;exports.VisitorKeys=VisitorKeys;exports.VisitorOption=VisitorOption;exports.Controller=Controller;exports.cloneEnvironment=function(){return clone({})};return exports})(exports)},{"./package.json":2}],2:[function(require,module,exports){module.exports={name:"estraverse",description:"ECMAScript JS AST traversal functions",homepage:"https://github.com/estools/estraverse",main:"estraverse.js",version:"2.0.0",engines:{node:">=0.10.0"},maintainers:[{name:"Yusuke Suzuki",email:"utatane.tea@gmail.com",url:"http://github.com/Constellation"}],repository:{type:"git",url:"http://github.com/estools/estraverse.git"},devDependencies:{chai:"^2.1.1","coffee-script":"^1.8.0",espree:"^1.11.0",gulp:"^3.8.10","gulp-bump":"^0.2.2","gulp-filter":"^2.0.0","gulp-git":"^1.0.1","gulp-tag-version":"^1.2.1",jshint:"^2.5.6",mocha:"^2.1.0"},licenses:[{type:"BSD",url:"http://github.com/estools/estraverse/raw/master/LICENSE.BSD"}],scripts:{test:"npm run-script lint && npm run-script unit-test",lint:"jshint estraverse.js","unit-test":"mocha --compilers coffee:coffee-script/register"},readme:"### Estraverse [![Build Status](https://secure.travis-ci.org/estools/estraverse.png)](http://travis-ci.org/estools/estraverse)\n\nEstraverse ([estraverse](http://github.com/estools/estraverse)) is\n[ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm)\ntraversal functions from [esmangle project](http://github.com/estools/esmangle).\n\n### Documentation\n\nYou can find usage docs at [wiki page](https://github.com/estools/estraverse/wiki/Usage).\n\n### Example Usage\n\nThe following code will output all variables declared at the root of a file.\n\n```javascript\nestraverse.traverse(ast, {\n enter: function (node, parent) {\n if (node.type == 'FunctionExpression' || node.type == 'FunctionDeclaration')\n return estraverse.VisitorOption.Skip;\n },\n leave: function (node, parent) {\n if (node.type == 'VariableDeclarator')\n console.log(node.id.name);\n }\n});\n```\n\nWe can use `this.skip`, `this.remove` and `this.break` functions instead of using Skip, Remove and Break.\n\n```javascript\nestraverse.traverse(ast, {\n enter: function (node) {\n this.break();\n }\n});\n```\n\nAnd estraverse provides `estraverse.replace` function. When returning node from `enter`/`leave`, current node is replaced with it.\n\n```javascript\nresult = estraverse.replace(tree, {\n enter: function (node) {\n // Replace it with replaced.\n if (node.type === 'Literal')\n return replaced;\n }\n});\n```\n\nBy passing `visitor.keys` mapping, we can extend estraverse traversing functionality.\n\n```javascript\n// This tree contains a user-defined `TestExpression` node.\nvar tree = {\n type: 'TestExpression',\n\n // This 'argument' is the property containing the other **node**.\n argument: {\n type: 'Literal',\n value: 20\n },\n\n // This 'extended' is the property not containing the other **node**.\n extended: true\n};\nestraverse.traverse(tree, {\n enter: function (node) { },\n\n // Extending the exising traversing rules.\n keys: {\n // TargetNodeName: [ 'keys', 'containing', 'the', 'other', '**node**' ]\n TestExpression: ['argument']\n }\n});\n```\n\nBy passing `visitor.fallback` option, we can control the behavior when encountering unknown nodes.\n```javascript\n// This tree contains a user-defined `TestExpression` node.\nvar tree = {\n type: 'TestExpression',\n\n // This 'argument' is the property containing the other **node**.\n argument: {\n type: 'Literal',\n value: 20\n },\n\n // This 'extended' is the property not containing the other **node**.\n extended: true\n};\nestraverse.traverse(tree, {\n enter: function (node) { },\n\n // Iterating the child **nodes** of unknown nodes.\n fallback: 'iteration'\n});\n```\n\n### License\n\nCopyright (C) 2012-2013 [Yusuke Suzuki](http://github.com/Constellation)\n (twitter: [@Constellation](http://twitter.com/Constellation)) and other contributors.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n\n * Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\nTHIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n",readmeFilename:"README.md",bugs:{url:"https://github.com/estools/estraverse/issues"},_id:"estraverse@2.0.0",_from:"estraverse@^2.0.0"}},{}],escope:[function(require,module,exports){(function(factory,global){"use strict";function namespace(str,obj){var i,iz,names,name;names=str.split(".");for(i=0,iz=names.length;i<iz;++i){name=names[i];if(obj.hasOwnProperty(name)){obj=obj[name]}else{obj=obj[name]={}}}return obj}if(typeof define==="function"&&define.amd){define("escope",["exports","estraverse"],function(exports,estraverse){factory(exports,global,estraverse)})}else if(typeof exports!=="undefined"){factory(exports,global,require("estraverse"))}else{factory(namespace("escope",global),global,global.estraverse)}})(function(exports,global,estraverse){"use strict";var Syntax,Map,currentScope,globalScope,scopes,options;Syntax=estraverse.Syntax;if(typeof global.Map!=="undefined"){Map=global.Map}else{Map=function Map(){this.__data={}};Map.prototype.get=function MapGet(key){key="$"+key;if(this.__data.hasOwnProperty(key)){return this.__data[key]}return undefined};Map.prototype.has=function MapHas(key){key="$"+key;return this.__data.hasOwnProperty(key)};Map.prototype.set=function MapSet(key,val){key="$"+key;this.__data[key]=val};Map.prototype["delete"]=function MapDelete(key){key="$"+key;return delete this.__data[key]}}function assert(cond,text){if(!cond){throw new Error(text)}}function defaultOptions(){return{optimistic:false,directive:false,ecmaVersion:5}}function updateDeeply(target,override){var key,val;function isHashObject(target){return typeof target==="object"&&target instanceof Object&&!(target instanceof RegExp)}for(key in override){if(override.hasOwnProperty(key)){val=override[key];if(isHashObject(val)){if(isHashObject(target[key])){updateDeeply(target[key],val)}else{target[key]=updateDeeply({},val)}}else{target[key]=val}}}return target}function Reference(ident,scope,flag,writeExpr,maybeImplicitGlobal){this.identifier=ident;this.from=scope;this.tainted=false;this.resolved=null;this.flag=flag;if(this.isWrite()){this.writeExpr=writeExpr}this.__maybeImplicitGlobal=maybeImplicitGlobal}Reference.READ=1;Reference.WRITE=2;Reference.RW=3;Reference.prototype.isStatic=function isStatic(){return!this.tainted&&this.resolved&&this.resolved.scope.isStatic()};Reference.prototype.isWrite=function isWrite(){return this.flag&Reference.WRITE};Reference.prototype.isRead=function isRead(){return this.flag&Reference.READ};Reference.prototype.isReadOnly=function isReadOnly(){return this.flag===Reference.READ};Reference.prototype.isWriteOnly=function isWriteOnly(){return this.flag===Reference.WRITE};Reference.prototype.isReadWrite=function isReadWrite(){return this.flag===Reference.RW};function Variable(name,scope){this.name=name;this.identifiers=[];this.references=[];this.defs=[];this.tainted=false;this.stack=true;this.scope=scope}Variable.CatchClause="CatchClause";Variable.Parameter="Parameter";Variable.FunctionName="FunctionName";Variable.Variable="Variable";Variable.ImplicitGlobalVariable="ImplicitGlobalVariable";function isStrictScope(scope,block){var body,i,iz,stmt,expr;if(scope.upper&&scope.upper.isStrict){return true}if(scope.type==="function"){body=block.body}else if(scope.type==="global"){body=block}else{return false}if(options.directive){for(i=0,iz=body.body.length;i<iz;++i){stmt=body.body[i];if(stmt.type!=="DirectiveStatement"){break}if(stmt.raw==='"use strict"'||stmt.raw==="'use strict'"){return true}}}else{for(i=0,iz=body.body.length;i<iz;++i){stmt=body.body[i];if(stmt.type!==Syntax.ExpressionStatement){break}expr=stmt.expression;if(expr.type!==Syntax.Literal||typeof expr.value!=="string"){break}if(expr.raw!=null){if(expr.raw==='"use strict"'||expr.raw==="'use strict'"){return true}}else{if(expr.value==="use strict"){return true}}}}return false}function Scope(block,opt){var variable,body;this.type=block.type===Syntax.CatchClause?"catch":block.type===Syntax.WithStatement?"with":block.type===Syntax.Program?"global":"function";this.set=new Map;this.taints=new Map;this.dynamic=this.type==="global"||this.type==="with";this.block=block;this.through=[];this.variables=[];this.references=[];this.left=[];this.variableScope=this.type==="global"||this.type==="function"?this:currentScope.variableScope;this.functionExpressionScope=false;this.directCallToEvalScope=false;this.thisFound=false;body=this.type==="function"?block.body:block;if(opt.naming){this.__define(block.id,{type:Variable.FunctionName,name:block.id,node:block});this.functionExpressionScope=true}else{if(this.type==="function"){variable=new Variable("arguments",this);this.taints.set("arguments",true);this.set.set("arguments",variable);this.variables.push(variable)}if(block.type===Syntax.FunctionExpression&&block.id){new Scope(block,{naming:true})}}this.upper=currentScope;this.isStrict=isStrictScope(this,block);this.childScopes=[];if(currentScope){currentScope.childScopes.push(this)}currentScope=this;if(this.type==="global"){globalScope=this;globalScope.implicit={set:new Map,variables:[]}}scopes.push(this)}Scope.prototype.__close=function __close(){var i,iz,ref,current,node,implicit;if(!this.dynamic||options.optimistic){for(i=0,iz=this.left.length;i<iz;++i){ref=this.left[i];if(!this.__resolve(ref)){this.__delegateToUpperScope(ref)}}}else{if(this.type==="with"){for(i=0,iz=this.left.length;i<iz;++i){ref=this.left[i];ref.tainted=true;this.__delegateToUpperScope(ref)}}else{for(i=0,iz=this.left.length;i<iz;++i){ref=this.left[i];current=this;do{current.through.push(ref);current=current.upper}while(current)}}}if(this.type==="global"){implicit=[];for(i=0,iz=this.left.length;i<iz;++i){ref=this.left[i];if(ref.__maybeImplicitGlobal&&!this.set.has(ref.identifier.name)){implicit.push(ref.__maybeImplicitGlobal)}}for(i=0,iz=implicit.length;i<iz;++i){node=implicit[i];this.__defineImplicit(node.left,{type:Variable.ImplicitGlobalVariable,name:node.left,node:node})}}this.left=null;currentScope=this.upper};Scope.prototype.__resolve=function __resolve(ref){var variable,name;name=ref.identifier.name;if(this.set.has(name)){variable=this.set.get(name);variable.references.push(ref);variable.stack=variable.stack&&ref.from.variableScope===this.variableScope;if(ref.tainted){variable.tainted=true;this.taints.set(variable.name,true)}ref.resolved=variable;return true}return false};Scope.prototype.__delegateToUpperScope=function __delegateToUpperScope(ref){if(this.upper){this.upper.left.push(ref)}this.through.push(ref)};Scope.prototype.__defineImplicit=function __defineImplicit(node,info){var name,variable;if(node&&node.type===Syntax.Identifier){name=node.name;if(!this.implicit.set.has(name)){variable=new Variable(name,this);variable.identifiers.push(node);variable.defs.push(info);this.implicit.set.set(name,variable);this.implicit.variables.push(variable)}else{variable=this.implicit.set.get(name);variable.identifiers.push(node);variable.defs.push(info)}}};Scope.prototype.__define=function __define(node,info){var name,variable;if(node&&node.type===Syntax.Identifier){name=node.name;if(!this.set.has(name)){variable=new Variable(name,this);variable.identifiers.push(node);variable.defs.push(info);this.set.set(name,variable);this.variables.push(variable)}else{variable=this.set.get(name);variable.identifiers.push(node);variable.defs.push(info)}}};Scope.prototype.__referencing=function __referencing(node,assign,writeExpr,maybeImplicitGlobal){var ref;if(node&&node.type===Syntax.Identifier){ref=new Reference(node,this,assign||Reference.READ,writeExpr,maybeImplicitGlobal);this.references.push(ref);this.left.push(ref)}};Scope.prototype.__detectEval=function __detectEval(){var current;current=this;this.directCallToEvalScope=true;do{current.dynamic=true;current=current.upper}while(current)};Scope.prototype.__detectThis=function __detectThis(){this.thisFound=true};Scope.prototype.__isClosed=function isClosed(){return this.left===null};Scope.prototype.resolve=function resolve(ident){var ref,i,iz;assert(this.__isClosed(),"scope should be closed");assert(ident.type===Syntax.Identifier,"target should be identifier");for(i=0,iz=this.references.length;i<iz;++i){ref=this.references[i];if(ref.identifier===ident){return ref}}return null};Scope.prototype.isStatic=function isStatic(){return!this.dynamic};Scope.prototype.isArgumentsMaterialized=function isArgumentsMaterialized(){var variable;if(this.type!=="function"){return true}if(!this.isStatic()){return true}variable=this.set.get("arguments");assert(variable,"always have arguments variable");return variable.tainted||variable.references.length!==0};Scope.prototype.isThisMaterialized=function isThisMaterialized(){if(this.type!=="function"){return true}if(!this.isStatic()){return true}return this.thisFound};Scope.mangledName="__$escope$__";Scope.prototype.attach=function attach(){if(!this.functionExpressionScope){this.block[Scope.mangledName]=this}};Scope.prototype.detach=function detach(){if(!this.functionExpressionScope){delete this.block[Scope.mangledName]}};Scope.prototype.isUsedName=function(name){if(this.set.has(name)){return true}for(var i=0,iz=this.through.length;i<iz;++i){if(this.through[i].identifier.name===name){return true}}return false};function ScopeManager(scopes){this.scopes=scopes;this.attached=false}ScopeManager.prototype.__get=function __get(node){var i,iz,scope;if(this.attached){return node[Scope.mangledName]||null}if(Scope.isScopeRequired(node)){for(i=0,iz=this.scopes.length;i<iz;++i){scope=this.scopes[i];if(!scope.functionExpressionScope){if(scope.block===node){return scope}}}}return null};ScopeManager.prototype.acquire=function acquire(node){return this.__get(node)};ScopeManager.prototype.release=function release(node){var scope=this.__get(node);if(scope){scope=scope.upper;while(scope){if(!scope.functionExpressionScope){return scope}scope=scope.upper}}return null};ScopeManager.prototype.attach=function attach(){var i,iz;for(i=0,iz=this.scopes.length;i<iz;++i){this.scopes[i].attach()}this.attached=true};ScopeManager.prototype.detach=function detach(){var i,iz;for(i=0,iz=this.scopes.length;i<iz;++i){this.scopes[i].detach()}this.attached=false};Scope.isScopeRequired=function isScopeRequired(node){return Scope.isVariableScopeRequired(node)||node.type===Syntax.WithStatement||node.type===Syntax.CatchClause};Scope.isVariableScopeRequired=function isVariableScopeRequired(node){return node.type===Syntax.Program||node.type===Syntax.FunctionExpression||node.type===Syntax.FunctionDeclaration};function analyze(tree,providedOptions){var resultScopes;options=updateDeeply(defaultOptions(),providedOptions);resultScopes=scopes=[];currentScope=null;globalScope=null;estraverse.traverse(tree,{enter:function enter(node){var i,iz,decl;if(Scope.isScopeRequired(node)){new Scope(node,{})}switch(node.type){case Syntax.AssignmentExpression:if(node.operator==="="){currentScope.__referencing(node.left,Reference.WRITE,node.right,!currentScope.isStrict&&node.left.name!=null&&node)}else{currentScope.__referencing(node.left,Reference.RW,node.right)}currentScope.__referencing(node.right);break;case Syntax.ArrayExpression:for(i=0,iz=node.elements.length;i<iz;++i){currentScope.__referencing(node.elements[i])}break;case Syntax.BlockStatement:break;case Syntax.BinaryExpression:currentScope.__referencing(node.left);currentScope.__referencing(node.right);break;case Syntax.BreakStatement:break;case Syntax.CallExpression:currentScope.__referencing(node.callee);for(i=0,iz=node["arguments"].length;i<iz;++i){currentScope.__referencing(node["arguments"][i])}if(!options.ignoreEval&&node.callee.type===Syntax.Identifier&&node.callee.name==="eval"){
currentScope.variableScope.__detectEval()}break;case Syntax.CatchClause:currentScope.__define(node.param,{type:Variable.CatchClause,name:node.param,node:node});break;case Syntax.ConditionalExpression:currentScope.__referencing(node.test);currentScope.__referencing(node.consequent);currentScope.__referencing(node.alternate);break;case Syntax.ContinueStatement:break;case Syntax.DirectiveStatement:break;case Syntax.DoWhileStatement:currentScope.__referencing(node.test);break;case Syntax.DebuggerStatement:break;case Syntax.EmptyStatement:break;case Syntax.ExpressionStatement:currentScope.__referencing(node.expression);break;case Syntax.ForStatement:currentScope.__referencing(node.init);currentScope.__referencing(node.test);currentScope.__referencing(node.update);break;case Syntax.ForInStatement:if(node.left.type===Syntax.VariableDeclaration){currentScope.__referencing(node.left.declarations[0].id,Reference.WRITE,null,false)}else{currentScope.__referencing(node.left,Reference.WRITE,null,!currentScope.isStrict&&node.left.name!=null&&node)}currentScope.__referencing(node.right);break;case Syntax.FunctionDeclaration:currentScope.upper.__define(node.id,{type:Variable.FunctionName,name:node.id,node:node});for(i=0,iz=node.params.length;i<iz;++i){currentScope.__define(node.params[i],{type:Variable.Parameter,name:node.params[i],node:node,index:i})}break;case Syntax.FunctionExpression:for(i=0,iz=node.params.length;i<iz;++i){currentScope.__define(node.params[i],{type:Variable.Parameter,name:node.params[i],node:node,index:i})}break;case Syntax.Identifier:break;case Syntax.IfStatement:currentScope.__referencing(node.test);break;case Syntax.Literal:break;case Syntax.LabeledStatement:break;case Syntax.LogicalExpression:currentScope.__referencing(node.left);currentScope.__referencing(node.right);break;case Syntax.MemberExpression:currentScope.__referencing(node.object);if(node.computed){currentScope.__referencing(node.property)}break;case Syntax.NewExpression:currentScope.__referencing(node.callee);for(i=0,iz=node["arguments"].length;i<iz;++i){currentScope.__referencing(node["arguments"][i])}break;case Syntax.ObjectExpression:for(i=0;i<node.properties.length;i++){if(node.properties[i].kind==="init"){currentScope.__referencing(node.properties[i].value)}}break;case Syntax.Program:break;case Syntax.Property:break;case Syntax.ReturnStatement:currentScope.__referencing(node.argument);break;case Syntax.SequenceExpression:for(i=0,iz=node.expressions.length;i<iz;++i){currentScope.__referencing(node.expressions[i])}break;case Syntax.SwitchStatement:currentScope.__referencing(node.discriminant);break;case Syntax.SwitchCase:currentScope.__referencing(node.test);break;case Syntax.ThisExpression:currentScope.variableScope.__detectThis();break;case Syntax.ThrowStatement:currentScope.__referencing(node.argument);break;case Syntax.TryStatement:break;case Syntax.UnaryExpression:currentScope.__referencing(node.argument);break;case Syntax.UpdateExpression:currentScope.__referencing(node.argument,Reference.RW,null);break;case Syntax.VariableDeclaration:for(i=0,iz=node.declarations.length;i<iz;++i){decl=node.declarations[i];currentScope.variableScope.__define(decl.id,{type:Variable.Variable,name:decl.id,node:decl,index:i,parent:node});if(decl.init){currentScope.__referencing(decl.id,Reference.WRITE,decl.init,false);currentScope.__referencing(decl.init)}}break;case Syntax.VariableDeclarator:break;case Syntax.WhileStatement:currentScope.__referencing(node.test);break;case Syntax.WithStatement:currentScope.upper.__referencing(node.object);break}},leave:function leave(node){while(currentScope&&node===currentScope.block){currentScope.__close()}}});assert(currentScope===null);globalScope=null;scopes=null;options=null;return new ScopeManager(resultScopes)}exports.version="1.0.3";exports.Reference=Reference;exports.Variable=Variable;exports.Scope=Scope;exports.ScopeManager=ScopeManager;exports.analyze=analyze},this)},{estraverse:1}]},{},[]);require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({esprima:[function(require,module,exports){(function(root,factory){"use strict";if(typeof define==="function"&&define.amd){define(["exports"],factory)}else if(typeof exports!=="undefined"){factory(exports)}else{factory(root.esprima={})}})(this,function(exports){"use strict";var Token,TokenName,FnExprTokens,Syntax,PlaceHolders,Messages,Regex,source,strict,sourceType,index,lineNumber,lineStart,hasLineTerminator,lastIndex,lastLineNumber,lastLineStart,startIndex,startLineNumber,startLineStart,scanning,length,lookahead,state,extra,isBindingElement,isAssignmentTarget,firstCoverInitializedNameError;Token={BooleanLiteral:1,EOF:2,Identifier:3,Keyword:4,NullLiteral:5,NumericLiteral:6,Punctuator:7,StringLiteral:8,RegularExpression:9,Template:10};TokenName={};TokenName[Token.BooleanLiteral]="Boolean";TokenName[Token.EOF]="<end>";TokenName[Token.Identifier]="Identifier";TokenName[Token.Keyword]="Keyword";TokenName[Token.NullLiteral]="Null";TokenName[Token.NumericLiteral]="Numeric";TokenName[Token.Punctuator]="Punctuator";TokenName[Token.StringLiteral]="String";TokenName[Token.RegularExpression]="RegularExpression";TokenName[Token.Template]="Template";FnExprTokens=["(","{","[","in","typeof","instanceof","new","return","case","delete","throw","void","=","+=","-=","*=","/=","%=","<<=",">>=",">>>=","&=","|=","^=",",","+","-","*","/","%","++","--","<<",">>",">>>","&","|","^","!","~","&&","||","?",":","===","==",">=","<=","<",">","!=","!=="];Syntax={AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DoWhileStatement:"DoWhileStatement",DebuggerStatement:"DebuggerStatement",EmptyStatement:"EmptyStatement",ExportAllDeclaration:"ExportAllDeclaration",ExportDefaultDeclaration:"ExportDefaultDeclaration",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MethodDefinition:"MethodDefinition",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",Program:"Program",Property:"Property",RestElement:"RestElement",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",Super:"Super",SwitchCase:"SwitchCase",SwitchStatement:"SwitchStatement",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement"};PlaceHolders={ArrowParameterPlaceHolder:"ArrowParameterPlaceHolder"};Messages={UnexpectedToken:"Unexpected token %0",UnexpectedNumber:"Unexpected number",UnexpectedString:"Unexpected string",UnexpectedIdentifier:"Unexpected identifier",UnexpectedReserved:"Unexpected reserved word",UnexpectedTemplate:"Unexpected quasi %0",UnexpectedEOS:"Unexpected end of input",NewlineAfterThrow:"Illegal newline after throw",InvalidRegExp:"Invalid regular expression",UnterminatedRegExp:"Invalid regular expression: missing /",InvalidLHSInAssignment:"Invalid left-hand side in assignment",InvalidLHSInForIn:"Invalid left-hand side in for-in",MultipleDefaultsInSwitch:"More than one default clause in switch statement",NoCatchOrFinally:"Missing catch or finally after try",UnknownLabel:"Undefined label '%0'",Redeclaration:"%0 '%1' has already been declared",IllegalContinue:"Illegal continue statement",IllegalBreak:"Illegal break statement",IllegalReturn:"Illegal return statement",StrictModeWith:"Strict mode code may not include a with statement",StrictCatchVariable:"Catch variable may not be eval or arguments in strict mode",StrictVarName:"Variable name may not be eval or arguments in strict mode",StrictParamName:"Parameter name eval or arguments is not allowed in strict mode",StrictParamDupe:"Strict mode function may not have duplicate parameter names",StrictFunctionName:"Function name may not be eval or arguments in strict mode",StrictOctalLiteral:"Octal literals are not allowed in strict mode.",StrictDelete:"Delete of an unqualified identifier in strict mode.",StrictLHSAssignment:"Assignment to eval or arguments is not allowed in strict mode",StrictLHSPostfix:"Postfix increment/decrement may not have eval or arguments operand in strict mode",StrictLHSPrefix:"Prefix increment/decrement may not have eval or arguments operand in strict mode",StrictReservedWord:"Use of future reserved word in strict mode",TemplateOctalLiteral:"Octal literals are not allowed in template strings.",ParameterAfterRestParameter:"Rest parameter must be last formal parameter",DefaultRestParameter:"Unexpected token =",ObjectPatternAsRestParameter:"Unexpected token {",DuplicateProtoProperty:"Duplicate __proto__ fields are not allowed in object literals",ConstructorSpecialMethod:"Class constructor may not be an accessor",DuplicateConstructor:"A class may only have one constructor",StaticPrototype:"Classes may not have static property named prototype",MissingFromClause:"Unexpected token",NoAsAfterImportNamespace:"Unexpected token",InvalidModuleSpecifier:"Unexpected token",IllegalImportDeclaration:"Unexpected token",IllegalExportDeclaration:"Unexpected token"};Regex={NonAsciiIdentifierStart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠ-ࢲऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々-〇〡-〩〱-〵〸-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞭꞰꞱꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭟꭤꭥꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]"),NonAsciiIdentifierPart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮ̀-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁ҃-҇Ҋ-ԯԱ-Ֆՙա-և֑-ׇֽֿׁׂׅׄא-תװ-ײؐ-ؚؠ-٩ٮ-ۓە-ۜ۟-۪ۨ-ۼۿܐ-݊ݍ-ޱ߀-ߵߺࠀ-࠭ࡀ-࡛ࢠ-ࢲࣤ-ॣ०-९ॱ-ঃঅ-ঌএঐও-নপ-রলশ-হ়-ৄেৈো-ৎৗড়ঢ়য়-ৣ০-ৱਁ-ਃਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹ਼ਾ-ੂੇੈੋ-੍ੑਖ਼-ੜਫ਼੦-ੵઁ-ઃઅ-ઍએ-ઑઓ-નપ-રલળવ-હ઼-ૅે-ૉો-્ૐૠ-ૣ૦-૯ଁ-ଃଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହ଼-ୄେୈୋ-୍ୖୗଡ଼ଢ଼ୟ-ୣ୦-୯ୱஂஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹா-ூெ-ைொ-்ௐௗ௦-௯ఀ-ఃఅ-ఌఎ-ఐఒ-నప-హఽ-ౄె-ైొ-్ౕౖౘౙౠ-ౣ౦-౯ಁ-ಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹ಼-ೄೆ-ೈೊ-್ೕೖೞೠ-ೣ೦-೯ೱೲഁ-ഃഅ-ഌഎ-ഐഒ-ഺഽ-ൄെ-ൈൊ-ൎൗൠ-ൣ൦-൯ൺ-ൿංඃඅ-ඖක-නඳ-රලව-ෆ්ා-ුූෘ-ෟ෦-෯ෲෳก-ฺเ-๎๐-๙ກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ູົ-ຽເ-ໄໆ່-ໍ໐-໙ໜ-ໟༀ༘༙༠-༩༹༵༷༾-ཇཉ-ཬཱ-྄྆-ྗྙ-ྼ࿆က-၉ၐ-ႝႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚ፝-፟ᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-᜔ᜠ-᜴ᝀ-ᝓᝠ-ᝬᝮ-ᝰᝲᝳក-៓ៗៜ៝០-៩᠋-᠍᠐-᠙ᠠ-ᡷᢀ-ᢪᢰ-ᣵᤀ-ᤞᤠ-ᤫᤰ-᤻᥆-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉ᧐-᧙ᨀ-ᨛᨠ-ᩞ᩠-᩿᩼-᪉᪐-᪙ᪧ᪰-᪽ᬀ-ᭋ᭐-᭙᭫-᭳ᮀ-᯳ᰀ-᰷᱀-᱉ᱍ-ᱽ᳐-᳔᳒-ᳶ᳸᳹ᴀ-᷵᷼-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ‌‍‿⁀⁔ⁱⁿₐ-ₜ⃐-⃥⃜⃡-⃰ℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯ⵿-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⷠ-ⷿⸯ々-〇〡-〯〱-〵〸-〼ぁ-ゖ゙゚ゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘫꙀ-꙯ꙴ-꙽ꙿ-ꚝꚟ-꛱ꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞭꞰꞱꟷ-ꠧꡀ-ꡳꢀ-꣄꣐-꣙꣠-ꣷꣻ꤀-꤭ꤰ-꥓ꥠ-ꥼꦀ-꧀ꧏ-꧙ꧠ-ꧾꨀ-ꨶꩀ-ꩍ꩐-꩙ꩠ-ꩶꩺ-ꫂꫛ-ꫝꫠ-ꫯꫲ-꫶ꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭟꭤꭥꯀ-ꯪ꯬꯭꯰-꯹가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻ︀-️︠-︭︳︴﹍-﹏ﹰ-ﹴﹶ-ﻼ0-9A-Z_a-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]")};function assert(condition,message){if(!condition){throw new Error("ASSERT: "+message)}}function isDecimalDigit(ch){return ch>=48&&ch<=57}function isHexDigit(ch){return"0123456789abcdefABCDEF".indexOf(ch)>=0}function isOctalDigit(ch){return"01234567".indexOf(ch)>=0}function octalToDecimal(ch){var octal=ch!=="0",code="01234567".indexOf(ch);if(index<length&&isOctalDigit(source[index])){octal=true;code=code*8+"01234567".indexOf(source[index++]);if("0123".indexOf(ch)>=0&&index<length&&isOctalDigit(source[index])){code=code*8+"01234567".indexOf(source[index++])}}return{code:code,octal:octal}}function isWhiteSpace(ch){return ch===32||ch===9||ch===11||ch===12||ch===160||ch>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(ch)>=0}function isLineTerminator(ch){return ch===10||ch===13||ch===8232||ch===8233}function isIdentifierStart(ch){return ch===36||ch===95||ch>=65&&ch<=90||ch>=97&&ch<=122||ch===92||ch>=128&&Regex.NonAsciiIdentifierStart.test(String.fromCharCode(ch))}function isIdentifierPart(ch){return ch===36||ch===95||ch>=65&&ch<=90||ch>=97&&ch<=122||ch>=48&&ch<=57||ch===92||ch>=128&&Regex.NonAsciiIdentifierPart.test(String.fromCharCode(ch))}function isFutureReservedWord(id){switch(id){case"enum":case"export":case"import":case"super":return true;default:return false}}function isStrictModeReservedWord(id){switch(id){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"yield":case"let":return true;default:return false}}function isRestrictedWord(id){return id==="eval"||id==="arguments"}function isKeyword(id){switch(id.length){case 2:return id==="if"||id==="in"||id==="do";case 3:return id==="var"||id==="for"||id==="new"||id==="try"||id==="let";case 4:return id==="this"||id==="else"||id==="case"||id==="void"||id==="with"||id==="enum";case 5:return id==="while"||id==="break"||id==="catch"||id==="throw"||id==="const"||id==="yield"||id==="class"||id==="super";case 6:return id==="return"||id==="typeof"||id==="delete"||id==="switch"||id==="export"||id==="import";case 7:return id==="default"||id==="finally"||id==="extends";case 8:return id==="function"||id==="continue"||id==="debugger";case 10:return id==="instanceof";default:return false}}function addComment(type,value,start,end,loc){var comment;assert(typeof start==="number","Comment must have valid position");state.lastCommentStart=start;comment={type:type,value:value};if(extra.range){comment.range=[start,end]}if(extra.loc){comment.loc=loc}extra.comments.push(comment);if(extra.attachComment){extra.leadingComments.push(comment);extra.trailingComments.push(comment)}}function skipSingleLineComment(offset){var start,loc,ch,comment;start=index-offset;loc={start:{line:lineNumber,column:index-lineStart-offset}};while(index<length){ch=source.charCodeAt(index);++index;if(isLineTerminator(ch)){hasLineTerminator=true;if(extra.comments){comment=source.slice(start+offset,index-1);loc.end={line:lineNumber,column:index-lineStart-1};addComment("Line",comment,start,index-1,loc)}if(ch===13&&source.charCodeAt(index)===10){++index}++lineNumber;lineStart=index;return}}if(extra.comments){comment=source.slice(start+offset,index);loc.end={line:lineNumber,column:index-lineStart};addComment("Line",comment,start,index,loc)}}function skipMultiLineComment(){var start,loc,ch,comment;if(extra.comments){start=index-2;loc={start:{line:lineNumber,column:index-lineStart-2}}}while(index<length){ch=source.charCodeAt(index);if(isLineTerminator(ch)){if(ch===13&&source.charCodeAt(index+1)===10){++index}hasLineTerminator=true;++lineNumber;++index;lineStart=index}else if(ch===42){if(source.charCodeAt(index+1)===47){++index;++index;if(extra.comments){comment=source.slice(start+2,index-2);loc.end={line:lineNumber,column:index-lineStart};addComment("Block",comment,start,index,loc)}return}++index}else{++index}}if(extra.comments){loc.end={line:lineNumber,column:index-lineStart};comment=source.slice(start+2,index);addComment("Block",comment,start,index,loc)}tolerateUnexpectedToken()}function skipComment(){var ch,start;hasLineTerminator=false;start=index===0;while(index<length){ch=source.charCodeAt(index);if(isWhiteSpace(ch)){++index}else if(isLineTerminator(ch)){hasLineTerminator=true;++index;if(ch===13&&source.charCodeAt(index)===10){++index}++lineNumber;lineStart=index;start=true}else if(ch===47){ch=source.charCodeAt(index+1);if(ch===47){++index;++index;skipSingleLineComment(2);start=true}else if(ch===42){++index;++index;skipMultiLineComment()}else{break}}else if(start&&ch===45){if(source.charCodeAt(index+1)===45&&source.charCodeAt(index+2)===62){index+=3;skipSingleLineComment(3)}else{break}}else if(ch===60){if(source.slice(index+1,index+4)==="!--"){++index;++index;++index;++index;skipSingleLineComment(4)}else{break}}else{break}}}function scanHexEscape(prefix){var i,len,ch,code=0;len=prefix==="u"?4:2;for(i=0;i<len;++i){if(index<length&&isHexDigit(source[index])){ch=source[index++];code=code*16+"0123456789abcdef".indexOf(ch.toLowerCase())}else{return""}}return String.fromCharCode(code)}function scanUnicodeCodePointEscape(){var ch,code,cu1,cu2;ch=source[index];code=0;if(ch==="}"){throwUnexpectedToken()}while(index<length){ch=source[index++];if(!isHexDigit(ch)){break}code=code*16+"0123456789abcdef".indexOf(ch.toLowerCase())}if(code>1114111||ch!=="}"){throwUnexpectedToken()}if(code<=65535){return String.fromCharCode(code)}cu1=(code-65536>>10)+55296;cu2=(code-65536&1023)+56320;return String.fromCharCode(cu1,cu2)}function getEscapedIdentifier(){var ch,id;ch=source.charCodeAt(index++);id=String.fromCharCode(ch);if(ch===92){if(source.charCodeAt(index)!==117){throwUnexpectedToken()}++index;ch=scanHexEscape("u");if(!ch||ch==="\\"||!isIdentifierStart(ch.charCodeAt(0))){throwUnexpectedToken()}id=ch}while(index<length){ch=source.charCodeAt(index);if(!isIdentifierPart(ch)){break}++index;id+=String.fromCharCode(ch);if(ch===92){id=id.substr(0,id.length-1);if(source.charCodeAt(index)!==117){throwUnexpectedToken()}++index;ch=scanHexEscape("u");if(!ch||ch==="\\"||!isIdentifierPart(ch.charCodeAt(0))){throwUnexpectedToken()}id+=ch}}return id}function getIdentifier(){var start,ch;start=index++;while(index<length){ch=source.charCodeAt(index);if(ch===92){index=start;return getEscapedIdentifier()}if(isIdentifierPart(ch)){++index}else{break}}return source.slice(start,index)}function scanIdentifier(){var start,id,type;start=index;id=source.charCodeAt(index)===92?getEscapedIdentifier():getIdentifier();if(id.length===1){type=Token.Identifier}else if(isKeyword(id)){type=Token.Keyword}else if(id==="null"){type=Token.NullLiteral}else if(id==="true"||id==="false"){type=Token.BooleanLiteral}else{type=Token.Identifier}return{type:type,value:id,lineNumber:lineNumber,lineStart:lineStart,start:start,end:index}}function scanPunctuator(){var token,str;token={type:Token.Punctuator,value:"",lineNumber:lineNumber,lineStart:lineStart,start:index,end:index};str=source[index];switch(str){case"(":if(extra.tokenize){extra.openParenToken=extra.tokens.length}++index;break;case"{":if(extra.tokenize){extra.openCurlyToken=extra.tokens.length}state.curlyStack.push("{");++index;break;case".":++index;if(source[index]==="."&&source[index+1]==="."){index+=2;str="..."}break;case"}":++index;state.curlyStack.pop();break;case")":case";":case",":case"[":case"]":case":":case"?":case"~":++index;break;default:str=source.substr(index,4);if(str===">>>="){index+=4}else{str=str.substr(0,3);if(str==="==="||str==="!=="||str===">>>"||str==="<<="||str===">>="){index+=3}else{str=str.substr(0,2);if(str==="&&"||str==="||"||str==="=="||str==="!="||str==="+="||str==="-="||str==="*="||str==="/="||str==="++"||str==="--"||str==="<<"||str===">>"||str==="&="||str==="|="||str==="^="||str==="%="||str==="<="||str===">="||str==="=>"){index+=2}else{str=source[index];if("<>=!+-*%&|^/".indexOf(str)>=0){++index}}}}}if(index===token.start){throwUnexpectedToken()}token.end=index;token.value=str;return token}function scanHexLiteral(start){var number="";while(index<length){if(!isHexDigit(source[index])){break}number+=source[index++]}if(number.length===0){throwUnexpectedToken()}if(isIdentifierStart(source.charCodeAt(index))){throwUnexpectedToken()}return{type:Token.NumericLiteral,value:parseInt("0x"+number,16),lineNumber:lineNumber,lineStart:lineStart,start:start,end:index}}function scanBinaryLiteral(start){var ch,number;number="";while(index<length){ch=source[index];if(ch!=="0"&&ch!=="1"){break}number+=source[index++]}if(number.length===0){throwUnexpectedToken()}if(index<length){ch=source.charCodeAt(index);if(isIdentifierStart(ch)||isDecimalDigit(ch)){throwUnexpectedToken()}}return{type:Token.NumericLiteral,value:parseInt(number,2),lineNumber:lineNumber,lineStart:lineStart,start:start,end:index}}function scanOctalLiteral(prefix,start){var number,octal;if(isOctalDigit(prefix)){octal=true;number="0"+source[index++]}else{octal=false;++index;number=""}while(index<length){if(!isOctalDigit(source[index])){break}number+=source[index++]}if(!octal&&number.length===0){throwUnexpectedToken()}if(isIdentifierStart(source.charCodeAt(index))||isDecimalDigit(source.charCodeAt(index))){throwUnexpectedToken()}return{type:Token.NumericLiteral,value:parseInt(number,8),octal:octal,lineNumber:lineNumber,lineStart:lineStart,start:start,end:index}}function isImplicitOctalLiteral(){var i,ch;for(i=index+1;i<length;++i){ch=source[i];if(ch==="8"||ch==="9"){return false}if(!isOctalDigit(ch)){return true}}return true}function scanNumericLiteral(){var number,start,ch;ch=source[index];assert(isDecimalDigit(ch.charCodeAt(0))||ch===".","Numeric literal must start with a decimal digit or a decimal point");start=index;number="";if(ch!=="."){number=source[index++];ch=source[index];if(number==="0"){if(ch==="x"||ch==="X"){++index;return scanHexLiteral(start)}if(ch==="b"||ch==="B"){++index;return scanBinaryLiteral(start)}if(ch==="o"||ch==="O"){return scanOctalLiteral(ch,start)}if(isOctalDigit(ch)){if(isImplicitOctalLiteral()){return scanOctalLiteral(ch,start)}}}while(isDecimalDigit(source.charCodeAt(index))){number+=source[index++]}ch=source[index]}if(ch==="."){number+=source[index++];while(isDecimalDigit(source.charCodeAt(index))){number+=source[index++]}ch=source[index]}if(ch==="e"||ch==="E"){number+=source[index++];ch=source[index];if(ch==="+"||ch==="-"){number+=source[index++]}if(isDecimalDigit(source.charCodeAt(index))){while(isDecimalDigit(source.charCodeAt(index))){number+=source[index++]}}else{throwUnexpectedToken()}}if(isIdentifierStart(source.charCodeAt(index))){throwUnexpectedToken()}return{type:Token.NumericLiteral,value:parseFloat(number),lineNumber:lineNumber,lineStart:lineStart,start:start,end:index}}function scanStringLiteral(){var str="",quote,start,ch,unescaped,octToDec,octal=false;quote=source[index];assert(quote==="'"||quote==='"',"String literal must starts with a quote");start=index;++index;while(index<length){ch=source[index++];if(ch===quote){quote="";break}else if(ch==="\\"){ch=source[index++];if(!ch||!isLineTerminator(ch.charCodeAt(0))){switch(ch){case"u":case"x":if(source[index]==="{"){++index;str+=scanUnicodeCodePointEscape()}else{unescaped=scanHexEscape(ch);if(!unescaped){throw throwUnexpectedToken()}str+=unescaped}break;case"n":str+="\n";break;case"r":str+="\r";break;case"t":str+=" ";break;case"b":str+="\b";break;case"f":str+="\f";break;case"v":str+=" ";break;case"8":case"9":throw throwUnexpectedToken();default:if(isOctalDigit(ch)){octToDec=octalToDecimal(ch);octal=octToDec.octal||octal;str+=String.fromCharCode(octToDec.code)}else{str+=ch}break}}else{++lineNumber;if(ch==="\r"&&source[index]==="\n"){++index}lineStart=index}}else if(isLineTerminator(ch.charCodeAt(0))){break}else{str+=ch}}if(quote!==""){throwUnexpectedToken()}return{type:Token.StringLiteral,value:str,octal:octal,lineNumber:startLineNumber,lineStart:startLineStart,start:start,end:index}}function scanTemplate(){var cooked="",ch,start,rawOffset,terminated,head,tail,restore,unescaped;terminated=false;tail=false;start=index;head=source[index]==="`";rawOffset=2;++index;while(index<length){ch=source[index++];if(ch==="`"){rawOffset=1;tail=true;terminated=true;break}else if(ch==="$"){if(source[index]==="{"){state.curlyStack.push("${");++index;terminated=true;break}cooked+=ch}else if(ch==="\\"){ch=source[index++];if(!isLineTerminator(ch.charCodeAt(0))){switch(ch){case"n":cooked+="\n";break;case"r":cooked+="\r";break;case"t":cooked+=" ";break;case"u":case"x":if(source[index]==="{"){++index;cooked+=scanUnicodeCodePointEscape()}else{restore=index;unescaped=scanHexEscape(ch);if(unescaped){cooked+=unescaped}else{index=restore;cooked+=ch}}break;case"b":cooked+="\b";break;case"f":cooked+="\f";break;case"v":cooked+=" ";break;default:if(ch==="0"){if(isDecimalDigit(source.charCodeAt(index))){throwError(Messages.TemplateOctalLiteral)}cooked+="\x00"}else if(isOctalDigit(ch)){throwError(Messages.TemplateOctalLiteral)}else{cooked+=ch}break}}else{++lineNumber;if(ch==="\r"&&source[index]==="\n"){++index}lineStart=index}}else if(isLineTerminator(ch.charCodeAt(0))){++lineNumber;if(ch==="\r"&&source[index]==="\n"){++index}lineStart=index;cooked+="\n"}else{cooked+=ch}}if(!terminated){throwUnexpectedToken()}if(!head){state.curlyStack.pop()}return{type:Token.Template,value:{cooked:cooked,raw:source.slice(start+1,index-rawOffset)},head:head,tail:tail,lineNumber:lineNumber,lineStart:lineStart,start:start,end:index}}function testRegExp(pattern,flags){var tmp=pattern;if(flags.indexOf("u")>=0){tmp=tmp.replace(/\\u\{([0-9a-fA-F]+)\}/g,function($0,$1){if(parseInt($1,16)<=1114111){return"x"}throwUnexpectedToken(null,Messages.InvalidRegExp)}).replace(/\\u([a-fA-F0-9]{4})|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"x")}try{RegExp(tmp)}catch(e){throwUnexpectedToken(null,Messages.InvalidRegExp)}try{return new RegExp(pattern,flags)}catch(exception){return null}}function scanRegExpBody(){var ch,str,classMarker,terminated,body;ch=source[index];assert(ch==="/","Regular expression literal must start with a slash");str=source[index++];classMarker=false;terminated=false;while(index<length){ch=source[index++];str+=ch;if(ch==="\\"){ch=source[index++];if(isLineTerminator(ch.charCodeAt(0))){throwUnexpectedToken(null,Messages.UnterminatedRegExp)}str+=ch}else if(isLineTerminator(ch.charCodeAt(0))){throwUnexpectedToken(null,Messages.UnterminatedRegExp)}else if(classMarker){if(ch==="]"){classMarker=false}}else{if(ch==="/"){terminated=true;break}else if(ch==="["){classMarker=true}}}if(!terminated){throwUnexpectedToken(null,Messages.UnterminatedRegExp)}body=str.substr(1,str.length-2);return{value:body,literal:str}}function scanRegExpFlags(){var ch,str,flags,restore;str="";flags="";while(index<length){ch=source[index];if(!isIdentifierPart(ch.charCodeAt(0))){break}++index;if(ch==="\\"&&index<length){ch=source[index];if(ch==="u"){++index;restore=index;ch=scanHexEscape("u");if(ch){flags+=ch;for(str+="\\u";restore<index;++restore){str+=source[restore]}}else{index=restore;flags+="u";str+="\\u"}tolerateUnexpectedToken()}else{str+="\\";tolerateUnexpectedToken()}}else{flags+=ch;str+=ch}}return{value:flags,literal:str}}function scanRegExp(){scanning=true;var start,body,flags,value;lookahead=null;skipComment();start=index;body=scanRegExpBody();flags=scanRegExpFlags();value=testRegExp(body.value,flags.value);scanning=false;if(extra.tokenize){return{type:Token.RegularExpression,value:value,regex:{pattern:body.value,flags:flags.value},lineNumber:lineNumber,lineStart:lineStart,start:start,end:index}}return{literal:body.literal+flags.literal,value:value,regex:{pattern:body.value,flags:flags.value},start:start,end:index}}function collectRegex(){var pos,loc,regex,token;skipComment();pos=index;loc={start:{line:lineNumber,column:index-lineStart}};regex=scanRegExp();loc.end={line:lineNumber,column:index-lineStart};if(!extra.tokenize){if(extra.tokens.length>0){token=extra.tokens[extra.tokens.length-1];if(token.range[0]===pos&&token.type==="Punctuator"){if(token.value==="/"||token.value==="/="){extra.tokens.pop()}}}extra.tokens.push({type:"RegularExpression",value:regex.literal,regex:regex.regex,range:[pos,index],loc:loc})}return regex}function isIdentifierName(token){return token.type===Token.Identifier||token.type===Token.Keyword||token.type===Token.BooleanLiteral||token.type===Token.NullLiteral}function advanceSlash(){var prevToken,checkToken;prevToken=extra.tokens[extra.tokens.length-1];if(!prevToken){return collectRegex()}if(prevToken.type==="Punctuator"){if(prevToken.value==="]"){return scanPunctuator()}if(prevToken.value===")"){checkToken=extra.tokens[extra.openParenToken-1];if(checkToken&&checkToken.type==="Keyword"&&(checkToken.value==="if"||checkToken.value==="while"||checkToken.value==="for"||checkToken.value==="with")){return collectRegex()}return scanPunctuator()}if(prevToken.value==="}"){if(extra.tokens[extra.openCurlyToken-3]&&extra.tokens[extra.openCurlyToken-3].type==="Keyword"){checkToken=extra.tokens[extra.openCurlyToken-4];if(!checkToken){return scanPunctuator()}}else if(extra.tokens[extra.openCurlyToken-4]&&extra.tokens[extra.openCurlyToken-4].type==="Keyword"){checkToken=extra.tokens[extra.openCurlyToken-5];if(!checkToken){return collectRegex()}}else{return scanPunctuator()}if(FnExprTokens.indexOf(checkToken.value)>=0){return scanPunctuator()}return collectRegex()}return collectRegex()}if(prevToken.type==="Keyword"&&prevToken.value!=="this"){return collectRegex()}return scanPunctuator()}function advance(){var ch,token;if(index>=length){return{type:Token.EOF,lineNumber:lineNumber,lineStart:lineStart,start:index,end:index}}ch=source.charCodeAt(index);if(isIdentifierStart(ch)){token=scanIdentifier();if(strict&&isStrictModeReservedWord(token.value)){token.type=Token.Keyword}return token}if(ch===40||ch===41||ch===59){return scanPunctuator()}if(ch===39||ch===34){return scanStringLiteral()}if(ch===46){if(isDecimalDigit(source.charCodeAt(index+1))){return scanNumericLiteral()}return scanPunctuator()}if(isDecimalDigit(ch)){return scanNumericLiteral()}if(extra.tokenize&&ch===47){return advanceSlash()}if(ch===96||ch===125&&state.curlyStack[state.curlyStack.length-1]==="${"){return scanTemplate()}return scanPunctuator()}function collectToken(){var loc,token,value,entry;loc={start:{line:lineNumber,column:index-lineStart}};token=advance();loc.end={line:lineNumber,column:index-lineStart};if(token.type!==Token.EOF){value=source.slice(token.start,token.end);entry={type:TokenName[token.type],value:value,range:[token.start,token.end],loc:loc};if(token.regex){entry.regex={pattern:token.regex.pattern,flags:token.regex.flags}}extra.tokens.push(entry)}return token}function lex(){var token;scanning=true;lastIndex=index;lastLineNumber=lineNumber;lastLineStart=lineStart;skipComment();token=lookahead;startIndex=index;startLineNumber=lineNumber;startLineStart=lineStart;lookahead=typeof extra.tokens!=="undefined"?collectToken():advance();scanning=false;return token}function peek(){scanning=true;skipComment();lastIndex=index;lastLineNumber=lineNumber;lastLineStart=lineStart;startIndex=index;startLineNumber=lineNumber;startLineStart=lineStart;lookahead=typeof extra.tokens!=="undefined"?collectToken():advance();scanning=false}function Position(){this.line=startLineNumber;this.column=startIndex-startLineStart;
}function SourceLocation(){this.start=new Position;this.end=null}function WrappingSourceLocation(startToken){this.start={line:startToken.lineNumber,column:startToken.start-startToken.lineStart};this.end=null}function Node(){if(extra.range){this.range=[startIndex,0]}if(extra.loc){this.loc=new SourceLocation}}function WrappingNode(startToken){if(extra.range){this.range=[startToken.start,0]}if(extra.loc){this.loc=new WrappingSourceLocation(startToken)}}WrappingNode.prototype=Node.prototype={processComment:function(){var lastChild,leadingComments,trailingComments,bottomRight=extra.bottomRightStack,i,comment,last=bottomRight[bottomRight.length-1];if(this.type===Syntax.Program){if(this.body.length>0){return}}if(extra.trailingComments.length>0){trailingComments=[];for(i=extra.trailingComments.length-1;i>=0;--i){comment=extra.trailingComments[i];if(comment.range[0]>=this.range[1]){trailingComments.unshift(comment);extra.trailingComments.splice(i,1)}}extra.trailingComments=[]}else{if(last&&last.trailingComments&&last.trailingComments[0].range[0]>=this.range[1]){trailingComments=last.trailingComments;delete last.trailingComments}}if(last){while(last&&last.range[0]>=this.range[0]){lastChild=last;last=bottomRight.pop()}}if(lastChild){if(lastChild.leadingComments&&lastChild.leadingComments[lastChild.leadingComments.length-1].range[1]<=this.range[0]){this.leadingComments=lastChild.leadingComments;lastChild.leadingComments=undefined}}else if(extra.leadingComments.length>0){leadingComments=[];for(i=extra.leadingComments.length-1;i>=0;--i){comment=extra.leadingComments[i];if(comment.range[1]<=this.range[0]){leadingComments.unshift(comment);extra.leadingComments.splice(i,1)}}}if(leadingComments&&leadingComments.length>0){this.leadingComments=leadingComments}if(trailingComments&&trailingComments.length>0){this.trailingComments=trailingComments}bottomRight.push(this)},finish:function(){if(extra.range){this.range[1]=lastIndex}if(extra.loc){this.loc.end={line:lastLineNumber,column:lastIndex-lastLineStart};if(extra.source){this.loc.source=extra.source}}if(extra.attachComment){this.processComment()}},finishArrayExpression:function(elements){this.type=Syntax.ArrayExpression;this.elements=elements;this.finish();return this},finishArrayPattern:function(elements){this.type=Syntax.ArrayPattern;this.elements=elements;this.finish();return this},finishArrowFunctionExpression:function(params,defaults,body,expression){this.type=Syntax.ArrowFunctionExpression;this.id=null;this.params=params;this.defaults=defaults;this.body=body;this.generator=false;this.expression=expression;this.finish();return this},finishAssignmentExpression:function(operator,left,right){this.type=Syntax.AssignmentExpression;this.operator=operator;this.left=left;this.right=right;this.finish();return this},finishAssignmentPattern:function(left,right){this.type=Syntax.AssignmentPattern;this.left=left;this.right=right;this.finish();return this},finishBinaryExpression:function(operator,left,right){this.type=operator==="||"||operator==="&&"?Syntax.LogicalExpression:Syntax.BinaryExpression;this.operator=operator;this.left=left;this.right=right;this.finish();return this},finishBlockStatement:function(body){this.type=Syntax.BlockStatement;this.body=body;this.finish();return this},finishBreakStatement:function(label){this.type=Syntax.BreakStatement;this.label=label;this.finish();return this},finishCallExpression:function(callee,args){this.type=Syntax.CallExpression;this.callee=callee;this.arguments=args;this.finish();return this},finishCatchClause:function(param,body){this.type=Syntax.CatchClause;this.param=param;this.body=body;this.finish();return this},finishClassBody:function(body){this.type=Syntax.ClassBody;this.body=body;this.finish();return this},finishClassDeclaration:function(id,superClass,body){this.type=Syntax.ClassDeclaration;this.id=id;this.superClass=superClass;this.body=body;this.finish();return this},finishClassExpression:function(id,superClass,body){this.type=Syntax.ClassExpression;this.id=id;this.superClass=superClass;this.body=body;this.finish();return this},finishConditionalExpression:function(test,consequent,alternate){this.type=Syntax.ConditionalExpression;this.test=test;this.consequent=consequent;this.alternate=alternate;this.finish();return this},finishContinueStatement:function(label){this.type=Syntax.ContinueStatement;this.label=label;this.finish();return this},finishDebuggerStatement:function(){this.type=Syntax.DebuggerStatement;this.finish();return this},finishDoWhileStatement:function(body,test){this.type=Syntax.DoWhileStatement;this.body=body;this.test=test;this.finish();return this},finishEmptyStatement:function(){this.type=Syntax.EmptyStatement;this.finish();return this},finishExpressionStatement:function(expression){this.type=Syntax.ExpressionStatement;this.expression=expression;this.finish();return this},finishForStatement:function(init,test,update,body){this.type=Syntax.ForStatement;this.init=init;this.test=test;this.update=update;this.body=body;this.finish();return this},finishForInStatement:function(left,right,body){this.type=Syntax.ForInStatement;this.left=left;this.right=right;this.body=body;this.each=false;this.finish();return this},finishFunctionDeclaration:function(id,params,defaults,body){this.type=Syntax.FunctionDeclaration;this.id=id;this.params=params;this.defaults=defaults;this.body=body;this.generator=false;this.expression=false;this.finish();return this},finishFunctionExpression:function(id,params,defaults,body){this.type=Syntax.FunctionExpression;this.id=id;this.params=params;this.defaults=defaults;this.body=body;this.generator=false;this.expression=false;this.finish();return this},finishIdentifier:function(name){this.type=Syntax.Identifier;this.name=name;this.finish();return this},finishIfStatement:function(test,consequent,alternate){this.type=Syntax.IfStatement;this.test=test;this.consequent=consequent;this.alternate=alternate;this.finish();return this},finishLabeledStatement:function(label,body){this.type=Syntax.LabeledStatement;this.label=label;this.body=body;this.finish();return this},finishLiteral:function(token){this.type=Syntax.Literal;this.value=token.value;this.raw=source.slice(token.start,token.end);if(token.regex){this.regex=token.regex}this.finish();return this},finishMemberExpression:function(accessor,object,property){this.type=Syntax.MemberExpression;this.computed=accessor==="[";this.object=object;this.property=property;this.finish();return this},finishNewExpression:function(callee,args){this.type=Syntax.NewExpression;this.callee=callee;this.arguments=args;this.finish();return this},finishObjectExpression:function(properties){this.type=Syntax.ObjectExpression;this.properties=properties;this.finish();return this},finishObjectPattern:function(properties){this.type=Syntax.ObjectPattern;this.properties=properties;this.finish();return this},finishPostfixExpression:function(operator,argument){this.type=Syntax.UpdateExpression;this.operator=operator;this.argument=argument;this.prefix=false;this.finish();return this},finishProgram:function(body){this.type=Syntax.Program;this.body=body;if(sourceType==="module"){this.sourceType=sourceType}this.finish();return this},finishProperty:function(kind,key,computed,value,method,shorthand){this.type=Syntax.Property;this.key=key;this.computed=computed;this.value=value;this.kind=kind;this.method=method;this.shorthand=shorthand;this.finish();return this},finishRestElement:function(argument){this.type=Syntax.RestElement;this.argument=argument;this.finish();return this},finishReturnStatement:function(argument){this.type=Syntax.ReturnStatement;this.argument=argument;this.finish();return this},finishSequenceExpression:function(expressions){this.type=Syntax.SequenceExpression;this.expressions=expressions;this.finish();return this},finishSpreadElement:function(argument){this.type=Syntax.SpreadElement;this.argument=argument;this.finish();return this},finishSwitchCase:function(test,consequent){this.type=Syntax.SwitchCase;this.test=test;this.consequent=consequent;this.finish();return this},finishSuper:function(){this.type=Syntax.Super;this.finish();return this},finishSwitchStatement:function(discriminant,cases){this.type=Syntax.SwitchStatement;this.discriminant=discriminant;this.cases=cases;this.finish();return this},finishTaggedTemplateExpression:function(tag,quasi){this.type=Syntax.TaggedTemplateExpression;this.tag=tag;this.quasi=quasi;this.finish();return this},finishTemplateElement:function(value,tail){this.type=Syntax.TemplateElement;this.value=value;this.tail=tail;this.finish();return this},finishTemplateLiteral:function(quasis,expressions){this.type=Syntax.TemplateLiteral;this.quasis=quasis;this.expressions=expressions;this.finish();return this},finishThisExpression:function(){this.type=Syntax.ThisExpression;this.finish();return this},finishThrowStatement:function(argument){this.type=Syntax.ThrowStatement;this.argument=argument;this.finish();return this},finishTryStatement:function(block,handler,finalizer){this.type=Syntax.TryStatement;this.block=block;this.guardedHandlers=[];this.handlers=handler?[handler]:[];this.handler=handler;this.finalizer=finalizer;this.finish();return this},finishUnaryExpression:function(operator,argument){this.type=operator==="++"||operator==="--"?Syntax.UpdateExpression:Syntax.UnaryExpression;this.operator=operator;this.argument=argument;this.prefix=true;this.finish();return this},finishVariableDeclaration:function(declarations){this.type=Syntax.VariableDeclaration;this.declarations=declarations;this.kind="var";this.finish();return this},finishLexicalDeclaration:function(declarations,kind){this.type=Syntax.VariableDeclaration;this.declarations=declarations;this.kind=kind;this.finish();return this},finishVariableDeclarator:function(id,init){this.type=Syntax.VariableDeclarator;this.id=id;this.init=init;this.finish();return this},finishWhileStatement:function(test,body){this.type=Syntax.WhileStatement;this.test=test;this.body=body;this.finish();return this},finishWithStatement:function(object,body){this.type=Syntax.WithStatement;this.object=object;this.body=body;this.finish();return this},finishExportSpecifier:function(local,exported){this.type=Syntax.ExportSpecifier;this.exported=exported||local;this.local=local;this.finish();return this},finishImportDefaultSpecifier:function(local){this.type=Syntax.ImportDefaultSpecifier;this.local=local;this.finish();return this},finishImportNamespaceSpecifier:function(local){this.type=Syntax.ImportNamespaceSpecifier;this.local=local;this.finish();return this},finishExportNamedDeclaration:function(declaration,specifiers,src){this.type=Syntax.ExportNamedDeclaration;this.declaration=declaration;this.specifiers=specifiers;this.source=src;this.finish();return this},finishExportDefaultDeclaration:function(declaration){this.type=Syntax.ExportDefaultDeclaration;this.declaration=declaration;this.finish();return this},finishExportAllDeclaration:function(src){this.type=Syntax.ExportAllDeclaration;this.source=src;this.finish();return this},finishImportSpecifier:function(local,imported){this.type=Syntax.ImportSpecifier;this.local=local||imported;this.imported=imported;this.finish();return this},finishImportDeclaration:function(specifiers,src){this.type=Syntax.ImportDeclaration;this.specifiers=specifiers;this.source=src;this.finish();return this}};function recordError(error){var e,existing;for(e=0;e<extra.errors.length;e++){existing=extra.errors[e];if(existing.index===error.index&&existing.message===error.message){return}}extra.errors.push(error)}function createError(line,pos,description){var error=new Error("Line "+line+": "+description);error.index=pos;error.lineNumber=line;error.column=pos-(scanning?lineStart:lastLineStart)+1;error.description=description;return error}function throwError(messageFormat){var args,msg;args=Array.prototype.slice.call(arguments,1);msg=messageFormat.replace(/%(\d)/g,function(whole,idx){assert(idx<args.length,"Message reference must be in range");return args[idx]});throw createError(lastLineNumber,lastIndex,msg)}function tolerateError(messageFormat){var args,msg,error;args=Array.prototype.slice.call(arguments,1);msg=messageFormat.replace(/%(\d)/g,function(whole,idx){assert(idx<args.length,"Message reference must be in range");return args[idx]});error=createError(lineNumber,lastIndex,msg);if(extra.errors){recordError(error)}else{throw error}}function unexpectedTokenError(token,message){var value,msg=message||Messages.UnexpectedToken;if(token){if(!message){msg=token.type===Token.EOF?Messages.UnexpectedEOS:token.type===Token.Identifier?Messages.UnexpectedIdentifier:token.type===Token.NumericLiteral?Messages.UnexpectedNumber:token.type===Token.StringLiteral?Messages.UnexpectedString:token.type===Token.Template?Messages.UnexpectedTemplate:Messages.UnexpectedToken;if(token.type===Token.Keyword){if(isFutureReservedWord(token.value)){msg=Messages.UnexpectedReserved}else if(strict&&isStrictModeReservedWord(token.value)){msg=Messages.StrictReservedWord}}}value=token.type===Token.Template?token.value.raw:token.value}else{value="ILLEGAL"}msg=msg.replace("%0",value);return token&&typeof token.lineNumber==="number"?createError(token.lineNumber,token.start,msg):createError(scanning?lineNumber:lastLineNumber,scanning?index:lastIndex,msg)}function throwUnexpectedToken(token,message){throw unexpectedTokenError(token,message)}function tolerateUnexpectedToken(token,message){var error=unexpectedTokenError(token,message);if(extra.errors){recordError(error)}else{throw error}}function expect(value){var token=lex();if(token.type!==Token.Punctuator||token.value!==value){throwUnexpectedToken(token)}}function expectCommaSeparator(){var token;if(extra.errors){token=lookahead;if(token.type===Token.Punctuator&&token.value===","){lex()}else if(token.type===Token.Punctuator&&token.value===";"){lex();tolerateUnexpectedToken(token)}else{tolerateUnexpectedToken(token,Messages.UnexpectedToken)}}else{expect(",")}}function expectKeyword(keyword){var token=lex();if(token.type!==Token.Keyword||token.value!==keyword){throwUnexpectedToken(token)}}function match(value){return lookahead.type===Token.Punctuator&&lookahead.value===value}function matchKeyword(keyword){return lookahead.type===Token.Keyword&&lookahead.value===keyword}function matchContextualKeyword(keyword){return lookahead.type===Token.Identifier&&lookahead.value===keyword}function matchAssign(){var op;if(lookahead.type!==Token.Punctuator){return false}op=lookahead.value;return op==="="||op==="*="||op==="/="||op==="%="||op==="+="||op==="-="||op==="<<="||op===">>="||op===">>>="||op==="&="||op==="^="||op==="|="}function consumeSemicolon(){if(source.charCodeAt(startIndex)===59||match(";")){lex();return}if(hasLineTerminator){return}lastIndex=startIndex;lastLineNumber=startLineNumber;lastLineStart=startLineStart;if(lookahead.type!==Token.EOF&&!match("}")){throwUnexpectedToken(lookahead)}}function isolateCoverGrammar(parser){var oldIsBindingElement=isBindingElement,oldIsAssignmentTarget=isAssignmentTarget,oldFirstCoverInitializedNameError=firstCoverInitializedNameError,result;isBindingElement=true;isAssignmentTarget=true;firstCoverInitializedNameError=null;result=parser();if(firstCoverInitializedNameError!==null){throwUnexpectedToken(firstCoverInitializedNameError)}isBindingElement=oldIsBindingElement;isAssignmentTarget=oldIsAssignmentTarget;firstCoverInitializedNameError=oldFirstCoverInitializedNameError;return result}function inheritCoverGrammar(parser){var oldIsBindingElement=isBindingElement,oldIsAssignmentTarget=isAssignmentTarget,oldFirstCoverInitializedNameError=firstCoverInitializedNameError,result;isBindingElement=true;isAssignmentTarget=true;firstCoverInitializedNameError=null;result=parser();isBindingElement=isBindingElement&&oldIsBindingElement;isAssignmentTarget=isAssignmentTarget&&oldIsAssignmentTarget;firstCoverInitializedNameError=oldFirstCoverInitializedNameError||firstCoverInitializedNameError;return result}function parseArrayPattern(){var node=new Node,elements=[],rest,restNode;expect("[");while(!match("]")){if(match(",")){lex();elements.push(null)}else{if(match("...")){restNode=new Node;lex();rest=parseVariableIdentifier();elements.push(restNode.finishRestElement(rest));break}else{elements.push(parsePatternWithDefault())}if(!match("]")){expect(",")}}}expect("]");return node.finishArrayPattern(elements)}function parsePropertyPattern(){var node=new Node,key,computed=match("["),init;if(lookahead.type===Token.Identifier){key=parseVariableIdentifier();if(match("=")){lex();init=parseAssignmentExpression();return node.finishProperty("init",key,false,new WrappingNode(key).finishAssignmentPattern(key,init),false,false)}else if(!match(":")){return node.finishProperty("init",key,false,key,false,true)}}else{key=parseObjectPropertyKey()}expect(":");init=parsePatternWithDefault();return node.finishProperty("init",key,computed,init,false,false)}function parseObjectPattern(){var node=new Node,properties=[];expect("{");while(!match("}")){properties.push(parsePropertyPattern());if(!match("}")){expect(",")}}lex();return node.finishObjectPattern(properties)}function parsePattern(){if(lookahead.type===Token.Identifier){return parseVariableIdentifier()}else if(match("[")){return parseArrayPattern()}else if(match("{")){return parseObjectPattern()}throwUnexpectedToken(lookahead)}function parsePatternWithDefault(){var startToken=lookahead,pattern,right;pattern=parsePattern();if(match("=")){lex();right=isolateCoverGrammar(parseAssignmentExpression);pattern=new WrappingNode(startToken).finishAssignmentPattern(pattern,right)}return pattern}function parseArrayInitialiser(){var elements=[],node=new Node,restSpread;expect("[");while(!match("]")){if(match(",")){lex();elements.push(null)}else if(match("...")){restSpread=new Node;lex();restSpread.finishSpreadElement(inheritCoverGrammar(parseAssignmentExpression));if(!match("]")){isAssignmentTarget=isBindingElement=false;expect(",")}elements.push(restSpread)}else{elements.push(inheritCoverGrammar(parseAssignmentExpression));if(!match("]")){expect(",")}}}lex();return node.finishArrayExpression(elements)}function parsePropertyFunction(node,paramInfo){var previousStrict,body;isAssignmentTarget=isBindingElement=false;previousStrict=strict;body=isolateCoverGrammar(parseFunctionSourceElements);if(strict&&paramInfo.firstRestricted){tolerateUnexpectedToken(paramInfo.firstRestricted,paramInfo.message)}if(strict&&paramInfo.stricted){tolerateUnexpectedToken(paramInfo.stricted,paramInfo.message)}strict=previousStrict;return node.finishFunctionExpression(null,paramInfo.params,paramInfo.defaults,body)}function parsePropertyMethodFunction(){var params,method,node=new Node;params=parseParams();method=parsePropertyFunction(node,params);return method}function parseObjectPropertyKey(){var token,node=new Node,expr;token=lex();switch(token.type){case Token.StringLiteral:case Token.NumericLiteral:if(strict&&token.octal){tolerateUnexpectedToken(token,Messages.StrictOctalLiteral)}return node.finishLiteral(token);case Token.Identifier:case Token.BooleanLiteral:case Token.NullLiteral:case Token.Keyword:return node.finishIdentifier(token.value);case Token.Punctuator:if(token.value==="["){expr=isolateCoverGrammar(parseAssignmentExpression);expect("]");return expr}break}throwUnexpectedToken(token)}function lookaheadPropertyName(){switch(lookahead.type){case Token.Identifier:case Token.StringLiteral:case Token.BooleanLiteral:case Token.NullLiteral:case Token.NumericLiteral:case Token.Keyword:return true;case Token.Punctuator:return lookahead.value==="["}return false}function tryParseMethodDefinition(token,key,computed,node){var value,options,methodNode;if(token.type===Token.Identifier){if(token.value==="get"&&lookaheadPropertyName()){computed=match("[");key=parseObjectPropertyKey();methodNode=new Node;expect("(");expect(")");value=parsePropertyFunction(methodNode,{params:[],defaults:[],stricted:null,firstRestricted:null,message:null});return node.finishProperty("get",key,computed,value,false,false)}else if(token.value==="set"&&lookaheadPropertyName()){computed=match("[");key=parseObjectPropertyKey();methodNode=new Node;expect("(");options={params:[],defaultCount:0,defaults:[],firstRestricted:null,paramSet:{}};if(match(")")){tolerateUnexpectedToken(lookahead)}else{parseParam(options);if(options.defaultCount===0){options.defaults=[]}}expect(")");value=parsePropertyFunction(methodNode,options);return node.finishProperty("set",key,computed,value,false,false)}}if(match("(")){value=parsePropertyMethodFunction();return node.finishProperty("init",key,computed,value,true,false)}return null}function checkProto(key,computed,hasProto){if(computed===false&&(key.type===Syntax.Identifier&&key.name==="__proto__"||key.type===Syntax.Literal&&key.value==="__proto__")){if(hasProto.value){tolerateError(Messages.DuplicateProtoProperty)}else{hasProto.value=true}}}function parseObjectProperty(hasProto){var token=lookahead,node=new Node,computed,key,maybeMethod,value;computed=match("[");key=parseObjectPropertyKey();maybeMethod=tryParseMethodDefinition(token,key,computed,node);if(maybeMethod){checkProto(maybeMethod.key,maybeMethod.computed,hasProto);return maybeMethod}checkProto(key,computed,hasProto);if(match(":")){lex();value=inheritCoverGrammar(parseAssignmentExpression);return node.finishProperty("init",key,computed,value,false,false)}if(token.type===Token.Identifier){if(match("=")){firstCoverInitializedNameError=lookahead;lex();value=isolateCoverGrammar(parseAssignmentExpression);return node.finishProperty("init",key,computed,new WrappingNode(token).finishAssignmentPattern(key,value),false,true)}return node.finishProperty("init",key,computed,key,false,true)}throwUnexpectedToken(lookahead)}function parseObjectInitialiser(){var properties=[],hasProto={value:false},node=new Node;expect("{");while(!match("}")){properties.push(parseObjectProperty(hasProto));if(!match("}")){expectCommaSeparator()}}expect("}");return node.finishObjectExpression(properties)}function reinterpretExpressionAsPattern(expr){var i;switch(expr.type){case Syntax.Identifier:case Syntax.MemberExpression:case Syntax.RestElement:case Syntax.AssignmentPattern:break;case Syntax.SpreadElement:expr.type=Syntax.RestElement;reinterpretExpressionAsPattern(expr.argument);break;case Syntax.ArrayExpression:expr.type=Syntax.ArrayPattern;for(i=0;i<expr.elements.length;i++){if(expr.elements[i]!==null){reinterpretExpressionAsPattern(expr.elements[i])}}break;case Syntax.ObjectExpression:expr.type=Syntax.ObjectPattern;for(i=0;i<expr.properties.length;i++){reinterpretExpressionAsPattern(expr.properties[i].value)}break;case Syntax.AssignmentExpression:expr.type=Syntax.AssignmentPattern;reinterpretExpressionAsPattern(expr.left);break;default:break}}function parseTemplateElement(option){var node,token;if(lookahead.type!==Token.Template||option.head&&!lookahead.head){throwUnexpectedToken()}node=new Node;token=lex();return node.finishTemplateElement({raw:token.value.raw,cooked:token.value.cooked},token.tail)}function parseTemplateLiteral(){var quasi,quasis,expressions,node=new Node;quasi=parseTemplateElement({head:true});quasis=[quasi];expressions=[];while(!quasi.tail){expressions.push(parseExpression());quasi=parseTemplateElement({head:false});quasis.push(quasi)}return node.finishTemplateLiteral(quasis,expressions)}function parseGroupExpression(){var expr,expressions,startToken,i;expect("(");if(match(")")){lex();if(!match("=>")){expect("=>")}return{type:PlaceHolders.ArrowParameterPlaceHolder,params:[]}}startToken=lookahead;if(match("...")){expr=parseRestElement();expect(")");if(!match("=>")){expect("=>")}return{type:PlaceHolders.ArrowParameterPlaceHolder,params:[expr]}}isBindingElement=true;expr=inheritCoverGrammar(parseAssignmentExpression);if(match(",")){isAssignmentTarget=false;expressions=[expr];while(startIndex<length){if(!match(",")){break}lex();if(match("...")){if(!isBindingElement){throwUnexpectedToken(lookahead)}expressions.push(parseRestElement());expect(")");if(!match("=>")){expect("=>")}isBindingElement=false;for(i=0;i<expressions.length;i++){reinterpretExpressionAsPattern(expressions[i])}return{type:PlaceHolders.ArrowParameterPlaceHolder,params:expressions}}expressions.push(inheritCoverGrammar(parseAssignmentExpression))}expr=new WrappingNode(startToken).finishSequenceExpression(expressions)}expect(")");if(match("=>")){if(!isBindingElement){throwUnexpectedToken(lookahead)}if(expr.type===Syntax.SequenceExpression){for(i=0;i<expr.expressions.length;i++){reinterpretExpressionAsPattern(expr.expressions[i])}}else{reinterpretExpressionAsPattern(expr)}expr={type:PlaceHolders.ArrowParameterPlaceHolder,params:expr.type===Syntax.SequenceExpression?expr.expressions:[expr]}}isBindingElement=false;return expr}function parsePrimaryExpression(){var type,token,expr,node;if(match("(")){isBindingElement=false;return inheritCoverGrammar(parseGroupExpression)}if(match("[")){return inheritCoverGrammar(parseArrayInitialiser)}if(match("{")){return inheritCoverGrammar(parseObjectInitialiser)}type=lookahead.type;node=new Node;if(type===Token.Identifier){expr=node.finishIdentifier(lex().value)}else if(type===Token.StringLiteral||type===Token.NumericLiteral){isAssignmentTarget=isBindingElement=false;if(strict&&lookahead.octal){tolerateUnexpectedToken(lookahead,Messages.StrictOctalLiteral)}expr=node.finishLiteral(lex())}else if(type===Token.Keyword){isAssignmentTarget=isBindingElement=false;if(matchKeyword("function")){return parseFunctionExpression()}if(matchKeyword("this")){lex();return node.finishThisExpression()}if(matchKeyword("class")){return parseClassExpression()}throwUnexpectedToken(lex())}else if(type===Token.BooleanLiteral){isAssignmentTarget=isBindingElement=false;token=lex();token.value=token.value==="true";expr=node.finishLiteral(token)}else if(type===Token.NullLiteral){isAssignmentTarget=isBindingElement=false;token=lex();token.value=null;expr=node.finishLiteral(token)}else if(match("/")||match("/=")){isAssignmentTarget=isBindingElement=false;index=startIndex;if(typeof extra.tokens!=="undefined"){token=collectRegex()}else{token=scanRegExp()}lex();expr=node.finishLiteral(token)}else if(type===Token.Template){expr=parseTemplateLiteral()}else{throwUnexpectedToken(lex())}return expr}function parseArguments(){var args=[];expect("(");if(!match(")")){while(startIndex<length){args.push(isolateCoverGrammar(parseAssignmentExpression));if(match(")")){break}expectCommaSeparator()}}expect(")");return args}function parseNonComputedProperty(){var token,node=new Node;token=lex();if(!isIdentifierName(token)){throwUnexpectedToken(token)}return node.finishIdentifier(token.value)}function parseNonComputedMember(){expect(".");return parseNonComputedProperty()}function parseComputedMember(){var expr;expect("[");expr=isolateCoverGrammar(parseExpression);expect("]");return expr}function parseNewExpression(){var callee,args,node=new Node;expectKeyword("new");callee=isolateCoverGrammar(parseLeftHandSideExpression);args=match("(")?parseArguments():[];isAssignmentTarget=isBindingElement=false;return node.finishNewExpression(callee,args)}function parseLeftHandSideExpressionAllowCall(){var quasi,expr,args,property,startToken,previousAllowIn=state.allowIn;startToken=lookahead;state.allowIn=true;if(matchKeyword("super")&&state.inFunctionBody){expr=new Node;lex();expr=expr.finishSuper();if(!match("(")&&!match(".")&&!match("[")){throwUnexpectedToken(lookahead)}}else{expr=inheritCoverGrammar(matchKeyword("new")?parseNewExpression:parsePrimaryExpression)}for(;;){if(match(".")){isBindingElement=false;isAssignmentTarget=true;property=parseNonComputedMember();expr=new WrappingNode(startToken).finishMemberExpression(".",expr,property)}else if(match("(")){isBindingElement=false;isAssignmentTarget=false;args=parseArguments();expr=new WrappingNode(startToken).finishCallExpression(expr,args)}else if(match("[")){isBindingElement=false;isAssignmentTarget=true;property=parseComputedMember();expr=new WrappingNode(startToken).finishMemberExpression("[",expr,property)}else if(lookahead.type===Token.Template&&lookahead.head){quasi=parseTemplateLiteral();expr=new WrappingNode(startToken).finishTaggedTemplateExpression(expr,quasi)}else{break}}state.allowIn=previousAllowIn;return expr}function parseLeftHandSideExpression(){var quasi,expr,property,startToken;assert(state.allowIn,"callee of new expression always allow in keyword.");startToken=lookahead;if(matchKeyword("super")&&state.inFunctionBody){expr=new Node;lex();expr=expr.finishSuper();if(!match("[")&&!match(".")){throwUnexpectedToken(lookahead)}}else{expr=inheritCoverGrammar(matchKeyword("new")?parseNewExpression:parsePrimaryExpression)}for(;;){if(match("[")){isBindingElement=false;isAssignmentTarget=true;property=parseComputedMember();expr=new WrappingNode(startToken).finishMemberExpression("[",expr,property)}else if(match(".")){isBindingElement=false;isAssignmentTarget=true;property=parseNonComputedMember();expr=new WrappingNode(startToken).finishMemberExpression(".",expr,property)}else if(lookahead.type===Token.Template&&lookahead.head){quasi=parseTemplateLiteral();expr=new WrappingNode(startToken).finishTaggedTemplateExpression(expr,quasi)}else{break}}return expr}function parsePostfixExpression(){var expr,token,startToken=lookahead;expr=inheritCoverGrammar(parseLeftHandSideExpressionAllowCall);if(!hasLineTerminator&&lookahead.type===Token.Punctuator){if(match("++")||match("--")){if(strict&&expr.type===Syntax.Identifier&&isRestrictedWord(expr.name)){tolerateError(Messages.StrictLHSPostfix)}if(!isAssignmentTarget){tolerateError(Messages.InvalidLHSInAssignment)}isAssignmentTarget=isBindingElement=false;token=lex();expr=new WrappingNode(startToken).finishPostfixExpression(token.value,expr)}}return expr}function parseUnaryExpression(){var token,expr,startToken;if(lookahead.type!==Token.Punctuator&&lookahead.type!==Token.Keyword){expr=parsePostfixExpression()}else if(match("++")||match("--")){startToken=lookahead;token=lex();expr=inheritCoverGrammar(parseUnaryExpression);if(strict&&expr.type===Syntax.Identifier&&isRestrictedWord(expr.name)){tolerateError(Messages.StrictLHSPrefix)}if(!isAssignmentTarget){tolerateError(Messages.InvalidLHSInAssignment)}expr=new WrappingNode(startToken).finishUnaryExpression(token.value,expr);isAssignmentTarget=isBindingElement=false}else if(match("+")||match("-")||match("~")||match("!")){startToken=lookahead;token=lex();expr=inheritCoverGrammar(parseUnaryExpression);expr=new WrappingNode(startToken).finishUnaryExpression(token.value,expr);isAssignmentTarget=isBindingElement=false}else if(matchKeyword("delete")||matchKeyword("void")||matchKeyword("typeof")){startToken=lookahead;token=lex();expr=inheritCoverGrammar(parseUnaryExpression);expr=new WrappingNode(startToken).finishUnaryExpression(token.value,expr);if(strict&&expr.operator==="delete"&&expr.argument.type===Syntax.Identifier){tolerateError(Messages.StrictDelete)}isAssignmentTarget=isBindingElement=false}else{expr=parsePostfixExpression()}return expr}function binaryPrecedence(token,allowIn){var prec=0;if(token.type!==Token.Punctuator&&token.type!==Token.Keyword){return 0}switch(token.value){case"||":prec=1;break;case"&&":prec=2;break;case"|":prec=3;break;case"^":prec=4;break;case"&":prec=5;break;case"==":case"!=":case"===":case"!==":prec=6;break;case"<":case">":case"<=":case">=":case"instanceof":prec=7;break;case"in":prec=allowIn?7:0;break;case"<<":case">>":case">>>":prec=8;break;case"+":case"-":prec=9;break;case"*":case"/":case"%":prec=11;break;default:break}return prec}function parseBinaryExpression(){var marker,markers,expr,token,prec,stack,right,operator,left,i;marker=lookahead;left=inheritCoverGrammar(parseUnaryExpression);token=lookahead;prec=binaryPrecedence(token,state.allowIn);if(prec===0){return left}isAssignmentTarget=isBindingElement=false;token.prec=prec;lex();markers=[marker,lookahead];right=isolateCoverGrammar(parseUnaryExpression);stack=[left,token,right];while((prec=binaryPrecedence(lookahead,state.allowIn))>0){while(stack.length>2&&prec<=stack[stack.length-2].prec){
right=stack.pop();operator=stack.pop().value;left=stack.pop();markers.pop();expr=new WrappingNode(markers[markers.length-1]).finishBinaryExpression(operator,left,right);stack.push(expr)}token=lex();token.prec=prec;stack.push(token);markers.push(lookahead);expr=isolateCoverGrammar(parseUnaryExpression);stack.push(expr)}i=stack.length-1;expr=stack[i];markers.pop();while(i>1){expr=new WrappingNode(markers.pop()).finishBinaryExpression(stack[i-1].value,stack[i-2],expr);i-=2}return expr}function parseConditionalExpression(){var expr,previousAllowIn,consequent,alternate,startToken;startToken=lookahead;expr=inheritCoverGrammar(parseBinaryExpression);if(match("?")){lex();previousAllowIn=state.allowIn;state.allowIn=true;consequent=isolateCoverGrammar(parseAssignmentExpression);state.allowIn=previousAllowIn;expect(":");alternate=isolateCoverGrammar(parseAssignmentExpression);expr=new WrappingNode(startToken).finishConditionalExpression(expr,consequent,alternate);isAssignmentTarget=isBindingElement=false}return expr}function parseConciseBody(){if(match("{")){return parseFunctionSourceElements()}return isolateCoverGrammar(parseAssignmentExpression)}function checkPatternParam(options,param){var i;switch(param.type){case Syntax.Identifier:validateParam(options,param,param.name);break;case Syntax.RestElement:checkPatternParam(options,param.argument);break;case Syntax.AssignmentPattern:checkPatternParam(options,param.left);break;case Syntax.ArrayPattern:for(i=0;i<param.elements.length;i++){if(param.elements[i]!==null){checkPatternParam(options,param.elements[i])}}break;default:assert(param.type===Syntax.ObjectPattern,"Invalid type");for(i=0;i<param.properties.length;i++){checkPatternParam(options,param.properties[i].value)}break}}function reinterpretAsCoverFormalsList(expr){var i,len,param,params,defaults,defaultCount,options,token;defaults=[];defaultCount=0;params=[expr];switch(expr.type){case Syntax.Identifier:break;case PlaceHolders.ArrowParameterPlaceHolder:params=expr.params;break;default:return null}options={paramSet:{}};for(i=0,len=params.length;i<len;i+=1){param=params[i];switch(param.type){case Syntax.AssignmentPattern:params[i]=param.left;defaults.push(param.right);++defaultCount;checkPatternParam(options,param.left);break;default:checkPatternParam(options,param);params[i]=param;defaults.push(null);break}}if(options.message===Messages.StrictParamDupe){token=strict?options.stricted:options.firstRestricted;throwUnexpectedToken(token,options.message)}if(defaultCount===0){defaults=[]}return{params:params,defaults:defaults,stricted:options.stricted,firstRestricted:options.firstRestricted,message:options.message}}function parseArrowFunctionExpression(options,node){var previousStrict,body;if(hasLineTerminator){tolerateUnexpectedToken(lookahead)}expect("=>");previousStrict=strict;body=parseConciseBody();if(strict&&options.firstRestricted){throwUnexpectedToken(options.firstRestricted,options.message)}if(strict&&options.stricted){tolerateUnexpectedToken(options.stricted,options.message)}strict=previousStrict;return node.finishArrowFunctionExpression(options.params,options.defaults,body,body.type!==Syntax.BlockStatement)}function parseAssignmentExpression(){var token,expr,right,list,startToken;startToken=lookahead;token=lookahead;expr=parseConditionalExpression();if(expr.type===PlaceHolders.ArrowParameterPlaceHolder||match("=>")){isAssignmentTarget=isBindingElement=false;list=reinterpretAsCoverFormalsList(expr);if(list){firstCoverInitializedNameError=null;return parseArrowFunctionExpression(list,new WrappingNode(startToken))}return expr}if(matchAssign()){if(!isAssignmentTarget){tolerateError(Messages.InvalidLHSInAssignment)}if(strict&&expr.type===Syntax.Identifier&&isRestrictedWord(expr.name)){tolerateUnexpectedToken(token,Messages.StrictLHSAssignment)}if(!match("=")){isAssignmentTarget=isBindingElement=false}else{reinterpretExpressionAsPattern(expr)}token=lex();right=isolateCoverGrammar(parseAssignmentExpression);expr=new WrappingNode(startToken).finishAssignmentExpression(token.value,expr,right);firstCoverInitializedNameError=null}return expr}function parseExpression(){var expr,startToken=lookahead,expressions;expr=isolateCoverGrammar(parseAssignmentExpression);if(match(",")){expressions=[expr];while(startIndex<length){if(!match(",")){break}lex();expressions.push(isolateCoverGrammar(parseAssignmentExpression))}expr=new WrappingNode(startToken).finishSequenceExpression(expressions)}return expr}function parseStatementListItem(){if(lookahead.type===Token.Keyword){switch(lookahead.value){case"export":if(sourceType!=="module"){tolerateUnexpectedToken(lookahead,Messages.IllegalExportDeclaration)}return parseExportDeclaration();case"import":if(sourceType!=="module"){tolerateUnexpectedToken(lookahead,Messages.IllegalImportDeclaration)}return parseImportDeclaration();case"const":case"let":return parseLexicalDeclaration({inFor:false});case"function":return parseFunctionDeclaration(new Node);case"class":return parseClassDeclaration()}}return parseStatement()}function parseStatementList(){var list=[];while(startIndex<length){if(match("}")){break}list.push(parseStatementListItem())}return list}function parseBlock(){var block,node=new Node;expect("{");block=parseStatementList();expect("}");return node.finishBlockStatement(block)}function parseVariableIdentifier(){var token,node=new Node;token=lex();if(token.type!==Token.Identifier){if(strict&&token.type===Token.Keyword&&isStrictModeReservedWord(token.value)){tolerateUnexpectedToken(token,Messages.StrictReservedWord)}else{throwUnexpectedToken(token)}}return node.finishIdentifier(token.value)}function parseVariableDeclaration(){var init=null,id,node=new Node;id=parsePattern();if(strict&&isRestrictedWord(id.name)){tolerateError(Messages.StrictVarName)}if(match("=")){lex();init=isolateCoverGrammar(parseAssignmentExpression)}else if(id.type!==Syntax.Identifier){expect("=")}return node.finishVariableDeclarator(id,init)}function parseVariableDeclarationList(){var list=[];do{list.push(parseVariableDeclaration());if(!match(",")){break}lex()}while(startIndex<length);return list}function parseVariableStatement(node){var declarations;expectKeyword("var");declarations=parseVariableDeclarationList();consumeSemicolon();return node.finishVariableDeclaration(declarations)}function parseLexicalBinding(kind,options){var init=null,id,node=new Node;id=parsePattern();if(strict&&id.type===Syntax.Identifier&&isRestrictedWord(id.name)){tolerateError(Messages.StrictVarName)}if(kind==="const"){if(!matchKeyword("in")){expect("=");init=isolateCoverGrammar(parseAssignmentExpression)}}else if(!options.inFor&&id.type!==Syntax.Identifier||match("=")){expect("=");init=isolateCoverGrammar(parseAssignmentExpression)}return node.finishVariableDeclarator(id,init)}function parseBindingList(kind,options){var list=[];do{list.push(parseLexicalBinding(kind,options));if(!match(",")){break}lex()}while(startIndex<length);return list}function parseLexicalDeclaration(options){var kind,declarations,node=new Node;kind=lex().value;assert(kind==="let"||kind==="const","Lexical declaration must be either let or const");declarations=parseBindingList(kind,options);consumeSemicolon();return node.finishLexicalDeclaration(declarations,kind)}function parseRestElement(){var param,node=new Node;lex();if(match("{")){throwError(Messages.ObjectPatternAsRestParameter)}param=parseVariableIdentifier();if(match("=")){throwError(Messages.DefaultRestParameter)}if(!match(")")){throwError(Messages.ParameterAfterRestParameter)}return node.finishRestElement(param)}function parseEmptyStatement(node){expect(";");return node.finishEmptyStatement()}function parseExpressionStatement(node){var expr=parseExpression();consumeSemicolon();return node.finishExpressionStatement(expr)}function parseIfStatement(node){var test,consequent,alternate;expectKeyword("if");expect("(");test=parseExpression();expect(")");consequent=parseStatement();if(matchKeyword("else")){lex();alternate=parseStatement()}else{alternate=null}return node.finishIfStatement(test,consequent,alternate)}function parseDoWhileStatement(node){var body,test,oldInIteration;expectKeyword("do");oldInIteration=state.inIteration;state.inIteration=true;body=parseStatement();state.inIteration=oldInIteration;expectKeyword("while");expect("(");test=parseExpression();expect(")");if(match(";")){lex()}return node.finishDoWhileStatement(body,test)}function parseWhileStatement(node){var test,body,oldInIteration;expectKeyword("while");expect("(");test=parseExpression();expect(")");oldInIteration=state.inIteration;state.inIteration=true;body=parseStatement();state.inIteration=oldInIteration;return node.finishWhileStatement(test,body)}function parseForStatement(node){var init,initSeq,initStartToken,test,update,left,right,kind,declarations,body,oldInIteration,previousAllowIn=state.allowIn;init=test=update=null;expectKeyword("for");expect("(");if(match(";")){lex()}else{if(matchKeyword("var")){init=new Node;lex();state.allowIn=false;init=init.finishVariableDeclaration(parseVariableDeclarationList());state.allowIn=previousAllowIn;if(init.declarations.length===1&&matchKeyword("in")){lex();left=init;right=parseExpression();init=null}else{expect(";")}}else if(matchKeyword("const")||matchKeyword("let")){init=new Node;kind=lex().value;state.allowIn=false;declarations=parseBindingList(kind,{inFor:true});state.allowIn=previousAllowIn;if(declarations.length===1&&declarations[0].init===null&&matchKeyword("in")){init=init.finishLexicalDeclaration(declarations,kind);lex();left=init;right=parseExpression();init=null}else{consumeSemicolon();init=init.finishLexicalDeclaration(declarations,kind)}}else{initStartToken=lookahead;state.allowIn=false;init=inheritCoverGrammar(parseAssignmentExpression);state.allowIn=previousAllowIn;if(matchKeyword("in")){if(!isAssignmentTarget){tolerateError(Messages.InvalidLHSInForIn)}lex();reinterpretExpressionAsPattern(init);left=init;right=parseExpression();init=null}else{if(match(",")){initSeq=[init];while(match(",")){lex();initSeq.push(isolateCoverGrammar(parseAssignmentExpression))}init=new WrappingNode(initStartToken).finishSequenceExpression(initSeq)}expect(";")}}}if(typeof left==="undefined"){if(!match(";")){test=parseExpression()}expect(";");if(!match(")")){update=parseExpression()}}expect(")");oldInIteration=state.inIteration;state.inIteration=true;body=isolateCoverGrammar(parseStatement);state.inIteration=oldInIteration;return typeof left==="undefined"?node.finishForStatement(init,test,update,body):node.finishForInStatement(left,right,body)}function parseContinueStatement(node){var label=null,key;expectKeyword("continue");if(source.charCodeAt(startIndex)===59){lex();if(!state.inIteration){throwError(Messages.IllegalContinue)}return node.finishContinueStatement(null)}if(hasLineTerminator){if(!state.inIteration){throwError(Messages.IllegalContinue)}return node.finishContinueStatement(null)}if(lookahead.type===Token.Identifier){label=parseVariableIdentifier();key="$"+label.name;if(!Object.prototype.hasOwnProperty.call(state.labelSet,key)){throwError(Messages.UnknownLabel,label.name)}}consumeSemicolon();if(label===null&&!state.inIteration){throwError(Messages.IllegalContinue)}return node.finishContinueStatement(label)}function parseBreakStatement(node){var label=null,key;expectKeyword("break");if(source.charCodeAt(lastIndex)===59){lex();if(!(state.inIteration||state.inSwitch)){throwError(Messages.IllegalBreak)}return node.finishBreakStatement(null)}if(hasLineTerminator){if(!(state.inIteration||state.inSwitch)){throwError(Messages.IllegalBreak)}return node.finishBreakStatement(null)}if(lookahead.type===Token.Identifier){label=parseVariableIdentifier();key="$"+label.name;if(!Object.prototype.hasOwnProperty.call(state.labelSet,key)){throwError(Messages.UnknownLabel,label.name)}}consumeSemicolon();if(label===null&&!(state.inIteration||state.inSwitch)){throwError(Messages.IllegalBreak)}return node.finishBreakStatement(label)}function parseReturnStatement(node){var argument=null;expectKeyword("return");if(!state.inFunctionBody){tolerateError(Messages.IllegalReturn)}if(source.charCodeAt(lastIndex)===32){if(isIdentifierStart(source.charCodeAt(lastIndex+1))){argument=parseExpression();consumeSemicolon();return node.finishReturnStatement(argument)}}if(hasLineTerminator){return node.finishReturnStatement(null)}if(!match(";")){if(!match("}")&&lookahead.type!==Token.EOF){argument=parseExpression()}}consumeSemicolon();return node.finishReturnStatement(argument)}function parseWithStatement(node){var object,body;if(strict){tolerateError(Messages.StrictModeWith)}expectKeyword("with");expect("(");object=parseExpression();expect(")");body=parseStatement();return node.finishWithStatement(object,body)}function parseSwitchCase(){var test,consequent=[],statement,node=new Node;if(matchKeyword("default")){lex();test=null}else{expectKeyword("case");test=parseExpression()}expect(":");while(startIndex<length){if(match("}")||matchKeyword("default")||matchKeyword("case")){break}statement=parseStatementListItem();consequent.push(statement)}return node.finishSwitchCase(test,consequent)}function parseSwitchStatement(node){var discriminant,cases,clause,oldInSwitch,defaultFound;expectKeyword("switch");expect("(");discriminant=parseExpression();expect(")");expect("{");cases=[];if(match("}")){lex();return node.finishSwitchStatement(discriminant,cases)}oldInSwitch=state.inSwitch;state.inSwitch=true;defaultFound=false;while(startIndex<length){if(match("}")){break}clause=parseSwitchCase();if(clause.test===null){if(defaultFound){throwError(Messages.MultipleDefaultsInSwitch)}defaultFound=true}cases.push(clause)}state.inSwitch=oldInSwitch;expect("}");return node.finishSwitchStatement(discriminant,cases)}function parseThrowStatement(node){var argument;expectKeyword("throw");if(hasLineTerminator){throwError(Messages.NewlineAfterThrow)}argument=parseExpression();consumeSemicolon();return node.finishThrowStatement(argument)}function parseCatchClause(){var param,body,node=new Node;expectKeyword("catch");expect("(");if(match(")")){throwUnexpectedToken(lookahead)}param=parsePattern();if(strict&&isRestrictedWord(param.name)){tolerateError(Messages.StrictCatchVariable)}expect(")");body=parseBlock();return node.finishCatchClause(param,body)}function parseTryStatement(node){var block,handler=null,finalizer=null;expectKeyword("try");block=parseBlock();if(matchKeyword("catch")){handler=parseCatchClause()}if(matchKeyword("finally")){lex();finalizer=parseBlock()}if(!handler&&!finalizer){throwError(Messages.NoCatchOrFinally)}return node.finishTryStatement(block,handler,finalizer)}function parseDebuggerStatement(node){expectKeyword("debugger");consumeSemicolon();return node.finishDebuggerStatement()}function parseStatement(){var type=lookahead.type,expr,labeledBody,key,node;if(type===Token.EOF){throwUnexpectedToken(lookahead)}if(type===Token.Punctuator&&lookahead.value==="{"){return parseBlock()}isAssignmentTarget=isBindingElement=true;node=new Node;if(type===Token.Punctuator){switch(lookahead.value){case";":return parseEmptyStatement(node);case"(":return parseExpressionStatement(node);default:break}}else if(type===Token.Keyword){switch(lookahead.value){case"break":return parseBreakStatement(node);case"continue":return parseContinueStatement(node);case"debugger":return parseDebuggerStatement(node);case"do":return parseDoWhileStatement(node);case"for":return parseForStatement(node);case"function":return parseFunctionDeclaration(node);case"if":return parseIfStatement(node);case"return":return parseReturnStatement(node);case"switch":return parseSwitchStatement(node);case"throw":return parseThrowStatement(node);case"try":return parseTryStatement(node);case"var":return parseVariableStatement(node);case"while":return parseWhileStatement(node);case"with":return parseWithStatement(node);default:break}}expr=parseExpression();if(expr.type===Syntax.Identifier&&match(":")){lex();key="$"+expr.name;if(Object.prototype.hasOwnProperty.call(state.labelSet,key)){throwError(Messages.Redeclaration,"Label",expr.name)}state.labelSet[key]=true;labeledBody=parseStatement();delete state.labelSet[key];return node.finishLabeledStatement(expr,labeledBody)}consumeSemicolon();return node.finishExpressionStatement(expr)}function parseFunctionSourceElements(){var statement,body=[],token,directive,firstRestricted,oldLabelSet,oldInIteration,oldInSwitch,oldInFunctionBody,oldParenthesisCount,node=new Node;expect("{");while(startIndex<length){if(lookahead.type!==Token.StringLiteral){break}token=lookahead;statement=parseStatementListItem();body.push(statement);if(statement.expression.type!==Syntax.Literal){break}directive=source.slice(token.start+1,token.end-1);if(directive==="use strict"){strict=true;if(firstRestricted){tolerateUnexpectedToken(firstRestricted,Messages.StrictOctalLiteral)}}else{if(!firstRestricted&&token.octal){firstRestricted=token}}}oldLabelSet=state.labelSet;oldInIteration=state.inIteration;oldInSwitch=state.inSwitch;oldInFunctionBody=state.inFunctionBody;oldParenthesisCount=state.parenthesizedCount;state.labelSet={};state.inIteration=false;state.inSwitch=false;state.inFunctionBody=true;state.parenthesizedCount=0;while(startIndex<length){if(match("}")){break}body.push(parseStatementListItem())}expect("}");state.labelSet=oldLabelSet;state.inIteration=oldInIteration;state.inSwitch=oldInSwitch;state.inFunctionBody=oldInFunctionBody;state.parenthesizedCount=oldParenthesisCount;return node.finishBlockStatement(body)}function validateParam(options,param,name){var key="$"+name;if(strict){if(isRestrictedWord(name)){options.stricted=param;options.message=Messages.StrictParamName}if(Object.prototype.hasOwnProperty.call(options.paramSet,key)){options.stricted=param;options.message=Messages.StrictParamDupe}}else if(!options.firstRestricted){if(isRestrictedWord(name)){options.firstRestricted=param;options.message=Messages.StrictParamName}else if(isStrictModeReservedWord(name)){options.firstRestricted=param;options.message=Messages.StrictReservedWord}else if(Object.prototype.hasOwnProperty.call(options.paramSet,key)){options.firstRestricted=param;options.message=Messages.StrictParamDupe}}options.paramSet[key]=true}function parseParam(options){var token,param,def;token=lookahead;if(token.value==="..."){param=parseRestElement();validateParam(options,param.argument,param.argument.name);options.params.push(param);options.defaults.push(null);return false}param=parsePatternWithDefault();validateParam(options,token,token.value);if(param.type===Syntax.AssignmentPattern){def=param.right;param=param.left;++options.defaultCount}options.params.push(param);options.defaults.push(def);return!match(")")}function parseParams(firstRestricted){var options;options={params:[],defaultCount:0,defaults:[],firstRestricted:firstRestricted};expect("(");if(!match(")")){options.paramSet={};while(startIndex<length){if(!parseParam(options)){break}expect(",")}}expect(")");if(options.defaultCount===0){options.defaults=[]}return{params:options.params,defaults:options.defaults,stricted:options.stricted,firstRestricted:options.firstRestricted,message:options.message}}function parseFunctionDeclaration(node,identifierIsOptional){var id=null,params=[],defaults=[],body,token,stricted,tmp,firstRestricted,message,previousStrict;expectKeyword("function");if(!identifierIsOptional||!match("(")){token=lookahead;id=parseVariableIdentifier();if(strict){if(isRestrictedWord(token.value)){tolerateUnexpectedToken(token,Messages.StrictFunctionName)}}else{if(isRestrictedWord(token.value)){firstRestricted=token;message=Messages.StrictFunctionName}else if(isStrictModeReservedWord(token.value)){firstRestricted=token;message=Messages.StrictReservedWord}}}tmp=parseParams(firstRestricted);params=tmp.params;defaults=tmp.defaults;stricted=tmp.stricted;firstRestricted=tmp.firstRestricted;if(tmp.message){message=tmp.message}previousStrict=strict;body=parseFunctionSourceElements();if(strict&&firstRestricted){throwUnexpectedToken(firstRestricted,message)}if(strict&&stricted){tolerateUnexpectedToken(stricted,message)}strict=previousStrict;return node.finishFunctionDeclaration(id,params,defaults,body)}function parseFunctionExpression(){var token,id=null,stricted,firstRestricted,message,tmp,params=[],defaults=[],body,previousStrict,node=new Node;expectKeyword("function");if(!match("(")){token=lookahead;id=parseVariableIdentifier();if(strict){if(isRestrictedWord(token.value)){tolerateUnexpectedToken(token,Messages.StrictFunctionName)}}else{if(isRestrictedWord(token.value)){firstRestricted=token;message=Messages.StrictFunctionName}else if(isStrictModeReservedWord(token.value)){firstRestricted=token;message=Messages.StrictReservedWord}}}tmp=parseParams(firstRestricted);params=tmp.params;defaults=tmp.defaults;stricted=tmp.stricted;firstRestricted=tmp.firstRestricted;if(tmp.message){message=tmp.message}previousStrict=strict;body=parseFunctionSourceElements();if(strict&&firstRestricted){throwUnexpectedToken(firstRestricted,message)}if(strict&&stricted){tolerateUnexpectedToken(stricted,message)}strict=previousStrict;return node.finishFunctionExpression(id,params,defaults,body)}function parseClassBody(){var classBody,token,isStatic,hasConstructor=false,body,method,computed,key;classBody=new Node;expect("{");body=[];while(!match("}")){if(match(";")){lex()}else{method=new Node;token=lookahead;isStatic=false;computed=match("[");key=parseObjectPropertyKey();if(key.name==="static"&&lookaheadPropertyName()){token=lookahead;isStatic=true;computed=match("[");key=parseObjectPropertyKey()}method=tryParseMethodDefinition(token,key,computed,method);if(method){method["static"]=isStatic;if(method.kind==="init"){method.kind="method"}if(!isStatic){if(!method.computed&&(method.key.name||method.key.value.toString())==="constructor"){if(method.kind!=="method"||!method.method||method.value.generator){throwUnexpectedToken(token,Messages.ConstructorSpecialMethod)}if(hasConstructor){throwUnexpectedToken(token,Messages.DuplicateConstructor)}else{hasConstructor=true}method.kind="constructor"}}else{if(!method.computed&&(method.key.name||method.key.value.toString())==="prototype"){throwUnexpectedToken(token,Messages.StaticPrototype)}}method.type=Syntax.MethodDefinition;delete method.method;delete method.shorthand;body.push(method)}else{throwUnexpectedToken(lookahead)}}}lex();return classBody.finishClassBody(body)}function parseClassDeclaration(identifierIsOptional){var id=null,superClass=null,classNode=new Node,classBody,previousStrict=strict;strict=true;expectKeyword("class");if(!identifierIsOptional||lookahead.type===Token.Identifier){id=parseVariableIdentifier()}if(matchKeyword("extends")){lex();superClass=isolateCoverGrammar(parseLeftHandSideExpressionAllowCall)}classBody=parseClassBody();strict=previousStrict;return classNode.finishClassDeclaration(id,superClass,classBody)}function parseClassExpression(){var id=null,superClass=null,classNode=new Node,classBody,previousStrict=strict;strict=true;expectKeyword("class");if(lookahead.type===Token.Identifier){id=parseVariableIdentifier()}if(matchKeyword("extends")){lex();superClass=isolateCoverGrammar(parseLeftHandSideExpressionAllowCall)}classBody=parseClassBody();strict=previousStrict;return classNode.finishClassExpression(id,superClass,classBody)}function parseModuleSpecifier(){var node=new Node;if(lookahead.type!==Token.StringLiteral){throwError(Messages.InvalidModuleSpecifier)}return node.finishLiteral(lex())}function parseExportSpecifier(){var exported,local,node=new Node,def;if(matchKeyword("default")){def=new Node;lex();local=def.finishIdentifier("default")}else{local=parseVariableIdentifier()}if(matchContextualKeyword("as")){lex();exported=parseNonComputedProperty()}return node.finishExportSpecifier(local,exported)}function parseExportNamedDeclaration(node){var declaration=null,isExportFromIdentifier,src=null,specifiers=[];if(lookahead.type===Token.Keyword){switch(lookahead.value){case"let":case"const":case"var":case"class":case"function":declaration=parseStatementListItem();return node.finishExportNamedDeclaration(declaration,specifiers,null)}}expect("{");if(!match("}")){do{isExportFromIdentifier=isExportFromIdentifier||matchKeyword("default");specifiers.push(parseExportSpecifier())}while(match(",")&&lex())}expect("}");if(matchContextualKeyword("from")){lex();src=parseModuleSpecifier();consumeSemicolon()}else if(isExportFromIdentifier){throwError(lookahead.value?Messages.UnexpectedToken:Messages.MissingFromClause,lookahead.value)}else{consumeSemicolon()}return node.finishExportNamedDeclaration(declaration,specifiers,src)}function parseExportDefaultDeclaration(node){var declaration=null,expression=null;expectKeyword("default");if(matchKeyword("function")){declaration=parseFunctionDeclaration(new Node,true);return node.finishExportDefaultDeclaration(declaration)}if(matchKeyword("class")){declaration=parseClassDeclaration(true);return node.finishExportDefaultDeclaration(declaration)}if(matchContextualKeyword("from")){throwError(Messages.UnexpectedToken,lookahead.value)}if(match("{")){expression=parseObjectInitialiser()}else if(match("[")){expression=parseArrayInitialiser()}else{expression=parseAssignmentExpression()}consumeSemicolon();return node.finishExportDefaultDeclaration(expression)}function parseExportAllDeclaration(node){var src;expect("*");if(!matchContextualKeyword("from")){throwError(lookahead.value?Messages.UnexpectedToken:Messages.MissingFromClause,lookahead.value)}lex();src=parseModuleSpecifier();consumeSemicolon();return node.finishExportAllDeclaration(src)}function parseExportDeclaration(){var node=new Node;if(state.inFunctionBody){throwError(Messages.IllegalExportDeclaration)}expectKeyword("export");if(matchKeyword("default")){return parseExportDefaultDeclaration(node)}if(match("*")){return parseExportAllDeclaration(node)}return parseExportNamedDeclaration(node)}function parseImportSpecifier(){var local,imported,node=new Node;imported=parseNonComputedProperty();if(matchContextualKeyword("as")){lex();local=parseVariableIdentifier()}return node.finishImportSpecifier(local,imported)}function parseNamedImports(){var specifiers=[];expect("{");if(!match("}")){do{specifiers.push(parseImportSpecifier())}while(match(",")&&lex())}expect("}");return specifiers}function parseImportDefaultSpecifier(){var local,node=new Node;local=parseNonComputedProperty();return node.finishImportDefaultSpecifier(local)}function parseImportNamespaceSpecifier(){var local,node=new Node;expect("*");if(!matchContextualKeyword("as")){throwError(Messages.NoAsAfterImportNamespace)}lex();local=parseNonComputedProperty();return node.finishImportNamespaceSpecifier(local)}function parseImportDeclaration(){var specifiers,src,node=new Node;if(state.inFunctionBody){throwError(Messages.IllegalImportDeclaration)}expectKeyword("import");specifiers=[];if(lookahead.type===Token.StringLiteral){src=parseModuleSpecifier();consumeSemicolon();return node.finishImportDeclaration(specifiers,src)}if(!matchKeyword("default")&&isIdentifierName(lookahead)){specifiers.push(parseImportDefaultSpecifier());if(match(",")){lex()}}if(match("*")){specifiers.push(parseImportNamespaceSpecifier())}else if(match("{")){specifiers=specifiers.concat(parseNamedImports())}if(!matchContextualKeyword("from")){throwError(lookahead.value?Messages.UnexpectedToken:Messages.MissingFromClause,lookahead.value)}lex();src=parseModuleSpecifier();consumeSemicolon();return node.finishImportDeclaration(specifiers,src)}function parseScriptBody(){var statement,body=[],token,directive,firstRestricted;while(startIndex<length){token=lookahead;if(token.type!==Token.StringLiteral){break}statement=parseStatementListItem();body.push(statement);if(statement.expression.type!==Syntax.Literal){break}directive=source.slice(token.start+1,token.end-1);if(directive==="use strict"){strict=true;if(firstRestricted){tolerateUnexpectedToken(firstRestricted,Messages.StrictOctalLiteral)}}else{if(!firstRestricted&&token.octal){firstRestricted=token}}}while(startIndex<length){statement=parseStatementListItem();if(typeof statement==="undefined"){break}body.push(statement)}return body}function parseProgram(){var body,node;peek();node=new Node;body=parseScriptBody();return node.finishProgram(body)}function filterTokenLocation(){var i,entry,token,tokens=[];for(i=0;i<extra.tokens.length;++i){entry=extra.tokens[i];token={type:entry.type,value:entry.value};if(entry.regex){token.regex={pattern:entry.regex.pattern,flags:entry.regex.flags}}if(extra.range){token.range=entry.range}if(extra.loc){token.loc=entry.loc}tokens.push(token)}extra.tokens=tokens}function tokenize(code,options){var toString,tokens;toString=String;if(typeof code!=="string"&&!(code instanceof String)){code=toString(code)}source=code;index=0;lineNumber=source.length>0?1:0;lineStart=0;startIndex=index;startLineNumber=lineNumber;startLineStart=lineStart;length=source.length;lookahead=null;state={allowIn:true,labelSet:{},inFunctionBody:false,inIteration:false,inSwitch:false,lastCommentStart:-1,curlyStack:[]};extra={};options=options||{};options.tokens=true;extra.tokens=[];extra.tokenize=true;extra.openParenToken=-1;extra.openCurlyToken=-1;extra.range=typeof options.range==="boolean"&&options.range;extra.loc=typeof options.loc==="boolean"&&options.loc;if(typeof options.comment==="boolean"&&options.comment){extra.comments=[]}if(typeof options.tolerant==="boolean"&&options.tolerant){extra.errors=[]}try{peek();if(lookahead.type===Token.EOF){return extra.tokens}lex();while(lookahead.type!==Token.EOF){try{lex()}catch(lexError){if(extra.errors){recordError(lexError);break}else{throw lexError}}}filterTokenLocation();tokens=extra.tokens;if(typeof extra.comments!=="undefined"){tokens.comments=extra.comments}if(typeof extra.errors!=="undefined"){tokens.errors=extra.errors}}catch(e){throw e}finally{extra={}}return tokens}function parse(code,options){var program,toString;toString=String;if(typeof code!=="string"&&!(code instanceof String)){code=toString(code)}source=code;index=0;lineNumber=source.length>0?1:0;lineStart=0;startIndex=index;startLineNumber=lineNumber;startLineStart=lineStart;length=source.length;lookahead=null;state={allowIn:true,labelSet:{},inFunctionBody:false,inIteration:false,inSwitch:false,lastCommentStart:-1,curlyStack:[]};sourceType="script";strict=false;extra={};if(typeof options!=="undefined"){extra.range=typeof options.range==="boolean"&&options.range;extra.loc=typeof options.loc==="boolean"&&options.loc;extra.attachComment=typeof options.attachComment==="boolean"&&options.attachComment;if(extra.loc&&options.source!==null&&options.source!==undefined){extra.source=toString(options.source)}if(typeof options.tokens==="boolean"&&options.tokens){extra.tokens=[]}if(typeof options.comment==="boolean"&&options.comment){extra.comments=[]}if(typeof options.tolerant==="boolean"&&options.tolerant){extra.errors=[]}if(extra.attachComment){extra.range=true;extra.comments=[];extra.bottomRightStack=[];extra.trailingComments=[];extra.leadingComments=[]}if(options.sourceType==="module"){sourceType=options.sourceType;strict=true}}try{program=parseProgram();if(typeof extra.comments!=="undefined"){program.comments=extra.comments}if(typeof extra.tokens!=="undefined"){filterTokenLocation();program.tokens=extra.tokens}if(typeof extra.errors!=="undefined"){program.errors=extra.errors}}catch(e){throw e}finally{extra={}}return program}exports.version="2.2.0";exports.tokenize=tokenize;exports.parse=parse;exports.Syntax=function(){var name,types={};if(typeof Object.create==="function"){types=Object.create(null)}for(name in Syntax){if(Syntax.hasOwnProperty(name)){types[name]=Syntax[name]}}if(typeof Object.freeze==="function"){Object.freeze(types)}return types}()})},{}]},{},[]);require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e);
},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){module.exports={name:"estraverse",description:"ECMAScript JS AST traversal functions",homepage:"https://github.com/estools/estraverse",main:"estraverse.js",version:"4.0.0",engines:{node:">=0.10.0"},maintainers:[{name:"Yusuke Suzuki",email:"utatane.tea@gmail.com",web:"http://github.com/Constellation"}],repository:{type:"git",url:"http://github.com/estools/estraverse.git"},devDependencies:{chai:"^2.1.1","coffee-script":"^1.8.0",espree:"^1.11.0",gulp:"^3.8.10","gulp-bump":"^0.2.2","gulp-filter":"^2.0.0","gulp-git":"^1.0.1","gulp-tag-version":"^1.2.1",jshint:"^2.5.6",mocha:"^2.1.0"},licenses:[{type:"BSD",url:"http://github.com/estools/estraverse/raw/master/LICENSE.BSD"}],scripts:{},readme:"### Estraverse [![Build Status](https://secure.travis-ci.org/estools/estraverse.png)](http://travis-ci.org/estools/estraverse)\n\nEstraverse ([estraverse](http://github.com/estools/estraverse)) is\n[ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm)\ntraversal functions from [esmangle project](http://github.com/estools/esmangle).\n\n### Documentation\n\nYou can find usage docs at [wiki page](https://github.com/estools/estraverse/wiki/Usage).\n\n### Example Usage\n\nThe following code will output all variables declared at the root of a file.\n\n```javascript\nestraverse.traverse(ast, {\n enter: function (node, parent) {\n if (node.type == 'FunctionExpression' || node.type == 'FunctionDeclaration')\n return estraverse.VisitorOption.Skip;\n },\n leave: function (node, parent) {\n if (node.type == 'VariableDeclarator')\n console.log(node.id.name);\n }\n});\n```\n\nWe can use `this.skip`, `this.remove` and `this.break` functions instead of using Skip, Remove and Break.\n\n```javascript\nestraverse.traverse(ast, {\n enter: function (node) {\n this.break();\n }\n});\n```\n\nAnd estraverse provides `estraverse.replace` function. When returning node from `enter`/`leave`, current node is replaced with it.\n\n```javascript\nresult = estraverse.replace(tree, {\n enter: function (node) {\n // Replace it with replaced.\n if (node.type === 'Literal')\n return replaced;\n }\n});\n```\n\nBy passing `visitor.keys` mapping, we can extend estraverse traversing functionality.\n\n```javascript\n// This tree contains a user-defined `TestExpression` node.\nvar tree = {\n type: 'TestExpression',\n\n // This 'argument' is the property containing the other **node**.\n argument: {\n type: 'Literal',\n value: 20\n },\n\n // This 'extended' is the property not containing the other **node**.\n extended: true\n};\nestraverse.traverse(tree, {\n enter: function (node) { },\n\n // Extending the exising traversing rules.\n keys: {\n // TargetNodeName: [ 'keys', 'containing', 'the', 'other', '**node**' ]\n TestExpression: ['argument']\n }\n});\n```\n\nBy passing `visitor.fallback` option, we can control the behavior when encountering unknown nodes.\n```javascript\n// This tree contains a user-defined `TestExpression` node.\nvar tree = {\n type: 'TestExpression',\n\n // This 'argument' is the property containing the other **node**.\n argument: {\n type: 'Literal',\n value: 20\n },\n\n // This 'extended' is the property not containing the other **node**.\n extended: true\n};\nestraverse.traverse(tree, {\n enter: function (node) { },\n\n // Iterating the child **nodes** of unknown nodes.\n fallback: 'iteration'\n});\n```\n\n### License\n\nCopyright (C) 2012-2013 [Yusuke Suzuki](http://github.com/Constellation)\n (twitter: [@Constellation](http://twitter.com/Constellation)) and other contributors.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n\n * Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\nTHIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n",readmeFilename:"package/README.md"}},{}],estraverse:[function(require,module,exports){(function clone(exports){"use strict";var Syntax,isArray,VisitorOption,VisitorKeys,objectCreate,objectKeys,BREAK,SKIP,REMOVE;function ignoreJSHintError(){}isArray=Array.isArray;if(!isArray){isArray=function isArray(array){return Object.prototype.toString.call(array)==="[object Array]"}}function deepCopy(obj){var ret={},key,val;for(key in obj){if(obj.hasOwnProperty(key)){val=obj[key];if(typeof val==="object"&&val!==null){ret[key]=deepCopy(val)}else{ret[key]=val}}}return ret}function shallowCopy(obj){var ret={},key;for(key in obj){if(obj.hasOwnProperty(key)){ret[key]=obj[key]}}return ret}ignoreJSHintError(shallowCopy);function upperBound(array,func){var diff,len,i,current;len=array.length;i=0;while(len){diff=len>>>1;current=i+diff;if(func(array[current])){len=diff}else{i=current+1;len-=diff+1}}return i}function lowerBound(array,func){var diff,len,i,current;len=array.length;i=0;while(len){diff=len>>>1;current=i+diff;if(func(array[current])){i=current+1;len-=diff+1}else{len=diff}}return i}ignoreJSHintError(lowerBound);objectCreate=Object.create||function(){function F(){}return function(o){F.prototype=o;return new F}}();objectKeys=Object.keys||function(o){var keys=[],key;for(key in o){keys.push(key)}return keys};function extend(to,from){var keys=objectKeys(from),key,i,len;for(i=0,len=keys.length;i<len;i+=1){key=keys[i];to[key]=from[key]}return to}Syntax={AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AwaitExpression:"AwaitExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ComprehensionBlock:"ComprehensionBlock",ComprehensionExpression:"ComprehensionExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DebuggerStatement:"DebuggerStatement",DirectiveStatement:"DirectiveStatement",DoWhileStatement:"DoWhileStatement",EmptyStatement:"EmptyStatement",ExportAllDeclaration:"ExportAllDeclaration",ExportDefaultDeclaration:"ExportDefaultDeclaration",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",ForOfStatement:"ForOfStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",GeneratorExpression:"GeneratorExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MethodDefinition:"MethodDefinition",ModuleSpecifier:"ModuleSpecifier",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",Program:"Program",Property:"Property",RestElement:"RestElement",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",Super:"Super",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement",YieldExpression:"YieldExpression"};VisitorKeys={AssignmentExpression:["left","right"],AssignmentPattern:["left","right"],ArrayExpression:["elements"],ArrayPattern:["elements"],ArrowFunctionExpression:["params","body"],AwaitExpression:["argument"],BlockStatement:["body"],BinaryExpression:["left","right"],BreakStatement:["label"],CallExpression:["callee","arguments"],CatchClause:["param","body"],ClassBody:["body"],ClassDeclaration:["id","superClass","body"],ClassExpression:["id","superClass","body"],ComprehensionBlock:["left","right"],ComprehensionExpression:["blocks","filter","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DirectiveStatement:[],DoWhileStatement:["body","test"],EmptyStatement:[],ExportAllDeclaration:["source"],ExportDefaultDeclaration:["declaration"],ExportNamedDeclaration:["declaration","specifiers","source"],ExportSpecifier:["exported","local"],ExpressionStatement:["expression"],ForStatement:["init","test","update","body"],ForInStatement:["left","right","body"],ForOfStatement:["left","right","body"],FunctionDeclaration:["id","params","body"],FunctionExpression:["id","params","body"],GeneratorExpression:["blocks","filter","body"],Identifier:[],IfStatement:["test","consequent","alternate"],ImportDeclaration:["specifiers","source"],ImportDefaultSpecifier:["local"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["imported","local"],Literal:[],LabeledStatement:["label","body"],LogicalExpression:["left","right"],MemberExpression:["object","property"],MethodDefinition:["key","value"],ModuleSpecifier:[],NewExpression:["callee","arguments"],ObjectExpression:["properties"],ObjectPattern:["properties"],Program:["body"],Property:["key","value"],RestElement:["argument"],ReturnStatement:["argument"],SequenceExpression:["expressions"],SpreadElement:["argument"],Super:[],SwitchStatement:["discriminant","cases"],SwitchCase:["test","consequent"],TaggedTemplateExpression:["tag","quasi"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],YieldExpression:["argument"]};BREAK={};SKIP={};REMOVE={};VisitorOption={Break:BREAK,Skip:SKIP,Remove:REMOVE};function Reference(parent,key){this.parent=parent;this.key=key}Reference.prototype.replace=function replace(node){this.parent[this.key]=node};Reference.prototype.remove=function remove(){if(isArray(this.parent)){this.parent.splice(this.key,1);return true}else{this.replace(null);return false}};function Element(node,path,wrap,ref){this.node=node;this.path=path;this.wrap=wrap;this.ref=ref}function Controller(){}Controller.prototype.path=function path(){var i,iz,j,jz,result,element;function addToPath(result,path){if(isArray(path)){for(j=0,jz=path.length;j<jz;++j){result.push(path[j])}}else{result.push(path)}}if(!this.__current.path){return null}result=[];for(i=2,iz=this.__leavelist.length;i<iz;++i){element=this.__leavelist[i];addToPath(result,element.path)}addToPath(result,this.__current.path);return result};Controller.prototype.type=function(){var node=this.current();return node.type||this.__current.wrap};Controller.prototype.parents=function parents(){var i,iz,result;result=[];for(i=1,iz=this.__leavelist.length;i<iz;++i){result.push(this.__leavelist[i].node)}return result};Controller.prototype.current=function current(){return this.__current.node};Controller.prototype.__execute=function __execute(callback,element){var previous,result;result=undefined;previous=this.__current;this.__current=element;this.__state=null;if(callback){result=callback.call(this,element.node,this.__leavelist[this.__leavelist.length-1].node)}this.__current=previous;return result};Controller.prototype.notify=function notify(flag){this.__state=flag};Controller.prototype.skip=function(){this.notify(SKIP)};Controller.prototype["break"]=function(){this.notify(BREAK)};Controller.prototype.remove=function(){this.notify(REMOVE)};Controller.prototype.__initialize=function(root,visitor){this.visitor=visitor;this.root=root;this.__worklist=[];this.__leavelist=[];this.__current=null;this.__state=null;this.__fallback=visitor.fallback==="iteration";this.__keys=VisitorKeys;if(visitor.keys){this.__keys=extend(objectCreate(this.__keys),visitor.keys)}};function isNode(node){if(node==null){return false}return typeof node==="object"&&typeof node.type==="string"}function isProperty(nodeType,key){return(nodeType===Syntax.ObjectExpression||nodeType===Syntax.ObjectPattern)&&"properties"===key}Controller.prototype.traverse=function traverse(root,visitor){var worklist,leavelist,element,node,nodeType,ret,key,current,current2,candidates,candidate,sentinel;this.__initialize(root,visitor);sentinel={};worklist=this.__worklist;leavelist=this.__leavelist;worklist.push(new Element(root,null,null,null));leavelist.push(new Element(null,null,null,null));while(worklist.length){element=worklist.pop();if(element===sentinel){element=leavelist.pop();ret=this.__execute(visitor.leave,element);if(this.__state===BREAK||ret===BREAK){return}continue}if(element.node){ret=this.__execute(visitor.enter,element);if(this.__state===BREAK||ret===BREAK){return}worklist.push(sentinel);leavelist.push(element);if(this.__state===SKIP||ret===SKIP){continue}node=element.node;nodeType=element.wrap||node.type;candidates=this.__keys[nodeType];if(!candidates){if(this.__fallback){candidates=objectKeys(node)}else{throw new Error("Unknown node type "+nodeType+".")}}current=candidates.length;while((current-=1)>=0){key=candidates[current];candidate=node[key];if(!candidate){continue}if(isArray(candidate)){current2=candidate.length;while((current2-=1)>=0){if(!candidate[current2]){continue}if(isProperty(nodeType,candidates[current])){element=new Element(candidate[current2],[key,current2],"Property",null)}else if(isNode(candidate[current2])){element=new Element(candidate[current2],[key,current2],null,null)}else{continue}worklist.push(element)}}else if(isNode(candidate)){worklist.push(new Element(candidate,key,null,null))}}}}};Controller.prototype.replace=function replace(root,visitor){function removeElem(element){var i,key,nextElem,parent;if(element.ref.remove()){key=element.ref.key;parent=element.ref.parent;i=worklist.length;while(i--){nextElem=worklist[i];if(nextElem.ref&&nextElem.ref.parent===parent){if(nextElem.ref.key<key){break}--nextElem.ref.key}}}}var worklist,leavelist,node,nodeType,target,element,current,current2,candidates,candidate,sentinel,outer,key;this.__initialize(root,visitor);sentinel={};worklist=this.__worklist;leavelist=this.__leavelist;outer={root:root};element=new Element(root,null,null,new Reference(outer,"root"));worklist.push(element);leavelist.push(element);while(worklist.length){element=worklist.pop();if(element===sentinel){element=leavelist.pop();target=this.__execute(visitor.leave,element);if(target!==undefined&&target!==BREAK&&target!==SKIP&&target!==REMOVE){element.ref.replace(target)}if(this.__state===REMOVE||target===REMOVE){removeElem(element)}if(this.__state===BREAK||target===BREAK){return outer.root}continue}target=this.__execute(visitor.enter,element);if(target!==undefined&&target!==BREAK&&target!==SKIP&&target!==REMOVE){element.ref.replace(target);element.node=target}if(this.__state===REMOVE||target===REMOVE){removeElem(element);element.node=null}if(this.__state===BREAK||target===BREAK){return outer.root}node=element.node;if(!node){continue}worklist.push(sentinel);leavelist.push(element);if(this.__state===SKIP||target===SKIP){continue}nodeType=element.wrap||node.type;candidates=this.__keys[nodeType];if(!candidates){if(this.__fallback){candidates=objectKeys(node)}else{throw new Error("Unknown node type "+nodeType+".")}}current=candidates.length;while((current-=1)>=0){key=candidates[current];candidate=node[key];if(!candidate){continue}if(isArray(candidate)){current2=candidate.length;while((current2-=1)>=0){if(!candidate[current2]){continue}if(isProperty(nodeType,candidates[current])){element=new Element(candidate[current2],[key,current2],"Property",new Reference(candidate,current2))}else if(isNode(candidate[current2])){element=new Element(candidate[current2],[key,current2],null,new Reference(candidate,current2))}else{continue}worklist.push(element)}}else if(isNode(candidate)){worklist.push(new Element(candidate,key,null,new Reference(node,key)))}}}return outer.root};function traverse(root,visitor){var controller=new Controller;return controller.traverse(root,visitor)}function replace(root,visitor){var controller=new Controller;return controller.replace(root,visitor)}function extendCommentRange(comment,tokens){var target;target=upperBound(tokens,function search(token){return token.range[0]>comment.range[0]});comment.extendedRange=[comment.range[0],comment.range[1]];if(target!==tokens.length){comment.extendedRange[1]=tokens[target].range[0]}target-=1;if(target>=0){comment.extendedRange[0]=tokens[target].range[1]}return comment}function attachComments(tree,providedComments,tokens){var comments=[],comment,len,i,cursor;if(!tree.range){throw new Error("attachComments needs range information")}if(!tokens.length){if(providedComments.length){for(i=0,len=providedComments.length;i<len;i+=1){comment=deepCopy(providedComments[i]);comment.extendedRange=[0,tree.range[0]];comments.push(comment)}tree.leadingComments=comments}return tree}for(i=0,len=providedComments.length;i<len;i+=1){comments.push(extendCommentRange(deepCopy(providedComments[i]),tokens))}cursor=0;traverse(tree,{enter:function(node){var comment;while(cursor<comments.length){comment=comments[cursor];if(comment.extendedRange[1]>node.range[0]){break}if(comment.extendedRange[1]===node.range[0]){if(!node.leadingComments){node.leadingComments=[]}node.leadingComments.push(comment);comments.splice(cursor,1)}else{cursor+=1}}if(cursor===comments.length){return VisitorOption.Break}if(comments[cursor].extendedRange[0]>node.range[1]){return VisitorOption.Skip}}});cursor=0;traverse(tree,{leave:function(node){var comment;while(cursor<comments.length){comment=comments[cursor];if(node.range[1]<comment.extendedRange[0]){break}if(node.range[1]===comment.extendedRange[0]){if(!node.trailingComments){node.trailingComments=[]}node.trailingComments.push(comment);comments.splice(cursor,1)}else{cursor+=1}}if(cursor===comments.length){return VisitorOption.Break}if(comments[cursor].extendedRange[0]>node.range[1]){return VisitorOption.Skip}}});return tree}exports.version=require("./package.json").version;exports.Syntax=Syntax;exports.traverse=traverse;exports.replace=replace;exports.attachComments=attachComments;exports.VisitorKeys=VisitorKeys;exports.VisitorOption=VisitorOption;exports.Controller=Controller;exports.cloneEnvironment=function(){return clone({})};return exports})(exports)},{"./package.json":1}]},{},[]);require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({treeify:[function(require,module,exports){(function(root,factory){if(typeof exports==="object"){module.exports=factory()}else if(typeof define==="function"&&define.amd){define(factory)}else{root.treeify=factory()}})(this,function(){function makePrefix(key,last){var str=last?"└":"├";if(key){str+="─ "}else{str+="──┐"}return str}function filterKeys(obj,hideFunctions){var keys=[];for(var branch in obj){if(!obj.hasOwnProperty(branch)){continue}if(hideFunctions&&typeof obj[branch]==="function"){continue}keys.push(branch)}return keys}function growBranch(key,root,last,lastStates,showValues,hideFunctions,callback){var line="",index=0,lastKey,circular,lastStatesCopy=lastStates.slice(0);if(lastStatesCopy.push([root,last])&&lastStates.length>0){lastStates.forEach(function(lastState,idx){if(idx>0){line+=(lastState[1]?" ":"│")+" "}if(!circular&&lastState[0]===root){circular=true}});line+=makePrefix(key,last)+key;showValues&&typeof root!=="object"&&(line+=": "+root);circular&&(line+=" (circular ref.)");callback(line)}if(!circular&&typeof root==="object"){var keys=filterKeys(root,hideFunctions);keys.forEach(function(branch){lastKey=++index===keys.length;growBranch(branch,root[branch],lastKey,lastStatesCopy,showValues,hideFunctions,callback)})}}var Treeify={};Treeify.asLines=function(obj,showValues,hideFunctions,lineCallback){var hideFunctionsArg=typeof hideFunctions!=="function"?hideFunctions:false;growBranch(".",obj,false,[],showValues,hideFunctionsArg,lineCallback||hideFunctions)};Treeify.asTree=function(obj,showValues,hideFunctions){var tree="";growBranch(".",obj,false,[],showValues,hideFunctions,function(line){tree+=line+"\n"});return tree};return Treeify})},{}]},{},[]);var escope=require("escope");var esprima=require("esprima");var estraverse=require("estraverse");var treeify=require("treeify").asTree;var code="x.call()";var ast=esprima.parse(code);var scopeManager=escope.analyze(ast);var currentScope=scopeManager.acquire(ast);window.currentScope=currentScope;console.log(treeify(currentScope,true));console.log(treeify(ast,true));
{
"name": "requirebin-sketch",
"version": "1.0.0",
"dependencies": {
"escope": "1.0.3",
"esprima": "2.2.0",
"estraverse": "4.0.0",
"treeify": "1.0.1"
}
}
<!-- contents of this file will be placed inside the <body> -->
<!-- contents of this file will be placed inside the <head> -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment