Skip to content

Instantly share code, notes, and snippets.

@RReverser
Created July 29, 2014 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RReverser/7296e168e755c318609c to your computer and use it in GitHub Desktop.
Save RReverser/7296e168e755c318609c to your computer and use it in GitHub Desktop.
requirebin sketch
// just for RequireBin
console.log = function () {
var pre = document.createElement('pre');
pre.textContent = Array.prototype.map.call(arguments, function (arg) {
return typeof arg === 'object' ? JSON.stringify(arg, null, 2) : arg;
}).join(' ');
document.body.appendChild(pre);
};
var esprima = require('esprima-fb'), ast;
console.log('Version: ', esprima.version);
ast = esprima.parse('<div>x\r\ny</div>', {loc: true});
console.log(ast.body[0].expression.loc);
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);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.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}({wTON3q:[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,PropertyKind,Messages,Regex,SyntaxTreeDelegate,XHTMLEntities,ClassPropertyType,source,strict,index,lineNumber,lineStart,length,delegate,lookahead,state,extra;Token={BooleanLiteral:1,EOF:2,Identifier:3,Keyword:4,NullLiteral:5,NumericLiteral:6,Punctuator:7,StringLiteral:8,RegularExpression:9,Template:10,XJSIdentifier:11,XJSText:12};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.XJSIdentifier]="XJSIdentifier";TokenName[Token.XJSText]="XJSText";TokenName[Token.RegularExpression]="RegularExpression";FnExprTokens=["(","{","[","in","typeof","instanceof","new","return","case","delete","throw","void","=","+=","-=","*=","/=","%=","<<=",">>=",">>>=","&=","|=","^=",",","+","-","*","/","%","++","--","<<",">>",">>>","&","|","^","!","~","&&","||","?",":","===","==",">=","<=","<",">","!=","!=="];Syntax={ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AssignmentExpression:"AssignmentExpression",BinaryExpression:"BinaryExpression",BlockStatement:"BlockStatement",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ClassProperty:"ClassProperty",ComprehensionBlock:"ComprehensionBlock",ComprehensionExpression:"ComprehensionExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DebuggerStatement:"DebuggerStatement",DoWhileStatement:"DoWhileStatement",EmptyStatement:"EmptyStatement",ExportDeclaration:"ExportDeclaration",ExportBatchSpecifier:"ExportBatchSpecifier",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForInStatement:"ForInStatement",ForOfStatement:"ForOfStatement",ForStatement:"ForStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportDeclaration:"ImportDeclaration",ImportSpecifier:"ImportSpecifier",LabeledStatement:"LabeledStatement",Literal:"Literal",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MethodDefinition:"MethodDefinition",ModuleDeclaration:"ModuleDeclaration",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",ObjectTypeAnnotation:"ObjectTypeAnnotation",OptionalParameter:"OptionalParameter",ParametricTypeAnnotation:"ParametricTypeAnnotation",ParametricallyTypedIdentifier:"ParametricallyTypedIdentifier",Program:"Program",Property:"Property",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",SpreadProperty:"SpreadProperty",SwitchCase:"SwitchCase",SwitchStatement:"SwitchStatement",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",TypeAnnotatedIdentifier:"TypeAnnotatedIdentifier",TypeAnnotation:"TypeAnnotation",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",VoidTypeAnnotation:"VoidTypeAnnotation",WhileStatement:"WhileStatement",WithStatement:"WithStatement",XJSIdentifier:"XJSIdentifier",XJSNamespacedName:"XJSNamespacedName",XJSMemberExpression:"XJSMemberExpression",XJSEmptyExpression:"XJSEmptyExpression",XJSExpressionContainer:"XJSExpressionContainer",XJSElement:"XJSElement",XJSClosingElement:"XJSClosingElement",XJSOpeningElement:"XJSOpeningElement",XJSAttribute:"XJSAttribute",XJSSpreadAttribute:"XJSSpreadAttribute",XJSText:"XJSText",YieldExpression:"YieldExpression"};PropertyKind={Data:1,Get:2,Set:4};ClassPropertyType={"static":"static",prototype:"prototype"};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",InvalidLHSInFormalsList:"Invalid left-hand side in formals list",InvalidLHSInForIn:"Invalid left-hand side in for-in",MultipleDefaultsInSwitch:"More than one default clause in switch statement",NoCatchOrFinally:"Missing catch or finally after try",UnknownLabel:"Undefined label '%0'",Redeclaration:"%0 '%1' has already been declared",IllegalContinue:"Illegal continue statement",IllegalBreak:"Illegal break statement",IllegalDuplicateClassProperty:"Illegal duplicate property in class definition",IllegalReturn:"Illegal return statement",IllegalYield:"Illegal yield expression",IllegalSpread:"Illegal spread element",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",ParameterAfterRestParameter:"Rest parameter must be final parameter of an argument list",DefaultRestParameter:"Rest parameter can not have a default value",ElementAfterSpreadElement:"Spread must be the final element of an element list",PropertyAfterSpreadProperty:"A rest property must be the final property of an object literal",ObjectPatternAsRestParameter:"Invalid rest parameter",ObjectPatternAsSpread:"Invalid spread argument",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.",StrictDuplicateProperty:"Duplicate data property in object literal not allowed in strict mode",AccessorDataProperty:"Object literal may not have data and accessor property with the same name",AccessorGetSet:"Object literal may not have multiple get/set accessors with the same name",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",NewlineAfterModule:"Illegal newline after module",NoFromAfterImport:"Missing from after import",InvalidModuleSpecifier:"Invalid module specifier",NestedModule:"Module declaration can not be nested",NoUnintializedConst:"Const must be initialized",ComprehensionRequiresBlock:"Comprehension must have at least one block",ComprehensionError:"Comprehension Error",EachNotAllowed:"Each is not supported",InvalidXJSAttributeValue:"XJS value should be either an expression or a quoted XJS text",ExpectedXJSClosingTag:"Expected corresponding XJS closing tag for %0",AdjacentXJSElements:"Adjacent XJS elements must be wrapped in an enclosing tag"};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 isWhiteSpace(ch){return ch===32||ch===9||ch===11||ch===12||ch===160||ch>=5760&&" ᠎              ".indexOf(String.fromCharCode(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"class":case"enum":case"export":case"extends":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){if(strict&&isStrictModeReservedWord(id)){return true}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==="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 skipComment(){var ch,blockComment,lineComment;blockComment=false;lineComment=false;while(index<length){ch=source.charCodeAt(index);if(lineComment){++index;if(isLineTerminator(ch)){lineComment=false;if(ch===13&&source.charCodeAt(index)===10){++index}++lineNumber;lineStart=index}}else if(blockComment){if(isLineTerminator(ch)){if(ch===13&&source.charCodeAt(index+1)===10){++index}++lineNumber;++index;lineStart=index;if(index>=length){throwError({},Messages.UnexpectedToken,"ILLEGAL")}}else{ch=source.charCodeAt(index++);if(index>=length){throwError({},Messages.UnexpectedToken,"ILLEGAL")}if(ch===42){ch=source.charCodeAt(index);if(ch===47){++index;blockComment=false}}}}else if(ch===47){ch=source.charCodeAt(index+1);if(ch===47){index+=2;lineComment=true}else if(ch===42){index+=2;blockComment=true;if(index>=length){throwError({},Messages.UnexpectedToken,"ILLEGAL")}}else{break}}else if(isWhiteSpace(ch)){++index}else if(isLineTerminator(ch)){++index;if(ch===13&&source.charCodeAt(index)===10){++index}++lineNumber;lineStart=index}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==="}"){throwError({},Messages.UnexpectedToken,"ILLEGAL")}while(index<length){ch=source[index++];if(!isHexDigit(ch)){break}code=code*16+"0123456789abcdef".indexOf(ch.toLowerCase())}if(code>1114111||ch!=="}"){throwError({},Messages.UnexpectedToken,"ILLEGAL")}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){throwError({},Messages.UnexpectedToken,"ILLEGAL")}++index;ch=scanHexEscape("u");if(!ch||ch==="\\"||!isIdentifierStart(ch.charCodeAt(0))){throwError({},Messages.UnexpectedToken,"ILLEGAL")}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){throwError({},Messages.UnexpectedToken,"ILLEGAL")}++index;ch=scanHexEscape("u");if(!ch||ch==="\\"||!isIdentifierPart(ch.charCodeAt(0))){throwError({},Messages.UnexpectedToken,"ILLEGAL")}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,range:[start,index]}}function scanPunctuator(){var start=index,code=source.charCodeAt(index),code2,ch1=source[index],ch2,ch3,ch4;switch(code){case 40:case 41:case 59:case 44:case 123:case 125:case 91:case 93:case 58:case 63:case 126:++index;if(extra.tokenize){if(code===40){extra.openParenToken=extra.tokens.length}else if(code===123){extra.openCurlyToken=extra.tokens.length}}return{type:Token.Punctuator,value:String.fromCharCode(code),lineNumber:lineNumber,lineStart:lineStart,range:[start,index]};default:code2=source.charCodeAt(index+1);if(code2===61){switch(code){case 37:case 38:case 42:case 43:case 45:case 47:case 60:case 62:case 94:case 124:index+=2;return{type:Token.Punctuator,value:String.fromCharCode(code)+String.fromCharCode(code2),lineNumber:lineNumber,lineStart:lineStart,range:[start,index]};case 33:case 61:index+=2;if(source.charCodeAt(index)===61){++index}return{type:Token.Punctuator,value:source.slice(start,index),lineNumber:lineNumber,lineStart:lineStart,range:[start,index]};default:break}}break}ch2=source[index+1];ch3=source[index+2];ch4=source[index+3];if(ch1===">"&&ch2===">"&&ch3===">"){if(ch4==="="){index+=4;return{type:Token.Punctuator,value:">>>=",lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}}if(ch1===">"&&ch2===">"&&ch3===">"){index+=3;return{type:Token.Punctuator,value:">>>",lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(ch1==="<"&&ch2==="<"&&ch3==="="){index+=3;return{type:Token.Punctuator,value:"<<=",lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(ch1===">"&&ch2===">"&&ch3==="="){index+=3;return{type:Token.Punctuator,value:">>=",lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(ch1==="."&&ch2==="."&&ch3==="."){index+=3;return{type:Token.Punctuator,value:"...",lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(ch1===ch2&&"+-<>&|".indexOf(ch1)>=0){index+=2;return{type:Token.Punctuator,value:ch1+ch2,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(ch1==="="&&ch2===">"){index+=2;return{type:Token.Punctuator,value:"=>",lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if("<>=!+-*%&|^/".indexOf(ch1)>=0){++index;return{type:Token.Punctuator,value:ch1,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(ch1==="."){++index;return{type:Token.Punctuator,value:ch1,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}throwError({},Messages.UnexpectedToken,"ILLEGAL")}function scanHexLiteral(start){var number="";while(index<length){if(!isHexDigit(source[index])){break}number+=source[index++]}if(number.length===0){throwError({},Messages.UnexpectedToken,"ILLEGAL")}if(isIdentifierStart(source.charCodeAt(index))){throwError({},Messages.UnexpectedToken,"ILLEGAL")}return{type:Token.NumericLiteral,value:parseInt("0x"+number,16),lineNumber:lineNumber,lineStart:lineStart,range:[start,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){throwError({},Messages.UnexpectedToken,"ILLEGAL")}if(isIdentifierStart(source.charCodeAt(index))||isDecimalDigit(source.charCodeAt(index))){throwError({},Messages.UnexpectedToken,"ILLEGAL")}return{type:Token.NumericLiteral,value:parseInt(number,8),octal:octal,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}function scanNumericLiteral(){var number,start,ch,octal;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;number="";while(index<length){ch=source[index];if(ch!=="0"&&ch!=="1"){break}number+=source[index++]}if(number.length===0){throwError({},Messages.UnexpectedToken,"ILLEGAL")}if(index<length){ch=source.charCodeAt(index);if(isIdentifierStart(ch)||isDecimalDigit(ch)){throwError({},Messages.UnexpectedToken,"ILLEGAL")}}return{type:Token.NumericLiteral,value:parseInt(number,2),lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(ch==="o"||ch==="O"||isOctalDigit(ch)){return scanOctalLiteral(ch,start)}if(ch&&isDecimalDigit(ch.charCodeAt(0))){throwError({},Messages.UnexpectedToken,"ILLEGAL")}}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{throwError({},Messages.UnexpectedToken,"ILLEGAL")}}if(isIdentifierStart(source.charCodeAt(index))){throwError({},Messages.UnexpectedToken,"ILLEGAL")}return{type:Token.NumericLiteral,value:parseFloat(number),lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}function scanStringLiteral(){var str="",quote,start,ch,code,unescaped,restore,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"n":str+="\n";break;case"r":str+="\r";break;case"t":str+=" ";break;case"u":case"x":if(source[index]==="{"){++index;str+=scanUnicodeCodePointEscape()}else{restore=index;unescaped=scanHexEscape(ch);if(unescaped){str+=unescaped}else{index=restore;str+=ch}}break;case"b":str+="\b";break;case"f":str+="\f";break;case"v":str+=" ";break;default:if(isOctalDigit(ch)){code="01234567".indexOf(ch);if(code!==0){octal=true}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++])}}str+=String.fromCharCode(code)}else{str+=ch}break}}else{++lineNumber;if(ch==="\r"&&source[index]==="\n"){++index}}}else if(isLineTerminator(ch.charCodeAt(0))){break}else{str+=ch}}if(quote!==""){throwError({},Messages.UnexpectedToken,"ILLEGAL")}return{type:Token.StringLiteral,value:str,octal:octal,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}function scanTemplate(){var cooked="",ch,start,terminated,tail,restore,unescaped,code,octal;terminated=false;tail=false;start=index;++index;while(index<length){ch=source[index++];if(ch==="`"){tail=true;terminated=true;break}else if(ch==="$"){if(source[index]==="{"){++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(isOctalDigit(ch)){code="01234567".indexOf(ch);if(code!==0){octal=true}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++])}}cooked+=String.fromCharCode(code)}else{cooked+=ch}break}}else{++lineNumber;if(ch==="\r"&&source[index]==="\n"){++index}}}else if(isLineTerminator(ch.charCodeAt(0))){++lineNumber;if(ch==="\r"&&source[index]==="\n"){++index}cooked+="\n"}else{cooked+=ch}}if(!terminated){throwError({},Messages.UnexpectedToken,"ILLEGAL")}return{type:Token.Template,value:{cooked:cooked,raw:source.slice(start+1,index-(tail?1:2))},tail:tail,octal:octal,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}function scanTemplateElement(option){var startsWith,template;lookahead=null;skipComment();startsWith=option.head?"`":"}";if(source[index]!==startsWith){throwError({},Messages.UnexpectedToken,"ILLEGAL")}template=scanTemplate();peek();return template}function scanRegExp(){var str,ch,start,pattern,flags,value,classMarker=false,restore,terminated=false;lookahead=null;skipComment();start=index;ch=source[index];assert(ch==="/","Regular expression literal must start with a slash");str=source[index++];while(index<length){ch=source[index++];str+=ch;if(classMarker){if(ch==="]"){classMarker=false}}else{if(ch==="\\"){ch=source[index++];if(isLineTerminator(ch.charCodeAt(0))){throwError({},Messages.UnterminatedRegExp)}str+=ch}else if(ch==="/"){terminated=true;break}else if(ch==="["){classMarker=true}else if(isLineTerminator(ch.charCodeAt(0))){throwError({},Messages.UnterminatedRegExp)}}}if(!terminated){throwError({},Messages.UnterminatedRegExp)}pattern=str.substr(1,str.length-2);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"}}else{str+="\\"}}else{flags+=ch;str+=ch}}try{value=new RegExp(pattern,flags)}catch(e){throwError({},Messages.InvalidRegExp)}peek();if(extra.tokenize){return{type:Token.RegularExpression,value:value,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}return{literal:str,value:value,range:[start,index]}}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 scanRegExp()}if(prevToken.type==="Punctuator"){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 scanRegExp()}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 scanRegExp()}}else{return scanPunctuator()}if(FnExprTokens.indexOf(checkToken.value)>=0){return scanPunctuator()}return scanRegExp()}return scanRegExp()}if(prevToken.type==="Keyword"){return scanRegExp()}return scanPunctuator()}function advance(){var ch;if(!state.inXJSChild){skipComment()}if(index>=length){return{type:Token.EOF,lineNumber:lineNumber,lineStart:lineStart,range:[index,index]}}if(state.inXJSChild){return advanceXJSChild()}ch=source.charCodeAt(index);if(ch===40||ch===41||ch===58){return scanPunctuator()}if(ch===39||ch===34){if(state.inXJSTag){return scanXJSStringLiteral()}return scanStringLiteral()}if(state.inXJSTag&&isXJSIdentifierStart(ch)){return scanXJSIdentifier()}if(ch===96){return scanTemplate()}if(isIdentifierStart(ch)){return scanIdentifier()}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()}return scanPunctuator()}function lex(){var token;token=lookahead;index=token.range[1];lineNumber=token.lineNumber;lineStart=token.lineStart;lookahead=advance();index=token.range[1];lineNumber=token.lineNumber;lineStart=token.lineStart;return token}function peek(){var pos,line,start;pos=index;line=lineNumber;start=lineStart;lookahead=advance();index=pos;lineNumber=line;lineStart=start}function lookahead2(){var adv,pos,line,start,result;adv=typeof extra.advance==="function"?extra.advance:advance;pos=index;line=lineNumber;start=lineStart;if(lookahead===null){lookahead=adv()}index=lookahead.range[1];lineNumber=lookahead.lineNumber;lineStart=lookahead.lineStart;result=adv();index=pos;lineNumber=line;lineStart=start;return result}function markerCreate(){if(!extra.loc&&!extra.range){return undefined}skipComment();return{offset:index,line:lineNumber,col:index-lineStart}}function markerCreatePreserveWhitespace(){if(!extra.loc&&!extra.range){return undefined}return{offset:index,line:lineNumber,col:index-lineStart}}function markerApply(marker,node){if(extra.range){node.range=[marker.offset,index]}if(extra.loc){node.loc={start:{line:marker.line,column:marker.col},end:{line:lineNumber,column:index-lineStart}};node=delegate.postProcess(node)}return node}SyntaxTreeDelegate={name:"SyntaxTree",postProcess:function(node){return node},createArrayExpression:function(elements){return{type:Syntax.ArrayExpression,elements:elements}},createAssignmentExpression:function(operator,left,right){return{type:Syntax.AssignmentExpression,operator:operator,left:left,right:right}},createBinaryExpression:function(operator,left,right){var type=operator==="||"||operator==="&&"?Syntax.LogicalExpression:Syntax.BinaryExpression;return{type:type,operator:operator,left:left,right:right}},createBlockStatement:function(body){return{type:Syntax.BlockStatement,body:body}},createBreakStatement:function(label){return{type:Syntax.BreakStatement,label:label}},createCallExpression:function(callee,args){return{type:Syntax.CallExpression,callee:callee,arguments:args}},createCatchClause:function(param,body){return{type:Syntax.CatchClause,param:param,body:body}},createConditionalExpression:function(test,consequent,alternate){return{type:Syntax.ConditionalExpression,test:test,consequent:consequent,alternate:alternate}},createContinueStatement:function(label){return{type:Syntax.ContinueStatement,label:label}},createDebuggerStatement:function(){return{type:Syntax.DebuggerStatement}},createDoWhileStatement:function(body,test){return{type:Syntax.DoWhileStatement,body:body,test:test}},createEmptyStatement:function(){return{type:Syntax.EmptyStatement}},createExpressionStatement:function(expression){return{type:Syntax.ExpressionStatement,expression:expression}},createForStatement:function(init,test,update,body){return{type:Syntax.ForStatement,init:init,test:test,update:update,body:body}},createForInStatement:function(left,right,body){return{type:Syntax.ForInStatement,left:left,right:right,body:body,each:false}},createForOfStatement:function(left,right,body){return{type:Syntax.ForOfStatement,left:left,right:right,body:body}},createFunctionDeclaration:function(id,params,defaults,body,rest,generator,expression,returnType,parametricType){return{type:Syntax.FunctionDeclaration,id:id,params:params,defaults:defaults,body:body,rest:rest,generator:generator,expression:expression,returnType:returnType,parametricType:parametricType}},createFunctionExpression:function(id,params,defaults,body,rest,generator,expression,returnType,parametricType){return{type:Syntax.FunctionExpression,id:id,params:params,defaults:defaults,body:body,rest:rest,generator:generator,expression:expression,returnType:returnType,parametricType:parametricType}},createIdentifier:function(name){return{type:Syntax.Identifier,name:name,typeAnnotation:undefined}},createTypeAnnotation:function(typeIdentifier,parametricType,params,returnType,nullable){return{type:Syntax.TypeAnnotation,id:typeIdentifier,parametricType:parametricType,params:params,returnType:returnType,nullable:nullable}},createParametricTypeAnnotation:function(parametricTypes){return{type:Syntax.ParametricTypeAnnotation,params:parametricTypes}},createVoidTypeAnnotation:function(){return{type:Syntax.VoidTypeAnnotation}},createObjectTypeAnnotation:function(properties){return{type:Syntax.ObjectTypeAnnotation,properties:properties}},createTypeAnnotatedIdentifier:function(identifier,annotation,isOptionalParam){return{type:Syntax.TypeAnnotatedIdentifier,id:identifier,annotation:annotation}},createOptionalParameter:function(identifier){return{type:Syntax.OptionalParameter,id:identifier}},createXJSAttribute:function(name,value){return{type:Syntax.XJSAttribute,name:name,value:value}},createXJSSpreadAttribute:function(argument){return{type:Syntax.XJSSpreadAttribute,argument:argument}},createXJSIdentifier:function(name){return{type:Syntax.XJSIdentifier,name:name}
},createXJSNamespacedName:function(namespace,name){return{type:Syntax.XJSNamespacedName,namespace:namespace,name:name}},createXJSMemberExpression:function(object,property){return{type:Syntax.XJSMemberExpression,object:object,property:property}},createXJSElement:function(openingElement,closingElement,children){return{type:Syntax.XJSElement,openingElement:openingElement,closingElement:closingElement,children:children}},createXJSEmptyExpression:function(){return{type:Syntax.XJSEmptyExpression}},createXJSExpressionContainer:function(expression){return{type:Syntax.XJSExpressionContainer,expression:expression}},createXJSOpeningElement:function(name,attributes,selfClosing){return{type:Syntax.XJSOpeningElement,name:name,selfClosing:selfClosing,attributes:attributes}},createXJSClosingElement:function(name){return{type:Syntax.XJSClosingElement,name:name}},createIfStatement:function(test,consequent,alternate){return{type:Syntax.IfStatement,test:test,consequent:consequent,alternate:alternate}},createLabeledStatement:function(label,body){return{type:Syntax.LabeledStatement,label:label,body:body}},createLiteral:function(token){return{type:Syntax.Literal,value:token.value,raw:source.slice(token.range[0],token.range[1])}},createMemberExpression:function(accessor,object,property){return{type:Syntax.MemberExpression,computed:accessor==="[",object:object,property:property}},createNewExpression:function(callee,args){return{type:Syntax.NewExpression,callee:callee,arguments:args}},createObjectExpression:function(properties){return{type:Syntax.ObjectExpression,properties:properties}},createPostfixExpression:function(operator,argument){return{type:Syntax.UpdateExpression,operator:operator,argument:argument,prefix:false}},createProgram:function(body){return{type:Syntax.Program,body:body}},createProperty:function(kind,key,value,method,shorthand,computed){return{type:Syntax.Property,key:key,value:value,kind:kind,method:method,shorthand:shorthand,computed:computed}},createReturnStatement:function(argument){return{type:Syntax.ReturnStatement,argument:argument}},createSequenceExpression:function(expressions){return{type:Syntax.SequenceExpression,expressions:expressions}},createSwitchCase:function(test,consequent){return{type:Syntax.SwitchCase,test:test,consequent:consequent}},createSwitchStatement:function(discriminant,cases){return{type:Syntax.SwitchStatement,discriminant:discriminant,cases:cases}},createThisExpression:function(){return{type:Syntax.ThisExpression}},createThrowStatement:function(argument){return{type:Syntax.ThrowStatement,argument:argument}},createTryStatement:function(block,guardedHandlers,handlers,finalizer){return{type:Syntax.TryStatement,block:block,guardedHandlers:guardedHandlers,handlers:handlers,finalizer:finalizer}},createUnaryExpression:function(operator,argument){if(operator==="++"||operator==="--"){return{type:Syntax.UpdateExpression,operator:operator,argument:argument,prefix:true}}return{type:Syntax.UnaryExpression,operator:operator,argument:argument,prefix:true}},createVariableDeclaration:function(declarations,kind){return{type:Syntax.VariableDeclaration,declarations:declarations,kind:kind}},createVariableDeclarator:function(id,init){return{type:Syntax.VariableDeclarator,id:id,init:init}},createWhileStatement:function(test,body){return{type:Syntax.WhileStatement,test:test,body:body}},createWithStatement:function(object,body){return{type:Syntax.WithStatement,object:object,body:body}},createTemplateElement:function(value,tail){return{type:Syntax.TemplateElement,value:value,tail:tail}},createTemplateLiteral:function(quasis,expressions){return{type:Syntax.TemplateLiteral,quasis:quasis,expressions:expressions}},createSpreadElement:function(argument){return{type:Syntax.SpreadElement,argument:argument}},createSpreadProperty:function(argument){return{type:Syntax.SpreadProperty,argument:argument}},createTaggedTemplateExpression:function(tag,quasi){return{type:Syntax.TaggedTemplateExpression,tag:tag,quasi:quasi}},createArrowFunctionExpression:function(params,defaults,body,rest,expression){return{type:Syntax.ArrowFunctionExpression,id:null,params:params,defaults:defaults,body:body,rest:rest,generator:false,expression:expression}},createMethodDefinition:function(propertyType,kind,key,value){return{type:Syntax.MethodDefinition,key:key,value:value,kind:kind,"static":propertyType===ClassPropertyType.static}},createClassProperty:function(propertyIdentifier){return{type:Syntax.ClassProperty,id:propertyIdentifier}},createClassBody:function(body){return{type:Syntax.ClassBody,body:body}},createClassExpression:function(id,superClass,body,parametricType){return{type:Syntax.ClassExpression,id:id,superClass:superClass,body:body,parametricType:parametricType}},createClassDeclaration:function(id,superClass,body,parametricType,superParametricType){return{type:Syntax.ClassDeclaration,id:id,superClass:superClass,body:body,parametricType:parametricType,superParametricType:superParametricType}},createExportSpecifier:function(id,name){return{type:Syntax.ExportSpecifier,id:id,name:name}},createExportBatchSpecifier:function(){return{type:Syntax.ExportBatchSpecifier}},createExportDeclaration:function(declaration,specifiers,source){return{type:Syntax.ExportDeclaration,declaration:declaration,specifiers:specifiers,source:source}},createImportSpecifier:function(id,name){return{type:Syntax.ImportSpecifier,id:id,name:name}},createImportDeclaration:function(specifiers,kind,source){return{type:Syntax.ImportDeclaration,specifiers:specifiers,kind:kind,source:source}},createYieldExpression:function(argument,delegate){return{type:Syntax.YieldExpression,argument:argument,delegate:delegate}},createModuleDeclaration:function(id,source,body){return{type:Syntax.ModuleDeclaration,id:id,source:source,body:body}},createComprehensionExpression:function(filter,blocks,body){return{type:Syntax.ComprehensionExpression,filter:filter,blocks:blocks,body:body}}};function peekLineTerminator(){var pos,line,start,found;pos=index;line=lineNumber;start=lineStart;skipComment();found=lineNumber!==line;index=pos;lineNumber=line;lineStart=start;return found}function throwError(token,messageFormat){var error,args=Array.prototype.slice.call(arguments,2),msg=messageFormat.replace(/%(\d)/g,function(whole,index){assert(index<args.length,"Message reference must be in range");return args[index]});if(typeof token.lineNumber==="number"){error=new Error("Line "+token.lineNumber+": "+msg);error.index=token.range[0];error.lineNumber=token.lineNumber;error.column=token.range[0]-lineStart+1}else{error=new Error("Line "+lineNumber+": "+msg);error.index=index;error.lineNumber=lineNumber;error.column=index-lineStart+1}error.description=msg;throw error}function throwErrorTolerant(){try{throwError.apply(null,arguments)}catch(e){if(extra.errors){extra.errors.push(e)}else{throw e}}}function throwUnexpected(token){if(token.type===Token.EOF){throwError(token,Messages.UnexpectedEOS)}if(token.type===Token.NumericLiteral){throwError(token,Messages.UnexpectedNumber)}if(token.type===Token.StringLiteral||token.type===Token.XJSText){throwError(token,Messages.UnexpectedString)}if(token.type===Token.Identifier){throwError(token,Messages.UnexpectedIdentifier)}if(token.type===Token.Keyword){if(isFutureReservedWord(token.value)){throwError(token,Messages.UnexpectedReserved)}else if(strict&&isStrictModeReservedWord(token.value)){throwErrorTolerant(token,Messages.StrictReservedWord);return}throwError(token,Messages.UnexpectedToken,token.value)}if(token.type===Token.Template){throwError(token,Messages.UnexpectedTemplate,token.value.raw)}throwError(token,Messages.UnexpectedToken,token.value)}function expect(value){var token=lex();if(token.type!==Token.Punctuator||token.value!==value){throwUnexpected(token)}}function expectKeyword(keyword){var token=lex();if(token.type!==Token.Keyword||token.value!==keyword){throwUnexpected(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(){var line;if(source.charCodeAt(index)===59){lex();return}line=lineNumber;skipComment();if(lineNumber!==line){return}if(match(";")){lex();return}if(lookahead.type!==Token.EOF&&!match("}")){throwUnexpected(lookahead)}}function isLeftHandSide(expr){return expr.type===Syntax.Identifier||expr.type===Syntax.MemberExpression}function isAssignableLeftHandSide(expr){return isLeftHandSide(expr)||expr.type===Syntax.ObjectPattern||expr.type===Syntax.ArrayPattern}function parseArrayInitialiser(){var elements=[],blocks=[],filter=null,tmp,possiblecomprehension=true,body,marker=markerCreate();expect("[");while(!match("]")){if(lookahead.value==="for"&&lookahead.type===Token.Keyword){if(!possiblecomprehension){throwError({},Messages.ComprehensionError)}matchKeyword("for");tmp=parseForStatement({ignoreBody:true});tmp.of=tmp.type===Syntax.ForOfStatement;tmp.type=Syntax.ComprehensionBlock;if(tmp.left.kind){throwError({},Messages.ComprehensionError)}blocks.push(tmp)}else if(lookahead.value==="if"&&lookahead.type===Token.Keyword){if(!possiblecomprehension){throwError({},Messages.ComprehensionError)}expectKeyword("if");expect("(");filter=parseExpression();expect(")")}else if(lookahead.value===","&&lookahead.type===Token.Punctuator){possiblecomprehension=false;lex();elements.push(null)}else{tmp=parseSpreadOrAssignmentExpression();elements.push(tmp);if(tmp&&tmp.type===Syntax.SpreadElement){if(!match("]")){throwError({},Messages.ElementAfterSpreadElement)}}else if(!(match("]")||matchKeyword("for")||matchKeyword("if"))){expect(",");possiblecomprehension=false}}}expect("]");if(filter&&!blocks.length){throwError({},Messages.ComprehensionRequiresBlock)}if(blocks.length){if(elements.length!==1){throwError({},Messages.ComprehensionError)}return markerApply(marker,delegate.createComprehensionExpression(filter,blocks,elements[0]))}return markerApply(marker,delegate.createArrayExpression(elements))}function parsePropertyFunction(options){var previousStrict,previousYieldAllowed,params,defaults,body,marker=markerCreate();previousStrict=strict;previousYieldAllowed=state.yieldAllowed;state.yieldAllowed=options.generator;params=options.params||[];defaults=options.defaults||[];body=parseConciseBody();if(options.name&&strict&&isRestrictedWord(params[0].name)){throwErrorTolerant(options.name,Messages.StrictParamName)}strict=previousStrict;state.yieldAllowed=previousYieldAllowed;return markerApply(marker,delegate.createFunctionExpression(null,params,defaults,body,options.rest||null,options.generator,body.type!==Syntax.BlockStatement,options.returnType,options.parametricType))}function parsePropertyMethodFunction(options){var previousStrict,tmp,method;previousStrict=strict;strict=true;tmp=parseParams();if(tmp.stricted){throwErrorTolerant(tmp.stricted,tmp.message)}method=parsePropertyFunction({params:tmp.params,defaults:tmp.defaults,rest:tmp.rest,generator:options.generator,returnType:tmp.returnType,parametricType:options.parametricType});strict=previousStrict;return method}function parseObjectPropertyKey(){var marker=markerCreate(),token=lex(),propertyKey,result;if(token.type===Token.StringLiteral||token.type===Token.NumericLiteral){if(strict&&token.octal){throwErrorTolerant(token,Messages.StrictOctalLiteral)}return markerApply(marker,delegate.createLiteral(token))}if(token.type===Token.Punctuator&&token.value==="["){marker=markerCreate();propertyKey=parseAssignmentExpression();result=markerApply(marker,propertyKey);expect("]");return result}return markerApply(marker,delegate.createIdentifier(token.value))}function parseObjectProperty(){var token,key,id,value,param,expr,computed,marker=markerCreate();token=lookahead;computed=token.value==="[";if(token.type===Token.Identifier||computed){id=parseObjectPropertyKey();if(token.value==="get"&&!(match(":")||match("("))){computed=lookahead.value==="[";key=parseObjectPropertyKey();expect("(");expect(")");return markerApply(marker,delegate.createProperty("get",key,parsePropertyFunction({generator:false}),false,false,computed))}if(token.value==="set"&&!(match(":")||match("("))){computed=lookahead.value==="[";key=parseObjectPropertyKey();expect("(");token=lookahead;param=[parseTypeAnnotatableIdentifier()];expect(")");return markerApply(marker,delegate.createProperty("set",key,parsePropertyFunction({params:param,generator:false,name:token}),false,false,computed))}if(match(":")){lex();return markerApply(marker,delegate.createProperty("init",id,parseAssignmentExpression(),false,false,computed))}if(match("(")){return markerApply(marker,delegate.createProperty("init",id,parsePropertyMethodFunction({generator:false}),true,false,computed))}if(computed){throwUnexpected(lookahead)}return markerApply(marker,delegate.createProperty("init",id,id,false,true,false))}if(token.type===Token.EOF||token.type===Token.Punctuator){if(!match("*")){throwUnexpected(token)}lex();computed=lookahead.type===Token.Punctuator&&lookahead.value==="[";id=parseObjectPropertyKey();if(!match("(")){throwUnexpected(lex())}return markerApply(marker,delegate.createProperty("init",id,parsePropertyMethodFunction({generator:true}),true,false,computed))}key=parseObjectPropertyKey();if(match(":")){lex();return markerApply(marker,delegate.createProperty("init",key,parseAssignmentExpression(),false,false,false))}if(match("(")){return markerApply(marker,delegate.createProperty("init",key,parsePropertyMethodFunction({generator:false}),true,false,false))}throwUnexpected(lex())}function parseObjectSpreadProperty(){var marker=markerCreate();expect("...");return markerApply(marker,delegate.createSpreadProperty(parseAssignmentExpression()))}function parseObjectInitialiser(){var properties=[],property,name,key,kind,map={},toString=String,marker=markerCreate();expect("{");while(!match("}")){if(match("...")){property=parseObjectSpreadProperty()}else{property=parseObjectProperty();if(property.key.type===Syntax.Identifier){name=property.key.name}else{name=toString(property.key.value)}kind=property.kind==="init"?PropertyKind.Data:property.kind==="get"?PropertyKind.Get:PropertyKind.Set;key="$"+name;if(Object.prototype.hasOwnProperty.call(map,key)){if(map[key]===PropertyKind.Data){if(strict&&kind===PropertyKind.Data){throwErrorTolerant({},Messages.StrictDuplicateProperty)}else if(kind!==PropertyKind.Data){throwErrorTolerant({},Messages.AccessorDataProperty)}}else{if(kind===PropertyKind.Data){throwErrorTolerant({},Messages.AccessorDataProperty)}else if(map[key]&kind){throwErrorTolerant({},Messages.AccessorGetSet)}}map[key]|=kind}else{map[key]=kind}}properties.push(property);if(!match("}")){expect(",")}}expect("}");return markerApply(marker,delegate.createObjectExpression(properties))}function parseTemplateElement(option){var marker=markerCreate(),token=scanTemplateElement(option);if(strict&&token.octal){throwError(token,Messages.StrictOctalLiteral)}return markerApply(marker,delegate.createTemplateElement({raw:token.value.raw,cooked:token.value.cooked},token.tail))}function parseTemplateLiteral(){var quasi,quasis,expressions,marker=markerCreate();quasi=parseTemplateElement({head:true});quasis=[quasi];expressions=[];while(!quasi.tail){expressions.push(parseExpression());quasi=parseTemplateElement({head:false});quasis.push(quasi)}return markerApply(marker,delegate.createTemplateLiteral(quasis,expressions))}function parseGroupExpression(){var expr;expect("(");++state.parenthesizedCount;expr=parseExpression();expect(")");return expr}function parsePrimaryExpression(){var marker,type,token,expr;type=lookahead.type;if(type===Token.Identifier){marker=markerCreate();return markerApply(marker,delegate.createIdentifier(lex().value))}if(type===Token.StringLiteral||type===Token.NumericLiteral){if(strict&&lookahead.octal){throwErrorTolerant(lookahead,Messages.StrictOctalLiteral)}marker=markerCreate();return markerApply(marker,delegate.createLiteral(lex()))}if(type===Token.Keyword){if(matchKeyword("this")){marker=markerCreate();lex();return markerApply(marker,delegate.createThisExpression())}if(matchKeyword("function")){return parseFunctionExpression()}if(matchKeyword("class")){return parseClassExpression()}if(matchKeyword("super")){marker=markerCreate();lex();return markerApply(marker,delegate.createIdentifier("super"))}}if(type===Token.BooleanLiteral){marker=markerCreate();token=lex();token.value=token.value==="true";return markerApply(marker,delegate.createLiteral(token))}if(type===Token.NullLiteral){marker=markerCreate();token=lex();token.value=null;return markerApply(marker,delegate.createLiteral(token))}if(match("[")){return parseArrayInitialiser()}if(match("{")){return parseObjectInitialiser()}if(match("(")){return parseGroupExpression()}if(match("/")||match("/=")){marker=markerCreate();return markerApply(marker,delegate.createLiteral(scanRegExp()))}if(type===Token.Template){return parseTemplateLiteral()}if(match("<")){return parseXJSElement()}throwUnexpected(lex())}function parseArguments(){var args=[],arg;expect("(");if(!match(")")){while(index<length){arg=parseSpreadOrAssignmentExpression();args.push(arg);if(match(")")){break}else if(arg.type===Syntax.SpreadElement){throwError({},Messages.ElementAfterSpreadElement)}expect(",")}}expect(")");return args}function parseSpreadOrAssignmentExpression(){if(match("...")){var marker=markerCreate();lex();return markerApply(marker,delegate.createSpreadElement(parseAssignmentExpression()))}return parseAssignmentExpression()}function parseNonComputedProperty(){var marker=markerCreate(),token=lex();if(!isIdentifierName(token)){throwUnexpected(token)}return markerApply(marker,delegate.createIdentifier(token.value))}function parseNonComputedMember(){expect(".");return parseNonComputedProperty()}function parseComputedMember(){var expr;expect("[");expr=parseExpression();expect("]");return expr}function parseNewExpression(){var callee,args,marker=markerCreate();expectKeyword("new");callee=parseLeftHandSideExpression();args=match("(")?parseArguments():[];return markerApply(marker,delegate.createNewExpression(callee,args))}function parseLeftHandSideExpressionAllowCall(){var expr,args,marker=markerCreate();expr=matchKeyword("new")?parseNewExpression():parsePrimaryExpression();while(match(".")||match("[")||match("(")||lookahead.type===Token.Template){if(match("(")){args=parseArguments();expr=markerApply(marker,delegate.createCallExpression(expr,args))}else if(match("[")){expr=markerApply(marker,delegate.createMemberExpression("[",expr,parseComputedMember()))}else if(match(".")){expr=markerApply(marker,delegate.createMemberExpression(".",expr,parseNonComputedMember()))}else{expr=markerApply(marker,delegate.createTaggedTemplateExpression(expr,parseTemplateLiteral()))}}return expr}function parseLeftHandSideExpression(){var expr,marker=markerCreate();expr=matchKeyword("new")?parseNewExpression():parsePrimaryExpression();while(match(".")||match("[")||lookahead.type===Token.Template){if(match("[")){expr=markerApply(marker,delegate.createMemberExpression("[",expr,parseComputedMember()))}else if(match(".")){expr=markerApply(marker,delegate.createMemberExpression(".",expr,parseNonComputedMember()))}else{expr=markerApply(marker,delegate.createTaggedTemplateExpression(expr,parseTemplateLiteral()))}}return expr}function parsePostfixExpression(){var marker=markerCreate(),expr=parseLeftHandSideExpressionAllowCall(),token;if(lookahead.type!==Token.Punctuator){return expr}if((match("++")||match("--"))&&!peekLineTerminator()){if(strict&&expr.type===Syntax.Identifier&&isRestrictedWord(expr.name)){throwErrorTolerant({},Messages.StrictLHSPostfix)}if(!isLeftHandSide(expr)){throwError({},Messages.InvalidLHSInAssignment)}token=lex();expr=markerApply(marker,delegate.createPostfixExpression(token.value,expr))}return expr}function parseUnaryExpression(){var marker,token,expr;if(lookahead.type!==Token.Punctuator&&lookahead.type!==Token.Keyword){return parsePostfixExpression()}if(match("++")||match("--")){marker=markerCreate();token=lex();expr=parseUnaryExpression();if(strict&&expr.type===Syntax.Identifier&&isRestrictedWord(expr.name)){throwErrorTolerant({},Messages.StrictLHSPrefix)}if(!isLeftHandSide(expr)){throwError({},Messages.InvalidLHSInAssignment)}return markerApply(marker,delegate.createUnaryExpression(token.value,expr))}if(match("+")||match("-")||match("~")||match("!")){marker=markerCreate();token=lex();expr=parseUnaryExpression();return markerApply(marker,delegate.createUnaryExpression(token.value,expr))}if(matchKeyword("delete")||matchKeyword("void")||matchKeyword("typeof")){marker=markerCreate();token=lex();expr=parseUnaryExpression();expr=markerApply(marker,delegate.createUnaryExpression(token.value,expr));if(strict&&expr.operator==="delete"&&expr.argument.type===Syntax.Identifier){throwErrorTolerant({},Messages.StrictDelete)}return expr}return parsePostfixExpression()}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 expr,token,prec,previousAllowIn,stack,right,operator,left,i,marker,markers;previousAllowIn=state.allowIn;state.allowIn=true;marker=markerCreate();left=parseUnaryExpression();token=lookahead;prec=binaryPrecedence(token,previousAllowIn);if(prec===0){return left}token.prec=prec;lex();markers=[marker,markerCreate()];right=parseUnaryExpression();stack=[left,token,right];while((prec=binaryPrecedence(lookahead,previousAllowIn))>0){while(stack.length>2&&prec<=stack[stack.length-2].prec){right=stack.pop();operator=stack.pop().value;left=stack.pop();expr=delegate.createBinaryExpression(operator,left,right);markers.pop();marker=markers.pop();markerApply(marker,expr);stack.push(expr);markers.push(marker)}token=lex();token.prec=prec;stack.push(token);markers.push(markerCreate());expr=parseUnaryExpression();stack.push(expr)}state.allowIn=previousAllowIn;i=stack.length-1;expr=stack[i];markers.pop();while(i>1){expr=delegate.createBinaryExpression(stack[i-1].value,stack[i-2],expr);i-=2;marker=markers.pop();markerApply(marker,expr)}return expr}function parseConditionalExpression(){var expr,previousAllowIn,consequent,alternate,marker=markerCreate();expr=parseBinaryExpression();if(match("?")){lex();previousAllowIn=state.allowIn;state.allowIn=true;consequent=parseAssignmentExpression();state.allowIn=previousAllowIn;expect(":");alternate=parseAssignmentExpression();expr=markerApply(marker,delegate.createConditionalExpression(expr,consequent,alternate))}return expr}function reinterpretAsAssignmentBindingPattern(expr){var i,len,property,element;if(expr.type===Syntax.ObjectExpression){expr.type=Syntax.ObjectPattern;for(i=0,len=expr.properties.length;i<len;i+=1){property=expr.properties[i];if(property.type===Syntax.SpreadProperty){if(i<len-1){throwError({},Messages.PropertyAfterSpreadProperty)}reinterpretAsAssignmentBindingPattern(property.argument)}else{if(property.kind!=="init"){throwError({},Messages.InvalidLHSInAssignment)}reinterpretAsAssignmentBindingPattern(property.value)}}}else if(expr.type===Syntax.ArrayExpression){expr.type=Syntax.ArrayPattern;for(i=0,len=expr.elements.length;i<len;i+=1){element=expr.elements[i];if(element){reinterpretAsAssignmentBindingPattern(element)}}}else if(expr.type===Syntax.Identifier){if(isRestrictedWord(expr.name)){throwError({},Messages.InvalidLHSInAssignment)}}else if(expr.type===Syntax.SpreadElement){reinterpretAsAssignmentBindingPattern(expr.argument);if(expr.argument.type===Syntax.ObjectPattern){throwError({},Messages.ObjectPatternAsSpread)}}else{if(expr.type!==Syntax.MemberExpression&&expr.type!==Syntax.CallExpression&&expr.type!==Syntax.NewExpression){throwError({},Messages.InvalidLHSInAssignment)}}}function reinterpretAsDestructuredParameter(options,expr){var i,len,property,element;if(expr.type===Syntax.ObjectExpression){expr.type=Syntax.ObjectPattern;for(i=0,len=expr.properties.length;i<len;i+=1){property=expr.properties[i];if(property.type===Syntax.SpreadProperty){if(i<len-1){throwError({},Messages.PropertyAfterSpreadProperty)}reinterpretAsDestructuredParameter(options,property.argument)}else{if(property.kind!=="init"){throwError({},Messages.InvalidLHSInFormalsList)}reinterpretAsDestructuredParameter(options,property.value)}}}else if(expr.type===Syntax.ArrayExpression){expr.type=Syntax.ArrayPattern;for(i=0,len=expr.elements.length;i<len;i+=1){element=expr.elements[i];if(element){reinterpretAsDestructuredParameter(options,element)}}}else if(expr.type===Syntax.Identifier){validateParam(options,expr,expr.name)}else{if(expr.type!==Syntax.MemberExpression){throwError({},Messages.InvalidLHSInFormalsList)}}}function reinterpretAsCoverFormalsList(expressions){var i,len,param,params,defaults,defaultCount,options,rest;params=[];defaults=[];defaultCount=0;rest=null;options={paramSet:{}};for(i=0,len=expressions.length;i<len;i+=1){param=expressions[i];if(param.type===Syntax.Identifier){params.push(param);defaults.push(null);validateParam(options,param,param.name)}else if(param.type===Syntax.ObjectExpression||param.type===Syntax.ArrayExpression){reinterpretAsDestructuredParameter(options,param);params.push(param);defaults.push(null)}else if(param.type===Syntax.SpreadElement){assert(i===len-1,"It is guaranteed that SpreadElement is last element by parseExpression");reinterpretAsDestructuredParameter(options,param.argument);rest=param.argument}else if(param.type===Syntax.AssignmentExpression){params.push(param.left);defaults.push(param.right);++defaultCount;validateParam(options,param.left,param.left.name)}else{return null}}if(options.message===Messages.StrictParamDupe){throwError(strict?options.stricted:options.firstRestricted,options.message)}if(defaultCount===0){defaults=[]}return{params:params,defaults:defaults,rest:rest,stricted:options.stricted,firstRestricted:options.firstRestricted,message:options.message}}function parseArrowFunctionExpression(options,marker){var previousStrict,previousYieldAllowed,body;expect("=>");previousStrict=strict;previousYieldAllowed=state.yieldAllowed;state.yieldAllowed=false;body=parseConciseBody();if(strict&&options.firstRestricted){throwError(options.firstRestricted,options.message)}if(strict&&options.stricted){throwErrorTolerant(options.stricted,options.message)}strict=previousStrict;state.yieldAllowed=previousYieldAllowed;return markerApply(marker,delegate.createArrowFunctionExpression(options.params,options.defaults,body,options.rest,body.type!==Syntax.BlockStatement))}function parseAssignmentExpression(){var marker,expr,token,params,oldParenthesizedCount;if(state.yieldAllowed&&matchContextualKeyword("yield")||strict&&matchKeyword("yield")){return parseYieldExpression()}oldParenthesizedCount=state.parenthesizedCount;marker=markerCreate();if(match("(")){token=lookahead2();if(token.type===Token.Punctuator&&token.value===")"||token.value==="..."){params=parseParams();if(!match("=>")){throwUnexpected(lex())}return parseArrowFunctionExpression(params,marker)}}token=lookahead;expr=parseConditionalExpression();if(match("=>")&&(state.parenthesizedCount===oldParenthesizedCount||state.parenthesizedCount===oldParenthesizedCount+1)){if(expr.type===Syntax.Identifier){params=reinterpretAsCoverFormalsList([expr])}else if(expr.type===Syntax.SequenceExpression){params=reinterpretAsCoverFormalsList(expr.expressions)}if(params){return parseArrowFunctionExpression(params,marker)}}if(matchAssign()){if(strict&&expr.type===Syntax.Identifier&&isRestrictedWord(expr.name)){throwErrorTolerant(token,Messages.StrictLHSAssignment)}if(match("=")&&(expr.type===Syntax.ObjectExpression||expr.type===Syntax.ArrayExpression)){reinterpretAsAssignmentBindingPattern(expr)}else if(!isLeftHandSide(expr)){throwError({},Messages.InvalidLHSInAssignment)}expr=markerApply(marker,delegate.createAssignmentExpression(lex().value,expr,parseAssignmentExpression()))}return expr}function parseExpression(){var marker,expr,expressions,sequence,coverFormalsList,spreadFound,oldParenthesizedCount;oldParenthesizedCount=state.parenthesizedCount;marker=markerCreate();expr=parseAssignmentExpression();expressions=[expr];if(match(",")){while(index<length){if(!match(",")){break}lex();expr=parseSpreadOrAssignmentExpression();expressions.push(expr);if(expr.type===Syntax.SpreadElement){spreadFound=true;if(!match(")")){throwError({},Messages.ElementAfterSpreadElement)}break}}sequence=markerApply(marker,delegate.createSequenceExpression(expressions))}if(match("=>")){if(state.parenthesizedCount===oldParenthesizedCount||state.parenthesizedCount===oldParenthesizedCount+1){expr=expr.type===Syntax.SequenceExpression?expr.expressions:expressions;coverFormalsList=reinterpretAsCoverFormalsList(expr);if(coverFormalsList){return parseArrowFunctionExpression(coverFormalsList,marker)}}throwUnexpected(lex())}if(spreadFound&&lookahead2().value!=="=>"){throwError({},Messages.IllegalSpread)}return sequence||expr}function parseStatementList(){var list=[],statement;while(index<length){if(match("}")){break}statement=parseSourceElement();if(typeof statement==="undefined"){break}list.push(statement)}return list}function parseBlock(){var block,marker=markerCreate();expect("{");block=parseStatementList();expect("}");return markerApply(marker,delegate.createBlockStatement(block))}function parseObjectTypeAnnotation(){var isMethod,marker,properties=[],property,propertyKey,propertyTypeAnnotation;expect("{");while(!match("}")){marker=markerCreate();propertyKey=parseObjectPropertyKey();isMethod=match("(");propertyTypeAnnotation=parseTypeAnnotation();properties.push(markerApply(marker,delegate.createProperty("init",propertyKey,propertyTypeAnnotation,isMethod,false)));if(!match("}")){if(match(",")||match(";")){lex()}else{throwUnexpected(lookahead)}}}expect("}");return delegate.createObjectTypeAnnotation(properties)}function parseVoidTypeAnnotation(){var marker=markerCreate();expectKeyword("void");return markerApply(marker,delegate.createVoidTypeAnnotation())}function parseParametricTypeAnnotation(){var marker=markerCreate(),typeIdentifier,paramTypes=[];expect("<");while(!match(">")){paramTypes.push(parseVariableIdentifier());if(!match(">")){expect(",")}}expect(">");return markerApply(marker,delegate.createParametricTypeAnnotation(paramTypes))}function parseTypeAnnotation(dontExpectColon){var typeIdentifier=null,params=null,returnType=null,nullable=false,marker=markerCreate(),returnTypeMarker=null,parametricType,annotation;if(!dontExpectColon){expect(":")}if(match("{")){return markerApply(marker,parseObjectTypeAnnotation())}if(match("?")){lex();nullable=true}if(lookahead.type===Token.Identifier){typeIdentifier=parseVariableIdentifier();if(match("<")){parametricType=parseParametricTypeAnnotation()}}else if(match("(")){lex();params=[];while(lookahead.type===Token.Identifier||match("?")){params.push(parseTypeAnnotatableIdentifier(true,true));if(!match(")")){expect(",")}}expect(")");returnTypeMarker=markerCreate();expect("=>");returnType=parseTypeAnnotation(true)}else{if(!matchKeyword("void")){throwUnexpected(lookahead)}else{return parseVoidTypeAnnotation()}}return markerApply(marker,delegate.createTypeAnnotation(typeIdentifier,parametricType,params,returnType,nullable))}function parseVariableIdentifier(){var marker=markerCreate(),token=lex();if(token.type!==Token.Identifier){throwUnexpected(token)}return markerApply(marker,delegate.createIdentifier(token.value))
}function parseTypeAnnotatableIdentifier(requireTypeAnnotation,canBeOptionalParam){var marker=markerCreate(),ident=parseVariableIdentifier(),isOptionalParam=false;if(canBeOptionalParam&&match("?")){expect("?");isOptionalParam=true}if(requireTypeAnnotation||match(":")){ident=markerApply(marker,delegate.createTypeAnnotatedIdentifier(ident,parseTypeAnnotation()))}if(isOptionalParam){ident=markerApply(marker,delegate.createOptionalParameter(ident))}return ident}function parseVariableDeclaration(kind){var id,marker=markerCreate(),init=null;if(match("{")){id=parseObjectInitialiser();reinterpretAsAssignmentBindingPattern(id)}else if(match("[")){id=parseArrayInitialiser();reinterpretAsAssignmentBindingPattern(id)}else{id=state.allowKeyword?parseNonComputedProperty():parseTypeAnnotatableIdentifier();if(strict&&isRestrictedWord(id.name)){throwErrorTolerant({},Messages.StrictVarName)}}if(kind==="const"){if(!match("=")){throwError({},Messages.NoUnintializedConst)}expect("=");init=parseAssignmentExpression()}else if(match("=")){lex();init=parseAssignmentExpression()}return markerApply(marker,delegate.createVariableDeclarator(id,init))}function parseVariableDeclarationList(kind){var list=[];do{list.push(parseVariableDeclaration(kind));if(!match(",")){break}lex()}while(index<length);return list}function parseVariableStatement(){var declarations,marker=markerCreate();expectKeyword("var");declarations=parseVariableDeclarationList();consumeSemicolon();return markerApply(marker,delegate.createVariableDeclaration(declarations,"var"))}function parseConstLetDeclaration(kind){var declarations,marker=markerCreate();expectKeyword(kind);declarations=parseVariableDeclarationList(kind);consumeSemicolon();return markerApply(marker,delegate.createVariableDeclaration(declarations,kind))}function parseModuleDeclaration(){var id,src,body,marker=markerCreate();lex();if(peekLineTerminator()){throwError({},Messages.NewlineAfterModule)}switch(lookahead.type){case Token.StringLiteral:id=parsePrimaryExpression();body=parseModuleBlock();src=null;break;case Token.Identifier:id=parseVariableIdentifier();body=null;if(!matchContextualKeyword("from")){throwUnexpected(lex())}lex();src=parsePrimaryExpression();if(src.type!==Syntax.Literal){throwError({},Messages.InvalidModuleSpecifier)}break}consumeSemicolon();return markerApply(marker,delegate.createModuleDeclaration(id,src,body))}function parseExportBatchSpecifier(){var marker=markerCreate();expect("*");return markerApply(marker,delegate.createExportBatchSpecifier())}function parseExportSpecifier(){var id,name=null,marker=markerCreate();id=parseVariableIdentifier();if(matchContextualKeyword("as")){lex();name=parseNonComputedProperty()}return markerApply(marker,delegate.createExportSpecifier(id,name))}function parseExportDeclaration(){var previousAllowKeyword,decl,def,src,specifiers,marker=markerCreate();expectKeyword("export");if(lookahead.type===Token.Keyword){switch(lookahead.value){case"let":case"const":case"var":case"class":case"function":return markerApply(marker,delegate.createExportDeclaration(parseSourceElement(),null,null))}}if(isIdentifierName(lookahead)){previousAllowKeyword=state.allowKeyword;state.allowKeyword=true;decl=parseVariableDeclarationList("let");state.allowKeyword=previousAllowKeyword;return markerApply(marker,delegate.createExportDeclaration(decl,null,null))}specifiers=[];src=null;if(match("*")){specifiers.push(parseExportBatchSpecifier())}else{expect("{");do{specifiers.push(parseExportSpecifier())}while(match(",")&&lex());expect("}")}if(matchContextualKeyword("from")){lex();src=parsePrimaryExpression();if(src.type!==Syntax.Literal){throwError({},Messages.InvalidModuleSpecifier)}}consumeSemicolon();return markerApply(marker,delegate.createExportDeclaration(null,specifiers,src))}function parseImportDeclaration(){var specifiers,kind,src,marker=markerCreate();expectKeyword("import");specifiers=[];if(isIdentifierName(lookahead)){kind="default";specifiers.push(parseImportSpecifier());if(!matchContextualKeyword("from")){throwError({},Messages.NoFromAfterImport)}lex()}else if(match("{")){kind="named";lex();do{specifiers.push(parseImportSpecifier())}while(match(",")&&lex());expect("}");if(!matchContextualKeyword("from")){throwError({},Messages.NoFromAfterImport)}lex()}src=parsePrimaryExpression();if(src.type!==Syntax.Literal){throwError({},Messages.InvalidModuleSpecifier)}consumeSemicolon();return markerApply(marker,delegate.createImportDeclaration(specifiers,kind,src))}function parseImportSpecifier(){var id,name=null,marker=markerCreate();id=parseNonComputedProperty();if(matchContextualKeyword("as")){lex();name=parseVariableIdentifier()}return markerApply(marker,delegate.createImportSpecifier(id,name))}function parseEmptyStatement(){var marker=markerCreate();expect(";");return markerApply(marker,delegate.createEmptyStatement())}function parseExpressionStatement(){var marker=markerCreate(),expr=parseExpression();consumeSemicolon();return markerApply(marker,delegate.createExpressionStatement(expr))}function parseIfStatement(){var test,consequent,alternate,marker=markerCreate();expectKeyword("if");expect("(");test=parseExpression();expect(")");consequent=parseStatement();if(matchKeyword("else")){lex();alternate=parseStatement()}else{alternate=null}return markerApply(marker,delegate.createIfStatement(test,consequent,alternate))}function parseDoWhileStatement(){var body,test,oldInIteration,marker=markerCreate();expectKeyword("do");oldInIteration=state.inIteration;state.inIteration=true;body=parseStatement();state.inIteration=oldInIteration;expectKeyword("while");expect("(");test=parseExpression();expect(")");if(match(";")){lex()}return markerApply(marker,delegate.createDoWhileStatement(body,test))}function parseWhileStatement(){var test,body,oldInIteration,marker=markerCreate();expectKeyword("while");expect("(");test=parseExpression();expect(")");oldInIteration=state.inIteration;state.inIteration=true;body=parseStatement();state.inIteration=oldInIteration;return markerApply(marker,delegate.createWhileStatement(test,body))}function parseForVariableDeclaration(){var marker=markerCreate(),token=lex(),declarations=parseVariableDeclarationList();return markerApply(marker,delegate.createVariableDeclaration(declarations,token.value))}function parseForStatement(opts){var init,test,update,left,right,body,operator,oldInIteration,marker=markerCreate();init=test=update=null;expectKeyword("for");if(matchContextualKeyword("each")){throwError({},Messages.EachNotAllowed)}expect("(");if(match(";")){lex()}else{if(matchKeyword("var")||matchKeyword("let")||matchKeyword("const")){state.allowIn=false;init=parseForVariableDeclaration();state.allowIn=true;if(init.declarations.length===1){if(matchKeyword("in")||matchContextualKeyword("of")){operator=lookahead;if(!((operator.value==="in"||init.kind!=="var")&&init.declarations[0].init)){lex();left=init;right=parseExpression();init=null}}}}else{state.allowIn=false;init=parseExpression();state.allowIn=true;if(matchContextualKeyword("of")){operator=lex();left=init;right=parseExpression();init=null}else if(matchKeyword("in")){if(!isAssignableLeftHandSide(init)){throwError({},Messages.InvalidLHSInForIn)}operator=lex();left=init;right=parseExpression();init=null}}if(typeof left==="undefined"){expect(";")}}if(typeof left==="undefined"){if(!match(";")){test=parseExpression()}expect(";");if(!match(")")){update=parseExpression()}}expect(")");oldInIteration=state.inIteration;state.inIteration=true;if(!(opts!==undefined&&opts.ignoreBody)){body=parseStatement()}state.inIteration=oldInIteration;if(typeof left==="undefined"){return markerApply(marker,delegate.createForStatement(init,test,update,body))}if(operator.value==="in"){return markerApply(marker,delegate.createForInStatement(left,right,body))}return markerApply(marker,delegate.createForOfStatement(left,right,body))}function parseContinueStatement(){var label=null,key,marker=markerCreate();expectKeyword("continue");if(source.charCodeAt(index)===59){lex();if(!state.inIteration){throwError({},Messages.IllegalContinue)}return markerApply(marker,delegate.createContinueStatement(null))}if(peekLineTerminator()){if(!state.inIteration){throwError({},Messages.IllegalContinue)}return markerApply(marker,delegate.createContinueStatement(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 markerApply(marker,delegate.createContinueStatement(label))}function parseBreakStatement(){var label=null,key,marker=markerCreate();expectKeyword("break");if(source.charCodeAt(index)===59){lex();if(!(state.inIteration||state.inSwitch)){throwError({},Messages.IllegalBreak)}return markerApply(marker,delegate.createBreakStatement(null))}if(peekLineTerminator()){if(!(state.inIteration||state.inSwitch)){throwError({},Messages.IllegalBreak)}return markerApply(marker,delegate.createBreakStatement(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 markerApply(marker,delegate.createBreakStatement(label))}function parseReturnStatement(){var argument=null,marker=markerCreate();expectKeyword("return");if(!state.inFunctionBody){throwErrorTolerant({},Messages.IllegalReturn)}if(source.charCodeAt(index)===32){if(isIdentifierStart(source.charCodeAt(index+1))){argument=parseExpression();consumeSemicolon();return markerApply(marker,delegate.createReturnStatement(argument))}}if(peekLineTerminator()){return markerApply(marker,delegate.createReturnStatement(null))}if(!match(";")){if(!match("}")&&lookahead.type!==Token.EOF){argument=parseExpression()}}consumeSemicolon();return markerApply(marker,delegate.createReturnStatement(argument))}function parseWithStatement(){var object,body,marker=markerCreate();if(strict){throwErrorTolerant({},Messages.StrictModeWith)}expectKeyword("with");expect("(");object=parseExpression();expect(")");body=parseStatement();return markerApply(marker,delegate.createWithStatement(object,body))}function parseSwitchCase(){var test,consequent=[],sourceElement,marker=markerCreate();if(matchKeyword("default")){lex();test=null}else{expectKeyword("case");test=parseExpression()}expect(":");while(index<length){if(match("}")||matchKeyword("default")||matchKeyword("case")){break}sourceElement=parseSourceElement();if(typeof sourceElement==="undefined"){break}consequent.push(sourceElement)}return markerApply(marker,delegate.createSwitchCase(test,consequent))}function parseSwitchStatement(){var discriminant,cases,clause,oldInSwitch,defaultFound,marker=markerCreate();expectKeyword("switch");expect("(");discriminant=parseExpression();expect(")");expect("{");cases=[];if(match("}")){lex();return markerApply(marker,delegate.createSwitchStatement(discriminant,cases))}oldInSwitch=state.inSwitch;state.inSwitch=true;defaultFound=false;while(index<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 markerApply(marker,delegate.createSwitchStatement(discriminant,cases))}function parseThrowStatement(){var argument,marker=markerCreate();expectKeyword("throw");if(peekLineTerminator()){throwError({},Messages.NewlineAfterThrow)}argument=parseExpression();consumeSemicolon();return markerApply(marker,delegate.createThrowStatement(argument))}function parseCatchClause(){var param,body,marker=markerCreate();expectKeyword("catch");expect("(");if(match(")")){throwUnexpected(lookahead)}param=parseExpression();if(strict&&param.type===Syntax.Identifier&&isRestrictedWord(param.name)){throwErrorTolerant({},Messages.StrictCatchVariable)}expect(")");body=parseBlock();return markerApply(marker,delegate.createCatchClause(param,body))}function parseTryStatement(){var block,handlers=[],finalizer=null,marker=markerCreate();expectKeyword("try");block=parseBlock();if(matchKeyword("catch")){handlers.push(parseCatchClause())}if(matchKeyword("finally")){lex();finalizer=parseBlock()}if(handlers.length===0&&!finalizer){throwError({},Messages.NoCatchOrFinally)}return markerApply(marker,delegate.createTryStatement(block,[],handlers,finalizer))}function parseDebuggerStatement(){var marker=markerCreate();expectKeyword("debugger");consumeSemicolon();return markerApply(marker,delegate.createDebuggerStatement())}function parseStatement(){var type=lookahead.type,marker,expr,labeledBody,key;if(type===Token.EOF){throwUnexpected(lookahead)}if(type===Token.Punctuator){switch(lookahead.value){case";":return parseEmptyStatement();case"{":return parseBlock();case"(":return parseExpressionStatement();default:break}}if(type===Token.Keyword){switch(lookahead.value){case"break":return parseBreakStatement();case"continue":return parseContinueStatement();case"debugger":return parseDebuggerStatement();case"do":return parseDoWhileStatement();case"for":return parseForStatement();case"function":return parseFunctionDeclaration();case"class":return parseClassDeclaration();case"if":return parseIfStatement();case"return":return parseReturnStatement();case"switch":return parseSwitchStatement();case"throw":return parseThrowStatement();case"try":return parseTryStatement();case"var":return parseVariableStatement();case"while":return parseWhileStatement();case"with":return parseWithStatement();default:break}}marker=markerCreate();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 markerApply(marker,delegate.createLabeledStatement(expr,labeledBody))}consumeSemicolon();return markerApply(marker,delegate.createExpressionStatement(expr))}function parseConciseBody(){if(match("{")){return parseFunctionSourceElements()}return parseAssignmentExpression()}function parseFunctionSourceElements(){var sourceElement,sourceElements=[],token,directive,firstRestricted,oldLabelSet,oldInIteration,oldInSwitch,oldInFunctionBody,oldParenthesizedCount,marker=markerCreate();expect("{");while(index<length){if(lookahead.type!==Token.StringLiteral){break}token=lookahead;sourceElement=parseSourceElement();sourceElements.push(sourceElement);if(sourceElement.expression.type!==Syntax.Literal){break}directive=source.slice(token.range[0]+1,token.range[1]-1);if(directive==="use strict"){strict=true;if(firstRestricted){throwErrorTolerant(firstRestricted,Messages.StrictOctalLiteral)}}else{if(!firstRestricted&&token.octal){firstRestricted=token}}}oldLabelSet=state.labelSet;oldInIteration=state.inIteration;oldInSwitch=state.inSwitch;oldInFunctionBody=state.inFunctionBody;oldParenthesizedCount=state.parenthesizedCount;state.labelSet={};state.inIteration=false;state.inSwitch=false;state.inFunctionBody=true;state.parenthesizedCount=0;while(index<length){if(match("}")){break}sourceElement=parseSourceElement();if(typeof sourceElement==="undefined"){break}sourceElements.push(sourceElement)}expect("}");state.labelSet=oldLabelSet;state.inIteration=oldInIteration;state.inSwitch=oldInSwitch;state.inFunctionBody=oldInFunctionBody;state.parenthesizedCount=oldParenthesizedCount;return markerApply(marker,delegate.createBlockStatement(sourceElements))}function validateParam(options,param,name){var key="$"+name;if(strict){if(isRestrictedWord(name)){options.stricted=param;options.message=Messages.StrictParamName}if(Object.prototype.hasOwnProperty.call(options.paramSet,key)){options.stricted=param;options.message=Messages.StrictParamDupe}}else if(!options.firstRestricted){if(isRestrictedWord(name)){options.firstRestricted=param;options.message=Messages.StrictParamName}else if(isStrictModeReservedWord(name)){options.firstRestricted=param;options.message=Messages.StrictReservedWord}else if(Object.prototype.hasOwnProperty.call(options.paramSet,key)){options.firstRestricted=param;options.message=Messages.StrictParamDupe}}options.paramSet[key]=true}function parseParam(options){var token,rest,param,def;token=lookahead;if(token.value==="..."){token=lex();rest=true}if(match("[")){param=parseArrayInitialiser();reinterpretAsDestructuredParameter(options,param)}else if(match("{")){if(rest){throwError({},Messages.ObjectPatternAsRestParameter)}param=parseObjectInitialiser();reinterpretAsDestructuredParameter(options,param)}else{param=rest?parseVariableIdentifier():parseTypeAnnotatableIdentifier(false,true);validateParam(options,token,token.value)}if(match("=")){if(rest){throwErrorTolerant(lookahead,Messages.DefaultRestParameter)}lex();def=parseAssignmentExpression();++options.defaultCount}if(rest){if(!match(")")){throwError({},Messages.ParameterAfterRestParameter)}options.rest=param;return false}options.params.push(param);options.defaults.push(def);return!match(")")}function parseParams(firstRestricted){var options,marker=markerCreate();options={params:[],defaultCount:0,defaults:[],rest:null,firstRestricted:firstRestricted};expect("(");if(!match(")")){options.paramSet={};while(index<length){if(!parseParam(options)){break}expect(",")}}expect(")");if(options.defaultCount===0){options.defaults=[]}if(match(":")){options.returnType=parseTypeAnnotation()}return markerApply(marker,options)}function parseFunctionDeclaration(){var id,body,token,tmp,firstRestricted,message,previousStrict,previousYieldAllowed,generator,marker=markerCreate(),parametricType;expectKeyword("function");generator=false;if(match("*")){lex();generator=true}token=lookahead;id=parseVariableIdentifier();if(match("<")){parametricType=parseParametricTypeAnnotation()}if(strict){if(isRestrictedWord(token.value)){throwErrorTolerant(token,Messages.StrictFunctionName)}}else{if(isRestrictedWord(token.value)){firstRestricted=token;message=Messages.StrictFunctionName}else if(isStrictModeReservedWord(token.value)){firstRestricted=token;message=Messages.StrictReservedWord}}tmp=parseParams(firstRestricted);firstRestricted=tmp.firstRestricted;if(tmp.message){message=tmp.message}previousStrict=strict;previousYieldAllowed=state.yieldAllowed;state.yieldAllowed=generator;body=parseFunctionSourceElements();if(strict&&firstRestricted){throwError(firstRestricted,message)}if(strict&&tmp.stricted){throwErrorTolerant(tmp.stricted,message)}strict=previousStrict;state.yieldAllowed=previousYieldAllowed;return markerApply(marker,delegate.createFunctionDeclaration(id,tmp.params,tmp.defaults,body,tmp.rest,generator,false,tmp.returnType,parametricType))}function parseFunctionExpression(){var token,id=null,firstRestricted,message,tmp,body,previousStrict,previousYieldAllowed,generator,marker=markerCreate(),parametricType;expectKeyword("function");generator=false;if(match("*")){lex();generator=true}if(!match("(")){if(!match("<")){token=lookahead;id=parseVariableIdentifier();if(strict){if(isRestrictedWord(token.value)){throwErrorTolerant(token,Messages.StrictFunctionName)}}else{if(isRestrictedWord(token.value)){firstRestricted=token;message=Messages.StrictFunctionName}else if(isStrictModeReservedWord(token.value)){firstRestricted=token;message=Messages.StrictReservedWord}}}if(match("<")){parametricType=parseParametricTypeAnnotation()}}tmp=parseParams(firstRestricted);firstRestricted=tmp.firstRestricted;if(tmp.message){message=tmp.message}previousStrict=strict;previousYieldAllowed=state.yieldAllowed;state.yieldAllowed=generator;body=parseFunctionSourceElements();if(strict&&firstRestricted){throwError(firstRestricted,message)}if(strict&&tmp.stricted){throwErrorTolerant(tmp.stricted,message)}strict=previousStrict;state.yieldAllowed=previousYieldAllowed;return markerApply(marker,delegate.createFunctionExpression(id,tmp.params,tmp.defaults,body,tmp.rest,generator,false,tmp.returnType,parametricType))}function parseYieldExpression(){var yieldToken,delegateFlag,expr,marker=markerCreate();yieldToken=lex();assert(yieldToken.value==="yield","Called parseYieldExpression with non-yield lookahead.");if(!state.yieldAllowed){throwErrorTolerant({},Messages.IllegalYield)}delegateFlag=false;if(match("*")){lex();delegateFlag=true}expr=parseAssignmentExpression();return markerApply(marker,delegate.createYieldExpression(expr,delegateFlag))}function parseMethodDefinition(existingPropNames){var token,key,param,propType,isValidDuplicateProp=false,marker=markerCreate(),token2,parametricType,parametricTypeMarker,annotationMarker;if(lookahead.value==="static"){propType=ClassPropertyType.static;lex()}else{propType=ClassPropertyType.prototype}if(match("*")){lex();return markerApply(marker,delegate.createMethodDefinition(propType,"",parseObjectPropertyKey(),parsePropertyMethodFunction({generator:true})))}token=lookahead;key=parseObjectPropertyKey();if(token.value==="get"&&!match("(")){key=parseObjectPropertyKey();if(existingPropNames[propType].hasOwnProperty(key.name)){isValidDuplicateProp=existingPropNames[propType][key.name].get===undefined&&existingPropNames[propType][key.name].data===undefined&&existingPropNames[propType][key.name].set!==undefined;if(!isValidDuplicateProp){throwError(key,Messages.IllegalDuplicateClassProperty)}}else{existingPropNames[propType][key.name]={}}existingPropNames[propType][key.name].get=true;expect("(");expect(")");return markerApply(marker,delegate.createMethodDefinition(propType,"get",key,parsePropertyFunction({generator:false})))}if(token.value==="set"&&!match("(")){key=parseObjectPropertyKey();if(existingPropNames[propType].hasOwnProperty(key.name)){isValidDuplicateProp=existingPropNames[propType][key.name].set===undefined&&existingPropNames[propType][key.name].data===undefined&&existingPropNames[propType][key.name].get!==undefined;if(!isValidDuplicateProp){throwError(key,Messages.IllegalDuplicateClassProperty)}}else{existingPropNames[propType][key.name]={}}existingPropNames[propType][key.name].set=true;expect("(");token=lookahead;param=[parseTypeAnnotatableIdentifier()];expect(")");return markerApply(marker,delegate.createMethodDefinition(propType,"set",key,parsePropertyFunction({params:param,generator:false,name:token})))}if(match("<")){parametricType=parseParametricTypeAnnotation()}if(existingPropNames[propType].hasOwnProperty(key.name)){throwError(key,Messages.IllegalDuplicateClassProperty)}else{existingPropNames[propType][key.name]={}}existingPropNames[propType][key.name].data=true;return markerApply(marker,delegate.createMethodDefinition(propType,"",key,parsePropertyMethodFunction({generator:false,parametricType:parametricType})))}function parseClassProperty(existingPropNames){var marker=markerCreate(),propertyIdentifier;propertyIdentifier=parseTypeAnnotatableIdentifier();expect(";");return markerApply(marker,delegate.createClassProperty(propertyIdentifier))}function parseClassElement(existingProps){if(match(";")){lex();return}var doubleLookahead=lookahead2();if(doubleLookahead.type===Token.Punctuator){if(doubleLookahead.value===":"){return parseClassProperty(existingProps)}}return parseMethodDefinition(existingProps)}function parseClassBody(){var classElement,classElements=[],existingProps={},marker=markerCreate();existingProps[ClassPropertyType.static]={};existingProps[ClassPropertyType.prototype]={};expect("{");while(index<length){if(match("}")){break}classElement=parseClassElement(existingProps);if(typeof classElement!=="undefined"){classElements.push(classElement)}}expect("}");return markerApply(marker,delegate.createClassBody(classElements))}function parseClassExpression(){var id,previousYieldAllowed,superClass=null,marker=markerCreate(),parametricType;expectKeyword("class");if(!matchKeyword("extends")&&!match("{")){id=parseVariableIdentifier()}if(match("<")){parametricType=parseParametricTypeAnnotation()}if(matchKeyword("extends")){expectKeyword("extends");previousYieldAllowed=state.yieldAllowed;state.yieldAllowed=false;superClass=parseAssignmentExpression();state.yieldAllowed=previousYieldAllowed}return markerApply(marker,delegate.createClassExpression(id,superClass,parseClassBody(),parametricType))}function parseClassDeclaration(){var id,previousYieldAllowed,superClass=null,marker=markerCreate(),parametricType,superParametricType;expectKeyword("class");id=parseVariableIdentifier();if(match("<")){parametricType=parseParametricTypeAnnotation()}if(matchKeyword("extends")){expectKeyword("extends");previousYieldAllowed=state.yieldAllowed;state.yieldAllowed=false;superClass=parseAssignmentExpression();state.yieldAllowed=previousYieldAllowed}return markerApply(marker,delegate.createClassDeclaration(id,superClass,parseClassBody(),parametricType,superParametricType))}function matchModuleDeclaration(){var id;if(matchContextualKeyword("module")){id=lookahead2();return id.type===Token.StringLiteral||id.type===Token.Identifier}return false}function parseSourceElement(){if(lookahead.type===Token.Keyword){switch(lookahead.value){case"const":case"let":return parseConstLetDeclaration(lookahead.value);case"function":return parseFunctionDeclaration();case"export":return parseExportDeclaration();case"import":return parseImportDeclaration();default:return parseStatement()}}if(matchModuleDeclaration()){throwError({},Messages.NestedModule)}if(lookahead.type!==Token.EOF){return parseStatement()}}function parseProgramElement(){if(lookahead.type===Token.Keyword){switch(lookahead.value){case"export":return parseExportDeclaration();case"import":return parseImportDeclaration()}}if(matchModuleDeclaration()){return parseModuleDeclaration()}return parseSourceElement()}function parseProgramElements(){var sourceElement,sourceElements=[],token,directive,firstRestricted;while(index<length){token=lookahead;if(token.type!==Token.StringLiteral){break}sourceElement=parseProgramElement();sourceElements.push(sourceElement);if(sourceElement.expression.type!==Syntax.Literal){break}directive=source.slice(token.range[0]+1,token.range[1]-1);if(directive==="use strict"){strict=true;if(firstRestricted){throwErrorTolerant(firstRestricted,Messages.StrictOctalLiteral)}}else{if(!firstRestricted&&token.octal){firstRestricted=token}}}while(index<length){sourceElement=parseProgramElement();if(typeof sourceElement==="undefined"){break}sourceElements.push(sourceElement)}return sourceElements}function parseModuleElement(){return parseSourceElement()}function parseModuleElements(){var list=[],statement;while(index<length){if(match("}")){break}statement=parseModuleElement();if(typeof statement==="undefined"){break}list.push(statement)}return list}function parseModuleBlock(){var block,marker=markerCreate();expect("{");block=parseModuleElements();expect("}");return markerApply(marker,delegate.createBlockStatement(block))}function parseProgram(){var body,marker=markerCreate();strict=false;peek();body=parseProgramElements();return markerApply(marker,delegate.createProgram(body))}function addComment(type,value,start,end,loc){var comment;assert(typeof start==="number","Comment must have valid position");if(state.lastCommentStart>=start){return}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)}function scanComment(){var comment,ch,loc,start,blockComment,lineComment;comment="";blockComment=false;lineComment=false;while(index<length){ch=source[index];if(lineComment){ch=source[index++];if(isLineTerminator(ch.charCodeAt(0))){loc.end={line:lineNumber,column:index-lineStart-1};lineComment=false;addComment("Line",comment,start,index-1,loc);if(ch==="\r"&&source[index]==="\n"){++index}++lineNumber;lineStart=index;comment=""}else if(index>=length){lineComment=false;comment+=ch;loc.end={line:lineNumber,column:length-lineStart};addComment("Line",comment,start,length,loc)}else{comment+=ch}}else if(blockComment){if(isLineTerminator(ch.charCodeAt(0))){if(ch==="\r"&&source[index+1]==="\n"){++index;comment+="\r\n"}else{comment+=ch}++lineNumber;++index;lineStart=index;if(index>=length){throwError({},Messages.UnexpectedToken,"ILLEGAL")}}else{ch=source[index++];if(index>=length){throwError({},Messages.UnexpectedToken,"ILLEGAL")}comment+=ch;if(ch==="*"){ch=source[index];if(ch==="/"){comment=comment.substr(0,comment.length-1);blockComment=false;++index;loc.end={line:lineNumber,column:index-lineStart};addComment("Block",comment,start,index,loc);comment=""}}}}else if(ch==="/"){ch=source[index+1];if(ch==="/"){loc={start:{line:lineNumber,column:index-lineStart}};start=index;index+=2;lineComment=true;if(index>=length){loc.end={line:lineNumber,column:index-lineStart};lineComment=false;addComment("Line",comment,start,index,loc)}}else if(ch==="*"){start=index;index+=2;blockComment=true;loc={start:{line:lineNumber,column:index-lineStart-2}};if(index>=length){throwError({},Messages.UnexpectedToken,"ILLEGAL")}}else{break}}else if(isWhiteSpace(ch.charCodeAt(0))){++index}else if(isLineTerminator(ch.charCodeAt(0))){++index;if(ch==="\r"&&source[index]==="\n"){++index}++lineNumber;lineStart=index}else{break}}}XHTMLEntities={quot:'"',amp:"&",apos:"'",lt:"<",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪","int":"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"};function getQualifiedXJSName(object){if(object.type===Syntax.XJSIdentifier){return object.name}if(object.type===Syntax.XJSNamespacedName){return object.namespace.name+":"+object.name.name}if(object.type===Syntax.XJSMemberExpression){return getQualifiedXJSName(object.object)+"."+getQualifiedXJSName(object.property)
}}function isXJSIdentifierStart(ch){return ch!==92&&isIdentifierStart(ch)}function isXJSIdentifierPart(ch){return ch!==92&&(ch===45||isIdentifierPart(ch))}function scanXJSIdentifier(){var ch,start,value="";start=index;while(index<length){ch=source.charCodeAt(index);if(!isXJSIdentifierPart(ch)){break}value+=source[index++]}return{type:Token.XJSIdentifier,value:value,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}function scanXJSEntity(){var ch,str="",count=0,entity;ch=source[index];assert(ch==="&","Entity must start with an ampersand");index++;while(index<length&&count++<10){ch=source[index++];if(ch===";"){break}str+=ch}if(str[0]==="#"&&str[1]==="x"){entity=String.fromCharCode(parseInt(str.substr(2),16))}else if(str[0]==="#"){entity=String.fromCharCode(parseInt(str.substr(1),10))}else{entity=XHTMLEntities[str]}return entity}function scanXJSText(stopChars){var ch,str="",start;start=index;while(index<length){ch=source[index];if(stopChars.indexOf(ch)!==-1){break}if(ch==="&"){str+=scanXJSEntity()}else{index++;if(isLineTerminator(ch.charCodeAt(0))){++lineNumber;lineStart=index}str+=ch}}return{type:Token.XJSText,value:str,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}function scanXJSStringLiteral(){var innerToken,quote,start;quote=source[index];assert(quote==="'"||quote==='"',"String literal must starts with a quote");start=index;++index;innerToken=scanXJSText([quote]);if(quote!==source[index]){throwError({},Messages.UnexpectedToken,"ILLEGAL")}++index;innerToken.range=[start,index];return innerToken}function advanceXJSChild(){var ch=source.charCodeAt(index);if(ch!==123&&ch!==60){return scanXJSText(["<","{"])}return scanPunctuator()}function parseXJSIdentifier(){var token,marker=markerCreate();if(lookahead.type!==Token.XJSIdentifier){throwUnexpected(lookahead)}token=lex();return markerApply(marker,delegate.createXJSIdentifier(token.value))}function parseXJSNamespacedName(){var namespace,name,marker=markerCreate();namespace=parseXJSIdentifier();expect(":");name=parseXJSIdentifier();return markerApply(marker,delegate.createXJSNamespacedName(namespace,name))}function parseXJSMemberExpression(){var marker=markerCreate(),expr=parseXJSIdentifier();while(match(".")){lex();expr=markerApply(marker,delegate.createXJSMemberExpression(expr,parseXJSIdentifier()))}return expr}function parseXJSElementName(){if(lookahead2().value===":"){return parseXJSNamespacedName()}if(lookahead2().value==="."){return parseXJSMemberExpression()}return parseXJSIdentifier()}function parseXJSAttributeName(){if(lookahead2().value===":"){return parseXJSNamespacedName()}return parseXJSIdentifier()}function parseXJSAttributeValue(){var value,marker;if(match("{")){value=parseXJSExpressionContainer();if(value.expression.type===Syntax.XJSEmptyExpression){throwError(value,"XJS attributes must only be assigned a non-empty "+"expression")}}else if(match("<")){value=parseXJSElement()}else if(lookahead.type===Token.XJSText){marker=markerCreate();value=markerApply(marker,delegate.createLiteral(lex()))}else{throwError({},Messages.InvalidXJSAttributeValue)}return value}function parseXJSEmptyExpression(){var marker=markerCreatePreserveWhitespace();while(source.charAt(index)!=="}"){index++}return markerApply(marker,delegate.createXJSEmptyExpression())}function parseXJSExpressionContainer(){var expression,origInXJSChild,origInXJSTag,marker=markerCreate();origInXJSChild=state.inXJSChild;origInXJSTag=state.inXJSTag;state.inXJSChild=false;state.inXJSTag=false;expect("{");if(match("}")){expression=parseXJSEmptyExpression()}else{expression=parseExpression()}state.inXJSChild=origInXJSChild;state.inXJSTag=origInXJSTag;expect("}");return markerApply(marker,delegate.createXJSExpressionContainer(expression))}function parseXJSSpreadAttribute(){var expression,origInXJSChild,origInXJSTag,marker=markerCreate();origInXJSChild=state.inXJSChild;origInXJSTag=state.inXJSTag;state.inXJSChild=false;state.inXJSTag=false;expect("{");expect("...");expression=parseAssignmentExpression();state.inXJSChild=origInXJSChild;state.inXJSTag=origInXJSTag;expect("}");return markerApply(marker,delegate.createXJSSpreadAttribute(expression))}function parseXJSAttribute(){var name,marker;if(match("{")){return parseXJSSpreadAttribute()}marker=markerCreate();name=parseXJSAttributeName();if(match("=")){lex();return markerApply(marker,delegate.createXJSAttribute(name,parseXJSAttributeValue()))}return markerApply(marker,delegate.createXJSAttribute(name))}function parseXJSChild(){var token,marker;if(match("{")){token=parseXJSExpressionContainer()}else if(lookahead.type===Token.XJSText){marker=markerCreatePreserveWhitespace();token=markerApply(marker,delegate.createLiteral(lex()))}else{token=parseXJSElement()}return token}function parseXJSClosingElement(){var name,origInXJSChild,origInXJSTag,marker=markerCreate();origInXJSChild=state.inXJSChild;origInXJSTag=state.inXJSTag;state.inXJSChild=false;state.inXJSTag=true;expect("<");expect("/");name=parseXJSElementName();state.inXJSChild=origInXJSChild;state.inXJSTag=origInXJSTag;expect(">");return markerApply(marker,delegate.createXJSClosingElement(name))}function parseXJSOpeningElement(){var name,attribute,attributes=[],selfClosing=false,origInXJSChild,origInXJSTag,marker=markerCreate();origInXJSChild=state.inXJSChild;origInXJSTag=state.inXJSTag;state.inXJSChild=false;state.inXJSTag=true;expect("<");name=parseXJSElementName();while(index<length&&lookahead.value!=="/"&&lookahead.value!==">"){attributes.push(parseXJSAttribute())}state.inXJSTag=origInXJSTag;if(lookahead.value==="/"){expect("/");state.inXJSChild=origInXJSChild;expect(">");selfClosing=true}else{state.inXJSChild=true;expect(">")}return markerApply(marker,delegate.createXJSOpeningElement(name,attributes,selfClosing))}function parseXJSElement(){var openingElement,closingElement,children=[],origInXJSChild,origInXJSTag,marker=markerCreate();origInXJSChild=state.inXJSChild;origInXJSTag=state.inXJSTag;openingElement=parseXJSOpeningElement();if(!openingElement.selfClosing){while(index<length){state.inXJSChild=false;if(lookahead.value==="<"&&lookahead2().value==="/"){break}state.inXJSChild=true;children.push(parseXJSChild())}state.inXJSChild=origInXJSChild;state.inXJSTag=origInXJSTag;closingElement=parseXJSClosingElement();if(getQualifiedXJSName(closingElement.name)!==getQualifiedXJSName(openingElement.name)){throwError({},Messages.ExpectedXJSClosingTag,getQualifiedXJSName(openingElement.name))}}if(!origInXJSChild&&match("<")){throwError(lookahead,Messages.AdjacentXJSElements)}return markerApply(marker,delegate.createXJSElement(openingElement,closingElement,children))}function collectToken(){var start,loc,token,range,value;if(!state.inXJSChild){skipComment()}start=index;loc={start:{line:lineNumber,column:index-lineStart}};token=extra.advance();loc.end={line:lineNumber,column:index-lineStart};if(token.type!==Token.EOF){range=[token.range[0],token.range[1]];value=source.slice(token.range[0],token.range[1]);extra.tokens.push({type:TokenName[token.type],value:value,range:range,loc:loc})}return token}function collectRegex(){var pos,loc,regex,token;skipComment();pos=index;loc={start:{line:lineNumber,column:index-lineStart}};regex=extra.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,range:[pos,index],loc:loc})}return regex}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(extra.range){token.range=entry.range}if(extra.loc){token.loc=entry.loc}tokens.push(token)}extra.tokens=tokens}function patch(){if(extra.comments){extra.skipComment=skipComment;skipComment=scanComment}if(typeof extra.tokens!=="undefined"){extra.advance=advance;extra.scanRegExp=scanRegExp;advance=collectToken;scanRegExp=collectRegex}}function unpatch(){if(typeof extra.skipComment==="function"){skipComment=extra.skipComment}if(typeof extra.scanRegExp==="function"){advance=extra.advance;scanRegExp=extra.scanRegExp}}function extend(object,properties){var entry,result={};for(entry in object){if(object.hasOwnProperty(entry)){result[entry]=object[entry]}}for(entry in properties){if(properties.hasOwnProperty(entry)){result[entry]=properties[entry]}}return result}function tokenize(code,options){var toString,token,tokens;toString=String;if(typeof code!=="string"&&!(code instanceof String)){code=toString(code)}delegate=SyntaxTreeDelegate;source=code;index=0;lineNumber=source.length>0?1:0;lineStart=0;length=source.length;lookahead=null;state={allowKeyword:true,allowIn:true,labelSet:{},inFunctionBody:false,inIteration:false,inSwitch:false,lastCommentStart:-1};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=[]}if(length>0){if(typeof source[0]==="undefined"){if(code instanceof String){source=code.valueOf()}}}patch();try{peek();if(lookahead.type===Token.EOF){return extra.tokens}token=lex();while(lookahead.type!==Token.EOF){try{token=lex()}catch(lexError){token=lookahead;if(extra.errors){extra.errors.push(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{unpatch();extra={}}return tokens}function parse(code,options){var program,toString;toString=String;if(typeof code!=="string"&&!(code instanceof String)){code=toString(code)}delegate=SyntaxTreeDelegate;source=code;index=0;lineNumber=source.length>0?1:0;lineStart=0;length=source.length;lookahead=null;state={allowKeyword:false,allowIn:true,labelSet:{},parenthesizedCount:0,inFunctionBody:false,inIteration:false,inSwitch:false,inXJSChild:false,inXJSTag:false,lastCommentStart:-1,yieldAllowed:false};extra={};if(typeof options!=="undefined"){extra.range=typeof options.range==="boolean"&&options.range;extra.loc=typeof options.loc==="boolean"&&options.loc;if(extra.loc&&options.source!==null&&options.source!==undefined){delegate=extend(delegate,{postProcess:function(node){node.loc.source=toString(options.source);return node}})}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(length>0){if(typeof source[0]==="undefined"){if(code instanceof String){source=code.valueOf()}}}patch();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{unpatch();extra={}}return program}exports.version="4001.3001.0000-dev-harmony-fb";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}()})},{}],"esprima-fb":[function(require,module,exports){module.exports=require("wTON3q")},{}]},{},[]);console.log=function(){var pre=document.createElement("pre");pre.textContent=Array.prototype.map.call(arguments,function(arg){return typeof arg==="object"?JSON.stringify(arg,null,2):arg}).join(" ");document.body.appendChild(pre)};var esprima=require("esprima-fb"),ast;console.log("Version: ",esprima.version);ast=esprima.parse("<div>x\r\ny</div>",{loc:true});console.log(ast.body[0].expression.loc);
{
"name": "requirebin-sketch",
"version": "1.0.0",
"dependencies": {
"esprima-fb": "4001.3001.0000-dev-harmony-fb"
}
}
<style type='text/css'>html, body { margin: 0; padding: 0; border: 0; }
body, html { height: 100%; width: 100%; }</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment