Skip to content

Instantly share code, notes, and snippets.

@drom
Created August 12, 2015 03:35
Show Gist options
  • Save drom/0690853ea41453389bdb to your computer and use it in GitHub Desktop.
Save drom/0690853ea41453389bdb to your computer and use it in GitHub Desktop.
requirebin sketch
var esprima = require('esprima');
var res = {};
res.process = typeof process;
res.window = typeof window;
res.document = typeof document;
res.module = typeof module;
res.exports = typeof exports;
res.require = typeof require;
console.log(res);
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",ForOfStatement:"ForOfStatement",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",YieldExpression:"YieldExpression"};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",InvalidLHSInForLoop:"Invalid left-hand side in for-loop",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",IllegalYield:"Unexpected token yield",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",DuplicateBinding:"Duplicate binding %0"};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 astralSubstitute="￿",tmp=pattern;if(flags.indexOf("u")>=0){tmp=tmp.replace(/\\u\{([0-9a-fA-F]+)\}|\\u([a-fA-F0-9]{4})/g,function($0,$1,$2){var codePoint=parseInt($1||$2,16);if(codePoint>1114111){throwUnexpectedToken(null,Messages.InvalidRegExp)}if(codePoint<=65535){return String.fromCharCode(codePoint)}return astralSubstitute}).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,astralSubstitute)}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}}while(last&&last.range[0]>=this.range[0]){lastChild=bottomRight.pop();last=bottomRight[bottomRight.length-1]}if(lastChild){if(lastChild.leadingComments){leadingComments=[];for(i=lastChild.leadingComments.length-1;i>=0;--i){comment=lastChild.leadingComments[i];if(comment.range[1]<=this.range[0]){leadingComments.unshift(comment);lastChild.leadingComments.splice(i,1)}}if(!lastChild.leadingComments.length){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},finishForOfStatement:function(left,right,body){this.type=Syntax.ForOfStatement;this.left=left;this.right=right;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,generator){this.type=Syntax.FunctionDeclaration;this.id=id;this.params=params;this.defaults=defaults;this.body=body;this.generator=generator;this.expression=false;this.finish();return this},finishFunctionExpression:function(id,params,defaults,body,generator){this.type=Syntax.FunctionExpression;this.id=id;this.params=params;this.defaults=defaults;this.body=body;this.generator=generator;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},finishYieldExpression:function(argument,delegate){this.type=Syntax.YieldExpression;this.argument=argument;this.delegate=delegate;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(params){var node=new Node,elements=[],rest,restNode;expect("[");while(!match("]")){if(match(",")){lex();elements.push(null)}else{if(match("...")){restNode=new Node;lex();params.push(lookahead);rest=parseVariableIdentifier(params);elements.push(restNode.finishRestElement(rest));break}else{elements.push(parsePatternWithDefault(params))}if(!match("]")){expect(",")}}}expect("]");return node.finishArrayPattern(elements)}function parsePropertyPattern(params){var node=new Node,key,keyToken,computed=match("["),init;if(lookahead.type===Token.Identifier){keyToken=lookahead;key=parseVariableIdentifier();if(match("=")){params.push(keyToken);lex();init=parseAssignmentExpression();return node.finishProperty("init",key,false,new WrappingNode(keyToken).finishAssignmentPattern(key,init),false,false)}else if(!match(":")){params.push(keyToken);return node.finishProperty("init",key,false,key,false,true)}}else{key=parseObjectPropertyKey(params)}expect(":");init=parsePatternWithDefault(params);return node.finishProperty("init",key,computed,init,false,false)}function parseObjectPattern(params){var node=new Node,properties=[];expect("{");while(!match("}")){properties.push(parsePropertyPattern(params));if(!match("}")){expect(",")}}lex();return node.finishObjectPattern(properties)}function parsePattern(params){var identifier;if(lookahead.type===Token.Identifier){params.push(lookahead);identifier=parseVariableIdentifier();return identifier}else if(match("[")){return parseArrayPattern(params)}else if(match("{")){return parseObjectPattern(params)}throwUnexpectedToken(lookahead)}function parsePatternWithDefault(params){var startToken=lookahead,pattern,right;pattern=parsePattern(params);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,isGenerator){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,isGenerator)}function parsePropertyMethodFunction(){var params,method,node=new Node,previousAllowYield=state.allowYield;state.allowYield=false;params=parseParams();state.allowYield=previousAllowYield;state.allowYield=false;method=parsePropertyFunction(node,params,false);state.allowYield=previousAllowYield;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,params,previousAllowYield=state.allowYield;if(token.type===Token.Identifier){if(token.value==="get"&&lookaheadPropertyName()){computed=match("[");key=parseObjectPropertyKey();methodNode=new Node;expect("(");expect(")");state.allowYield=false;value=parsePropertyFunction(methodNode,{params:[],defaults:[],stricted:null,firstRestricted:null,message:null},false);state.allowYield=previousAllowYield;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{state.allowYield=false;parseParam(options);state.allowYield=previousAllowYield;if(options.defaultCount===0){options.defaults=[]}}expect(")");state.allowYield=false;value=parsePropertyFunction(methodNode,options,false);state.allowYield=previousAllowYield;return node.finishProperty("set",key,computed,value,false,false)}}else if(token.type===Token.Punctuator&&token.value==="*"&&lookaheadPropertyName()){computed=match("[");key=parseObjectPropertyKey();methodNode=new Node;state.allowYield=false;params=parseParams();state.allowYield=previousAllowYield;state.allowYield=true;value=parsePropertyFunction(methodNode,params,true);state.allowYield=previousAllowYield;return node.finishProperty("init",key,computed,value,true,false)}if(key&&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("[");if(match("*")){lex()}else{key=parseObjectPropertyKey()}maybeMethod=tryParseMethodDefinition(token,key,computed,node);if(maybeMethod){checkProto(maybeMethod.key,maybeMethod.computed,hasProto);return maybeMethod}if(!key){throwUnexpectedToken(lookahead)}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,params=[];expect("(");if(match(")")){lex();if(!match("=>")){expect("=>")}return{type:PlaceHolders.ArrowParameterPlaceHolder,params:[],rawParams:[]}}startToken=lookahead;if(match("...")){expr=parseRestElement(params);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(params));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=[],expr;expect("(");if(!match(")")){while(startIndex<length){if(match("...")){expr=new Node;lex();expr.finishSpreadElement(isolateCoverGrammar(parseAssignmentExpression))}else{expr=isolateCoverGrammar(parseAssignmentExpression)}args.push(expr);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 parseYieldExpression(){var argument,expr,delegate;expr=new Node;if(!state.allowYield){tolerateUnexpectedToken(lookahead,Messages.IllegalYield)}expectKeyword("yield");if(!hasLineTerminator){delegate=match("*");if(delegate){lex();argument=parseExpression()}else{if(!match(";")&&!match("}")&&lookahead.type!==Token.EOF){argument=parseExpression()}}}return expr.finishYieldExpression(argument,delegate)}function parseAssignmentExpression(){var token,expr,right,list,startToken;startToken=lookahead;token=lookahead;if(matchKeyword("yield")){return parseYieldExpression()}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,params=[];id=parsePattern(params);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,params=[];id=parsePattern(params);if(strict&&id.type===Syntax.Identifier&&isRestrictedWord(id.name)){tolerateError(Messages.StrictVarName)}if(kind==="const"){if(!matchKeyword("in")&&!matchContextualKeyword("of")){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(params){var param,node=new Node;lex();if(match("{")){throwError(Messages.ObjectPatternAsRestParameter)}params.push(lookahead);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,forIn,initSeq,initStartToken,test,update,left,right,kind,declarations,body,oldInIteration,previousAllowIn=state.allowIn;init=test=update=null;forIn=true;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 if(init.declarations.length===1&&init.declarations[0].init===null&&matchContextualKeyword("of")){lex();left=init;right=parseAssignmentExpression();init=null;forIn=false}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 if(declarations.length===1&&declarations[0].init===null&&matchContextualKeyword("of")){init=init.finishLexicalDeclaration(declarations,kind);lex();left=init;right=parseAssignmentExpression();init=null;forIn=false}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(matchContextualKeyword("of")){if(!isAssignmentTarget){tolerateError(Messages.InvalidLHSInForLoop)}lex();reinterpretExpressionAsPattern(init);left=init;right=parseAssignmentExpression();init=null;forIn=false}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):forIn?node.finishForInStatement(left,right,body):node.finishForOfStatement(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,params=[],paramMap={},key,i,body,node=new Node;expectKeyword("catch");expect("(");if(match(")")){throwUnexpectedToken(lookahead)}param=parsePattern(params);for(i=0;i<params.length;i++){key="$"+params[i].value;if(Object.prototype.hasOwnProperty.call(paramMap,key)){tolerateError(Messages.DuplicateBinding,params[i].value)}paramMap[key]=true}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.stricted=param;options.message=Messages.StrictParamDupe}}options.paramSet[key]=true}function parseParam(options){var token,param,params=[],i,def;token=lookahead;if(token.value==="..."){param=parseRestElement(params);validateParam(options,param.argument,param.argument.name);options.params.push(param);options.defaults.push(null);return false}param=parsePatternWithDefault(params);for(i=0;i<params.length;i++){validateParam(options,params[i],params[i].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,isGenerator,previousAllowYield;expectKeyword("function");isGenerator=match("*");if(isGenerator){lex()}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}}}previousAllowYield=state.allowYield;state.allowYield=false;tmp=parseParams(firstRestricted);state.allowYield=previousAllowYield;params=tmp.params;defaults=tmp.defaults;stricted=tmp.stricted;firstRestricted=tmp.firstRestricted;if(tmp.message){message=tmp.message}previousAllowYield=state.allowYield;previousStrict=strict;state.allowYield=isGenerator;body=parseFunctionSourceElements();if(strict&&firstRestricted){throwUnexpectedToken(firstRestricted,message)}if(strict&&stricted){tolerateUnexpectedToken(stricted,message)}strict=previousStrict;state.allowYield=previousAllowYield;return node.finishFunctionDeclaration(id,params,defaults,body,isGenerator)}function parseFunctionExpression(){var token,id=null,stricted,firstRestricted,message,tmp,params=[],defaults=[],body,previousStrict,node=new Node,isGenerator,previousAllowYield;expectKeyword("function");isGenerator=match("*");if(isGenerator){lex()}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}}}previousAllowYield=state.allowYield;state.allowYield=false;tmp=parseParams(firstRestricted);state.allowYield=previousAllowYield;params=tmp.params;defaults=tmp.defaults;stricted=tmp.stricted;firstRestricted=tmp.firstRestricted;if(tmp.message){message=tmp.message}previousStrict=strict;previousAllowYield=state.allowYield;state.allowYield=isGenerator;body=parseFunctionSourceElements();if(strict&&firstRestricted){throwUnexpectedToken(firstRestricted,message)}if(strict&&stricted){tolerateUnexpectedToken(stricted,message)}strict=previousStrict;state.allowYield=previousAllowYield;return node.finishFunctionExpression(id,params,defaults,body,isGenerator)}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("[");if(match("*")){lex()}else{key=parseObjectPropertyKey();if(key.name==="static"&&(lookaheadPropertyName()||match("*"))){token=lookahead;isStatic=true;computed=match("[");if(match("*")){lex()}else{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,allowYield:false,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,allowYield:false,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.4.1";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}();
})},{}]},{},[]);var esprima=require("esprima");var res={};res.process=typeof process;res.window=typeof window;res.document=typeof document;res.module=typeof module;res.exports=typeof exports;res.require=typeof require;console.log(res);
{
"name": "requirebin-sketch",
"version": "1.0.0",
"dependencies": {
"esprima": "2.4.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