tenko
Version:
A "pixel perfect" 100% spec compliant ES2021 JavaScript parser written in JS.
1,752 lines (1,738 loc) • 372 kB
JavaScript
// <perf>
let IGNORE = {};
// </perf>
// <charcodes>
// </charcodes>
// <utils>
function inspect(...args) {
console.dir(((args.length === 1)? args[0] : args), {depth:null});
}
function THROW(str, ...rest) {
throw new Error(`Parser error! ${str} ${(rest.length? rest : '')}`);
}
// </utils>
// <tokentype>
let __$flag_leaf = 0;
let __$flag_group = 7;
let ALL_GEES;
let KEYWORD_TRIE_OBJLIT = {0:{17:{6:{20:{12:{4:{13:{19:{18:{hit:2072, canon:'arguments'}}}}}}}}, 18:{24:{13:{2:{hit:2074, canon:'async'}}}, hit:2073, canon:'as'}, 22:{0:{8:{19:{hit:2075, canon:'await'}}}}}, 1:{17:{4:{0:{10:{hit:2076, canon:'break'}}}}}, 2:{0:{18:{4:{hit:2077, canon:'case'}}, 19:{2:{7:{hit:2078, canon:'catch'}}}}, 11:{0:{18:{18:{hit:2079, canon:'class'}}}}, 14:{13:{18:{19:{hit:2080, canon:'const'}}, 19:{8:{13:{20:{4:{hit:2081, canon:'continue'}}}}}}}}, 3:{4:{1:{20:{6:{6:{4:{17:{hit:2082, canon:'debugger'}}}}}}, 5:{0:{20:{11:{19:{hit:2083, canon:'default'}}}}}, 11:{4:{19:{4:{hit:2084, canon:'delete'}}}}}, 14:{hit:2085, canon:'do'}}, 4:{11:{18:{4:{hit:2086, canon:'else'}}}, 13:{20:{12:{hit:2087, canon:'enum'}}}, 21:{0:{11:{hit:2088, canon:'eval'}}}, 23:{15:{14:{17:{19:{hit:2089, canon:'export'}}}}, 19:{4:{13:{3:{18:{hit:2090, canon:'extends'}}}}}}}, 5:{0:{11:{18:{4:{hit:2091, canon:'false'}}}}, 8:{13:{0:{11:{11:{24:{hit:2092, canon:'finally'}}}}}}, 14:{17:{hit:2093, canon:'for'}}, 17:{14:{12:{hit:2094, canon:'from'}}}, 20:{13:{2:{19:{8:{14:{13:{hit:2095, canon:'function'}}}}}}}}, 6:{4:{19:{hit:2096, canon:'get'}}}, 8:{5:{hit:2097, canon:'if'}, 12:{15:{11:{4:{12:{4:{13:{19:{18:{hit:2098, canon:'implements'}}}}}}}, 14:{17:{19:{hit:2099, canon:'import'}}}}}, 13:{18:{19:{0:{13:{2:{4:{14:{5:{hit:67637, canon:'instanceof'}}}}}}}}, 19:{4:{17:{5:{0:{2:{4:{hit:2102, canon:'interface'}}}}}}}, hit:67636, canon:'in'}}, 11:{4:{19:{hit:2103, canon:'let'}}}, 13:{4:{22:{hit:2104, canon:'new'}}, 20:{11:{11:{hit:2105, canon:'null'}}}}, 14:{5:{hit:2106, canon:'of'}}, 15:{0:{2:{10:{0:{6:{4:{hit:2107, canon:'package'}}}}}}, 17:{8:{21:{0:{19:{4:{hit:2108, canon:'private'}}}}}, 14:{19:{4:{2:{19:{4:{3:{hit:2109, canon:'protected'}}}}}}}}, 20:{1:{11:{8:{2:{hit:2110, canon:'public'}}}}}}, 17:{4:{19:{20:{17:{13:{hit:2111, canon:'return'}}}}}}, 18:{4:{19:{hit:2112, canon:'set'}}, 19:{0:{19:{8:{2:{hit:2113, canon:'static'}}}}}, 20:{15:{4:{17:{hit:2114, canon:'super'}}}}, 22:{8:{19:{2:{7:{hit:2115, canon:'switch'}}}}}}, 19:{0:{17:{6:{4:{19:{hit:2116, canon:'target'}}}}}, 7:{8:{18:{hit:2117, canon:'this'}}, 17:{14:{22:{hit:2118, canon:'throw'}}}}, 17:{20:{4:{hit:2119, canon:'true'}}, 24:{hit:2120, canon:'try'}}, 24:{15:{4:{14:{5:{hit:2121, canon:'typeof'}}}}}}, 21:{0:{17:{hit:2122, canon:'var'}}, 14:{8:{3:{hit:2123, canon:'void'}}}}, 22:{7:{8:{11:{4:{hit:2124, canon:'while'}}}}, 8:{19:{7:{hit:2125, canon:'with'}}}}, 24:{8:{4:{11:{3:{hit:2126, canon:'yield'}}}}}};
function isWhiteToken(type) {
return (type & 256) === 256;
}
function isNewlineToken(type) {
return (type & 512) === 512;
}
function isCommentToken(type) {
return (type & 1024) === 1024;
}
function isIdentToken(type) {
return (type & 2048) === 2048;
}
function isNumberToken(type) {
return (type & 4096) === 4096;
}
function isBigintToken(type) {
return (type & 8192) === 8192;
}
function isStringToken(type) {
return (type & 131072) === 131072;
}
function isPunctuatorToken(type) {
return (type & 16384) === 16384;
}
function isRegexToken(type) {
return (type & 262144) === 262144;
}
function isTickToken(type) {
return (type & 524288) === 524288;
}
function isBadTickToken(type) {
return (type & 1048576) === 1048576;
}
function isNumberStringToken(type) {
return (type & 135168) !== 0;
}
function isNumberStringRegex(type) {
return (type & 397312) !== 0;
}
function toktypeToString(type) {
switch ((((typeof type) === 'object')? type.type : type)) {
case 0:
return 'UNTYPED';
case 257:
return 'SPACE';
case 258:
return 'TAB';
case 771:
return 'NL_SOLO';
case 772:
return 'NL_CRLF';
case 1285:
return 'COMMENT_SINGLE';
case 1286:
return 'COMMENT_MULTI';
case 1287:
return 'COMMENT_HTML';
case 2048:
return 'IDENT';
case 2072:
return 'ID_arguments';
case 2073:
return 'ID_as';
case 2074:
return 'ID_async';
case 2075:
return 'ID_await';
case 2076:
return 'ID_break';
case 2077:
return 'ID_case';
case 2078:
return 'ID_catch';
case 2079:
return 'ID_class';
case 2080:
return 'ID_const';
case 2081:
return 'ID_continue';
case 2082:
return 'ID_debugger';
case 2083:
return 'ID_default';
case 2084:
return 'ID_delete';
case 2085:
return 'ID_do';
case 2086:
return 'ID_else';
case 2087:
return 'ID_enum';
case 2088:
return 'ID_eval';
case 2089:
return 'ID_export';
case 2090:
return 'ID_extends';
case 2091:
return 'ID_false';
case 2092:
return 'ID_finally';
case 2093:
return 'ID_for';
case 2094:
return 'ID_from';
case 2095:
return 'ID_function';
case 2096:
return 'ID_get';
case 2097:
return 'ID_if';
case 2098:
return 'ID_implements';
case 2099:
return 'ID_import';
case 67636:
return 'ID_in';
case 67637:
return 'ID_instanceof';
case 2102:
return 'ID_interface';
case 2103:
return 'ID_let';
case 2104:
return 'ID_new';
case 2105:
return 'ID_null';
case 2106:
return 'ID_of';
case 2107:
return 'ID_package';
case 2108:
return 'ID_private';
case 2109:
return 'ID_protected';
case 2110:
return 'ID_public';
case 2111:
return 'ID_return';
case 2112:
return 'ID_set';
case 2113:
return 'ID_static';
case 2114:
return 'ID_super';
case 2115:
return 'ID_switch';
case 2116:
return 'ID_target';
case 2117:
return 'ID_this';
case 2118:
return 'ID_throw';
case 2119:
return 'ID_true';
case 2120:
return 'ID_try';
case 2121:
return 'ID_typeof';
case 2122:
return 'ID_var';
case 2123:
return 'ID_void';
case 2124:
return 'ID_while';
case 2125:
return 'ID_with';
case 2126:
return 'ID_yield';
case 4104:
return 'NUMBER_HEX';
case 4105:
return 'NUMBER_DEC';
case 4106:
return 'NUMBER_BIN';
case 4107:
return 'NUMBER_OCT';
case 4108:
return 'NUMBER_OLD';
case 12296:
return 'NUMBER_BIG_HEX';
case 12297:
return 'NUMBER_BIG_DEC';
case 12298:
return 'NUMBER_BIG_BIN';
case 12299:
return 'NUMBER_BIG_OCT';
case 16463:
return 'PUNC_EXCL';
case 82000:
return 'PUNC_EXCL_EQ';
case 82001:
return 'PUNC_EXCL_EQ_EQ';
case 82002:
return 'PUNC_PERCENT';
case 49235:
return 'PUNC_PERCENT_EQ';
case 82004:
return 'PUNC_AND';
case 82005:
return 'PUNC_AND_AND';
case 49238:
return 'PUNC_AND_AND';
case 49239:
return 'PUNC_AND_EQ';
case 16472:
return 'PUNC_PAREN_OPEN';
case 16473:
return 'PUNC_PAREN_CLOSE';
case 82010:
return 'PUNC_STAR';
case 82011:
return 'PUNC_STAR_STAR';
case 49244:
return 'PUNC_STAR_EQ';
case 49245:
return 'PUNC_STAR_STAR_EQ';
case 82014:
return 'PUNC_PLUS';
case 16479:
return 'PUNC_PLUS_PLUS';
case 49248:
return 'PUNC_PLUS_EQ';
case 16481:
return 'PUNC_COMMA';
case 82018:
return 'PUNC_MIN';
case 16483:
return 'PUNC_MIN_MIN';
case 49252:
return 'PUNC_MIN_EQ';
case 16485:
return 'PUNC_MIN_MIN_GT';
case 16486:
return 'PUNC_DOT';
case 16487:
return 'PUNC_DOT_DOT_DOT';
case 82024:
return 'PUNC_DIV';
case 49257:
return 'PUNC_DIV_EQ';
case 16490:
return 'PUNC_COLON';
case 16491:
return 'PUNC_SEMI';
case 82028:
return 'PUNC_LT';
case 82029:
return 'PUNC_LT_LT';
case 82030:
return 'PUNC_LT_EQ';
case 49263:
return 'PUNC_LT_LT_EQ';
case 16496:
return 'PUNC_LT_EXCL_MIN_MIN';
case 49265:
return 'PUNC_EQ';
case 82034:
return 'PUNC_EQ_EQ';
case 82035:
return 'PUNC_EQ_EQ_EQ';
case 16500:
return 'PUNC_EQ_GT';
case 82037:
return 'PUNC_GT';
case 82038:
return 'PUNC_GT_GT';
case 82039:
return 'PUNC_GT_GT_GT';
case 82040:
return 'PUNC_GT_EQ';
case 49273:
return 'PUNC_GT_GT_EQ';
case 49274:
return 'PUNC_GT_GT_GT_EQ';
case 16507:
return 'PUNC_QMARK';
case 82044:
return 'QMARK_DOT';
case 82045:
return 'QMARK_QMARK';
case 49277:
return 'QMARK_QMARK';
case 16511:
return 'PUNC_BRACKET_OPEN';
case 16512:
return 'PUNC_BRACKET_CLOSE';
case 82049:
return 'PUNC_CARET';
case 49282:
return 'PUNC_CARET_EQ';
case 16515:
return 'PUNC_CURLY_OPEN';
case 82052:
return 'PUNC_OR';
case 82053:
return 'PUNC_OR_OR';
case 49286:
return 'PUNC_OR_OR';
case 49287:
return 'PUNC_OR_EQ';
case 16520:
return 'PUNC_CURLY_CLOSE';
case 16521:
return 'PUNC_TILDE';
case 262157:
return 'REGEXN';
case 262158:
return 'REGEXU';
case 131087:
return 'STRING_SINGLE';
case 131088:
return 'STRING_DOUBLE';
case 524305:
return 'TICK_HEAD';
case 524306:
return 'TICK_BODY';
case 524307:
return 'TICK_TAIL';
case 524308:
return 'TICK_PURE';
case 1572881:
return 'TICK_BAD_HEAD';
case 1572882:
return 'TICK_BAD_BODY';
case 1572883:
return 'TICK_BAD_TAIL';
case 1572884:
return 'TICK_BAD_PURE';
case 2097173:
return 'EOF';
case 2097174:
return 'ASI';
case 2097175:
return 'ERROR';
}
throw new Error(('toktypeToString: UNKNOWN[' + JSON.stringify(type)) + ']');
}
let MAX_START_VALUE = 26;
let __$flag_start = 0;
let tokenStartJumpTable = [26, 26, 26, 26, 26, 26, 26, 26, 26, 1, 4, 1, 1, 5, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 1, 16, 6, 26, 2, 17, 18, 6, 16472, 16473, 19, 12, 16481, 13, 8, 11, 14, 7, 7, 7, 7, 7, 7, 7, 7, 7, 16490, 16491, 21, 10, 22, 25, 26, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 16511, 24, 16512, 20, 2, 15, 3, 3, 3, 3, 3, 3, 3, 2, 3, 2, 2, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 2, 3, 2, 16515, 23, 9, 16521];
let stringScanTable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let identScanTable = [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, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1];
let regexAtomEscapeStartJumpTable = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 1, 1, 1, 1, 0, 1, 11, 11, 11, 0, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 6, 11, 11, 0, 11, 11, 11, 0, 11, 11, 11, 0, 0, 0, 0, 11, 1, 11, 11, 5, 0, 11, 0, 11, 11, 11, 11, 9, 11, 11, 0, 11, 6, 11, 0, 0, 0, 2, 0, 0, 3, 11, 11, 0, 0, 0, 1];
let regexClassEscapeStartJumpTable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 18, 18, 18, 18, 0, 19, 18, 18, 15, 16, 16, 16, 16, 16, 16, 16, 17, 17, 0, 0, 0, 0, 0, 18, 0, 0, 7, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 13, 0, 0, 0, 13, 0, 0, 0, 18, 18, 18, 18, 0, 0, 0, 6, 4, 13, 0, 8, 0, 0, 0, 0, 5, 0, 0, 9, 0, 14, 0, 10, 13, 11, 2, 12, 13, 3, 0, 0, 18, 18, 18, 0];
let hexValueJumpTable = [16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 16, 16, 16, 16, 16, 16, 10, 11, 12, 13, 14, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 10, 11, 12, 13, 14, 15];
let regexAtomJumpTable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 3, 4, 2, 2, 0, 0, 1, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 7, 6, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 14, 13, 0];
let stringEscapeStartJumpTable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 8, 0, 7, 4, 15, 0, 5, 0, 0, 0, 0, 0, 0];
function getTokenStart(c) {
let s = tokenStartJumpTable[c];
return s;
}
function getStringPart(c) {
if (c > 0x7e) return 3;
let s = stringScanTable[c];
return s;
}
function getIdentPart(c) {
if (c > 0x7e) return 3;
let s = identScanTable[c];
return s;
}
function getHexValue(c) {
if (c > 0x66) return 16;
let v = hexValueJumpTable[c];
return v;
}
function T(type) {
return ('T<' + toktypeToString(type)) + '>';
}
// </tokentype>
// <lexerflags>
let __$flag_lf = 0;
function L(flags) {
let bak = flags;
let s = [];
if (!flags) {
s.push('LF_NO_FLAGS');
}
if (flags & 8192) {
flags ^= 8192;
s.push('LF_STRICT_MODE');
}
if (flags & 4) {
flags ^= 4;
s.push('LF_FOR_REGEX');
}
if (flags & 2048) {
flags ^= 2048;
s.push('LF_IN_TEMPLATE');
}
if (flags & 8) {
flags ^= 8;
s.push('LF_IN_ASYNC');
}
if (flags & 128) {
flags ^= 128;
s.push('LF_IN_GENERATOR');
}
if (flags & 16) {
flags ^= 16;
s.push('LF_IN_CONSTRUCTOR');
}
if (flags & 64) {
flags ^= 64;
s.push('LF_IN_FUNC_ARGS');
}
if (flags & 256) {
flags ^= 256;
s.push('LF_IN_GLOBAL');
}
if (flags & 512) {
flags ^= 512;
s.push('LF_IN_ITERATION');
}
if (flags & 1024) {
flags ^= 1024;
s.push('LF_IN_SWITCH');
}
if (flags & 2) {
flags ^= 2;
s.push('LF_CAN_NEW_DOT_TARGET');
}
if (flags & 32) {
flags ^= 32;
s.push('LF_IN_FOR_LHS');
}
if (flags & 4096) {
flags ^= 4096;
s.push('LF_NO_ASI');
}
if (flags & 16384) {
flags ^= 16384;
s.push('LF_SUPER_CALL');
}
if (flags & 32768) {
flags ^= 32768;
s.push('LF_SUPER_PROP');
}
if (flags & 65536) {
flags ^= 65536;
s.push('LF_NOT_KEYWORD');
}
if (flags & 131072) {
flags ^= 131072;
s.push('LF_CHAIING');
}
if (flags) {
throw new Error(((((('UNKNOWN_FLAGS: ' + flags.toString(2)) + ' (was: ') + bak.toString(2)) + '), so far: [') + s.join('|')) + ']');
}
return 'L:' + s.join('|');
}
// </lexerflags>
// <enum_lexer>
const GOAL_MODULE = true;
const GOAL_SCRIPT = false;
const COLLECT_TOKENS_NONE = 0;
const COLLECT_TOKENS_SOLID = 1;
const COLLECT_TOKENS_ALL = 2;
const COLLECT_TOKENS_TYPES = 3;
const WEB_COMPAT_OFF = false;
const WEB_COMPAT_ON = true;
// </enum_lexer>
// <enum_parser>
const VERSION_EXPONENTIATION = 7;
const VERSION_WHATEVER = Infinity;
let BINDING_TYPE_NONE = 0;
let BINDING_TYPE_ARG = 1;
let BINDING_TYPE_VAR = 2;
let BINDING_TYPE_FUNC_VAR = 3;
let BINDING_TYPE_FUNC_STMT = 4;
let BINDING_TYPE_FUNC_LEX = 5;
let BINDING_TYPE_LET = 6;
let BINDING_TYPE_CONST = 7;
let BINDING_TYPE_CLASS = 8;
let BINDING_TYPE_CATCH_IDENT = 9;
let BINDING_TYPE_CATCH_OTHER = 10;
let HAS_NO_BINDINGS = null;
let SCOPE_LAYER_GLOBAL = 0;
let SCOPE_LAYER_FOR_HEADER = 1;
let SCOPE_LAYER_BLOCK = 2;
let SCOPE_LAYER_FUNC_PARAMS = 3;
let SCOPE_LAYER_CATCH_HEAD = 5;
let SCOPE_LAYER_CATCH_BODY = 6;
let SCOPE_LAYER_FINALLY = 7;
let SCOPE_LAYER_SWITCH = 8;
let SCOPE_LAYER_FUNC_ROOT = 9;
let SCOPE_LAYER_FUNC_BODY = 10;
let SCOPE_LAYER_ARROW_PARAMS = 11;
let SCOPE_LAYER_FAKE_BLOCK = 12;
function DEVONLY() {
let dev = false;
return dev;
}
function copyPiggies(output, input) {
return output | (input & 1984);
}
function P(f, arr) {
if (f & 256) {
arr.push('PIGGY_BACK_WAS_CONSTRUCTOR');
f ^= 256;
}
if (f & 512) {
arr.push('PIGGY_BACK_WAS_PROTO');
f ^= 512;
}
if (f & 64) {
arr.push('PIGGY_BACK_SAW_AWAIT');
f ^= 64;
}
if (f & 128) {
arr.push('PIGGY_BACK_SAW_YIELD');
f ^= 128;
}
if (f & 1024) {
arr.push('PIGGY_BACK_WAS_ARROW');
f ^= 1024;
}
return f;
}
// </enum_parser>
// <lexer>
const TABLE_NONBIN_UNI_PROPS = ',General_Category,gc,Script,sc,Script_Extensions,scx,';
const TABLE_BIN_UNI_PROPS = ',ASCII,ASCII_Hex_Digit,AHex,Alphabetic,Alpha,Any,Assigned,Bidi_Control,Bidi_C,Bidi_Mirrored,Bidi_M,Case_Ignorable,CI,Cased,Changes_When_Casefolded,CWCF,Changes_When_Casemapped,CWCM,Changes_When_Lowercased,CWL,Changes_When_NFKC_Casefolded,CWKCF,Changes_When_Titlecased,CWT,Changes_When_Uppercased,CWU,Dash,Default_Ignorable_Code_Point,DI,Deprecated,Dep,Diacritic,Dia,Emoji,Emoji_Component,Emoji_Modifier,Emoji_Modifier_Base,Emoji_Presentation,Extended_Pictographic,Extender,Ext,Grapheme_Base,Gr_Base,Grapheme_Extend,Gr_Ext,Hex_Digit,Hex,IDS_Binary_Operator,IDSB,IDS_Trinary_Operator,IDST,ID_Continue,IDC,ID_Start,IDS,Ideographic,Ideo,Join_Control,Join_C,Logical_Order_Exception,LOE,Lowercase,Lower,Math,Noncharacter_Code_Point,NChar,Pattern_Syntax,Pat_Syn,Pattern_White_Space,Pat_WS,Quotation_Mark,QMark,Radical,Regional_Indicator,RI,Sentence_Terminal,STerm,Soft_Dotted,SD,Terminal_Punctuation,Term,Unified_Ideograph,UIdeo,Uppercase,Upper,Variation_Selector,VS,White_Space,space,XID_Continue,XIDC,XID_Start,XIDS,';
const TABLE_GEN_CAT_VALUES = ',Cased_Letter,LC,Close_Punctuation,Pe,Connector_Punctuation,Pc,Control,Cc,cntrl,Currency_Symbol,Sc,Dash_Punctuation,Pd,Decimal_Number,Nd,digit,Enclosing_Mark,Me,Final_Punctuation,Pf,Format,Cf,Initial_Punctuation,Pi,Letter,L,Letter_Number,Nl,Line_Separator,Zl,Lowercase_Letter,Ll,Mark,M,Combining_Mark,Math_Symbol,Sm,Modifier_Letter,Lm,Modifier_Symbol,Sk,Nonspacing_Mark,Mn,Number,N,Open_Punctuation,Ps,Other,C,Other_Letter,Lo,Other_Number,No,Other_Punctuation,Po,Other_Symbol,So,Paragraph_Separator,Zp,Private_Use,Co,Punctuation,P,punct,Separator,Z,Space_Separator,Zs,Spacing_Mark,Mc,Surrogate,Cs,Symbol,S,Titlecase_Letter,Lt,Unassigned,Cn,Uppercase_Letter,Lu,';
const TABLE_SCRIPT_VALUES = ',Adlam,Adlm,Ahom,Anatolian_Hieroglyphs,Hluw,Arabic,Arab,Armenian,Armn,Avestan,Avst,Balinese,Bali,Bamum,Bamu,Bassa_Vah,Bass,Batak,Batk,Bengali,Beng,Bhaiksuki,Bhks,Bopomofo,Bopo,Brahmi,Brah,Braille,Brai,Buginese,Bugi,Buhid,Buhd,Canadian_Aboriginal,Cans,Carian,Cari,Caucasian_Albanian,Aghb,Chakma,Cakm,Cham,Cherokee,Cher,Common,Zyyy,Coptic,Copt,Qaac,Cuneiform,Xsux,Cypriot,Cprt,Cyrillic,Cyrl,Deseret,Dsrt,Devanagari,Deva,Dogra,Dogr,Duployan,Dupl,Egyptian_Hieroglyphs,Egyp,Elbasan,Elba,Elymaic,Elym,Ethiopic,Ethi,Georgian,Geor,Glagolitic,Glag,Gothic,Goth,Grantha,Gran,Greek,Grek,Gujarati,Gujr,Gunjala_Gondi,Gong,Gurmukhi,Guru,Han,Hani,Hangul,Hang,Hanifi_Rohingya,Rohg,Hanunoo,Hano,Hatran,Hatr,Hebrew,Hebr,Hiragana,Hira,Imperial_Aramaic,Armi,Inherited,Zinh,Qaai,Inscriptional_Pahlavi,Phli,Inscriptional_Parthian,Prti,Javanese,Java,Kaithi,Kthi,Kannada,Knda,Katakana,Kana,Kayah_Li,Kali,Kharoshthi,Khar,Khmer,Khmr,Khojki,Khoj,Khudawadi,Sind,Lao,Laoo,Latin,Latn,Lepcha,Lepc,Limbu,Limb,Linear_A,Lina,Linear_B,Linb,Lisu,Lycian,Lyci,Lydian,Lydi,Mahajani,Mahj,Makasar,Maka,Malayalam,Mlym,Mandaic,Mand,Manichaean,Mani,Marchen,Marc,Medefaidrin,Medf,Masaram_Gondi,Gonm,Meetei_Mayek,Mtei,Mende_Kikakui,Mend,Meroitic_Cursive,Merc,Meroitic_Hieroglyphs,Mero,Miao,Plrd,Modi,Mongolian,Mong,Mro,Mroo,Multani,Mult,Myanmar,Mymr,Nabataean,Nbat,Nandinagari,Nand,New_Tai_Lue,Talu,Newa,Nko,Nkoo,Nushu,Nshu,Nyiakeng_Puachue_Hmong,Hmnp,Ogham,Ogam,Ol_Chiki,Olck,Old_Hungarian,Hung,Old_Italic,Ital,Old_North_Arabian,Narb,Old_Permic,Perm,Old_Persian,Xpeo,Old_Sogdian,Sogo,Old_South_Arabian,Sarb,Old_Turkic,Orkh,Oriya,Orya,Osage,Osge,Osmanya,Osma,Pahawh_Hmong,Hmng,Palmyrene,Palm,Pau_Cin_Hau,Pauc,Phags_Pa,Phag,Phoenician,Phnx,Psalter_Pahlavi,Phlp,Rejang,Rjng,Runic,Runr,Samaritan,Samr,Saurashtra,Saur,Sharada,Shrd,Shavian,Shaw,Siddham,Sidd,SignWriting,Sgnw,Sinhala,Sinh,Sogdian,Sogd,Sora_Sompeng,Sora,Soyombo,Soyo,Sundanese,Sund,Syloti_Nagri,Sylo,Syriac,Syrc,Tagalog,Tglg,Tagbanwa,Tagb,Tai_Le,Tale,Tai_Tham,Lana,Tai_Viet,Tavt,Takri,Takr,Tamil,Taml,Tangut,Tang,Telugu,Telu,Thaana,Thaa,Thai,Tibetan,Tibt,Tifinagh,Tfng,Tirhuta,Tirh,Ugaritic,Ugar,Vai,Vaii,Wancho,Wcho,Warang_Citi,Wara,Yi,Yiii,Zanabazar_Square,Zanb,';
let ID_START_REGEX = undefined;
function getIdStartRegexSuperSlow() {
if (ID_START_REGEX) return ID_START_REGEX;
return ID_START_REGEX = createUnicodeRegex('^\\p{ID_Start}$');
}
let ID_CONTINUE_REGEX = undefined;
function getIdRestRegexSuperSlow() {
if (ID_CONTINUE_REGEX) return ID_CONTINUE_REGEX;
return ID_CONTINUE_REGEX = createUnicodeRegex('^\\p{ID_Continue}$');
}
function createUnicodeRegex(pattern) {
try {
return new RegExp(pattern, 'u');
} catch (e) {
console.warn(('Tenko: Current nodejs version does not suppport unicode regexes or regex property escapes; Input contains unicode that requires it so Tenko is unable to properly parse input (' + e.message) + ')');
return /|/;
}
}
function Lexer(input, options) {
const {targetEsVersion = Infinity, parsingGoal = true, collectTokens = 0, returnTokens = 3, webCompat = true, gracefulErrors = false, tokenStorageExternal, babelTokenCompat = false, errorCodeFrame = true, truncCodeFrame = false, $log = console.log, $warn = console.warn, $error = console.error} = options;
const tokenStorage = (tokenStorageExternal || (((collectTokens !== 0)? [] : undefined)));
const supportRegexPropertyEscapes = ((targetEsVersion >= 9) || (targetEsVersion === Infinity));
const supportRegexLookbehinds = ((targetEsVersion >= 9) || (targetEsVersion === Infinity));
const supportRegexDotallFlag = ((targetEsVersion >= 9) || (targetEsVersion === Infinity));
const supportRegexNamedGroups = ((targetEsVersion >= 9) || (targetEsVersion === Infinity));
const supportBigInt = ((targetEsVersion === 11) || (targetEsVersion === Infinity));
const supportNullishCoalescing = ((targetEsVersion === 11) || (targetEsVersion === Infinity));
const supportOptionalChaining = ((targetEsVersion === 11) || (targetEsVersion === Infinity));
const supportLogicCompound = ((targetEsVersion === 12) || (targetEsVersion === Infinity));
let pointer = 0;
let len = input.length;
let consumedNewlinesBeforeSolid = false;
let nlwas = false;
let finished = false;
let lastOffset = pointer;
let startForError = 0;
let lastType = 0;
let lastStart = 0;
let lastStop = 0;
let lastLine = 0;
let lastColumn = 0;
let lastCanonizedInput = '';
let lastCanonizedInputLen = 0;
let lastPotentialRegexError = '';
let lastReportableLexerError = '';
let currentLine = 1;
let currentColOffset = 0;
let prevTokenEndColumn = 0;
let prevTokenEndLine = 0;
let prevTokenEndPointer = 0;
let prevTokenSolid = true;
let stale = false;
let cache = input.charCodeAt(0);
let anyTokenCount = 0;
let solidTokenCount = 0;
function peek() {
return cache;
}
function _readCache() {
return cache;
}
function peekd(delta) {
return input.charCodeAt(pointer + delta);
}
function peeky(ord) {
return cache === ord;
}
function slice(from, to) {
return input.slice(from, to);
}
function skipPeek() {
return cache = input.charCodeAt(++pointer);
}
function skip() {
let p = ++pointer;
if (pointer >= len) {
cache = 0;
return;
}
cache = input.charCodeAt(p);
}
function skipFastWithoutUpdatingCache() {
++pointer;
}
function eof() {
return pointer >= len;
}
function eofd(d) {
return pointer >= (len - d);
}
function neof() {
return pointer < len;
}
function neofd(d) {
return pointer <= (len - d);
}
function nextToken(lexerFlags) {
if (prevTokenSolid) {
prevTokenEndColumn = pointer - currentColOffset;
prevTokenEndLine = currentLine;
prevTokenEndPointer = pointer;
prevTokenSolid = false;
}
lastPotentialRegexError = '';
lastReportableLexerError = '';
do {
++anyTokenCount;
let startCol = pointer - currentColOffset;
let startRow = currentLine;
lastCanonizedInput = '';
lastCanonizedInputLen = 0;
nlwas = consumedNewlinesBeforeSolid;
if (pointer >= len) {
createToken(2097173, pointer, pointer, startCol, startRow);
finished = true;
return returnSolidToken(2097173, pointer, pointer, startCol, startRow);
}
let start = startForError = pointer;
let consumedTokenType = jumpTableLexer(lexerFlags);
if (!isWhiteToken(consumedTokenType)) {
createToken(consumedTokenType, start, pointer, startCol, startRow);
return returnSolidToken(consumedTokenType, start, pointer, startCol, startRow);
}
if (isCommentToken(consumedTokenType)) {
if (returnTokens === 2) {
createToken(consumedTokenType, start, pointer, startCol, startRow);
return returnCommentToken(consumedTokenType, start, pointer, startCol, startRow);
}
}
if (((collectTokens === 2) || (collectTokens === 3))) {
createToken(consumedTokenType, start, pointer, startCol, startRow);
tokenStorage.push(((collectTokens === 3)? consumedTokenType : createBaseToken(consumedTokenType, start, pointer, startCol, startRow, false)));
}
if (returnTokens === 1) {
return createToken(consumedTokenType, start, pointer, startCol, startRow);
}
if (consumedTokenType === 1285) {
if (((collectTokens !== 2) && (collectTokens !== 3))) skipNewlinesWithoutTokens();
}
if (nlwas === true) {
if (((collectTokens !== 2) && (collectTokens !== 3))) skipSpacesWithoutTokens();
}
} while (true);
}
function returnCommentToken(consumedTokenType, start, pointer, startCol, startRow) {
if (((collectTokens === 2) || (collectTokens === 3))) {
tokenStorage.push(((collectTokens === 3)? consumedTokenType : createBaseToken(consumedTokenType, start, pointer, startCol, startRow, false)));
}
}
function returnSolidToken(consumedTokenType, start, pointer, startCol, startRow) {
++solidTokenCount;
if (collectTokens !== 0) {
tokenStorage.push(((collectTokens === 3)? consumedTokenType : createBaseToken(consumedTokenType, start, pointer, startCol, startRow, consumedNewlinesBeforeSolid)));
}
consumedNewlinesBeforeSolid = false;
prevTokenSolid = true;
}
function skipSpacesWithoutTokens() {
while (pointer < len) {
let c = cache;
if (((c !== 0x20) && (c !== 0x09))) return;
skip();
}
}
function skipNewlinesWithoutTokens() {
while (pointer < len) {
let c = cache;
if (c === 0x0A) {
skip();
incrementLine();
} else if (c === 0x0D) {
skip();
parseCR();
} else {
return;
}
}
}
function jumpTableLexer(lexerFlags) {
let c = cache;
skip();
if (c > 0x7e) {
return parseOtherUnicode(c);
}
let s = getTokenStart(c);
if (s > MAX_START_VALUE) {
return s;
}
switch (s) {
case 1:
return parseSpace();
case 2:
return parseIdentifierRest(String.fromCharCode(c), 1);
case 3:
if ((lexerFlags & 65536) === 65536) return parseIdentifierRest(String.fromCharCode(c), 1);
return parsePotentialKeywordTrieMap(c);
case 4:
return parseNewlineSolo();
case 5:
return parseCR();
case 6:
return parseAnyString(c, lexerFlags);
case 7:
return parseDecimal();
case 8:
return parseLeadingDot();
case 9:
if ((lexerFlags & 2048) === 2048) return parseTemplateString(lexerFlags, false);
return 16520;
case 10:
return parseEqual();
case 11:
return parseFwdSlash(lexerFlags);
case 12:
return parseSameOrCompound(0x2b);
case 13:
return parseDash();
case 14:
return parseLeadingZero(lexerFlags);
case 15:
return parseTemplateString(lexerFlags, true);
case 16:
return parseExcl();
case 17:
return parseCompoundAssignment(0x25);
case 18:
return parseSameOrCompound(0x26);
case 19:
return parseStar();
case 20:
return parseCompoundAssignment(0x5e);
case 21:
return parseLt();
case 22:
return parseGtPunctuator();
case 23:
return parseSameOrCompound(0x7c);
case 24:
return parseBackslash();
case 25:
return parseQmark();
}
THROW('Unknown input', pointer - 1, pointer);
}
function incrementLine() {
consumedNewlinesBeforeSolid = true;
++currentLine;
currentColOffset = pointer;
}
function addAsi() {
if (collectTokens !== 0) {
tokenStorage.push(((collectTokens === 3)? 2097174 : createBaseToken(2097174, pointer, pointer, pointer - currentColOffset, currentLine, false)), tokenStorage.pop());
}
++anyTokenCount;
++solidTokenCount;
prevTokenSolid = true;
}
function createToken(type, start, stop, column, line) {
lastType = type;
lastStart = start;
lastStop = stop;
lastLine = line;
lastColumn = column;
}
function createBaseToken(type, start, stop, column, line, nl) {
if (babelTokenCompat) {
return {type, start, stop, loc:{start:{line:line, column:column}, end:{line:currentLine, column:currentColOffset}}, column, line};
}
return {type, start, stop, column, line, nl};
}
function parseLeadingDot() {
if (pointer >= len) return 16486;
let c = cache;
if (c === 0x2e) {
return parseTripleDot();
}
if (isAsciiNumber(c)) {
return parseNumberFromDot(c);
}
return 16486;
}
function parseTripleDot() {
if (peekd(1) === 0x2e) {
skip();
skip();
return 16487;
}
return 16487;
}
function parseNumberFromDot(c) {
skip();
if (pointer < len) {
let d = skipDigitsWithSeparators(true);
parseExponentMaybe(d);
}
verifyCharAfterNumber();
return 4105;
}
function parseSpace() {
return 257;
}
function parseCR() {
if ((pointer < len && (cache === 0x0A))) {
skip();
incrementLine();
return 772;
}
incrementLine();
return 771;
}
function parseAnyString(marker, lexerFlags) {
let pointerOffset = pointer;
let badEscape = false;
let hadNewline = false;
while (pointer < len) {
let c = cache;
let s = getStringPart(c);
if (s <= MAX_START_VALUE) {
switch (s) {
case 0:
skip();
break;
case 1:
skip();
if (c === marker) {
if (badEscape) {
if (!lastReportableLexerError) lastReportableLexerError = 'String had an illegal escape';
return 2097175;
}
if (hadNewline) {
if (!lastReportableLexerError) lastReportableLexerError = 'Encountered newline in string which is not allowed';
return 2097175;
}
lastCanonizedInput += slice(pointerOffset, pointer - 1);
lastCanonizedInputLen += (pointer - 1) - pointerOffset;
return ((marker === 0x22)? 131088 : 131087);
}
break;
case 2:
lastCanonizedInput += slice(pointerOffset, pointer);
lastCanonizedInputLen += pointer - pointerOffset;
badEscape = ((parseStringOrTemplateEscape(lexerFlags, false) === true) || badEscape);
pointerOffset = pointer;
break;
case 3:
skip();
if (((c <= 0x2029) && (c >= 0x2028))) {
incrementLine();
}
break;
case 4:
skip();
hadNewline = true;
break;
;
}
}
}
if (!lastReportableLexerError) lastReportableLexerError = 'Unclosed string at EOF';
return 2097175;
}
function parseStringOrTemplateEscape(lexerFlags, forTemplate) {
skip();
if (pointer >= len) {
if (!lastReportableLexerError) lastReportableLexerError = 'Backslash at end of input';
return true;
}
let c = cache;
skip();
let s = ((c > 0x7e)? 6 : stringEscapeStartJumpTable[c]);
switch (s) {
case 0:
lastCanonizedInput += String.fromCharCode(c);
++lastCanonizedInputLen;
return false;
case 1:
lastCanonizedInput += '\n';
++lastCanonizedInputLen;
return false;
case 2:
lastCanonizedInput += '\'';
++lastCanonizedInputLen;
return false;
case 3:
lastCanonizedInput += '"';
++lastCanonizedInputLen;
return false;
case 4:
{
if (pointer >= len) return true;
let r = parseUnicodeEscapeForNonRegex();
if (r === 0x110000) return true;
lastCanonizedInput += ((r > 0xffff)? String.fromCodePoint(r) : String.fromCharCode(r));
lastCanonizedInputLen += ((r > 0xffff)? 2 : 1);
return false;
}
case 5:
return parseStringEscapeHex();
case 6:
if (((c === 0x2028) || (c === 0x2029))) {
incrementLine();
return false;
}
lastCanonizedInput += String.fromCharCode(c);
++lastCanonizedInputLen;
return false;
case 7:
lastCanonizedInput += '\t';
++lastCanonizedInputLen;
return false;
case 8:
lastCanonizedInput += '\r';
++lastCanonizedInputLen;
return false;
case 9:
if ((pointer < len && (cache === 0x0A))) skip();
incrementLine();
return false;
case 10:
incrementLine();
return false;
case 11:
case 12:
return parseStringEscapeOctalOrDigit(c, forTemplate, lexerFlags);
case 13:
lastCanonizedInput += '\b';
++lastCanonizedInputLen;
return false;
case 14:
lastCanonizedInput += '\f';
++lastCanonizedInputLen;
return false;
case 15:
lastCanonizedInput += '\v';
++lastCanonizedInputLen;
return false;
;
}
}
function skipZeroes() {
let c = cache;
while (c === 0x30) {
skip();
if (pointer >= len) return 0;
c = cache;
}
return c;
}
function parseStringEscapeHex() {
if (eofd(1)) {
if (pointer >= len) return false;
if (!lastReportableLexerError) lastReportableLexerError = 'Not enough of input left to create valid hex escape';
return true;
}
let a = cache;
let b = peekd(1);
let va = getHexValue(a);
let vb = getHexValue(b);
if ((va | vb) >= 16) {
lastCanonizedInput += 'x';
++lastCanonizedInputLen;
if (!lastReportableLexerError) lastReportableLexerError = 'At least one of the two hex characters were not hex character (0-9a-f)';
return true;
}
skip();
skip();
lastCanonizedInput += String.fromCharCode((va << 4) | vb);
++lastCanonizedInputLen;
return false;
}
function parseStringEscapeOctalOrDigit(a, forTemplate, lexerFlags) {
if (((a === 0x38) || (a === 0x39))) {
if (!lastReportableLexerError) lastReportableLexerError = 'The grammar does not allow to escape the 8 or the 9 character';
return true;
}
if (pointer >= len) return false;
let b = cache;
if (((((webCompat === false) || forTemplate)) || ((lexerFlags & 8192) === 8192))) {
if (((a === 0x30) && (((b < 0x30) || (b > 0x39))))) {
lastCanonizedInput += '\0';
++lastCanonizedInputLen;
return false;
}
if (forTemplate) {
if (!lastReportableLexerError) lastReportableLexerError = 'Illegal legacy octal escape in template, where octal escapes are never allowed';
} else if ((lexerFlags & 8192) === 8192) {
if (!lastReportableLexerError) lastReportableLexerError = 'Illegal legacy octal escape in strict mode';
} else {
if (!lastReportableLexerError) lastReportableLexerError = 'Octal escapes are only allowed in sloppy mode with web compat enabled';
}
return true;
}
if (((a === 0x30) && (((b < 0x30) || (b > 0x37))))) {
lastCanonizedInput += '\0';
++lastCanonizedInputLen;
return false;
}
if (((b < 0x30) || (b > 0x37))) {
lastCanonizedInput += String.fromCharCode(parseInt(String.fromCharCode(a), 8));
++lastCanonizedInputLen;
return false;
}
skip();
if (pointer >= len) return false;
if (a > 0x33) {
lastCanonizedInput += String.fromCharCode(parseInt(String.fromCharCode(a, b), 8));
++lastCanonizedInputLen;
return false;
}
let c = cache;
if (((c < 0x30) || (c > 0x37))) {
lastCanonizedInput += String.fromCharCode(parseInt(String.fromCharCode(a, b), 8));
++lastCanonizedInputLen;
return false;
}
skip();
lastCanonizedInput += String.fromCharCode(parseInt(String.fromCharCode(a, b, c), 8));
++lastCanonizedInputLen;
return false;
}
function parseDash() {
if (((((((((parsingGoal === false) && (webCompat === true))) && (!eofd(1)))) && (cache === 0x2d))) && (peekd(1) === 0x3e))) {
if (consumedNewlinesBeforeSolid === true) {
return parseCommentHtmlClose();
} else {
}
}
return parseSameOrCompound(0x2d);
}
function parseSameOrCompound(c) {
if (pointer < len) {
let d = cache;
if (d === c) {
skip();
switch (c) {
case 0x2b:
return 16479;
case 0x2d:
return 16483;
case 0x26:
if ((pointer < len && (cache === 0x3d))) {
skip();
if (supportLogicCompound) return 49238;
return THROW('The logical compound operator (`&&=`) is only supported since ES2021, currently targeting a lower version', pointer - 3, pointer);
}
return 82005;
case 0x7c:
if ((pointer < len && (cache === 0x3d))) {
skip();
if (supportLogicCompound) return 49238;
return THROW('The logical compound operator (`||=`) is only supported since ES2021, currently targeting a lower version', pointer - 3, pointer);
}
return 82053;
;
}
}
if (d === 0x3d) {
skip();
switch (c) {
case 0x2b:
return 49248;
case 0x2d:
return 49252;
case 0x26:
return 49239;
case 0x7c:
return 49287;
;
}
}
}
switch (c) {
case 0x2b:
return 82014;
case 0x2d:
return 82018;
case 0x26:
return 82004;
case 0x7c:
return 82052;
;
}
}
function parseTemplateString(lexerFlags, fromTick) {
lastOffset = pointer;
let badEscapes = false;
while (pointer < len) {
let c = cache;
while (c === 0x24) {
skip();
if (pointer >= len) {
if (!lastReportableLexerError) lastReportableLexerError = 'Unclosed template string';
lastCanonizedInput += slice(lastOffset, pointer);
lastCanonizedInputLen += pointer - lastOffset;
return 2097175;
}
c = cache;
if (c === 0x7b) {
lastCanonizedInput += slice(lastOffset, pointer - 1);
lastCanonizedInputLen += (pointer - 1) - lastOffset;
skip();
return (badEscapes? ((fromTick? 1572881 : 1572882)) : ((fromTick? 524305 : 524306)));
}
}
if (c === 0x60) {
lastCanonizedInput += slice(lastOffset, pointer);
lastCanonizedInputLen += pointer - lastOffset;
skip();
return (badEscapes? ((fromTick? 1572884 : 1572883)) : ((fromTick? 524308 : 524307)));
}
if (c === 0x0D) {
skip();
if ((pointer < len && (cache === 0x0A))) {
skip();
}
incrementLine();
} else if (isLfPsLs(c)) {
skip();
incrementLine();
} else if (c === 0x5c) {
lastCanonizedInput += slice(lastOffset, pointer);
lastCanonizedInputLen += pointer - lastOffset;
badEscapes = ((parseStringOrTemplateEscape(lexerFlags, true) === true) || badEscapes);
lastOffset = pointer;
} else {
skip();
}
}
lastCanonizedInput += slice(lastOffset, pointer);
lastCanonizedInputLen += pointer - lastOffset;
if (!lastReportableLexerError) lastReportableLexerError = 'Unclosed template literal';
return 2097175;
}
function verifyCharAfterNumber() {
if (pointer >= len) return;
let c = cache;
if (((isIdentStart(c, 0) !== (-1)) || (((c >= 0x30) && (c <= 0x39))))) {
return THROW(('Found `' + String.fromCharCode(c)) + '`. It is not legal for an ident or number token to start after a number token without some form of separation', pointer, pointer);
}
}
function parseLeadingZero(lexerFlags) {
let r = _parseLeadingZero(lexerFlags);
if (r !== 2097175) verifyCharAfterNumber();
return r;
}
function _parseLeadingZero(lexerFlags) {
if (pointer >= len) return 4105;
let c = cache;
if (isAsciiNumber(c)) {
skip();
if (pointer < len) skipDigits();
if ((lexerFlags & 8192) === 8192) {
if (!lastReportableLexerError) lastReportableLexerError = '"Illegal" octal escape in strict mode';
return 2097175;
}
if (pointer < len) {
let e = cache;
if (((e === 0x45) || (e === 0x65))) {
if (!lastReportableLexerError) lastReportableLexerError = 'An exponent is not allowed after a legacy octal number and an ident after number must be separated by some whitespace so this is an error';
return 2097175;
}
if (e === 0x6E) {
if (!supportBigInt) {
return THROW('BigInt suffix is not supported on legacy octals; use the `0o` prefix notation for that', startForError, pointer + 1);
}
}
}
return 4108;
}
if (c === 0x2e) {
parseFromFractionDot();
return 4105;
}
if (((c === 0x78) || (c === 0x58))) {
skip();
return parseHex();
}
if (((c === 0x6F) || (c === 0x4F))) {
skip();
return parseOctal();
}
if (((c === 0x62) || (c === 0x42))) {
skip();
return parseBinary();
}
if (((c === 0x65) || (c === 0x45))) {
parseExponentMaybe(c);
return 4105;
}
if (c === 0x6E) {
if (!supportBigInt) {
return THROW(('The BigInt syntax is supported in ES11+ / ES2020 (currently parsing ES' + targetEsVersion) + ')', startForError, pointer + 1);
}
skip();
return 12297;
}
return 4105;
}
function parseDecimal() {
if (pointer >= len) {
return 4105;
}
let c = skipDigitsWithSeparators(true);
if (pointer >= len) {
return 4105;
}
if (c === 0x2e) {
parseFromFractionDot();
verifyCharAfterNumber();
return 4105;
}
if (c === 0x6E) {
if (!supportBigInt) {
return THROW(('The BigInt syntax is supported in ES11+ / ES2020 (currently parsing ES' + targetEsVersion) + ')', startForError, pointer);
}
skip();
verifyCharAfterNumber();
return 12297;
}
parseExponentMaybe(c);
verifyCharAfterNumber();
return 4105;
}
function skipDigitsWithSeparators(canStartWithSeparator) {
let c = cache;
if (canStartWithSeparator) {
while (c === 0x5f) {
skip();
if (pointer >= len) return THROW('A numeric separator must be preceded and followed by a digit, EOF is not valid', startForError, pointer);
c = cache;
if (!isAsciiNumber(c)) {
return THROW('A numeric separator must be preceded and followed by a digit, found a different character', startForError, pointer);
}
skip();
if (pointer >= len) {
return 0;
}
c = cache;
}
}
while (isAsciiNumber(c)) {
skip();
if (pointer >= len) {
return 0;
}
c = cache;
if (c === 0x5f) {
skip();
if (pointer >= len) return THROW('A numeric separator must be preceded and followed by a digit, EOF is not valid', startForError, pointer);
c = cache;
if (!isAsciiNumber(c)) {
return THROW('A numeric separator must be preceded and followed by a digit, found a different character', startForError, pointer);
}
skip();
if (pointer >= len) {
return 0;
}
c = cache;
}
}
return c;
}
function skipDigits() {
let c = cache;
while (isAsciiNumber(c)) {
skip();
if (pointer >= len) return 0;
c = cache;
}
return c;
}
function parseExponentMaybe(c) {
if (((c !== 0x65) && (c !== 0x45))) return;
if (eofd(1)) return;
let d = peekd(1);
if (((d === 0x2d) || (d === 0x2b))) {
if (eofd(2)) return;
let e = peekd(2);
if (!isAsciiNumber(e)) return;
skipFastWithoutUpdatingCache();
skipFastWithoutUpdatingCache();
skip();
if (pointer >= len) return;
skipDigitsWithSeparators(true);
return;
}
if (!isAsciiNumber(d)) return;
skipFastWithoutUpdatingCache();
skip();
if (pointer >= len) return;
skipDigitsWithSeparators(true);
}
function parseFromFractionDot() {
skip();
if (pointer >= len) return;
let c = skipDigitsWithSeparators(false);
parseExponentMaybe(c);
}
function parseHex() {
if (pointer >= len) {
if (!lastReportableLexerError) lastReportableLexerError = '`0x` is illegal without a digit';
return 2097175;
}
let c = cache;
const cv = getHexValue(c);
if (cv === 16) {
if (!lastReportableLexerError) lastReportableLexerError = '`0x` is illegal without a digit';
return 2097175;
}
skip();
do {
if (pointer >= len) return 4104;
c = cache;
if (c === 0x5f) {
skip();
if (pointer >= len) {
return THROW('A numeric separator must be preceded and followed by a digit, EOF is not valid', startForError, pointer);
}
c = cache;
const cv = getHexValue(c);
if (cv === 16) {
return THROW('A numeric separator must be preceded and followed by a digit, found a different character', startForError, pointer);
}
} else {
const cv = getHexValue(c);
if (cv === 16) {
break;
}
}
skip();
} while (true);
if (c === 0x6E) {
if (!supportBigInt) {
return THROW(('The BigInt syntax is supported in ES11+ / ES2020 (currently parsing ES' + targetEsVersion) + ')', startForError, pointer + 1);
}
skip();
return 12296;
}
return 4104;
}
function parseOctal() {
if (pointer >= len) {
if (!lastReportableLexerError) lastReportableLexerError = '`0o` is illegal without a digit';
return 2097175;
}
let c = cache;
if (!isOctal(c)) {
if (!lastReportableLexerError) lastReportableLexerError = '`0o` is illegal without a digit';
return 2097175;
}
skip();
do {
if (pointer >= len) return 4107;
c = cache;
if (c === 0x5f) {
skip();
if (pointer >= len) {
return THROW('A numeric separator must be preceded and followed by a digit, EOF is not valid', startForError, pointer);
}
c = cache;
if (!isOctal(c)) {
return THROW('A numeric separator must be preceded and followed by a digit, found a different character', startForError, pointer);
}
} else {
if (!isOctal(c)) break;
}
skip();
} while (true);
if (c === 0x6E) {
if (!supportBigInt) {
return THROW(('The BigInt syntax is supported in ES11+ / ES2020 (currently parsing ES' + targetEsVersion) + ')', startForError, pointer + 1);
}
skip();
return 12299;
}
return 4107;
}
function parseBinary() {
if (pointer >= len) {
if (!lastReportableLexerError) lastReportableLexerError = '`0b` is illegal without a digit';
return 2097175;
}
let c = cache;
if (!isBinary(c)) {
if (!lastReportableLexerError) lastReportableLexerError = '`0b` is illegal without a digit';
return 2097175;
}
skip();
do {
if (pointer >= len) return 4106;
c = cache;
if (c === 0x5f) {
skip();
if (pointer >= len) {
return THROW('A numeric separator must be preceded and followed by a digit, EOF is not valid', startForError, pointer);
}
c = cache;
if (!isBinary(c)) {
return THROW('A numeric separator must be preceded and followed by a digit, found a different character', startForError, pointer);
}
} else {
if (!isBinary(c)) break;
}
skip();
} while (true);
if (c === 0x6E) {
if (!supportBigInt) {
return THROW(('The BigInt syntax is supported in ES11+ / ES2020 (currently parsing ES' + targetEsVersion) + ')', startForError, pointer + 1);
}
skip();
return 12297;
}
return 4106;
}
function isBinary(ord) {
return ((ord === 0x30) || (ord === 0x31));
}
function parseExcl() {
if (pointer >= len) return 16463;
if ((cache === 0x3d)) {
skip();
if ((pointer < len && (cache === 0x3d))) {
skip();
return 82001;
}
return 82000;
}
return 16463;
}
function parseStar() {
if (pointer < len) {
let c = cache;
if (c === 0x2a) {
skip();
if ((pointer < len && (cache === 0x3d))) {
skip();
return 49245;
}
return 82011;
} else if (c === 0x3d) {
skip();
return 49244;
}
}
return 82010;
}
function parseIdentRestNotKeywordObjTrie(d, n, start) {
pointer = n - 1;
cache = d;
return parseIdentifierRest(slice(start, n - 1), (n - 1) - start);
}
function parsePotentialKeywordTrieMap(c) {
let trieObjlit = KEYWORD_TRIE_OBJLIT[c - 0x61];
let start = pointer - 1;
let n = start + 1;
do {
if (n >= len) return eofAfterPotentialKeywordTrieMap(trieObjlit, n, start);
let d = input.charCodeAt(n++);
if (((d < 0x61) || (d > 0x7a))) {
return endOfPotentialKeywordTrieMap(trieObjlit, d, n, start);
}
trieObjlit = trieObjlit[d - 0x61];
if (trieObjlit === undefined) return parseIdentRestNotKeywordObjTrie(d, n, start);
} while (true);
}
function endOfPotentialKeywordTrieMap(trieObjlit, d, n, start) {
let hit = trieObjlit.hit;
if (d > 0x7e) {
pointer = n - 1;
cache = d;
let wide = isIdentRestChr(d, n - 1);
if (wide === (-1)) {
lastCanonizedInputLen = (n - 1) - start;
if (hit === undefined) {
lastCanonizedInput = slice(start, n - 1);
return 2048;
}
let canon = trieObjlit.canon;
lastCanonizedInput = canon;
return hit;
}
return parseIdentifierRest(slice(start, n - 1), (n - 1) - start);
}
let s = getTokenStart(d);
if (((((s === 2) || (s === 7))) || (s === 14))) {
pointer = n - 1;
cache = d;
return parseIdentifierRest(slice(start, n - 1), (n - 1) - start);
}
if (s === 24) {
pointer = n - 1;
cache = d;
return parseIdentifierRest(slice(start, n - 1), (n - 1) - start);
}
if (hit !== undefined) {
pointer = n - 1;
cache = d;
lastCanonizedInputLen = (n - 1) - start;
let canon = trieObjlit.canon;
lastCanonizedInput = canon;
return hit;
}
lastCanonizedInput = slice(start, n - 1);
lastCanonizedInputLen = (n - 1) - start;
pointer = n - 1;
cache = d;
return 2048;
}
function eofAfterPotentialKeywordTrieMap(trieObjlit, n, start) {
pointer = n - 1;
skip();
lastCanonizedInputLen = n - start;
let hit = trieObjlit.hit;
if (hit !== undefined) {
let canon = trieObjlit.canon;
lastCanonizedInput = canon;
return hit;
}
lastCanonizedInput = slice(start, n);
return 2048;
}
function parseIdentifierRest(prevStr, prevLen) {
let start = pointer;
while (pointer < len) {
let c = cache;
let s = getIdentPart(c);
switch (s) {
case 0:
skip();
break;
case 1:
lastCanonizedInput = prevStr + slice(start, pointer);
lastCanonizedInputLen = prevLen + (pointer - start);
return 2048;
case 2:
let x = prevStr + slice(start, pointer);
let xlen = prevLen + (pointer - start);
skip();
return parseIdentFromUnicodeEscape(false, x, xlen);
case 3:
let wide = isIdentRestChrUnicode(c, pointer);
if (wide === (-1)) {
lastCanonizedInput = prevStr + slice(start, pointer);
lastCanonizedInputLen = prevLen + (pointer - start);
return 2048;
}
if (wide === (-3)) {
skipFastWithoutUpdatingCache();
}
skip();
break;
;
}
}
lastCanonizedInput = prevStr + slice(start, pointer);
lastCanonizedInputLen = prevLen + (pointer - start);
return 2048;
}
function parseIdentFromUnicodeEscape(fromStart, prevStr, prevLen) {
if (pointer >= len) {
lastCanonizedInput = prevStr;
lastCanonizedInputLen = prevLen;
if (!lastReportableLexerError) lastReportableLexerError = 'Encountered a backslash at end of input';
return 2097175;
}
if (!(cache === 0x75)) {
return THROW('Only unicode escapes are supported in identifier escapes', startForError, pointer + 1);
}
skip();
if (pointer >= len) {
if (!lastReportableLexerError) lastReportableLexerError = 'Reached end of input before closing the current ident escape';
return 2097175;
}
let r = parseUnicodeEscapeForNonRegex();
if (r === 0x110000) {
parseIdentifierRest(prevStr, prevLen);
lastCanonizedInput = prevStr;
lastCanonizedInputLen = prevLen;
if (!lastReportableLexerError) lastReportableLexerError = 'Only _unicode_ escapes are supported in identifiers';
return 2097175;
}
if (r > 0xffff) {
prevStr += String.fromCodePoint(r);
prevLen += 2;
} else {
prevStr += String.fromCharCode(r);
++prevLen;
}
if (((fromStart === true) && (isIdentStart(r, -1) !== (-1)))) {
return parseIdentifierRest(prevStr, prevLen);
}
if (((fromStart === false) && (isIdentRestChr(r, -1) !== (-1)))) {
return parseIdentifierRest(prevStr, prevLen);
}
lastCanonizedInput = prevStr;
lastCanonizedInputLen = prevLen;
if (!lastReportableLexerError) lastReportableLexerError = 'Identifier escape did not yield a valid identifier character';
return 2097175;
}
function toStringExpensive(c) {
return String.fromCodePoint(c);
}
function isIdentStart(c, offsetOfC) {
if (c > 0x7e) {
return veryExpensiveUnicodeCheck(c, offsetOfC, getIdStartRegexSuperSlow());
}
let s = getTokenStart(c);
if (((s === 2) || (s === 3))) return -2;
return -1;
}
function isIdentRestChr(c, offsetOfC) {
if (c > 0x7e) {
return isIdentRestChrUnicode(c, offsetOfC);
}
let s = getTokenStart(c);
if (((s === 2) || (s === 3))) return -2;
if (s === 7) return -2;
if (s === 14) return -2;
return -1;
}
function isIdentRestChrUnicode(c, offsetOfC) {
if (((c === 0x200C) || (c === 0x200D))) return -2;
return veryExpensiveUnicodeCheck(c, offsetOfC, getIdRestRegexSuperSlow());
}
function veryExpensiveUnicodeCheck(c, offset, regexScanner) {
if (offset !== (-1)) {
c = input.codePointAt(offset);
}
let s = String.fromCodePoint(c);
if (regexScanner.test(s)) {
return ((s.length === 1)? (-2) : (-3));
}
return -1;
}
function isAsciiLetter(c) {
let d = c | 32;
return ((d >= 0x61) && (d <= 0x7a));
}
function isAsciiNumber(c) {
return ((c >= 0x30) && (c <= 0x39));
}
function parseCompoundAssignment(c) {
if ((pointer < len && (cache === 0x3d))) {
skip();
if (c === 0x5e) return 49282;
return 49235;
}
if (c === 0x5e) return 82049;
return 82002;
}
function parseFwdSlash(lexerFlags) {
if (pointer >= len) return 82024;
let c = cache;
if (c === 0x2f) {
skip();
return parseCommentSingle();
}
if (c === 0x2a) {
return parseCommentMulti();
}
if ((lexerFlags & 4) === 4) {
return parseRegex(c);
}
if (c === 0x3d) {
skip();
return 49257;
}
return 82024;
}
function parseCommentSingle() {
while (pointer < len) {
let c = cache;
if (((c === 0x0D) || isLfPsLs(c))) {
return 1285;
}
skip();
}
return 1285;
}
function parseCommentMulti() {
skip();
let c = 0;
while (pointer < len) {
c = cache;
skip();
while (c === 0x2a) {
if (pointer >= len) break;
c = cache;
skip();
if (c === 0x2f) {
return 1286;
}
}
if (c =