diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index 75bd43ad6..148673dcc 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -333,9 +333,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.16.12", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.16.12.tgz", - "integrity": "sha512-VfaV15po8RiZssrkPweyvbGVSe4x2y+aciFCgn0n0/SJMR22cwofRV1mtnJQYcSB1wUTaA/X1LnA3es66MCO5A==", + "version": "7.17.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.17.0.tgz", + "integrity": "sha512-VKXSCQx5D8S04ej+Dqsr1CzYvvWgf20jIw2D+YhQCrIlr2UZGaDds23Y0xg75/skOxpLCRpUZvk/1EAVkGoDOw==", "bin": { "parser": "bin/babel-parser.js" }, diff --git a/node_modules/@babel/parser/lib/index.js b/node_modules/@babel/parser/lib/index.js index d03c941d7..b9559112d 100644 --- a/node_modules/@babel/parser/lib/index.js +++ b/node_modules/@babel/parser/lib/index.js @@ -2,37 +2,6 @@ Object.defineProperty(exports, '__esModule', { value: true }); -class Position { - constructor(line, col, index) { - this.line = void 0; - this.column = void 0; - this.index = void 0; - this.line = line; - this.column = col; - indexes.set(this, index); - } - -} -class SourceLocation { - constructor(start, end) { - this.start = void 0; - this.end = void 0; - this.filename = void 0; - this.identifierName = void 0; - this.start = start; - this.end = end; - } - -} -const indexes = new WeakMap(); -function createPositionWithColumnOffset(position, columnOffset) { - const { - line, - column - } = position; - return new Position(line, column + columnOffset, indexes.get(position) + columnOffset); -} - class BaseParser { constructor() { this.sawUnambiguousESM = false; @@ -316,6 +285,7 @@ const ErrorMessages = makeErrorTemplates({ ImportCallArity: "`import()` requires exactly %0.", ImportCallNotNewExpression: "Cannot use new with import(...).", ImportCallSpreadArgument: "`...` is not allowed in `import()`.", + IncompatibleRegExpUVFlags: "The 'u' and 'v' regular expression flags cannot be enabled at the same time.", InvalidBigIntLiteral: "Invalid BigIntLiteral.", InvalidCodePoint: "Code point out of bounds.", InvalidCoverInitializedName: "Invalid shorthand property initializer.", @@ -467,7 +437,7 @@ class ParserError extends CommentsParser { code, template }, ...params) { - const pos = indexes.get(loc); + const pos = loc.index; const message = template.replace(/%(\d+)/g, (_, i) => params[i]) + ` (${loc.line}:${loc.column})`; if (this.options.errorRecovery) { @@ -494,7 +464,7 @@ class ParserError extends CommentsParser { } raiseWithData(loc, data, errorTemplate, ...params) { - const pos = indexes.get(loc); + const pos = loc.index; const message = errorTemplate.replace(/%(\d+)/g, (_, i) => params[i]) + ` (${loc.line}:${loc.column})`; return this._raise(Object.assign({ loc, @@ -516,7 +486,32 @@ class ParserError extends CommentsParser { } +const { + defineProperty +} = Object; + +const toUnenumerable = (object, key) => defineProperty(object, key, { + enumerable: false, + value: object[key] +}); + +function toESTreeLocation(node) { + toUnenumerable(node.loc.start, "index"); + toUnenumerable(node.loc.end, "index"); + return node; +} + var estree = (superClass => class extends superClass { + parse() { + const file = toESTreeLocation(super.parse()); + + if (this.options.tokens) { + file.tokens = file.tokens.map(toESTreeLocation); + } + + return file; + } + parseRegExpLiteral({ pattern, flags @@ -749,7 +744,16 @@ var estree = (superClass => class extends superClass { toAssignable(node, isLHS = false) { if (node != null && this.isObjectProperty(node)) { - this.toAssignable(node.value, isLHS); + const { + key, + value + } = node; + + if (this.isPrivateName(key)) { + this.classScope.usePrivateName(this.getPrivateNameSV(key), key.loc.start); + } + + this.toAssignable(value, isLHS); return node; } @@ -859,6 +863,15 @@ var estree = (superClass => class extends superClass { return node.method || node.kind === "get" || node.kind === "set"; } + finishNodeAt(node, type, endLoc) { + return toESTreeLocation(super.finishNodeAt(node, type, endLoc)); + } + + resetEndLocation(node, endLoc = this.state.lastTokEndLoc) { + super.resetEndLocation(node, endLoc); + toESTreeLocation(node); + } + }); class TokContext { @@ -1079,6 +1092,12 @@ const tt = { prefix, startsExpr }), + doubleCaret: createToken("^^", { + startsExpr + }), + doubleAt: createToken("@@", { + startsExpr + }), pipeline: createBinop("|>", 0), nullishCoalescing: createBinop("??", 1), logicalOR: createBinop("||", 1), @@ -1091,6 +1110,8 @@ const tt = { gt: createBinop("/<=/>=", 7), relational: createBinop("/<=/>=", 7), bitShift: createBinop("<>/>>>", 8), + bitShiftL: createBinop("<>/>>>", 8), + bitShiftR: createBinop("<>/>>>", 8), plusMin: createToken("+/-", { beforeExpr, binop: 9, @@ -1343,16 +1364,16 @@ const tt = { }) }; function tokenIsIdentifier(token) { - return token >= 89 && token <= 124; + return token >= 93 && token <= 128; } function tokenKeywordOrIdentifierIsKeyword(token) { - return token <= 88; + return token <= 92; } function tokenIsKeywordOrIdentifier(token) { - return token >= 54 && token <= 124; + return token >= 58 && token <= 128; } function tokenIsLiteralPropertyName(token) { - return token >= 54 && token <= 128; + return token >= 58 && token <= 132; } function tokenComesBeforeExpression(token) { return tokenBeforeExprs[token]; @@ -1364,16 +1385,16 @@ function tokenIsAssignment(token) { return token >= 29 && token <= 33; } function tokenIsFlowInterfaceOrTypeOrOpaque(token) { - return token >= 121 && token <= 123; + return token >= 125 && token <= 127; } function tokenIsLoop(token) { - return token >= 86 && token <= 88; + return token >= 90 && token <= 92; } function tokenIsKeyword(token) { - return token >= 54 && token <= 88; + return token >= 58 && token <= 92; } function tokenIsOperator(token) { - return token >= 37 && token <= 55; + return token >= 39 && token <= 59; } function tokenIsPostfix(token) { return token === 34; @@ -1382,10 +1403,10 @@ function tokenIsPrefix(token) { return tokenPrefixes[token]; } function tokenIsTSTypeOperator(token) { - return token >= 113 && token <= 115; + return token >= 117 && token <= 119; } function tokenIsTSDeclarationStart(token) { - return token >= 116 && token <= 122; + return token >= 120 && token <= 126; } function tokenLabelName(token) { return tokenLabels[token]; @@ -1394,7 +1415,7 @@ function tokenOperatorPrecedence(token) { return tokenBinops[token]; } function tokenIsRightAssociative(token) { - return token === 53; + return token === 57; } function tokenIsTemplate(token) { return token >= 24 && token <= 25; @@ -1419,11 +1440,42 @@ function getExportedToken(token) { } }; - tokenTypes[134].updateContext = context => { + tokenTypes[138].updateContext = context => { context.push(types.j_expr, types.j_oTag); }; } +class Position { + constructor(line, col, index) { + this.line = void 0; + this.column = void 0; + this.index = void 0; + this.line = line; + this.column = col; + this.index = index; + } + +} +class SourceLocation { + constructor(start, end) { + this.start = void 0; + this.end = void 0; + this.filename = void 0; + this.identifierName = void 0; + this.start = start; + this.end = end; + } + +} +function createPositionWithColumnOffset(position, columnOffset) { + const { + line, + column, + index + } = position; + return new Position(line, column + columnOffset, index + columnOffset); +} + let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u0870-\u0887\u0889-\u088e\u08a0-\u08c9\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u1711\u171f-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4c\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ca\ua7d0\ua7d1\ua7d3\ua7d5-\ua7d9\ua7f2-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; let nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0898-\u089f\u08ca-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3c\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\u1ace\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"; const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); @@ -1496,8 +1548,8 @@ function isKeyword(word) { return keywords.has(word); } -function isIteratorStart(current, next) { - return current === 64 && next === 64; +function isIteratorStart(current, next, next2) { + return current === 64 && next === 64 && isIdentifierStart(next2); } const reservedWordLikeSet = new Set(["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete", "implements", "interface", "let", "package", "private", "protected", "public", "static", "yield", "eval", "arguments", "enum", "await"]); function canBeReservedWord(word) { @@ -1845,7 +1897,7 @@ class State { this.comments = []; this.commentStack = []; this.pos = 0; - this.type = 131; + this.type = 135; this.value = null; this.start = 0; this.end = 0; @@ -1898,7 +1950,7 @@ class State { var _isDigit = function isDigit(code) { return code >= 48 && code <= 57; }; -const VALID_REGEX_FLAGS = new Set([103, 109, 115, 105, 121, 117, 100]); +const VALID_REGEX_FLAGS = new Set([103, 109, 115, 105, 121, 117, 100, 118]); const forbiddenNumericSeparatorSiblings = { decBinOct: [46, 66, 69, 79, 95, 98, 101, 111], hex: [46, 88, 95, 120] @@ -2041,7 +2093,7 @@ class Tokenizer extends ParserError { if (!this.isLookahead) this.state.startLoc = this.state.curPosition(); if (this.state.pos >= this.length) { - this.finishToken(131); + this.finishToken(135); return; } @@ -2264,10 +2316,10 @@ class Tokenizer extends ParserError { } } else if (isIdentifierStart(next)) { ++this.state.pos; - this.finishToken(130, this.readWord1(next)); + this.finishToken(134, this.readWord1(next)); } else if (next === 92) { ++this.state.pos; - this.finishToken(130, this.readWord1()); + this.finishToken(134, this.readWord1()); } else { this.finishOp(27, 1); } @@ -2296,7 +2348,7 @@ class Tokenizer extends ParserError { if (next === 61) { this.finishOp(31, 2); } else { - this.finishOp(52, 1); + this.finishOp(56, 1); } } @@ -2317,14 +2369,14 @@ class Tokenizer extends ParserError { } readToken_mult_modulo(code) { - let type = code === 42 ? 51 : 50; + let type = code === 42 ? 55 : 54; let width = 1; let next = this.input.charCodeAt(this.state.pos + 1); if (code === 42 && next === 42) { width++; next = this.input.charCodeAt(this.state.pos + 2); - type = 53; + type = 57; } if (next === 61 && !this.state.inType) { @@ -2342,7 +2394,7 @@ class Tokenizer extends ParserError { if (this.input.charCodeAt(this.state.pos + 2) === 61) { this.finishOp(30, 3); } else { - this.finishOp(code === 124 ? 39 : 40, 2); + this.finishOp(code === 124 ? 41 : 42, 2); } return; @@ -2350,7 +2402,7 @@ class Tokenizer extends ParserError { if (code === 124) { if (next === 62) { - this.finishOp(37, 2); + this.finishOp(39, 2); return; } @@ -2384,7 +2436,7 @@ class Tokenizer extends ParserError { return; } - this.finishOp(code === 124 ? 41 : 43, 1); + this.finishOp(code === 124 ? 43 : 45, 1); } readToken_caret() { @@ -2392,8 +2444,31 @@ class Tokenizer extends ParserError { if (next === 61 && !this.state.inType) { this.finishOp(32, 2); + } else if (next === 94 && this.hasPlugin(["pipelineOperator", { + proposal: "hack", + topicToken: "^^" + }])) { + this.finishOp(37, 2); + const lookaheadCh = this.input.codePointAt(this.state.pos); + + if (lookaheadCh === 94) { + throw this.unexpected(); + } } else { - this.finishOp(42, 1); + this.finishOp(44, 1); + } + } + + readToken_atSign() { + const next = this.input.charCodeAt(this.state.pos + 1); + + if (next === 64 && this.hasPlugin(["pipelineOperator", { + proposal: "hack", + topicToken: "@@" + }])) { + this.finishOp(38, 2); + } else { + this.finishOp(26, 1); } } @@ -2408,7 +2483,7 @@ class Tokenizer extends ParserError { if (next === 61) { this.finishOp(30, 2); } else { - this.finishOp(49, 1); + this.finishOp(53, 1); } } @@ -2424,16 +2499,16 @@ class Tokenizer extends ParserError { return; } - this.finishOp(48, 2); + this.finishOp(51, 2); return; } if (next === 61) { - this.finishOp(47, 2); + this.finishOp(49, 2); return; } - this.finishOp(45, 1); + this.finishOp(47, 1); } readToken_gt() { @@ -2450,23 +2525,23 @@ class Tokenizer extends ParserError { return; } - this.finishOp(48, size); + this.finishOp(52, size); return; } if (next === 61) { - this.finishOp(47, 2); + this.finishOp(49, 2); return; } - this.finishOp(46, 1); + this.finishOp(48, 1); } readToken_eq_excl(code) { const next = this.input.charCodeAt(this.state.pos + 1); if (next === 61) { - this.finishOp(44, this.input.charCodeAt(this.state.pos + 2) === 61 ? 3 : 2); + this.finishOp(46, this.input.charCodeAt(this.state.pos + 2) === 61 ? 3 : 2); return; } @@ -2487,7 +2562,7 @@ class Tokenizer extends ParserError { if (next2 === 61) { this.finishOp(30, 3); } else { - this.finishOp(38, 2); + this.finishOp(40, 2); } } else if (next === 46 && !(next2 >= 48 && next2 <= 57)) { this.state.pos += 2; @@ -2664,8 +2739,7 @@ class Tokenizer extends ParserError { return; case 64: - ++this.state.pos; - this.finishToken(26); + this.readToken_atSign(); return; case 35: @@ -2737,19 +2811,37 @@ class Tokenizer extends ParserError { ++pos; let mods = ""; + const nextPos = () => createPositionWithColumnOffset(startLoc, pos + 2 - start); + while (pos < this.length) { const cp = this.codePointAtPos(pos); const char = String.fromCharCode(cp); if (VALID_REGEX_FLAGS.has(cp)) { + if (cp === 118) { + this.expectPlugin("regexpUnicodeSets", nextPos()); + + if (mods.includes("u")) { + this.raise(ErrorMessages.IncompatibleRegExpUVFlags, { + at: nextPos() + }); + } + } else if (cp === 117) { + if (mods.includes("v")) { + this.raise(ErrorMessages.IncompatibleRegExpUVFlags, { + at: nextPos() + }); + } + } + if (mods.includes(char)) { this.raise(ErrorMessages.DuplicateRegExpFlags, { - at: createPositionWithColumnOffset(startLoc, pos + 2 - start) + at: nextPos() }); } } else if (isIdentifierChar(cp) || cp === 92) { this.raise(ErrorMessages.MalformedRegExpFlags, { - at: createPositionWithColumnOffset(startLoc, pos + 2 - start) + at: nextPos() }); } else { break; @@ -2760,7 +2852,7 @@ class Tokenizer extends ParserError { } this.state.pos = pos; - this.finishToken(129, { + this.finishToken(133, { pattern: content, flags: mods }); @@ -2866,12 +2958,12 @@ class Tokenizer extends ParserError { } if (isBigInt) { - const str = this.input.slice(indexes.get(startLoc), this.state.pos).replace(/[_n]/g, ""); - this.finishToken(127, str); + const str = this.input.slice(startLoc.index, this.state.pos).replace(/[_n]/g, ""); + this.finishToken(131, str); return; } - this.finishToken(126, val); + this.finishToken(130, val); } readNumber(startsWithDot) { @@ -2968,17 +3060,17 @@ class Tokenizer extends ParserError { const str = this.input.slice(start, this.state.pos).replace(/[_mn]/g, ""); if (isBigInt) { - this.finishToken(127, str); + this.finishToken(131, str); return; } if (isDecimal) { - this.finishToken(128, str); + this.finishToken(132, str); return; } const val = isOctal ? parseInt(str, 8) : parseFloat(str); - this.finishToken(126, val); + this.finishToken(130, val); } readCodePoint(throwOnInvalid) { @@ -3038,7 +3130,7 @@ class Tokenizer extends ParserError { } out += this.input.slice(chunkStart, this.state.pos++); - this.finishToken(125, out); + this.finishToken(129, out); } readTemplateContinuation() { @@ -3119,14 +3211,12 @@ class Tokenizer extends ParserError { } recordStrictModeErrors(message, loc) { - const index = indexes.get(loc); - - if (this.state.strict && !this.state.strictErrors.has(index)) { + if (this.state.strict && !this.state.strictErrors.has(loc.index)) { this.raise(message, { at: loc }); } else { - this.state.strictErrors.set(index, { + this.state.strictErrors.set(loc.index, { loc, message }); @@ -3230,7 +3320,7 @@ class Tokenizer extends ParserError { at: codeLoc }); } else { - this.state.pos = indexes.get(codeLoc) - 1; + this.state.pos = codeLoc.index - 1; } } @@ -3295,7 +3385,7 @@ class Tokenizer extends ParserError { if (type !== undefined) { this.finishToken(type, tokenLabelName(type)); } else { - this.finishToken(124, word); + this.finishToken(128, word); } } @@ -3434,14 +3524,14 @@ class ArrowHeadParsingScope extends ExpressionScope { } recordDeclarationError(message, loc) { - this.errors.set(indexes.get(loc), { + this.errors.set(loc.index, { message, loc }); } clearDeclarationError(loc) { - this.errors.delete(indexes.get(loc)); + this.errors.delete(loc.index); } iterateErrors(iterator) { @@ -3656,11 +3746,11 @@ class UtilParser extends Tokenizer { } canInsertSemicolon() { - return this.match(131) || this.match(8) || this.hasPrecedingLineBreak(); + return this.match(135) || this.match(8) || this.hasPrecedingLineBreak(); } hasPrecedingLineBreak() { - return lineBreak.test(this.input.slice(indexes.get(this.state.lastTokEndLoc), this.state.start)); + return lineBreak.test(this.input.slice(this.state.lastTokEndLoc.index, this.state.start)); } hasFollowingLineBreak() { @@ -3684,7 +3774,7 @@ class UtilParser extends Tokenizer { } assertNoSpace(message = "Unexpected space.") { - if (this.state.start > indexes.get(this.state.lastTokEndLoc)) { + if (this.state.start > this.state.lastTokEndLoc.index) { this.raise({ code: ErrorCodes.SyntaxError, reasonCode: "UnexpectedSpace", @@ -3797,9 +3887,10 @@ class UtilParser extends Tokenizer { const { shorthandAssignLoc, doubleProtoLoc, + privateKeyLoc, optionalParametersLoc } = refExpressionErrors; - const hasErrors = !!shorthandAssignLoc || !!doubleProtoLoc || !!optionalParametersLoc; + const hasErrors = !!shorthandAssignLoc || !!doubleProtoLoc || !!optionalParametersLoc || !!privateKeyLoc; if (!andThrow) { return hasErrors; @@ -3817,6 +3908,12 @@ class UtilParser extends Tokenizer { }); } + if (privateKeyLoc != null) { + this.raise(ErrorMessages.UnexpectedPrivateField, { + at: privateKeyLoc + }); + } + if (optionalParametersLoc != null) { this.unexpected(optionalParametersLoc); } @@ -3888,11 +3985,22 @@ class UtilParser extends Tokenizer { this.prodParam.enter(paramFlags); } + checkDestructuringPrivate(refExpressionErrors) { + const { + privateKeyLoc + } = refExpressionErrors; + + if (privateKeyLoc !== null) { + this.expectPlugin("destructuringPrivate", privateKeyLoc); + } + } + } class ExpressionErrors { constructor() { this.shorthandAssignLoc = null; this.doubleProtoLoc = null; + this.privateKeyLoc = null; this.optionalParametersLoc = null; } @@ -4007,9 +4115,9 @@ class NodeUtils extends UtilParser { finishNodeAt(node, type, endLoc) { node.type = type; - node.end = indexes.get(endLoc); + node.end = endLoc.index; node.loc.end = endLoc; - if (this.options.ranges) node.range[1] = node.end; + if (this.options.ranges) node.range[1] = endLoc.index; if (this.options.attachComment) this.processComment(node); return node; } @@ -4021,9 +4129,9 @@ class NodeUtils extends UtilParser { } resetEndLocation(node, endLoc = this.state.lastTokEndLoc) { - node.end = indexes.get(endLoc); + node.end = endLoc.index; node.loc.end = endLoc; - if (this.options.ranges) node.range[1] = node.end; + if (this.options.ranges) node.range[1] = endLoc.index; } resetStartLocationFromNode(node, locationNode) { @@ -4092,7 +4200,7 @@ function hasTypeImportKind(node) { } function isMaybeDefaultImport(type) { - return tokenIsKeywordOrIdentifier(type) && type !== 93; + return tokenIsKeywordOrIdentifier(type) && type !== 97; } const exportSuggestions = { @@ -4133,7 +4241,7 @@ var flow = (superClass => class extends superClass { } finishToken(type, val) { - if (type !== 125 && type !== 13 && type !== 28) { + if (type !== 129 && type !== 13 && type !== 28) { if (this.flowPragma === undefined) { this.flowPragma = null; } @@ -4171,9 +4279,9 @@ var flow = (superClass => class extends superClass { const node = this.startNode(); const moduloLoc = this.state.startLoc; this.next(); - this.expectContextual(103); + this.expectContextual(107); - if (this.state.lastTokStart > indexes.get(moduloLoc) + 1) { + if (this.state.lastTokStart > moduloLoc.index + 1) { this.raise(FlowErrors.UnexpectedSpaceBetweenModuloChecks, { at: moduloLoc }); @@ -4195,14 +4303,14 @@ var flow = (superClass => class extends superClass { let type = null; let predicate = null; - if (this.match(50)) { + if (this.match(54)) { this.state.inType = oldInType; predicate = this.flowParsePredicate(); } else { type = this.flowParseType(); this.state.inType = oldInType; - if (this.match(50)) { + if (this.match(54)) { predicate = this.flowParsePredicate(); } } @@ -4222,7 +4330,7 @@ var flow = (superClass => class extends superClass { const typeNode = this.startNode(); const typeContainer = this.startNode(); - if (this.match(45)) { + if (this.match(47)) { typeNode.typeParameters = this.flowParseTypeParameterDeclaration(); } else { typeNode.typeParameters = null; @@ -4244,13 +4352,13 @@ var flow = (superClass => class extends superClass { } flowParseDeclare(node, insideModule) { - if (this.match(76)) { + if (this.match(80)) { return this.flowParseDeclareClass(node); - } else if (this.match(64)) { + } else if (this.match(68)) { return this.flowParseDeclareFunction(node); - } else if (this.match(70)) { + } else if (this.match(74)) { return this.flowParseDeclareVariable(node); - } else if (this.eatContextual(119)) { + } else if (this.eatContextual(123)) { if (this.match(16)) { return this.flowParseDeclareModuleExports(node); } else { @@ -4262,13 +4370,13 @@ var flow = (superClass => class extends superClass { return this.flowParseDeclareModule(node); } - } else if (this.isContextual(122)) { + } else if (this.isContextual(126)) { return this.flowParseDeclareTypeAlias(node); - } else if (this.isContextual(123)) { + } else if (this.isContextual(127)) { return this.flowParseDeclareOpaqueType(node); - } else if (this.isContextual(121)) { + } else if (this.isContextual(125)) { return this.flowParseDeclareInterface(node); - } else if (this.match(78)) { + } else if (this.match(82)) { return this.flowParseDeclareExportDeclaration(node, insideModule); } else { throw this.unexpected(); @@ -4286,7 +4394,7 @@ var flow = (superClass => class extends superClass { flowParseDeclareModule(node) { this.scope.enter(SCOPE_OTHER); - if (this.match(125)) { + if (this.match(129)) { node.id = this.parseExprAtom(); } else { node.id = this.parseIdentifier(); @@ -4299,10 +4407,10 @@ var flow = (superClass => class extends superClass { while (!this.match(8)) { let bodyNode = this.startNode(); - if (this.match(79)) { + if (this.match(83)) { this.next(); - if (!this.isContextual(122) && !this.match(83)) { + if (!this.isContextual(126) && !this.match(87)) { this.raise(FlowErrors.InvalidNonTypeImportInDeclareModule, { at: this.state.lastTokStartLoc }); @@ -4310,7 +4418,7 @@ var flow = (superClass => class extends superClass { this.parseImport(bodyNode); } else { - this.expectContextual(117, FlowErrors.UnsupportedStatementInDeclareModule); + this.expectContextual(121, FlowErrors.UnsupportedStatementInDeclareModule); bodyNode = this.flowParseDeclare(bodyNode, true); } @@ -4353,10 +4461,10 @@ var flow = (superClass => class extends superClass { } flowParseDeclareExportDeclaration(node, insideModule) { - this.expect(78); + this.expect(82); - if (this.eat(61)) { - if (this.match(64) || this.match(76)) { + if (this.eat(65)) { + if (this.match(68) || this.match(80)) { node.declaration = this.flowParseDeclare(this.startNode()); } else { node.declaration = this.flowParseType(); @@ -4366,7 +4474,7 @@ var flow = (superClass => class extends superClass { node.default = true; return this.finishNode(node, "DeclareExportDeclaration"); } else { - if (this.match(71) || this.isLet() || (this.isContextual(122) || this.isContextual(121)) && !insideModule) { + if (this.match(75) || this.isLet() || (this.isContextual(126) || this.isContextual(125)) && !insideModule) { const label = this.state.value; const suggestion = exportSuggestions[label]; throw this.raise(FlowErrors.UnsupportedDeclareExportKind, { @@ -4374,11 +4482,11 @@ var flow = (superClass => class extends superClass { }, label, suggestion); } - if (this.match(70) || this.match(64) || this.match(76) || this.isContextual(123)) { + if (this.match(74) || this.match(68) || this.match(80) || this.isContextual(127)) { node.declaration = this.flowParseDeclare(this.startNode()); node.default = false; return this.finishNode(node, "DeclareExportDeclaration"); - } else if (this.match(51) || this.match(5) || this.isContextual(121) || this.isContextual(122) || this.isContextual(123)) { + } else if (this.match(55) || this.match(5) || this.isContextual(125) || this.isContextual(126) || this.isContextual(127)) { node = this.parseExport(node); if (node.type === "ExportNamedDeclaration") { @@ -4397,7 +4505,7 @@ var flow = (superClass => class extends superClass { flowParseDeclareModuleExports(node) { this.next(); - this.expectContextual(104); + this.expectContextual(108); node.typeAnnotation = this.flowParseTypeAnnotation(); this.semicolon(); return this.finishNode(node, "DeclareModuleExports"); @@ -4427,7 +4535,7 @@ var flow = (superClass => class extends superClass { node.id = this.flowParseRestrictedIdentifier(!isClass, true); this.scope.declareName(node.id.name, isClass ? BIND_FUNCTION : BIND_LEXICAL, node.id.loc.start); - if (this.match(45)) { + if (this.match(47)) { node.typeParameters = this.flowParseTypeParameterDeclaration(); } else { node.typeParameters = null; @@ -4437,13 +4545,13 @@ var flow = (superClass => class extends superClass { node.implements = []; node.mixins = []; - if (this.eat(77)) { + if (this.eat(81)) { do { node.extends.push(this.flowParseInterfaceExtends()); } while (!isClass && this.eat(12)); } - if (this.isContextual(110)) { + if (this.isContextual(114)) { this.next(); do { @@ -4451,7 +4559,7 @@ var flow = (superClass => class extends superClass { } while (this.eat(12)); } - if (this.isContextual(106)) { + if (this.isContextual(110)) { this.next(); do { @@ -4472,7 +4580,7 @@ var flow = (superClass => class extends superClass { const node = this.startNode(); node.id = this.flowParseQualifiedTypeIdentifier(); - if (this.match(45)) { + if (this.match(47)) { node.typeParameters = this.flowParseTypeParameterInstantiation(); } else { node.typeParameters = null; @@ -4510,7 +4618,7 @@ var flow = (superClass => class extends superClass { node.id = this.flowParseRestrictedIdentifier(false, true); this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.loc.start); - if (this.match(45)) { + if (this.match(47)) { node.typeParameters = this.flowParseTypeParameterDeclaration(); } else { node.typeParameters = null; @@ -4522,11 +4630,11 @@ var flow = (superClass => class extends superClass { } flowParseOpaqueType(node, declare) { - this.expectContextual(122); + this.expectContextual(126); node.id = this.flowParseRestrictedIdentifier(true, true); this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.loc.start); - if (this.match(45)) { + if (this.match(47)) { node.typeParameters = this.flowParseTypeParameterDeclaration(); } else { node.typeParameters = null; @@ -4577,7 +4685,7 @@ var flow = (superClass => class extends superClass { node.params = []; this.state.inType = true; - if (this.match(45) || this.match(134)) { + if (this.match(47) || this.match(138)) { this.next(); } else { this.unexpected(); @@ -4593,12 +4701,12 @@ var flow = (superClass => class extends superClass { defaultRequired = true; } - if (!this.match(46)) { + if (!this.match(48)) { this.expect(12); } - } while (!this.match(46)); + } while (!this.match(48)); - this.expect(46); + this.expect(48); this.state.inType = oldInType; return this.finishNode(node, "TypeParameterDeclaration"); } @@ -4608,20 +4716,20 @@ var flow = (superClass => class extends superClass { const oldInType = this.state.inType; node.params = []; this.state.inType = true; - this.expect(45); + this.expect(47); const oldNoAnonFunctionType = this.state.noAnonFunctionType; this.state.noAnonFunctionType = false; - while (!this.match(46)) { + while (!this.match(48)) { node.params.push(this.flowParseType()); - if (!this.match(46)) { + if (!this.match(48)) { this.expect(12); } } this.state.noAnonFunctionType = oldNoAnonFunctionType; - this.expect(46); + this.expect(48); this.state.inType = oldInType; return this.finishNode(node, "TypeParameterInstantiation"); } @@ -4631,27 +4739,27 @@ var flow = (superClass => class extends superClass { const oldInType = this.state.inType; node.params = []; this.state.inType = true; - this.expect(45); + this.expect(47); - while (!this.match(46)) { + while (!this.match(48)) { node.params.push(this.flowParseTypeOrImplicitInstantiation()); - if (!this.match(46)) { + if (!this.match(48)) { this.expect(12); } } - this.expect(46); + this.expect(48); this.state.inType = oldInType; return this.finishNode(node, "TypeParameterInstantiation"); } flowParseInterfaceType() { const node = this.startNode(); - this.expectContextual(121); + this.expectContextual(125); node.extends = []; - if (this.eat(77)) { + if (this.eat(81)) { do { node.extends.push(this.flowParseInterfaceExtends()); } while (this.eat(12)); @@ -4668,7 +4776,7 @@ var flow = (superClass => class extends superClass { } flowParseObjectPropertyKey() { - return this.match(126) || this.match(125) ? this.parseExprAtom() : this.parseIdentifier(true); + return this.match(130) || this.match(129) ? this.parseExprAtom() : this.parseIdentifier(true); } flowParseObjectTypeIndexer(node, isStatic, variance) { @@ -4694,7 +4802,7 @@ var flow = (superClass => class extends superClass { this.expect(3); this.expect(3); - if (this.match(45) || this.match(10)) { + if (this.match(47) || this.match(10)) { node.method = true; node.optional = false; node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.start, node.loc.start)); @@ -4717,13 +4825,13 @@ var flow = (superClass => class extends superClass { node.typeParameters = null; node.this = null; - if (this.match(45)) { + if (this.match(47)) { node.typeParameters = this.flowParseTypeParameterDeclaration(); } this.expect(10); - if (this.match(74)) { + if (this.match(78)) { node.this = this.flowParseFunctionTypeParam(true); node.this.name = null; @@ -4792,7 +4900,7 @@ var flow = (superClass => class extends superClass { let inexactStartLoc = null; const node = this.startNode(); - if (allowProto && this.isContextual(111)) { + if (allowProto && this.isContextual(115)) { const lookahead = this.lookahead(); if (lookahead.type !== 14 && lookahead.type !== 17) { @@ -4802,7 +4910,7 @@ var flow = (superClass => class extends superClass { } } - if (allowStatic && this.isContextual(100)) { + if (allowStatic && this.isContextual(104)) { const lookahead = this.lookahead(); if (lookahead.type !== 14 && lookahead.type !== 17) { @@ -4827,7 +4935,7 @@ var flow = (superClass => class extends superClass { } else { nodeStart.indexers.push(this.flowParseObjectTypeIndexer(node, isStatic, variance)); } - } else if (this.match(10) || this.match(45)) { + } else if (this.match(10) || this.match(47)) { if (protoStartLoc != null) { this.unexpected(protoStartLoc); } @@ -4840,7 +4948,7 @@ var flow = (superClass => class extends superClass { } else { let kind = "init"; - if (this.isContextual(94) || this.isContextual(99)) { + if (this.isContextual(98) || this.isContextual(103)) { const lookahead = this.lookahead(); if (tokenIsLiteralPropertyName(lookahead.type)) { @@ -4928,7 +5036,7 @@ var flow = (superClass => class extends superClass { node.kind = kind; let optional = false; - if (this.match(45) || this.match(10)) { + if (this.match(47) || this.match(10)) { node.method = true; if (protoStartLoc != null) { @@ -5016,7 +5124,7 @@ var flow = (superClass => class extends superClass { node.typeParameters = null; node.id = this.flowParseQualifiedTypeIdentifier(startPos, startLoc, id); - if (this.match(45)) { + if (this.match(47)) { node.typeParameters = this.flowParseTypeParameterInstantiation(); } @@ -5025,7 +5133,7 @@ var flow = (superClass => class extends superClass { flowParseTypeofType() { const node = this.startNode(); - this.expect(83); + this.expect(87); node.argument = this.flowParsePrimaryType(); return this.finishNode(node, "TypeofTypeAnnotation"); } @@ -5051,7 +5159,7 @@ var flow = (superClass => class extends superClass { let typeAnnotation = null; const node = this.startNode(); const lh = this.lookahead(); - const isThis = this.state.type === 74; + const isThis = this.state.type === 78; if (lh.type === 14 || lh.type === 17) { if (isThis && !first) { @@ -5095,7 +5203,7 @@ var flow = (superClass => class extends superClass { let rest = null; let _this = null; - if (this.match(74)) { + if (this.match(78)) { _this = this.flowParseFunctionTypeParam(true); _this.name = null; @@ -5187,7 +5295,7 @@ var flow = (superClass => class extends superClass { this.state.noAnonFunctionType = oldNoAnonFunctionType; return type; - case 45: + case 47: node.typeParameters = this.flowParseTypeParameterDeclaration(); this.expect(10); tmp = this.flowParseFunctionTypeParams(); @@ -5203,7 +5311,7 @@ var flow = (superClass => class extends superClass { this.next(); if (!this.match(11) && !this.match(21)) { - if (tokenIsIdentifier(this.state.type) || this.match(74)) { + if (tokenIsIdentifier(this.state.type) || this.match(78)) { const token = this.lookahead().type; isGroupedType = token !== 17 && token !== 14; } else { @@ -5239,24 +5347,24 @@ var flow = (superClass => class extends superClass { node.typeParameters = null; return this.finishNode(node, "FunctionTypeAnnotation"); - case 125: + case 129: return this.parseLiteral(this.state.value, "StringLiteralTypeAnnotation"); - case 81: - case 82: - node.value = this.match(81); + case 85: + case 86: + node.value = this.match(85); this.next(); return this.finishNode(node, "BooleanLiteralTypeAnnotation"); - case 49: + case 53: if (this.state.value === "-") { this.next(); - if (this.match(126)) { + if (this.match(130)) { return this.parseLiteralAtNode(-this.state.value, "NumberLiteralTypeAnnotation", node); } - if (this.match(127)) { + if (this.match(131)) { return this.parseLiteralAtNode(-this.state.value, "BigIntLiteralTypeAnnotation", node); } @@ -5267,29 +5375,29 @@ var flow = (superClass => class extends superClass { throw this.unexpected(); - case 126: + case 130: return this.parseLiteral(this.state.value, "NumberLiteralTypeAnnotation"); - case 127: + case 131: return this.parseLiteral(this.state.value, "BigIntLiteralTypeAnnotation"); - case 84: + case 88: this.next(); return this.finishNode(node, "VoidTypeAnnotation"); - case 80: + case 84: this.next(); return this.finishNode(node, "NullLiteralTypeAnnotation"); - case 74: + case 78: this.next(); return this.finishNode(node, "ThisTypeAnnotation"); - case 51: + case 55: this.next(); return this.finishNode(node, "ExistsTypeAnnotation"); - case 83: + case 87: return this.flowParseTypeofType(); default: @@ -5298,7 +5406,7 @@ var flow = (superClass => class extends superClass { this.next(); return super.createIdentifier(node, label); } else if (tokenIsIdentifier(this.state.type)) { - if (this.isContextual(121)) { + if (this.isContextual(125)) { return this.flowParseInterfaceType(); } @@ -5372,11 +5480,11 @@ var flow = (superClass => class extends superClass { flowParseIntersectionType() { const node = this.startNode(); - this.eat(43); + this.eat(45); const type = this.flowParseAnonFunctionWithoutParens(); node.types = [type]; - while (this.eat(43)) { + while (this.eat(45)) { node.types.push(this.flowParseAnonFunctionWithoutParens()); } @@ -5385,11 +5493,11 @@ var flow = (superClass => class extends superClass { flowParseUnionType() { const node = this.startNode(); - this.eat(41); + this.eat(43); const type = this.flowParseIntersectionType(); node.types = [type]; - while (this.eat(41)) { + while (this.eat(43)) { node.types.push(this.flowParseIntersectionType()); } @@ -5405,7 +5513,7 @@ var flow = (superClass => class extends superClass { } flowParseTypeOrImplicitInstantiation() { - if (this.state.type === 124 && this.state.value === "_") { + if (this.state.type === 128 && this.state.value === "_") { const startPos = this.state.start; const startLoc = this.state.startLoc; const node = this.parseIdentifier(); @@ -5441,7 +5549,7 @@ var flow = (superClass => class extends superClass { flowParseVariance() { let variance = null; - if (this.match(49)) { + if (this.match(53)) { variance = this.startNode(); if (this.state.value === "+") { @@ -5476,7 +5584,7 @@ var flow = (superClass => class extends superClass { } parseStatement(context, topLevel) { - if (this.state.strict && this.isContextual(121)) { + if (this.state.strict && this.isContextual(125)) { const lookahead = this.lookahead(); if (tokenIsKeywordOrIdentifier(lookahead.type)) { @@ -5484,7 +5592,7 @@ var flow = (superClass => class extends superClass { this.next(); return this.flowParseInterface(node); } - } else if (this.shouldParseEnums() && this.isContextual(118)) { + } else if (this.shouldParseEnums() && this.isContextual(122)) { const node = this.startNode(); this.next(); return this.flowParseEnumDeclaration(node); @@ -5502,7 +5610,7 @@ var flow = (superClass => class extends superClass { parseExpressionStatement(node, expr) { if (expr.type === "Identifier") { if (expr.name === "declare") { - if (this.match(76) || tokenIsIdentifier(this.state.type) || this.match(64) || this.match(70) || this.match(78)) { + if (this.match(80) || tokenIsIdentifier(this.state.type) || this.match(68) || this.match(74) || this.match(82)) { return this.flowParseDeclare(node); } } else if (tokenIsIdentifier(this.state.type)) { @@ -5524,7 +5632,7 @@ var flow = (superClass => class extends superClass { type } = this.state; - if (tokenIsFlowInterfaceOrTypeOrOpaque(type) || this.shouldParseEnums() && type === 118) { + if (tokenIsFlowInterfaceOrTypeOrOpaque(type) || this.shouldParseEnums() && type === 122) { return !this.state.containsEsc; } @@ -5536,7 +5644,7 @@ var flow = (superClass => class extends superClass { type } = this.state; - if (tokenIsFlowInterfaceOrTypeOrOpaque(type) || this.shouldParseEnums() && type === 118) { + if (tokenIsFlowInterfaceOrTypeOrOpaque(type) || this.shouldParseEnums() && type === 122) { return this.state.containsEsc; } @@ -5544,7 +5652,7 @@ var flow = (superClass => class extends superClass { } parseExportDefaultExpression() { - if (this.shouldParseEnums() && this.isContextual(118)) { + if (this.shouldParseEnums() && this.isContextual(122)) { const node = this.startNode(); this.next(); return this.flowParseEnumDeclaration(node); @@ -5719,7 +5827,7 @@ var flow = (superClass => class extends superClass { } parseExportDeclaration(node) { - if (this.isContextual(122)) { + if (this.isContextual(126)) { node.exportKind = "type"; const declarationNode = this.startNode(); this.next(); @@ -5731,17 +5839,17 @@ var flow = (superClass => class extends superClass { } else { return this.flowParseTypeAlias(declarationNode); } - } else if (this.isContextual(123)) { + } else if (this.isContextual(127)) { node.exportKind = "type"; const declarationNode = this.startNode(); this.next(); return this.flowParseOpaqueType(declarationNode, false); - } else if (this.isContextual(121)) { + } else if (this.isContextual(125)) { node.exportKind = "type"; const declarationNode = this.startNode(); this.next(); return this.flowParseInterface(declarationNode); - } else if (this.shouldParseEnums() && this.isContextual(118)) { + } else if (this.shouldParseEnums() && this.isContextual(122)) { node.exportKind = "value"; const declarationNode = this.startNode(); this.next(); @@ -5754,7 +5862,7 @@ var flow = (superClass => class extends superClass { eatExportStar(node) { if (super.eatExportStar(...arguments)) return true; - if (this.isContextual(122) && this.lookahead().type === 51) { + if (this.isContextual(126) && this.lookahead().type === 55) { node.exportKind = "type"; this.next(); this.next(); @@ -5780,7 +5888,7 @@ var flow = (superClass => class extends superClass { parseClassId(node, isStatement, optionalId) { super.parseClassId(node, isStatement, optionalId); - if (this.match(45)) { + if (this.match(47)) { node.typeParameters = this.flowParseTypeParameterDeclaration(); } } @@ -5790,7 +5898,7 @@ var flow = (superClass => class extends superClass { startLoc } = this.state; - if (this.isContextual(117)) { + if (this.isContextual(121)) { if (this.parseClassMemberFromModifier(classBody, member)) { return; } @@ -5827,7 +5935,7 @@ var flow = (superClass => class extends superClass { }, fullWord); } - this.finishToken(124, fullWord); + this.finishToken(128, fullWord); } getTokenFromCode(code) { @@ -5836,14 +5944,14 @@ var flow = (superClass => class extends superClass { if (code === 123 && next === 124) { return this.finishOp(6, 2); } else if (this.state.inType && (code === 62 || code === 60)) { - return this.finishOp(code === 62 ? 46 : 45, 1); + return this.finishOp(code === 62 ? 48 : 47, 1); } else if (this.state.inType && code === 63) { if (next === 46) { return this.finishOp(18, 2); } return this.finishOp(17, 1); - } else if (isIteratorStart(code, next)) { + } else if (isIteratorStart(code, next, this.input.charCodeAt(this.state.pos + 2))) { this.state.pos += 2; return this.readIterator(); } else { @@ -5928,7 +6036,7 @@ var flow = (superClass => class extends superClass { } isClassMethod() { - return this.match(45) || super.isClassMethod(); + return this.match(47) || super.isClassMethod(); } isClassProperty() { @@ -5946,7 +6054,7 @@ var flow = (superClass => class extends superClass { delete method.variance; - if (this.match(45)) { + if (this.match(47)) { method.typeParameters = this.flowParseTypeParameterDeclaration(); } @@ -5978,7 +6086,7 @@ var flow = (superClass => class extends superClass { delete method.variance; - if (this.match(45)) { + if (this.match(47)) { method.typeParameters = this.flowParseTypeParameterDeclaration(); } @@ -5988,11 +6096,11 @@ var flow = (superClass => class extends superClass { parseClassSuper(node) { super.parseClassSuper(node); - if (node.superClass && this.match(45)) { + if (node.superClass && this.match(47)) { node.superTypeParameters = this.flowParseTypeParameterInstantiation(); } - if (this.isContextual(106)) { + if (this.isContextual(110)) { this.next(); const implemented = node.implements = []; @@ -6000,7 +6108,7 @@ var flow = (superClass => class extends superClass { const node = this.startNode(); node.id = this.flowParseRestrictedIdentifier(true); - if (this.match(45)) { + if (this.match(47)) { node.typeParameters = this.flowParseTypeParameterInstantiation(); } else { node.typeParameters = null; @@ -6042,7 +6150,7 @@ var flow = (superClass => class extends superClass { delete prop.variance; let typeParameters; - if (this.match(45) && !isAccessor) { + if (this.match(47) && !isAccessor) { typeParameters = this.flowParseTypeParameterDeclaration(); if (!this.match(10)) this.unexpected(); } @@ -6119,9 +6227,9 @@ var flow = (superClass => class extends superClass { node.importKind = "value"; let kind = null; - if (this.match(83)) { + if (this.match(87)) { kind = "typeof"; - } else if (this.isContextual(122)) { + } else if (this.isContextual(126)) { kind = "type"; } @@ -6131,11 +6239,11 @@ var flow = (superClass => class extends superClass { type } = lh; - if (kind === "type" && type === 51) { + if (kind === "type" && type === 55) { this.unexpected(null, lh.type); } - if (isMaybeDefaultImport(type) || type === 5 || type === 51) { + if (isMaybeDefaultImport(type) || type === 5 || type === 55) { this.next(); node.importKind = kind; } @@ -6158,7 +6266,7 @@ var flow = (superClass => class extends superClass { let isBinding = false; - if (this.isContextual(89) && !this.isLookaheadContextual("as")) { + if (this.isContextual(93) && !this.isLookaheadContextual("as")) { const as_ident = this.parseIdentifier(true); if (specifierTypeKind !== null && !tokenIsKeywordOrIdentifier(this.state.type)) { @@ -6185,7 +6293,7 @@ var flow = (superClass => class extends superClass { specifier.importKind = null; } - if (this.eatContextual(89)) { + if (this.eatContextual(93)) { specifier.local = this.parseIdentifier(); } else { isBinding = true; @@ -6215,7 +6323,7 @@ var flow = (superClass => class extends superClass { parseBindingAtom() { switch (this.state.type) { - case 74: + case 78: return this.parseIdentifier(true); default: @@ -6226,7 +6334,7 @@ var flow = (superClass => class extends superClass { parseFunctionParams(node, allowModifiers) { const kind = node.kind; - if (kind !== "get" && kind !== "set" && this.match(45)) { + if (kind !== "get" && kind !== "set" && this.match(47)) { node.typeParameters = this.flowParseTypeParameterDeclaration(); } @@ -6263,7 +6371,7 @@ var flow = (superClass => class extends superClass { let state = null; let jsx; - if (this.hasPlugin("jsx") && (this.match(134) || this.match(45))) { + if (this.hasPlugin("jsx") && (this.match(138) || this.match(47))) { state = this.state.clone(); jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state); if (!jsx.error) return jsx.node; @@ -6277,7 +6385,7 @@ var flow = (superClass => class extends superClass { } } - if ((_jsx = jsx) != null && _jsx.error || this.match(45)) { + if ((_jsx = jsx) != null && _jsx.error || this.match(47)) { var _jsx2, _jsx3; state = state || this.state.clone(); @@ -6393,7 +6501,7 @@ var flow = (superClass => class extends superClass { node.callee = base; node.arguments = this.parseCallExpressionArguments(11, false); base = this.finishNode(node, "CallExpression"); - } else if (base.type === "Identifier" && base.name === "async" && this.match(45)) { + } else if (base.type === "Identifier" && base.name === "async" && this.match(47)) { const state = this.state.clone(); const arrow = this.tryParse(abort => this.parseAsyncArrowWithTypeParameters(startPos, startLoc) || abort(), state); if (!arrow.error && !arrow.aborted) return arrow.node; @@ -6433,7 +6541,7 @@ var flow = (superClass => class extends superClass { node.arguments = this.parseCallExpressionArguments(11, false); node.optional = true; return this.finishCallExpression(node, true); - } else if (!noCalls && this.shouldParseTypes() && this.match(45)) { + } else if (!noCalls && this.shouldParseTypes() && this.match(47)) { const node = this.startNodeAt(startPos, startLoc); node.callee = base; const result = this.tryParse(() => { @@ -6456,7 +6564,7 @@ var flow = (superClass => class extends superClass { parseNewArguments(node) { let targs = null; - if (this.shouldParseTypes() && this.match(45)) { + if (this.shouldParseTypes() && this.match(47)) { targs = this.tryParse(() => this.flowParseTypeParameterInstantiationCallOrNew()).node; } @@ -6626,7 +6734,7 @@ var flow = (superClass => class extends superClass { const endOfInit = () => this.match(12) || this.match(8); switch (this.state.type) { - case 126: + case 130: { const literal = this.parseNumericLiteral(this.state.value); @@ -6644,7 +6752,7 @@ var flow = (superClass => class extends superClass { }; } - case 125: + case 129: { const literal = this.parseStringLiteral(this.state.value); @@ -6662,10 +6770,10 @@ var flow = (superClass => class extends superClass { }; } - case 81: - case 82: + case 85: + case 86: { - const literal = this.parseBooleanLiteral(this.match(81)); + const literal = this.parseBooleanLiteral(this.match(85)); if (endOfInit()) { return { @@ -6853,7 +6961,7 @@ var flow = (superClass => class extends superClass { flowEnumParseExplicitType({ enumName }) { - if (this.eatContextual(97)) { + if (this.eatContextual(101)) { if (!tokenIsIdentifier(this.state.type)) { throw this.flowEnumErrorInvalidExplicitType(this.state.startLoc, { enumName, @@ -7307,14 +7415,14 @@ var jsx = (superClass => class extends superClass { if (this.state.pos === this.state.start) { if (ch === 60 && this.state.canStartJSXElement) { ++this.state.pos; - return this.finishToken(134); + return this.finishToken(138); } return super.getTokenFromCode(ch); } out += this.input.slice(chunkStart, this.state.pos); - return this.finishToken(133, out); + return this.finishToken(137, out); case 38: out += this.input.slice(chunkStart, this.state.pos); @@ -7383,7 +7491,7 @@ var jsx = (superClass => class extends superClass { } out += this.input.slice(chunkStart, this.state.pos++); - return this.finishToken(125, out); + return this.finishToken(129, out); } jsxReadEntity() { @@ -7437,13 +7545,13 @@ var jsx = (superClass => class extends superClass { ch = this.input.charCodeAt(++this.state.pos); } while (isIdentifierChar(ch) || ch === 45); - return this.finishToken(132, this.input.slice(start, this.state.pos)); + return this.finishToken(136, this.input.slice(start, this.state.pos)); } jsxParseIdentifier() { const node = this.startNode(); - if (this.match(132)) { + if (this.match(136)) { node.name = this.state.value; } else if (tokenIsKeyword(this.state.type)) { node.name = tokenLabelName(this.state.type); @@ -7503,8 +7611,8 @@ var jsx = (superClass => class extends superClass { return node; - case 134: - case 125: + case 138: + case 129: return this.parseExprAtom(); default: @@ -7515,7 +7623,7 @@ var jsx = (superClass => class extends superClass { } jsxParseEmptyExpression() { - const node = this.startNodeAt(indexes.get(this.state.lastTokEndLoc), this.state.lastTokEndLoc); + const node = this.startNodeAt(this.state.lastTokEndLoc.index, this.state.lastTokEndLoc); return this.finishNodeAt(node, "JSXEmptyExpression", this.state.startLoc); } @@ -7561,8 +7669,8 @@ var jsx = (superClass => class extends superClass { jsxParseOpeningElementAt(startPos, startLoc) { const node = this.startNodeAt(startPos, startLoc); - if (this.match(135)) { - this.expect(135); + if (this.match(139)) { + this.expect(139); return this.finishNode(node, "JSXOpeningFragment"); } @@ -7573,26 +7681,26 @@ var jsx = (superClass => class extends superClass { jsxParseOpeningElementAfterName(node) { const attributes = []; - while (!this.match(52) && !this.match(135)) { + while (!this.match(56) && !this.match(139)) { attributes.push(this.jsxParseAttribute()); } node.attributes = attributes; - node.selfClosing = this.eat(52); - this.expect(135); + node.selfClosing = this.eat(56); + this.expect(139); return this.finishNode(node, "JSXOpeningElement"); } jsxParseClosingElementAt(startPos, startLoc) { const node = this.startNodeAt(startPos, startLoc); - if (this.match(135)) { - this.expect(135); + if (this.match(139)) { + this.expect(139); return this.finishNode(node, "JSXClosingFragment"); } node.name = this.jsxParseElementName(); - this.expect(135); + this.expect(139); return this.finishNode(node, "JSXClosingElement"); } @@ -7605,12 +7713,12 @@ var jsx = (superClass => class extends superClass { if (!openingElement.selfClosing) { contents: for (;;) { switch (this.state.type) { - case 134: + case 138: startPos = this.state.start; startLoc = this.state.startLoc; this.next(); - if (this.eat(52)) { + if (this.eat(56)) { closingElement = this.jsxParseClosingElementAt(startPos, startLoc); break contents; } @@ -7618,7 +7726,7 @@ var jsx = (superClass => class extends superClass { children.push(this.jsxParseElementAt(startPos, startLoc)); break; - case 133: + case 137: children.push(this.parseExprAtom()); break; @@ -7669,7 +7777,7 @@ var jsx = (superClass => class extends superClass { node.children = children; - if (this.match(45)) { + if (this.match(47)) { throw this.raise(JsxErrors.UnwrappedAdjacentJSXElements, { at: this.state.startLoc }); @@ -7693,12 +7801,12 @@ var jsx = (superClass => class extends superClass { } parseExprAtom(refExpressionErrors) { - if (this.match(133)) { + if (this.match(137)) { return this.parseLiteral(this.state.value, "JSXText"); - } else if (this.match(134)) { + } else if (this.match(138)) { return this.jsxParseElement(); - } else if (this.match(45) && this.input.charCodeAt(this.state.pos) !== 33) { - this.replaceToken(134); + } else if (this.match(47) && this.input.charCodeAt(this.state.pos) !== 33) { + this.replaceToken(138); return this.jsxParseElement(); } else { return super.parseExprAtom(refExpressionErrors); @@ -7724,7 +7832,7 @@ var jsx = (superClass => class extends superClass { if (code === 62) { ++this.state.pos; - return this.finishToken(135); + return this.finishToken(139); } if ((code === 34 || code === 39) && context === types.j_oTag) { @@ -7734,7 +7842,7 @@ var jsx = (superClass => class extends superClass { if (code === 60 && this.state.canStartJSXElement && this.input.charCodeAt(this.state.pos + 1) !== 33) { ++this.state.pos; - return this.finishToken(134); + return this.finishToken(138); } return super.getTokenFromCode(code); @@ -7746,15 +7854,15 @@ var jsx = (superClass => class extends superClass { type } = this.state; - if (type === 52 && prevType === 134) { + if (type === 56 && prevType === 138) { context.splice(-2, 2, types.j_cTag); this.state.canStartJSXElement = false; - } else if (type === 134) { + } else if (type === 138) { context.push(types.j_oTag); - } else if (type === 135) { + } else if (type === 139) { const out = context[context.length - 1]; - if (out === types.j_oTag && prevType === 52 || out === types.j_cTag) { + if (out === types.j_oTag && prevType === 56 || out === types.j_cTag) { context.pop(); this.state.canStartJSXElement = context[context.length - 1] === types.j_expr; } else { @@ -7970,7 +8078,7 @@ var typescript = (superClass => class extends superClass { } tsTokenCanFollowModifier() { - return (this.match(0) || this.match(5) || this.match(51) || this.match(21) || this.match(130) || this.isLiteralPropertyName()) && !this.hasPrecedingLineBreak(); + return (this.match(0) || this.match(5) || this.match(55) || this.match(21) || this.match(134) || this.isLiteralPropertyName()) && !this.hasPrecedingLineBreak(); } tsNextTokenCanFollowModifier() { @@ -8071,7 +8179,7 @@ var typescript = (superClass => class extends superClass { return this.match(3); case "TypeParametersOrArguments": - return this.match(46); + return this.match(48); } throw new Error("Unreachable"); @@ -8137,7 +8245,7 @@ var typescript = (superClass => class extends superClass { if (bracket) { this.expect(0); } else { - this.expect(45); + this.expect(47); } } @@ -8146,7 +8254,7 @@ var typescript = (superClass => class extends superClass { if (bracket) { this.expect(3); } else { - this.expect(46); + this.expect(48); } return result; @@ -8154,10 +8262,10 @@ var typescript = (superClass => class extends superClass { tsParseImportType() { const node = this.startNode(); - this.expect(79); + this.expect(83); this.expect(10); - if (!this.match(125)) { + if (!this.match(129)) { this.raise(TSErrors.UnsupportedImportTypeArgument, { at: this.state.startLoc }); @@ -8170,7 +8278,7 @@ var typescript = (superClass => class extends superClass { node.qualifier = this.tsParseEntityName(true); } - if (this.match(45)) { + if (this.match(47)) { node.typeParameters = this.tsParseTypeArguments(); } @@ -8194,7 +8302,7 @@ var typescript = (superClass => class extends superClass { const node = this.startNode(); node.typeName = this.tsParseEntityName(false); - if (!this.hasPrecedingLineBreak() && this.match(45)) { + if (!this.hasPrecedingLineBreak() && this.match(47)) { node.typeParameters = this.tsParseTypeArguments(); } @@ -8218,9 +8326,9 @@ var typescript = (superClass => class extends superClass { tsParseTypeQuery() { const node = this.startNode(); - this.expect(83); + this.expect(87); - if (this.match(79)) { + if (this.match(83)) { node.exprName = this.tsParseImportType(); } else { node.exprName = this.tsParseEntityName(true); @@ -8232,13 +8340,13 @@ var typescript = (superClass => class extends superClass { tsParseTypeParameter() { const node = this.startNode(); node.name = this.tsParseTypeParameterName(); - node.constraint = this.tsEatThenParseType(77); + node.constraint = this.tsEatThenParseType(81); node.default = this.tsEatThenParseType(29); return this.finishNode(node, "TSTypeParameter"); } tsTryParseTypeParameters() { - if (this.match(45)) { + if (this.match(47)) { return this.tsParseTypeParameters(); } } @@ -8246,7 +8354,7 @@ var typescript = (superClass => class extends superClass { tsParseTypeParameters() { const node = this.startNode(); - if (this.match(45) || this.match(134)) { + if (this.match(47) || this.match(138)) { this.next(); } else { this.unexpected(); @@ -8271,7 +8379,7 @@ var typescript = (superClass => class extends superClass { } tsTryNextParseConstantContext() { - if (this.lookahead().type === 71) { + if (this.lookahead().type === 75) { this.next(); return this.tsParseTypeReference(); } @@ -8350,7 +8458,7 @@ var typescript = (superClass => class extends superClass { if (this.eat(17)) node.optional = true; const nodeAny = node; - if (this.match(10) || this.match(45)) { + if (this.match(10) || this.match(47)) { if (readonly) { this.raise(TSErrors.ReadonlyForMethodSignature, { node @@ -8359,7 +8467,7 @@ var typescript = (superClass => class extends superClass { const method = nodeAny; - if (method.kind && this.match(45)) { + if (method.kind && this.match(47)) { this.raise(TSErrors.AccesorCannotHaveTypeParameters, { at: this.state.curPosition() }); @@ -8432,15 +8540,15 @@ var typescript = (superClass => class extends superClass { tsParseTypeMember() { const node = this.startNode(); - if (this.match(10) || this.match(45)) { + if (this.match(10) || this.match(47)) { return this.tsParseSignatureMember("TSCallSignatureDeclaration", node); } - if (this.match(73)) { + if (this.match(77)) { const id = this.startNode(); this.next(); - if (this.match(10) || this.match(45)) { + if (this.match(10) || this.match(47)) { return this.tsParseSignatureMember("TSConstructSignatureDeclaration", node); } else { node.key = this.createIdentifier(id, "new"); @@ -8481,11 +8589,11 @@ var typescript = (superClass => class extends superClass { tsIsStartOfMappedType() { this.next(); - if (this.eat(49)) { - return this.isContextual(114); + if (this.eat(53)) { + return this.isContextual(118); } - if (this.isContextual(114)) { + if (this.isContextual(118)) { this.next(); } @@ -8500,13 +8608,13 @@ var typescript = (superClass => class extends superClass { } this.next(); - return this.match(54); + return this.match(58); } tsParseMappedTypeParameter() { const node = this.startNode(); node.name = this.tsParseTypeParameterName(); - node.constraint = this.tsExpectThenParseType(54); + node.constraint = this.tsExpectThenParseType(58); return this.finishNode(node, "TSTypeParameter"); } @@ -8514,20 +8622,20 @@ var typescript = (superClass => class extends superClass { const node = this.startNode(); this.expect(5); - if (this.match(49)) { + if (this.match(53)) { node.readonly = this.state.value; this.next(); - this.expectContextual(114); - } else if (this.eatContextual(114)) { + this.expectContextual(118); + } else if (this.eatContextual(118)) { node.readonly = true; } this.expect(0); node.typeParameter = this.tsParseMappedTypeParameter(); - node.nameType = this.eatContextual(89) ? this.tsParseType() : null; + node.nameType = this.eatContextual(93) ? this.tsParseType() : null; this.expect(3); - if (this.match(49)) { + if (this.match(53)) { node.optional = this.state.value; this.next(); this.expect(17); @@ -8644,11 +8752,11 @@ var typescript = (superClass => class extends superClass { node.literal = (() => { switch (this.state.type) { - case 126: - case 127: - case 125: - case 81: - case 82: + case 130: + case 131: + case 129: + case 85: + case 86: return this.parseExprAtom(); default: @@ -8673,7 +8781,7 @@ var typescript = (superClass => class extends superClass { tsParseThisTypeOrThisTypePredicate() { const thisKeyword = this.tsParseThisTypeNode(); - if (this.isContextual(109) && !this.hasPrecedingLineBreak()) { + if (this.isContextual(113) && !this.hasPrecedingLineBreak()) { return this.tsParseThisTypePredicate(thisKeyword); } else { return thisKeyword; @@ -8682,19 +8790,19 @@ var typescript = (superClass => class extends superClass { tsParseNonArrayType() { switch (this.state.type) { - case 125: - case 126: - case 127: - case 81: - case 82: + case 129: + case 130: + case 131: + case 85: + case 86: return this.tsParseLiteralTypeNode(); - case 49: + case 53: if (this.state.value === "-") { const node = this.startNode(); const nextToken = this.lookahead(); - if (nextToken.type !== 126 && nextToken.type !== 127) { + if (nextToken.type !== 130 && nextToken.type !== 131) { throw this.unexpected(); } @@ -8704,13 +8812,13 @@ var typescript = (superClass => class extends superClass { break; - case 74: + case 78: return this.tsParseThisTypeOrThisTypePredicate(); - case 83: + case 87: return this.tsParseTypeQuery(); - case 79: + case 83: return this.tsParseImportType(); case 5: @@ -8732,8 +8840,8 @@ var typescript = (superClass => class extends superClass { type } = this.state; - if (tokenIsIdentifier(type) || type === 84 || type === 80) { - const nodeType = type === 84 ? "TSVoidKeyword" : type === 80 ? "TSNullKeyword" : keywordTypeFromName(this.state.value); + if (tokenIsIdentifier(type) || type === 88 || type === 84) { + const nodeType = type === 88 ? "TSVoidKeyword" : type === 84 ? "TSNullKeyword" : keywordTypeFromName(this.state.value); if (nodeType !== undefined && this.lookaheadCharCode() !== 46) { const node = this.startNode(); @@ -8799,7 +8907,7 @@ var typescript = (superClass => class extends superClass { tsParseInferType() { const node = this.startNode(); - this.expectContextual(108); + this.expectContextual(112); const typeParameter = this.startNode(); typeParameter.name = this.tsParseTypeParameterName(); node.typeParameter = this.finishNode(typeParameter, "TSTypeParameter"); @@ -8808,7 +8916,7 @@ var typescript = (superClass => class extends superClass { tsParseTypeOperatorOrHigher() { const isTypeOperator = tokenIsTSTypeOperator(this.state.type) && !this.state.containsEsc; - return isTypeOperator ? this.tsParseTypeOperator() : this.isContextual(108) ? this.tsParseInferType() : this.tsParseArrayTypeOrHigher(); + return isTypeOperator ? this.tsParseTypeOperator() : this.isContextual(112) ? this.tsParseInferType() : this.tsParseArrayTypeOrHigher(); } tsParseUnionOrIntersectionType(kind, parseConstituentType, operator) { @@ -8829,15 +8937,15 @@ var typescript = (superClass => class extends superClass { } tsParseIntersectionTypeOrHigher() { - return this.tsParseUnionOrIntersectionType("TSIntersectionType", this.tsParseTypeOperatorOrHigher.bind(this), 43); + return this.tsParseUnionOrIntersectionType("TSIntersectionType", this.tsParseTypeOperatorOrHigher.bind(this), 45); } tsParseUnionTypeOrHigher() { - return this.tsParseUnionOrIntersectionType("TSUnionType", this.tsParseIntersectionTypeOrHigher.bind(this), 41); + return this.tsParseUnionOrIntersectionType("TSUnionType", this.tsParseIntersectionTypeOrHigher.bind(this), 43); } tsIsStartOfFunctionType() { - if (this.match(45)) { + if (this.match(47)) { return true; } @@ -8845,7 +8953,7 @@ var typescript = (superClass => class extends superClass { } tsSkipParameterStart() { - if (tokenIsIdentifier(this.state.type) || this.match(74)) { + if (tokenIsIdentifier(this.state.type) || this.match(78)) { this.next(); return true; } @@ -8918,7 +9026,7 @@ var typescript = (superClass => class extends superClass { const node = this.startNode(); const asserts = !!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this)); - if (asserts && this.match(74)) { + if (asserts && this.match(78)) { let thisTypePredicate = this.tsParseThisTypeOrThisTypePredicate(); if (thisTypePredicate.type === "TSThisType") { @@ -8973,21 +9081,21 @@ var typescript = (superClass => class extends superClass { tsParseTypePredicatePrefix() { const id = this.parseIdentifier(); - if (this.isContextual(109) && !this.hasPrecedingLineBreak()) { + if (this.isContextual(113) && !this.hasPrecedingLineBreak()) { this.next(); return id; } } tsParseTypePredicateAsserts() { - if (this.state.type !== 102) { + if (this.state.type !== 106) { return false; } const containsEsc = this.state.containsEsc; this.next(); - if (!tokenIsIdentifier(this.state.type) && !this.match(74)) { + if (!tokenIsIdentifier(this.state.type) && !this.match(78)) { return false; } @@ -9012,7 +9120,7 @@ var typescript = (superClass => class extends superClass { assert(this.state.inType); const type = this.tsParseNonConditionalType(); - if (this.hasPrecedingLineBreak() || !this.eat(77)) { + if (this.hasPrecedingLineBreak() || !this.eat(81)) { return type; } @@ -9027,7 +9135,7 @@ var typescript = (superClass => class extends superClass { } isAbstractConstructorSignature() { - return this.isContextual(116) && this.lookahead().type === 73; + return this.isContextual(120) && this.lookahead().type === 77; } tsParseNonConditionalType() { @@ -9035,7 +9143,7 @@ var typescript = (superClass => class extends superClass { return this.tsParseFunctionOrConstructorType("TSFunctionType"); } - if (this.match(73)) { + if (this.match(77)) { return this.tsParseFunctionOrConstructorType("TSConstructorType"); } else if (this.isAbstractConstructorSignature()) { return this.tsParseFunctionOrConstructorType("TSConstructorType", true); @@ -9056,7 +9164,7 @@ var typescript = (superClass => class extends superClass { const _const = this.tsTryNextParseConstantContext(); node.typeAnnotation = _const || this.tsNextThenParseType(); - this.expect(46); + this.expect(48); node.expression = this.parseMaybeUnary(); return this.finishNode(node, "TSTypeAssertion"); } @@ -9078,7 +9186,7 @@ var typescript = (superClass => class extends superClass { const node = this.startNode(); node.expression = this.tsParseEntityName(false); - if (this.match(45)) { + if (this.match(47)) { node.typeParameters = this.tsParseTypeArguments(); } @@ -9098,7 +9206,7 @@ var typescript = (superClass => class extends superClass { node.typeParameters = this.tsTryParseTypeParameters(); - if (this.eat(77)) { + if (this.eat(81)) { node.extends = this.tsParseHeritageClause("extends"); } @@ -9115,7 +9223,7 @@ var typescript = (superClass => class extends superClass { node.typeAnnotation = this.tsInType(() => { this.expect(29); - if (this.isContextual(107) && this.lookahead().type !== 16) { + if (this.isContextual(111) && this.lookahead().type !== 16) { const node = this.startNode(); this.next(); return this.finishNode(node, "TSIntrinsicKeyword"); @@ -9170,7 +9278,7 @@ var typescript = (superClass => class extends superClass { tsParseEnumMember() { const node = this.startNode(); - node.id = this.match(125) ? this.parseExprAtom() : this.parseIdentifier(true); + node.id = this.match(129) ? this.parseExprAtom() : this.parseIdentifier(true); if (this.eat(29)) { node.initializer = this.parseMaybeAssignAllowIn(); @@ -9221,10 +9329,10 @@ var typescript = (superClass => class extends superClass { } tsParseAmbientExternalModuleDeclaration(node) { - if (this.isContextual(105)) { + if (this.isContextual(109)) { node.global = true; node.id = this.parseIdentifier(); - } else if (this.match(125)) { + } else if (this.match(129)) { node.id = this.parseExprAtom(); } else { this.unexpected(); @@ -9262,7 +9370,7 @@ var typescript = (superClass => class extends superClass { } tsIsExternalModuleReference() { - return this.isContextual(112) && this.lookaheadCharCode() === 40; + return this.isContextual(116) && this.lookaheadCharCode() === 40; } tsParseModuleReference() { @@ -9271,10 +9379,10 @@ var typescript = (superClass => class extends superClass { tsParseExternalModuleReference() { const node = this.startNode(); - this.expectContextual(112); + this.expectContextual(116); this.expect(10); - if (!this.match(125)) { + if (!this.match(129)) { throw this.unexpected(); } @@ -9317,33 +9425,33 @@ var typescript = (superClass => class extends superClass { let starttype = this.state.type; let kind; - if (this.isContextual(95)) { - starttype = 70; + if (this.isContextual(99)) { + starttype = 74; kind = "let"; } return this.tsInAmbientContext(() => { switch (starttype) { - case 64: + case 68: nany.declare = true; return this.parseFunctionStatement(nany, false, true); - case 76: + case 80: nany.declare = true; return this.parseClass(nany, true, false); - case 71: - if (this.match(71) && this.isLookaheadContextual("enum")) { - this.expect(71); - this.expectContextual(118); + case 75: + if (this.match(75) && this.isLookaheadContextual("enum")) { + this.expect(75); + this.expectContextual(122); return this.tsParseEnumDeclaration(nany, true); } - case 70: + case 74: kind = kind || this.state.value; return this.parseVarStatement(nany, kind); - case 105: + case 109: return this.tsParseAmbientExternalModuleDeclaration(nany); default: @@ -9397,7 +9505,7 @@ var typescript = (superClass => class extends superClass { tsParseDeclaration(node, value, next) { switch (value) { case "abstract": - if (this.tsCheckLineTerminator(next) && (this.match(76) || tokenIsIdentifier(this.state.type))) { + if (this.tsCheckLineTerminator(next) && (this.match(80) || tokenIsIdentifier(this.state.type))) { return this.tsParseAbstractDeclaration(node); } @@ -9420,7 +9528,7 @@ var typescript = (superClass => class extends superClass { case "module": if (this.tsCheckLineTerminator(next)) { - if (this.match(125)) { + if (this.match(129)) { return this.tsParseAmbientExternalModuleDeclaration(node); } else if (tokenIsIdentifier(this.state.type)) { return this.tsParseModuleOrNamespaceDeclaration(node); @@ -9456,7 +9564,7 @@ var typescript = (superClass => class extends superClass { } tsTryParseGenericAsyncArrowFunction(startPos, startLoc) { - if (!this.match(45)) { + if (!this.match(47)) { return undefined; } @@ -9479,10 +9587,18 @@ var typescript = (superClass => class extends superClass { return this.parseArrowExpression(res, null, true); } + tsParseTypeArgumentsInExpression() { + if (this.reScan_lt() !== 47) { + return undefined; + } + + return this.tsParseTypeArguments(); + } + tsParseTypeArguments() { const node = this.startNode(); node.params = this.tsInType(() => this.tsInNoContext(() => { - this.expect(45); + this.expect(47); return this.tsParseDelimitedList("TypeParametersOrArguments", this.tsParseType.bind(this)); })); @@ -9492,7 +9608,7 @@ var typescript = (superClass => class extends superClass { }); } - this.expect(46); + this.expect(48); return this.finishNode(node, "TSTypeParameterInstantiation"); } @@ -9638,7 +9754,7 @@ var typescript = (superClass => class extends superClass { this.next(); } - if (this.match(45)) { + if (this.match(47) || this.match(51)) { let missingParenErrorLoc; const result = this.tsTryParseAndCatch(() => { if (!noCalls && this.atPossibleAsyncArrow(base)) { @@ -9651,7 +9767,7 @@ var typescript = (superClass => class extends superClass { const node = this.startNodeAt(startPos, startLoc); node.callee = base; - const typeArguments = this.tsParseTypeArguments(); + const typeArguments = this.tsParseTypeArgumentsInExpression(); if (typeArguments) { if (isOptionalCall && !this.match(10)) { @@ -9690,9 +9806,9 @@ var typescript = (superClass => class extends superClass { } parseNewArguments(node) { - if (this.match(45)) { + if (this.match(47) || this.match(51)) { const typeParameters = this.tsTryParseAndCatch(() => { - const args = this.tsParseTypeArguments(); + const args = this.tsParseTypeArgumentsInExpression(); if (!this.match(10)) this.unexpected(); return args; }); @@ -9706,7 +9822,7 @@ var typescript = (superClass => class extends superClass { } parseExprOp(left, leftStartPos, leftStartLoc, minPrec) { - if (tokenOperatorPrecedence(54) > minPrec && !this.hasPrecedingLineBreak() && this.isContextual(89)) { + if (tokenOperatorPrecedence(58) > minPrec && !this.hasPrecedingLineBreak() && this.isContextual(93)) { const node = this.startNodeAt(leftStartPos, leftStartLoc); node.expression = left; @@ -9733,10 +9849,10 @@ var typescript = (superClass => class extends superClass { parseImport(node) { node.importKind = "value"; - if (tokenIsIdentifier(this.state.type) || this.match(51) || this.match(5)) { + if (tokenIsIdentifier(this.state.type) || this.match(55) || this.match(5)) { let ahead = this.lookahead(); - if (this.isContextual(122) && ahead.type !== 12 && ahead.type !== 93 && ahead.type !== 29) { + if (this.isContextual(126) && ahead.type !== 12 && ahead.type !== 97 && ahead.type !== 29) { node.importKind = "type"; this.next(); ahead = this.lookahead(); @@ -9759,10 +9875,10 @@ var typescript = (superClass => class extends superClass { } parseExport(node) { - if (this.match(79)) { + if (this.match(83)) { this.next(); - if (this.isContextual(122) && this.lookaheadCharCode() !== 61) { + if (this.isContextual(126) && this.lookaheadCharCode() !== 61) { node.importKind = "type"; this.next(); } else { @@ -9775,14 +9891,14 @@ var typescript = (superClass => class extends superClass { assign.expression = this.parseExpression(); this.semicolon(); return this.finishNode(assign, "TSExportAssignment"); - } else if (this.eatContextual(89)) { + } else if (this.eatContextual(93)) { const decl = node; - this.expectContextual(120); + this.expectContextual(124); decl.id = this.parseIdentifier(); this.semicolon(); return this.finishNode(decl, "TSNamespaceExportDeclaration"); } else { - if (this.isContextual(122) && this.lookahead().type === 5) { + if (this.isContextual(126) && this.lookahead().type === 5) { this.next(); node.exportKind = "type"; } else { @@ -9794,7 +9910,7 @@ var typescript = (superClass => class extends superClass { } isAbstractClass() { - return this.isContextual(116) && this.lookahead().type === 76; + return this.isContextual(120) && this.lookahead().type === 80; } parseExportDefaultExpression() { @@ -9806,7 +9922,7 @@ var typescript = (superClass => class extends superClass { return cls; } - if (this.match(121)) { + if (this.match(125)) { const interfaceNode = this.startNode(); this.next(); const result = this.tsParseInterfaceDeclaration(interfaceNode); @@ -9817,13 +9933,13 @@ var typescript = (superClass => class extends superClass { } parseStatementContent(context, topLevel) { - if (this.state.type === 71) { + if (this.state.type === 75) { const ahead = this.lookahead(); - if (ahead.type === 118) { + if (ahead.type === 122) { const node = this.startNode(); this.next(); - this.expectContextual(118); + this.expectContextual(122); return this.tsParseEnumDeclaration(node, true); } } @@ -9846,7 +9962,7 @@ var typescript = (superClass => class extends superClass { } tsIsStartOfStaticBlocks() { - return this.isContextual(100) && this.lookaheadCharCode() === 123; + return this.isContextual(104) && this.lookaheadCharCode() === 123; } parseClassMember(classBody, member, state) { @@ -9994,9 +10110,9 @@ var typescript = (superClass => class extends superClass { parseExportDeclaration(node) { const startPos = this.state.start; const startLoc = this.state.startLoc; - const isDeclare = this.eatContextual(117); + const isDeclare = this.eatContextual(121); - if (isDeclare && (this.isContextual(117) || !this.shouldParseExportDeclaration())) { + if (isDeclare && (this.isContextual(121) || !this.shouldParseExportDeclaration())) { throw this.raise(TSErrors.ExpectedAmbientAfterExportDeclare, { at: this.state.startLoc }); @@ -10025,7 +10141,7 @@ var typescript = (superClass => class extends superClass { } parseClassId(node, isStatement, optionalId) { - if ((!isStatement || optionalId) && this.isContextual(106)) { + if ((!isStatement || optionalId) && this.isContextual(110)) { return; } @@ -10115,11 +10231,11 @@ var typescript = (superClass => class extends superClass { parseClassSuper(node) { super.parseClassSuper(node); - if (node.superClass && this.match(45)) { - node.superTypeParameters = this.tsParseTypeArguments(); + if (node.superClass && (this.match(47) || this.match(51))) { + node.superTypeParameters = this.tsParseTypeArgumentsInExpression(); } - if (this.eatContextual(106)) { + if (this.eatContextual(110)) { node.implements = this.tsParseHeritageClause("implements"); } } @@ -10166,7 +10282,7 @@ var typescript = (superClass => class extends superClass { let jsx; let typeCast; - if (this.hasPlugin("jsx") && (this.match(134) || this.match(45))) { + if (this.hasPlugin("jsx") && (this.match(138) || this.match(47))) { state = this.state.clone(); jsx = this.tryParse(() => super.parseMaybeAssign(...args), state); if (!jsx.error) return jsx.node; @@ -10180,7 +10296,7 @@ var typescript = (superClass => class extends superClass { } } - if (!((_jsx = jsx) != null && _jsx.error) && !this.match(45)) { + if (!((_jsx = jsx) != null && _jsx.error) && !this.match(47)) { return super.parseMaybeAssign(...args); } @@ -10248,7 +10364,7 @@ var typescript = (superClass => class extends superClass { } parseMaybeUnary(refExpressionErrors) { - if (!this.hasPlugin("jsx") && this.match(45)) { + if (!this.hasPlugin("jsx") && this.match(47)) { return this.tsParseTypeAssertion(); } else { return super.parseMaybeUnary(refExpressionErrors); @@ -10374,7 +10490,7 @@ var typescript = (superClass => class extends superClass { parseBindingAtom() { switch (this.state.type) { - case 74: + case 78: return this.parseIdentifier(true); default: @@ -10383,8 +10499,8 @@ var typescript = (superClass => class extends superClass { } parseMaybeDecoratorArguments(expr) { - if (this.match(45)) { - const typeArguments = this.tsParseTypeArguments(); + if (this.match(47) || this.match(51)) { + const typeArguments = this.tsParseTypeArgumentsInExpression(); if (this.match(10)) { const call = super.parseMaybeDecoratorArguments(expr); @@ -10408,7 +10524,7 @@ var typescript = (superClass => class extends superClass { } isClassMethod() { - return this.match(45) || super.isClassMethod(); + return this.match(47) || super.isClassMethod(); } isClassProperty() { @@ -10430,11 +10546,11 @@ var typescript = (superClass => class extends superClass { getTokenFromCode(code) { if (this.state.inType) { if (code === 62) { - return this.finishOp(46, 1); + return this.finishOp(48, 1); } if (code === 60) { - return this.finishOp(45, 1); + return this.finishOp(47, 1); } } @@ -10446,15 +10562,29 @@ var typescript = (superClass => class extends superClass { type } = this.state; - if (type === 45) { + if (type === 47) { this.state.pos -= 1; this.readToken_lt(); - } else if (type === 46) { + } else if (type === 48) { this.state.pos -= 1; this.readToken_gt(); } } + reScan_lt() { + const { + type + } = this.state; + + if (type === 51) { + this.state.pos -= 2; + this.finishOp(47, 1); + return 47; + } + + return type; + } + toAssignableList(exprList) { for (let i = 0; i < exprList.length; i++) { const expr = exprList[i]; @@ -10505,8 +10635,8 @@ var typescript = (superClass => class extends superClass { } jsxParseOpeningElementAfterName(node) { - if (this.match(45)) { - const typeArguments = this.tsTryParseAndCatch(() => this.tsParseTypeArguments()); + if (this.match(47) || this.match(51)) { + const typeArguments = this.tsTryParseAndCatch(() => this.tsParseTypeArgumentsInExpression()); if (typeArguments) node.typeParameters = typeArguments; } @@ -10556,10 +10686,10 @@ var typescript = (superClass => class extends superClass { } tsParseAbstractDeclaration(node) { - if (this.match(76)) { + if (this.match(80)) { node.abstract = true; return this.parseClass(node, true, false); - } else if (this.isContextual(121)) { + } else if (this.isContextual(125)) { if (!this.hasFollowingLineBreak()) { node.abstract = true; this.raise(TSErrors.NonClassMethodPropertyHasAbstractModifer, { @@ -10569,7 +10699,7 @@ var typescript = (superClass => class extends superClass { return this.tsParseInterfaceDeclaration(node); } } else { - this.unexpected(null, 76); + this.unexpected(null, 80); } } @@ -10646,10 +10776,10 @@ var typescript = (superClass => class extends superClass { let canParseAsKeyword = true; const loc = leftOfAs.loc.start; - if (this.isContextual(89)) { + if (this.isContextual(93)) { const firstAs = this.parseIdentifier(); - if (this.isContextual(89)) { + if (this.isContextual(93)) { const secondAs = this.parseIdentifier(); if (tokenIsKeywordOrIdentifier(this.state.type)) { @@ -10684,7 +10814,7 @@ var typescript = (superClass => class extends superClass { const kindKey = isImport ? "importKind" : "exportKind"; node[kindKey] = hasTypeSpecifier ? "type" : "value"; - if (canParseAsKeyword && this.eatContextual(89)) { + if (canParseAsKeyword && this.eatContextual(93)) { node[rightOfAsKey] = isImport ? this.parseIdentifier() : this.parseModuleExportName(); } @@ -10704,13 +10834,13 @@ const PlaceholderErrors = makeErrorTemplates({ }, ErrorCodes.SyntaxError, "placeholders"); var placeholders = (superClass => class extends superClass { parsePlaceholder(expectedNode) { - if (this.match(136)) { + if (this.match(140)) { const node = this.startNode(); this.next(); this.assertNoSpace("Unexpected space in placeholder."); node.name = super.parseIdentifier(true); this.assertNoSpace("Unexpected space in placeholder."); - this.expect(136); + this.expect(140); return this.finishPlaceholder(node, expectedNode); } } @@ -10723,7 +10853,7 @@ var placeholders = (superClass => class extends superClass { getTokenFromCode(code) { if (code === 37 && this.input.charCodeAt(this.state.pos + 1) === 37) { - return this.finishOp(136, 2); + return this.finishOp(140, 2); } return super.getTokenFromCode(...arguments); @@ -10763,14 +10893,14 @@ var placeholders = (superClass => class extends superClass { return true; } - if (!this.isContextual(95)) { + if (!this.isContextual(99)) { return false; } if (context) return false; const nextToken = this.lookahead(); - if (nextToken.type === 136) { + if (nextToken.type === 140) { return true; } @@ -10816,7 +10946,7 @@ var placeholders = (superClass => class extends superClass { const placeholder = this.parsePlaceholder("Identifier"); if (placeholder) { - if (this.match(77) || this.match(136) || this.match(5)) { + if (this.match(81) || this.match(140) || this.match(5)) { node.id = placeholder; } else if (optionalId || !isStatement) { node.id = null; @@ -10840,7 +10970,7 @@ var placeholders = (superClass => class extends superClass { const placeholder = this.parsePlaceholder("Identifier"); if (!placeholder) return super.parseExport(...arguments); - if (!this.isContextual(93) && !this.match(12)) { + if (!this.isContextual(97) && !this.match(12)) { node.specifiers = []; node.source = null; node.declaration = this.finishPlaceholder(placeholder, "Declaration"); @@ -10855,11 +10985,11 @@ var placeholders = (superClass => class extends superClass { } isExportDefaultSpecifier() { - if (this.match(61)) { + if (this.match(65)) { const next = this.nextTokenStart(); if (this.isUnparsedContextual(next, "from")) { - if (this.input.startsWith(tokenLabelName(136), this.nextTokenStartSince(next + 4))) { + if (this.input.startsWith(tokenLabelName(140), this.nextTokenStartSince(next + 4))) { return true; } } @@ -10894,7 +11024,7 @@ var placeholders = (superClass => class extends superClass { if (!placeholder) return super.parseImport(...arguments); node.specifiers = []; - if (!this.isContextual(93) && !this.match(12)) { + if (!this.isContextual(97) && !this.match(12)) { node.source = this.finishPlaceholder(placeholder, "StringLiteral"); this.semicolon(); return this.finishNode(node, "ImportDeclaration"); @@ -10910,7 +11040,7 @@ var placeholders = (superClass => class extends superClass { if (!hasStarImport) this.parseNamedImportSpecifiers(node); } - this.expectContextual(93); + this.expectContextual(97); node.source = this.parseImportSource(); this.semicolon(); return this.finishNode(node, "ImportDeclaration"); @@ -10924,7 +11054,7 @@ var placeholders = (superClass => class extends superClass { var v8intrinsic = (superClass => class extends superClass { parseV8Intrinsic() { - if (this.match(50)) { + if (this.match(54)) { const v8IntrinsicStartLoc = this.state.startLoc; const node = this.startNode(); this.next(); @@ -10989,7 +11119,7 @@ function getPluginOption(plugins, name, option) { return null; } const PIPELINE_PROPOSALS = ["minimal", "fsharp", "hack", "smart"]; -const TOPIC_TOKENS = ["^", "%", "#"]; +const TOPIC_TOKENS = ["^^", "@@", "^", "%", "#"]; const RECORD_AND_TUPLE_SYNTAX_TYPES = ["hash", "bar"]; function validatePlugins(plugins) { if (hasPlugin(plugins, "decorators")) { @@ -11168,8 +11298,19 @@ class LValParser extends NodeUtils { break; case "ObjectProperty": - this.toAssignable(node.value, isLHS); - break; + { + const { + key, + value + } = node; + + if (this.isPrivateName(key)) { + this.classScope.usePrivateName(this.getPrivateNameSV(key), key.loc.start); + } + + this.toAssignable(value, isLHS); + break; + } case "SpreadElement": { @@ -11409,6 +11550,10 @@ class LValParser extends NodeUtils { if (type === 21) { return this.parseBindingRestProperty(prop); + } else if (type === 134) { + this.expectPlugin("destructuringPrivate", startLoc); + this.classScope.usePrivateName(this.state.value, startLoc); + prop.key = this.parsePrivateName(); } else { this.parsePropertyName(prop); } @@ -11595,7 +11740,7 @@ class ExpressionParser extends LValParser { this.nextToken(); const expr = this.parseExpression(); - if (!this.match(131)) { + if (!this.match(135)) { this.unexpected(); } @@ -11656,7 +11801,7 @@ class ExpressionParser extends LValParser { const startPos = this.state.start; const startLoc = this.state.startLoc; - if (this.isContextual(101)) { + if (this.isContextual(105)) { if (this.prodParam.hasYield) { let left = this.parseYield(); @@ -11699,13 +11844,18 @@ class ExpressionParser extends LValParser { if (this.match(29)) { node.left = this.toAssignable(left, true); - if (refExpressionErrors.doubleProtoLoc != null && indexes.get(refExpressionErrors.doubleProtoLoc) >= startPos) { + if (refExpressionErrors.doubleProtoLoc != null && refExpressionErrors.doubleProtoLoc.index >= startPos) { refExpressionErrors.doubleProtoLoc = null; } - if (refExpressionErrors.shorthandAssignLoc != null && indexes.get(refExpressionErrors.shorthandAssignLoc) >= startPos) { + if (refExpressionErrors.shorthandAssignLoc != null && refExpressionErrors.shorthandAssignLoc.index >= startPos) { refExpressionErrors.shorthandAssignLoc = null; } + + if (refExpressionErrors.privateKeyLoc != null && refExpressionErrors.privateKeyLoc.index >= startPos) { + this.checkDestructuringPrivate(refExpressionErrors); + refExpressionErrors.privateKeyLoc = null; + } } else { node.left = left; } @@ -11748,7 +11898,7 @@ class ExpressionParser extends LValParser { } parseMaybeUnaryOrPrivate(refExpressionErrors) { - return this.match(130) ? this.parsePrivateName() : this.parseMaybeUnary(refExpressionErrors); + return this.match(134) ? this.parsePrivateName() : this.parseMaybeUnary(refExpressionErrors); } parseExprOps(refExpressionErrors) { @@ -11768,7 +11918,7 @@ class ExpressionParser extends LValParser { if (this.isPrivateName(left)) { const value = this.getPrivateNameSV(left); - if (minPrec >= tokenOperatorPrecedence(54) || !this.prodParam.hasIn || !this.match(54)) { + if (minPrec >= tokenOperatorPrecedence(58) || !this.prodParam.hasIn || !this.match(58)) { this.raise(ErrorMessages.PrivateInExpectedIn, { node: left }, value); @@ -11779,11 +11929,11 @@ class ExpressionParser extends LValParser { const op = this.state.type; - if (tokenIsOperator(op) && (this.prodParam.hasIn || !this.match(54))) { + if (tokenIsOperator(op) && (this.prodParam.hasIn || !this.match(58))) { let prec = tokenOperatorPrecedence(op); if (prec > minPrec) { - if (op === 37) { + if (op === 39) { this.expectPlugin("pipelineOperator"); if (this.state.inFSharpPipelineDirectBody) { @@ -11796,19 +11946,19 @@ class ExpressionParser extends LValParser { const node = this.startNodeAt(leftStartPos, leftStartLoc); node.left = left; node.operator = this.state.value; - const logical = op === 39 || op === 40; - const coalesce = op === 38; + const logical = op === 41 || op === 42; + const coalesce = op === 40; if (coalesce) { - prec = tokenOperatorPrecedence(40); + prec = tokenOperatorPrecedence(42); } this.next(); - if (op === 37 && this.hasPlugin(["pipelineOperator", { + if (op === 39 && this.hasPlugin(["pipelineOperator", { proposal: "minimal" }])) { - if (this.state.type === 92 && this.prodParam.hasAwait) { + if (this.state.type === 96 && this.prodParam.hasAwait) { throw this.raise(ErrorMessages.UnexpectedAwaitAfterPipelineBody, { at: this.state.startLoc }); @@ -11819,7 +11969,7 @@ class ExpressionParser extends LValParser { this.finishNode(node, logical || coalesce ? "LogicalExpression" : "BinaryExpression"); const nextOp = this.state.type; - if (coalesce && (nextOp === 39 || nextOp === 40) || logical && nextOp === 38) { + if (coalesce && (nextOp === 41 || nextOp === 42) || logical && nextOp === 40) { throw this.raise(ErrorMessages.MixingCoalesceWithLogical, { at: this.state.startLoc }); @@ -11837,7 +11987,7 @@ class ExpressionParser extends LValParser { const startLoc = this.state.startLoc; switch (op) { - case 37: + case 39: switch (this.getPluginOption("pipelineOperator", "proposal")) { case "hack": return this.withTopicBindingContext(() => { @@ -11846,7 +11996,7 @@ class ExpressionParser extends LValParser { case "smart": return this.withTopicBindingContext(() => { - if (this.prodParam.hasYield && this.isContextual(101)) { + if (this.prodParam.hasYield && this.isContextual(105)) { throw this.raise(ErrorMessages.PipeBodyIsTighter, { at: this.state.startLoc }, this.state.value); @@ -11896,7 +12046,7 @@ class ExpressionParser extends LValParser { } checkExponentialAfterUnary(node) { - if (this.match(53)) { + if (this.match(57)) { this.raise(ErrorMessages.UnexpectedTokenUnaryExponentiation, { node: node.argument }); @@ -11906,7 +12056,7 @@ class ExpressionParser extends LValParser { parseMaybeUnary(refExpressionErrors, sawUnary) { const startPos = this.state.start; const startLoc = this.state.startLoc; - const isAwait = this.isContextual(92); + const isAwait = this.isContextual(96); if (isAwait && this.isAwaitAllowed()) { this.next(); @@ -11922,11 +12072,11 @@ class ExpressionParser extends LValParser { node.operator = this.state.value; node.prefix = true; - if (this.match(68)) { + if (this.match(72)) { this.expectPlugin("throwExpressions"); } - const isDelete = this.match(85); + const isDelete = this.match(89); this.next(); node.argument = this.parseMaybeUnary(null, true); this.checkExpressionErrors(refExpressionErrors, true); @@ -11957,7 +12107,7 @@ class ExpressionParser extends LValParser { const { type } = this.state; - const startsExpr = this.hasPlugin("v8intrinsic") ? tokenCanStartExpression(type) : tokenCanStartExpression(type) && !this.match(50); + const startsExpr = this.hasPlugin("v8intrinsic") ? tokenCanStartExpression(type) : tokenCanStartExpression(type) && !this.match(54); if (startsExpr && !this.isAmbiguousAwait()) { this.raiseOverwrite(startLoc, ErrorMessages.AwaitNotInAsyncContext); @@ -12065,7 +12215,7 @@ class ExpressionParser extends LValParser { if (computed) { node.property = this.parseExpression(); this.expect(3); - } else if (this.match(130)) { + } else if (this.match(134)) { if (base.type === "Super") { this.raise(ErrorMessages.SuperPrivateField, { at: startLoc @@ -12102,13 +12252,17 @@ class ExpressionParser extends LValParser { this.next(); let node = this.startNodeAt(startPos, startLoc); node.callee = base; + const { + maybeAsyncArrow, + optionalChainMember + } = state; - if (state.maybeAsyncArrow) { + if (maybeAsyncArrow) { this.expressionScope.enter(newAsyncArrowScope()); refExpressionErrors = new ExpressionErrors(); } - if (state.optionalChainMember) { + if (optionalChainMember) { node.optional = optional; } @@ -12118,15 +12272,16 @@ class ExpressionParser extends LValParser { node.arguments = this.parseCallExpressionArguments(11, base.type === "Import", base.type !== "Super", node, refExpressionErrors); } - this.finishCallExpression(node, state.optionalChainMember); + this.finishCallExpression(node, optionalChainMember); - if (state.maybeAsyncArrow && this.shouldParseAsyncArrow() && !optional) { + if (maybeAsyncArrow && this.shouldParseAsyncArrow() && !optional) { state.stop = true; + this.checkDestructuringPrivate(refExpressionErrors); this.expressionScope.validateAsPattern(); this.expressionScope.exit(); node = this.parseAsyncArrowFromCallExpression(this.startNodeAt(startPos, startLoc), node); } else { - if (state.maybeAsyncArrow) { + if (maybeAsyncArrow) { this.checkExpressionErrors(refExpressionErrors, true); this.expressionScope.exit(); } @@ -12157,7 +12312,7 @@ class ExpressionParser extends LValParser { } atPossibleAsyncArrow(base) { - return base.type === "Identifier" && base.name === "async" && indexes.get(this.state.lastTokEndLoc) === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 && base.start === this.state.potentialArrowAt; + return base.type === "Identifier" && base.name === "async" && this.state.lastTokEndLoc.index === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 && base.start === this.state.potentialArrowAt; } finishCallExpression(node, optional) { @@ -12258,10 +12413,10 @@ class ExpressionParser extends LValParser { } = this.state; switch (type) { - case 75: + case 79: return this.parseSuper(); - case 79: + case 83: node = this.startNode(); this.next(); @@ -12277,42 +12432,42 @@ class ExpressionParser extends LValParser { return this.finishNode(node, "Import"); - case 74: + case 78: node = this.startNode(); this.next(); return this.finishNode(node, "ThisExpression"); - case 86: + case 90: { return this.parseDo(this.startNode(), false); } - case 52: + case 56: case 31: { this.readRegexp(); return this.parseRegExpLiteral(this.state.value); } - case 126: + case 130: return this.parseNumericLiteral(this.state.value); - case 127: + case 131: return this.parseBigIntLiteral(this.state.value); - case 128: + case 132: return this.parseDecimalLiteral(this.state.value); - case 125: + case 129: return this.parseStringLiteral(this.state.value); - case 80: + case 84: return this.parseNullLiteral(); - case 81: + case 85: return this.parseBooleanLiteral(true); - case 82: + case 86: return this.parseBooleanLiteral(false); case 10: @@ -12343,18 +12498,18 @@ class ExpressionParser extends LValParser { return this.parseObjectLike(8, false, false, refExpressionErrors); } - case 64: + case 68: return this.parseFunctionOrFunctionSent(); case 26: this.parseDecorators(); - case 76: + case 80: node = this.startNode(); this.takeDecorators(node); return this.parseClass(node, false); - case 73: + case 77: return this.parseNewOrNewTarget(); case 25: @@ -12377,7 +12532,7 @@ class ExpressionParser extends LValParser { } } - case 130: + case 134: { this.raise(ErrorMessages.PrivateInExpectedIn, { at: this.state.startLoc @@ -12387,16 +12542,22 @@ class ExpressionParser extends LValParser { case 33: { - return this.parseTopicReferenceThenEqualsSign(50, "%"); + return this.parseTopicReferenceThenEqualsSign(54, "%"); } case 32: { - return this.parseTopicReferenceThenEqualsSign(42, "^"); + return this.parseTopicReferenceThenEqualsSign(44, "^"); } - case 42: - case 50: + case 37: + case 38: + { + return this.parseTopicReference("hack"); + } + + case 44: + case 54: case 27: { const pipeProposal = this.getPluginOption("pipelineOperator", "proposal"); @@ -12408,7 +12569,7 @@ class ExpressionParser extends LValParser { } } - case 45: + case 47: { const lookaheadCh = this.input.codePointAt(this.nextTokenStart()); @@ -12422,7 +12583,7 @@ class ExpressionParser extends LValParser { default: if (tokenIsIdentifier(type)) { - if (this.isContextual(119) && this.lookaheadCharCode() === 123 && !this.hasFollowingLineBreak()) { + if (this.isContextual(123) && this.lookaheadCharCode() === 123 && !this.hasFollowingLineBreak()) { return this.parseModuleExpression(); } @@ -12435,7 +12596,7 @@ class ExpressionParser extends LValParser { type } = this.state; - if (type === 64) { + if (type === 68) { this.resetPreviousNodeTrailingComments(id); this.next(); return this.parseFunction(this.startNodeAtNode(id), undefined, true); @@ -12445,7 +12606,7 @@ class ExpressionParser extends LValParser { } else { return id; } - } else if (type === 86) { + } else if (type === 90) { this.resetPreviousNodeTrailingComments(id); return this.parseDo(this.startNodeAtNode(id), true); } @@ -12605,7 +12766,7 @@ class ExpressionParser extends LValParser { const meta = this.createIdentifier(this.startNodeAtNode(node), "function"); this.next(); - if (this.match(98)) { + if (this.match(102)) { this.expectPlugin("functionSent"); } else if (!this.hasPlugin("functionSent")) { this.unexpected(); @@ -12635,7 +12796,7 @@ class ExpressionParser extends LValParser { const id = this.createIdentifier(this.startNodeAtNode(node), "import"); this.next(); - if (this.isContextual(96)) { + if (this.isContextual(100)) { if (!this.inModule) { this.raise(SourceTypeModuleErrorMessages.ImportMetaOutsideModule, { node: id @@ -12748,6 +12909,7 @@ class ExpressionParser extends LValParser { let arrowNode = this.startNodeAt(startPos, startLoc); if (canBeArrow && this.shouldParseArrow(exprList) && (arrowNode = this.parseArrow(arrowNode))) { + this.checkDestructuringPrivate(refExpressionErrors); this.expressionScope.validateAsPattern(); this.expressionScope.exit(); this.parseArrowExpression(arrowNode, exprList, false); @@ -12777,7 +12939,7 @@ class ExpressionParser extends LValParser { if (!this.options.createParenthesizedExpressions) { this.addExtra(val, "parenthesized", true); this.addExtra(val, "parenStart", startPos); - this.takeSurroundingComments(val, startPos, indexes.get(this.state.lastTokEndLoc)); + this.takeSurroundingComments(val, startPos, this.state.lastTokEndLoc.index); return val; } @@ -12970,7 +13132,7 @@ class ExpressionParser extends LValParser { } maybeAsyncOrAccessorProp(prop) { - return !prop.computed && prop.key.type === "Identifier" && (this.isLiteralPropertyName() || this.match(0) || this.match(51)); + return !prop.computed && prop.key.type === "Identifier" && (this.isLiteralPropertyName() || this.match(0) || this.match(55)); } parsePropertyDefinition(refExpressionErrors) { @@ -13011,10 +13173,10 @@ class ExpressionParser extends LValParser { startLoc = this.state.startLoc; } - let isGenerator = this.eat(51); + let isGenerator = this.eat(55); this.parsePropertyNamePrefixOperator(prop); const containsEsc = this.state.containsEsc; - const key = this.parsePropertyName(prop); + const key = this.parsePropertyName(prop, refExpressionErrors); if (!isGenerator && !containsEsc && this.maybeAsyncOrAccessorProp(prop)) { const keyName = key.name; @@ -13022,7 +13184,7 @@ class ExpressionParser extends LValParser { if (keyName === "async" && !this.hasPrecedingLineBreak()) { isAsync = true; this.resetPreviousNodeTrailingComments(key); - isGenerator = this.eat(51); + isGenerator = this.eat(55); this.parsePropertyName(prop); } @@ -13031,7 +13193,7 @@ class ExpressionParser extends LValParser { this.resetPreviousNodeTrailingComments(key); prop.kind = keyName; - if (this.match(51)) { + if (this.match(55)) { isGenerator = true; this.raise(ErrorMessages.AccessorIsGenerator, { at: this.state.curPosition() @@ -13131,7 +13293,7 @@ class ExpressionParser extends LValParser { return node; } - parsePropertyName(prop) { + parsePropertyName(prop, refExpressionErrors) { if (this.eat(0)) { prop.computed = true; prop.key = this.parseMaybeAssignAllowIn(); @@ -13147,27 +13309,36 @@ class ExpressionParser extends LValParser { key = this.parseIdentifier(true); } else { switch (type) { - case 126: + case 130: key = this.parseNumericLiteral(value); break; - case 125: + case 129: key = this.parseStringLiteral(value); break; - case 127: + case 131: key = this.parseBigIntLiteral(value); break; - case 128: + case 132: key = this.parseDecimalLiteral(value); break; - case 130: + case 134: { - this.raise(ErrorMessages.UnexpectedPrivateField, { - at: createPositionWithColumnOffset(this.state.startLoc, 1) - }); + const privateKeyLoc = this.state.startLoc; + + if (refExpressionErrors != null) { + if (refExpressionErrors.privateKeyLoc === null) { + refExpressionErrors.privateKeyLoc = privateKeyLoc; + } + } else { + this.raise(ErrorMessages.UnexpectedPrivateField, { + at: privateKeyLoc + }); + } + key = this.parsePrivateName(); break; } @@ -13179,7 +13350,7 @@ class ExpressionParser extends LValParser { prop.key = key; - if (type !== 130) { + if (type !== 134) { prop.computed = false; } } @@ -13397,7 +13568,7 @@ class ExpressionParser extends LValParser { if (liberal) { if (tokenIsKeyword) { - this.replaceToken(124); + this.replaceToken(128); } } else { this.checkReservedWord(name, startLoc, tokenIsKeyword, false); @@ -13478,7 +13649,7 @@ class ExpressionParser extends LValParser { const node = this.startNodeAt(startPos, startLoc); this.expressionScope.recordParameterInitializerError(node.loc.start, ErrorMessages.AwaitExpressionFormalParameter); - if (this.eat(51)) { + if (this.eat(55)) { this.raise(ErrorMessages.ObsoleteAwaitStar, { node }); @@ -13504,7 +13675,7 @@ class ExpressionParser extends LValParser { const { type } = this.state; - return type === 49 || type === 10 || type === 0 || tokenIsTemplate(type) || type === 129 || type === 52 || this.hasPlugin("v8intrinsic") && type === 50; + return type === 53 || type === 10 || type === 0 || tokenIsTemplate(type) || type === 133 || type === 56 || this.hasPlugin("v8intrinsic") && type === 54; } parseYield() { @@ -13515,11 +13686,11 @@ class ExpressionParser extends LValParser { let argument = null; if (!this.hasPrecedingLineBreak()) { - delegating = this.eat(51); + delegating = this.eat(55); switch (this.state.type) { case 13: - case 131: + case 135: case 8: case 11: case 3: @@ -13737,7 +13908,7 @@ function babel7CompatTokens(tokens, input) { if (typeof type === "number") { { - if (type === 130) { + if (type === 134) { const { loc, start, @@ -13754,7 +13925,7 @@ function babel7CompatTokens(tokens, input) { startLoc: loc.start, endLoc: hashEndLoc }), new Token({ - type: getExportedToken(124), + type: getExportedToken(128), value: value, start: hashEndPos, end: end, @@ -13855,7 +14026,7 @@ class StatementParser extends ExpressionParser { return this.finishNode(file, "File"); } - parseProgram(program, end = 131, sourceType = this.options.sourceType) { + parseProgram(program, end = 135, sourceType = this.options.sourceType) { program.sourceType = sourceType; program.interpreter = this.parseInterpreterDirective(); this.parseBlockBody(program, true, true, end); @@ -13899,7 +14070,7 @@ class StatementParser extends ExpressionParser { } isLet(context) { - if (!this.isContextual(95)) { + if (!this.isContextual(99)) { return false; } @@ -13948,27 +14119,27 @@ class StatementParser extends ExpressionParser { let kind; if (this.isLet(context)) { - starttype = 70; + starttype = 74; kind = "let"; } switch (starttype) { - case 56: + case 60: return this.parseBreakContinueStatement(node, true); - case 59: + case 63: return this.parseBreakContinueStatement(node, false); - case 60: + case 64: return this.parseDebuggerStatement(node); - case 86: + case 90: return this.parseDoStatement(node); - case 87: + case 91: return this.parseForStatement(node); - case 64: + case 68: if (this.lookaheadCharCode() === 46) break; if (context) { @@ -13985,27 +14156,27 @@ class StatementParser extends ExpressionParser { return this.parseFunctionStatement(node, false, !context); - case 76: + case 80: if (context) this.unexpected(); return this.parseClass(node, true); - case 65: + case 69: return this.parseIfStatement(node); - case 66: + case 70: return this.parseReturnStatement(node); - case 67: + case 71: return this.parseSwitchStatement(node); - case 68: + case 72: return this.parseThrowStatement(node); - case 69: + case 73: return this.parseTryStatement(node); - case 71: - case 70: + case 75: + case 74: kind = kind || this.state.value; if (context && kind !== "var") { @@ -14016,10 +14187,10 @@ class StatementParser extends ExpressionParser { return this.parseVarStatement(node, kind); - case 88: + case 92: return this.parseWhileStatement(node); - case 72: + case 76: return this.parseWithStatement(node); case 5: @@ -14028,7 +14199,7 @@ class StatementParser extends ExpressionParser { case 13: return this.parseEmptyStatement(node); - case 79: + case 83: { const nextTokenCharCode = this.lookaheadCharCode(); @@ -14037,7 +14208,7 @@ class StatementParser extends ExpressionParser { } } - case 78: + case 82: { if (!this.options.allowImportExportEverywhere && !topLevel) { this.raise(ErrorMessages.UnexpectedImportExport, { @@ -14048,7 +14219,7 @@ class StatementParser extends ExpressionParser { this.next(); let result; - if (starttype === 79) { + if (starttype === 83) { result = this.parseImport(node); if (result.type === "ImportDeclaration" && (!result.importKind || result.importKind === "value")) { @@ -14110,7 +14281,7 @@ class StatementParser extends ExpressionParser { } canHaveLeadingDecorator() { - return this.match(76); + return this.match(80); } parseDecorators(allowExport) { @@ -14121,7 +14292,7 @@ class StatementParser extends ExpressionParser { currentContextDecorators.push(decorator); } - if (this.match(78)) { + if (this.match(82)) { if (!allowExport) { this.unexpected(); } @@ -14236,7 +14407,7 @@ class StatementParser extends ExpressionParser { this.state.labels.push(loopLabel); node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement("do")); this.state.labels.pop(); - this.expect(88); + this.expect(92); node.test = this.parseHeaderExpression(); this.eat(13); return this.finishNode(node, "DoWhileStatement"); @@ -14247,7 +14418,7 @@ class StatementParser extends ExpressionParser { this.state.labels.push(loopLabel); let awaitAt = null; - if (this.isAwaitAllowed() && this.eatContextual(92)) { + if (this.isAwaitAllowed() && this.eatContextual(96)) { awaitAt = this.state.lastTokStartLoc; } @@ -14262,17 +14433,17 @@ class StatementParser extends ExpressionParser { return this.parseFor(node, null); } - const startsWithLet = this.isContextual(95); + const startsWithLet = this.isContextual(99); const isLet = startsWithLet && this.isLetKeyword(); - if (this.match(70) || this.match(71) || isLet) { + if (this.match(74) || this.match(75) || isLet) { const init = this.startNode(); const kind = isLet ? "let" : this.state.value; this.next(); this.parseVar(init, true, kind); this.finishNode(init, "VariableDeclaration"); - if ((this.match(54) || this.isContextual(97)) && init.declarations.length === 1) { + if ((this.match(58) || this.isContextual(101)) && init.declarations.length === 1) { return this.parseForIn(node, init, awaitAt); } @@ -14283,10 +14454,10 @@ class StatementParser extends ExpressionParser { return this.parseFor(node, init); } - const startsWithAsync = this.isContextual(91); + const startsWithAsync = this.isContextual(95); const refExpressionErrors = new ExpressionErrors(); const init = this.parseExpression(true, refExpressionErrors); - const isForOf = this.isContextual(97); + const isForOf = this.isContextual(101); if (isForOf) { if (startsWithLet) { @@ -14302,7 +14473,8 @@ class StatementParser extends ExpressionParser { } } - if (isForOf || this.match(54)) { + if (isForOf || this.match(58)) { + this.checkDestructuringPrivate(refExpressionErrors); this.toAssignable(init, true); const description = isForOf ? "for-of statement" : "for-in statement"; this.checkLVal(init, description); @@ -14327,7 +14499,7 @@ class StatementParser extends ExpressionParser { this.next(); node.test = this.parseHeaderExpression(); node.consequent = this.parseStatement("if"); - node.alternate = this.eat(62) ? this.parseStatement("if") : null; + node.alternate = this.eat(66) ? this.parseStatement("if") : null; return this.finishNode(node, "IfStatement"); } @@ -14360,8 +14532,8 @@ class StatementParser extends ExpressionParser { let cur; for (let sawDefault; !this.match(8);) { - if (this.match(57) || this.match(61)) { - const isCase = this.match(57); + if (this.match(61) || this.match(65)) { + const isCase = this.match(61); if (cur) this.finishNode(cur, "SwitchCase"); cases.push(cur = this.startNode()); cur.consequent = []; @@ -14424,7 +14596,7 @@ class StatementParser extends ExpressionParser { node.block = this.parseBlock(); node.handler = null; - if (this.match(58)) { + if (this.match(62)) { const clause = this.startNode(); this.next(); @@ -14442,7 +14614,7 @@ class StatementParser extends ExpressionParser { node.handler = this.finishNode(clause, "CatchClause"); } - node.finalizer = this.eat(63) ? this.parseBlock() : null; + node.finalizer = this.eat(67) ? this.parseBlock() : null; if (!node.handler && !node.finalizer) { this.raise(ErrorMessages.NoCatchOrFinally, { @@ -14496,7 +14668,7 @@ class StatementParser extends ExpressionParser { } } - const kind = tokenIsLoop(this.state.type) ? "loop" : this.match(67) ? "switch" : null; + const kind = tokenIsLoop(this.state.type) ? "loop" : this.match(71) ? "switch" : null; for (let i = this.state.labels.length - 1; i >= 0; i--) { const label = this.state.labels[i]; @@ -14611,7 +14783,7 @@ class StatementParser extends ExpressionParser { } parseForIn(node, init, awaitAt) { - const isForIn = this.match(54); + const isForIn = this.match(58); this.next(); if (isForIn) { @@ -14653,13 +14825,13 @@ class StatementParser extends ExpressionParser { if (this.eat(29)) { decl.init = isFor ? this.parseMaybeAssignDisallowIn() : this.parseMaybeAssignAllowIn(); } else { - if (kind === "const" && !(this.match(54) || this.isContextual(97))) { + if (kind === "const" && !(this.match(58) || this.isContextual(101))) { if (!isTypescript) { this.raise(ErrorMessages.DeclarationMissingInitializer, { at: this.state.lastTokEndLoc }, "Const declarations"); } - } else if (decl.id.type !== "Identifier" && !(isFor && (this.match(54) || this.isContextual(97)))) { + } else if (decl.id.type !== "Identifier" && !(isFor && (this.match(58) || this.isContextual(101)))) { this.raise(ErrorMessages.DeclarationMissingInitializer, { at: this.state.lastTokEndLoc }, "Complex binding patterns"); @@ -14686,13 +14858,13 @@ class StatementParser extends ExpressionParser { const requireId = !!isStatement && !(statement & FUNC_NULLABLE_ID); this.initFunction(node, isAsync); - if (this.match(51) && isHangingStatement) { + if (this.match(55) && isHangingStatement) { this.raise(ErrorMessages.GeneratorInSingleStatementContext, { at: this.state.startLoc }); } - node.generator = this.eat(51); + node.generator = this.eat(55); if (isStatement) { node.id = this.parseFunctionId(requireId); @@ -14843,7 +15015,7 @@ class StatementParser extends ExpressionParser { } parseClassMember(classBody, member, state) { - const isStatic = this.isContextual(100); + const isStatic = this.isContextual(104); if (isStatic) { if (this.parseClassMemberFromModifier(classBody, member)) { @@ -14864,14 +15036,15 @@ class StatementParser extends ExpressionParser { const privateMethod = member; const publicProp = member; const privateProp = member; + const accessorProp = member; const method = publicMethod; const publicMember = publicMethod; member.static = isStatic; this.parsePropertyNamePrefixOperator(member); - if (this.eat(51)) { + if (this.eat(55)) { method.kind = "method"; - const isPrivateName = this.match(130); + const isPrivateName = this.match(134); this.parseClassElementName(method); if (isPrivateName) { @@ -14890,7 +15063,7 @@ class StatementParser extends ExpressionParser { } const isContextual = tokenIsIdentifier(this.state.type) && !this.state.containsEsc; - const isPrivate = this.match(130); + const isPrivate = this.match(134); const key = this.parseClassElementName(member); const maybeQuestionTokenStartLoc = this.state.startLoc; this.parsePostMemberNameModifiers(publicMember); @@ -14934,14 +15107,14 @@ class StatementParser extends ExpressionParser { } } else if (isContextual && key.name === "async" && !this.isLineTerminator()) { this.resetPreviousNodeTrailingComments(key); - const isGenerator = this.eat(51); + const isGenerator = this.eat(55); if (publicMember.optional) { this.unexpected(maybeQuestionTokenStartLoc); } method.kind = "method"; - const isPrivate = this.match(130); + const isPrivate = this.match(134); this.parseClassElementName(method); this.parsePostMemberNameModifiers(publicMember); @@ -14956,10 +15129,10 @@ class StatementParser extends ExpressionParser { this.pushClassMethod(classBody, publicMethod, isGenerator, true, false, false); } - } else if (isContextual && (key.name === "get" || key.name === "set") && !(this.match(51) && this.isLineTerminator())) { + } else if (isContextual && (key.name === "get" || key.name === "set") && !(this.match(55) && this.isLineTerminator())) { this.resetPreviousNodeTrailingComments(key); method.kind = key.name; - const isPrivate = this.match(130); + const isPrivate = this.match(134); this.parseClassElementName(publicMethod); if (isPrivate) { @@ -14975,6 +15148,12 @@ class StatementParser extends ExpressionParser { } this.checkGetterSetterParams(publicMethod); + } else if (isContextual && key.name === "accessor" && !this.isLineTerminator()) { + this.expectPlugin("decoratorAutoAccessors"); + this.resetPreviousNodeTrailingComments(key); + const isPrivate = this.match(134); + this.parseClassElementName(publicProp); + this.pushClassAccessorProperty(classBody, accessorProp, isPrivate); } else if (this.isLineTerminator()) { if (isPrivate) { this.pushClassPrivateProperty(classBody, privateProp); @@ -14992,13 +15171,13 @@ class StatementParser extends ExpressionParser { value } = this.state; - if ((type === 124 || type === 125) && member.static && value === "prototype") { + if ((type === 128 || type === 129) && member.static && value === "prototype") { this.raise(ErrorMessages.StaticPrototype, { at: this.state.startLoc }); } - if (type === 130) { + if (type === 134) { if (value === "constructor") { this.raise(ErrorMessages.ConstructorClassPrivateField, { at: this.state.startLoc @@ -15050,6 +15229,25 @@ class StatementParser extends ExpressionParser { this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), CLASS_ELEMENT_OTHER, node.key.loc.start); } + pushClassAccessorProperty(classBody, prop, isPrivate) { + if (!isPrivate && !prop.computed) { + const key = prop.key; + + if (key.name === "constructor" || key.value === "constructor") { + this.raise(ErrorMessages.ConstructorClassField, { + node: key + }); + } + } + + const node = this.parseClassAccessorProperty(prop); + classBody.body.push(node); + + if (isPrivate) { + this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), CLASS_ELEMENT_OTHER, node.key.loc.start); + } + } + pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) { classBody.body.push(this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true)); } @@ -15079,6 +15277,12 @@ class StatementParser extends ExpressionParser { return this.finishNode(node, "ClassProperty"); } + parseClassAccessorProperty(node) { + this.parseInitializer(node); + this.semicolon(); + return this.finishNode(node, "ClassAccessorProperty"); + } + parseInitializer(node) { this.scope.enter(SCOPE_CLASS | SCOPE_SUPER); this.expressionScope.enter(newExpressionScope()); @@ -15108,7 +15312,7 @@ class StatementParser extends ExpressionParser { } parseClassSuper(node) { - node.superClass = this.eat(77) ? this.parseExprSubscripts() : null; + node.superClass = this.eat(81) ? this.parseExprSubscripts() : null; } parseExport(node) { @@ -15145,7 +15349,7 @@ class StatementParser extends ExpressionParser { return this.finishNode(node, "ExportNamedDeclaration"); } - if (this.eat(61)) { + if (this.eat(65)) { node.declaration = this.parseExportDefaultExpression(); this.checkExport(node, true, true); return this.finishNode(node, "ExportDefaultDeclaration"); @@ -15155,7 +15359,7 @@ class StatementParser extends ExpressionParser { } eatExportStar(node) { - return this.eat(51); + return this.eat(55); } maybeParseExportDefaultSpecifier(node) { @@ -15171,7 +15375,7 @@ class StatementParser extends ExpressionParser { } maybeParseExportNamespaceSpecifier(node) { - if (this.isContextual(89)) { + if (this.isContextual(93)) { if (!node.specifiers) node.specifiers = []; const specifier = this.startNodeAt(this.state.lastTokStart, this.state.lastTokStartLoc); this.next(); @@ -15218,7 +15422,7 @@ class StatementParser extends ExpressionParser { } isAsyncFunction() { - if (!this.isContextual(91)) return false; + if (!this.isContextual(95)) return false; const next = this.nextTokenStart(); return !lineBreak.test(this.input.slice(this.state.pos, next)) && this.isUnparsedContextual(next, "function"); } @@ -15227,7 +15431,7 @@ class StatementParser extends ExpressionParser { const expr = this.startNode(); const isAsync = this.isAsyncFunction(); - if (this.match(64) || isAsync) { + if (this.match(68) || isAsync) { this.next(); if (isAsync) { @@ -15237,7 +15441,7 @@ class StatementParser extends ExpressionParser { return this.parseFunction(expr, FUNC_STATEMENT | FUNC_NULLABLE_ID, isAsync); } - if (this.match(76)) { + if (this.match(80)) { return this.parseClass(expr, true, true); } @@ -15252,7 +15456,7 @@ class StatementParser extends ExpressionParser { return this.parseClass(expr, true, true); } - if (this.match(71) || this.match(70) || this.isLet()) { + if (this.match(75) || this.match(74) || this.isLet()) { throw this.raise(ErrorMessages.UnsupportedDefaultExport, { at: this.state.startLoc }); @@ -15273,21 +15477,21 @@ class StatementParser extends ExpressionParser { } = this.state; if (tokenIsIdentifier(type)) { - if (type === 91 && !this.state.containsEsc || type === 95) { + if (type === 95 && !this.state.containsEsc || type === 99) { return false; } - if ((type === 122 || type === 121) && !this.state.containsEsc) { + if ((type === 126 || type === 125) && !this.state.containsEsc) { const { type: nextType } = this.lookahead(); - if (tokenIsIdentifier(nextType) && nextType !== 93 || nextType === 5) { + if (tokenIsIdentifier(nextType) && nextType !== 97 || nextType === 5) { this.expectOnePlugin(["flow", "typescript"]); return false; } } - } else if (!this.match(61)) { + } else if (!this.match(65)) { return false; } @@ -15298,7 +15502,7 @@ class StatementParser extends ExpressionParser { return true; } - if (this.match(61) && hasFrom) { + if (this.match(65) && hasFrom) { const nextAfterFrom = this.input.charCodeAt(this.nextTokenStartSince(next + 4)); return nextAfterFrom === 34 || nextAfterFrom === 39; } @@ -15307,7 +15511,7 @@ class StatementParser extends ExpressionParser { } parseExportFrom(node, expect) { - if (this.eatContextual(93)) { + if (this.eatContextual(97)) { node.source = this.parseImportSource(); this.checkExport(node); const assertions = this.maybeParseImportAssertions(); @@ -15341,7 +15545,7 @@ class StatementParser extends ExpressionParser { } } - return type === 70 || type === 71 || type === 64 || type === 76 || this.isLet() || this.isAsyncFunction(); + return type === 74 || type === 75 || type === 68 || type === 80 || this.isLet() || this.isAsyncFunction(); } checkExport(node, checkNames, isDefault, isFrom) { @@ -15450,8 +15654,8 @@ class StatementParser extends ExpressionParser { if (this.eat(8)) break; } - const isMaybeTypeOnly = this.isContextual(122); - const isString = this.match(125); + const isMaybeTypeOnly = this.isContextual(126); + const isString = this.match(129); const node = this.startNode(); node.local = this.parseModuleExportName(); nodes.push(this.parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly)); @@ -15461,7 +15665,7 @@ class StatementParser extends ExpressionParser { } parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly) { - if (this.eatContextual(89)) { + if (this.eatContextual(93)) { node.exported = this.parseModuleExportName(); } else if (isString) { node.exported = cloneStringLiteral(node.local); @@ -15473,7 +15677,7 @@ class StatementParser extends ExpressionParser { } parseModuleExportName() { - if (this.match(125)) { + if (this.match(129)) { const result = this.parseStringLiteral(this.state.value); const surrogate = result.value.match(loneSurrogate); @@ -15492,12 +15696,12 @@ class StatementParser extends ExpressionParser { parseImport(node) { node.specifiers = []; - if (!this.match(125)) { + if (!this.match(129)) { const hasDefault = this.maybeParseDefaultImportSpecifier(node); const parseNext = !hasDefault || this.eat(12); const hasStar = parseNext && this.maybeParseStarImportSpecifier(node); if (parseNext && !hasStar) this.parseNamedImportSpecifiers(node); - this.expectContextual(93); + this.expectContextual(97); } node.source = this.parseImportSource(); @@ -15518,7 +15722,7 @@ class StatementParser extends ExpressionParser { } parseImportSource() { - if (!this.match(125)) this.unexpected(); + if (!this.match(129)) this.unexpected(); return this.parseExprAtom(); } @@ -15552,7 +15756,7 @@ class StatementParser extends ExpressionParser { attrNames.add(keyName); - if (this.match(125)) { + if (this.match(129)) { node.key = this.parseStringLiteral(keyName); } else { node.key = this.parseIdentifier(true); @@ -15560,7 +15764,7 @@ class StatementParser extends ExpressionParser { this.expect(14); - if (!this.match(125)) { + if (!this.match(129)) { throw this.raise(ErrorMessages.ModuleAttributeInvalidValue, { at: this.state.startLoc }); @@ -15575,7 +15779,7 @@ class StatementParser extends ExpressionParser { } maybeParseModuleAttributes() { - if (this.match(72) && !this.hasPrecedingLineBreak()) { + if (this.match(76) && !this.hasPrecedingLineBreak()) { this.expectPlugin("moduleAttributes"); this.next(); } else { @@ -15605,7 +15809,7 @@ class StatementParser extends ExpressionParser { attributes.add(node.key.name); this.expect(14); - if (!this.match(125)) { + if (!this.match(129)) { throw this.raise(ErrorMessages.ModuleAttributeInvalidValue, { at: this.state.startLoc }); @@ -15620,7 +15824,7 @@ class StatementParser extends ExpressionParser { } maybeParseImportAssertions() { - if (this.isContextual(90) && !this.hasPrecedingLineBreak()) { + if (this.isContextual(94) && !this.hasPrecedingLineBreak()) { this.expectPlugin("importAssertions"); this.next(); } else { @@ -15644,10 +15848,10 @@ class StatementParser extends ExpressionParser { } maybeParseStarImportSpecifier(node) { - if (this.match(51)) { + if (this.match(55)) { const specifier = this.startNode(); this.next(); - this.expectContextual(89); + this.expectContextual(93); this.parseImportSpecifierLocal(node, specifier, "ImportNamespaceSpecifier", "import namespace specifier"); return true; } @@ -15674,8 +15878,8 @@ class StatementParser extends ExpressionParser { } const specifier = this.startNode(); - const importedIsString = this.match(125); - const isMaybeTypeOnly = this.isContextual(122); + const importedIsString = this.match(129); + const isMaybeTypeOnly = this.isContextual(126); specifier.imported = this.parseModuleExportName(); const importSpecifier = this.parseImportSpecifier(specifier, importedIsString, node.importKind === "type" || node.importKind === "typeof", isMaybeTypeOnly); node.specifiers.push(importSpecifier); @@ -15683,7 +15887,7 @@ class StatementParser extends ExpressionParser { } parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly) { - if (this.eatContextual(89)) { + if (this.eatContextual(93)) { specifier.local = this.parseIdentifier(); } else { const { diff --git a/node_modules/@babel/parser/lib/index.js.map b/node_modules/@babel/parser/lib/index.js.map index cf5316647..4c35ccf50 100644 --- a/node_modules/@babel/parser/lib/index.js.map +++ b/node_modules/@babel/parser/lib/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sources":["../src/util/location.js","../src/parser/base.js","../src/parser/comments.js","../src/parser/error-codes.js","../src/parser/error-message.js","../src/parser/error.js","../src/plugins/estree.js","../src/tokenizer/context.js","../src/tokenizer/types.js","../../babel-helper-validator-identifier/src/identifier.ts","../../babel-helper-validator-identifier/src/keyword.ts","../src/util/identifier.js","../src/util/scopeflags.js","../src/util/scope.js","../src/plugins/flow/scope.js","../src/util/whitespace.js","../src/tokenizer/state.js","../src/tokenizer/index.js","../src/util/class-scope.js","../src/util/expression-scope.js","../src/util/production-parameter.js","../src/parser/util.js","../src/parser/node.js","../src/plugins/flow/index.js","../src/plugins/jsx/xhtml.js","../src/plugins/jsx/index.js","../src/plugins/typescript/scope.js","../src/plugins/typescript/index.js","../src/plugins/placeholders.js","../src/plugins/v8intrinsic.js","../src/plugin-utils.js","../src/options.js","../src/parser/lval.js","../src/parser/expression.js","../src/parser/statement.js","../src/parser/index.js","../src/index.js"],"sourcesContent":["// @flow\n\nexport type Pos = {\n start: number,\n};\n\n// These are used when `options.locations` is on, for the\n// `startLoc` and `endLoc` properties.\n\nexport class Position {\n line: number;\n column: number;\n index: number;\n\n constructor(line: number, col: number, index: number) {\n this.line = line;\n this.column = col;\n\n // this.index = index;\n // Object.defineProperty(this, \"index\", { enumerable: false, value: index });\n indexes.set(this, index);\n }\n}\n\nexport class SourceLocation {\n start: Position;\n end: Position;\n filename: string;\n identifierName: ?string;\n\n constructor(start: Position, end?: Position) {\n this.start = start;\n // $FlowIgnore (may start as null, but initialized later)\n this.end = end;\n }\n}\n\nexport const indexes: WeakMap = new WeakMap();\n\n/**\n * creates a new position with a non-zero column offset from the given position.\n * This function should be only be used when we create AST node out of the token\n * boundaries, such as TemplateElement ends before tt.templateNonTail. This\n * function does not skip whitespaces.\n *\n * @export\n * @param {Position} position\n * @param {number} columnOffset\n * @returns {Position}\n */\nexport function createPositionWithColumnOffset(\n position: Position,\n columnOffset: number,\n) {\n const { line, column } = position;\n return new Position(\n line,\n column + columnOffset,\n indexes.get(position) + columnOffset,\n );\n}\n","// @flow\n\nimport type { Options } from \"../options\";\nimport type State from \"../tokenizer/state\";\nimport type { PluginsMap } from \"./index\";\nimport type ScopeHandler from \"../util/scope\";\nimport type ExpressionScopeHandler from \"../util/expression-scope\";\nimport type ClassScopeHandler from \"../util/class-scope\";\nimport type ProductionParameterHandler from \"../util/production-parameter\";\n\nexport default class BaseParser {\n // Properties set by constructor in index.js\n declare options: Options;\n declare inModule: boolean;\n declare scope: ScopeHandler<*>;\n declare classScope: ClassScopeHandler;\n declare prodParam: ProductionParameterHandler;\n declare expressionScope: ExpressionScopeHandler;\n declare plugins: PluginsMap;\n declare filename: ?string;\n // Names of exports store. `default` is stored as a name for both\n // `export default foo;` and `export { foo as default };`.\n declare exportedIdentifiers: Set;\n sawUnambiguousESM: boolean = false;\n ambiguousScriptDifferentAst: boolean = false;\n\n // Initialized by Tokenizer\n declare state: State;\n // input and length are not in state as they are constant and we do\n // not want to ever copy them, which happens if state gets cloned\n declare input: string;\n declare length: number;\n\n // This method accepts either a string (plugin name) or an array pair\n // (plugin name and options object). If an options object is given,\n // then each value is non-recursively checked for identity with that\n // plugin’s actual option value.\n hasPlugin(pluginConfig: PluginConfig): boolean {\n if (typeof pluginConfig === \"string\") {\n return this.plugins.has(pluginConfig);\n } else {\n const [pluginName, pluginOptions] = pluginConfig;\n if (!this.hasPlugin(pluginName)) {\n return false;\n }\n const actualOptions = this.plugins.get(pluginName);\n for (const key of Object.keys(pluginOptions)) {\n if (actualOptions?.[key] !== pluginOptions[key]) {\n return false;\n }\n }\n return true;\n }\n }\n\n getPluginOption(plugin: string, name: string) {\n return this.plugins.get(plugin)?.[name];\n }\n}\n\nexport type PluginConfig = string | [string, { [string]: any }];\n","// @flow\n\n/*:: declare var invariant; */\n\nimport BaseParser from \"./base\";\nimport type { Comment, Node } from \"../types\";\nimport * as charCodes from \"charcodes\";\n\n/**\n * A whitespace token containing comments\n * @typedef CommentWhitespace\n * @type {object}\n * @property {number} start - the start of the whitespace token.\n * @property {number} end - the end of the whitespace token.\n * @property {Array} comments - the containing comments\n * @property {Node | null} leadingNode - the immediately preceding AST node of the whitespace token\n * @property {Node | null} trailingNode - the immediately following AST node of the whitespace token\n * @property {Node | null} containingNode - the innermost AST node containing the whitespace\n * with minimal size (|end - start|)\n */\nexport type CommentWhitespace = {\n start: number,\n end: number,\n comments: Array,\n leadingNode: Node | null,\n trailingNode: Node | null,\n containingNode: Node | null,\n};\n\n/**\n * Merge comments with node's trailingComments or assign comments to be\n * trailingComments. New comments will be placed before old comments\n * because the commentStack is enumerated reversely.\n *\n * @param {Node} node\n * @param {Array} comments\n */\nfunction setTrailingComments(node: Node, comments: Array) {\n if (node.trailingComments === undefined) {\n node.trailingComments = comments;\n } else {\n node.trailingComments.unshift(...comments);\n }\n}\n\n/**\n * Merge comments with node's leadingComments or assign comments to be\n * leadingComments. New comments will be placed before old comments\n * because the commentStack is enumerated reversely.\n *\n * @param {Node} node\n * @param {Array} comments\n */\nfunction setLeadingComments(node: Node, comments: Array) {\n if (node.leadingComments === undefined) {\n node.leadingComments = comments;\n } else {\n node.leadingComments.unshift(...comments);\n }\n}\n\n/**\n * Merge comments with node's innerComments or assign comments to be\n * innerComments. New comments will be placed before old comments\n * because the commentStack is enumerated reversely.\n *\n * @param {Node} node\n * @param {Array} comments\n */\nexport function setInnerComments(node: Node, comments: Array) {\n if (node.innerComments === undefined) {\n node.innerComments = comments;\n } else {\n node.innerComments.unshift(...comments);\n }\n}\n\n/**\n * Given node and elements array, if elements has non-null element,\n * merge comments to its trailingComments, otherwise merge comments\n * to node's innerComments\n *\n * @param {Node} node\n * @param {Array} elements\n * @param {Array} comments\n */\nfunction adjustInnerComments(\n node: Node,\n elements: Array,\n commentWS: CommentWhitespace,\n) {\n let lastElement = null;\n let i = elements.length;\n while (lastElement === null && i > 0) {\n lastElement = elements[--i];\n }\n if (lastElement === null || lastElement.start > commentWS.start) {\n setInnerComments(node, commentWS.comments);\n } else {\n setTrailingComments(lastElement, commentWS.comments);\n }\n}\n\n/** @class CommentsParser */\nexport default class CommentsParser extends BaseParser {\n addComment(comment: Comment): void {\n if (this.filename) comment.loc.filename = this.filename;\n this.state.comments.push(comment);\n }\n\n /**\n * Given a newly created AST node _n_, attach _n_ to a comment whitespace _w_ if applicable\n * {@see {@link CommentWhitespace}}\n *\n * @param {Node} node\n * @returns {void}\n * @memberof CommentsParser\n */\n processComment(node: Node): void {\n const { commentStack } = this.state;\n const commentStackLength = commentStack.length;\n if (commentStackLength === 0) return;\n let i = commentStackLength - 1;\n const lastCommentWS = commentStack[i];\n\n if (lastCommentWS.start === node.end) {\n lastCommentWS.leadingNode = node;\n i--;\n }\n\n const { start: nodeStart } = node;\n // invariant: for all 0 <= j <= i, let c = commentStack[j], c must satisfy c.end < node.end\n for (; i >= 0; i--) {\n const commentWS = commentStack[i];\n const commentEnd = commentWS.end;\n if (commentEnd > nodeStart) {\n // by definition of commentWhiteSpace, this implies commentWS.start > nodeStart\n // so node can be a containingNode candidate. At this time we can finalize the comment\n // whitespace, because\n // 1) its leadingNode or trailingNode, if exists, will not change\n // 2) its containingNode have been assigned and will not change because it is the\n // innermost minimal-sized AST node\n commentWS.containingNode = node;\n this.finalizeComment(commentWS);\n commentStack.splice(i, 1);\n } else {\n if (commentEnd === nodeStart) {\n commentWS.trailingNode = node;\n }\n // stop the loop when commentEnd <= nodeStart\n break;\n }\n }\n }\n\n /**\n * Assign the comments of comment whitespaces to related AST nodes.\n * Also adjust innerComments following trailing comma.\n *\n * @memberof CommentsParser\n */\n finalizeComment(commentWS: CommentWhitespace) {\n const { comments } = commentWS;\n if (commentWS.leadingNode !== null || commentWS.trailingNode !== null) {\n if (commentWS.leadingNode !== null) {\n setTrailingComments(commentWS.leadingNode, comments);\n }\n if (commentWS.trailingNode !== null) {\n setLeadingComments(commentWS.trailingNode, comments);\n }\n } else {\n /*:: invariant(commentWS.containingNode !== null) */\n const { containingNode: node, start: commentStart } = commentWS;\n if (this.input.charCodeAt(commentStart - 1) === charCodes.comma) {\n // If a commentWhitespace follows a comma and the containingNode allows\n // list structures with trailing comma, merge it to the trailingComment\n // of the last non-null list element\n switch (node.type) {\n case \"ObjectExpression\":\n case \"ObjectPattern\":\n case \"RecordExpression\":\n adjustInnerComments(node, node.properties, commentWS);\n break;\n case \"CallExpression\":\n case \"OptionalCallExpression\":\n adjustInnerComments(node, node.arguments, commentWS);\n break;\n case \"FunctionDeclaration\":\n case \"FunctionExpression\":\n case \"ArrowFunctionExpression\":\n case \"ObjectMethod\":\n case \"ClassMethod\":\n case \"ClassPrivateMethod\":\n adjustInnerComments(node, node.params, commentWS);\n break;\n case \"ArrayExpression\":\n case \"ArrayPattern\":\n case \"TupleExpression\":\n adjustInnerComments(node, node.elements, commentWS);\n break;\n case \"ExportNamedDeclaration\":\n case \"ImportDeclaration\":\n adjustInnerComments(node, node.specifiers, commentWS);\n break;\n default: {\n setInnerComments(node, comments);\n }\n }\n } else {\n setInnerComments(node, comments);\n }\n }\n }\n\n /**\n * Drains remaning commentStack and applies finalizeComment\n * to each comment whitespace. Used only in parseExpression\n * where the top level AST node is _not_ Program\n * {@see {@link CommentsParser#finalizeComment}}\n *\n * @memberof CommentsParser\n */\n finalizeRemainingComments() {\n const { commentStack } = this.state;\n for (let i = commentStack.length - 1; i >= 0; i--) {\n this.finalizeComment(commentStack[i]);\n }\n this.state.commentStack = [];\n }\n\n /**\n * Reset previous node trailing comments. Used in object / class\n * property parsing. We parse `async`, `static`, `set` and `get`\n * as an identifier but may reinterepret it into an async/static/accessor\n * method later. In this case the identifier is not part of the AST and we\n * should sync the knowledge to commentStacks\n *\n * For example, when parsing */\n // async /* 1 */ function f() {}\n /*\n * the comment whitespace \"* 1 *\" has leading node Identifier(async). When\n * we see the function token, we create a Function node and mark \"* 1 *\" as\n * inner comments. So \"* 1 *\" should be detached from the Identifier node.\n *\n * @param {N.Node} node the last finished AST node _before_ current token\n * @returns\n * @memberof CommentsParser\n */\n resetPreviousNodeTrailingComments(node: Node) {\n const { commentStack } = this.state;\n const { length } = commentStack;\n if (length === 0) return;\n const commentWS = commentStack[length - 1];\n if (commentWS.leadingNode === node) {\n commentWS.leadingNode = null;\n }\n }\n\n /**\n * Attach a node to the comment whitespaces right before/after\n * the given range.\n *\n * This is used to properly attach comments around parenthesized\n * expressions as leading/trailing comments of the inner expression.\n *\n * @param {Node} node\n * @param {number} start\n * @param {number} end\n */\n takeSurroundingComments(node: Node, start: number, end: number) {\n const { commentStack } = this.state;\n const commentStackLength = commentStack.length;\n if (commentStackLength === 0) return;\n let i = commentStackLength - 1;\n\n for (; i >= 0; i--) {\n const commentWS = commentStack[i];\n const commentEnd = commentWS.end;\n const commentStart = commentWS.start;\n\n if (commentStart === end) {\n commentWS.leadingNode = node;\n } else if (commentEnd === start) {\n commentWS.trailingNode = node;\n } else if (commentEnd < start) {\n break;\n }\n }\n }\n}\n","// @flow\n\nexport const ErrorCodes = Object.freeze({\n SyntaxError: \"BABEL_PARSER_SYNTAX_ERROR\",\n SourceTypeModuleError: \"BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED\",\n});\n\nexport type ErrorCode = $Values;\n","// @flow\n\nimport { makeErrorTemplates, ErrorCodes } from \"./error\";\n\n/* eslint sort-keys: \"error\" */\n\n/**\n * @module parser/error-message\n */\n\n// The Errors key follows https://cs.chromium.org/chromium/src/v8/src/common/message-template.h unless it does not exist\nexport const ErrorMessages = makeErrorTemplates(\n {\n AccessorIsGenerator: \"A %0ter cannot be a generator.\",\n ArgumentsInClass:\n \"'arguments' is only allowed in functions and class methods.\",\n AsyncFunctionInSingleStatementContext:\n \"Async functions can only be declared at the top level or inside a block.\",\n AwaitBindingIdentifier:\n \"Can not use 'await' as identifier inside an async function.\",\n AwaitBindingIdentifierInStaticBlock:\n \"Can not use 'await' as identifier inside a static block.\",\n AwaitExpressionFormalParameter:\n \"'await' is not allowed in async function parameters.\",\n AwaitNotInAsyncContext:\n \"'await' is only allowed within async functions and at the top levels of modules.\",\n AwaitNotInAsyncFunction: \"'await' is only allowed within async functions.\",\n BadGetterArity: \"A 'get' accesor must not have any formal parameters.\",\n BadSetterArity: \"A 'set' accesor must have exactly one formal parameter.\",\n BadSetterRestParameter:\n \"A 'set' accesor function argument must not be a rest parameter.\",\n ConstructorClassField: \"Classes may not have a field named 'constructor'.\",\n ConstructorClassPrivateField:\n \"Classes may not have a private field named '#constructor'.\",\n ConstructorIsAccessor: \"Class constructor may not be an accessor.\",\n ConstructorIsAsync: \"Constructor can't be an async function.\",\n ConstructorIsGenerator: \"Constructor can't be a generator.\",\n DeclarationMissingInitializer: \"'%0' require an initialization value.\",\n DecoratorBeforeExport:\n \"Decorators must be placed *before* the 'export' keyword. You can set the 'decoratorsBeforeExport' option to false to use the 'export @decorator class {}' syntax.\",\n DecoratorConstructor:\n \"Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?\",\n DecoratorExportClass:\n \"Using the export keyword between a decorator and a class is not allowed. Please use `export @dec class` instead.\",\n DecoratorSemicolon: \"Decorators must not be followed by a semicolon.\",\n DecoratorStaticBlock: \"Decorators can't be used with a static block.\",\n DeletePrivateField: \"Deleting a private field is not allowed.\",\n DestructureNamedImport:\n \"ES2015 named imports do not destructure. Use another statement for destructuring after the import.\",\n DuplicateConstructor: \"Duplicate constructor in the same class.\",\n DuplicateDefaultExport: \"Only one default export allowed per module.\",\n DuplicateExport:\n \"`%0` has already been exported. Exported identifiers must be unique.\",\n DuplicateProto: \"Redefinition of __proto__ property.\",\n DuplicateRegExpFlags: \"Duplicate regular expression flag.\",\n ElementAfterRest: \"Rest element must be last element.\",\n EscapedCharNotAnIdentifier: \"Invalid Unicode escape.\",\n ExportBindingIsString:\n \"A string literal cannot be used as an exported binding without `from`.\\n- Did you mean `export { '%0' as '%1' } from 'some-module'`?\",\n ExportDefaultFromAsIdentifier:\n \"'from' is not allowed as an identifier after 'export default'.\",\n ForInOfLoopInitializer:\n \"'%0' loop variable declaration may not have an initializer.\",\n ForOfAsync: \"The left-hand side of a for-of loop may not be 'async'.\",\n ForOfLet: \"The left-hand side of a for-of loop may not start with 'let'.\",\n GeneratorInSingleStatementContext:\n \"Generators can only be declared at the top level or inside a block.\",\n IllegalBreakContinue: \"Unsyntactic %0.\",\n IllegalLanguageModeDirective:\n \"Illegal 'use strict' directive in function with non-simple parameter list.\",\n IllegalReturn: \"'return' outside of function.\",\n ImportBindingIsString:\n 'A string literal cannot be used as an imported binding.\\n- Did you mean `import { \"%0\" as foo }`?',\n ImportCallArgumentTrailingComma:\n \"Trailing comma is disallowed inside import(...) arguments.\",\n ImportCallArity: \"`import()` requires exactly %0.\",\n ImportCallNotNewExpression: \"Cannot use new with import(...).\",\n ImportCallSpreadArgument: \"`...` is not allowed in `import()`.\",\n InvalidBigIntLiteral: \"Invalid BigIntLiteral.\",\n InvalidCodePoint: \"Code point out of bounds.\",\n InvalidCoverInitializedName: \"Invalid shorthand property initializer.\",\n InvalidDecimal: \"Invalid decimal.\",\n InvalidDigit: \"Expected number in radix %0.\",\n InvalidEscapeSequence: \"Bad character escape sequence.\",\n InvalidEscapeSequenceTemplate: \"Invalid escape sequence in template.\",\n InvalidEscapedReservedWord: \"Escape sequence in keyword %0.\",\n InvalidIdentifier: \"Invalid identifier %0.\",\n InvalidLhs: \"Invalid left-hand side in %0.\",\n InvalidLhsBinding: \"Binding invalid left-hand side in %0.\",\n InvalidNumber: \"Invalid number.\",\n InvalidOrMissingExponent:\n \"Floating-point numbers require a valid exponent after the 'e'.\",\n InvalidOrUnexpectedToken: \"Unexpected character '%0'.\",\n InvalidParenthesizedAssignment: \"Invalid parenthesized assignment pattern.\",\n InvalidPrivateFieldResolution: \"Private name #%0 is not defined.\",\n InvalidPropertyBindingPattern: \"Binding member expression.\",\n InvalidRecordProperty:\n \"Only properties and spread elements are allowed in record definitions.\",\n InvalidRestAssignmentPattern: \"Invalid rest operator's argument.\",\n LabelRedeclaration: \"Label '%0' is already declared.\",\n LetInLexicalBinding:\n \"'let' is not allowed to be used as a name in 'let' or 'const' declarations.\",\n LineTerminatorBeforeArrow: \"No line break is allowed before '=>'.\",\n MalformedRegExpFlags: \"Invalid regular expression flag.\",\n MissingClassName: \"A class name is required.\",\n MissingEqInAssignment:\n \"Only '=' operator can be used for specifying default value.\",\n MissingSemicolon: \"Missing semicolon.\",\n MissingUnicodeEscape: \"Expecting Unicode escape sequence \\\\uXXXX.\",\n MixingCoalesceWithLogical:\n \"Nullish coalescing operator(??) requires parens when mixing with logical operators.\",\n ModuleAttributeDifferentFromType:\n \"The only accepted module attribute is `type`.\",\n ModuleAttributeInvalidValue:\n \"Only string literals are allowed as module attribute values.\",\n ModuleAttributesWithDuplicateKeys:\n 'Duplicate key \"%0\" is not allowed in module attributes.',\n ModuleExportNameHasLoneSurrogate:\n \"An export name cannot include a lone surrogate, found '\\\\u%0'.\",\n ModuleExportUndefined: \"Export '%0' is not defined.\",\n MultipleDefaultsInSwitch: \"Multiple default clauses.\",\n NewlineAfterThrow: \"Illegal newline after throw.\",\n NoCatchOrFinally: \"Missing catch or finally clause.\",\n NumberIdentifier: \"Identifier directly after number.\",\n NumericSeparatorInEscapeSequence:\n \"Numeric separators are not allowed inside unicode escape sequences or hex escape sequences.\",\n ObsoleteAwaitStar:\n \"'await*' has been removed from the async functions proposal. Use Promise.all() instead.\",\n OptionalChainingNoNew:\n \"Constructors in/after an Optional Chain are not allowed.\",\n OptionalChainingNoTemplate:\n \"Tagged Template Literals are not allowed in optionalChain.\",\n OverrideOnConstructor:\n \"'override' modifier cannot appear on a constructor declaration.\",\n ParamDupe: \"Argument name clash.\",\n PatternHasAccessor: \"Object pattern can't contain getter or setter.\",\n PatternHasMethod: \"Object pattern can't contain methods.\",\n // This error is only used by the smart-mix proposal\n PipeBodyIsTighter:\n \"Unexpected %0 after pipeline body; any %0 expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence.\",\n PipeTopicRequiresHackPipes:\n 'Topic reference is used, but the pipelineOperator plugin was not passed a \"proposal\": \"hack\" or \"smart\" option.',\n PipeTopicUnbound:\n \"Topic reference is unbound; it must be inside a pipe body.\",\n PipeTopicUnconfiguredToken:\n 'Invalid topic token %0. In order to use %0 as a topic reference, the pipelineOperator plugin must be configured with { \"proposal\": \"hack\", \"topicToken\": \"%0\" }.',\n PipeTopicUnused:\n \"Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once.\",\n PipeUnparenthesizedBody:\n \"Hack-style pipe body cannot be an unparenthesized %0 expression; please wrap it in parentheses.\",\n\n // Messages whose codes start with “Pipeline” or “PrimaryTopic”\n // are retained for backwards compatibility\n // with the deprecated smart-mix pipe operator proposal plugin.\n // They are subject to removal in a future major version.\n PipelineBodyNoArrow:\n 'Unexpected arrow \"=>\" after pipeline body; arrow function in pipeline body must be parenthesized.',\n PipelineBodySequenceExpression:\n \"Pipeline body may not be a comma-separated sequence expression.\",\n PipelineHeadSequenceExpression:\n \"Pipeline head should not be a comma-separated sequence expression.\",\n PipelineTopicUnused:\n \"Pipeline is in topic style but does not use topic reference.\",\n PrimaryTopicNotAllowed:\n \"Topic reference was used in a lexical context without topic binding.\",\n PrimaryTopicRequiresSmartPipeline:\n 'Topic reference is used, but the pipelineOperator plugin was not passed a \"proposal\": \"hack\" or \"smart\" option.',\n\n PrivateInExpectedIn:\n \"Private names are only allowed in property accesses (`obj.#%0`) or in `in` expressions (`#%0 in obj`).\",\n PrivateNameRedeclaration: \"Duplicate private name #%0.\",\n RecordExpressionBarIncorrectEndSyntaxType:\n \"Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.\",\n RecordExpressionBarIncorrectStartSyntaxType:\n \"Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.\",\n RecordExpressionHashIncorrectStartSyntaxType:\n \"Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.\",\n RecordNoProto: \"'__proto__' is not allowed in Record expressions.\",\n RestTrailingComma: \"Unexpected trailing comma after rest element.\",\n SloppyFunction:\n \"In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement.\",\n StaticPrototype: \"Classes may not have static property named prototype.\",\n StrictDelete: \"Deleting local variable in strict mode.\",\n StrictEvalArguments: \"Assigning to '%0' in strict mode.\",\n StrictEvalArgumentsBinding: \"Binding '%0' in strict mode.\",\n StrictFunction:\n \"In strict mode code, functions can only be declared at top level or inside a block.\",\n StrictNumericEscape:\n \"The only valid numeric escape in strict mode is '\\\\0'.\",\n StrictOctalLiteral: \"Legacy octal literals are not allowed in strict mode.\",\n StrictWith: \"'with' in strict mode.\",\n SuperNotAllowed:\n \"`super()` is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?\",\n SuperPrivateField: \"Private fields can't be accessed on super.\",\n TrailingDecorator: \"Decorators must be attached to a class element.\",\n TupleExpressionBarIncorrectEndSyntaxType:\n \"Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.\",\n TupleExpressionBarIncorrectStartSyntaxType:\n \"Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.\",\n TupleExpressionHashIncorrectStartSyntaxType:\n \"Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.\",\n UnexpectedArgumentPlaceholder: \"Unexpected argument placeholder.\",\n UnexpectedAwaitAfterPipelineBody:\n 'Unexpected \"await\" after pipeline body; await must have parentheses in minimal proposal.',\n UnexpectedDigitAfterHash: \"Unexpected digit after hash token.\",\n UnexpectedImportExport:\n \"'import' and 'export' may only appear at the top level.\",\n UnexpectedKeyword: \"Unexpected keyword '%0'.\",\n UnexpectedLeadingDecorator:\n \"Leading decorators must be attached to a class declaration.\",\n UnexpectedLexicalDeclaration:\n \"Lexical declaration cannot appear in a single-statement context.\",\n UnexpectedNewTarget:\n \"`new.target` can only be used in functions or class properties.\",\n UnexpectedNumericSeparator:\n \"A numeric separator is only allowed between two digits.\",\n UnexpectedPrivateField: \"Unexpected private name.\",\n UnexpectedReservedWord: \"Unexpected reserved word '%0'.\",\n UnexpectedSuper: \"'super' is only allowed in object methods and classes.\",\n UnexpectedToken: \"Unexpected token '%0'.\",\n UnexpectedTokenUnaryExponentiation:\n \"Illegal expression. Wrap left hand side or entire exponentiation in parentheses.\",\n UnsupportedBind: \"Binding should be performed on object property.\",\n UnsupportedDecoratorExport:\n \"A decorated export must export a class declaration.\",\n UnsupportedDefaultExport:\n \"Only expressions, functions or classes are allowed as the `default` export.\",\n UnsupportedImport:\n \"`import` can only be used in `import()` or `import.meta`.\",\n UnsupportedMetaProperty: \"The only valid meta property for %0 is %0.%1.\",\n UnsupportedParameterDecorator:\n \"Decorators cannot be used to decorate parameters.\",\n UnsupportedPropertyDecorator:\n \"Decorators cannot be used to decorate object literal properties.\",\n UnsupportedSuper:\n \"'super' can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]).\",\n UnterminatedComment: \"Unterminated comment.\",\n UnterminatedRegExp: \"Unterminated regular expression.\",\n UnterminatedString: \"Unterminated string constant.\",\n UnterminatedTemplate: \"Unterminated template.\",\n VarRedeclaration: \"Identifier '%0' has already been declared.\",\n YieldBindingIdentifier:\n \"Can not use 'yield' as identifier inside a generator.\",\n YieldInParameter: \"Yield expression is not allowed in formal parameters.\",\n ZeroDigitNumericSeparator:\n \"Numeric separator can not be used after leading 0.\",\n },\n /* code */ ErrorCodes.SyntaxError,\n);\n\nexport const SourceTypeModuleErrorMessages = makeErrorTemplates(\n {\n ImportMetaOutsideModule: `import.meta may appear only with 'sourceType: \"module\"'`,\n ImportOutsideModule: `'import' and 'export' may appear only with 'sourceType: \"module\"'`,\n },\n /* code */ ErrorCodes.SourceTypeModuleError,\n);\n","// @flow\n/* eslint sort-keys: \"error\" */\nimport { type Position, indexes } from \"../util/location\";\nimport CommentsParser from \"./comments\";\nimport { type ErrorCode, ErrorCodes } from \"./error-codes\";\nimport { type Node } from \"../types\";\n\n// This function is used to raise exceptions on parse errors. It\n// takes an offset integer (into the current `input`) to indicate\n// the location of the error, attaches the position to the end\n// of the error message, and then raises a `SyntaxError` with that\n// message.\n\ntype ErrorContext = {\n pos: number,\n loc: Position,\n missingPlugin?: Array,\n code?: string,\n reasonCode?: String,\n};\nexport type ParsingError = SyntaxError & ErrorContext;\n\nexport type ErrorTemplate = {\n code: ErrorCode,\n template: string,\n reasonCode: string,\n};\nexport type ErrorTemplates = {\n [key: string]: ErrorTemplate,\n};\n\ntype Origin = {| node: Node |} | {| at: Position |};\n\ntype SyntaxPlugin =\n | \"flow\"\n | \"typescript\"\n | \"jsx\"\n | \"placeholders\"\n | typeof undefined;\n\nfunction keepReasonCodeCompat(reasonCode: string, syntaxPlugin: SyntaxPlugin) {\n if (!process.env.BABEL_8_BREAKING) {\n // For consistency in TypeScript and Flow error codes\n if (syntaxPlugin === \"flow\" && reasonCode === \"PatternIsOptional\") {\n return \"OptionalBindingPattern\";\n }\n }\n return reasonCode;\n}\n\nexport function makeErrorTemplates(\n messages: {\n [key: string]: string,\n },\n code: ErrorCode,\n syntaxPlugin?: SyntaxPlugin,\n): ErrorTemplates {\n const templates: ErrorTemplates = {};\n Object.keys(messages).forEach(reasonCode => {\n templates[reasonCode] = Object.freeze({\n code,\n reasonCode: keepReasonCodeCompat(reasonCode, syntaxPlugin),\n template: messages[reasonCode],\n });\n });\n return Object.freeze(templates);\n}\n\nexport { ErrorCodes };\nexport {\n ErrorMessages as Errors,\n SourceTypeModuleErrorMessages as SourceTypeModuleErrors,\n} from \"./error-message\";\n\nexport type raiseFunction = (ErrorTemplate, Origin, ...any) => void;\nexport type ErrorData = {| message: ErrorTemplate, loc: Position |};\n\nexport default class ParserError extends CommentsParser {\n // Forward-declaration: defined in tokenizer/index.js\n /*::\n +isLookahead: boolean;\n */\n\n raise(\n { code, reasonCode, template }: ErrorTemplate,\n origin: Origin,\n ...params: any\n ): Error | empty {\n return this.raiseWithData(\n origin.node ? origin.node.loc.start : origin.at,\n { code, reasonCode },\n template,\n ...params,\n );\n }\n\n /**\n * Raise a parsing error on given position pos. If errorRecovery is true,\n * it will first search current errors and overwrite the error thrown on the exact\n * position before with the new error message. If errorRecovery is false, it\n * fallbacks to `raise`.\n *\n * @param {number} pos\n * @param {string} errorTemplate\n * @param {...any} params\n * @returns {(Error | empty)}\n * @memberof ParserError\n */\n raiseOverwrite(\n loc: Position,\n { code, template }: ErrorTemplate,\n ...params: any\n ): Error | empty {\n // $FlowIgnore[incompatible-type] We know this exists, so it can't be undefined.\n const pos: number = indexes.get(loc);\n const message =\n template.replace(/%(\\d+)/g, (_, i: number) => params[i]) +\n ` (${loc.line}:${loc.column})`;\n if (this.options.errorRecovery) {\n const errors = this.state.errors;\n for (let i = errors.length - 1; i >= 0; i--) {\n const error = errors[i];\n if (error.pos === pos) {\n return Object.assign(error, { message });\n } else if (error.pos < pos) {\n break;\n }\n }\n }\n return this._raise({ code, loc, pos }, message);\n }\n\n raiseWithData(\n loc: Position,\n data?: {\n missingPlugin?: Array,\n code?: string,\n },\n errorTemplate: string,\n ...params: any\n ): Error | empty {\n const pos = indexes.get(loc);\n const message =\n errorTemplate.replace(/%(\\d+)/g, (_, i: number) => params[i]) +\n ` (${loc.line}:${loc.column})`;\n return this._raise(Object.assign(({ loc, pos }: Object), data), message);\n }\n\n _raise(errorContext: ErrorContext, message: string): Error | empty {\n // $FlowIgnore\n const err: SyntaxError & ErrorContext = new SyntaxError(message);\n Object.assign(err, errorContext);\n if (this.options.errorRecovery) {\n if (!this.isLookahead) this.state.errors.push(err);\n return err;\n } else {\n throw err;\n }\n }\n}\n","// @flow\n\nimport { type TokenType } from \"../tokenizer/types\";\nimport type Parser from \"../parser\";\nimport type { ExpressionErrors } from \"../parser/util\";\nimport * as N from \"../types\";\nimport type { Position } from \"../util/location\";\nimport { Errors } from \"../parser/error\";\n\nexport default (superClass: Class): Class =>\n class extends superClass {\n parseRegExpLiteral({ pattern, flags }): N.Node {\n let regex = null;\n try {\n regex = new RegExp(pattern, flags);\n } catch (e) {\n // In environments that don't support these flags value will\n // be null as the regex can't be represented natively.\n }\n const node = this.estreeParseLiteral(regex);\n node.regex = { pattern, flags };\n\n return node;\n }\n\n parseBigIntLiteral(value: any): N.Node {\n // https://github.com/estree/estree/blob/master/es2020.md#bigintliteral\n let bigInt;\n try {\n // $FlowIgnore\n bigInt = BigInt(value);\n } catch {\n bigInt = null;\n }\n const node = this.estreeParseLiteral(bigInt);\n node.bigint = String(node.value || value);\n\n return node;\n }\n\n parseDecimalLiteral(value: any): N.Node {\n // https://github.com/estree/estree/blob/master/experimental/decimal.md\n // todo: use BigDecimal when node supports it.\n const decimal = null;\n const node = this.estreeParseLiteral(decimal);\n node.decimal = String(node.value || value);\n\n return node;\n }\n\n estreeParseLiteral(value: any) {\n return this.parseLiteral(value, \"Literal\");\n }\n\n parseStringLiteral(value: any): N.Node {\n return this.estreeParseLiteral(value);\n }\n\n parseNumericLiteral(value: any): any {\n return this.estreeParseLiteral(value);\n }\n\n parseNullLiteral(): N.Node {\n return this.estreeParseLiteral(null);\n }\n\n parseBooleanLiteral(value: boolean): N.BooleanLiteral {\n return this.estreeParseLiteral(value);\n }\n\n directiveToStmt(directive: N.Directive): N.ExpressionStatement {\n const directiveLiteral = directive.value;\n\n const stmt = this.startNodeAt(directive.start, directive.loc.start);\n const expression = this.startNodeAt(\n directiveLiteral.start,\n directiveLiteral.loc.start,\n );\n\n expression.value = directiveLiteral.extra.expressionValue;\n expression.raw = directiveLiteral.extra.raw;\n\n stmt.expression = this.finishNodeAt(\n expression,\n \"Literal\",\n directiveLiteral.loc.end,\n );\n stmt.directive = directiveLiteral.extra.raw.slice(1, -1);\n\n return this.finishNodeAt(stmt, \"ExpressionStatement\", directive.loc.end);\n }\n\n // ==================================\n // Overrides\n // ==================================\n\n initFunction(\n node: N.BodilessFunctionOrMethodBase,\n isAsync: ?boolean,\n ): void {\n super.initFunction(node, isAsync);\n node.expression = false;\n }\n\n checkDeclaration(node: N.Pattern | N.ObjectProperty): void {\n if (node != null && this.isObjectProperty(node)) {\n this.checkDeclaration(((node: any): N.EstreeProperty).value);\n } else {\n super.checkDeclaration(node);\n }\n }\n\n getObjectOrClassMethodParams(method: N.ObjectMethod | N.ClassMethod) {\n return ((method: any): N.EstreeProperty | N.EstreeMethodDefinition).value\n .params;\n }\n\n isValidDirective(stmt: N.Statement): boolean {\n return (\n stmt.type === \"ExpressionStatement\" &&\n stmt.expression.type === \"Literal\" &&\n typeof stmt.expression.value === \"string\" &&\n !stmt.expression.extra?.parenthesized\n );\n }\n\n parseBlockBody(\n node: N.BlockStatementLike,\n ...args: [?boolean, boolean, TokenType, void | (boolean => void)]\n ): void {\n super.parseBlockBody(node, ...args);\n\n const directiveStatements = node.directives.map(d =>\n this.directiveToStmt(d),\n );\n node.body = directiveStatements.concat(node.body);\n // $FlowIgnore - directives isn't optional in the type definition\n delete node.directives;\n }\n\n pushClassMethod(\n classBody: N.ClassBody,\n method: N.ClassMethod,\n isGenerator: boolean,\n isAsync: boolean,\n isConstructor: boolean,\n allowsDirectSuper: boolean,\n ): void {\n this.parseMethod(\n method,\n isGenerator,\n isAsync,\n isConstructor,\n allowsDirectSuper,\n \"ClassMethod\",\n true,\n );\n if (method.typeParameters) {\n // $FlowIgnore\n method.value.typeParameters = method.typeParameters;\n delete method.typeParameters;\n }\n classBody.body.push(method);\n }\n\n parsePrivateName(): any {\n const node = super.parsePrivateName();\n if (!process.env.BABEL_8_BREAKING) {\n if (!this.getPluginOption(\"estree\", \"classFeatures\")) {\n return node;\n }\n }\n return this.convertPrivateNameToPrivateIdentifier(node);\n }\n\n convertPrivateNameToPrivateIdentifier(\n node: N.PrivateName,\n ): N.EstreePrivateIdentifier {\n const name = super.getPrivateNameSV(node);\n node = (node: any);\n delete node.id;\n node.name = name;\n node.type = \"PrivateIdentifier\";\n return node;\n }\n\n isPrivateName(node: N.Node): boolean {\n if (!process.env.BABEL_8_BREAKING) {\n if (!this.getPluginOption(\"estree\", \"classFeatures\")) {\n return super.isPrivateName(node);\n }\n }\n return node.type === \"PrivateIdentifier\";\n }\n\n getPrivateNameSV(node: N.Node): string {\n if (!process.env.BABEL_8_BREAKING) {\n if (!this.getPluginOption(\"estree\", \"classFeatures\")) {\n return super.getPrivateNameSV(node);\n }\n }\n return node.name;\n }\n\n parseLiteral(value: any, type: $ElementType): T {\n const node = super.parseLiteral(value, type);\n node.raw = node.extra.raw;\n delete node.extra;\n\n return node;\n }\n\n parseFunctionBody(\n node: N.Function,\n allowExpression: ?boolean,\n isMethod?: boolean = false,\n ): void {\n super.parseFunctionBody(node, allowExpression, isMethod);\n node.expression = node.body.type !== \"BlockStatement\";\n }\n\n parseMethod(\n node: T,\n isGenerator: boolean,\n isAsync: boolean,\n isConstructor: boolean,\n allowDirectSuper: boolean,\n type: string,\n inClassScope: boolean = false,\n ): T {\n let funcNode = this.startNode();\n funcNode.kind = node.kind; // provide kind, so super method correctly sets state\n funcNode = super.parseMethod(\n funcNode,\n isGenerator,\n isAsync,\n isConstructor,\n allowDirectSuper,\n type,\n inClassScope,\n );\n funcNode.type = \"FunctionExpression\";\n delete funcNode.kind;\n // $FlowIgnore\n node.value = funcNode;\n if (type === \"ClassPrivateMethod\") {\n // $FlowIgnore\n node.computed = false;\n }\n type = \"MethodDefinition\";\n return this.finishNode(node, type);\n }\n\n parseClassProperty(...args: [N.ClassProperty]): any {\n const propertyNode = (super.parseClassProperty(...args): any);\n if (!process.env.BABEL_8_BREAKING) {\n if (!this.getPluginOption(\"estree\", \"classFeatures\")) {\n return (propertyNode: N.EstreePropertyDefinition);\n }\n }\n propertyNode.type = \"PropertyDefinition\";\n return (propertyNode: N.EstreePropertyDefinition);\n }\n\n parseClassPrivateProperty(...args: [N.ClassPrivateProperty]): any {\n const propertyNode = (super.parseClassPrivateProperty(...args): any);\n if (!process.env.BABEL_8_BREAKING) {\n if (!this.getPluginOption(\"estree\", \"classFeatures\")) {\n return (propertyNode: N.EstreePropertyDefinition);\n }\n }\n propertyNode.type = \"PropertyDefinition\";\n propertyNode.computed = false;\n return (propertyNode: N.EstreePropertyDefinition);\n }\n\n parseObjectMethod(\n prop: N.ObjectMethod,\n isGenerator: boolean,\n isAsync: boolean,\n isPattern: boolean,\n isAccessor: boolean,\n ): ?N.ObjectMethod {\n const node: N.EstreeProperty = (super.parseObjectMethod(\n prop,\n isGenerator,\n isAsync,\n isPattern,\n isAccessor,\n ): any);\n\n if (node) {\n node.type = \"Property\";\n if (((node: any): N.ClassMethod).kind === \"method\") node.kind = \"init\";\n node.shorthand = false;\n }\n\n return (node: any);\n }\n\n parseObjectProperty(\n prop: N.ObjectProperty,\n startPos: ?number,\n startLoc: ?Position,\n isPattern: boolean,\n refExpressionErrors: ?ExpressionErrors,\n ): ?N.ObjectProperty {\n const node: N.EstreeProperty = (super.parseObjectProperty(\n prop,\n startPos,\n startLoc,\n isPattern,\n refExpressionErrors,\n ): any);\n\n if (node) {\n node.kind = \"init\";\n node.type = \"Property\";\n }\n\n return (node: any);\n }\n\n isAssignable(node: N.Node, isBinding?: boolean): boolean {\n if (node != null && this.isObjectProperty(node)) {\n return this.isAssignable(node.value, isBinding);\n }\n return super.isAssignable(node, isBinding);\n }\n\n toAssignable(node: N.Node, isLHS: boolean = false): N.Node {\n if (node != null && this.isObjectProperty(node)) {\n this.toAssignable(node.value, isLHS);\n\n return node;\n }\n\n return super.toAssignable(node, isLHS);\n }\n\n toAssignableObjectExpressionProp(prop: N.Node, ...args) {\n if (prop.kind === \"get\" || prop.kind === \"set\") {\n this.raise(Errors.PatternHasAccessor, { node: prop.key });\n } else if (prop.method) {\n this.raise(Errors.PatternHasMethod, { node: prop.key });\n } else {\n super.toAssignableObjectExpressionProp(prop, ...args);\n }\n }\n\n finishCallExpression(\n node: T,\n optional: boolean,\n ): N.Expression {\n super.finishCallExpression(node, optional);\n\n if (node.callee.type === \"Import\") {\n ((node: N.Node): N.EstreeImportExpression).type = \"ImportExpression\";\n ((node: N.Node): N.EstreeImportExpression).source = node.arguments[0];\n if (this.hasPlugin(\"importAssertions\")) {\n ((node: N.Node): N.EstreeImportExpression).attributes =\n node.arguments[1] ?? null;\n }\n // $FlowIgnore - arguments isn't optional in the type definition\n delete node.arguments;\n // $FlowIgnore - callee isn't optional in the type definition\n delete node.callee;\n }\n\n return node;\n }\n\n toReferencedArguments(\n node:\n | N.CallExpression\n | N.OptionalCallExpression\n | N.EstreeImportExpression,\n /* isParenthesizedExpr?: boolean, */\n ) {\n // ImportExpressions do not have an arguments array.\n if (node.type === \"ImportExpression\") {\n return;\n }\n\n super.toReferencedArguments(node);\n }\n\n parseExport(node: N.Node) {\n super.parseExport(node);\n\n switch (node.type) {\n case \"ExportAllDeclaration\":\n node.exported = null;\n break;\n\n case \"ExportNamedDeclaration\":\n if (\n node.specifiers.length === 1 &&\n node.specifiers[0].type === \"ExportNamespaceSpecifier\"\n ) {\n node.type = \"ExportAllDeclaration\";\n node.exported = node.specifiers[0].exported;\n delete node.specifiers;\n }\n\n break;\n }\n\n return node;\n }\n\n parseSubscript(\n base: N.Expression,\n startPos: number,\n startLoc: Position,\n noCalls: ?boolean,\n state: N.ParseSubscriptState,\n ) {\n const node = super.parseSubscript(\n base,\n startPos,\n startLoc,\n noCalls,\n state,\n );\n\n if (state.optionalChainMember) {\n // https://github.com/estree/estree/blob/master/es2020.md#chainexpression\n if (\n node.type === \"OptionalMemberExpression\" ||\n node.type === \"OptionalCallExpression\"\n ) {\n node.type = node.type.substring(8); // strip Optional prefix\n }\n if (state.stop) {\n const chain = this.startNodeAtNode(node);\n chain.expression = node;\n return this.finishNode(chain, \"ChainExpression\");\n }\n } else if (\n node.type === \"MemberExpression\" ||\n node.type === \"CallExpression\"\n ) {\n node.optional = false;\n }\n\n return node;\n }\n\n hasPropertyAsPrivateName(node: N.Node): boolean {\n if (node.type === \"ChainExpression\") {\n node = node.expression;\n }\n return super.hasPropertyAsPrivateName(node);\n }\n\n isOptionalChain(node: N.Node): boolean {\n return node.type === \"ChainExpression\";\n }\n\n isObjectProperty(node: N.Node): boolean {\n return node.type === \"Property\" && node.kind === \"init\" && !node.method;\n }\n\n isObjectMethod(node: N.Node): boolean {\n return node.method || node.kind === \"get\" || node.kind === \"set\";\n }\n };\n","// @flow\n\n// The token context is used in JSX plugin to track\n// jsx tag / jsx text / normal JavaScript expression\n\nexport class TokContext {\n constructor(token: string, preserveSpace?: boolean) {\n this.token = token;\n this.preserveSpace = !!preserveSpace;\n }\n\n token: string;\n preserveSpace: boolean;\n}\n\nconst types: {\n [key: string]: TokContext,\n} = {\n brace: new TokContext(\"{\"), // normal JavaScript expression\n j_oTag: new TokContext(\"...\", true), // JSX expressions\n};\n\nif (!process.env.BABEL_8_BREAKING) {\n types.template = new TokContext(\"`\", true);\n}\n\nexport { types };\n","// @flow\nimport { types as tc, type TokContext } from \"./context\";\n// ## Token types\n\n// The assignment of fine-grained, information-carrying type objects\n// allows the tokenizer to store the information it has about a\n// token in a way that is very cheap for the parser to look up.\n\n// All token type variables start with an underscore, to make them\n// easy to recognize.\n\n// The `beforeExpr` property is used to disambiguate between 1) binary\n// expression (<) and JSX Tag start (); 2) object literal and JSX\n// texts. It is set on the `updateContext` function in the JSX plugin.\n\n// The `startsExpr` property is used to determine whether an expression\n// may be the “argument” subexpression of a `yield` expression or\n// `yield` statement. It is set on all token types that may be at the\n// start of a subexpression.\n\n// `isLoop` marks a keyword as starting a loop, which is important\n// to know when parsing a label, in order to allow or disallow\n// continue jumps to that label.\n\nconst beforeExpr = true;\nconst startsExpr = true;\nconst isLoop = true;\nconst isAssign = true;\nconst prefix = true;\nconst postfix = true;\n\ntype TokenOptions = {\n keyword?: string,\n beforeExpr?: boolean,\n startsExpr?: boolean,\n rightAssociative?: boolean,\n isLoop?: boolean,\n isAssign?: boolean,\n prefix?: boolean,\n postfix?: boolean,\n binop?: ?number,\n};\n\n// Internally the tokenizer stores token as a number\nexport opaque type TokenType = number;\n\n// The `ExportedTokenType` is exported via `tokTypes` and accessible\n// when `tokens: true` is enabled. Unlike internal token type, it provides\n// metadata of the tokens.\nexport class ExportedTokenType {\n label: string;\n keyword: ?string;\n beforeExpr: boolean;\n startsExpr: boolean;\n rightAssociative: boolean;\n isLoop: boolean;\n isAssign: boolean;\n prefix: boolean;\n postfix: boolean;\n binop: ?number;\n // todo(Babel 8): remove updateContext from exposed token layout\n declare updateContext: ?(context: Array) => void;\n\n constructor(label: string, conf: TokenOptions = {}) {\n this.label = label;\n this.keyword = conf.keyword;\n this.beforeExpr = !!conf.beforeExpr;\n this.startsExpr = !!conf.startsExpr;\n this.rightAssociative = !!conf.rightAssociative;\n this.isLoop = !!conf.isLoop;\n this.isAssign = !!conf.isAssign;\n this.prefix = !!conf.prefix;\n this.postfix = !!conf.postfix;\n this.binop = conf.binop != null ? conf.binop : null;\n if (!process.env.BABEL_8_BREAKING) {\n this.updateContext = null;\n }\n }\n}\n\n// A map from keyword/keyword-like string value to the token type\nexport const keywords = new Map();\n\nfunction createKeyword(name: string, options: TokenOptions = {}): TokenType {\n options.keyword = name;\n const token = createToken(name, options);\n keywords.set(name, token);\n return token;\n}\n\nfunction createBinop(name: string, binop: number) {\n return createToken(name, { beforeExpr, binop });\n}\n\nlet tokenTypeCounter = -1;\nexport const tokenTypes: ExportedTokenType[] = [];\nconst tokenLabels: string[] = [];\nconst tokenBinops: number[] = [];\nconst tokenBeforeExprs: boolean[] = [];\nconst tokenStartsExprs: boolean[] = [];\nconst tokenPrefixes: boolean[] = [];\n\nfunction createToken(name: string, options: TokenOptions = {}): TokenType {\n ++tokenTypeCounter;\n tokenLabels.push(name);\n tokenBinops.push(options.binop ?? -1);\n tokenBeforeExprs.push(options.beforeExpr ?? false);\n tokenStartsExprs.push(options.startsExpr ?? false);\n tokenPrefixes.push(options.prefix ?? false);\n tokenTypes.push(new ExportedTokenType(name, options));\n\n return tokenTypeCounter;\n}\n\nfunction createKeywordLike(\n name: string,\n options: TokenOptions = {},\n): TokenType {\n ++tokenTypeCounter;\n keywords.set(name, tokenTypeCounter);\n tokenLabels.push(name);\n tokenBinops.push(options.binop ?? -1);\n tokenBeforeExprs.push(options.beforeExpr ?? false);\n tokenStartsExprs.push(options.startsExpr ?? false);\n tokenPrefixes.push(options.prefix ?? false);\n // In the exported token type, we set the label as \"name\" for backward compatibility with Babel 7\n tokenTypes.push(new ExportedTokenType(\"name\", options));\n\n return tokenTypeCounter;\n}\n\n// For performance the token type helpers depend on the following declarations order.\n// When adding new token types, please also check if the token helpers need update.\n\nexport const tt: { [name: string]: TokenType } = {\n // Punctuation token types.\n bracketL: createToken(\"[\", { beforeExpr, startsExpr }),\n bracketHashL: createToken(\"#[\", { beforeExpr, startsExpr }),\n bracketBarL: createToken(\"[|\", { beforeExpr, startsExpr }),\n bracketR: createToken(\"]\"),\n bracketBarR: createToken(\"|]\"),\n braceL: createToken(\"{\", { beforeExpr, startsExpr }),\n braceBarL: createToken(\"{|\", { beforeExpr, startsExpr }),\n braceHashL: createToken(\"#{\", { beforeExpr, startsExpr }),\n braceR: createToken(\"}\", { beforeExpr }),\n braceBarR: createToken(\"|}\"),\n parenL: createToken(\"(\", { beforeExpr, startsExpr }),\n parenR: createToken(\")\"),\n comma: createToken(\",\", { beforeExpr }),\n semi: createToken(\";\", { beforeExpr }),\n colon: createToken(\":\", { beforeExpr }),\n doubleColon: createToken(\"::\", { beforeExpr }),\n dot: createToken(\".\"),\n question: createToken(\"?\", { beforeExpr }),\n questionDot: createToken(\"?.\"),\n arrow: createToken(\"=>\", { beforeExpr }),\n template: createToken(\"template\"),\n ellipsis: createToken(\"...\", { beforeExpr }),\n backQuote: createToken(\"`\", { startsExpr }),\n dollarBraceL: createToken(\"${\", { beforeExpr, startsExpr }),\n // start: isTemplate\n templateTail: createToken(\"...`\", { startsExpr }),\n templateNonTail: createToken(\"...${\", { beforeExpr, startsExpr }),\n // end: isTemplate\n at: createToken(\"@\"),\n hash: createToken(\"#\", { startsExpr }),\n\n // Special hashbang token.\n interpreterDirective: createToken(\"#!...\"),\n\n // Operators. These carry several kinds of properties to help the\n // parser use them properly (the presence of these properties is\n // what categorizes them as operators).\n //\n // `binop`, when present, specifies that this operator is a binary\n // operator, and will refer to its precedence.\n //\n // `prefix` and `postfix` mark the operator as a prefix or postfix\n // unary operator.\n //\n // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as\n // binary operators with a very low precedence, that should result\n // in AssignmentExpression nodes.\n\n // start: isAssign\n eq: createToken(\"=\", { beforeExpr, isAssign }),\n assign: createToken(\"_=\", { beforeExpr, isAssign }),\n slashAssign: createToken(\"_=\", { beforeExpr, isAssign }),\n // These are only needed to support % and ^ as a Hack-pipe topic token. When the\n // proposal settles on a token, the others can be merged with tt.assign.\n xorAssign: createToken(\"_=\", { beforeExpr, isAssign }),\n moduloAssign: createToken(\"_=\", { beforeExpr, isAssign }),\n // end: isAssign\n\n incDec: createToken(\"++/--\", { prefix, postfix, startsExpr }),\n bang: createToken(\"!\", { beforeExpr, prefix, startsExpr }),\n tilde: createToken(\"~\", { beforeExpr, prefix, startsExpr }),\n // start: isBinop\n pipeline: createBinop(\"|>\", 0),\n nullishCoalescing: createBinop(\"??\", 1),\n logicalOR: createBinop(\"||\", 1),\n logicalAND: createBinop(\"&&\", 2),\n bitwiseOR: createBinop(\"|\", 3),\n bitwiseXOR: createBinop(\"^\", 4),\n bitwiseAND: createBinop(\"&\", 5),\n equality: createBinop(\"==/!=/===/!==\", 6),\n lt: createBinop(\"/<=/>=\", 7),\n gt: createBinop(\"/<=/>=\", 7),\n relational: createBinop(\"/<=/>=\", 7),\n bitShift: createBinop(\"<>/>>>\", 8),\n plusMin: createToken(\"+/-\", { beforeExpr, binop: 9, prefix, startsExpr }),\n // startsExpr: required by v8intrinsic plugin\n modulo: createToken(\"%\", { binop: 10, startsExpr }),\n // unset `beforeExpr` as it can be `function *`\n star: createToken(\"*\", { binop: 10 }),\n slash: createBinop(\"/\", 10),\n exponent: createToken(\"**\", {\n beforeExpr,\n binop: 11,\n rightAssociative: true,\n }),\n\n // Keywords\n // Don't forget to update packages/babel-helper-validator-identifier/src/keyword.js\n // when new keywords are added\n // start: isLiteralPropertyName\n // start: isKeyword\n _in: createKeyword(\"in\", { beforeExpr, binop: 7 }),\n _instanceof: createKeyword(\"instanceof\", { beforeExpr, binop: 7 }),\n // end: isBinop\n _break: createKeyword(\"break\"),\n _case: createKeyword(\"case\", { beforeExpr }),\n _catch: createKeyword(\"catch\"),\n _continue: createKeyword(\"continue\"),\n _debugger: createKeyword(\"debugger\"),\n _default: createKeyword(\"default\", { beforeExpr }),\n _else: createKeyword(\"else\", { beforeExpr }),\n _finally: createKeyword(\"finally\"),\n _function: createKeyword(\"function\", { startsExpr }),\n _if: createKeyword(\"if\"),\n _return: createKeyword(\"return\", { beforeExpr }),\n _switch: createKeyword(\"switch\"),\n _throw: createKeyword(\"throw\", { beforeExpr, prefix, startsExpr }),\n _try: createKeyword(\"try\"),\n _var: createKeyword(\"var\"),\n _const: createKeyword(\"const\"),\n _with: createKeyword(\"with\"),\n _new: createKeyword(\"new\", { beforeExpr, startsExpr }),\n _this: createKeyword(\"this\", { startsExpr }),\n _super: createKeyword(\"super\", { startsExpr }),\n _class: createKeyword(\"class\", { startsExpr }),\n _extends: createKeyword(\"extends\", { beforeExpr }),\n _export: createKeyword(\"export\"),\n _import: createKeyword(\"import\", { startsExpr }),\n _null: createKeyword(\"null\", { startsExpr }),\n _true: createKeyword(\"true\", { startsExpr }),\n _false: createKeyword(\"false\", { startsExpr }),\n _typeof: createKeyword(\"typeof\", { beforeExpr, prefix, startsExpr }),\n _void: createKeyword(\"void\", { beforeExpr, prefix, startsExpr }),\n _delete: createKeyword(\"delete\", { beforeExpr, prefix, startsExpr }),\n // start: isLoop\n _do: createKeyword(\"do\", { isLoop, beforeExpr }),\n _for: createKeyword(\"for\", { isLoop }),\n _while: createKeyword(\"while\", { isLoop }),\n // end: isLoop\n // end: isKeyword\n\n // Primary literals\n // start: isIdentifier\n _as: createKeywordLike(\"as\", { startsExpr }),\n _assert: createKeywordLike(\"assert\", { startsExpr }),\n _async: createKeywordLike(\"async\", { startsExpr }),\n _await: createKeywordLike(\"await\", { startsExpr }),\n _from: createKeywordLike(\"from\", { startsExpr }),\n _get: createKeywordLike(\"get\", { startsExpr }),\n _let: createKeywordLike(\"let\", { startsExpr }),\n _meta: createKeywordLike(\"meta\", { startsExpr }),\n _of: createKeywordLike(\"of\", { startsExpr }),\n _sent: createKeywordLike(\"sent\", { startsExpr }),\n _set: createKeywordLike(\"set\", { startsExpr }),\n _static: createKeywordLike(\"static\", { startsExpr }),\n _yield: createKeywordLike(\"yield\", { startsExpr }),\n\n // Flow and TypeScript Keywordlike\n _asserts: createKeywordLike(\"asserts\", { startsExpr }),\n _checks: createKeywordLike(\"checks\", { startsExpr }),\n _exports: createKeywordLike(\"exports\", { startsExpr }),\n _global: createKeywordLike(\"global\", { startsExpr }),\n _implements: createKeywordLike(\"implements\", { startsExpr }),\n _intrinsic: createKeywordLike(\"intrinsic\", { startsExpr }),\n _infer: createKeywordLike(\"infer\", { startsExpr }),\n _is: createKeywordLike(\"is\", { startsExpr }),\n _mixins: createKeywordLike(\"mixins\", { startsExpr }),\n _proto: createKeywordLike(\"proto\", { startsExpr }),\n _require: createKeywordLike(\"require\", { startsExpr }),\n // start: isTSTypeOperator\n _keyof: createKeywordLike(\"keyof\", { startsExpr }),\n _readonly: createKeywordLike(\"readonly\", { startsExpr }),\n _unique: createKeywordLike(\"unique\", { startsExpr }),\n // end: isTSTypeOperator\n // start: isTSDeclarationStart\n _abstract: createKeywordLike(\"abstract\", { startsExpr }),\n _declare: createKeywordLike(\"declare\", { startsExpr }),\n _enum: createKeywordLike(\"enum\", { startsExpr }),\n _module: createKeywordLike(\"module\", { startsExpr }),\n _namespace: createKeywordLike(\"namespace\", { startsExpr }),\n // start: isFlowInterfaceOrTypeOrOpaque\n _interface: createKeywordLike(\"interface\", { startsExpr }),\n _type: createKeywordLike(\"type\", { startsExpr }),\n // end: isTSDeclarationStart\n _opaque: createKeywordLike(\"opaque\", { startsExpr }),\n // end: isFlowInterfaceOrTypeOrOpaque\n name: createToken(\"name\", { startsExpr }),\n // end: isIdentifier\n\n string: createToken(\"string\", { startsExpr }),\n num: createToken(\"num\", { startsExpr }),\n bigint: createToken(\"bigint\", { startsExpr }),\n decimal: createToken(\"decimal\", { startsExpr }),\n // end: isLiteralPropertyName\n regexp: createToken(\"regexp\", { startsExpr }),\n privateName: createToken(\"#name\", { startsExpr }),\n eof: createToken(\"eof\"),\n\n // jsx plugin\n jsxName: createToken(\"jsxName\"),\n jsxText: createToken(\"jsxText\", { beforeExpr: true }),\n jsxTagStart: createToken(\"jsxTagStart\", { startsExpr: true }),\n jsxTagEnd: createToken(\"jsxTagEnd\"),\n\n // placeholder plugin\n placeholder: createToken(\"%%\", { startsExpr: true }),\n};\n\nexport function tokenIsIdentifier(token: TokenType): boolean {\n return token >= tt._as && token <= tt.name;\n}\n\nexport function tokenKeywordOrIdentifierIsKeyword(token: TokenType): boolean {\n // we can remove the token >= tt._in check when we\n // know a token is either keyword or identifier\n return token <= tt._while;\n}\n\nexport function tokenIsKeywordOrIdentifier(token: TokenType): boolean {\n return token >= tt._in && token <= tt.name;\n}\n\nexport function tokenIsLiteralPropertyName(token: TokenType): boolean {\n return token >= tt._in && token <= tt.decimal;\n}\n\nexport function tokenComesBeforeExpression(token: TokenType): boolean {\n return tokenBeforeExprs[token];\n}\n\nexport function tokenCanStartExpression(token: TokenType): boolean {\n return tokenStartsExprs[token];\n}\n\nexport function tokenIsAssignment(token: TokenType): boolean {\n return token >= tt.eq && token <= tt.moduloAssign;\n}\n\nexport function tokenIsFlowInterfaceOrTypeOrOpaque(token: TokenType): boolean {\n return token >= tt._interface && token <= tt._opaque;\n}\n\nexport function tokenIsLoop(token: TokenType): boolean {\n return token >= tt._do && token <= tt._while;\n}\n\nexport function tokenIsKeyword(token: TokenType): boolean {\n return token >= tt._in && token <= tt._while;\n}\n\nexport function tokenIsOperator(token: TokenType): boolean {\n return token >= tt.pipeline && token <= tt._instanceof;\n}\n\nexport function tokenIsPostfix(token: TokenType): boolean {\n return token === tt.incDec;\n}\n\nexport function tokenIsPrefix(token: TokenType): boolean {\n return tokenPrefixes[token];\n}\n\nexport function tokenIsTSTypeOperator(token: TokenType): boolean {\n return token >= tt._keyof && token <= tt._unique;\n}\n\nexport function tokenIsTSDeclarationStart(token: TokenType): boolean {\n return token >= tt._abstract && token <= tt._type;\n}\n\nexport function tokenLabelName(token: TokenType): string {\n return tokenLabels[token];\n}\n\nexport function tokenOperatorPrecedence(token: TokenType): number {\n return tokenBinops[token];\n}\n\nexport function tokenIsRightAssociative(token: TokenType): boolean {\n return token === tt.exponent;\n}\n\nexport function tokenIsTemplate(token: TokenType): boolean {\n return token >= tt.templateTail && token <= tt.templateNonTail;\n}\n\nexport function getExportedToken(token: TokenType): ExportedTokenType {\n return tokenTypes[token];\n}\n\nexport function isTokenType(obj: any): boolean {\n return typeof obj === \"number\";\n}\n\nif (!process.env.BABEL_8_BREAKING) {\n tokenTypes[tt.braceR].updateContext = context => {\n context.pop();\n };\n\n tokenTypes[tt.braceL].updateContext =\n tokenTypes[tt.braceHashL].updateContext =\n tokenTypes[tt.dollarBraceL].updateContext =\n context => {\n context.push(tc.brace);\n };\n\n tokenTypes[tt.backQuote].updateContext = context => {\n if (context[context.length - 1] === tc.template) {\n context.pop();\n } else {\n context.push(tc.template);\n }\n };\n\n tokenTypes[tt.jsxTagStart].updateContext = context => {\n context.push(tc.j_expr, tc.j_oTag);\n };\n}\n","import * as charCodes from \"charcodes\";\n\n// ## Character categories\n\n// Big ugly regular expressions that match characters in the\n// whitespace, identifier, and identifier-start categories. These\n// are only applied when a character is found to actually have a\n// code point between 0x80 and 0xffff.\n// Generated by `scripts/generate-identifier-regex.js`.\n\n/* prettier-ignore */\nlet nonASCIIidentifierStartChars = \"\\xaa\\xb5\\xba\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u02c1\\u02c6-\\u02d1\\u02e0-\\u02e4\\u02ec\\u02ee\\u0370-\\u0374\\u0376\\u0377\\u037a-\\u037d\\u037f\\u0386\\u0388-\\u038a\\u038c\\u038e-\\u03a1\\u03a3-\\u03f5\\u03f7-\\u0481\\u048a-\\u052f\\u0531-\\u0556\\u0559\\u0560-\\u0588\\u05d0-\\u05ea\\u05ef-\\u05f2\\u0620-\\u064a\\u066e\\u066f\\u0671-\\u06d3\\u06d5\\u06e5\\u06e6\\u06ee\\u06ef\\u06fa-\\u06fc\\u06ff\\u0710\\u0712-\\u072f\\u074d-\\u07a5\\u07b1\\u07ca-\\u07ea\\u07f4\\u07f5\\u07fa\\u0800-\\u0815\\u081a\\u0824\\u0828\\u0840-\\u0858\\u0860-\\u086a\\u0870-\\u0887\\u0889-\\u088e\\u08a0-\\u08c9\\u0904-\\u0939\\u093d\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098c\\u098f\\u0990\\u0993-\\u09a8\\u09aa-\\u09b0\\u09b2\\u09b6-\\u09b9\\u09bd\\u09ce\\u09dc\\u09dd\\u09df-\\u09e1\\u09f0\\u09f1\\u09fc\\u0a05-\\u0a0a\\u0a0f\\u0a10\\u0a13-\\u0a28\\u0a2a-\\u0a30\\u0a32\\u0a33\\u0a35\\u0a36\\u0a38\\u0a39\\u0a59-\\u0a5c\\u0a5e\\u0a72-\\u0a74\\u0a85-\\u0a8d\\u0a8f-\\u0a91\\u0a93-\\u0aa8\\u0aaa-\\u0ab0\\u0ab2\\u0ab3\\u0ab5-\\u0ab9\\u0abd\\u0ad0\\u0ae0\\u0ae1\\u0af9\\u0b05-\\u0b0c\\u0b0f\\u0b10\\u0b13-\\u0b28\\u0b2a-\\u0b30\\u0b32\\u0b33\\u0b35-\\u0b39\\u0b3d\\u0b5c\\u0b5d\\u0b5f-\\u0b61\\u0b71\\u0b83\\u0b85-\\u0b8a\\u0b8e-\\u0b90\\u0b92-\\u0b95\\u0b99\\u0b9a\\u0b9c\\u0b9e\\u0b9f\\u0ba3\\u0ba4\\u0ba8-\\u0baa\\u0bae-\\u0bb9\\u0bd0\\u0c05-\\u0c0c\\u0c0e-\\u0c10\\u0c12-\\u0c28\\u0c2a-\\u0c39\\u0c3d\\u0c58-\\u0c5a\\u0c5d\\u0c60\\u0c61\\u0c80\\u0c85-\\u0c8c\\u0c8e-\\u0c90\\u0c92-\\u0ca8\\u0caa-\\u0cb3\\u0cb5-\\u0cb9\\u0cbd\\u0cdd\\u0cde\\u0ce0\\u0ce1\\u0cf1\\u0cf2\\u0d04-\\u0d0c\\u0d0e-\\u0d10\\u0d12-\\u0d3a\\u0d3d\\u0d4e\\u0d54-\\u0d56\\u0d5f-\\u0d61\\u0d7a-\\u0d7f\\u0d85-\\u0d96\\u0d9a-\\u0db1\\u0db3-\\u0dbb\\u0dbd\\u0dc0-\\u0dc6\\u0e01-\\u0e30\\u0e32\\u0e33\\u0e40-\\u0e46\\u0e81\\u0e82\\u0e84\\u0e86-\\u0e8a\\u0e8c-\\u0ea3\\u0ea5\\u0ea7-\\u0eb0\\u0eb2\\u0eb3\\u0ebd\\u0ec0-\\u0ec4\\u0ec6\\u0edc-\\u0edf\\u0f00\\u0f40-\\u0f47\\u0f49-\\u0f6c\\u0f88-\\u0f8c\\u1000-\\u102a\\u103f\\u1050-\\u1055\\u105a-\\u105d\\u1061\\u1065\\u1066\\u106e-\\u1070\\u1075-\\u1081\\u108e\\u10a0-\\u10c5\\u10c7\\u10cd\\u10d0-\\u10fa\\u10fc-\\u1248\\u124a-\\u124d\\u1250-\\u1256\\u1258\\u125a-\\u125d\\u1260-\\u1288\\u128a-\\u128d\\u1290-\\u12b0\\u12b2-\\u12b5\\u12b8-\\u12be\\u12c0\\u12c2-\\u12c5\\u12c8-\\u12d6\\u12d8-\\u1310\\u1312-\\u1315\\u1318-\\u135a\\u1380-\\u138f\\u13a0-\\u13f5\\u13f8-\\u13fd\\u1401-\\u166c\\u166f-\\u167f\\u1681-\\u169a\\u16a0-\\u16ea\\u16ee-\\u16f8\\u1700-\\u1711\\u171f-\\u1731\\u1740-\\u1751\\u1760-\\u176c\\u176e-\\u1770\\u1780-\\u17b3\\u17d7\\u17dc\\u1820-\\u1878\\u1880-\\u18a8\\u18aa\\u18b0-\\u18f5\\u1900-\\u191e\\u1950-\\u196d\\u1970-\\u1974\\u1980-\\u19ab\\u19b0-\\u19c9\\u1a00-\\u1a16\\u1a20-\\u1a54\\u1aa7\\u1b05-\\u1b33\\u1b45-\\u1b4c\\u1b83-\\u1ba0\\u1bae\\u1baf\\u1bba-\\u1be5\\u1c00-\\u1c23\\u1c4d-\\u1c4f\\u1c5a-\\u1c7d\\u1c80-\\u1c88\\u1c90-\\u1cba\\u1cbd-\\u1cbf\\u1ce9-\\u1cec\\u1cee-\\u1cf3\\u1cf5\\u1cf6\\u1cfa\\u1d00-\\u1dbf\\u1e00-\\u1f15\\u1f18-\\u1f1d\\u1f20-\\u1f45\\u1f48-\\u1f4d\\u1f50-\\u1f57\\u1f59\\u1f5b\\u1f5d\\u1f5f-\\u1f7d\\u1f80-\\u1fb4\\u1fb6-\\u1fbc\\u1fbe\\u1fc2-\\u1fc4\\u1fc6-\\u1fcc\\u1fd0-\\u1fd3\\u1fd6-\\u1fdb\\u1fe0-\\u1fec\\u1ff2-\\u1ff4\\u1ff6-\\u1ffc\\u2071\\u207f\\u2090-\\u209c\\u2102\\u2107\\u210a-\\u2113\\u2115\\u2118-\\u211d\\u2124\\u2126\\u2128\\u212a-\\u2139\\u213c-\\u213f\\u2145-\\u2149\\u214e\\u2160-\\u2188\\u2c00-\\u2ce4\\u2ceb-\\u2cee\\u2cf2\\u2cf3\\u2d00-\\u2d25\\u2d27\\u2d2d\\u2d30-\\u2d67\\u2d6f\\u2d80-\\u2d96\\u2da0-\\u2da6\\u2da8-\\u2dae\\u2db0-\\u2db6\\u2db8-\\u2dbe\\u2dc0-\\u2dc6\\u2dc8-\\u2dce\\u2dd0-\\u2dd6\\u2dd8-\\u2dde\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303c\\u3041-\\u3096\\u309b-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312f\\u3131-\\u318e\\u31a0-\\u31bf\\u31f0-\\u31ff\\u3400-\\u4dbf\\u4e00-\\ua48c\\ua4d0-\\ua4fd\\ua500-\\ua60c\\ua610-\\ua61f\\ua62a\\ua62b\\ua640-\\ua66e\\ua67f-\\ua69d\\ua6a0-\\ua6ef\\ua717-\\ua71f\\ua722-\\ua788\\ua78b-\\ua7ca\\ua7d0\\ua7d1\\ua7d3\\ua7d5-\\ua7d9\\ua7f2-\\ua801\\ua803-\\ua805\\ua807-\\ua80a\\ua80c-\\ua822\\ua840-\\ua873\\ua882-\\ua8b3\\ua8f2-\\ua8f7\\ua8fb\\ua8fd\\ua8fe\\ua90a-\\ua925\\ua930-\\ua946\\ua960-\\ua97c\\ua984-\\ua9b2\\ua9cf\\ua9e0-\\ua9e4\\ua9e6-\\ua9ef\\ua9fa-\\ua9fe\\uaa00-\\uaa28\\uaa40-\\uaa42\\uaa44-\\uaa4b\\uaa60-\\uaa76\\uaa7a\\uaa7e-\\uaaaf\\uaab1\\uaab5\\uaab6\\uaab9-\\uaabd\\uaac0\\uaac2\\uaadb-\\uaadd\\uaae0-\\uaaea\\uaaf2-\\uaaf4\\uab01-\\uab06\\uab09-\\uab0e\\uab11-\\uab16\\uab20-\\uab26\\uab28-\\uab2e\\uab30-\\uab5a\\uab5c-\\uab69\\uab70-\\uabe2\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufb00-\\ufb06\\ufb13-\\ufb17\\ufb1d\\ufb1f-\\ufb28\\ufb2a-\\ufb36\\ufb38-\\ufb3c\\ufb3e\\ufb40\\ufb41\\ufb43\\ufb44\\ufb46-\\ufbb1\\ufbd3-\\ufd3d\\ufd50-\\ufd8f\\ufd92-\\ufdc7\\ufdf0-\\ufdfb\\ufe70-\\ufe74\\ufe76-\\ufefc\\uff21-\\uff3a\\uff41-\\uff5a\\uff66-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc\";\n/* prettier-ignore */\nlet nonASCIIidentifierChars = \"\\u200c\\u200d\\xb7\\u0300-\\u036f\\u0387\\u0483-\\u0487\\u0591-\\u05bd\\u05bf\\u05c1\\u05c2\\u05c4\\u05c5\\u05c7\\u0610-\\u061a\\u064b-\\u0669\\u0670\\u06d6-\\u06dc\\u06df-\\u06e4\\u06e7\\u06e8\\u06ea-\\u06ed\\u06f0-\\u06f9\\u0711\\u0730-\\u074a\\u07a6-\\u07b0\\u07c0-\\u07c9\\u07eb-\\u07f3\\u07fd\\u0816-\\u0819\\u081b-\\u0823\\u0825-\\u0827\\u0829-\\u082d\\u0859-\\u085b\\u0898-\\u089f\\u08ca-\\u08e1\\u08e3-\\u0903\\u093a-\\u093c\\u093e-\\u094f\\u0951-\\u0957\\u0962\\u0963\\u0966-\\u096f\\u0981-\\u0983\\u09bc\\u09be-\\u09c4\\u09c7\\u09c8\\u09cb-\\u09cd\\u09d7\\u09e2\\u09e3\\u09e6-\\u09ef\\u09fe\\u0a01-\\u0a03\\u0a3c\\u0a3e-\\u0a42\\u0a47\\u0a48\\u0a4b-\\u0a4d\\u0a51\\u0a66-\\u0a71\\u0a75\\u0a81-\\u0a83\\u0abc\\u0abe-\\u0ac5\\u0ac7-\\u0ac9\\u0acb-\\u0acd\\u0ae2\\u0ae3\\u0ae6-\\u0aef\\u0afa-\\u0aff\\u0b01-\\u0b03\\u0b3c\\u0b3e-\\u0b44\\u0b47\\u0b48\\u0b4b-\\u0b4d\\u0b55-\\u0b57\\u0b62\\u0b63\\u0b66-\\u0b6f\\u0b82\\u0bbe-\\u0bc2\\u0bc6-\\u0bc8\\u0bca-\\u0bcd\\u0bd7\\u0be6-\\u0bef\\u0c00-\\u0c04\\u0c3c\\u0c3e-\\u0c44\\u0c46-\\u0c48\\u0c4a-\\u0c4d\\u0c55\\u0c56\\u0c62\\u0c63\\u0c66-\\u0c6f\\u0c81-\\u0c83\\u0cbc\\u0cbe-\\u0cc4\\u0cc6-\\u0cc8\\u0cca-\\u0ccd\\u0cd5\\u0cd6\\u0ce2\\u0ce3\\u0ce6-\\u0cef\\u0d00-\\u0d03\\u0d3b\\u0d3c\\u0d3e-\\u0d44\\u0d46-\\u0d48\\u0d4a-\\u0d4d\\u0d57\\u0d62\\u0d63\\u0d66-\\u0d6f\\u0d81-\\u0d83\\u0dca\\u0dcf-\\u0dd4\\u0dd6\\u0dd8-\\u0ddf\\u0de6-\\u0def\\u0df2\\u0df3\\u0e31\\u0e34-\\u0e3a\\u0e47-\\u0e4e\\u0e50-\\u0e59\\u0eb1\\u0eb4-\\u0ebc\\u0ec8-\\u0ecd\\u0ed0-\\u0ed9\\u0f18\\u0f19\\u0f20-\\u0f29\\u0f35\\u0f37\\u0f39\\u0f3e\\u0f3f\\u0f71-\\u0f84\\u0f86\\u0f87\\u0f8d-\\u0f97\\u0f99-\\u0fbc\\u0fc6\\u102b-\\u103e\\u1040-\\u1049\\u1056-\\u1059\\u105e-\\u1060\\u1062-\\u1064\\u1067-\\u106d\\u1071-\\u1074\\u1082-\\u108d\\u108f-\\u109d\\u135d-\\u135f\\u1369-\\u1371\\u1712-\\u1715\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17b4-\\u17d3\\u17dd\\u17e0-\\u17e9\\u180b-\\u180d\\u180f-\\u1819\\u18a9\\u1920-\\u192b\\u1930-\\u193b\\u1946-\\u194f\\u19d0-\\u19da\\u1a17-\\u1a1b\\u1a55-\\u1a5e\\u1a60-\\u1a7c\\u1a7f-\\u1a89\\u1a90-\\u1a99\\u1ab0-\\u1abd\\u1abf-\\u1ace\\u1b00-\\u1b04\\u1b34-\\u1b44\\u1b50-\\u1b59\\u1b6b-\\u1b73\\u1b80-\\u1b82\\u1ba1-\\u1bad\\u1bb0-\\u1bb9\\u1be6-\\u1bf3\\u1c24-\\u1c37\\u1c40-\\u1c49\\u1c50-\\u1c59\\u1cd0-\\u1cd2\\u1cd4-\\u1ce8\\u1ced\\u1cf4\\u1cf7-\\u1cf9\\u1dc0-\\u1dff\\u203f\\u2040\\u2054\\u20d0-\\u20dc\\u20e1\\u20e5-\\u20f0\\u2cef-\\u2cf1\\u2d7f\\u2de0-\\u2dff\\u302a-\\u302f\\u3099\\u309a\\ua620-\\ua629\\ua66f\\ua674-\\ua67d\\ua69e\\ua69f\\ua6f0\\ua6f1\\ua802\\ua806\\ua80b\\ua823-\\ua827\\ua82c\\ua880\\ua881\\ua8b4-\\ua8c5\\ua8d0-\\ua8d9\\ua8e0-\\ua8f1\\ua8ff-\\ua909\\ua926-\\ua92d\\ua947-\\ua953\\ua980-\\ua983\\ua9b3-\\ua9c0\\ua9d0-\\ua9d9\\ua9e5\\ua9f0-\\ua9f9\\uaa29-\\uaa36\\uaa43\\uaa4c\\uaa4d\\uaa50-\\uaa59\\uaa7b-\\uaa7d\\uaab0\\uaab2-\\uaab4\\uaab7\\uaab8\\uaabe\\uaabf\\uaac1\\uaaeb-\\uaaef\\uaaf5\\uaaf6\\uabe3-\\uabea\\uabec\\uabed\\uabf0-\\uabf9\\ufb1e\\ufe00-\\ufe0f\\ufe20-\\ufe2f\\ufe33\\ufe34\\ufe4d-\\ufe4f\\uff10-\\uff19\\uff3f\";\n\nconst nonASCIIidentifierStart = new RegExp(\n \"[\" + nonASCIIidentifierStartChars + \"]\",\n);\nconst nonASCIIidentifier = new RegExp(\n \"[\" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + \"]\",\n);\n\nnonASCIIidentifierStartChars = nonASCIIidentifierChars = null;\n\n// These are a run-length and offset-encoded representation of the\n// >0xffff code points that are a valid part of identifiers. The\n// offset starts at 0x10000, and each pair of numbers represents an\n// offset to the next range, and then a size of the range. They were\n// generated by `scripts/generate-identifier-regex.js`.\n/* prettier-ignore */\nconst astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,68,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,349,41,7,1,79,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,190,0,80,921,103,110,18,195,2637,96,16,1070,4050,582,8634,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,689,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,43,8,8936,3,2,6,2,1,2,290,46,2,18,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,482,44,11,6,17,0,322,29,19,43,1269,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4152,8,221,3,5761,15,7472,3104,541,1507,4938];\n/* prettier-ignore */\nconst astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,370,1,154,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,161,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,19306,9,87,9,39,4,60,6,26,9,1014,0,2,54,8,3,82,0,12,1,19628,1,4706,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,262,6,10,9,357,0,62,13,1495,6,110,6,6,9,4759,9,787719,239];\n\n// This has a complexity linear to the value of the code. The\n// assumption is that looking up astral identifier characters is\n// rare.\nfunction isInAstralSet(code: number, set: readonly number[]): boolean {\n let pos = 0x10000;\n for (let i = 0, length = set.length; i < length; i += 2) {\n pos += set[i];\n if (pos > code) return false;\n\n pos += set[i + 1];\n if (pos >= code) return true;\n }\n return false;\n}\n\n// Test whether a given character code starts an identifier.\n\nexport function isIdentifierStart(code: number): boolean {\n if (code < charCodes.uppercaseA) return code === charCodes.dollarSign;\n if (code <= charCodes.uppercaseZ) return true;\n if (code < charCodes.lowercaseA) return code === charCodes.underscore;\n if (code <= charCodes.lowercaseZ) return true;\n if (code <= 0xffff) {\n return (\n code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code))\n );\n }\n return isInAstralSet(code, astralIdentifierStartCodes);\n}\n\n// Test whether a given character is part of an identifier.\n\nexport function isIdentifierChar(code: number): boolean {\n if (code < charCodes.digit0) return code === charCodes.dollarSign;\n if (code < charCodes.colon) return true;\n if (code < charCodes.uppercaseA) return false;\n if (code <= charCodes.uppercaseZ) return true;\n if (code < charCodes.lowercaseA) return code === charCodes.underscore;\n if (code <= charCodes.lowercaseZ) return true;\n if (code <= 0xffff) {\n return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));\n }\n return (\n isInAstralSet(code, astralIdentifierStartCodes) ||\n isInAstralSet(code, astralIdentifierCodes)\n );\n}\n\n// Test whether a given string is a valid identifier name\n\nexport function isIdentifierName(name: string): boolean {\n let isFirst = true;\n for (let i = 0; i < name.length; i++) {\n // The implementation is based on\n // https://source.chromium.org/chromium/chromium/src/+/master:v8/src/builtins/builtins-string-gen.cc;l=1455;drc=221e331b49dfefadbc6fa40b0c68e6f97606d0b3;bpv=0;bpt=1\n // We reimplement `codePointAt` because `codePointAt` is a V8 builtin which is not inlined by TurboFan (as of M91)\n // since `name` is mostly ASCII, an inlined `charCodeAt` wins here\n let cp = name.charCodeAt(i);\n if ((cp & 0xfc00) === 0xd800 && i + 1 < name.length) {\n const trail = name.charCodeAt(++i);\n if ((trail & 0xfc00) === 0xdc00) {\n cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff);\n }\n }\n if (isFirst) {\n isFirst = false;\n if (!isIdentifierStart(cp)) {\n return false;\n }\n } else if (!isIdentifierChar(cp)) {\n return false;\n }\n }\n return !isFirst;\n}\n","const reservedWords = {\n keyword: [\n \"break\",\n \"case\",\n \"catch\",\n \"continue\",\n \"debugger\",\n \"default\",\n \"do\",\n \"else\",\n \"finally\",\n \"for\",\n \"function\",\n \"if\",\n \"return\",\n \"switch\",\n \"throw\",\n \"try\",\n \"var\",\n \"const\",\n \"while\",\n \"with\",\n \"new\",\n \"this\",\n \"super\",\n \"class\",\n \"extends\",\n \"export\",\n \"import\",\n \"null\",\n \"true\",\n \"false\",\n \"in\",\n \"instanceof\",\n \"typeof\",\n \"void\",\n \"delete\",\n ],\n strict: [\n \"implements\",\n \"interface\",\n \"let\",\n \"package\",\n \"private\",\n \"protected\",\n \"public\",\n \"static\",\n \"yield\",\n ],\n strictBind: [\"eval\", \"arguments\"],\n};\nconst keywords = new Set(reservedWords.keyword);\nconst reservedWordsStrictSet = new Set(reservedWords.strict);\nconst reservedWordsStrictBindSet = new Set(reservedWords.strictBind);\n\n/**\n * Checks if word is a reserved word in non-strict mode\n */\nexport function isReservedWord(word: string, inModule: boolean): boolean {\n return (inModule && word === \"await\") || word === \"enum\";\n}\n\n/**\n * Checks if word is a reserved word in non-binding strict mode\n *\n * Includes non-strict reserved words\n */\nexport function isStrictReservedWord(word: string, inModule: boolean): boolean {\n return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);\n}\n\n/**\n * Checks if word is a reserved word in binding strict mode, but it is allowed as\n * a normal identifier.\n */\nexport function isStrictBindOnlyReservedWord(word: string): boolean {\n return reservedWordsStrictBindSet.has(word);\n}\n\n/**\n * Checks if word is a reserved word in binding strict mode\n *\n * Includes non-strict reserved words and non-binding strict reserved words\n */\nexport function isStrictBindReservedWord(\n word: string,\n inModule: boolean,\n): boolean {\n return (\n isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word)\n );\n}\n\nexport function isKeyword(word: string): boolean {\n return keywords.has(word);\n}\n","/* eslint max-len: 0 */\n\n// @flow\n\nimport * as charCodes from \"charcodes\";\n\nexport {\n isIdentifierStart,\n isIdentifierChar,\n isReservedWord,\n isStrictBindOnlyReservedWord,\n isStrictBindReservedWord,\n isStrictReservedWord,\n isKeyword,\n} from \"@babel/helper-validator-identifier\";\n\nexport const keywordRelationalOperator = /^in(stanceof)?$/;\n\n// Test whether a current state character code and next character code is @\n\nexport function isIteratorStart(current: number, next: number): boolean {\n return current === charCodes.atSign && next === charCodes.atSign;\n}\n\n// This is the comprehensive set of JavaScript reserved words\n// If a word is in this set, it could be a reserved word,\n// depending on sourceType/strictMode/binding info. In other words\n// if a word is not in this set, it is not a reserved word under\n// any circumstance.\nconst reservedWordLikeSet = new Set([\n \"break\",\n \"case\",\n \"catch\",\n \"continue\",\n \"debugger\",\n \"default\",\n \"do\",\n \"else\",\n \"finally\",\n \"for\",\n \"function\",\n \"if\",\n \"return\",\n \"switch\",\n \"throw\",\n \"try\",\n \"var\",\n \"const\",\n \"while\",\n \"with\",\n \"new\",\n \"this\",\n \"super\",\n \"class\",\n \"extends\",\n \"export\",\n \"import\",\n \"null\",\n \"true\",\n \"false\",\n \"in\",\n \"instanceof\",\n \"typeof\",\n \"void\",\n \"delete\",\n // strict\n \"implements\",\n \"interface\",\n \"let\",\n \"package\",\n \"private\",\n \"protected\",\n \"public\",\n \"static\",\n \"yield\",\n // strictBind\n \"eval\",\n \"arguments\",\n // reservedWorkLike\n \"enum\",\n \"await\",\n]);\n\nexport function canBeReservedWord(word: string): boolean {\n return reservedWordLikeSet.has(word);\n}\n","// @flow\n\n// Each scope gets a bitset that may contain these flags\n// prettier-ignore\nexport const SCOPE_OTHER = 0b000000000,\n SCOPE_PROGRAM = 0b000000001,\n SCOPE_FUNCTION = 0b000000010,\n SCOPE_ARROW = 0b000000100,\n SCOPE_SIMPLE_CATCH = 0b000001000,\n SCOPE_SUPER = 0b000010000,\n SCOPE_DIRECT_SUPER = 0b000100000,\n SCOPE_CLASS = 0b001000000,\n SCOPE_STATIC_BLOCK = 0b010000000,\n SCOPE_TS_MODULE = 0b100000000,\n SCOPE_VAR = SCOPE_PROGRAM | SCOPE_FUNCTION | SCOPE_TS_MODULE;\n\nexport type ScopeFlags =\n | typeof SCOPE_OTHER\n | typeof SCOPE_PROGRAM\n | typeof SCOPE_FUNCTION\n | typeof SCOPE_VAR\n | typeof SCOPE_ARROW\n | typeof SCOPE_SIMPLE_CATCH\n | typeof SCOPE_SUPER\n | typeof SCOPE_DIRECT_SUPER\n | typeof SCOPE_CLASS\n | typeof SCOPE_STATIC_BLOCK;\n\n// These flags are meant to be _only_ used inside the Scope class (or subclasses).\n// prettier-ignore\nexport const BIND_KIND_VALUE = 0b000000_0000_01,\n BIND_KIND_TYPE = 0b000000_0000_10,\n // Used in checkLVal and declareName to determine the type of a binding\n BIND_SCOPE_VAR = 0b000000_0001_00, // Var-style binding\n BIND_SCOPE_LEXICAL = 0b000000_0010_00, // Let- or const-style binding\n BIND_SCOPE_FUNCTION = 0b000000_0100_00, // Function declaration\n BIND_SCOPE_OUTSIDE = 0b000000_1000_00, // Special case for function names as\n // bound inside the function\n // Misc flags\n BIND_FLAGS_NONE = 0b000001_0000_00,\n BIND_FLAGS_CLASS = 0b000010_0000_00,\n BIND_FLAGS_TS_ENUM = 0b000100_0000_00,\n BIND_FLAGS_TS_CONST_ENUM = 0b001000_0000_00,\n BIND_FLAGS_TS_EXPORT_ONLY = 0b010000_0000_00,\n BIND_FLAGS_FLOW_DECLARE_FN = 0b100000_0000_00;\n\n// These flags are meant to be _only_ used by Scope consumers\n// prettier-ignore\n/* = is value? | is type? | scope | misc flags */\nexport const BIND_CLASS = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_LEXICAL | BIND_FLAGS_CLASS ,\n BIND_LEXICAL = BIND_KIND_VALUE | 0 | BIND_SCOPE_LEXICAL | 0 ,\n BIND_VAR = BIND_KIND_VALUE | 0 | BIND_SCOPE_VAR | 0 ,\n BIND_FUNCTION = BIND_KIND_VALUE | 0 | BIND_SCOPE_FUNCTION | 0 ,\n BIND_TS_INTERFACE = 0 | BIND_KIND_TYPE | 0 | BIND_FLAGS_CLASS ,\n BIND_TS_TYPE = 0 | BIND_KIND_TYPE | 0 | 0 ,\n BIND_TS_ENUM = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_LEXICAL | BIND_FLAGS_TS_ENUM,\n BIND_TS_AMBIENT = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY,\n // These bindings don't introduce anything in the scope. They are used for assignments and\n // function expressions IDs.\n BIND_NONE = 0 | 0 | 0 | BIND_FLAGS_NONE ,\n BIND_OUTSIDE = BIND_KIND_VALUE | 0 | 0 | BIND_FLAGS_NONE ,\n\n BIND_TS_CONST_ENUM = BIND_TS_ENUM | BIND_FLAGS_TS_CONST_ENUM,\n BIND_TS_NAMESPACE = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY,\n\n BIND_FLOW_DECLARE_FN = BIND_FLAGS_FLOW_DECLARE_FN;\n\nexport type BindingTypes =\n | typeof BIND_NONE\n | typeof BIND_OUTSIDE\n | typeof BIND_VAR\n | typeof BIND_LEXICAL\n | typeof BIND_CLASS\n | typeof BIND_FUNCTION\n | typeof BIND_TS_INTERFACE\n | typeof BIND_TS_TYPE\n | typeof BIND_TS_ENUM\n | typeof BIND_TS_AMBIENT\n | typeof BIND_TS_NAMESPACE;\n\n// prettier-ignore\nexport const CLASS_ELEMENT_FLAG_STATIC = 0b1_00,\n CLASS_ELEMENT_KIND_GETTER = 0b0_10,\n CLASS_ELEMENT_KIND_SETTER = 0b0_01,\n CLASS_ELEMENT_KIND_ACCESSOR = CLASS_ELEMENT_KIND_GETTER | CLASS_ELEMENT_KIND_SETTER;\n\n// prettier-ignore\nexport const CLASS_ELEMENT_STATIC_GETTER = CLASS_ELEMENT_KIND_GETTER | CLASS_ELEMENT_FLAG_STATIC,\n CLASS_ELEMENT_STATIC_SETTER = CLASS_ELEMENT_KIND_SETTER | CLASS_ELEMENT_FLAG_STATIC,\n CLASS_ELEMENT_INSTANCE_GETTER = CLASS_ELEMENT_KIND_GETTER,\n CLASS_ELEMENT_INSTANCE_SETTER = CLASS_ELEMENT_KIND_SETTER,\n CLASS_ELEMENT_OTHER = 0;\n\nexport type ClassElementTypes =\n | typeof CLASS_ELEMENT_STATIC_GETTER\n | typeof CLASS_ELEMENT_STATIC_SETTER\n | typeof CLASS_ELEMENT_INSTANCE_GETTER\n | typeof CLASS_ELEMENT_INSTANCE_SETTER\n | typeof CLASS_ELEMENT_OTHER;\n","// @flow\nimport {\n SCOPE_ARROW,\n SCOPE_DIRECT_SUPER,\n SCOPE_FUNCTION,\n SCOPE_SIMPLE_CATCH,\n SCOPE_SUPER,\n SCOPE_PROGRAM,\n SCOPE_VAR,\n SCOPE_CLASS,\n SCOPE_STATIC_BLOCK,\n BIND_SCOPE_FUNCTION,\n BIND_SCOPE_VAR,\n BIND_SCOPE_LEXICAL,\n BIND_KIND_VALUE,\n type ScopeFlags,\n type BindingTypes,\n} from \"./scopeflags\";\nimport { Position } from \"./location\";\nimport * as N from \"../types\";\nimport { Errors, type raiseFunction } from \"../parser/error\";\n\n// Start an AST node, attaching a start offset.\nexport class Scope {\n declare flags: ScopeFlags;\n // A set of var-declared names in the current lexical scope\n var: Set = new Set();\n // A set of lexically-declared names in the current lexical scope\n lexical: Set = new Set();\n // A set of lexically-declared FunctionDeclaration names in the current lexical scope\n functions: Set = new Set();\n\n constructor(flags: ScopeFlags) {\n this.flags = flags;\n }\n}\n\n// The functions in this module keep track of declared variables in the\n// current scope in order to detect duplicate variable names.\nexport default class ScopeHandler {\n scopeStack: Array = [];\n declare raise: raiseFunction;\n declare inModule: boolean;\n undefinedExports: Map = new Map();\n\n constructor(raise: raiseFunction, inModule: boolean) {\n this.raise = raise;\n this.inModule = inModule;\n }\n\n get inFunction() {\n return (this.currentVarScopeFlags() & SCOPE_FUNCTION) > 0;\n }\n get allowSuper() {\n return (this.currentThisScopeFlags() & SCOPE_SUPER) > 0;\n }\n get allowDirectSuper() {\n return (this.currentThisScopeFlags() & SCOPE_DIRECT_SUPER) > 0;\n }\n get inClass() {\n return (this.currentThisScopeFlags() & SCOPE_CLASS) > 0;\n }\n get inClassAndNotInNonArrowFunction() {\n const flags = this.currentThisScopeFlags();\n return (flags & SCOPE_CLASS) > 0 && (flags & SCOPE_FUNCTION) === 0;\n }\n get inStaticBlock() {\n for (let i = this.scopeStack.length - 1; ; i--) {\n const { flags } = this.scopeStack[i];\n if (flags & SCOPE_STATIC_BLOCK) {\n return true;\n }\n if (flags & (SCOPE_VAR | SCOPE_CLASS)) {\n // function body, module body, class property initializers\n return false;\n }\n }\n }\n get inNonArrowFunction() {\n return (this.currentThisScopeFlags() & SCOPE_FUNCTION) > 0;\n }\n get treatFunctionsAsVar() {\n return this.treatFunctionsAsVarInScope(this.currentScope());\n }\n\n createScope(flags: ScopeFlags): Scope {\n return new Scope(flags);\n }\n // This method will be overwritten by subclasses\n /*:: +createScope: (flags: ScopeFlags) => IScope; */\n\n enter(flags: ScopeFlags) {\n this.scopeStack.push(this.createScope(flags));\n }\n\n exit() {\n this.scopeStack.pop();\n }\n\n // The spec says:\n // > At the top level of a function, or script, function declarations are\n // > treated like var declarations rather than like lexical declarations.\n treatFunctionsAsVarInScope(scope: IScope): boolean {\n return !!(\n scope.flags & SCOPE_FUNCTION ||\n (!this.inModule && scope.flags & SCOPE_PROGRAM)\n );\n }\n\n declareName(name: string, bindingType: BindingTypes, loc: Position) {\n let scope = this.currentScope();\n if (bindingType & BIND_SCOPE_LEXICAL || bindingType & BIND_SCOPE_FUNCTION) {\n this.checkRedeclarationInScope(scope, name, bindingType, loc);\n\n if (bindingType & BIND_SCOPE_FUNCTION) {\n scope.functions.add(name);\n } else {\n scope.lexical.add(name);\n }\n\n if (bindingType & BIND_SCOPE_LEXICAL) {\n this.maybeExportDefined(scope, name);\n }\n } else if (bindingType & BIND_SCOPE_VAR) {\n for (let i = this.scopeStack.length - 1; i >= 0; --i) {\n scope = this.scopeStack[i];\n this.checkRedeclarationInScope(scope, name, bindingType, loc);\n scope.var.add(name);\n this.maybeExportDefined(scope, name);\n\n if (scope.flags & SCOPE_VAR) break;\n }\n }\n if (this.inModule && scope.flags & SCOPE_PROGRAM) {\n this.undefinedExports.delete(name);\n }\n }\n\n maybeExportDefined(scope: IScope, name: string) {\n if (this.inModule && scope.flags & SCOPE_PROGRAM) {\n this.undefinedExports.delete(name);\n }\n }\n\n checkRedeclarationInScope(\n scope: IScope,\n name: string,\n bindingType: BindingTypes,\n loc: Position,\n ) {\n if (this.isRedeclaredInScope(scope, name, bindingType)) {\n this.raise(Errors.VarRedeclaration, { at: loc }, name);\n }\n }\n\n isRedeclaredInScope(\n scope: IScope,\n name: string,\n bindingType: BindingTypes,\n ): boolean {\n if (!(bindingType & BIND_KIND_VALUE)) return false;\n\n if (bindingType & BIND_SCOPE_LEXICAL) {\n return (\n scope.lexical.has(name) ||\n scope.functions.has(name) ||\n scope.var.has(name)\n );\n }\n\n if (bindingType & BIND_SCOPE_FUNCTION) {\n return (\n scope.lexical.has(name) ||\n (!this.treatFunctionsAsVarInScope(scope) && scope.var.has(name))\n );\n }\n\n return (\n (scope.lexical.has(name) &&\n !(\n scope.flags & SCOPE_SIMPLE_CATCH &&\n scope.lexical.values().next().value === name\n )) ||\n (!this.treatFunctionsAsVarInScope(scope) && scope.functions.has(name))\n );\n }\n\n checkLocalExport(id: N.Identifier) {\n const { name } = id;\n const topLevelScope = this.scopeStack[0];\n if (\n !topLevelScope.lexical.has(name) &&\n !topLevelScope.var.has(name) &&\n // In strict mode, scope.functions will always be empty.\n // Modules are strict by default, but the `scriptMode` option\n // can overwrite this behavior.\n !topLevelScope.functions.has(name)\n ) {\n this.undefinedExports.set(name, id.loc.start);\n }\n }\n\n currentScope(): IScope {\n return this.scopeStack[this.scopeStack.length - 1];\n }\n\n // $FlowIgnore\n currentVarScopeFlags(): ScopeFlags {\n for (let i = this.scopeStack.length - 1; ; i--) {\n const { flags } = this.scopeStack[i];\n if (flags & SCOPE_VAR) {\n return flags;\n }\n }\n }\n\n // Could be useful for `arguments`, `this`, `new.target`, `super()`, `super.property`, and `super[property]`.\n // $FlowIgnore\n currentThisScopeFlags(): ScopeFlags {\n for (let i = this.scopeStack.length - 1; ; i--) {\n const { flags } = this.scopeStack[i];\n if (flags & (SCOPE_VAR | SCOPE_CLASS) && !(flags & SCOPE_ARROW)) {\n return flags;\n }\n }\n }\n}\n","// @flow\n\nimport { Position } from \"../../util/location\";\nimport ScopeHandler, { Scope } from \"../../util/scope\";\nimport {\n BIND_FLAGS_FLOW_DECLARE_FN,\n type ScopeFlags,\n type BindingTypes,\n} from \"../../util/scopeflags\";\nimport * as N from \"../../types\";\n\n// Reference implementation: https://github.com/facebook/flow/blob/23aeb2a2ef6eb4241ce178fde5d8f17c5f747fb5/src/typing/env.ml#L536-L584\nclass FlowScope extends Scope {\n // declare function foo(): type;\n declareFunctions: Set = new Set();\n}\n\nexport default class FlowScopeHandler extends ScopeHandler {\n createScope(flags: ScopeFlags): FlowScope {\n return new FlowScope(flags);\n }\n\n declareName(name: string, bindingType: BindingTypes, loc: Position) {\n const scope = this.currentScope();\n if (bindingType & BIND_FLAGS_FLOW_DECLARE_FN) {\n this.checkRedeclarationInScope(scope, name, bindingType, loc);\n this.maybeExportDefined(scope, name);\n scope.declareFunctions.add(name);\n return;\n }\n\n super.declareName(...arguments);\n }\n\n isRedeclaredInScope(\n scope: FlowScope,\n name: string,\n bindingType: BindingTypes,\n ): boolean {\n if (super.isRedeclaredInScope(...arguments)) return true;\n\n if (bindingType & BIND_FLAGS_FLOW_DECLARE_FN) {\n return (\n !scope.declareFunctions.has(name) &&\n (scope.lexical.has(name) || scope.functions.has(name))\n );\n }\n\n return false;\n }\n\n checkLocalExport(id: N.Identifier) {\n if (!this.scopeStack[0].declareFunctions.has(id.name)) {\n super.checkLocalExport(id);\n }\n }\n}\n","// @flow\n\nimport * as charCodes from \"charcodes\";\n\n// Matches a whole line break (where CRLF is considered a single\n// line break). Used to count lines.\nexport const lineBreak = /\\r\\n?|[\\n\\u2028\\u2029]/;\nexport const lineBreakG = new RegExp(lineBreak.source, \"g\");\n\n// https://tc39.github.io/ecma262/#sec-line-terminators\nexport function isNewLine(code: number): boolean {\n switch (code) {\n case charCodes.lineFeed:\n case charCodes.carriageReturn:\n case charCodes.lineSeparator:\n case charCodes.paragraphSeparator:\n return true;\n\n default:\n return false;\n }\n}\n\nexport const skipWhiteSpace = /(?:\\s|\\/\\/.*|\\/\\*[^]*?\\*\\/)*/g;\n\nexport const skipWhiteSpaceInLine =\n /(?:[^\\S\\n\\r\\u2028\\u2029]|\\/\\/.*|\\/\\*.*?\\*\\/)*/y;\n\n// Skip whitespace and single-line comments, including /* no newline here */.\n// After this RegExp matches, its lastIndex points to a line terminator, or\n// the start of multi-line comment (which is effectively a line terminator),\n// or the end of string.\nexport const skipWhiteSpaceToLineBreak = new RegExp(\n // Unfortunately JS doesn't support Perl's atomic /(?>pattern)/ or\n // possessive quantifiers, so we use a trick to prevent backtracking\n // when the look-ahead for line terminator fails.\n \"(?=(\" +\n // Capture the whitespace and comments that should be skipped inside\n // a look-ahead assertion, and then re-match the group as a unit.\n skipWhiteSpaceInLine.source +\n \"))\\\\1\" +\n // Look-ahead for either line terminator, start of multi-line comment,\n // or end of string.\n /(?=[\\n\\r\\u2028\\u2029]|\\/\\*(?!.*?\\*\\/)|$)/.source,\n \"y\", // sticky\n);\n\n// https://tc39.github.io/ecma262/#sec-white-space\nexport function isWhitespace(code: number): boolean {\n switch (code) {\n case 0x0009: // CHARACTER TABULATION\n case 0x000b: // LINE TABULATION\n case 0x000c: // FORM FEED\n case charCodes.space:\n case charCodes.nonBreakingSpace:\n case charCodes.oghamSpaceMark:\n case 0x2000: // EN QUAD\n case 0x2001: // EM QUAD\n case 0x2002: // EN SPACE\n case 0x2003: // EM SPACE\n case 0x2004: // THREE-PER-EM SPACE\n case 0x2005: // FOUR-PER-EM SPACE\n case 0x2006: // SIX-PER-EM SPACE\n case 0x2007: // FIGURE SPACE\n case 0x2008: // PUNCTUATION SPACE\n case 0x2009: // THIN SPACE\n case 0x200a: // HAIR SPACE\n case 0x202f: // NARROW NO-BREAK SPACE\n case 0x205f: // MEDIUM MATHEMATICAL SPACE\n case 0x3000: // IDEOGRAPHIC SPACE\n case 0xfeff: // ZERO WIDTH NO-BREAK SPACE\n return true;\n\n default:\n return false;\n }\n}\n","// @flow\n\nimport type { Options } from \"../options\";\nimport * as N from \"../types\";\nimport type { CommentWhitespace } from \"../parser/comments\";\nimport { Position } from \"../util/location\";\n\nimport { types as ct, type TokContext } from \"./context\";\nimport { tt, type TokenType } from \"./types\";\nimport type { ErrorData, ParsingError } from \"../parser/error\";\n\ntype TopicContextState = {\n // When a topic binding has been currently established,\n // then this is 1. Otherwise, it is 0. This is forwards compatible\n // with a future plugin for multiple lexical topics.\n maxNumOfResolvableTopics: number,\n\n // When a topic binding has been currently established, and if that binding\n // has been used as a topic reference `#`, then this is 0. Otherwise, it is\n // `null`. This is forwards compatible with a future plugin for multiple\n // lexical topics.\n maxTopicIndex: null | 0,\n};\n\nexport default class State {\n strict: boolean;\n curLine: number;\n lineStart: number;\n\n // And, if locations are used, the {line, column} object\n // corresponding to those offsets\n startLoc: Position;\n endLoc: Position;\n\n init({ strictMode, sourceType, startLine, startColumn }: Options): void {\n this.strict =\n strictMode === false\n ? false\n : strictMode === true\n ? true\n : sourceType === \"module\";\n\n this.curLine = startLine;\n this.lineStart = -startColumn;\n this.startLoc = this.endLoc = new Position(startLine, startColumn, 0);\n }\n\n errors: ParsingError[] = [];\n\n // Used to signify the start of a potential arrow function\n potentialArrowAt: number = -1;\n\n // Used to signify the start of an expression which looks like a\n // typed arrow function, but it isn't\n // e.g. a ? (b) : c => d\n // ^\n noArrowAt: number[] = [];\n\n // Used to signify the start of an expression whose params, if it looks like\n // an arrow function, shouldn't be converted to assignable nodes.\n // This is used to defer the validation of typed arrow functions inside\n // conditional expressions.\n // e.g. a ? (b) : c => d\n // ^\n noArrowParamsConversionAt: number[] = [];\n\n // Flags to track\n maybeInArrowParameters: boolean = false;\n inType: boolean = false;\n noAnonFunctionType: boolean = false;\n hasFlowComment: boolean = false;\n isAmbientContext: boolean = false;\n inAbstractClass: boolean = false;\n\n // For the Hack-style pipelines plugin\n topicContext: TopicContextState = {\n maxNumOfResolvableTopics: 0,\n maxTopicIndex: null,\n };\n\n // For the F#-style pipelines plugin\n soloAwait: boolean = false;\n inFSharpPipelineDirectBody: boolean = false;\n\n // Labels in scope.\n labels: Array<{\n kind: ?(\"loop\" | \"switch\"),\n name?: ?string,\n statementStart?: number,\n }> = [];\n\n // Leading decorators. Last element of the stack represents the decorators in current context.\n // Supports nesting of decorators, e.g. @foo(@bar class inner {}) class outer {}\n // where @foo belongs to the outer class and @bar to the inner\n decoratorStack: Array> = [[]];\n\n // Comment store for Program.comments\n comments: Array = [];\n\n // Comment attachment store\n commentStack: Array = [];\n\n // The current position of the tokenizer in the input.\n pos: number = 0;\n\n // Properties of the current token:\n // Its type\n type: TokenType = tt.eof;\n\n // For tokens that include more information than their type, the value\n value: any = null;\n\n // Its start and end offset\n start: number = 0;\n end: number = 0;\n\n // Position information for the previous token\n // $FlowIgnore this is initialized when generating the second token.\n lastTokEndLoc: Position = null;\n // $FlowIgnore this is initialized when generating the second token.\n lastTokStartLoc: Position = null;\n lastTokStart: number = 0;\n\n // The context stack is used to track whether the apostrophe \"`\" starts\n // or ends a string template\n context: Array = [ct.brace];\n // Used to track whether a JSX element is allowed to form\n canStartJSXElement: boolean = true;\n\n // Used to signal to callers of `readWord1` whether the word\n // contained any escape sequences. This is needed because words with\n // escape sequences must not be interpreted as keywords.\n containsEsc: boolean = false;\n\n // This property is used to track the following errors\n // - StrictNumericEscape\n // - StrictOctalLiteral\n //\n // in a literal that occurs prior to/immediately after a \"use strict\" directive.\n\n // todo(JLHwung): set strictErrors to null and avoid recording string errors\n // after a non-directive is parsed\n strictErrors: Map = new Map();\n\n // Tokens length in token store\n tokensLength: number = 0;\n\n curPosition(): Position {\n return new Position(this.curLine, this.pos - this.lineStart, this.pos);\n }\n\n clone(skipArrays?: boolean): State {\n const state = new State();\n const keys = Object.keys(this);\n for (let i = 0, length = keys.length; i < length; i++) {\n const key = keys[i];\n // $FlowIgnore\n let val = this[key];\n\n if (!skipArrays && Array.isArray(val)) {\n val = val.slice();\n }\n\n // $FlowIgnore\n state[key] = val;\n }\n\n return state;\n }\n}\n\nexport type LookaheadState = {\n pos: number,\n value: any,\n type: TokenType,\n start: number,\n end: number,\n /* Used only in readToken_mult_modulo */\n inType: boolean,\n};\n","// @flow\n\n/*:: declare var invariant; */\n\nimport type { Options } from \"../options\";\nimport {\n indexes,\n Position,\n createPositionWithColumnOffset,\n} from \"../util/location\";\nimport * as N from \"../types\";\nimport * as charCodes from \"charcodes\";\nimport { isIdentifierStart, isIdentifierChar } from \"../util/identifier\";\nimport {\n tokenIsKeyword,\n tokenLabelName,\n tt,\n keywords as keywordTypes,\n type TokenType,\n} from \"./types\";\nimport { type TokContext } from \"./context\";\nimport ParserErrors, { Errors, type ErrorTemplate } from \"../parser/error\";\nimport { SourceLocation } from \"../util/location\";\nimport {\n lineBreakG,\n isNewLine,\n isWhitespace,\n skipWhiteSpace,\n} from \"../util/whitespace\";\nimport State from \"./state\";\nimport type { LookaheadState } from \"./state\";\n\nconst VALID_REGEX_FLAGS = new Set([\n charCodes.lowercaseG,\n charCodes.lowercaseM,\n charCodes.lowercaseS,\n charCodes.lowercaseI,\n charCodes.lowercaseY,\n charCodes.lowercaseU,\n charCodes.lowercaseD,\n]);\n\n// The following character codes are forbidden from being\n// an immediate sibling of NumericLiteralSeparator _\n\nconst forbiddenNumericSeparatorSiblings = {\n decBinOct: [\n charCodes.dot,\n charCodes.uppercaseB,\n charCodes.uppercaseE,\n charCodes.uppercaseO,\n charCodes.underscore, // multiple separators are not allowed\n charCodes.lowercaseB,\n charCodes.lowercaseE,\n charCodes.lowercaseO,\n ],\n hex: [\n charCodes.dot,\n charCodes.uppercaseX,\n charCodes.underscore, // multiple separators are not allowed\n charCodes.lowercaseX,\n ],\n};\n\nconst allowedNumericSeparatorSiblings = {};\nallowedNumericSeparatorSiblings.bin = [\n // 0 - 1\n charCodes.digit0,\n charCodes.digit1,\n];\nallowedNumericSeparatorSiblings.oct = [\n // 0 - 7\n ...allowedNumericSeparatorSiblings.bin,\n\n charCodes.digit2,\n charCodes.digit3,\n charCodes.digit4,\n charCodes.digit5,\n charCodes.digit6,\n charCodes.digit7,\n];\nallowedNumericSeparatorSiblings.dec = [\n // 0 - 9\n ...allowedNumericSeparatorSiblings.oct,\n\n charCodes.digit8,\n charCodes.digit9,\n];\n\nallowedNumericSeparatorSiblings.hex = [\n // 0 - 9, A - F, a - f,\n ...allowedNumericSeparatorSiblings.dec,\n\n charCodes.uppercaseA,\n charCodes.uppercaseB,\n charCodes.uppercaseC,\n charCodes.uppercaseD,\n charCodes.uppercaseE,\n charCodes.uppercaseF,\n\n charCodes.lowercaseA,\n charCodes.lowercaseB,\n charCodes.lowercaseC,\n charCodes.lowercaseD,\n charCodes.lowercaseE,\n charCodes.lowercaseF,\n];\n\n// Object type used to represent tokens. Note that normally, tokens\n// simply exist as properties on the parser object. This is only\n// used for the onToken callback and the external tokenizer.\n\nexport class Token {\n constructor(state: State) {\n this.type = state.type;\n this.value = state.value;\n this.start = state.start;\n this.end = state.end;\n this.loc = new SourceLocation(state.startLoc, state.endLoc);\n }\n\n declare type: TokenType;\n declare value: any;\n declare start: number;\n declare end: number;\n declare loc: SourceLocation;\n}\n\n// ## Tokenizer\n\nexport default class Tokenizer extends ParserErrors {\n // Forward-declarations\n // parser/util.js\n /*::\n +hasPrecedingLineBreak: () => boolean;\n +unexpected: (loc?: ?Position, type?: TokenType) => empty;\n +expectPlugin: (name: string, loc?: Position) => true;\n */\n\n isLookahead: boolean;\n\n // Token store.\n tokens: Array = [];\n\n constructor(options: Options, input: string) {\n super();\n this.state = new State();\n this.state.init(options);\n this.input = input;\n this.length = input.length;\n this.isLookahead = false;\n }\n\n pushToken(token: Token | N.Comment) {\n // Pop out invalid tokens trapped by try-catch parsing.\n // Those parsing branches are mainly created by typescript and flow plugins.\n this.tokens.length = this.state.tokensLength;\n this.tokens.push(token);\n ++this.state.tokensLength;\n }\n\n // Move to the next token\n\n next(): void {\n this.checkKeywordEscapes();\n if (this.options.tokens) {\n this.pushToken(new Token(this.state));\n }\n\n this.state.lastTokStart = this.state.start;\n this.state.lastTokEndLoc = this.state.endLoc;\n this.state.lastTokStartLoc = this.state.startLoc;\n this.nextToken();\n }\n\n // TODO\n\n eat(type: TokenType): boolean {\n if (this.match(type)) {\n this.next();\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Whether current token matches given type\n *\n * @param {TokenType} type\n * @returns {boolean}\n * @memberof Tokenizer\n */\n match(type: TokenType): boolean {\n return this.state.type === type;\n }\n\n /**\n * Create a LookaheadState from current parser state\n *\n * @param {State} state\n * @returns {LookaheadState}\n * @memberof Tokenizer\n */\n createLookaheadState(state: State): LookaheadState {\n return {\n pos: state.pos,\n value: null,\n type: state.type,\n start: state.start,\n end: state.end,\n context: [this.curContext()],\n inType: state.inType,\n startLoc: state.startLoc,\n lastTokEndLoc: state.lastTokEndLoc,\n curLine: state.curLine,\n lineStart: state.lineStart,\n curPosition: state.curPosition,\n };\n }\n\n /**\n * lookahead peeks the next token, skipping changes to token context and\n * comment stack. For performance it returns a limited LookaheadState\n * instead of full parser state.\n *\n * The { column, line } Loc info is not included in lookahead since such usage\n * is rare. Although it may return other location properties e.g. `curLine` and\n * `lineStart`, these properties are not listed in the LookaheadState interface\n * and thus the returned value is _NOT_ reliable.\n *\n * The tokenizer should make best efforts to avoid using any parser state\n * other than those defined in LookaheadState\n *\n * @returns {LookaheadState}\n * @memberof Tokenizer\n */\n lookahead(): LookaheadState {\n const old = this.state;\n // For performance we use a simpified tokenizer state structure\n // $FlowIgnore\n this.state = this.createLookaheadState(old);\n\n this.isLookahead = true;\n this.nextToken();\n this.isLookahead = false;\n\n const curr = this.state;\n this.state = old;\n return curr;\n }\n\n nextTokenStart(): number {\n return this.nextTokenStartSince(this.state.pos);\n }\n\n nextTokenStartSince(pos: number): number {\n skipWhiteSpace.lastIndex = pos;\n return skipWhiteSpace.test(this.input) ? skipWhiteSpace.lastIndex : pos;\n }\n\n lookaheadCharCode(): number {\n return this.input.charCodeAt(this.nextTokenStart());\n }\n\n codePointAtPos(pos: number): number {\n // The implementation is based on\n // https://source.chromium.org/chromium/chromium/src/+/master:v8/src/builtins/builtins-string-gen.cc;l=1455;drc=221e331b49dfefadbc6fa40b0c68e6f97606d0b3;bpv=0;bpt=1\n // We reimplement `codePointAt` because `codePointAt` is a V8 builtin which is not inlined by TurboFan (as of M91)\n // since `input` is mostly ASCII, an inlined `charCodeAt` wins here\n let cp = this.input.charCodeAt(pos);\n if ((cp & 0xfc00) === 0xd800 && ++pos < this.input.length) {\n const trail = this.input.charCodeAt(pos);\n if ((trail & 0xfc00) === 0xdc00) {\n cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff);\n }\n }\n return cp;\n }\n\n // Toggle strict mode. Re-reads the next number or string to please\n // pedantic tests (`\"use strict\"; 010;` should fail).\n\n setStrict(strict: boolean): void {\n this.state.strict = strict;\n if (strict) {\n // Throw an error for any string decimal escape found before/immediately\n // after a \"use strict\" directive. Strict mode will be set at parse\n // time for any literals that occur after the next node of the strict\n // directive.\n this.state.strictErrors.forEach(({ message, loc }) =>\n /* eslint-disable @babel/development-internal/dry-error-messages */\n this.raise(message, { at: loc }),\n );\n this.state.strictErrors.clear();\n }\n }\n\n curContext(): TokContext {\n return this.state.context[this.state.context.length - 1];\n }\n\n // Read a single token, updating the parser object's token-related\n // properties.\n\n nextToken(): void {\n this.skipSpace();\n this.state.start = this.state.pos;\n if (!this.isLookahead) this.state.startLoc = this.state.curPosition();\n if (this.state.pos >= this.length) {\n this.finishToken(tt.eof);\n return;\n }\n\n this.getTokenFromCode(this.codePointAtPos(this.state.pos));\n }\n\n skipBlockComment(): N.CommentBlock | void {\n let startLoc;\n if (!this.isLookahead) startLoc = this.state.curPosition();\n const start = this.state.pos;\n const end = this.input.indexOf(\"*/\", start + 2);\n if (end === -1) {\n // We have to call this again here because startLoc may not be set...\n // This seems to be for performance reasons:\n // https://github.com/babel/babel/commit/acf2a10899f696a8aaf34df78bf9725b5ea7f2da\n throw this.raise(Errors.UnterminatedComment, {\n at: this.state.curPosition(),\n });\n }\n\n this.state.pos = end + 2;\n lineBreakG.lastIndex = start + 2;\n while (lineBreakG.test(this.input) && lineBreakG.lastIndex <= end) {\n ++this.state.curLine;\n this.state.lineStart = lineBreakG.lastIndex;\n }\n\n // If we are doing a lookahead right now we need to advance the position (above code)\n // but we do not want to push the comment to the state.\n if (this.isLookahead) return;\n /*:: invariant(startLoc) */\n\n const comment = {\n type: \"CommentBlock\",\n value: this.input.slice(start + 2, end),\n start,\n end: end + 2,\n loc: new SourceLocation(startLoc, this.state.curPosition()),\n };\n if (this.options.tokens) this.pushToken(comment);\n return comment;\n }\n\n skipLineComment(startSkip: number): N.CommentLine | void {\n const start = this.state.pos;\n let startLoc;\n if (!this.isLookahead) startLoc = this.state.curPosition();\n let ch = this.input.charCodeAt((this.state.pos += startSkip));\n if (this.state.pos < this.length) {\n while (!isNewLine(ch) && ++this.state.pos < this.length) {\n ch = this.input.charCodeAt(this.state.pos);\n }\n }\n\n // If we are doing a lookahead right now we need to advance the position (above code)\n // but we do not want to push the comment to the state.\n if (this.isLookahead) return;\n /*:: invariant(startLoc) */\n\n const end = this.state.pos;\n const value = this.input.slice(start + startSkip, end);\n\n const comment = {\n type: \"CommentLine\",\n value,\n start,\n end,\n loc: new SourceLocation(startLoc, this.state.curPosition()),\n };\n if (this.options.tokens) this.pushToken(comment);\n return comment;\n }\n\n // Called at the start of the parse and after every token. Skips\n // whitespace and comments, and.\n\n skipSpace(): void {\n const spaceStart = this.state.pos;\n const comments = [];\n loop: while (this.state.pos < this.length) {\n const ch = this.input.charCodeAt(this.state.pos);\n switch (ch) {\n case charCodes.space:\n case charCodes.nonBreakingSpace:\n case charCodes.tab:\n ++this.state.pos;\n break;\n case charCodes.carriageReturn:\n if (\n this.input.charCodeAt(this.state.pos + 1) === charCodes.lineFeed\n ) {\n ++this.state.pos;\n }\n // fall through\n case charCodes.lineFeed:\n case charCodes.lineSeparator:\n case charCodes.paragraphSeparator:\n ++this.state.pos;\n ++this.state.curLine;\n this.state.lineStart = this.state.pos;\n break;\n\n case charCodes.slash:\n switch (this.input.charCodeAt(this.state.pos + 1)) {\n case charCodes.asterisk: {\n const comment = this.skipBlockComment();\n if (comment !== undefined) {\n this.addComment(comment);\n if (this.options.attachComment) comments.push(comment);\n }\n break;\n }\n\n case charCodes.slash: {\n const comment = this.skipLineComment(2);\n if (comment !== undefined) {\n this.addComment(comment);\n if (this.options.attachComment) comments.push(comment);\n }\n break;\n }\n\n default:\n break loop;\n }\n break;\n\n default:\n if (isWhitespace(ch)) {\n ++this.state.pos;\n } else if (ch === charCodes.dash && !this.inModule) {\n const pos = this.state.pos;\n if (\n this.input.charCodeAt(pos + 1) === charCodes.dash &&\n this.input.charCodeAt(pos + 2) === charCodes.greaterThan &&\n (spaceStart === 0 || this.state.lineStart > spaceStart)\n ) {\n // A `-->` line comment\n const comment = this.skipLineComment(3);\n if (comment !== undefined) {\n this.addComment(comment);\n if (this.options.attachComment) comments.push(comment);\n }\n } else {\n break loop;\n }\n } else if (ch === charCodes.lessThan && !this.inModule) {\n const pos = this.state.pos;\n if (\n this.input.charCodeAt(pos + 1) === charCodes.exclamationMark &&\n this.input.charCodeAt(pos + 2) === charCodes.dash &&\n this.input.charCodeAt(pos + 3) === charCodes.dash\n ) {\n // `` line comment\n const comment = this.skipLineComment(3);\n if (comment !== undefined) {\n this.addComment(comment);\n if (this.options.attachComment) comments.push(comment);\n }\n } else {\n break loop;\n }\n } else if (ch === charCodes.lessThan && !this.inModule) {\n const pos = this.state.pos;\n if (\n this.input.charCodeAt(pos + 1) === charCodes.exclamationMark &&\n this.input.charCodeAt(pos + 2) === charCodes.dash &&\n this.input.charCodeAt(pos + 3) === charCodes.dash\n ) {\n // `