@mizchi/sucrase
Version:
Super-fast alternative to Babel for when you can target modern JS runtimes
1,128 lines (1,117 loc) • 317 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const HELPERS = {
interopRequireWildcard: `
function interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
} else {
var newObj = {};
if (obj != null) {
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
return newObj;
}
}
`,
interopRequireDefault: `
function interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
`,
createNamedExportFrom: `
function createNamedExportFrom(obj, localName, importedName) {
Object.defineProperty(exports, localName, {enumerable: true, get: () => obj[importedName]});
}
`,
// Note that TypeScript and Babel do this differently; TypeScript does a simple existence
// check in the exports object and does a plain assignment, whereas Babel uses
// defineProperty and builds an object of explicitly-exported names so that star exports can
// always take lower precedence. For now, we do the easier TypeScript thing.
createStarExport: `
function createStarExport(obj) {
Object.keys(obj)
.filter((key) => key !== "default" && key !== "__esModule")
.forEach((key) => {
if (exports.hasOwnProperty(key)) {
return;
}
Object.defineProperty(exports, key, {enumerable: true, get: () => obj[key]});
});
}
`,
nullishCoalesce: `
function nullishCoalesce(lhs, rhsFn) {
if (lhs != null) {
return lhs;
} else {
return rhsFn();
}
}
`,
asyncNullishCoalesce: `
async function asyncNullishCoalesce(lhs, rhsFn) {
if (lhs != null) {
return lhs;
} else {
return await rhsFn();
}
}
`,
optionalChain: `
function optionalChain(ops) {
let lastAccessLHS = undefined;
let value = ops[0];
let i = 1;
while (i < ops.length) {
const op = ops[i];
const fn = ops[i + 1];
i += 2;
if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
return undefined;
}
if (op === 'access' || op === 'optionalAccess') {
lastAccessLHS = value;
value = fn(value);
} else if (op === 'call' || op === 'optionalCall') {
value = fn((...args) => value.call(lastAccessLHS, ...args));
lastAccessLHS = undefined;
}
}
return value;
}
`,
asyncOptionalChain: `
async function asyncOptionalChain(ops) {
let lastAccessLHS = undefined;
let value = ops[0];
let i = 1;
while (i < ops.length) {
const op = ops[i];
const fn = ops[i + 1];
i += 2;
if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
return undefined;
}
if (op === 'access' || op === 'optionalAccess') {
lastAccessLHS = value;
value = await fn(value);
} else if (op === 'call' || op === 'optionalCall') {
value = await fn((...args) => value.call(lastAccessLHS, ...args));
lastAccessLHS = undefined;
}
}
return value;
}
`,
optionalChainDelete: `
function optionalChainDelete(ops) {
const result = OPTIONAL_CHAIN_NAME(ops);
return result == null ? true : result;
}
`,
asyncOptionalChainDelete: `
async function asyncOptionalChainDelete(ops) {
const result = await ASYNC_OPTIONAL_CHAIN_NAME(ops);
return result == null ? true : result;
}
`,
};
class HelperManager {
constructor(nameManager) {
this.nameManager = nameManager;
this.helperNames = {};
}
getHelperName(baseName) {
let helperName = this.helperNames[baseName];
if (helperName) {
return helperName;
}
helperName = this.nameManager.claimFreeName(`_${baseName}`);
this.helperNames[baseName] = helperName;
return helperName;
}
emitHelpers() {
let resultCode = "";
if (this.helperNames.optionalChainDelete) {
this.getHelperName("optionalChain");
}
if (this.helperNames.asyncOptionalChainDelete) {
this.getHelperName("asyncOptionalChain");
}
for (const [baseName, helperCodeTemplate] of Object.entries(HELPERS)) {
const helperName = this.helperNames[baseName];
let helperCode = helperCodeTemplate;
if (baseName === "optionalChainDelete") {
helperCode = helperCode.replace("OPTIONAL_CHAIN_NAME", this.helperNames.optionalChain);
}
else if (baseName === "asyncOptionalChainDelete") {
helperCode = helperCode.replace("ASYNC_OPTIONAL_CHAIN_NAME", this.helperNames.asyncOptionalChain);
}
if (helperName) {
resultCode += " ";
resultCode += helperCode.replace(baseName, helperName).replace(/\s+/g, " ").trim();
}
}
return resultCode;
}
}
var ContextualKeyword;
(function (ContextualKeyword) {
ContextualKeyword[ContextualKeyword["NONE"] = 0] = "NONE";
ContextualKeyword[ContextualKeyword["_abstract"] = 1] = "_abstract";
ContextualKeyword[ContextualKeyword["_as"] = 2] = "_as";
ContextualKeyword[ContextualKeyword["_asserts"] = 3] = "_asserts";
ContextualKeyword[ContextualKeyword["_async"] = 4] = "_async";
ContextualKeyword[ContextualKeyword["_await"] = 5] = "_await";
ContextualKeyword[ContextualKeyword["_checks"] = 6] = "_checks";
ContextualKeyword[ContextualKeyword["_constructor"] = 7] = "_constructor";
ContextualKeyword[ContextualKeyword["_declare"] = 8] = "_declare";
ContextualKeyword[ContextualKeyword["_enum"] = 9] = "_enum";
ContextualKeyword[ContextualKeyword["_exports"] = 10] = "_exports";
ContextualKeyword[ContextualKeyword["_from"] = 11] = "_from";
ContextualKeyword[ContextualKeyword["_get"] = 12] = "_get";
ContextualKeyword[ContextualKeyword["_global"] = 13] = "_global";
ContextualKeyword[ContextualKeyword["_implements"] = 14] = "_implements";
ContextualKeyword[ContextualKeyword["_infer"] = 15] = "_infer";
ContextualKeyword[ContextualKeyword["_interface"] = 16] = "_interface";
ContextualKeyword[ContextualKeyword["_is"] = 17] = "_is";
ContextualKeyword[ContextualKeyword["_keyof"] = 18] = "_keyof";
ContextualKeyword[ContextualKeyword["_mixins"] = 19] = "_mixins";
ContextualKeyword[ContextualKeyword["_module"] = 20] = "_module";
ContextualKeyword[ContextualKeyword["_namespace"] = 21] = "_namespace";
ContextualKeyword[ContextualKeyword["_of"] = 22] = "_of";
ContextualKeyword[ContextualKeyword["_opaque"] = 23] = "_opaque";
ContextualKeyword[ContextualKeyword["_private"] = 24] = "_private";
ContextualKeyword[ContextualKeyword["_protected"] = 25] = "_protected";
ContextualKeyword[ContextualKeyword["_proto"] = 26] = "_proto";
ContextualKeyword[ContextualKeyword["_public"] = 27] = "_public";
ContextualKeyword[ContextualKeyword["_readonly"] = 28] = "_readonly";
ContextualKeyword[ContextualKeyword["_require"] = 29] = "_require";
ContextualKeyword[ContextualKeyword["_set"] = 30] = "_set";
ContextualKeyword[ContextualKeyword["_static"] = 31] = "_static";
ContextualKeyword[ContextualKeyword["_type"] = 32] = "_type";
ContextualKeyword[ContextualKeyword["_unique"] = 33] = "_unique";
})(ContextualKeyword || (ContextualKeyword = {}));
// Generated file, do not edit! Run "yarn generate" to re-generate this file.
/**
* Enum of all token types, with bit fields to signify meaningful properties.
*/
var TokenType;
(function (TokenType) {
// Precedence 0 means not an operator; otherwise it is a positive number up to 12.
TokenType[TokenType["PRECEDENCE_MASK"] = 15] = "PRECEDENCE_MASK";
TokenType[TokenType["IS_KEYWORD"] = 16] = "IS_KEYWORD";
TokenType[TokenType["IS_ASSIGN"] = 32] = "IS_ASSIGN";
TokenType[TokenType["IS_RIGHT_ASSOCIATIVE"] = 64] = "IS_RIGHT_ASSOCIATIVE";
TokenType[TokenType["IS_PREFIX"] = 128] = "IS_PREFIX";
TokenType[TokenType["IS_POSTFIX"] = 256] = "IS_POSTFIX";
TokenType[TokenType["num"] = 0] = "num";
TokenType[TokenType["bigint"] = 512] = "bigint";
TokenType[TokenType["decimal"] = 1024] = "decimal";
TokenType[TokenType["regexp"] = 1536] = "regexp";
TokenType[TokenType["string"] = 2048] = "string";
TokenType[TokenType["name"] = 2560] = "name";
TokenType[TokenType["eof"] = 3072] = "eof";
TokenType[TokenType["bracketL"] = 3584] = "bracketL";
TokenType[TokenType["bracketR"] = 4096] = "bracketR";
TokenType[TokenType["braceL"] = 4608] = "braceL";
TokenType[TokenType["braceBarL"] = 5120] = "braceBarL";
TokenType[TokenType["braceR"] = 5632] = "braceR";
TokenType[TokenType["braceBarR"] = 6144] = "braceBarR";
TokenType[TokenType["parenL"] = 6656] = "parenL";
TokenType[TokenType["parenR"] = 7168] = "parenR";
TokenType[TokenType["comma"] = 7680] = "comma";
TokenType[TokenType["semi"] = 8192] = "semi";
TokenType[TokenType["colon"] = 8704] = "colon";
TokenType[TokenType["doubleColon"] = 9216] = "doubleColon";
TokenType[TokenType["dot"] = 9728] = "dot";
TokenType[TokenType["question"] = 10240] = "question";
TokenType[TokenType["questionDot"] = 10752] = "questionDot";
TokenType[TokenType["arrow"] = 11264] = "arrow";
TokenType[TokenType["template"] = 11776] = "template";
TokenType[TokenType["ellipsis"] = 12288] = "ellipsis";
TokenType[TokenType["backQuote"] = 12800] = "backQuote";
TokenType[TokenType["dollarBraceL"] = 13312] = "dollarBraceL";
TokenType[TokenType["at"] = 13824] = "at";
TokenType[TokenType["hash"] = 14336] = "hash";
TokenType[TokenType["eq"] = 14880] = "eq";
TokenType[TokenType["assign"] = 15392] = "assign";
TokenType[TokenType["preIncDec"] = 16256] = "preIncDec";
TokenType[TokenType["postIncDec"] = 16768] = "postIncDec";
TokenType[TokenType["bang"] = 17024] = "bang";
TokenType[TokenType["tilde"] = 17536] = "tilde";
TokenType[TokenType["pipeline"] = 17921] = "pipeline";
TokenType[TokenType["nullishCoalescing"] = 18434] = "nullishCoalescing";
TokenType[TokenType["logicalOR"] = 18946] = "logicalOR";
TokenType[TokenType["logicalAND"] = 19459] = "logicalAND";
TokenType[TokenType["bitwiseOR"] = 19972] = "bitwiseOR";
TokenType[TokenType["bitwiseXOR"] = 20485] = "bitwiseXOR";
TokenType[TokenType["bitwiseAND"] = 20998] = "bitwiseAND";
TokenType[TokenType["equality"] = 21511] = "equality";
TokenType[TokenType["lessThan"] = 22024] = "lessThan";
TokenType[TokenType["greaterThan"] = 22536] = "greaterThan";
TokenType[TokenType["relationalOrEqual"] = 23048] = "relationalOrEqual";
TokenType[TokenType["bitShift"] = 23561] = "bitShift";
TokenType[TokenType["plus"] = 24202] = "plus";
TokenType[TokenType["minus"] = 24714] = "minus";
TokenType[TokenType["modulo"] = 25099] = "modulo";
TokenType[TokenType["star"] = 25611] = "star";
TokenType[TokenType["slash"] = 26123] = "slash";
TokenType[TokenType["exponent"] = 26700] = "exponent";
TokenType[TokenType["jsxName"] = 27136] = "jsxName";
TokenType[TokenType["jsxText"] = 27648] = "jsxText";
TokenType[TokenType["jsxTagStart"] = 28160] = "jsxTagStart";
TokenType[TokenType["jsxTagEnd"] = 28672] = "jsxTagEnd";
TokenType[TokenType["typeParameterStart"] = 29184] = "typeParameterStart";
TokenType[TokenType["nonNullAssertion"] = 29696] = "nonNullAssertion";
TokenType[TokenType["_break"] = 30224] = "_break";
TokenType[TokenType["_case"] = 30736] = "_case";
TokenType[TokenType["_catch"] = 31248] = "_catch";
TokenType[TokenType["_continue"] = 31760] = "_continue";
TokenType[TokenType["_debugger"] = 32272] = "_debugger";
TokenType[TokenType["_default"] = 32784] = "_default";
TokenType[TokenType["_do"] = 33296] = "_do";
TokenType[TokenType["_else"] = 33808] = "_else";
TokenType[TokenType["_finally"] = 34320] = "_finally";
TokenType[TokenType["_for"] = 34832] = "_for";
TokenType[TokenType["_function"] = 35344] = "_function";
TokenType[TokenType["_if"] = 35856] = "_if";
TokenType[TokenType["_return"] = 36368] = "_return";
TokenType[TokenType["_switch"] = 36880] = "_switch";
TokenType[TokenType["_throw"] = 37520] = "_throw";
TokenType[TokenType["_try"] = 37904] = "_try";
TokenType[TokenType["_var"] = 38416] = "_var";
TokenType[TokenType["_let"] = 38928] = "_let";
TokenType[TokenType["_const"] = 39440] = "_const";
TokenType[TokenType["_while"] = 39952] = "_while";
TokenType[TokenType["_with"] = 40464] = "_with";
TokenType[TokenType["_new"] = 40976] = "_new";
TokenType[TokenType["_this"] = 41488] = "_this";
TokenType[TokenType["_super"] = 42000] = "_super";
TokenType[TokenType["_class"] = 42512] = "_class";
TokenType[TokenType["_extends"] = 43024] = "_extends";
TokenType[TokenType["_export"] = 43536] = "_export";
TokenType[TokenType["_import"] = 44048] = "_import";
TokenType[TokenType["_yield"] = 44560] = "_yield";
TokenType[TokenType["_null"] = 45072] = "_null";
TokenType[TokenType["_true"] = 45584] = "_true";
TokenType[TokenType["_false"] = 46096] = "_false";
TokenType[TokenType["_in"] = 46616] = "_in";
TokenType[TokenType["_instanceof"] = 47128] = "_instanceof";
TokenType[TokenType["_typeof"] = 47760] = "_typeof";
TokenType[TokenType["_void"] = 48272] = "_void";
TokenType[TokenType["_delete"] = 48784] = "_delete";
TokenType[TokenType["_async"] = 49168] = "_async";
TokenType[TokenType["_get"] = 49680] = "_get";
TokenType[TokenType["_set"] = 50192] = "_set";
TokenType[TokenType["_declare"] = 50704] = "_declare";
TokenType[TokenType["_readonly"] = 51216] = "_readonly";
TokenType[TokenType["_abstract"] = 51728] = "_abstract";
TokenType[TokenType["_static"] = 52240] = "_static";
TokenType[TokenType["_public"] = 52752] = "_public";
TokenType[TokenType["_private"] = 53264] = "_private";
TokenType[TokenType["_protected"] = 53776] = "_protected";
TokenType[TokenType["_as"] = 54288] = "_as";
TokenType[TokenType["_enum"] = 54800] = "_enum";
TokenType[TokenType["_type"] = 55312] = "_type";
TokenType[TokenType["_implements"] = 55824] = "_implements";
})(TokenType || (TokenType = {}));
function formatTokenType(tokenType) {
switch (tokenType) {
case TokenType.num:
return "num";
case TokenType.bigint:
return "bigint";
case TokenType.decimal:
return "decimal";
case TokenType.regexp:
return "regexp";
case TokenType.string:
return "string";
case TokenType.name:
return "name";
case TokenType.eof:
return "eof";
case TokenType.bracketL:
return "[";
case TokenType.bracketR:
return "]";
case TokenType.braceL:
return "{";
case TokenType.braceBarL:
return "{|";
case TokenType.braceR:
return "}";
case TokenType.braceBarR:
return "|}";
case TokenType.parenL:
return "(";
case TokenType.parenR:
return ")";
case TokenType.comma:
return ",";
case TokenType.semi:
return ";";
case TokenType.colon:
return ":";
case TokenType.doubleColon:
return "::";
case TokenType.dot:
return ".";
case TokenType.question:
return "?";
case TokenType.questionDot:
return "?.";
case TokenType.arrow:
return "=>";
case TokenType.template:
return "template";
case TokenType.ellipsis:
return "...";
case TokenType.backQuote:
return "`";
case TokenType.dollarBraceL:
return "${";
case TokenType.at:
return "@";
case TokenType.hash:
return "#";
case TokenType.eq:
return "=";
case TokenType.assign:
return "_=";
case TokenType.preIncDec:
return "++/--";
case TokenType.postIncDec:
return "++/--";
case TokenType.bang:
return "!";
case TokenType.tilde:
return "~";
case TokenType.pipeline:
return "|>";
case TokenType.nullishCoalescing:
return "??";
case TokenType.logicalOR:
return "||";
case TokenType.logicalAND:
return "&&";
case TokenType.bitwiseOR:
return "|";
case TokenType.bitwiseXOR:
return "^";
case TokenType.bitwiseAND:
return "&";
case TokenType.equality:
return "==/!=";
case TokenType.lessThan:
return "<";
case TokenType.greaterThan:
return ">";
case TokenType.relationalOrEqual:
return "<=/>=";
case TokenType.bitShift:
return "<</>>";
case TokenType.plus:
return "+";
case TokenType.minus:
return "-";
case TokenType.modulo:
return "%";
case TokenType.star:
return "*";
case TokenType.slash:
return "/";
case TokenType.exponent:
return "**";
case TokenType.jsxName:
return "jsxName";
case TokenType.jsxText:
return "jsxText";
case TokenType.jsxTagStart:
return "jsxTagStart";
case TokenType.jsxTagEnd:
return "jsxTagEnd";
case TokenType.typeParameterStart:
return "typeParameterStart";
case TokenType.nonNullAssertion:
return "nonNullAssertion";
case TokenType._break:
return "break";
case TokenType._case:
return "case";
case TokenType._catch:
return "catch";
case TokenType._continue:
return "continue";
case TokenType._debugger:
return "debugger";
case TokenType._default:
return "default";
case TokenType._do:
return "do";
case TokenType._else:
return "else";
case TokenType._finally:
return "finally";
case TokenType._for:
return "for";
case TokenType._function:
return "function";
case TokenType._if:
return "if";
case TokenType._return:
return "return";
case TokenType._switch:
return "switch";
case TokenType._throw:
return "throw";
case TokenType._try:
return "try";
case TokenType._var:
return "var";
case TokenType._let:
return "let";
case TokenType._const:
return "const";
case TokenType._while:
return "while";
case TokenType._with:
return "with";
case TokenType._new:
return "new";
case TokenType._this:
return "this";
case TokenType._super:
return "super";
case TokenType._class:
return "class";
case TokenType._extends:
return "extends";
case TokenType._export:
return "export";
case TokenType._import:
return "import";
case TokenType._yield:
return "yield";
case TokenType._null:
return "null";
case TokenType._true:
return "true";
case TokenType._false:
return "false";
case TokenType._in:
return "in";
case TokenType._instanceof:
return "instanceof";
case TokenType._typeof:
return "typeof";
case TokenType._void:
return "void";
case TokenType._delete:
return "delete";
case TokenType._async:
return "async";
case TokenType._get:
return "get";
case TokenType._set:
return "set";
case TokenType._declare:
return "declare";
case TokenType._readonly:
return "readonly";
case TokenType._abstract:
return "abstract";
case TokenType._static:
return "static";
case TokenType._public:
return "public";
case TokenType._private:
return "private";
case TokenType._protected:
return "protected";
case TokenType._as:
return "as";
case TokenType._enum:
return "enum";
case TokenType._type:
return "type";
case TokenType._implements:
return "implements";
default:
return "";
}
}
class Scope {
constructor(startTokenIndex, endTokenIndex, isFunctionScope) {
this.startTokenIndex = startTokenIndex;
this.endTokenIndex = endTokenIndex;
this.isFunctionScope = isFunctionScope;
}
}
class StateSnapshot {
constructor(potentialArrowAt, noAnonFunctionType, tokensLength, scopesLength, pos, type, contextualKeyword, start, end, isType, scopeDepth, error) {
this.potentialArrowAt = potentialArrowAt;
this.noAnonFunctionType = noAnonFunctionType;
this.tokensLength = tokensLength;
this.scopesLength = scopesLength;
this.pos = pos;
this.type = type;
this.contextualKeyword = contextualKeyword;
this.start = start;
this.end = end;
this.isType = isType;
this.scopeDepth = scopeDepth;
this.error = error;
}
}
class State {
constructor() {
// Used to signify the start of a potential arrow function
this.potentialArrowAt = -1;
// Used by Flow to handle an edge case involving function type parsing.
this.noAnonFunctionType = false;
// Token store.
this.tokens = [];
// Array of all observed scopes, ordered by their ending position.
this.scopes = [];
// The current position of the tokenizer in the input.
this.pos = 0;
// Information about the current token.
this.type = TokenType.eof;
this.contextualKeyword = ContextualKeyword.NONE;
this.start = 0;
this.end = 0;
this.isType = false;
this.scopeDepth = 0;
/**
* If the parser is in an error state, then the token is always tt.eof and all functions can
* keep executing but should be written so they don't get into an infinite loop in this situation.
*
* This approach, combined with the ability to snapshot and restore state, allows us to implement
* backtracking without exceptions and without needing to explicitly propagate error states
* everywhere.
*/
this.error = null;
}
snapshot() {
return new StateSnapshot(this.potentialArrowAt, this.noAnonFunctionType, this.tokens.length, this.scopes.length, this.pos, this.type, this.contextualKeyword, this.start, this.end, this.isType, this.scopeDepth, this.error);
}
restoreFromSnapshot(snapshot) {
this.potentialArrowAt = snapshot.potentialArrowAt;
this.noAnonFunctionType = snapshot.noAnonFunctionType;
this.tokens.length = snapshot.tokensLength;
this.scopes.length = snapshot.scopesLength;
this.pos = snapshot.pos;
this.type = snapshot.type;
this.contextualKeyword = snapshot.contextualKeyword;
this.start = snapshot.start;
this.end = snapshot.end;
this.isType = snapshot.isType;
this.scopeDepth = snapshot.scopeDepth;
this.error = snapshot.error;
}
}
var charCodes;
(function (charCodes) {
charCodes[charCodes["backSpace"] = 8] = "backSpace";
charCodes[charCodes["lineFeed"] = 10] = "lineFeed";
charCodes[charCodes["carriageReturn"] = 13] = "carriageReturn";
charCodes[charCodes["shiftOut"] = 14] = "shiftOut";
charCodes[charCodes["space"] = 32] = "space";
charCodes[charCodes["exclamationMark"] = 33] = "exclamationMark";
charCodes[charCodes["quotationMark"] = 34] = "quotationMark";
charCodes[charCodes["numberSign"] = 35] = "numberSign";
charCodes[charCodes["dollarSign"] = 36] = "dollarSign";
charCodes[charCodes["percentSign"] = 37] = "percentSign";
charCodes[charCodes["ampersand"] = 38] = "ampersand";
charCodes[charCodes["apostrophe"] = 39] = "apostrophe";
charCodes[charCodes["leftParenthesis"] = 40] = "leftParenthesis";
charCodes[charCodes["rightParenthesis"] = 41] = "rightParenthesis";
charCodes[charCodes["asterisk"] = 42] = "asterisk";
charCodes[charCodes["plusSign"] = 43] = "plusSign";
charCodes[charCodes["comma"] = 44] = "comma";
charCodes[charCodes["dash"] = 45] = "dash";
charCodes[charCodes["dot"] = 46] = "dot";
charCodes[charCodes["slash"] = 47] = "slash";
charCodes[charCodes["digit0"] = 48] = "digit0";
charCodes[charCodes["digit1"] = 49] = "digit1";
charCodes[charCodes["digit2"] = 50] = "digit2";
charCodes[charCodes["digit3"] = 51] = "digit3";
charCodes[charCodes["digit4"] = 52] = "digit4";
charCodes[charCodes["digit5"] = 53] = "digit5";
charCodes[charCodes["digit6"] = 54] = "digit6";
charCodes[charCodes["digit7"] = 55] = "digit7";
charCodes[charCodes["digit8"] = 56] = "digit8";
charCodes[charCodes["digit9"] = 57] = "digit9";
charCodes[charCodes["colon"] = 58] = "colon";
charCodes[charCodes["semicolon"] = 59] = "semicolon";
charCodes[charCodes["lessThan"] = 60] = "lessThan";
charCodes[charCodes["equalsTo"] = 61] = "equalsTo";
charCodes[charCodes["greaterThan"] = 62] = "greaterThan";
charCodes[charCodes["questionMark"] = 63] = "questionMark";
charCodes[charCodes["atSign"] = 64] = "atSign";
charCodes[charCodes["uppercaseA"] = 65] = "uppercaseA";
charCodes[charCodes["uppercaseB"] = 66] = "uppercaseB";
charCodes[charCodes["uppercaseC"] = 67] = "uppercaseC";
charCodes[charCodes["uppercaseD"] = 68] = "uppercaseD";
charCodes[charCodes["uppercaseE"] = 69] = "uppercaseE";
charCodes[charCodes["uppercaseF"] = 70] = "uppercaseF";
charCodes[charCodes["uppercaseG"] = 71] = "uppercaseG";
charCodes[charCodes["uppercaseH"] = 72] = "uppercaseH";
charCodes[charCodes["uppercaseI"] = 73] = "uppercaseI";
charCodes[charCodes["uppercaseJ"] = 74] = "uppercaseJ";
charCodes[charCodes["uppercaseK"] = 75] = "uppercaseK";
charCodes[charCodes["uppercaseL"] = 76] = "uppercaseL";
charCodes[charCodes["uppercaseM"] = 77] = "uppercaseM";
charCodes[charCodes["uppercaseN"] = 78] = "uppercaseN";
charCodes[charCodes["uppercaseO"] = 79] = "uppercaseO";
charCodes[charCodes["uppercaseP"] = 80] = "uppercaseP";
charCodes[charCodes["uppercaseQ"] = 81] = "uppercaseQ";
charCodes[charCodes["uppercaseR"] = 82] = "uppercaseR";
charCodes[charCodes["uppercaseS"] = 83] = "uppercaseS";
charCodes[charCodes["uppercaseT"] = 84] = "uppercaseT";
charCodes[charCodes["uppercaseU"] = 85] = "uppercaseU";
charCodes[charCodes["uppercaseV"] = 86] = "uppercaseV";
charCodes[charCodes["uppercaseW"] = 87] = "uppercaseW";
charCodes[charCodes["uppercaseX"] = 88] = "uppercaseX";
charCodes[charCodes["uppercaseY"] = 89] = "uppercaseY";
charCodes[charCodes["uppercaseZ"] = 90] = "uppercaseZ";
charCodes[charCodes["leftSquareBracket"] = 91] = "leftSquareBracket";
charCodes[charCodes["backslash"] = 92] = "backslash";
charCodes[charCodes["rightSquareBracket"] = 93] = "rightSquareBracket";
charCodes[charCodes["caret"] = 94] = "caret";
charCodes[charCodes["underscore"] = 95] = "underscore";
charCodes[charCodes["graveAccent"] = 96] = "graveAccent";
charCodes[charCodes["lowercaseA"] = 97] = "lowercaseA";
charCodes[charCodes["lowercaseB"] = 98] = "lowercaseB";
charCodes[charCodes["lowercaseC"] = 99] = "lowercaseC";
charCodes[charCodes["lowercaseD"] = 100] = "lowercaseD";
charCodes[charCodes["lowercaseE"] = 101] = "lowercaseE";
charCodes[charCodes["lowercaseF"] = 102] = "lowercaseF";
charCodes[charCodes["lowercaseG"] = 103] = "lowercaseG";
charCodes[charCodes["lowercaseH"] = 104] = "lowercaseH";
charCodes[charCodes["lowercaseI"] = 105] = "lowercaseI";
charCodes[charCodes["lowercaseJ"] = 106] = "lowercaseJ";
charCodes[charCodes["lowercaseK"] = 107] = "lowercaseK";
charCodes[charCodes["lowercaseL"] = 108] = "lowercaseL";
charCodes[charCodes["lowercaseM"] = 109] = "lowercaseM";
charCodes[charCodes["lowercaseN"] = 110] = "lowercaseN";
charCodes[charCodes["lowercaseO"] = 111] = "lowercaseO";
charCodes[charCodes["lowercaseP"] = 112] = "lowercaseP";
charCodes[charCodes["lowercaseQ"] = 113] = "lowercaseQ";
charCodes[charCodes["lowercaseR"] = 114] = "lowercaseR";
charCodes[charCodes["lowercaseS"] = 115] = "lowercaseS";
charCodes[charCodes["lowercaseT"] = 116] = "lowercaseT";
charCodes[charCodes["lowercaseU"] = 117] = "lowercaseU";
charCodes[charCodes["lowercaseV"] = 118] = "lowercaseV";
charCodes[charCodes["lowercaseW"] = 119] = "lowercaseW";
charCodes[charCodes["lowercaseX"] = 120] = "lowercaseX";
charCodes[charCodes["lowercaseY"] = 121] = "lowercaseY";
charCodes[charCodes["lowercaseZ"] = 122] = "lowercaseZ";
charCodes[charCodes["leftCurlyBrace"] = 123] = "leftCurlyBrace";
charCodes[charCodes["verticalBar"] = 124] = "verticalBar";
charCodes[charCodes["rightCurlyBrace"] = 125] = "rightCurlyBrace";
charCodes[charCodes["tilde"] = 126] = "tilde";
charCodes[charCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace";
// eslint-disable-next-line no-irregular-whitespace
charCodes[charCodes["oghamSpaceMark"] = 5760] = "oghamSpaceMark";
charCodes[charCodes["lineSeparator"] = 8232] = "lineSeparator";
charCodes[charCodes["paragraphSeparator"] = 8233] = "paragraphSeparator";
})(charCodes || (charCodes = {}));
let isJSXEnabled;
let state;
let input;
let nextContextId;
function getNextContextId() {
return nextContextId++;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function augmentError(error) {
if ("pos" in error) {
const loc = locationForIndex(error.pos);
error.message += ` (${loc.line}:${loc.column})`;
error.loc = loc;
}
return error;
}
class Loc {
constructor(line, column) {
this.line = line;
this.column = column;
}
}
function locationForIndex(pos) {
let line = 1;
let column = 1;
for (let i = 0; i < pos; i++) {
if (input.charCodeAt(i) === charCodes.lineFeed) {
line++;
column = 1;
}
else {
column++;
}
}
return new Loc(line, column);
}
function initParser(inputCode, isJSXEnabledArg) {
input = inputCode;
state = new State();
nextContextId = 1;
isJSXEnabled = isJSXEnabledArg;
}
// ## Parser utilities
// Tests whether parsed token is a contextual keyword.
function isContextual(contextualKeyword) {
return state.contextualKeyword === contextualKeyword;
}
function isLookaheadContextual(contextualKeyword) {
const l = lookaheadTypeAndKeyword();
return l.type === TokenType.name && l.contextualKeyword === contextualKeyword;
}
// Consumes contextual keyword if possible.
function eatContextual(contextualKeyword) {
return state.contextualKeyword === contextualKeyword && eat(TokenType.name);
}
// Asserts that following token is given contextual keyword.
function expectContextual(contextualKeyword) {
if (!eatContextual(contextualKeyword)) {
unexpected();
}
}
// Test whether a semicolon can be inserted at the current position.
function canInsertSemicolon() {
return match(TokenType.eof) || match(TokenType.braceR) || hasPrecedingLineBreak();
}
function hasPrecedingLineBreak() {
const prevToken = state.tokens[state.tokens.length - 1];
const lastTokEnd = prevToken ? prevToken.end : 0;
for (let i = lastTokEnd; i < state.start; i++) {
const code = input.charCodeAt(i);
if (code === charCodes.lineFeed ||
code === charCodes.carriageReturn ||
code === 0x2028 ||
code === 0x2029) {
return true;
}
}
return false;
}
function isLineTerminator() {
return eat(TokenType.semi) || canInsertSemicolon();
}
// Consume a semicolon, or, failing that, see if we are allowed to
// pretend that there is a semicolon at this position.
function semicolon() {
if (!isLineTerminator()) {
unexpected('Unexpected token, expected ";"');
}
}
// Expect a token of a given type. If found, consume it, otherwise,
// raise an unexpected token error at given pos.
function expect(type) {
const matched = eat(type);
if (!matched) {
unexpected(`Unexpected token, expected "${formatTokenType(type)}"`);
}
}
/**
* Transition the parser to an error state. All code needs to be written to naturally unwind in this
* state, which allows us to backtrack without exceptions and without error plumbing everywhere.
*/
function unexpected(message = "Unexpected token", pos = state.start) {
if (state.error) {
return;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const err = new SyntaxError(message);
err.pos = pos;
state.error = err;
state.pos = input.length;
finishToken(TokenType.eof);
}
// https://tc39.github.io/ecma262/#sec-white-space
const WHITESPACE_CHARS = [
0x0009,
0x000b,
0x000c,
charCodes.space,
charCodes.nonBreakingSpace,
charCodes.oghamSpaceMark,
0x2000,
0x2001,
0x2002,
0x2003,
0x2004,
0x2005,
0x2006,
0x2007,
0x2008,
0x2009,
0x200a,
0x202f,
0x205f,
0x3000,
0xfeff, // ZERO WIDTH NO-BREAK SPACE
];
const skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
const IS_WHITESPACE = new Uint8Array(65536);
for (const char of WHITESPACE_CHARS) {
IS_WHITESPACE[char] = 1;
}
function computeIsIdentifierChar(code) {
if (code < 48)
return code === 36;
if (code < 58)
return true;
if (code < 65)
return false;
if (code < 91)
return true;
if (code < 97)
return code === 95;
if (code < 123)
return true;
if (code < 128)
return false;
throw new Error("Should not be called with non-ASCII char code.");
}
const IS_IDENTIFIER_CHAR = new Uint8Array(65536);
for (let i = 0; i < 128; i++) {
IS_IDENTIFIER_CHAR[i] = computeIsIdentifierChar(i) ? 1 : 0;
}
for (let i = 128; i < 65536; i++) {
IS_IDENTIFIER_CHAR[i] = 1;
}
// Aside from whitespace and newlines, all characters outside the ASCII space are either
// identifier characters or invalid. Since we're not performing code validation, we can just
// treat all invalid characters as identifier characters.
for (const whitespaceChar of WHITESPACE_CHARS) {
IS_IDENTIFIER_CHAR[whitespaceChar] = 0;
}
IS_IDENTIFIER_CHAR[0x2028] = 0;
IS_IDENTIFIER_CHAR[0x2029] = 0;
const IS_IDENTIFIER_START = IS_IDENTIFIER_CHAR.slice();
for (let numChar = charCodes.digit0; numChar <= charCodes.digit9; numChar++) {
IS_IDENTIFIER_START[numChar] = 0;
}
// Generated file, do not edit! Run "yarn generate" to re-generate this file.
// prettier-ignore
const READ_WORD_TREE = new Int32Array([
// ""
-1, 27, 594, 729, 1566, 2187, 2673, 3294, -1, 3510, -1, 4428, 4563, 4644, 4941, 5319, 5508, -1, 6048, 6507, 6966, 7398, 7560, 7722, -1, 7938, -1,
// "a"
-1, -1, 54, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 243, -1, -1, -1, 486, -1, -1, -1,
// "ab"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 81, -1, -1, -1, -1, -1, -1, -1,
// "abs"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 108, -1, -1, -1, -1, -1, -1,
// "abst"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 135, -1, -1, -1, -1, -1, -1, -1, -1,
// "abstr"
-1, 162, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "abstra"
-1, -1, -1, 189, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "abstrac"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 216, -1, -1, -1, -1, -1, -1,
// "abstract"
ContextualKeyword._abstract << 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "as"
ContextualKeyword._as << 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 270, -1, -1, -1, -1, -1, 405, -1,
// "ass"
-1, -1, -1, -1, -1, 297, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "asse"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 324, -1, -1, -1, -1, -1, -1, -1, -1,
// "asser"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 351, -1, -1, -1, -1, -1, -1,
// "assert"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 378, -1, -1, -1, -1, -1, -1, -1,
// "asserts"
ContextualKeyword._asserts << 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "asy"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 432, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "asyn"
-1, -1, -1, 459, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "async"
ContextualKeyword._async << 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "aw"
-1, 513, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "awa"
-1, -1, -1, -1, -1, -1, -1, -1, -1, 540, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "awai"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 567, -1, -1, -1, -1, -1, -1,
// "await"
ContextualKeyword._await << 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "b"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 621, -1, -1, -1, -1, -1, -1, -1, -1,
// "br"
-1, -1, -1, -1, -1, 648, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "bre"
-1, 675, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "brea"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 702, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "break"
(TokenType._break << 1) + 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "c"
-1, 756, -1, -1, -1, -1, -1, -1, 918, -1, -1, -1, 1053, -1, -1, 1161, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "ca"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 783, 837, -1, -1, -1, -1, -1, -1,
// "cas"
-1, -1, -1, -1, -1, 810, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "case"
(TokenType._case << 1) + 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "cat"
-1, -1, -1, 864, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "catc"
-1, -1, -1, -1, -1, -1, -1, -1, 891, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "catch"
(TokenType._catch << 1) + 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "ch"
-1, -1, -1, -1, -1, 945, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "che"
-1, -1, -1, 972, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "chec"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 999, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "check"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1026, -1, -1, -1, -1, -1, -1, -1,
// "checks"
ContextualKeyword._checks << 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "cl"
-1, 1080, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "cla"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1107, -1, -1, -1, -1, -1, -1, -1,
// "clas"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1134, -1, -1, -1, -1, -1, -1, -1,
// "class"
(TokenType._class << 1) + 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "co"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1188, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "con"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1215, 1431, -1, -1, -1, -1, -1, -1,
// "cons"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1242, -1, -1, -1, -1, -1, -1,
// "const"
(TokenType._const << 1) + 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1269, -1, -1, -1, -1, -1, -1, -1, -1,
// "constr"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1296, -1, -1, -1, -1, -1,
// "constru"
-1, -1, -1, 1323, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "construc"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1350, -1, -1, -1, -1, -1, -1,
// "construct"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1377, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "constructo"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1404, -1, -1, -1, -1, -1, -1, -1, -1,
// "constructor"
ContextualKeyword._constructor << 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "cont"
-1, -1, -1, -1, -1, -1, -1, -1, -1, 1458, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "conti"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1485, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "contin"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1512, -1, -1, -1, -1, -1,
// "continu"
-1, -1, -1, -1, -1, 1539, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "continue"
(TokenType._continue << 1) + 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "d"
-1, -1, -1, -1, -1, 1593, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2160, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "de"
-1, -1, 1620, 1782, -1, -1, 1917, -1, -1, -1, -1, -1, 2052, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "deb"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1647, -1, -1, -1, -1, -1,
// "debu"
-1, -1, -1, -1, -1, -1, -1, 1674, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "debug"
-1, -1, -1, -1, -1, -1, -1, 1701, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "debugg"
-1, -1, -1, -1, -1, 1728, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "debugge"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1755, -1, -1, -1, -1, -1, -1, -1, -1,
// "debugger"
(TokenType._debugger << 1) + 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "dec"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1809, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "decl"
-1, 1836, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "decla"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1863, -1, -1, -1, -1, -1, -1, -1, -1,
// "declar"
-1, -1, -1, -1, -1, 1890, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "declare"
ContextualKeyword._declare << 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "def"
-1, 1944, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "defa"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1971, -1, -1, -1, -1, -1,
// "defau"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1998, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "defaul"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2025, -1, -1, -1, -1, -1, -1,
// "default"
(TokenType._default << 1) + 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "del"
-1, -1, -1, -1, -1, 2079, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "dele"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2106, -1, -1, -1, -1, -1, -1,
// "delet"
-1, -1, -1, -1, -1, 2133, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "delete"
(TokenType._delete << 1) + 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "do"
(TokenType._do << 1) + 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "e"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2214, -1, 2295, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2376, -1, -1,
// "el"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2241, -1, -1, -1, -1, -1, -1, -1,
// "els"
-1, -1, -1, -1, -1, 2268, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "else"
(TokenType._else << 1) + 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "en"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2322, -1, -1, -1, -1, -1,
// "enu"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2349, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "enum"
ContextualKeyword._enum << 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "ex"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2403, -1, -1, -1, 2538, -1, -1, -1, -1, -1, -1,
// "exp"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2430, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "expo"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2457, -1, -1, -1, -1, -1, -1, -1, -1,
// "expor"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2484, -1, -1, -1, -1, -1, -1,
// "export"
(TokenType._export << 1) + 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2511, -1, -1, -1, -1, -1, -1, -1,
// "exports"
ContextualKeyword._exports << 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "ext"
-1, -1, -1, -1, -1, 2565, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "exte"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2592, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "exten"
-1, -1, -1, -1, 2619, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "extend"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2646, -1, -1, -1, -1, -1, -1, -1,
// "extends"
(TokenType._extends << 1) + 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "f"
-1, 2700, -1, -1, -1, -1, -1, -1, -1, 2808, -1, -1, -1, -1, -1, 2970, -1, -1, 3024, -1, -1, 3105, -1, -1, -1, -1, -1,
// "fa"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2727, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "fal"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2754, -1, -1, -1, -1, -1, -1, -1,
// "fals"
-1, -1, -1, -1, -1, 2781, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "false"
(TokenType._false << 1) + 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
// "fi"
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2835, -1, -1, -1, -1, -1, -1, -1,