source: trip-planner-front/node_modules/acorn/dist/acorn.js@ e29cc2e

Last change on this file since e29cc2e was e29cc2e, checked in by Ema <ema_spirova@…>, 3 years ago

primeNG components

  • Property mode set to 100644
File size: 211.2 KB
Line 
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3 typeof define === 'function' && define.amd ? define(['exports'], factory) :
4 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.acorn = {}));
5})(this, (function (exports) { 'use strict';
6
7 // Reserved word lists for various dialects of the language
8
9 var reservedWords = {
10 3: "abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",
11 5: "class enum extends super const export import",
12 6: "enum",
13 strict: "implements interface let package private protected public static yield",
14 strictBind: "eval arguments"
15 };
16
17 // And the keywords
18
19 var ecma5AndLessKeywords = "break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this";
20
21 var keywords$1 = {
22 5: ecma5AndLessKeywords,
23 "5module": ecma5AndLessKeywords + " export import",
24 6: ecma5AndLessKeywords + " const class extends export import super"
25 };
26
27 var keywordRelationalOperator = /^in(stanceof)?$/;
28
29 // ## Character categories
30
31 // Big ugly regular expressions that match characters in the
32 // whitespace, identifier, and identifier-start categories. These
33 // are only applied when a character is found to actually have a
34 // code point above 128.
35 // Generated by `bin/generate-identifier-regex.js`.
36 var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u08a0-\u08b4\u08b6-\u08c7\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\u9ffc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7ca\ua7f5-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
37 var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf\u1ac0\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f";
38
39 var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
40 var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
41
42 nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
43
44 // These are a run-length and offset encoded representation of the
45 // >0xffff code points that are a valid part of identifiers. The
46 // offset starts at 0x10000, and each pair of numbers represents an
47 // offset to the next range, and then a size of the range. They were
48 // generated by bin/generate-identifier-regex.js
49
50 // eslint-disable-next-line comma-spacing
51 var astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,349,41,7,1,79,28,11,0,9,21,107,20,28,22,13,52,76,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,230,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,35,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,190,0,80,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,689,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,43,8,8952,286,50,2,18,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,2357,44,11,6,17,0,370,43,1301,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42717,35,4148,12,221,3,5761,15,7472,3104,541,1507,4938];
52
53 // eslint-disable-next-line comma-spacing
54 var astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,370,1,154,10,176,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,161,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,19306,9,135,4,60,6,26,9,1014,0,2,54,8,3,82,0,12,1,19628,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,262,6,10,9,419,13,1495,6,110,6,6,9,4759,9,787719,239];
55
56 // This has a complexity linear to the value of the code. The
57 // assumption is that looking up astral identifier characters is
58 // rare.
59 function isInAstralSet(code, set) {
60 var pos = 0x10000;
61 for (var i = 0; i < set.length; i += 2) {
62 pos += set[i];
63 if (pos > code) { return false }
64 pos += set[i + 1];
65 if (pos >= code) { return true }
66 }
67 }
68
69 // Test whether a given character code starts an identifier.
70
71 function isIdentifierStart(code, astral) {
72 if (code < 65) { return code === 36 }
73 if (code < 91) { return true }
74 if (code < 97) { return code === 95 }
75 if (code < 123) { return true }
76 if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)) }
77 if (astral === false) { return false }
78 return isInAstralSet(code, astralIdentifierStartCodes)
79 }
80
81 // Test whether a given character is part of an identifier.
82
83 function isIdentifierChar(code, astral) {
84 if (code < 48) { return code === 36 }
85 if (code < 58) { return true }
86 if (code < 65) { return false }
87 if (code < 91) { return true }
88 if (code < 97) { return code === 95 }
89 if (code < 123) { return true }
90 if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)) }
91 if (astral === false) { return false }
92 return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes)
93 }
94
95 // ## Token types
96
97 // The assignment of fine-grained, information-carrying type objects
98 // allows the tokenizer to store the information it has about a
99 // token in a way that is very cheap for the parser to look up.
100
101 // All token type variables start with an underscore, to make them
102 // easy to recognize.
103
104 // The `beforeExpr` property is used to disambiguate between regular
105 // expressions and divisions. It is set on all token types that can
106 // be followed by an expression (thus, a slash after them would be a
107 // regular expression).
108 //
109 // The `startsExpr` property is used to check if the token ends a
110 // `yield` expression. It is set on all token types that either can
111 // directly start an expression (like a quotation mark) or can
112 // continue an expression (like the body of a string).
113 //
114 // `isLoop` marks a keyword as starting a loop, which is important
115 // to know when parsing a label, in order to allow or disallow
116 // continue jumps to that label.
117
118 var TokenType = function TokenType(label, conf) {
119 if ( conf === void 0 ) conf = {};
120
121 this.label = label;
122 this.keyword = conf.keyword;
123 this.beforeExpr = !!conf.beforeExpr;
124 this.startsExpr = !!conf.startsExpr;
125 this.isLoop = !!conf.isLoop;
126 this.isAssign = !!conf.isAssign;
127 this.prefix = !!conf.prefix;
128 this.postfix = !!conf.postfix;
129 this.binop = conf.binop || null;
130 this.updateContext = null;
131 };
132
133 function binop(name, prec) {
134 return new TokenType(name, {beforeExpr: true, binop: prec})
135 }
136 var beforeExpr = {beforeExpr: true}, startsExpr = {startsExpr: true};
137
138 // Map keyword names to token types.
139
140 var keywords = {};
141
142 // Succinct definitions of keyword token types
143 function kw(name, options) {
144 if ( options === void 0 ) options = {};
145
146 options.keyword = name;
147 return keywords[name] = new TokenType(name, options)
148 }
149
150 var types$1 = {
151 num: new TokenType("num", startsExpr),
152 regexp: new TokenType("regexp", startsExpr),
153 string: new TokenType("string", startsExpr),
154 name: new TokenType("name", startsExpr),
155 privateId: new TokenType("privateId", startsExpr),
156 eof: new TokenType("eof"),
157
158 // Punctuation token types.
159 bracketL: new TokenType("[", {beforeExpr: true, startsExpr: true}),
160 bracketR: new TokenType("]"),
161 braceL: new TokenType("{", {beforeExpr: true, startsExpr: true}),
162 braceR: new TokenType("}"),
163 parenL: new TokenType("(", {beforeExpr: true, startsExpr: true}),
164 parenR: new TokenType(")"),
165 comma: new TokenType(",", beforeExpr),
166 semi: new TokenType(";", beforeExpr),
167 colon: new TokenType(":", beforeExpr),
168 dot: new TokenType("."),
169 question: new TokenType("?", beforeExpr),
170 questionDot: new TokenType("?."),
171 arrow: new TokenType("=>", beforeExpr),
172 template: new TokenType("template"),
173 invalidTemplate: new TokenType("invalidTemplate"),
174 ellipsis: new TokenType("...", beforeExpr),
175 backQuote: new TokenType("`", startsExpr),
176 dollarBraceL: new TokenType("${", {beforeExpr: true, startsExpr: true}),
177
178 // Operators. These carry several kinds of properties to help the
179 // parser use them properly (the presence of these properties is
180 // what categorizes them as operators).
181 //
182 // `binop`, when present, specifies that this operator is a binary
183 // operator, and will refer to its precedence.
184 //
185 // `prefix` and `postfix` mark the operator as a prefix or postfix
186 // unary operator.
187 //
188 // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as
189 // binary operators with a very low precedence, that should result
190 // in AssignmentExpression nodes.
191
192 eq: new TokenType("=", {beforeExpr: true, isAssign: true}),
193 assign: new TokenType("_=", {beforeExpr: true, isAssign: true}),
194 incDec: new TokenType("++/--", {prefix: true, postfix: true, startsExpr: true}),
195 prefix: new TokenType("!/~", {beforeExpr: true, prefix: true, startsExpr: true}),
196 logicalOR: binop("||", 1),
197 logicalAND: binop("&&", 2),
198 bitwiseOR: binop("|", 3),
199 bitwiseXOR: binop("^", 4),
200 bitwiseAND: binop("&", 5),
201 equality: binop("==/!=/===/!==", 6),
202 relational: binop("</>/<=/>=", 7),
203 bitShift: binop("<</>>/>>>", 8),
204 plusMin: new TokenType("+/-", {beforeExpr: true, binop: 9, prefix: true, startsExpr: true}),
205 modulo: binop("%", 10),
206 star: binop("*", 10),
207 slash: binop("/", 10),
208 starstar: new TokenType("**", {beforeExpr: true}),
209 coalesce: binop("??", 1),
210
211 // Keyword token types.
212 _break: kw("break"),
213 _case: kw("case", beforeExpr),
214 _catch: kw("catch"),
215 _continue: kw("continue"),
216 _debugger: kw("debugger"),
217 _default: kw("default", beforeExpr),
218 _do: kw("do", {isLoop: true, beforeExpr: true}),
219 _else: kw("else", beforeExpr),
220 _finally: kw("finally"),
221 _for: kw("for", {isLoop: true}),
222 _function: kw("function", startsExpr),
223 _if: kw("if"),
224 _return: kw("return", beforeExpr),
225 _switch: kw("switch"),
226 _throw: kw("throw", beforeExpr),
227 _try: kw("try"),
228 _var: kw("var"),
229 _const: kw("const"),
230 _while: kw("while", {isLoop: true}),
231 _with: kw("with"),
232 _new: kw("new", {beforeExpr: true, startsExpr: true}),
233 _this: kw("this", startsExpr),
234 _super: kw("super", startsExpr),
235 _class: kw("class", startsExpr),
236 _extends: kw("extends", beforeExpr),
237 _export: kw("export"),
238 _import: kw("import", startsExpr),
239 _null: kw("null", startsExpr),
240 _true: kw("true", startsExpr),
241 _false: kw("false", startsExpr),
242 _in: kw("in", {beforeExpr: true, binop: 7}),
243 _instanceof: kw("instanceof", {beforeExpr: true, binop: 7}),
244 _typeof: kw("typeof", {beforeExpr: true, prefix: true, startsExpr: true}),
245 _void: kw("void", {beforeExpr: true, prefix: true, startsExpr: true}),
246 _delete: kw("delete", {beforeExpr: true, prefix: true, startsExpr: true})
247 };
248
249 // Matches a whole line break (where CRLF is considered a single
250 // line break). Used to count lines.
251
252 var lineBreak = /\r\n?|\n|\u2028|\u2029/;
253 var lineBreakG = new RegExp(lineBreak.source, "g");
254
255 function isNewLine(code) {
256 return code === 10 || code === 13 || code === 0x2028 || code === 0x2029
257 }
258
259 var nonASCIIwhitespace = /[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
260
261 var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
262
263 var ref = Object.prototype;
264 var hasOwnProperty = ref.hasOwnProperty;
265 var toString = ref.toString;
266
267 // Checks if an object has a property.
268
269 function has(obj, propName) {
270 return hasOwnProperty.call(obj, propName)
271 }
272
273 var isArray = Array.isArray || (function (obj) { return (
274 toString.call(obj) === "[object Array]"
275 ); });
276
277 function wordsRegexp(words) {
278 return new RegExp("^(?:" + words.replace(/ /g, "|") + ")$")
279 }
280
281 // These are used when `options.locations` is on, for the
282 // `startLoc` and `endLoc` properties.
283
284 var Position = function Position(line, col) {
285 this.line = line;
286 this.column = col;
287 };
288
289 Position.prototype.offset = function offset (n) {
290 return new Position(this.line, this.column + n)
291 };
292
293 var SourceLocation = function SourceLocation(p, start, end) {
294 this.start = start;
295 this.end = end;
296 if (p.sourceFile !== null) { this.source = p.sourceFile; }
297 };
298
299 // The `getLineInfo` function is mostly useful when the
300 // `locations` option is off (for performance reasons) and you
301 // want to find the line/column position for a given character
302 // offset. `input` should be the code string that the offset refers
303 // into.
304
305 function getLineInfo(input, offset) {
306 for (var line = 1, cur = 0;;) {
307 lineBreakG.lastIndex = cur;
308 var match = lineBreakG.exec(input);
309 if (match && match.index < offset) {
310 ++line;
311 cur = match.index + match[0].length;
312 } else {
313 return new Position(line, offset - cur)
314 }
315 }
316 }
317
318 // A second argument must be given to configure the parser process.
319 // These options are recognized (only `ecmaVersion` is required):
320
321 var defaultOptions = {
322 // `ecmaVersion` indicates the ECMAScript version to parse. Must be
323 // either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10
324 // (2019), 11 (2020), 12 (2021), 13 (2022), or `"latest"` (the
325 // latest version the library supports). This influences support
326 // for strict mode, the set of reserved words, and support for
327 // new syntax features.
328 ecmaVersion: null,
329 // `sourceType` indicates the mode the code should be parsed in.
330 // Can be either `"script"` or `"module"`. This influences global
331 // strict mode and parsing of `import` and `export` declarations.
332 sourceType: "script",
333 // `onInsertedSemicolon` can be a callback that will be called
334 // when a semicolon is automatically inserted. It will be passed
335 // the position of the comma as an offset, and if `locations` is
336 // enabled, it is given the location as a `{line, column}` object
337 // as second argument.
338 onInsertedSemicolon: null,
339 // `onTrailingComma` is similar to `onInsertedSemicolon`, but for
340 // trailing commas.
341 onTrailingComma: null,
342 // By default, reserved words are only enforced if ecmaVersion >= 5.
343 // Set `allowReserved` to a boolean value to explicitly turn this on
344 // an off. When this option has the value "never", reserved words
345 // and keywords can also not be used as property names.
346 allowReserved: null,
347 // When enabled, a return at the top level is not considered an
348 // error.
349 allowReturnOutsideFunction: false,
350 // When enabled, import/export statements are not constrained to
351 // appearing at the top of the program, and an import.meta expression
352 // in a script isn't considered an error.
353 allowImportExportEverywhere: false,
354 // By default, await identifiers are allowed to appear at the top-level scope only if ecmaVersion >= 2022.
355 // When enabled, await identifiers are allowed to appear at the top-level scope,
356 // but they are still not allowed in non-async functions.
357 allowAwaitOutsideFunction: null,
358 // When enabled, super identifiers are not constrained to
359 // appearing in methods and do not raise an error when they appear elsewhere.
360 allowSuperOutsideMethod: null,
361 // When enabled, hashbang directive in the beginning of file
362 // is allowed and treated as a line comment.
363 allowHashBang: false,
364 // When `locations` is on, `loc` properties holding objects with
365 // `start` and `end` properties in `{line, column}` form (with
366 // line being 1-based and column 0-based) will be attached to the
367 // nodes.
368 locations: false,
369 // A function can be passed as `onToken` option, which will
370 // cause Acorn to call that function with object in the same
371 // format as tokens returned from `tokenizer().getToken()`. Note
372 // that you are not allowed to call the parser from the
373 // callback—that will corrupt its internal state.
374 onToken: null,
375 // A function can be passed as `onComment` option, which will
376 // cause Acorn to call that function with `(block, text, start,
377 // end)` parameters whenever a comment is skipped. `block` is a
378 // boolean indicating whether this is a block (`/* */`) comment,
379 // `text` is the content of the comment, and `start` and `end` are
380 // character offsets that denote the start and end of the comment.
381 // When the `locations` option is on, two more parameters are
382 // passed, the full `{line, column}` locations of the start and
383 // end of the comments. Note that you are not allowed to call the
384 // parser from the callback—that will corrupt its internal state.
385 onComment: null,
386 // Nodes have their start and end characters offsets recorded in
387 // `start` and `end` properties (directly on the node, rather than
388 // the `loc` object, which holds line/column data. To also add a
389 // [semi-standardized][range] `range` property holding a `[start,
390 // end]` array with the same numbers, set the `ranges` option to
391 // `true`.
392 //
393 // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678
394 ranges: false,
395 // It is possible to parse multiple files into a single AST by
396 // passing the tree produced by parsing the first file as
397 // `program` option in subsequent parses. This will add the
398 // toplevel forms of the parsed file to the `Program` (top) node
399 // of an existing parse tree.
400 program: null,
401 // When `locations` is on, you can pass this to record the source
402 // file in every node's `loc` object.
403 sourceFile: null,
404 // This value, if given, is stored in every node, whether
405 // `locations` is on or off.
406 directSourceFile: null,
407 // When enabled, parenthesized expressions are represented by
408 // (non-standard) ParenthesizedExpression nodes
409 preserveParens: false
410 };
411
412 // Interpret and default an options object
413
414 var warnedAboutEcmaVersion = false;
415
416 function getOptions(opts) {
417 var options = {};
418
419 for (var opt in defaultOptions)
420 { options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt]; }
421
422 if (options.ecmaVersion === "latest") {
423 options.ecmaVersion = 1e8;
424 } else if (options.ecmaVersion == null) {
425 if (!warnedAboutEcmaVersion && typeof console === "object" && console.warn) {
426 warnedAboutEcmaVersion = true;
427 console.warn("Since Acorn 8.0.0, options.ecmaVersion is required.\nDefaulting to 2020, but this will stop working in the future.");
428 }
429 options.ecmaVersion = 11;
430 } else if (options.ecmaVersion >= 2015) {
431 options.ecmaVersion -= 2009;
432 }
433
434 if (options.allowReserved == null)
435 { options.allowReserved = options.ecmaVersion < 5; }
436
437 if (isArray(options.onToken)) {
438 var tokens = options.onToken;
439 options.onToken = function (token) { return tokens.push(token); };
440 }
441 if (isArray(options.onComment))
442 { options.onComment = pushComment(options, options.onComment); }
443
444 return options
445 }
446
447 function pushComment(options, array) {
448 return function(block, text, start, end, startLoc, endLoc) {
449 var comment = {
450 type: block ? "Block" : "Line",
451 value: text,
452 start: start,
453 end: end
454 };
455 if (options.locations)
456 { comment.loc = new SourceLocation(this, startLoc, endLoc); }
457 if (options.ranges)
458 { comment.range = [start, end]; }
459 array.push(comment);
460 }
461 }
462
463 // Each scope gets a bitset that may contain these flags
464 var
465 SCOPE_TOP = 1,
466 SCOPE_FUNCTION = 2,
467 SCOPE_ASYNC = 4,
468 SCOPE_GENERATOR = 8,
469 SCOPE_ARROW = 16,
470 SCOPE_SIMPLE_CATCH = 32,
471 SCOPE_SUPER = 64,
472 SCOPE_DIRECT_SUPER = 128,
473 SCOPE_CLASS_STATIC_BLOCK = 256,
474 SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK;
475
476 function functionFlags(async, generator) {
477 return SCOPE_FUNCTION | (async ? SCOPE_ASYNC : 0) | (generator ? SCOPE_GENERATOR : 0)
478 }
479
480 // Used in checkLVal* and declareName to determine the type of a binding
481 var
482 BIND_NONE = 0, // Not a binding
483 BIND_VAR = 1, // Var-style binding
484 BIND_LEXICAL = 2, // Let- or const-style binding
485 BIND_FUNCTION = 3, // Function declaration
486 BIND_SIMPLE_CATCH = 4, // Simple (identifier pattern) catch binding
487 BIND_OUTSIDE = 5; // Special case for function names as bound inside the function
488
489 var Parser = function Parser(options, input, startPos) {
490 this.options = options = getOptions(options);
491 this.sourceFile = options.sourceFile;
492 this.keywords = wordsRegexp(keywords$1[options.ecmaVersion >= 6 ? 6 : options.sourceType === "module" ? "5module" : 5]);
493 var reserved = "";
494 if (options.allowReserved !== true) {
495 reserved = reservedWords[options.ecmaVersion >= 6 ? 6 : options.ecmaVersion === 5 ? 5 : 3];
496 if (options.sourceType === "module") { reserved += " await"; }
497 }
498 this.reservedWords = wordsRegexp(reserved);
499 var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict;
500 this.reservedWordsStrict = wordsRegexp(reservedStrict);
501 this.reservedWordsStrictBind = wordsRegexp(reservedStrict + " " + reservedWords.strictBind);
502 this.input = String(input);
503
504 // Used to signal to callers of `readWord1` whether the word
505 // contained any escape sequences. This is needed because words with
506 // escape sequences must not be interpreted as keywords.
507 this.containsEsc = false;
508
509 // Set up token state
510
511 // The current position of the tokenizer in the input.
512 if (startPos) {
513 this.pos = startPos;
514 this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1;
515 this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;
516 } else {
517 this.pos = this.lineStart = 0;
518 this.curLine = 1;
519 }
520
521 // Properties of the current token:
522 // Its type
523 this.type = types$1.eof;
524 // For tokens that include more information than their type, the value
525 this.value = null;
526 // Its start and end offset
527 this.start = this.end = this.pos;
528 // And, if locations are used, the {line, column} object
529 // corresponding to those offsets
530 this.startLoc = this.endLoc = this.curPosition();
531
532 // Position information for the previous token
533 this.lastTokEndLoc = this.lastTokStartLoc = null;
534 this.lastTokStart = this.lastTokEnd = this.pos;
535
536 // The context stack is used to superficially track syntactic
537 // context to predict whether a regular expression is allowed in a
538 // given position.
539 this.context = this.initialContext();
540 this.exprAllowed = true;
541
542 // Figure out if it's a module code.
543 this.inModule = options.sourceType === "module";
544 this.strict = this.inModule || this.strictDirective(this.pos);
545
546 // Used to signify the start of a potential arrow function
547 this.potentialArrowAt = -1;
548 this.potentialArrowInForAwait = false;
549
550 // Positions to delayed-check that yield/await does not exist in default parameters.
551 this.yieldPos = this.awaitPos = this.awaitIdentPos = 0;
552 // Labels in scope.
553 this.labels = [];
554 // Thus-far undefined exports.
555 this.undefinedExports = Object.create(null);
556
557 // If enabled, skip leading hashbang line.
558 if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === "#!")
559 { this.skipLineComment(2); }
560
561 // Scope tracking for duplicate variable names (see scope.js)
562 this.scopeStack = [];
563 this.enterScope(SCOPE_TOP);
564
565 // For RegExp validation
566 this.regexpState = null;
567
568 // The stack of private names.
569 // Each element has two properties: 'declared' and 'used'.
570 // When it exited from the outermost class definition, all used private names must be declared.
571 this.privateNameStack = [];
572 };
573
574 var prototypeAccessors = { inFunction: { configurable: true },inGenerator: { configurable: true },inAsync: { configurable: true },canAwait: { configurable: true },allowSuper: { configurable: true },allowDirectSuper: { configurable: true },treatFunctionsAsVar: { configurable: true },allowNewDotTarget: { configurable: true },inClassStaticBlock: { configurable: true } };
575
576 Parser.prototype.parse = function parse () {
577 var node = this.options.program || this.startNode();
578 this.nextToken();
579 return this.parseTopLevel(node)
580 };
581
582 prototypeAccessors.inFunction.get = function () { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 };
583
584 prototypeAccessors.inGenerator.get = function () { return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 && !this.currentVarScope().inClassFieldInit };
585
586 prototypeAccessors.inAsync.get = function () { return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 && !this.currentVarScope().inClassFieldInit };
587
588 prototypeAccessors.canAwait.get = function () {
589 for (var i = this.scopeStack.length - 1; i >= 0; i--) {
590 var scope = this.scopeStack[i];
591 if (scope.inClassFieldInit || scope.flags & SCOPE_CLASS_STATIC_BLOCK) { return false }
592 if (scope.flags & SCOPE_FUNCTION) { return (scope.flags & SCOPE_ASYNC) > 0 }
593 }
594 return (this.inModule && this.options.ecmaVersion >= 13) || this.options.allowAwaitOutsideFunction
595 };
596
597 prototypeAccessors.allowSuper.get = function () {
598 var ref = this.currentThisScope();
599 var flags = ref.flags;
600 var inClassFieldInit = ref.inClassFieldInit;
601 return (flags & SCOPE_SUPER) > 0 || inClassFieldInit || this.options.allowSuperOutsideMethod
602 };
603
604 prototypeAccessors.allowDirectSuper.get = function () { return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0 };
605
606 prototypeAccessors.treatFunctionsAsVar.get = function () { return this.treatFunctionsAsVarInScope(this.currentScope()) };
607
608 prototypeAccessors.allowNewDotTarget.get = function () {
609 var ref = this.currentThisScope();
610 var flags = ref.flags;
611 var inClassFieldInit = ref.inClassFieldInit;
612 return (flags & (SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK)) > 0 || inClassFieldInit
613 };
614
615 prototypeAccessors.inClassStaticBlock.get = function () {
616 return (this.currentVarScope().flags & SCOPE_CLASS_STATIC_BLOCK) > 0
617 };
618
619 Parser.extend = function extend () {
620 var plugins = [], len = arguments.length;
621 while ( len-- ) plugins[ len ] = arguments[ len ];
622
623 var cls = this;
624 for (var i = 0; i < plugins.length; i++) { cls = plugins[i](cls); }
625 return cls
626 };
627
628 Parser.parse = function parse (input, options) {
629 return new this(options, input).parse()
630 };
631
632 Parser.parseExpressionAt = function parseExpressionAt (input, pos, options) {
633 var parser = new this(options, input, pos);
634 parser.nextToken();
635 return parser.parseExpression()
636 };
637
638 Parser.tokenizer = function tokenizer (input, options) {
639 return new this(options, input)
640 };
641
642 Object.defineProperties( Parser.prototype, prototypeAccessors );
643
644 var pp$9 = Parser.prototype;
645
646 // ## Parser utilities
647
648 var literal = /^(?:'((?:\\.|[^'\\])*?)'|"((?:\\.|[^"\\])*?)")/;
649 pp$9.strictDirective = function(start) {
650 for (;;) {
651 // Try to find string literal.
652 skipWhiteSpace.lastIndex = start;
653 start += skipWhiteSpace.exec(this.input)[0].length;
654 var match = literal.exec(this.input.slice(start));
655 if (!match) { return false }
656 if ((match[1] || match[2]) === "use strict") {
657 skipWhiteSpace.lastIndex = start + match[0].length;
658 var spaceAfter = skipWhiteSpace.exec(this.input), end = spaceAfter.index + spaceAfter[0].length;
659 var next = this.input.charAt(end);
660 return next === ";" || next === "}" ||
661 (lineBreak.test(spaceAfter[0]) &&
662 !(/[(`.[+\-/*%<>=,?^&]/.test(next) || next === "!" && this.input.charAt(end + 1) === "="))
663 }
664 start += match[0].length;
665
666 // Skip semicolon, if any.
667 skipWhiteSpace.lastIndex = start;
668 start += skipWhiteSpace.exec(this.input)[0].length;
669 if (this.input[start] === ";")
670 { start++; }
671 }
672 };
673
674 // Predicate that tests whether the next token is of the given
675 // type, and if yes, consumes it as a side effect.
676
677 pp$9.eat = function(type) {
678 if (this.type === type) {
679 this.next();
680 return true
681 } else {
682 return false
683 }
684 };
685
686 // Tests whether parsed token is a contextual keyword.
687
688 pp$9.isContextual = function(name) {
689 return this.type === types$1.name && this.value === name && !this.containsEsc
690 };
691
692 // Consumes contextual keyword if possible.
693
694 pp$9.eatContextual = function(name) {
695 if (!this.isContextual(name)) { return false }
696 this.next();
697 return true
698 };
699
700 // Asserts that following token is given contextual keyword.
701
702 pp$9.expectContextual = function(name) {
703 if (!this.eatContextual(name)) { this.unexpected(); }
704 };
705
706 // Test whether a semicolon can be inserted at the current position.
707
708 pp$9.canInsertSemicolon = function() {
709 return this.type === types$1.eof ||
710 this.type === types$1.braceR ||
711 lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
712 };
713
714 pp$9.insertSemicolon = function() {
715 if (this.canInsertSemicolon()) {
716 if (this.options.onInsertedSemicolon)
717 { this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc); }
718 return true
719 }
720 };
721
722 // Consume a semicolon, or, failing that, see if we are allowed to
723 // pretend that there is a semicolon at this position.
724
725 pp$9.semicolon = function() {
726 if (!this.eat(types$1.semi) && !this.insertSemicolon()) { this.unexpected(); }
727 };
728
729 pp$9.afterTrailingComma = function(tokType, notNext) {
730 if (this.type === tokType) {
731 if (this.options.onTrailingComma)
732 { this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc); }
733 if (!notNext)
734 { this.next(); }
735 return true
736 }
737 };
738
739 // Expect a token of a given type. If found, consume it, otherwise,
740 // raise an unexpected token error.
741
742 pp$9.expect = function(type) {
743 this.eat(type) || this.unexpected();
744 };
745
746 // Raise an unexpected token error.
747
748 pp$9.unexpected = function(pos) {
749 this.raise(pos != null ? pos : this.start, "Unexpected token");
750 };
751
752 function DestructuringErrors() {
753 this.shorthandAssign =
754 this.trailingComma =
755 this.parenthesizedAssign =
756 this.parenthesizedBind =
757 this.doubleProto =
758 -1;
759 }
760
761 pp$9.checkPatternErrors = function(refDestructuringErrors, isAssign) {
762 if (!refDestructuringErrors) { return }
763 if (refDestructuringErrors.trailingComma > -1)
764 { this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element"); }
765 var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind;
766 if (parens > -1) { this.raiseRecoverable(parens, "Parenthesized pattern"); }
767 };
768
769 pp$9.checkExpressionErrors = function(refDestructuringErrors, andThrow) {
770 if (!refDestructuringErrors) { return false }
771 var shorthandAssign = refDestructuringErrors.shorthandAssign;
772 var doubleProto = refDestructuringErrors.doubleProto;
773 if (!andThrow) { return shorthandAssign >= 0 || doubleProto >= 0 }
774 if (shorthandAssign >= 0)
775 { this.raise(shorthandAssign, "Shorthand property assignments are valid only in destructuring patterns"); }
776 if (doubleProto >= 0)
777 { this.raiseRecoverable(doubleProto, "Redefinition of __proto__ property"); }
778 };
779
780 pp$9.checkYieldAwaitInDefaultParams = function() {
781 if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos))
782 { this.raise(this.yieldPos, "Yield expression cannot be a default value"); }
783 if (this.awaitPos)
784 { this.raise(this.awaitPos, "Await expression cannot be a default value"); }
785 };
786
787 pp$9.isSimpleAssignTarget = function(expr) {
788 if (expr.type === "ParenthesizedExpression")
789 { return this.isSimpleAssignTarget(expr.expression) }
790 return expr.type === "Identifier" || expr.type === "MemberExpression"
791 };
792
793 var pp$8 = Parser.prototype;
794
795 // ### Statement parsing
796
797 // Parse a program. Initializes the parser, reads any number of
798 // statements, and wraps them in a Program node. Optionally takes a
799 // `program` argument. If present, the statements will be appended
800 // to its body instead of creating a new node.
801
802 pp$8.parseTopLevel = function(node) {
803 var exports = Object.create(null);
804 if (!node.body) { node.body = []; }
805 while (this.type !== types$1.eof) {
806 var stmt = this.parseStatement(null, true, exports);
807 node.body.push(stmt);
808 }
809 if (this.inModule)
810 { for (var i = 0, list = Object.keys(this.undefinedExports); i < list.length; i += 1)
811 {
812 var name = list[i];
813
814 this.raiseRecoverable(this.undefinedExports[name].start, ("Export '" + name + "' is not defined"));
815 } }
816 this.adaptDirectivePrologue(node.body);
817 this.next();
818 node.sourceType = this.options.sourceType;
819 return this.finishNode(node, "Program")
820 };
821
822 var loopLabel = {kind: "loop"}, switchLabel = {kind: "switch"};
823
824 pp$8.isLet = function(context) {
825 if (this.options.ecmaVersion < 6 || !this.isContextual("let")) { return false }
826 skipWhiteSpace.lastIndex = this.pos;
827 var skip = skipWhiteSpace.exec(this.input);
828 var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
829 // For ambiguous cases, determine if a LexicalDeclaration (or only a
830 // Statement) is allowed here. If context is not empty then only a Statement
831 // is allowed. However, `let [` is an explicit negative lookahead for
832 // ExpressionStatement, so special-case it first.
833 if (nextCh === 91 || nextCh === 92 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true } // '[', '/', astral
834 if (context) { return false }
835
836 if (nextCh === 123) { return true } // '{'
837 if (isIdentifierStart(nextCh, true)) {
838 var pos = next + 1;
839 while (isIdentifierChar(nextCh = this.input.charCodeAt(pos), true)) { ++pos; }
840 if (nextCh === 92 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true }
841 var ident = this.input.slice(next, pos);
842 if (!keywordRelationalOperator.test(ident)) { return true }
843 }
844 return false
845 };
846
847 // check 'async [no LineTerminator here] function'
848 // - 'async /*foo*/ function' is OK.
849 // - 'async /*\n*/ function' is invalid.
850 pp$8.isAsyncFunction = function() {
851 if (this.options.ecmaVersion < 8 || !this.isContextual("async"))
852 { return false }
853
854 skipWhiteSpace.lastIndex = this.pos;
855 var skip = skipWhiteSpace.exec(this.input);
856 var next = this.pos + skip[0].length, after;
857 return !lineBreak.test(this.input.slice(this.pos, next)) &&
858 this.input.slice(next, next + 8) === "function" &&
859 (next + 8 === this.input.length ||
860 !(isIdentifierChar(after = this.input.charCodeAt(next + 8)) || after > 0xd7ff && after < 0xdc00))
861 };
862
863 // Parse a single statement.
864 //
865 // If expecting a statement and finding a slash operator, parse a
866 // regular expression literal. This is to handle cases like
867 // `if (foo) /blah/.exec(foo)`, where looking at the previous token
868 // does not help.
869
870 pp$8.parseStatement = function(context, topLevel, exports) {
871 var starttype = this.type, node = this.startNode(), kind;
872
873 if (this.isLet(context)) {
874 starttype = types$1._var;
875 kind = "let";
876 }
877
878 // Most types of statements are recognized by the keyword they
879 // start with. Many are trivial to parse, some require a bit of
880 // complexity.
881
882 switch (starttype) {
883 case types$1._break: case types$1._continue: return this.parseBreakContinueStatement(node, starttype.keyword)
884 case types$1._debugger: return this.parseDebuggerStatement(node)
885 case types$1._do: return this.parseDoStatement(node)
886 case types$1._for: return this.parseForStatement(node)
887 case types$1._function:
888 // Function as sole body of either an if statement or a labeled statement
889 // works, but not when it is part of a labeled statement that is the sole
890 // body of an if statement.
891 if ((context && (this.strict || context !== "if" && context !== "label")) && this.options.ecmaVersion >= 6) { this.unexpected(); }
892 return this.parseFunctionStatement(node, false, !context)
893 case types$1._class:
894 if (context) { this.unexpected(); }
895 return this.parseClass(node, true)
896 case types$1._if: return this.parseIfStatement(node)
897 case types$1._return: return this.parseReturnStatement(node)
898 case types$1._switch: return this.parseSwitchStatement(node)
899 case types$1._throw: return this.parseThrowStatement(node)
900 case types$1._try: return this.parseTryStatement(node)
901 case types$1._const: case types$1._var:
902 kind = kind || this.value;
903 if (context && kind !== "var") { this.unexpected(); }
904 return this.parseVarStatement(node, kind)
905 case types$1._while: return this.parseWhileStatement(node)
906 case types$1._with: return this.parseWithStatement(node)
907 case types$1.braceL: return this.parseBlock(true, node)
908 case types$1.semi: return this.parseEmptyStatement(node)
909 case types$1._export:
910 case types$1._import:
911 if (this.options.ecmaVersion > 10 && starttype === types$1._import) {
912 skipWhiteSpace.lastIndex = this.pos;
913 var skip = skipWhiteSpace.exec(this.input);
914 var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
915 if (nextCh === 40 || nextCh === 46) // '(' or '.'
916 { return this.parseExpressionStatement(node, this.parseExpression()) }
917 }
918
919 if (!this.options.allowImportExportEverywhere) {
920 if (!topLevel)
921 { this.raise(this.start, "'import' and 'export' may only appear at the top level"); }
922 if (!this.inModule)
923 { this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'"); }
924 }
925 return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports)
926
927 // If the statement does not start with a statement keyword or a
928 // brace, it's an ExpressionStatement or LabeledStatement. We
929 // simply start parsing an expression, and afterwards, if the
930 // next token is a colon and the expression was a simple
931 // Identifier node, we switch to interpreting it as a label.
932 default:
933 if (this.isAsyncFunction()) {
934 if (context) { this.unexpected(); }
935 this.next();
936 return this.parseFunctionStatement(node, true, !context)
937 }
938
939 var maybeName = this.value, expr = this.parseExpression();
940 if (starttype === types$1.name && expr.type === "Identifier" && this.eat(types$1.colon))
941 { return this.parseLabeledStatement(node, maybeName, expr, context) }
942 else { return this.parseExpressionStatement(node, expr) }
943 }
944 };
945
946 pp$8.parseBreakContinueStatement = function(node, keyword) {
947 var isBreak = keyword === "break";
948 this.next();
949 if (this.eat(types$1.semi) || this.insertSemicolon()) { node.label = null; }
950 else if (this.type !== types$1.name) { this.unexpected(); }
951 else {
952 node.label = this.parseIdent();
953 this.semicolon();
954 }
955
956 // Verify that there is an actual destination to break or
957 // continue to.
958 var i = 0;
959 for (; i < this.labels.length; ++i) {
960 var lab = this.labels[i];
961 if (node.label == null || lab.name === node.label.name) {
962 if (lab.kind != null && (isBreak || lab.kind === "loop")) { break }
963 if (node.label && isBreak) { break }
964 }
965 }
966 if (i === this.labels.length) { this.raise(node.start, "Unsyntactic " + keyword); }
967 return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement")
968 };
969
970 pp$8.parseDebuggerStatement = function(node) {
971 this.next();
972 this.semicolon();
973 return this.finishNode(node, "DebuggerStatement")
974 };
975
976 pp$8.parseDoStatement = function(node) {
977 this.next();
978 this.labels.push(loopLabel);
979 node.body = this.parseStatement("do");
980 this.labels.pop();
981 this.expect(types$1._while);
982 node.test = this.parseParenExpression();
983 if (this.options.ecmaVersion >= 6)
984 { this.eat(types$1.semi); }
985 else
986 { this.semicolon(); }
987 return this.finishNode(node, "DoWhileStatement")
988 };
989
990 // Disambiguating between a `for` and a `for`/`in` or `for`/`of`
991 // loop is non-trivial. Basically, we have to parse the init `var`
992 // statement or expression, disallowing the `in` operator (see
993 // the second parameter to `parseExpression`), and then check
994 // whether the next token is `in` or `of`. When there is no init
995 // part (semicolon immediately after the opening parenthesis), it
996 // is a regular `for` loop.
997
998 pp$8.parseForStatement = function(node) {
999 this.next();
1000 var awaitAt = (this.options.ecmaVersion >= 9 && this.canAwait && this.eatContextual("await")) ? this.lastTokStart : -1;
1001 this.labels.push(loopLabel);
1002 this.enterScope(0);
1003 this.expect(types$1.parenL);
1004 if (this.type === types$1.semi) {
1005 if (awaitAt > -1) { this.unexpected(awaitAt); }
1006 return this.parseFor(node, null)
1007 }
1008 var isLet = this.isLet();
1009 if (this.type === types$1._var || this.type === types$1._const || isLet) {
1010 var init$1 = this.startNode(), kind = isLet ? "let" : this.value;
1011 this.next();
1012 this.parseVar(init$1, true, kind);
1013 this.finishNode(init$1, "VariableDeclaration");
1014 if ((this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1) {
1015 if (this.options.ecmaVersion >= 9) {
1016 if (this.type === types$1._in) {
1017 if (awaitAt > -1) { this.unexpected(awaitAt); }
1018 } else { node.await = awaitAt > -1; }
1019 }
1020 return this.parseForIn(node, init$1)
1021 }
1022 if (awaitAt > -1) { this.unexpected(awaitAt); }
1023 return this.parseFor(node, init$1)
1024 }
1025 var startsWithLet = this.isContextual("let"), isForOf = false;
1026 var refDestructuringErrors = new DestructuringErrors;
1027 var init = this.parseExpression(awaitAt > -1 ? "await" : true, refDestructuringErrors);
1028 if (this.type === types$1._in || (isForOf = this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
1029 if (this.options.ecmaVersion >= 9) {
1030 if (this.type === types$1._in) {
1031 if (awaitAt > -1) { this.unexpected(awaitAt); }
1032 } else { node.await = awaitAt > -1; }
1033 }
1034 if (startsWithLet && isForOf) { this.raise(init.start, "The left-hand side of a for-of loop may not start with 'let'."); }
1035 this.toAssignable(init, false, refDestructuringErrors);
1036 this.checkLValPattern(init);
1037 return this.parseForIn(node, init)
1038 } else {
1039 this.checkExpressionErrors(refDestructuringErrors, true);
1040 }
1041 if (awaitAt > -1) { this.unexpected(awaitAt); }
1042 return this.parseFor(node, init)
1043 };
1044
1045 pp$8.parseFunctionStatement = function(node, isAsync, declarationPosition) {
1046 this.next();
1047 return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync)
1048 };
1049
1050 pp$8.parseIfStatement = function(node) {
1051 this.next();
1052 node.test = this.parseParenExpression();
1053 // allow function declarations in branches, but only in non-strict mode
1054 node.consequent = this.parseStatement("if");
1055 node.alternate = this.eat(types$1._else) ? this.parseStatement("if") : null;
1056 return this.finishNode(node, "IfStatement")
1057 };
1058
1059 pp$8.parseReturnStatement = function(node) {
1060 if (!this.inFunction && !this.options.allowReturnOutsideFunction)
1061 { this.raise(this.start, "'return' outside of function"); }
1062 this.next();
1063
1064 // In `return` (and `break`/`continue`), the keywords with
1065 // optional arguments, we eagerly look for a semicolon or the
1066 // possibility to insert one.
1067
1068 if (this.eat(types$1.semi) || this.insertSemicolon()) { node.argument = null; }
1069 else { node.argument = this.parseExpression(); this.semicolon(); }
1070 return this.finishNode(node, "ReturnStatement")
1071 };
1072
1073 pp$8.parseSwitchStatement = function(node) {
1074 this.next();
1075 node.discriminant = this.parseParenExpression();
1076 node.cases = [];
1077 this.expect(types$1.braceL);
1078 this.labels.push(switchLabel);
1079 this.enterScope(0);
1080
1081 // Statements under must be grouped (by label) in SwitchCase
1082 // nodes. `cur` is used to keep the node that we are currently
1083 // adding statements to.
1084
1085 var cur;
1086 for (var sawDefault = false; this.type !== types$1.braceR;) {
1087 if (this.type === types$1._case || this.type === types$1._default) {
1088 var isCase = this.type === types$1._case;
1089 if (cur) { this.finishNode(cur, "SwitchCase"); }
1090 node.cases.push(cur = this.startNode());
1091 cur.consequent = [];
1092 this.next();
1093 if (isCase) {
1094 cur.test = this.parseExpression();
1095 } else {
1096 if (sawDefault) { this.raiseRecoverable(this.lastTokStart, "Multiple default clauses"); }
1097 sawDefault = true;
1098 cur.test = null;
1099 }
1100 this.expect(types$1.colon);
1101 } else {
1102 if (!cur) { this.unexpected(); }
1103 cur.consequent.push(this.parseStatement(null));
1104 }
1105 }
1106 this.exitScope();
1107 if (cur) { this.finishNode(cur, "SwitchCase"); }
1108 this.next(); // Closing brace
1109 this.labels.pop();
1110 return this.finishNode(node, "SwitchStatement")
1111 };
1112
1113 pp$8.parseThrowStatement = function(node) {
1114 this.next();
1115 if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start)))
1116 { this.raise(this.lastTokEnd, "Illegal newline after throw"); }
1117 node.argument = this.parseExpression();
1118 this.semicolon();
1119 return this.finishNode(node, "ThrowStatement")
1120 };
1121
1122 // Reused empty array added for node fields that are always empty.
1123
1124 var empty$1 = [];
1125
1126 pp$8.parseTryStatement = function(node) {
1127 this.next();
1128 node.block = this.parseBlock();
1129 node.handler = null;
1130 if (this.type === types$1._catch) {
1131 var clause = this.startNode();
1132 this.next();
1133 if (this.eat(types$1.parenL)) {
1134 clause.param = this.parseBindingAtom();
1135 var simple = clause.param.type === "Identifier";
1136 this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0);
1137 this.checkLValPattern(clause.param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL);
1138 this.expect(types$1.parenR);
1139 } else {
1140 if (this.options.ecmaVersion < 10) { this.unexpected(); }
1141 clause.param = null;
1142 this.enterScope(0);
1143 }
1144 clause.body = this.parseBlock(false);
1145 this.exitScope();
1146 node.handler = this.finishNode(clause, "CatchClause");
1147 }
1148 node.finalizer = this.eat(types$1._finally) ? this.parseBlock() : null;
1149 if (!node.handler && !node.finalizer)
1150 { this.raise(node.start, "Missing catch or finally clause"); }
1151 return this.finishNode(node, "TryStatement")
1152 };
1153
1154 pp$8.parseVarStatement = function(node, kind) {
1155 this.next();
1156 this.parseVar(node, false, kind);
1157 this.semicolon();
1158 return this.finishNode(node, "VariableDeclaration")
1159 };
1160
1161 pp$8.parseWhileStatement = function(node) {
1162 this.next();
1163 node.test = this.parseParenExpression();
1164 this.labels.push(loopLabel);
1165 node.body = this.parseStatement("while");
1166 this.labels.pop();
1167 return this.finishNode(node, "WhileStatement")
1168 };
1169
1170 pp$8.parseWithStatement = function(node) {
1171 if (this.strict) { this.raise(this.start, "'with' in strict mode"); }
1172 this.next();
1173 node.object = this.parseParenExpression();
1174 node.body = this.parseStatement("with");
1175 return this.finishNode(node, "WithStatement")
1176 };
1177
1178 pp$8.parseEmptyStatement = function(node) {
1179 this.next();
1180 return this.finishNode(node, "EmptyStatement")
1181 };
1182
1183 pp$8.parseLabeledStatement = function(node, maybeName, expr, context) {
1184 for (var i$1 = 0, list = this.labels; i$1 < list.length; i$1 += 1)
1185 {
1186 var label = list[i$1];
1187
1188 if (label.name === maybeName)
1189 { this.raise(expr.start, "Label '" + maybeName + "' is already declared");
1190 } }
1191 var kind = this.type.isLoop ? "loop" : this.type === types$1._switch ? "switch" : null;
1192 for (var i = this.labels.length - 1; i >= 0; i--) {
1193 var label$1 = this.labels[i];
1194 if (label$1.statementStart === node.start) {
1195 // Update information about previous labels on this node
1196 label$1.statementStart = this.start;
1197 label$1.kind = kind;
1198 } else { break }
1199 }
1200 this.labels.push({name: maybeName, kind: kind, statementStart: this.start});
1201 node.body = this.parseStatement(context ? context.indexOf("label") === -1 ? context + "label" : context : "label");
1202 this.labels.pop();
1203 node.label = expr;
1204 return this.finishNode(node, "LabeledStatement")
1205 };
1206
1207 pp$8.parseExpressionStatement = function(node, expr) {
1208 node.expression = expr;
1209 this.semicolon();
1210 return this.finishNode(node, "ExpressionStatement")
1211 };
1212
1213 // Parse a semicolon-enclosed block of statements, handling `"use
1214 // strict"` declarations when `allowStrict` is true (used for
1215 // function bodies).
1216
1217 pp$8.parseBlock = function(createNewLexicalScope, node, exitStrict) {
1218 if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true;
1219 if ( node === void 0 ) node = this.startNode();
1220
1221 node.body = [];
1222 this.expect(types$1.braceL);
1223 if (createNewLexicalScope) { this.enterScope(0); }
1224 while (this.type !== types$1.braceR) {
1225 var stmt = this.parseStatement(null);
1226 node.body.push(stmt);
1227 }
1228 if (exitStrict) { this.strict = false; }
1229 this.next();
1230 if (createNewLexicalScope) { this.exitScope(); }
1231 return this.finishNode(node, "BlockStatement")
1232 };
1233
1234 // Parse a regular `for` loop. The disambiguation code in
1235 // `parseStatement` will already have parsed the init statement or
1236 // expression.
1237
1238 pp$8.parseFor = function(node, init) {
1239 node.init = init;
1240 this.expect(types$1.semi);
1241 node.test = this.type === types$1.semi ? null : this.parseExpression();
1242 this.expect(types$1.semi);
1243 node.update = this.type === types$1.parenR ? null : this.parseExpression();
1244 this.expect(types$1.parenR);
1245 node.body = this.parseStatement("for");
1246 this.exitScope();
1247 this.labels.pop();
1248 return this.finishNode(node, "ForStatement")
1249 };
1250
1251 // Parse a `for`/`in` and `for`/`of` loop, which are almost
1252 // same from parser's perspective.
1253
1254 pp$8.parseForIn = function(node, init) {
1255 var isForIn = this.type === types$1._in;
1256 this.next();
1257
1258 if (
1259 init.type === "VariableDeclaration" &&
1260 init.declarations[0].init != null &&
1261 (
1262 !isForIn ||
1263 this.options.ecmaVersion < 8 ||
1264 this.strict ||
1265 init.kind !== "var" ||
1266 init.declarations[0].id.type !== "Identifier"
1267 )
1268 ) {
1269 this.raise(
1270 init.start,
1271 ((isForIn ? "for-in" : "for-of") + " loop variable declaration may not have an initializer")
1272 );
1273 }
1274 node.left = init;
1275 node.right = isForIn ? this.parseExpression() : this.parseMaybeAssign();
1276 this.expect(types$1.parenR);
1277 node.body = this.parseStatement("for");
1278 this.exitScope();
1279 this.labels.pop();
1280 return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement")
1281 };
1282
1283 // Parse a list of variable declarations.
1284
1285 pp$8.parseVar = function(node, isFor, kind) {
1286 node.declarations = [];
1287 node.kind = kind;
1288 for (;;) {
1289 var decl = this.startNode();
1290 this.parseVarId(decl, kind);
1291 if (this.eat(types$1.eq)) {
1292 decl.init = this.parseMaybeAssign(isFor);
1293 } else if (kind === "const" && !(this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of")))) {
1294 this.unexpected();
1295 } else if (decl.id.type !== "Identifier" && !(isFor && (this.type === types$1._in || this.isContextual("of")))) {
1296 this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");
1297 } else {
1298 decl.init = null;
1299 }
1300 node.declarations.push(this.finishNode(decl, "VariableDeclarator"));
1301 if (!this.eat(types$1.comma)) { break }
1302 }
1303 return node
1304 };
1305
1306 pp$8.parseVarId = function(decl, kind) {
1307 decl.id = this.parseBindingAtom();
1308 this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false);
1309 };
1310
1311 var FUNC_STATEMENT = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID = 4;
1312
1313 // Parse a function declaration or literal (depending on the
1314 // `statement & FUNC_STATEMENT`).
1315
1316 // Remove `allowExpressionBody` for 7.0.0, as it is only called with false
1317 pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, forInit) {
1318 this.initFunction(node);
1319 if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) {
1320 if (this.type === types$1.star && (statement & FUNC_HANGING_STATEMENT))
1321 { this.unexpected(); }
1322 node.generator = this.eat(types$1.star);
1323 }
1324 if (this.options.ecmaVersion >= 8)
1325 { node.async = !!isAsync; }
1326
1327 if (statement & FUNC_STATEMENT) {
1328 node.id = (statement & FUNC_NULLABLE_ID) && this.type !== types$1.name ? null : this.parseIdent();
1329 if (node.id && !(statement & FUNC_HANGING_STATEMENT))
1330 // If it is a regular function declaration in sloppy mode, then it is
1331 // subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding
1332 // mode depends on properties of the current scope (see
1333 // treatFunctionsAsVar).
1334 { this.checkLValSimple(node.id, (this.strict || node.generator || node.async) ? this.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION); }
1335 }
1336
1337 var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
1338 this.yieldPos = 0;
1339 this.awaitPos = 0;
1340 this.awaitIdentPos = 0;
1341 this.enterScope(functionFlags(node.async, node.generator));
1342
1343 if (!(statement & FUNC_STATEMENT))
1344 { node.id = this.type === types$1.name ? this.parseIdent() : null; }
1345
1346 this.parseFunctionParams(node);
1347 this.parseFunctionBody(node, allowExpressionBody, false, forInit);
1348
1349 this.yieldPos = oldYieldPos;
1350 this.awaitPos = oldAwaitPos;
1351 this.awaitIdentPos = oldAwaitIdentPos;
1352 return this.finishNode(node, (statement & FUNC_STATEMENT) ? "FunctionDeclaration" : "FunctionExpression")
1353 };
1354
1355 pp$8.parseFunctionParams = function(node) {
1356 this.expect(types$1.parenL);
1357 node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8);
1358 this.checkYieldAwaitInDefaultParams();
1359 };
1360
1361 // Parse a class declaration or literal (depending on the
1362 // `isStatement` parameter).
1363
1364 pp$8.parseClass = function(node, isStatement) {
1365 this.next();
1366
1367 // ecma-262 14.6 Class Definitions
1368 // A class definition is always strict mode code.
1369 var oldStrict = this.strict;
1370 this.strict = true;
1371
1372 this.parseClassId(node, isStatement);
1373 this.parseClassSuper(node);
1374 var privateNameMap = this.enterClassBody();
1375 var classBody = this.startNode();
1376 var hadConstructor = false;
1377 classBody.body = [];
1378 this.expect(types$1.braceL);
1379 while (this.type !== types$1.braceR) {
1380 var element = this.parseClassElement(node.superClass !== null);
1381 if (element) {
1382 classBody.body.push(element);
1383 if (element.type === "MethodDefinition" && element.kind === "constructor") {
1384 if (hadConstructor) { this.raise(element.start, "Duplicate constructor in the same class"); }
1385 hadConstructor = true;
1386 } else if (element.key && element.key.type === "PrivateIdentifier" && isPrivateNameConflicted(privateNameMap, element)) {
1387 this.raiseRecoverable(element.key.start, ("Identifier '#" + (element.key.name) + "' has already been declared"));
1388 }
1389 }
1390 }
1391 this.strict = oldStrict;
1392 this.next();
1393 node.body = this.finishNode(classBody, "ClassBody");
1394 this.exitClassBody();
1395 return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression")
1396 };
1397
1398 pp$8.parseClassElement = function(constructorAllowsSuper) {
1399 if (this.eat(types$1.semi)) { return null }
1400
1401 var ecmaVersion = this.options.ecmaVersion;
1402 var node = this.startNode();
1403 var keyName = "";
1404 var isGenerator = false;
1405 var isAsync = false;
1406 var kind = "method";
1407 var isStatic = false;
1408
1409 if (this.eatContextual("static")) {
1410 // Parse static init block
1411 if (ecmaVersion >= 13 && this.eat(types$1.braceL)) {
1412 this.parseClassStaticBlock(node);
1413 return node
1414 }
1415 if (this.isClassElementNameStart() || this.type === types$1.star) {
1416 isStatic = true;
1417 } else {
1418 keyName = "static";
1419 }
1420 }
1421 node.static = isStatic;
1422 if (!keyName && ecmaVersion >= 8 && this.eatContextual("async")) {
1423 if ((this.isClassElementNameStart() || this.type === types$1.star) && !this.canInsertSemicolon()) {
1424 isAsync = true;
1425 } else {
1426 keyName = "async";
1427 }
1428 }
1429 if (!keyName && (ecmaVersion >= 9 || !isAsync) && this.eat(types$1.star)) {
1430 isGenerator = true;
1431 }
1432 if (!keyName && !isAsync && !isGenerator) {
1433 var lastValue = this.value;
1434 if (this.eatContextual("get") || this.eatContextual("set")) {
1435 if (this.isClassElementNameStart()) {
1436 kind = lastValue;
1437 } else {
1438 keyName = lastValue;
1439 }
1440 }
1441 }
1442
1443 // Parse element name
1444 if (keyName) {
1445 // 'async', 'get', 'set', or 'static' were not a keyword contextually.
1446 // The last token is any of those. Make it the element name.
1447 node.computed = false;
1448 node.key = this.startNodeAt(this.lastTokStart, this.lastTokStartLoc);
1449 node.key.name = keyName;
1450 this.finishNode(node.key, "Identifier");
1451 } else {
1452 this.parseClassElementName(node);
1453 }
1454
1455 // Parse element value
1456 if (ecmaVersion < 13 || this.type === types$1.parenL || kind !== "method" || isGenerator || isAsync) {
1457 var isConstructor = !node.static && checkKeyName(node, "constructor");
1458 var allowsDirectSuper = isConstructor && constructorAllowsSuper;
1459 // Couldn't move this check into the 'parseClassMethod' method for backward compatibility.
1460 if (isConstructor && kind !== "method") { this.raise(node.key.start, "Constructor can't have get/set modifier"); }
1461 node.kind = isConstructor ? "constructor" : kind;
1462 this.parseClassMethod(node, isGenerator, isAsync, allowsDirectSuper);
1463 } else {
1464 this.parseClassField(node);
1465 }
1466
1467 return node
1468 };
1469
1470 pp$8.isClassElementNameStart = function() {
1471 return (
1472 this.type === types$1.name ||
1473 this.type === types$1.privateId ||
1474 this.type === types$1.num ||
1475 this.type === types$1.string ||
1476 this.type === types$1.bracketL ||
1477 this.type.keyword
1478 )
1479 };
1480
1481 pp$8.parseClassElementName = function(element) {
1482 if (this.type === types$1.privateId) {
1483 if (this.value === "constructor") {
1484 this.raise(this.start, "Classes can't have an element named '#constructor'");
1485 }
1486 element.computed = false;
1487 element.key = this.parsePrivateIdent();
1488 } else {
1489 this.parsePropertyName(element);
1490 }
1491 };
1492
1493 pp$8.parseClassMethod = function(method, isGenerator, isAsync, allowsDirectSuper) {
1494 // Check key and flags
1495 var key = method.key;
1496 if (method.kind === "constructor") {
1497 if (isGenerator) { this.raise(key.start, "Constructor can't be a generator"); }
1498 if (isAsync) { this.raise(key.start, "Constructor can't be an async method"); }
1499 } else if (method.static && checkKeyName(method, "prototype")) {
1500 this.raise(key.start, "Classes may not have a static property named prototype");
1501 }
1502
1503 // Parse value
1504 var value = method.value = this.parseMethod(isGenerator, isAsync, allowsDirectSuper);
1505
1506 // Check value
1507 if (method.kind === "get" && value.params.length !== 0)
1508 { this.raiseRecoverable(value.start, "getter should have no params"); }
1509 if (method.kind === "set" && value.params.length !== 1)
1510 { this.raiseRecoverable(value.start, "setter should have exactly one param"); }
1511 if (method.kind === "set" && value.params[0].type === "RestElement")
1512 { this.raiseRecoverable(value.params[0].start, "Setter cannot use rest params"); }
1513
1514 return this.finishNode(method, "MethodDefinition")
1515 };
1516
1517 pp$8.parseClassField = function(field) {
1518 if (checkKeyName(field, "constructor")) {
1519 this.raise(field.key.start, "Classes can't have a field named 'constructor'");
1520 } else if (field.static && checkKeyName(field, "prototype")) {
1521 this.raise(field.key.start, "Classes can't have a static field named 'prototype'");
1522 }
1523
1524 if (this.eat(types$1.eq)) {
1525 // To raise SyntaxError if 'arguments' exists in the initializer.
1526 var scope = this.currentThisScope();
1527 var inClassFieldInit = scope.inClassFieldInit;
1528 scope.inClassFieldInit = true;
1529 field.value = this.parseMaybeAssign();
1530 scope.inClassFieldInit = inClassFieldInit;
1531 } else {
1532 field.value = null;
1533 }
1534 this.semicolon();
1535
1536 return this.finishNode(field, "PropertyDefinition")
1537 };
1538
1539 pp$8.parseClassStaticBlock = function(node) {
1540 node.body = [];
1541
1542 var oldLabels = this.labels;
1543 this.labels = [];
1544 this.enterScope(SCOPE_CLASS_STATIC_BLOCK | SCOPE_SUPER);
1545 while (this.type !== types$1.braceR) {
1546 var stmt = this.parseStatement(null);
1547 node.body.push(stmt);
1548 }
1549 this.next();
1550 this.exitScope();
1551 this.labels = oldLabels;
1552
1553 return this.finishNode(node, "StaticBlock")
1554 };
1555
1556 pp$8.parseClassId = function(node, isStatement) {
1557 if (this.type === types$1.name) {
1558 node.id = this.parseIdent();
1559 if (isStatement)
1560 { this.checkLValSimple(node.id, BIND_LEXICAL, false); }
1561 } else {
1562 if (isStatement === true)
1563 { this.unexpected(); }
1564 node.id = null;
1565 }
1566 };
1567
1568 pp$8.parseClassSuper = function(node) {
1569 node.superClass = this.eat(types$1._extends) ? this.parseExprSubscripts(false) : null;
1570 };
1571
1572 pp$8.enterClassBody = function() {
1573 var element = {declared: Object.create(null), used: []};
1574 this.privateNameStack.push(element);
1575 return element.declared
1576 };
1577
1578 pp$8.exitClassBody = function() {
1579 var ref = this.privateNameStack.pop();
1580 var declared = ref.declared;
1581 var used = ref.used;
1582 var len = this.privateNameStack.length;
1583 var parent = len === 0 ? null : this.privateNameStack[len - 1];
1584 for (var i = 0; i < used.length; ++i) {
1585 var id = used[i];
1586 if (!has(declared, id.name)) {
1587 if (parent) {
1588 parent.used.push(id);
1589 } else {
1590 this.raiseRecoverable(id.start, ("Private field '#" + (id.name) + "' must be declared in an enclosing class"));
1591 }
1592 }
1593 }
1594 };
1595
1596 function isPrivateNameConflicted(privateNameMap, element) {
1597 var name = element.key.name;
1598 var curr = privateNameMap[name];
1599
1600 var next = "true";
1601 if (element.type === "MethodDefinition" && (element.kind === "get" || element.kind === "set")) {
1602 next = (element.static ? "s" : "i") + element.kind;
1603 }
1604
1605 // `class { get #a(){}; static set #a(_){} }` is also conflict.
1606 if (
1607 curr === "iget" && next === "iset" ||
1608 curr === "iset" && next === "iget" ||
1609 curr === "sget" && next === "sset" ||
1610 curr === "sset" && next === "sget"
1611 ) {
1612 privateNameMap[name] = "true";
1613 return false
1614 } else if (!curr) {
1615 privateNameMap[name] = next;
1616 return false
1617 } else {
1618 return true
1619 }
1620 }
1621
1622 function checkKeyName(node, name) {
1623 var computed = node.computed;
1624 var key = node.key;
1625 return !computed && (
1626 key.type === "Identifier" && key.name === name ||
1627 key.type === "Literal" && key.value === name
1628 )
1629 }
1630
1631 // Parses module export declaration.
1632
1633 pp$8.parseExport = function(node, exports) {
1634 this.next();
1635 // export * from '...'
1636 if (this.eat(types$1.star)) {
1637 if (this.options.ecmaVersion >= 11) {
1638 if (this.eatContextual("as")) {
1639 node.exported = this.parseIdent(true);
1640 this.checkExport(exports, node.exported.name, this.lastTokStart);
1641 } else {
1642 node.exported = null;
1643 }
1644 }
1645 this.expectContextual("from");
1646 if (this.type !== types$1.string) { this.unexpected(); }
1647 node.source = this.parseExprAtom();
1648 this.semicolon();
1649 return this.finishNode(node, "ExportAllDeclaration")
1650 }
1651 if (this.eat(types$1._default)) { // export default ...
1652 this.checkExport(exports, "default", this.lastTokStart);
1653 var isAsync;
1654 if (this.type === types$1._function || (isAsync = this.isAsyncFunction())) {
1655 var fNode = this.startNode();
1656 this.next();
1657 if (isAsync) { this.next(); }
1658 node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);
1659 } else if (this.type === types$1._class) {
1660 var cNode = this.startNode();
1661 node.declaration = this.parseClass(cNode, "nullableID");
1662 } else {
1663 node.declaration = this.parseMaybeAssign();
1664 this.semicolon();
1665 }
1666 return this.finishNode(node, "ExportDefaultDeclaration")
1667 }
1668 // export var|const|let|function|class ...
1669 if (this.shouldParseExportStatement()) {
1670 node.declaration = this.parseStatement(null);
1671 if (node.declaration.type === "VariableDeclaration")
1672 { this.checkVariableExport(exports, node.declaration.declarations); }
1673 else
1674 { this.checkExport(exports, node.declaration.id.name, node.declaration.id.start); }
1675 node.specifiers = [];
1676 node.source = null;
1677 } else { // export { x, y as z } [from '...']
1678 node.declaration = null;
1679 node.specifiers = this.parseExportSpecifiers(exports);
1680 if (this.eatContextual("from")) {
1681 if (this.type !== types$1.string) { this.unexpected(); }
1682 node.source = this.parseExprAtom();
1683 } else {
1684 for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
1685 // check for keywords used as local names
1686 var spec = list[i];
1687
1688 this.checkUnreserved(spec.local);
1689 // check if export is defined
1690 this.checkLocalExport(spec.local);
1691 }
1692
1693 node.source = null;
1694 }
1695 this.semicolon();
1696 }
1697 return this.finishNode(node, "ExportNamedDeclaration")
1698 };
1699
1700 pp$8.checkExport = function(exports, name, pos) {
1701 if (!exports) { return }
1702 if (has(exports, name))
1703 { this.raiseRecoverable(pos, "Duplicate export '" + name + "'"); }
1704 exports[name] = true;
1705 };
1706
1707 pp$8.checkPatternExport = function(exports, pat) {
1708 var type = pat.type;
1709 if (type === "Identifier")
1710 { this.checkExport(exports, pat.name, pat.start); }
1711 else if (type === "ObjectPattern")
1712 { for (var i = 0, list = pat.properties; i < list.length; i += 1)
1713 {
1714 var prop = list[i];
1715
1716 this.checkPatternExport(exports, prop);
1717 } }
1718 else if (type === "ArrayPattern")
1719 { for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
1720 var elt = list$1[i$1];
1721
1722 if (elt) { this.checkPatternExport(exports, elt); }
1723 } }
1724 else if (type === "Property")
1725 { this.checkPatternExport(exports, pat.value); }
1726 else if (type === "AssignmentPattern")
1727 { this.checkPatternExport(exports, pat.left); }
1728 else if (type === "RestElement")
1729 { this.checkPatternExport(exports, pat.argument); }
1730 else if (type === "ParenthesizedExpression")
1731 { this.checkPatternExport(exports, pat.expression); }
1732 };
1733
1734 pp$8.checkVariableExport = function(exports, decls) {
1735 if (!exports) { return }
1736 for (var i = 0, list = decls; i < list.length; i += 1)
1737 {
1738 var decl = list[i];
1739
1740 this.checkPatternExport(exports, decl.id);
1741 }
1742 };
1743
1744 pp$8.shouldParseExportStatement = function() {
1745 return this.type.keyword === "var" ||
1746 this.type.keyword === "const" ||
1747 this.type.keyword === "class" ||
1748 this.type.keyword === "function" ||
1749 this.isLet() ||
1750 this.isAsyncFunction()
1751 };
1752
1753 // Parses a comma-separated list of module exports.
1754
1755 pp$8.parseExportSpecifiers = function(exports) {
1756 var nodes = [], first = true;
1757 // export { x, y as z } [from '...']
1758 this.expect(types$1.braceL);
1759 while (!this.eat(types$1.braceR)) {
1760 if (!first) {
1761 this.expect(types$1.comma);
1762 if (this.afterTrailingComma(types$1.braceR)) { break }
1763 } else { first = false; }
1764
1765 var node = this.startNode();
1766 node.local = this.parseIdent(true);
1767 node.exported = this.eatContextual("as") ? this.parseIdent(true) : node.local;
1768 this.checkExport(exports, node.exported.name, node.exported.start);
1769 nodes.push(this.finishNode(node, "ExportSpecifier"));
1770 }
1771 return nodes
1772 };
1773
1774 // Parses import declaration.
1775
1776 pp$8.parseImport = function(node) {
1777 this.next();
1778 // import '...'
1779 if (this.type === types$1.string) {
1780 node.specifiers = empty$1;
1781 node.source = this.parseExprAtom();
1782 } else {
1783 node.specifiers = this.parseImportSpecifiers();
1784 this.expectContextual("from");
1785 node.source = this.type === types$1.string ? this.parseExprAtom() : this.unexpected();
1786 }
1787 this.semicolon();
1788 return this.finishNode(node, "ImportDeclaration")
1789 };
1790
1791 // Parses a comma-separated list of module imports.
1792
1793 pp$8.parseImportSpecifiers = function() {
1794 var nodes = [], first = true;
1795 if (this.type === types$1.name) {
1796 // import defaultObj, { x, y as z } from '...'
1797 var node = this.startNode();
1798 node.local = this.parseIdent();
1799 this.checkLValSimple(node.local, BIND_LEXICAL);
1800 nodes.push(this.finishNode(node, "ImportDefaultSpecifier"));
1801 if (!this.eat(types$1.comma)) { return nodes }
1802 }
1803 if (this.type === types$1.star) {
1804 var node$1 = this.startNode();
1805 this.next();
1806 this.expectContextual("as");
1807 node$1.local = this.parseIdent();
1808 this.checkLValSimple(node$1.local, BIND_LEXICAL);
1809 nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier"));
1810 return nodes
1811 }
1812 this.expect(types$1.braceL);
1813 while (!this.eat(types$1.braceR)) {
1814 if (!first) {
1815 this.expect(types$1.comma);
1816 if (this.afterTrailingComma(types$1.braceR)) { break }
1817 } else { first = false; }
1818
1819 var node$2 = this.startNode();
1820 node$2.imported = this.parseIdent(true);
1821 if (this.eatContextual("as")) {
1822 node$2.local = this.parseIdent();
1823 } else {
1824 this.checkUnreserved(node$2.imported);
1825 node$2.local = node$2.imported;
1826 }
1827 this.checkLValSimple(node$2.local, BIND_LEXICAL);
1828 nodes.push(this.finishNode(node$2, "ImportSpecifier"));
1829 }
1830 return nodes
1831 };
1832
1833 // Set `ExpressionStatement#directive` property for directive prologues.
1834 pp$8.adaptDirectivePrologue = function(statements) {
1835 for (var i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i) {
1836 statements[i].directive = statements[i].expression.raw.slice(1, -1);
1837 }
1838 };
1839 pp$8.isDirectiveCandidate = function(statement) {
1840 return (
1841 statement.type === "ExpressionStatement" &&
1842 statement.expression.type === "Literal" &&
1843 typeof statement.expression.value === "string" &&
1844 // Reject parenthesized strings.
1845 (this.input[statement.start] === "\"" || this.input[statement.start] === "'")
1846 )
1847 };
1848
1849 var pp$7 = Parser.prototype;
1850
1851 // Convert existing expression atom to assignable pattern
1852 // if possible.
1853
1854 pp$7.toAssignable = function(node, isBinding, refDestructuringErrors) {
1855 if (this.options.ecmaVersion >= 6 && node) {
1856 switch (node.type) {
1857 case "Identifier":
1858 if (this.inAsync && node.name === "await")
1859 { this.raise(node.start, "Cannot use 'await' as identifier inside an async function"); }
1860 break
1861
1862 case "ObjectPattern":
1863 case "ArrayPattern":
1864 case "AssignmentPattern":
1865 case "RestElement":
1866 break
1867
1868 case "ObjectExpression":
1869 node.type = "ObjectPattern";
1870 if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
1871 for (var i = 0, list = node.properties; i < list.length; i += 1) {
1872 var prop = list[i];
1873
1874 this.toAssignable(prop, isBinding);
1875 // Early error:
1876 // AssignmentRestProperty[Yield, Await] :
1877 // `...` DestructuringAssignmentTarget[Yield, Await]
1878 //
1879 // It is a Syntax Error if |DestructuringAssignmentTarget| is an |ArrayLiteral| or an |ObjectLiteral|.
1880 if (
1881 prop.type === "RestElement" &&
1882 (prop.argument.type === "ArrayPattern" || prop.argument.type === "ObjectPattern")
1883 ) {
1884 this.raise(prop.argument.start, "Unexpected token");
1885 }
1886 }
1887 break
1888
1889 case "Property":
1890 // AssignmentProperty has type === "Property"
1891 if (node.kind !== "init") { this.raise(node.key.start, "Object pattern can't contain getter or setter"); }
1892 this.toAssignable(node.value, isBinding);
1893 break
1894
1895 case "ArrayExpression":
1896 node.type = "ArrayPattern";
1897 if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
1898 this.toAssignableList(node.elements, isBinding);
1899 break
1900
1901 case "SpreadElement":
1902 node.type = "RestElement";
1903 this.toAssignable(node.argument, isBinding);
1904 if (node.argument.type === "AssignmentPattern")
1905 { this.raise(node.argument.start, "Rest elements cannot have a default value"); }
1906 break
1907
1908 case "AssignmentExpression":
1909 if (node.operator !== "=") { this.raise(node.left.end, "Only '=' operator can be used for specifying default value."); }
1910 node.type = "AssignmentPattern";
1911 delete node.operator;
1912 this.toAssignable(node.left, isBinding);
1913 break
1914
1915 case "ParenthesizedExpression":
1916 this.toAssignable(node.expression, isBinding, refDestructuringErrors);
1917 break
1918
1919 case "ChainExpression":
1920 this.raiseRecoverable(node.start, "Optional chaining cannot appear in left-hand side");
1921 break
1922
1923 case "MemberExpression":
1924 if (!isBinding) { break }
1925
1926 default:
1927 this.raise(node.start, "Assigning to rvalue");
1928 }
1929 } else if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
1930 return node
1931 };
1932
1933 // Convert list of expression atoms to binding list.
1934
1935 pp$7.toAssignableList = function(exprList, isBinding) {
1936 var end = exprList.length;
1937 for (var i = 0; i < end; i++) {
1938 var elt = exprList[i];
1939 if (elt) { this.toAssignable(elt, isBinding); }
1940 }
1941 if (end) {
1942 var last = exprList[end - 1];
1943 if (this.options.ecmaVersion === 6 && isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier")
1944 { this.unexpected(last.argument.start); }
1945 }
1946 return exprList
1947 };
1948
1949 // Parses spread element.
1950
1951 pp$7.parseSpread = function(refDestructuringErrors) {
1952 var node = this.startNode();
1953 this.next();
1954 node.argument = this.parseMaybeAssign(false, refDestructuringErrors);
1955 return this.finishNode(node, "SpreadElement")
1956 };
1957
1958 pp$7.parseRestBinding = function() {
1959 var node = this.startNode();
1960 this.next();
1961
1962 // RestElement inside of a function parameter must be an identifier
1963 if (this.options.ecmaVersion === 6 && this.type !== types$1.name)
1964 { this.unexpected(); }
1965
1966 node.argument = this.parseBindingAtom();
1967
1968 return this.finishNode(node, "RestElement")
1969 };
1970
1971 // Parses lvalue (assignable) atom.
1972
1973 pp$7.parseBindingAtom = function() {
1974 if (this.options.ecmaVersion >= 6) {
1975 switch (this.type) {
1976 case types$1.bracketL:
1977 var node = this.startNode();
1978 this.next();
1979 node.elements = this.parseBindingList(types$1.bracketR, true, true);
1980 return this.finishNode(node, "ArrayPattern")
1981
1982 case types$1.braceL:
1983 return this.parseObj(true)
1984 }
1985 }
1986 return this.parseIdent()
1987 };
1988
1989 pp$7.parseBindingList = function(close, allowEmpty, allowTrailingComma) {
1990 var elts = [], first = true;
1991 while (!this.eat(close)) {
1992 if (first) { first = false; }
1993 else { this.expect(types$1.comma); }
1994 if (allowEmpty && this.type === types$1.comma) {
1995 elts.push(null);
1996 } else if (allowTrailingComma && this.afterTrailingComma(close)) {
1997 break
1998 } else if (this.type === types$1.ellipsis) {
1999 var rest = this.parseRestBinding();
2000 this.parseBindingListItem(rest);
2001 elts.push(rest);
2002 if (this.type === types$1.comma) { this.raise(this.start, "Comma is not permitted after the rest element"); }
2003 this.expect(close);
2004 break
2005 } else {
2006 var elem = this.parseMaybeDefault(this.start, this.startLoc);
2007 this.parseBindingListItem(elem);
2008 elts.push(elem);
2009 }
2010 }
2011 return elts
2012 };
2013
2014 pp$7.parseBindingListItem = function(param) {
2015 return param
2016 };
2017
2018 // Parses assignment pattern around given atom if possible.
2019
2020 pp$7.parseMaybeDefault = function(startPos, startLoc, left) {
2021 left = left || this.parseBindingAtom();
2022 if (this.options.ecmaVersion < 6 || !this.eat(types$1.eq)) { return left }
2023 var node = this.startNodeAt(startPos, startLoc);
2024 node.left = left;
2025 node.right = this.parseMaybeAssign();
2026 return this.finishNode(node, "AssignmentPattern")
2027 };
2028
2029 // The following three functions all verify that a node is an lvalue —
2030 // something that can be bound, or assigned to. In order to do so, they perform
2031 // a variety of checks:
2032 //
2033 // - Check that none of the bound/assigned-to identifiers are reserved words.
2034 // - Record name declarations for bindings in the appropriate scope.
2035 // - Check duplicate argument names, if checkClashes is set.
2036 //
2037 // If a complex binding pattern is encountered (e.g., object and array
2038 // destructuring), the entire pattern is recursively checked.
2039 //
2040 // There are three versions of checkLVal*() appropriate for different
2041 // circumstances:
2042 //
2043 // - checkLValSimple() shall be used if the syntactic construct supports
2044 // nothing other than identifiers and member expressions. Parenthesized
2045 // expressions are also correctly handled. This is generally appropriate for
2046 // constructs for which the spec says
2047 //
2048 // > It is a Syntax Error if AssignmentTargetType of [the production] is not
2049 // > simple.
2050 //
2051 // It is also appropriate for checking if an identifier is valid and not
2052 // defined elsewhere, like import declarations or function/class identifiers.
2053 //
2054 // Examples where this is used include:
2055 // a += …;
2056 // import a from '…';
2057 // where a is the node to be checked.
2058 //
2059 // - checkLValPattern() shall be used if the syntactic construct supports
2060 // anything checkLValSimple() supports, as well as object and array
2061 // destructuring patterns. This is generally appropriate for constructs for
2062 // which the spec says
2063 //
2064 // > It is a Syntax Error if [the production] is neither an ObjectLiteral nor
2065 // > an ArrayLiteral and AssignmentTargetType of [the production] is not
2066 // > simple.
2067 //
2068 // Examples where this is used include:
2069 // (a = …);
2070 // const a = …;
2071 // try { … } catch (a) { … }
2072 // where a is the node to be checked.
2073 //
2074 // - checkLValInnerPattern() shall be used if the syntactic construct supports
2075 // anything checkLValPattern() supports, as well as default assignment
2076 // patterns, rest elements, and other constructs that may appear within an
2077 // object or array destructuring pattern.
2078 //
2079 // As a special case, function parameters also use checkLValInnerPattern(),
2080 // as they also support defaults and rest constructs.
2081 //
2082 // These functions deliberately support both assignment and binding constructs,
2083 // as the logic for both is exceedingly similar. If the node is the target of
2084 // an assignment, then bindingType should be set to BIND_NONE. Otherwise, it
2085 // should be set to the appropriate BIND_* constant, like BIND_VAR or
2086 // BIND_LEXICAL.
2087 //
2088 // If the function is called with a non-BIND_NONE bindingType, then
2089 // additionally a checkClashes object may be specified to allow checking for
2090 // duplicate argument names. checkClashes is ignored if the provided construct
2091 // is an assignment (i.e., bindingType is BIND_NONE).
2092
2093 pp$7.checkLValSimple = function(expr, bindingType, checkClashes) {
2094 if ( bindingType === void 0 ) bindingType = BIND_NONE;
2095
2096 var isBind = bindingType !== BIND_NONE;
2097
2098 switch (expr.type) {
2099 case "Identifier":
2100 if (this.strict && this.reservedWordsStrictBind.test(expr.name))
2101 { this.raiseRecoverable(expr.start, (isBind ? "Binding " : "Assigning to ") + expr.name + " in strict mode"); }
2102 if (isBind) {
2103 if (bindingType === BIND_LEXICAL && expr.name === "let")
2104 { this.raiseRecoverable(expr.start, "let is disallowed as a lexically bound name"); }
2105 if (checkClashes) {
2106 if (has(checkClashes, expr.name))
2107 { this.raiseRecoverable(expr.start, "Argument name clash"); }
2108 checkClashes[expr.name] = true;
2109 }
2110 if (bindingType !== BIND_OUTSIDE) { this.declareName(expr.name, bindingType, expr.start); }
2111 }
2112 break
2113
2114 case "ChainExpression":
2115 this.raiseRecoverable(expr.start, "Optional chaining cannot appear in left-hand side");
2116 break
2117
2118 case "MemberExpression":
2119 if (isBind) { this.raiseRecoverable(expr.start, "Binding member expression"); }
2120 break
2121
2122 case "ParenthesizedExpression":
2123 if (isBind) { this.raiseRecoverable(expr.start, "Binding parenthesized expression"); }
2124 return this.checkLValSimple(expr.expression, bindingType, checkClashes)
2125
2126 default:
2127 this.raise(expr.start, (isBind ? "Binding" : "Assigning to") + " rvalue");
2128 }
2129 };
2130
2131 pp$7.checkLValPattern = function(expr, bindingType, checkClashes) {
2132 if ( bindingType === void 0 ) bindingType = BIND_NONE;
2133
2134 switch (expr.type) {
2135 case "ObjectPattern":
2136 for (var i = 0, list = expr.properties; i < list.length; i += 1) {
2137 var prop = list[i];
2138
2139 this.checkLValInnerPattern(prop, bindingType, checkClashes);
2140 }
2141 break
2142
2143 case "ArrayPattern":
2144 for (var i$1 = 0, list$1 = expr.elements; i$1 < list$1.length; i$1 += 1) {
2145 var elem = list$1[i$1];
2146
2147 if (elem) { this.checkLValInnerPattern(elem, bindingType, checkClashes); }
2148 }
2149 break
2150
2151 default:
2152 this.checkLValSimple(expr, bindingType, checkClashes);
2153 }
2154 };
2155
2156 pp$7.checkLValInnerPattern = function(expr, bindingType, checkClashes) {
2157 if ( bindingType === void 0 ) bindingType = BIND_NONE;
2158
2159 switch (expr.type) {
2160 case "Property":
2161 // AssignmentProperty has type === "Property"
2162 this.checkLValInnerPattern(expr.value, bindingType, checkClashes);
2163 break
2164
2165 case "AssignmentPattern":
2166 this.checkLValPattern(expr.left, bindingType, checkClashes);
2167 break
2168
2169 case "RestElement":
2170 this.checkLValPattern(expr.argument, bindingType, checkClashes);
2171 break
2172
2173 default:
2174 this.checkLValPattern(expr, bindingType, checkClashes);
2175 }
2176 };
2177
2178 // The algorithm used to determine whether a regexp can appear at a
2179
2180 var TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) {
2181 this.token = token;
2182 this.isExpr = !!isExpr;
2183 this.preserveSpace = !!preserveSpace;
2184 this.override = override;
2185 this.generator = !!generator;
2186 };
2187
2188 var types = {
2189 b_stat: new TokContext("{", false),
2190 b_expr: new TokContext("{", true),
2191 b_tmpl: new TokContext("${", false),
2192 p_stat: new TokContext("(", false),
2193 p_expr: new TokContext("(", true),
2194 q_tmpl: new TokContext("`", true, true, function (p) { return p.tryReadTemplateToken(); }),
2195 f_stat: new TokContext("function", false),
2196 f_expr: new TokContext("function", true),
2197 f_expr_gen: new TokContext("function", true, false, null, true),
2198 f_gen: new TokContext("function", false, false, null, true)
2199 };
2200
2201 var pp$6 = Parser.prototype;
2202
2203 pp$6.initialContext = function() {
2204 return [types.b_stat]
2205 };
2206
2207 pp$6.curContext = function() {
2208 return this.context[this.context.length - 1]
2209 };
2210
2211 pp$6.braceIsBlock = function(prevType) {
2212 var parent = this.curContext();
2213 if (parent === types.f_expr || parent === types.f_stat)
2214 { return true }
2215 if (prevType === types$1.colon && (parent === types.b_stat || parent === types.b_expr))
2216 { return !parent.isExpr }
2217
2218 // The check for `tt.name && exprAllowed` detects whether we are
2219 // after a `yield` or `of` construct. See the `updateContext` for
2220 // `tt.name`.
2221 if (prevType === types$1._return || prevType === types$1.name && this.exprAllowed)
2222 { return lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) }
2223 if (prevType === types$1._else || prevType === types$1.semi || prevType === types$1.eof || prevType === types$1.parenR || prevType === types$1.arrow)
2224 { return true }
2225 if (prevType === types$1.braceL)
2226 { return parent === types.b_stat }
2227 if (prevType === types$1._var || prevType === types$1._const || prevType === types$1.name)
2228 { return false }
2229 return !this.exprAllowed
2230 };
2231
2232 pp$6.inGeneratorContext = function() {
2233 for (var i = this.context.length - 1; i >= 1; i--) {
2234 var context = this.context[i];
2235 if (context.token === "function")
2236 { return context.generator }
2237 }
2238 return false
2239 };
2240
2241 pp$6.updateContext = function(prevType) {
2242 var update, type = this.type;
2243 if (type.keyword && prevType === types$1.dot)
2244 { this.exprAllowed = false; }
2245 else if (update = type.updateContext)
2246 { update.call(this, prevType); }
2247 else
2248 { this.exprAllowed = type.beforeExpr; }
2249 };
2250
2251 // Used to handle egde case when token context could not be inferred correctly in tokenize phase
2252 pp$6.overrideContext = function(tokenCtx) {
2253 if (this.curContext() !== tokenCtx) {
2254 this.context[this.context.length - 1] = tokenCtx;
2255 }
2256 };
2257
2258 // Token-specific context update code
2259
2260 types$1.parenR.updateContext = types$1.braceR.updateContext = function() {
2261 if (this.context.length === 1) {
2262 this.exprAllowed = true;
2263 return
2264 }
2265 var out = this.context.pop();
2266 if (out === types.b_stat && this.curContext().token === "function") {
2267 out = this.context.pop();
2268 }
2269 this.exprAllowed = !out.isExpr;
2270 };
2271
2272 types$1.braceL.updateContext = function(prevType) {
2273 this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr);
2274 this.exprAllowed = true;
2275 };
2276
2277 types$1.dollarBraceL.updateContext = function() {
2278 this.context.push(types.b_tmpl);
2279 this.exprAllowed = true;
2280 };
2281
2282 types$1.parenL.updateContext = function(prevType) {
2283 var statementParens = prevType === types$1._if || prevType === types$1._for || prevType === types$1._with || prevType === types$1._while;
2284 this.context.push(statementParens ? types.p_stat : types.p_expr);
2285 this.exprAllowed = true;
2286 };
2287
2288 types$1.incDec.updateContext = function() {
2289 // tokExprAllowed stays unchanged
2290 };
2291
2292 types$1._function.updateContext = types$1._class.updateContext = function(prevType) {
2293 if (prevType.beforeExpr && prevType !== types$1._else &&
2294 !(prevType === types$1.semi && this.curContext() !== types.p_stat) &&
2295 !(prevType === types$1._return && lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) &&
2296 !((prevType === types$1.colon || prevType === types$1.braceL) && this.curContext() === types.b_stat))
2297 { this.context.push(types.f_expr); }
2298 else
2299 { this.context.push(types.f_stat); }
2300 this.exprAllowed = false;
2301 };
2302
2303 types$1.backQuote.updateContext = function() {
2304 if (this.curContext() === types.q_tmpl)
2305 { this.context.pop(); }
2306 else
2307 { this.context.push(types.q_tmpl); }
2308 this.exprAllowed = false;
2309 };
2310
2311 types$1.star.updateContext = function(prevType) {
2312 if (prevType === types$1._function) {
2313 var index = this.context.length - 1;
2314 if (this.context[index] === types.f_expr)
2315 { this.context[index] = types.f_expr_gen; }
2316 else
2317 { this.context[index] = types.f_gen; }
2318 }
2319 this.exprAllowed = true;
2320 };
2321
2322 types$1.name.updateContext = function(prevType) {
2323 var allowed = false;
2324 if (this.options.ecmaVersion >= 6 && prevType !== types$1.dot) {
2325 if (this.value === "of" && !this.exprAllowed ||
2326 this.value === "yield" && this.inGeneratorContext())
2327 { allowed = true; }
2328 }
2329 this.exprAllowed = allowed;
2330 };
2331
2332 // A recursive descent parser operates by defining functions for all
2333
2334 var pp$5 = Parser.prototype;
2335
2336 // Check if property name clashes with already added.
2337 // Object/class getters and setters are not allowed to clash —
2338 // either with each other or with an init property — and in
2339 // strict mode, init properties are also not allowed to be repeated.
2340
2341 pp$5.checkPropClash = function(prop, propHash, refDestructuringErrors) {
2342 if (this.options.ecmaVersion >= 9 && prop.type === "SpreadElement")
2343 { return }
2344 if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand))
2345 { return }
2346 var key = prop.key;
2347 var name;
2348 switch (key.type) {
2349 case "Identifier": name = key.name; break
2350 case "Literal": name = String(key.value); break
2351 default: return
2352 }
2353 var kind = prop.kind;
2354 if (this.options.ecmaVersion >= 6) {
2355 if (name === "__proto__" && kind === "init") {
2356 if (propHash.proto) {
2357 if (refDestructuringErrors) {
2358 if (refDestructuringErrors.doubleProto < 0) {
2359 refDestructuringErrors.doubleProto = key.start;
2360 }
2361 } else {
2362 this.raiseRecoverable(key.start, "Redefinition of __proto__ property");
2363 }
2364 }
2365 propHash.proto = true;
2366 }
2367 return
2368 }
2369 name = "$" + name;
2370 var other = propHash[name];
2371 if (other) {
2372 var redefinition;
2373 if (kind === "init") {
2374 redefinition = this.strict && other.init || other.get || other.set;
2375 } else {
2376 redefinition = other.init || other[kind];
2377 }
2378 if (redefinition)
2379 { this.raiseRecoverable(key.start, "Redefinition of property"); }
2380 } else {
2381 other = propHash[name] = {
2382 init: false,
2383 get: false,
2384 set: false
2385 };
2386 }
2387 other[kind] = true;
2388 };
2389
2390 // ### Expression parsing
2391
2392 // These nest, from the most general expression type at the top to
2393 // 'atomic', nondivisible expression types at the bottom. Most of
2394 // the functions will simply let the function(s) below them parse,
2395 // and, *if* the syntactic construct they handle is present, wrap
2396 // the AST node that the inner parser gave them in another node.
2397
2398 // Parse a full expression. The optional arguments are used to
2399 // forbid the `in` operator (in for loops initalization expressions)
2400 // and provide reference for storing '=' operator inside shorthand
2401 // property assignment in contexts where both object expression
2402 // and object pattern might appear (so it's possible to raise
2403 // delayed syntax error at correct position).
2404
2405 pp$5.parseExpression = function(forInit, refDestructuringErrors) {
2406 var startPos = this.start, startLoc = this.startLoc;
2407 var expr = this.parseMaybeAssign(forInit, refDestructuringErrors);
2408 if (this.type === types$1.comma) {
2409 var node = this.startNodeAt(startPos, startLoc);
2410 node.expressions = [expr];
2411 while (this.eat(types$1.comma)) { node.expressions.push(this.parseMaybeAssign(forInit, refDestructuringErrors)); }
2412 return this.finishNode(node, "SequenceExpression")
2413 }
2414 return expr
2415 };
2416
2417 // Parse an assignment expression. This includes applications of
2418 // operators like `+=`.
2419
2420 pp$5.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse) {
2421 if (this.isContextual("yield")) {
2422 if (this.inGenerator) { return this.parseYield(forInit) }
2423 // The tokenizer will assume an expression is allowed after
2424 // `yield`, but this isn't that kind of yield
2425 else { this.exprAllowed = false; }
2426 }
2427
2428 var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1, oldDoubleProto = -1;
2429 if (refDestructuringErrors) {
2430 oldParenAssign = refDestructuringErrors.parenthesizedAssign;
2431 oldTrailingComma = refDestructuringErrors.trailingComma;
2432 oldDoubleProto = refDestructuringErrors.doubleProto;
2433 refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1;
2434 } else {
2435 refDestructuringErrors = new DestructuringErrors;
2436 ownDestructuringErrors = true;
2437 }
2438
2439 var startPos = this.start, startLoc = this.startLoc;
2440 if (this.type === types$1.parenL || this.type === types$1.name) {
2441 this.potentialArrowAt = this.start;
2442 this.potentialArrowInForAwait = forInit === "await";
2443 }
2444 var left = this.parseMaybeConditional(forInit, refDestructuringErrors);
2445 if (afterLeftParse) { left = afterLeftParse.call(this, left, startPos, startLoc); }
2446 if (this.type.isAssign) {
2447 var node = this.startNodeAt(startPos, startLoc);
2448 node.operator = this.value;
2449 if (this.type === types$1.eq)
2450 { left = this.toAssignable(left, false, refDestructuringErrors); }
2451 if (!ownDestructuringErrors) {
2452 refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.doubleProto = -1;
2453 }
2454 if (refDestructuringErrors.shorthandAssign >= left.start)
2455 { refDestructuringErrors.shorthandAssign = -1; } // reset because shorthand default was used correctly
2456 if (this.type === types$1.eq)
2457 { this.checkLValPattern(left); }
2458 else
2459 { this.checkLValSimple(left); }
2460 node.left = left;
2461 this.next();
2462 node.right = this.parseMaybeAssign(forInit);
2463 if (oldDoubleProto > -1) { refDestructuringErrors.doubleProto = oldDoubleProto; }
2464 return this.finishNode(node, "AssignmentExpression")
2465 } else {
2466 if (ownDestructuringErrors) { this.checkExpressionErrors(refDestructuringErrors, true); }
2467 }
2468 if (oldParenAssign > -1) { refDestructuringErrors.parenthesizedAssign = oldParenAssign; }
2469 if (oldTrailingComma > -1) { refDestructuringErrors.trailingComma = oldTrailingComma; }
2470 return left
2471 };
2472
2473 // Parse a ternary conditional (`?:`) operator.
2474
2475 pp$5.parseMaybeConditional = function(forInit, refDestructuringErrors) {
2476 var startPos = this.start, startLoc = this.startLoc;
2477 var expr = this.parseExprOps(forInit, refDestructuringErrors);
2478 if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
2479 if (this.eat(types$1.question)) {
2480 var node = this.startNodeAt(startPos, startLoc);
2481 node.test = expr;
2482 node.consequent = this.parseMaybeAssign();
2483 this.expect(types$1.colon);
2484 node.alternate = this.parseMaybeAssign(forInit);
2485 return this.finishNode(node, "ConditionalExpression")
2486 }
2487 return expr
2488 };
2489
2490 // Start the precedence parser.
2491
2492 pp$5.parseExprOps = function(forInit, refDestructuringErrors) {
2493 var startPos = this.start, startLoc = this.startLoc;
2494 var expr = this.parseMaybeUnary(refDestructuringErrors, false, false, forInit);
2495 if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
2496 return expr.start === startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, forInit)
2497 };
2498
2499 // Parse binary operators with the operator precedence parsing
2500 // algorithm. `left` is the left-hand side of the operator.
2501 // `minPrec` provides context that allows the function to stop and
2502 // defer further parser to one of its callers when it encounters an
2503 // operator that has a lower precedence than the set it is parsing.
2504
2505 pp$5.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, forInit) {
2506 var prec = this.type.binop;
2507 if (prec != null && (!forInit || this.type !== types$1._in)) {
2508 if (prec > minPrec) {
2509 var logical = this.type === types$1.logicalOR || this.type === types$1.logicalAND;
2510 var coalesce = this.type === types$1.coalesce;
2511 if (coalesce) {
2512 // Handle the precedence of `tt.coalesce` as equal to the range of logical expressions.
2513 // In other words, `node.right` shouldn't contain logical expressions in order to check the mixed error.
2514 prec = types$1.logicalAND.binop;
2515 }
2516 var op = this.value;
2517 this.next();
2518 var startPos = this.start, startLoc = this.startLoc;
2519 var right = this.parseExprOp(this.parseMaybeUnary(null, false, false, forInit), startPos, startLoc, prec, forInit);
2520 var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical || coalesce);
2521 if ((logical && this.type === types$1.coalesce) || (coalesce && (this.type === types$1.logicalOR || this.type === types$1.logicalAND))) {
2522 this.raiseRecoverable(this.start, "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses");
2523 }
2524 return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, forInit)
2525 }
2526 }
2527 return left
2528 };
2529
2530 pp$5.buildBinary = function(startPos, startLoc, left, right, op, logical) {
2531 if (right.type === "PrivateIdentifier") { this.raise(right.start, "Private identifier can only be left side of binary expression"); }
2532 var node = this.startNodeAt(startPos, startLoc);
2533 node.left = left;
2534 node.operator = op;
2535 node.right = right;
2536 return this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression")
2537 };
2538
2539 // Parse unary operators, both prefix and postfix.
2540
2541 pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forInit) {
2542 var startPos = this.start, startLoc = this.startLoc, expr;
2543 if (this.isContextual("await") && this.canAwait) {
2544 expr = this.parseAwait(forInit);
2545 sawUnary = true;
2546 } else if (this.type.prefix) {
2547 var node = this.startNode(), update = this.type === types$1.incDec;
2548 node.operator = this.value;
2549 node.prefix = true;
2550 this.next();
2551 node.argument = this.parseMaybeUnary(null, true, update, forInit);
2552 this.checkExpressionErrors(refDestructuringErrors, true);
2553 if (update) { this.checkLValSimple(node.argument); }
2554 else if (this.strict && node.operator === "delete" &&
2555 node.argument.type === "Identifier")
2556 { this.raiseRecoverable(node.start, "Deleting local variable in strict mode"); }
2557 else if (node.operator === "delete" && isPrivateFieldAccess(node.argument))
2558 { this.raiseRecoverable(node.start, "Private fields can not be deleted"); }
2559 else { sawUnary = true; }
2560 expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
2561 } else if (!sawUnary && this.type === types$1.privateId) {
2562 if (forInit || this.privateNameStack.length === 0) { this.unexpected(); }
2563 expr = this.parsePrivateIdent();
2564 // only could be private fields in 'in', such as #x in obj
2565 if (this.type !== types$1._in) { this.unexpected(); }
2566 } else {
2567 expr = this.parseExprSubscripts(refDestructuringErrors, forInit);
2568 if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
2569 while (this.type.postfix && !this.canInsertSemicolon()) {
2570 var node$1 = this.startNodeAt(startPos, startLoc);
2571 node$1.operator = this.value;
2572 node$1.prefix = false;
2573 node$1.argument = expr;
2574 this.checkLValSimple(expr);
2575 this.next();
2576 expr = this.finishNode(node$1, "UpdateExpression");
2577 }
2578 }
2579
2580 if (!incDec && this.eat(types$1.starstar)) {
2581 if (sawUnary)
2582 { this.unexpected(this.lastTokStart); }
2583 else
2584 { return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false, false, forInit), "**", false) }
2585 } else {
2586 return expr
2587 }
2588 };
2589
2590 function isPrivateFieldAccess(node) {
2591 return (
2592 node.type === "MemberExpression" && node.property.type === "PrivateIdentifier" ||
2593 node.type === "ChainExpression" && isPrivateFieldAccess(node.expression)
2594 )
2595 }
2596
2597 // Parse call, dot, and `[]`-subscript expressions.
2598
2599 pp$5.parseExprSubscripts = function(refDestructuringErrors, forInit) {
2600 var startPos = this.start, startLoc = this.startLoc;
2601 var expr = this.parseExprAtom(refDestructuringErrors, forInit);
2602 if (expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")")
2603 { return expr }
2604 var result = this.parseSubscripts(expr, startPos, startLoc, false, forInit);
2605 if (refDestructuringErrors && result.type === "MemberExpression") {
2606 if (refDestructuringErrors.parenthesizedAssign >= result.start) { refDestructuringErrors.parenthesizedAssign = -1; }
2607 if (refDestructuringErrors.parenthesizedBind >= result.start) { refDestructuringErrors.parenthesizedBind = -1; }
2608 if (refDestructuringErrors.trailingComma >= result.start) { refDestructuringErrors.trailingComma = -1; }
2609 }
2610 return result
2611 };
2612
2613 pp$5.parseSubscripts = function(base, startPos, startLoc, noCalls, forInit) {
2614 var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" &&
2615 this.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 &&
2616 this.potentialArrowAt === base.start;
2617 var optionalChained = false;
2618
2619 while (true) {
2620 var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit);
2621
2622 if (element.optional) { optionalChained = true; }
2623 if (element === base || element.type === "ArrowFunctionExpression") {
2624 if (optionalChained) {
2625 var chainNode = this.startNodeAt(startPos, startLoc);
2626 chainNode.expression = element;
2627 element = this.finishNode(chainNode, "ChainExpression");
2628 }
2629 return element
2630 }
2631
2632 base = element;
2633 }
2634 };
2635
2636 pp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit) {
2637 var optionalSupported = this.options.ecmaVersion >= 11;
2638 var optional = optionalSupported && this.eat(types$1.questionDot);
2639 if (noCalls && optional) { this.raise(this.lastTokStart, "Optional chaining cannot appear in the callee of new expressions"); }
2640
2641 var computed = this.eat(types$1.bracketL);
2642 if (computed || (optional && this.type !== types$1.parenL && this.type !== types$1.backQuote) || this.eat(types$1.dot)) {
2643 var node = this.startNodeAt(startPos, startLoc);
2644 node.object = base;
2645 if (computed) {
2646 node.property = this.parseExpression();
2647 this.expect(types$1.bracketR);
2648 } else if (this.type === types$1.privateId && base.type !== "Super") {
2649 node.property = this.parsePrivateIdent();
2650 } else {
2651 node.property = this.parseIdent(this.options.allowReserved !== "never");
2652 }
2653 node.computed = !!computed;
2654 if (optionalSupported) {
2655 node.optional = optional;
2656 }
2657 base = this.finishNode(node, "MemberExpression");
2658 } else if (!noCalls && this.eat(types$1.parenL)) {
2659 var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
2660 this.yieldPos = 0;
2661 this.awaitPos = 0;
2662 this.awaitIdentPos = 0;
2663 var exprList = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors);
2664 if (maybeAsyncArrow && !optional && !this.canInsertSemicolon() && this.eat(types$1.arrow)) {
2665 this.checkPatternErrors(refDestructuringErrors, false);
2666 this.checkYieldAwaitInDefaultParams();
2667 if (this.awaitIdentPos > 0)
2668 { this.raise(this.awaitIdentPos, "Cannot use 'await' as identifier inside an async function"); }
2669 this.yieldPos = oldYieldPos;
2670 this.awaitPos = oldAwaitPos;
2671 this.awaitIdentPos = oldAwaitIdentPos;
2672 return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true, forInit)
2673 }
2674 this.checkExpressionErrors(refDestructuringErrors, true);
2675 this.yieldPos = oldYieldPos || this.yieldPos;
2676 this.awaitPos = oldAwaitPos || this.awaitPos;
2677 this.awaitIdentPos = oldAwaitIdentPos || this.awaitIdentPos;
2678 var node$1 = this.startNodeAt(startPos, startLoc);
2679 node$1.callee = base;
2680 node$1.arguments = exprList;
2681 if (optionalSupported) {
2682 node$1.optional = optional;
2683 }
2684 base = this.finishNode(node$1, "CallExpression");
2685 } else if (this.type === types$1.backQuote) {
2686 if (optional || optionalChained) {
2687 this.raise(this.start, "Optional chaining cannot appear in the tag of tagged template expressions");
2688 }
2689 var node$2 = this.startNodeAt(startPos, startLoc);
2690 node$2.tag = base;
2691 node$2.quasi = this.parseTemplate({isTagged: true});
2692 base = this.finishNode(node$2, "TaggedTemplateExpression");
2693 }
2694 return base
2695 };
2696
2697 // Parse an atomic expression — either a single token that is an
2698 // expression, an expression started by a keyword like `function` or
2699 // `new`, or an expression wrapped in punctuation like `()`, `[]`,
2700 // or `{}`.
2701
2702 pp$5.parseExprAtom = function(refDestructuringErrors, forInit) {
2703 // If a division operator appears in an expression position, the
2704 // tokenizer got confused, and we force it to read a regexp instead.
2705 if (this.type === types$1.slash) { this.readRegexp(); }
2706
2707 var node, canBeArrow = this.potentialArrowAt === this.start;
2708 switch (this.type) {
2709 case types$1._super:
2710 if (!this.allowSuper)
2711 { this.raise(this.start, "'super' keyword outside a method"); }
2712 node = this.startNode();
2713 this.next();
2714 if (this.type === types$1.parenL && !this.allowDirectSuper)
2715 { this.raise(node.start, "super() call outside constructor of a subclass"); }
2716 // The `super` keyword can appear at below:
2717 // SuperProperty:
2718 // super [ Expression ]
2719 // super . IdentifierName
2720 // SuperCall:
2721 // super ( Arguments )
2722 if (this.type !== types$1.dot && this.type !== types$1.bracketL && this.type !== types$1.parenL)
2723 { this.unexpected(); }
2724 return this.finishNode(node, "Super")
2725
2726 case types$1._this:
2727 node = this.startNode();
2728 this.next();
2729 return this.finishNode(node, "ThisExpression")
2730
2731 case types$1.name:
2732 var startPos = this.start, startLoc = this.startLoc, containsEsc = this.containsEsc;
2733 var id = this.parseIdent(false);
2734 if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === "async" && !this.canInsertSemicolon() && this.eat(types$1._function)) {
2735 this.overrideContext(types.f_expr);
2736 return this.parseFunction(this.startNodeAt(startPos, startLoc), 0, false, true, forInit)
2737 }
2738 if (canBeArrow && !this.canInsertSemicolon()) {
2739 if (this.eat(types$1.arrow))
2740 { return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false, forInit) }
2741 if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === types$1.name && !containsEsc &&
2742 (!this.potentialArrowInForAwait || this.value !== "of" || this.containsEsc)) {
2743 id = this.parseIdent(false);
2744 if (this.canInsertSemicolon() || !this.eat(types$1.arrow))
2745 { this.unexpected(); }
2746 return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true, forInit)
2747 }
2748 }
2749 return id
2750
2751 case types$1.regexp:
2752 var value = this.value;
2753 node = this.parseLiteral(value.value);
2754 node.regex = {pattern: value.pattern, flags: value.flags};
2755 return node
2756
2757 case types$1.num: case types$1.string:
2758 return this.parseLiteral(this.value)
2759
2760 case types$1._null: case types$1._true: case types$1._false:
2761 node = this.startNode();
2762 node.value = this.type === types$1._null ? null : this.type === types$1._true;
2763 node.raw = this.type.keyword;
2764 this.next();
2765 return this.finishNode(node, "Literal")
2766
2767 case types$1.parenL:
2768 var start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow, forInit);
2769 if (refDestructuringErrors) {
2770 if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr))
2771 { refDestructuringErrors.parenthesizedAssign = start; }
2772 if (refDestructuringErrors.parenthesizedBind < 0)
2773 { refDestructuringErrors.parenthesizedBind = start; }
2774 }
2775 return expr
2776
2777 case types$1.bracketL:
2778 node = this.startNode();
2779 this.next();
2780 node.elements = this.parseExprList(types$1.bracketR, true, true, refDestructuringErrors);
2781 return this.finishNode(node, "ArrayExpression")
2782
2783 case types$1.braceL:
2784 this.overrideContext(types.b_expr);
2785 return this.parseObj(false, refDestructuringErrors)
2786
2787 case types$1._function:
2788 node = this.startNode();
2789 this.next();
2790 return this.parseFunction(node, 0)
2791
2792 case types$1._class:
2793 return this.parseClass(this.startNode(), false)
2794
2795 case types$1._new:
2796 return this.parseNew()
2797
2798 case types$1.backQuote:
2799 return this.parseTemplate()
2800
2801 case types$1._import:
2802 if (this.options.ecmaVersion >= 11) {
2803 return this.parseExprImport()
2804 } else {
2805 return this.unexpected()
2806 }
2807
2808 default:
2809 this.unexpected();
2810 }
2811 };
2812
2813 pp$5.parseExprImport = function() {
2814 var node = this.startNode();
2815
2816 // Consume `import` as an identifier for `import.meta`.
2817 // Because `this.parseIdent(true)` doesn't check escape sequences, it needs the check of `this.containsEsc`.
2818 if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword import"); }
2819 var meta = this.parseIdent(true);
2820
2821 switch (this.type) {
2822 case types$1.parenL:
2823 return this.parseDynamicImport(node)
2824 case types$1.dot:
2825 node.meta = meta;
2826 return this.parseImportMeta(node)
2827 default:
2828 this.unexpected();
2829 }
2830 };
2831
2832 pp$5.parseDynamicImport = function(node) {
2833 this.next(); // skip `(`
2834
2835 // Parse node.source.
2836 node.source = this.parseMaybeAssign();
2837
2838 // Verify ending.
2839 if (!this.eat(types$1.parenR)) {
2840 var errorPos = this.start;
2841 if (this.eat(types$1.comma) && this.eat(types$1.parenR)) {
2842 this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()");
2843 } else {
2844 this.unexpected(errorPos);
2845 }
2846 }
2847
2848 return this.finishNode(node, "ImportExpression")
2849 };
2850
2851 pp$5.parseImportMeta = function(node) {
2852 this.next(); // skip `.`
2853
2854 var containsEsc = this.containsEsc;
2855 node.property = this.parseIdent(true);
2856
2857 if (node.property.name !== "meta")
2858 { this.raiseRecoverable(node.property.start, "The only valid meta property for import is 'import.meta'"); }
2859 if (containsEsc)
2860 { this.raiseRecoverable(node.start, "'import.meta' must not contain escaped characters"); }
2861 if (this.options.sourceType !== "module" && !this.options.allowImportExportEverywhere)
2862 { this.raiseRecoverable(node.start, "Cannot use 'import.meta' outside a module"); }
2863
2864 return this.finishNode(node, "MetaProperty")
2865 };
2866
2867 pp$5.parseLiteral = function(value) {
2868 var node = this.startNode();
2869 node.value = value;
2870 node.raw = this.input.slice(this.start, this.end);
2871 if (node.raw.charCodeAt(node.raw.length - 1) === 110) { node.bigint = node.raw.slice(0, -1).replace(/_/g, ""); }
2872 this.next();
2873 return this.finishNode(node, "Literal")
2874 };
2875
2876 pp$5.parseParenExpression = function() {
2877 this.expect(types$1.parenL);
2878 var val = this.parseExpression();
2879 this.expect(types$1.parenR);
2880 return val
2881 };
2882
2883 pp$5.parseParenAndDistinguishExpression = function(canBeArrow, forInit) {
2884 var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8;
2885 if (this.options.ecmaVersion >= 6) {
2886 this.next();
2887
2888 var innerStartPos = this.start, innerStartLoc = this.startLoc;
2889 var exprList = [], first = true, lastIsComma = false;
2890 var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart;
2891 this.yieldPos = 0;
2892 this.awaitPos = 0;
2893 // Do not save awaitIdentPos to allow checking awaits nested in parameters
2894 while (this.type !== types$1.parenR) {
2895 first ? first = false : this.expect(types$1.comma);
2896 if (allowTrailingComma && this.afterTrailingComma(types$1.parenR, true)) {
2897 lastIsComma = true;
2898 break
2899 } else if (this.type === types$1.ellipsis) {
2900 spreadStart = this.start;
2901 exprList.push(this.parseParenItem(this.parseRestBinding()));
2902 if (this.type === types$1.comma) { this.raise(this.start, "Comma is not permitted after the rest element"); }
2903 break
2904 } else {
2905 exprList.push(this.parseMaybeAssign(false, refDestructuringErrors, this.parseParenItem));
2906 }
2907 }
2908 var innerEndPos = this.lastTokEnd, innerEndLoc = this.lastTokEndLoc;
2909 this.expect(types$1.parenR);
2910
2911 if (canBeArrow && !this.canInsertSemicolon() && this.eat(types$1.arrow)) {
2912 this.checkPatternErrors(refDestructuringErrors, false);
2913 this.checkYieldAwaitInDefaultParams();
2914 this.yieldPos = oldYieldPos;
2915 this.awaitPos = oldAwaitPos;
2916 return this.parseParenArrowList(startPos, startLoc, exprList, forInit)
2917 }
2918
2919 if (!exprList.length || lastIsComma) { this.unexpected(this.lastTokStart); }
2920 if (spreadStart) { this.unexpected(spreadStart); }
2921 this.checkExpressionErrors(refDestructuringErrors, true);
2922 this.yieldPos = oldYieldPos || this.yieldPos;
2923 this.awaitPos = oldAwaitPos || this.awaitPos;
2924
2925 if (exprList.length > 1) {
2926 val = this.startNodeAt(innerStartPos, innerStartLoc);
2927 val.expressions = exprList;
2928 this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc);
2929 } else {
2930 val = exprList[0];
2931 }
2932 } else {
2933 val = this.parseParenExpression();
2934 }
2935
2936 if (this.options.preserveParens) {
2937 var par = this.startNodeAt(startPos, startLoc);
2938 par.expression = val;
2939 return this.finishNode(par, "ParenthesizedExpression")
2940 } else {
2941 return val
2942 }
2943 };
2944
2945 pp$5.parseParenItem = function(item) {
2946 return item
2947 };
2948
2949 pp$5.parseParenArrowList = function(startPos, startLoc, exprList, forInit) {
2950 return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, false, forInit)
2951 };
2952
2953 // New's precedence is slightly tricky. It must allow its argument to
2954 // be a `[]` or dot subscript expression, but not a call — at least,
2955 // not without wrapping it in parentheses. Thus, it uses the noCalls
2956 // argument to parseSubscripts to prevent it from consuming the
2957 // argument list.
2958
2959 var empty = [];
2960
2961 pp$5.parseNew = function() {
2962 if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword new"); }
2963 var node = this.startNode();
2964 var meta = this.parseIdent(true);
2965 if (this.options.ecmaVersion >= 6 && this.eat(types$1.dot)) {
2966 node.meta = meta;
2967 var containsEsc = this.containsEsc;
2968 node.property = this.parseIdent(true);
2969 if (node.property.name !== "target")
2970 { this.raiseRecoverable(node.property.start, "The only valid meta property for new is 'new.target'"); }
2971 if (containsEsc)
2972 { this.raiseRecoverable(node.start, "'new.target' must not contain escaped characters"); }
2973 if (!this.allowNewDotTarget)
2974 { this.raiseRecoverable(node.start, "'new.target' can only be used in functions and class static block"); }
2975 return this.finishNode(node, "MetaProperty")
2976 }
2977 var startPos = this.start, startLoc = this.startLoc, isImport = this.type === types$1._import;
2978 node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true, false);
2979 if (isImport && node.callee.type === "ImportExpression") {
2980 this.raise(startPos, "Cannot use new with import()");
2981 }
2982 if (this.eat(types$1.parenL)) { node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false); }
2983 else { node.arguments = empty; }
2984 return this.finishNode(node, "NewExpression")
2985 };
2986
2987 // Parse template expression.
2988
2989 pp$5.parseTemplateElement = function(ref) {
2990 var isTagged = ref.isTagged;
2991
2992 var elem = this.startNode();
2993 if (this.type === types$1.invalidTemplate) {
2994 if (!isTagged) {
2995 this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal");
2996 }
2997 elem.value = {
2998 raw: this.value,
2999 cooked: null
3000 };
3001 } else {
3002 elem.value = {
3003 raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, "\n"),
3004 cooked: this.value
3005 };
3006 }
3007 this.next();
3008 elem.tail = this.type === types$1.backQuote;
3009 return this.finishNode(elem, "TemplateElement")
3010 };
3011
3012 pp$5.parseTemplate = function(ref) {
3013 if ( ref === void 0 ) ref = {};
3014 var isTagged = ref.isTagged; if ( isTagged === void 0 ) isTagged = false;
3015
3016 var node = this.startNode();
3017 this.next();
3018 node.expressions = [];
3019 var curElt = this.parseTemplateElement({isTagged: isTagged});
3020 node.quasis = [curElt];
3021 while (!curElt.tail) {
3022 if (this.type === types$1.eof) { this.raise(this.pos, "Unterminated template literal"); }
3023 this.expect(types$1.dollarBraceL);
3024 node.expressions.push(this.parseExpression());
3025 this.expect(types$1.braceR);
3026 node.quasis.push(curElt = this.parseTemplateElement({isTagged: isTagged}));
3027 }
3028 this.next();
3029 return this.finishNode(node, "TemplateLiteral")
3030 };
3031
3032 pp$5.isAsyncProp = function(prop) {
3033 return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" &&
3034 (this.type === types$1.name || this.type === types$1.num || this.type === types$1.string || this.type === types$1.bracketL || this.type.keyword || (this.options.ecmaVersion >= 9 && this.type === types$1.star)) &&
3035 !lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
3036 };
3037
3038 // Parse an object literal or binding pattern.
3039
3040 pp$5.parseObj = function(isPattern, refDestructuringErrors) {
3041 var node = this.startNode(), first = true, propHash = {};
3042 node.properties = [];
3043 this.next();
3044 while (!this.eat(types$1.braceR)) {
3045 if (!first) {
3046 this.expect(types$1.comma);
3047 if (this.options.ecmaVersion >= 5 && this.afterTrailingComma(types$1.braceR)) { break }
3048 } else { first = false; }
3049
3050 var prop = this.parseProperty(isPattern, refDestructuringErrors);
3051 if (!isPattern) { this.checkPropClash(prop, propHash, refDestructuringErrors); }
3052 node.properties.push(prop);
3053 }
3054 return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression")
3055 };
3056
3057 pp$5.parseProperty = function(isPattern, refDestructuringErrors) {
3058 var prop = this.startNode(), isGenerator, isAsync, startPos, startLoc;
3059 if (this.options.ecmaVersion >= 9 && this.eat(types$1.ellipsis)) {
3060 if (isPattern) {
3061 prop.argument = this.parseIdent(false);
3062 if (this.type === types$1.comma) {
3063 this.raise(this.start, "Comma is not permitted after the rest element");
3064 }
3065 return this.finishNode(prop, "RestElement")
3066 }
3067 // To disallow parenthesized identifier via `this.toAssignable()`.
3068 if (this.type === types$1.parenL && refDestructuringErrors) {
3069 if (refDestructuringErrors.parenthesizedAssign < 0) {
3070 refDestructuringErrors.parenthesizedAssign = this.start;
3071 }
3072 if (refDestructuringErrors.parenthesizedBind < 0) {
3073 refDestructuringErrors.parenthesizedBind = this.start;
3074 }
3075 }
3076 // Parse argument.
3077 prop.argument = this.parseMaybeAssign(false, refDestructuringErrors);
3078 // To disallow trailing comma via `this.toAssignable()`.
3079 if (this.type === types$1.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0) {
3080 refDestructuringErrors.trailingComma = this.start;
3081 }
3082 // Finish
3083 return this.finishNode(prop, "SpreadElement")
3084 }
3085 if (this.options.ecmaVersion >= 6) {
3086 prop.method = false;
3087 prop.shorthand = false;
3088 if (isPattern || refDestructuringErrors) {
3089 startPos = this.start;
3090 startLoc = this.startLoc;
3091 }
3092 if (!isPattern)
3093 { isGenerator = this.eat(types$1.star); }
3094 }
3095 var containsEsc = this.containsEsc;
3096 this.parsePropertyName(prop);
3097 if (!isPattern && !containsEsc && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) {
3098 isAsync = true;
3099 isGenerator = this.options.ecmaVersion >= 9 && this.eat(types$1.star);
3100 this.parsePropertyName(prop, refDestructuringErrors);
3101 } else {
3102 isAsync = false;
3103 }
3104 this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc);
3105 return this.finishNode(prop, "Property")
3106 };
3107
3108 pp$5.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) {
3109 if ((isGenerator || isAsync) && this.type === types$1.colon)
3110 { this.unexpected(); }
3111
3112 if (this.eat(types$1.colon)) {
3113 prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors);
3114 prop.kind = "init";
3115 } else if (this.options.ecmaVersion >= 6 && this.type === types$1.parenL) {
3116 if (isPattern) { this.unexpected(); }
3117 prop.kind = "init";
3118 prop.method = true;
3119 prop.value = this.parseMethod(isGenerator, isAsync);
3120 } else if (!isPattern && !containsEsc &&
3121 this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" &&
3122 (prop.key.name === "get" || prop.key.name === "set") &&
3123 (this.type !== types$1.comma && this.type !== types$1.braceR && this.type !== types$1.eq)) {
3124 if (isGenerator || isAsync) { this.unexpected(); }
3125 prop.kind = prop.key.name;
3126 this.parsePropertyName(prop);
3127 prop.value = this.parseMethod(false);
3128 var paramCount = prop.kind === "get" ? 0 : 1;
3129 if (prop.value.params.length !== paramCount) {
3130 var start = prop.value.start;
3131 if (prop.kind === "get")
3132 { this.raiseRecoverable(start, "getter should have no params"); }
3133 else
3134 { this.raiseRecoverable(start, "setter should have exactly one param"); }
3135 } else {
3136 if (prop.kind === "set" && prop.value.params[0].type === "RestElement")
3137 { this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params"); }
3138 }
3139 } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
3140 if (isGenerator || isAsync) { this.unexpected(); }
3141 this.checkUnreserved(prop.key);
3142 if (prop.key.name === "await" && !this.awaitIdentPos)
3143 { this.awaitIdentPos = startPos; }
3144 prop.kind = "init";
3145 if (isPattern) {
3146 prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key));
3147 } else if (this.type === types$1.eq && refDestructuringErrors) {
3148 if (refDestructuringErrors.shorthandAssign < 0)
3149 { refDestructuringErrors.shorthandAssign = this.start; }
3150 prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key));
3151 } else {
3152 prop.value = this.copyNode(prop.key);
3153 }
3154 prop.shorthand = true;
3155 } else { this.unexpected(); }
3156 };
3157
3158 pp$5.parsePropertyName = function(prop) {
3159 if (this.options.ecmaVersion >= 6) {
3160 if (this.eat(types$1.bracketL)) {
3161 prop.computed = true;
3162 prop.key = this.parseMaybeAssign();
3163 this.expect(types$1.bracketR);
3164 return prop.key
3165 } else {
3166 prop.computed = false;
3167 }
3168 }
3169 return prop.key = this.type === types$1.num || this.type === types$1.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never")
3170 };
3171
3172 // Initialize empty function node.
3173
3174 pp$5.initFunction = function(node) {
3175 node.id = null;
3176 if (this.options.ecmaVersion >= 6) { node.generator = node.expression = false; }
3177 if (this.options.ecmaVersion >= 8) { node.async = false; }
3178 };
3179
3180 // Parse object or class method.
3181
3182 pp$5.parseMethod = function(isGenerator, isAsync, allowDirectSuper) {
3183 var node = this.startNode(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
3184
3185 this.initFunction(node);
3186 if (this.options.ecmaVersion >= 6)
3187 { node.generator = isGenerator; }
3188 if (this.options.ecmaVersion >= 8)
3189 { node.async = !!isAsync; }
3190
3191 this.yieldPos = 0;
3192 this.awaitPos = 0;
3193 this.awaitIdentPos = 0;
3194 this.enterScope(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0));
3195
3196 this.expect(types$1.parenL);
3197 node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8);
3198 this.checkYieldAwaitInDefaultParams();
3199 this.parseFunctionBody(node, false, true, false);
3200
3201 this.yieldPos = oldYieldPos;
3202 this.awaitPos = oldAwaitPos;
3203 this.awaitIdentPos = oldAwaitIdentPos;
3204 return this.finishNode(node, "FunctionExpression")
3205 };
3206
3207 // Parse arrow function expression with given parameters.
3208
3209 pp$5.parseArrowExpression = function(node, params, isAsync, forInit) {
3210 var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
3211
3212 this.enterScope(functionFlags(isAsync, false) | SCOPE_ARROW);
3213 this.initFunction(node);
3214 if (this.options.ecmaVersion >= 8) { node.async = !!isAsync; }
3215
3216 this.yieldPos = 0;
3217 this.awaitPos = 0;
3218 this.awaitIdentPos = 0;
3219
3220 node.params = this.toAssignableList(params, true);
3221 this.parseFunctionBody(node, true, false, forInit);
3222
3223 this.yieldPos = oldYieldPos;
3224 this.awaitPos = oldAwaitPos;
3225 this.awaitIdentPos = oldAwaitIdentPos;
3226 return this.finishNode(node, "ArrowFunctionExpression")
3227 };
3228
3229 // Parse function body and check parameters.
3230
3231 pp$5.parseFunctionBody = function(node, isArrowFunction, isMethod, forInit) {
3232 var isExpression = isArrowFunction && this.type !== types$1.braceL;
3233 var oldStrict = this.strict, useStrict = false;
3234
3235 if (isExpression) {
3236 node.body = this.parseMaybeAssign(forInit);
3237 node.expression = true;
3238 this.checkParams(node, false);
3239 } else {
3240 var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params);
3241 if (!oldStrict || nonSimple) {
3242 useStrict = this.strictDirective(this.end);
3243 // If this is a strict mode function, verify that argument names
3244 // are not repeated, and it does not try to bind the words `eval`
3245 // or `arguments`.
3246 if (useStrict && nonSimple)
3247 { this.raiseRecoverable(node.start, "Illegal 'use strict' directive in function with non-simple parameter list"); }
3248 }
3249 // Start a new scope with regard to labels and the `inFunction`
3250 // flag (restore them to their old value afterwards).
3251 var oldLabels = this.labels;
3252 this.labels = [];
3253 if (useStrict) { this.strict = true; }
3254
3255 // Add the params to varDeclaredNames to ensure that an error is thrown
3256 // if a let/const declaration in the function clashes with one of the params.
3257 this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params));
3258 // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval'
3259 if (this.strict && node.id) { this.checkLValSimple(node.id, BIND_OUTSIDE); }
3260 node.body = this.parseBlock(false, undefined, useStrict && !oldStrict);
3261 node.expression = false;
3262 this.adaptDirectivePrologue(node.body.body);
3263 this.labels = oldLabels;
3264 }
3265 this.exitScope();
3266 };
3267
3268 pp$5.isSimpleParamList = function(params) {
3269 for (var i = 0, list = params; i < list.length; i += 1)
3270 {
3271 var param = list[i];
3272
3273 if (param.type !== "Identifier") { return false
3274 } }
3275 return true
3276 };
3277
3278 // Checks function params for various disallowed patterns such as using "eval"
3279 // or "arguments" and duplicate parameters.
3280
3281 pp$5.checkParams = function(node, allowDuplicates) {
3282 var nameHash = Object.create(null);
3283 for (var i = 0, list = node.params; i < list.length; i += 1)
3284 {
3285 var param = list[i];
3286
3287 this.checkLValInnerPattern(param, BIND_VAR, allowDuplicates ? null : nameHash);
3288 }
3289 };
3290
3291 // Parses a comma-separated list of expressions, and returns them as
3292 // an array. `close` is the token type that ends the list, and
3293 // `allowEmpty` can be turned on to allow subsequent commas with
3294 // nothing in between them to be parsed as `null` (which is needed
3295 // for array literals).
3296
3297 pp$5.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) {
3298 var elts = [], first = true;
3299 while (!this.eat(close)) {
3300 if (!first) {
3301 this.expect(types$1.comma);
3302 if (allowTrailingComma && this.afterTrailingComma(close)) { break }
3303 } else { first = false; }
3304
3305 var elt = (void 0);
3306 if (allowEmpty && this.type === types$1.comma)
3307 { elt = null; }
3308 else if (this.type === types$1.ellipsis) {
3309 elt = this.parseSpread(refDestructuringErrors);
3310 if (refDestructuringErrors && this.type === types$1.comma && refDestructuringErrors.trailingComma < 0)
3311 { refDestructuringErrors.trailingComma = this.start; }
3312 } else {
3313 elt = this.parseMaybeAssign(false, refDestructuringErrors);
3314 }
3315 elts.push(elt);
3316 }
3317 return elts
3318 };
3319
3320 pp$5.checkUnreserved = function(ref) {
3321 var start = ref.start;
3322 var end = ref.end;
3323 var name = ref.name;
3324
3325 if (this.inGenerator && name === "yield")
3326 { this.raiseRecoverable(start, "Cannot use 'yield' as identifier inside a generator"); }
3327 if (this.inAsync && name === "await")
3328 { this.raiseRecoverable(start, "Cannot use 'await' as identifier inside an async function"); }
3329 if (this.currentThisScope().inClassFieldInit && name === "arguments")
3330 { this.raiseRecoverable(start, "Cannot use 'arguments' in class field initializer"); }
3331 if (this.inClassStaticBlock && (name === "arguments" || name === "await"))
3332 { this.raise(start, ("Cannot use " + name + " in class static initialization block")); }
3333 if (this.keywords.test(name))
3334 { this.raise(start, ("Unexpected keyword '" + name + "'")); }
3335 if (this.options.ecmaVersion < 6 &&
3336 this.input.slice(start, end).indexOf("\\") !== -1) { return }
3337 var re = this.strict ? this.reservedWordsStrict : this.reservedWords;
3338 if (re.test(name)) {
3339 if (!this.inAsync && name === "await")
3340 { this.raiseRecoverable(start, "Cannot use keyword 'await' outside an async function"); }
3341 this.raiseRecoverable(start, ("The keyword '" + name + "' is reserved"));
3342 }
3343 };
3344
3345 // Parse the next token as an identifier. If `liberal` is true (used
3346 // when parsing properties), it will also convert keywords into
3347 // identifiers.
3348
3349 pp$5.parseIdent = function(liberal, isBinding) {
3350 var node = this.startNode();
3351 if (this.type === types$1.name) {
3352 node.name = this.value;
3353 } else if (this.type.keyword) {
3354 node.name = this.type.keyword;
3355
3356 // To fix https://github.com/acornjs/acorn/issues/575
3357 // `class` and `function` keywords push new context into this.context.
3358 // But there is no chance to pop the context if the keyword is consumed as an identifier such as a property name.
3359 // If the previous token is a dot, this does not apply because the context-managing code already ignored the keyword
3360 if ((node.name === "class" || node.name === "function") &&
3361 (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) {
3362 this.context.pop();
3363 }
3364 } else {
3365 this.unexpected();
3366 }
3367 this.next(!!liberal);
3368 this.finishNode(node, "Identifier");
3369 if (!liberal) {
3370 this.checkUnreserved(node);
3371 if (node.name === "await" && !this.awaitIdentPos)
3372 { this.awaitIdentPos = node.start; }
3373 }
3374 return node
3375 };
3376
3377 pp$5.parsePrivateIdent = function() {
3378 var node = this.startNode();
3379 if (this.type === types$1.privateId) {
3380 node.name = this.value;
3381 } else {
3382 this.unexpected();
3383 }
3384 this.next();
3385 this.finishNode(node, "PrivateIdentifier");
3386
3387 // For validating existence
3388 if (this.privateNameStack.length === 0) {
3389 this.raise(node.start, ("Private field '#" + (node.name) + "' must be declared in an enclosing class"));
3390 } else {
3391 this.privateNameStack[this.privateNameStack.length - 1].used.push(node);
3392 }
3393
3394 return node
3395 };
3396
3397 // Parses yield expression inside generator.
3398
3399 pp$5.parseYield = function(forInit) {
3400 if (!this.yieldPos) { this.yieldPos = this.start; }
3401
3402 var node = this.startNode();
3403 this.next();
3404 if (this.type === types$1.semi || this.canInsertSemicolon() || (this.type !== types$1.star && !this.type.startsExpr)) {
3405 node.delegate = false;
3406 node.argument = null;
3407 } else {
3408 node.delegate = this.eat(types$1.star);
3409 node.argument = this.parseMaybeAssign(forInit);
3410 }
3411 return this.finishNode(node, "YieldExpression")
3412 };
3413
3414 pp$5.parseAwait = function(forInit) {
3415 if (!this.awaitPos) { this.awaitPos = this.start; }
3416
3417 var node = this.startNode();
3418 this.next();
3419 node.argument = this.parseMaybeUnary(null, true, false, forInit);
3420 return this.finishNode(node, "AwaitExpression")
3421 };
3422
3423 var pp$4 = Parser.prototype;
3424
3425 // This function is used to raise exceptions on parse errors. It
3426 // takes an offset integer (into the current `input`) to indicate
3427 // the location of the error, attaches the position to the end
3428 // of the error message, and then raises a `SyntaxError` with that
3429 // message.
3430
3431 pp$4.raise = function(pos, message) {
3432 var loc = getLineInfo(this.input, pos);
3433 message += " (" + loc.line + ":" + loc.column + ")";
3434 var err = new SyntaxError(message);
3435 err.pos = pos; err.loc = loc; err.raisedAt = this.pos;
3436 throw err
3437 };
3438
3439 pp$4.raiseRecoverable = pp$4.raise;
3440
3441 pp$4.curPosition = function() {
3442 if (this.options.locations) {
3443 return new Position(this.curLine, this.pos - this.lineStart)
3444 }
3445 };
3446
3447 var pp$3 = Parser.prototype;
3448
3449 var Scope = function Scope(flags) {
3450 this.flags = flags;
3451 // A list of var-declared names in the current lexical scope
3452 this.var = [];
3453 // A list of lexically-declared names in the current lexical scope
3454 this.lexical = [];
3455 // A list of lexically-declared FunctionDeclaration names in the current lexical scope
3456 this.functions = [];
3457 // A switch to disallow the identifier reference 'arguments'
3458 this.inClassFieldInit = false;
3459 };
3460
3461 // The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names.
3462
3463 pp$3.enterScope = function(flags) {
3464 this.scopeStack.push(new Scope(flags));
3465 };
3466
3467 pp$3.exitScope = function() {
3468 this.scopeStack.pop();
3469 };
3470
3471 // The spec says:
3472 // > At the top level of a function, or script, function declarations are
3473 // > treated like var declarations rather than like lexical declarations.
3474 pp$3.treatFunctionsAsVarInScope = function(scope) {
3475 return (scope.flags & SCOPE_FUNCTION) || !this.inModule && (scope.flags & SCOPE_TOP)
3476 };
3477
3478 pp$3.declareName = function(name, bindingType, pos) {
3479 var redeclared = false;
3480 if (bindingType === BIND_LEXICAL) {
3481 var scope = this.currentScope();
3482 redeclared = scope.lexical.indexOf(name) > -1 || scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1;
3483 scope.lexical.push(name);
3484 if (this.inModule && (scope.flags & SCOPE_TOP))
3485 { delete this.undefinedExports[name]; }
3486 } else if (bindingType === BIND_SIMPLE_CATCH) {
3487 var scope$1 = this.currentScope();
3488 scope$1.lexical.push(name);
3489 } else if (bindingType === BIND_FUNCTION) {
3490 var scope$2 = this.currentScope();
3491 if (this.treatFunctionsAsVar)
3492 { redeclared = scope$2.lexical.indexOf(name) > -1; }
3493 else
3494 { redeclared = scope$2.lexical.indexOf(name) > -1 || scope$2.var.indexOf(name) > -1; }
3495 scope$2.functions.push(name);
3496 } else {
3497 for (var i = this.scopeStack.length - 1; i >= 0; --i) {
3498 var scope$3 = this.scopeStack[i];
3499 if (scope$3.lexical.indexOf(name) > -1 && !((scope$3.flags & SCOPE_SIMPLE_CATCH) && scope$3.lexical[0] === name) ||
3500 !this.treatFunctionsAsVarInScope(scope$3) && scope$3.functions.indexOf(name) > -1) {
3501 redeclared = true;
3502 break
3503 }
3504 scope$3.var.push(name);
3505 if (this.inModule && (scope$3.flags & SCOPE_TOP))
3506 { delete this.undefinedExports[name]; }
3507 if (scope$3.flags & SCOPE_VAR) { break }
3508 }
3509 }
3510 if (redeclared) { this.raiseRecoverable(pos, ("Identifier '" + name + "' has already been declared")); }
3511 };
3512
3513 pp$3.checkLocalExport = function(id) {
3514 // scope.functions must be empty as Module code is always strict.
3515 if (this.scopeStack[0].lexical.indexOf(id.name) === -1 &&
3516 this.scopeStack[0].var.indexOf(id.name) === -1) {
3517 this.undefinedExports[id.name] = id;
3518 }
3519 };
3520
3521 pp$3.currentScope = function() {
3522 return this.scopeStack[this.scopeStack.length - 1]
3523 };
3524
3525 pp$3.currentVarScope = function() {
3526 for (var i = this.scopeStack.length - 1;; i--) {
3527 var scope = this.scopeStack[i];
3528 if (scope.flags & SCOPE_VAR) { return scope }
3529 }
3530 };
3531
3532 // Could be useful for `this`, `new.target`, `super()`, `super.property`, and `super[property]`.
3533 pp$3.currentThisScope = function() {
3534 for (var i = this.scopeStack.length - 1;; i--) {
3535 var scope = this.scopeStack[i];
3536 if (scope.flags & SCOPE_VAR && !(scope.flags & SCOPE_ARROW)) { return scope }
3537 }
3538 };
3539
3540 var Node = function Node(parser, pos, loc) {
3541 this.type = "";
3542 this.start = pos;
3543 this.end = 0;
3544 if (parser.options.locations)
3545 { this.loc = new SourceLocation(parser, loc); }
3546 if (parser.options.directSourceFile)
3547 { this.sourceFile = parser.options.directSourceFile; }
3548 if (parser.options.ranges)
3549 { this.range = [pos, 0]; }
3550 };
3551
3552 // Start an AST node, attaching a start offset.
3553
3554 var pp$2 = Parser.prototype;
3555
3556 pp$2.startNode = function() {
3557 return new Node(this, this.start, this.startLoc)
3558 };
3559
3560 pp$2.startNodeAt = function(pos, loc) {
3561 return new Node(this, pos, loc)
3562 };
3563
3564 // Finish an AST node, adding `type` and `end` properties.
3565
3566 function finishNodeAt(node, type, pos, loc) {
3567 node.type = type;
3568 node.end = pos;
3569 if (this.options.locations)
3570 { node.loc.end = loc; }
3571 if (this.options.ranges)
3572 { node.range[1] = pos; }
3573 return node
3574 }
3575
3576 pp$2.finishNode = function(node, type) {
3577 return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc)
3578 };
3579
3580 // Finish node at given position
3581
3582 pp$2.finishNodeAt = function(node, type, pos, loc) {
3583 return finishNodeAt.call(this, node, type, pos, loc)
3584 };
3585
3586 pp$2.copyNode = function(node) {
3587 var newNode = new Node(this, node.start, this.startLoc);
3588 for (var prop in node) { newNode[prop] = node[prop]; }
3589 return newNode
3590 };
3591
3592 // This file contains Unicode properties extracted from the ECMAScript
3593 // specification. The lists are extracted like so:
3594 // $$('#table-binary-unicode-properties > figure > table > tbody > tr > td:nth-child(1) code').map(el => el.innerText)
3595
3596 // #table-binary-unicode-properties
3597 var ecma9BinaryProperties = "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 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";
3598 var ecma10BinaryProperties = ecma9BinaryProperties + " Extended_Pictographic";
3599 var ecma11BinaryProperties = ecma10BinaryProperties;
3600 var ecma12BinaryProperties = ecma11BinaryProperties + " EBase EComp EMod EPres ExtPict";
3601 var unicodeBinaryProperties = {
3602 9: ecma9BinaryProperties,
3603 10: ecma10BinaryProperties,
3604 11: ecma11BinaryProperties,
3605 12: ecma12BinaryProperties
3606 };
3607
3608 // #table-unicode-general-category-values
3609 var unicodeGeneralCategoryValues = "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";
3610
3611 // #table-unicode-script-values
3612 var ecma9ScriptValues = "Adlam Adlm Ahom 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 Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang 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 Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo 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 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 Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb";
3613 var ecma10ScriptValues = ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd";
3614 var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho";
3615 var ecma12ScriptValues = ecma11ScriptValues + " Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi";
3616 var unicodeScriptValues = {
3617 9: ecma9ScriptValues,
3618 10: ecma10ScriptValues,
3619 11: ecma11ScriptValues,
3620 12: ecma12ScriptValues
3621 };
3622
3623 var data = {};
3624 function buildUnicodeData(ecmaVersion) {
3625 var d = data[ecmaVersion] = {
3626 binary: wordsRegexp(unicodeBinaryProperties[ecmaVersion] + " " + unicodeGeneralCategoryValues),
3627 nonBinary: {
3628 General_Category: wordsRegexp(unicodeGeneralCategoryValues),
3629 Script: wordsRegexp(unicodeScriptValues[ecmaVersion])
3630 }
3631 };
3632 d.nonBinary.Script_Extensions = d.nonBinary.Script;
3633
3634 d.nonBinary.gc = d.nonBinary.General_Category;
3635 d.nonBinary.sc = d.nonBinary.Script;
3636 d.nonBinary.scx = d.nonBinary.Script_Extensions;
3637 }
3638 buildUnicodeData(9);
3639 buildUnicodeData(10);
3640 buildUnicodeData(11);
3641 buildUnicodeData(12);
3642
3643 var pp$1 = Parser.prototype;
3644
3645 var RegExpValidationState = function RegExpValidationState(parser) {
3646 this.parser = parser;
3647 this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "");
3648 this.unicodeProperties = data[parser.options.ecmaVersion >= 12 ? 12 : parser.options.ecmaVersion];
3649 this.source = "";
3650 this.flags = "";
3651 this.start = 0;
3652 this.switchU = false;
3653 this.switchN = false;
3654 this.pos = 0;
3655 this.lastIntValue = 0;
3656 this.lastStringValue = "";
3657 this.lastAssertionIsQuantifiable = false;
3658 this.numCapturingParens = 0;
3659 this.maxBackReference = 0;
3660 this.groupNames = [];
3661 this.backReferenceNames = [];
3662 };
3663
3664 RegExpValidationState.prototype.reset = function reset (start, pattern, flags) {
3665 var unicode = flags.indexOf("u") !== -1;
3666 this.start = start | 0;
3667 this.source = pattern + "";
3668 this.flags = flags;
3669 this.switchU = unicode && this.parser.options.ecmaVersion >= 6;
3670 this.switchN = unicode && this.parser.options.ecmaVersion >= 9;
3671 };
3672
3673 RegExpValidationState.prototype.raise = function raise (message) {
3674 this.parser.raiseRecoverable(this.start, ("Invalid regular expression: /" + (this.source) + "/: " + message));
3675 };
3676
3677 // If u flag is given, this returns the code point at the index (it combines a surrogate pair).
3678 // Otherwise, this returns the code unit of the index (can be a part of a surrogate pair).
3679 RegExpValidationState.prototype.at = function at (i, forceU) {
3680 if ( forceU === void 0 ) forceU = false;
3681
3682 var s = this.source;
3683 var l = s.length;
3684 if (i >= l) {
3685 return -1
3686 }
3687 var c = s.charCodeAt(i);
3688 if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) {
3689 return c
3690 }
3691 var next = s.charCodeAt(i + 1);
3692 return next >= 0xDC00 && next <= 0xDFFF ? (c << 10) + next - 0x35FDC00 : c
3693 };
3694
3695 RegExpValidationState.prototype.nextIndex = function nextIndex (i, forceU) {
3696 if ( forceU === void 0 ) forceU = false;
3697
3698 var s = this.source;
3699 var l = s.length;
3700 if (i >= l) {
3701 return l
3702 }
3703 var c = s.charCodeAt(i), next;
3704 if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l ||
3705 (next = s.charCodeAt(i + 1)) < 0xDC00 || next > 0xDFFF) {
3706 return i + 1
3707 }
3708 return i + 2
3709 };
3710
3711 RegExpValidationState.prototype.current = function current (forceU) {
3712 if ( forceU === void 0 ) forceU = false;
3713
3714 return this.at(this.pos, forceU)
3715 };
3716
3717 RegExpValidationState.prototype.lookahead = function lookahead (forceU) {
3718 if ( forceU === void 0 ) forceU = false;
3719
3720 return this.at(this.nextIndex(this.pos, forceU), forceU)
3721 };
3722
3723 RegExpValidationState.prototype.advance = function advance (forceU) {
3724 if ( forceU === void 0 ) forceU = false;
3725
3726 this.pos = this.nextIndex(this.pos, forceU);
3727 };
3728
3729 RegExpValidationState.prototype.eat = function eat (ch, forceU) {
3730 if ( forceU === void 0 ) forceU = false;
3731
3732 if (this.current(forceU) === ch) {
3733 this.advance(forceU);
3734 return true
3735 }
3736 return false
3737 };
3738
3739 function codePointToString$1(ch) {
3740 if (ch <= 0xFFFF) { return String.fromCharCode(ch) }
3741 ch -= 0x10000;
3742 return String.fromCharCode((ch >> 10) + 0xD800, (ch & 0x03FF) + 0xDC00)
3743 }
3744
3745 /**
3746 * Validate the flags part of a given RegExpLiteral.
3747 *
3748 * @param {RegExpValidationState} state The state to validate RegExp.
3749 * @returns {void}
3750 */
3751 pp$1.validateRegExpFlags = function(state) {
3752 var validFlags = state.validFlags;
3753 var flags = state.flags;
3754
3755 for (var i = 0; i < flags.length; i++) {
3756 var flag = flags.charAt(i);
3757 if (validFlags.indexOf(flag) === -1) {
3758 this.raise(state.start, "Invalid regular expression flag");
3759 }
3760 if (flags.indexOf(flag, i + 1) > -1) {
3761 this.raise(state.start, "Duplicate regular expression flag");
3762 }
3763 }
3764 };
3765
3766 /**
3767 * Validate the pattern part of a given RegExpLiteral.
3768 *
3769 * @param {RegExpValidationState} state The state to validate RegExp.
3770 * @returns {void}
3771 */
3772 pp$1.validateRegExpPattern = function(state) {
3773 this.regexp_pattern(state);
3774
3775 // The goal symbol for the parse is |Pattern[~U, ~N]|. If the result of
3776 // parsing contains a |GroupName|, reparse with the goal symbol
3777 // |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError*
3778 // exception if _P_ did not conform to the grammar, if any elements of _P_
3779 // were not matched by the parse, or if any Early Error conditions exist.
3780 if (!state.switchN && this.options.ecmaVersion >= 9 && state.groupNames.length > 0) {
3781 state.switchN = true;
3782 this.regexp_pattern(state);
3783 }
3784 };
3785
3786 // https://www.ecma-international.org/ecma-262/8.0/#prod-Pattern
3787 pp$1.regexp_pattern = function(state) {
3788 state.pos = 0;
3789 state.lastIntValue = 0;
3790 state.lastStringValue = "";
3791 state.lastAssertionIsQuantifiable = false;
3792 state.numCapturingParens = 0;
3793 state.maxBackReference = 0;
3794 state.groupNames.length = 0;
3795 state.backReferenceNames.length = 0;
3796
3797 this.regexp_disjunction(state);
3798
3799 if (state.pos !== state.source.length) {
3800 // Make the same messages as V8.
3801 if (state.eat(0x29 /* ) */)) {
3802 state.raise("Unmatched ')'");
3803 }
3804 if (state.eat(0x5D /* ] */) || state.eat(0x7D /* } */)) {
3805 state.raise("Lone quantifier brackets");
3806 }
3807 }
3808 if (state.maxBackReference > state.numCapturingParens) {
3809 state.raise("Invalid escape");
3810 }
3811 for (var i = 0, list = state.backReferenceNames; i < list.length; i += 1) {
3812 var name = list[i];
3813
3814 if (state.groupNames.indexOf(name) === -1) {
3815 state.raise("Invalid named capture referenced");
3816 }
3817 }
3818 };
3819
3820 // https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction
3821 pp$1.regexp_disjunction = function(state) {
3822 this.regexp_alternative(state);
3823 while (state.eat(0x7C /* | */)) {
3824 this.regexp_alternative(state);
3825 }
3826
3827 // Make the same message as V8.
3828 if (this.regexp_eatQuantifier(state, true)) {
3829 state.raise("Nothing to repeat");
3830 }
3831 if (state.eat(0x7B /* { */)) {
3832 state.raise("Lone quantifier brackets");
3833 }
3834 };
3835
3836 // https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative
3837 pp$1.regexp_alternative = function(state) {
3838 while (state.pos < state.source.length && this.regexp_eatTerm(state))
3839 { }
3840 };
3841
3842 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term
3843 pp$1.regexp_eatTerm = function(state) {
3844 if (this.regexp_eatAssertion(state)) {
3845 // Handle `QuantifiableAssertion Quantifier` alternative.
3846 // `state.lastAssertionIsQuantifiable` is true if the last eaten Assertion
3847 // is a QuantifiableAssertion.
3848 if (state.lastAssertionIsQuantifiable && this.regexp_eatQuantifier(state)) {
3849 // Make the same message as V8.
3850 if (state.switchU) {
3851 state.raise("Invalid quantifier");
3852 }
3853 }
3854 return true
3855 }
3856
3857 if (state.switchU ? this.regexp_eatAtom(state) : this.regexp_eatExtendedAtom(state)) {
3858 this.regexp_eatQuantifier(state);
3859 return true
3860 }
3861
3862 return false
3863 };
3864
3865 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Assertion
3866 pp$1.regexp_eatAssertion = function(state) {
3867 var start = state.pos;
3868 state.lastAssertionIsQuantifiable = false;
3869
3870 // ^, $
3871 if (state.eat(0x5E /* ^ */) || state.eat(0x24 /* $ */)) {
3872 return true
3873 }
3874
3875 // \b \B
3876 if (state.eat(0x5C /* \ */)) {
3877 if (state.eat(0x42 /* B */) || state.eat(0x62 /* b */)) {
3878 return true
3879 }
3880 state.pos = start;
3881 }
3882
3883 // Lookahead / Lookbehind
3884 if (state.eat(0x28 /* ( */) && state.eat(0x3F /* ? */)) {
3885 var lookbehind = false;
3886 if (this.options.ecmaVersion >= 9) {
3887 lookbehind = state.eat(0x3C /* < */);
3888 }
3889 if (state.eat(0x3D /* = */) || state.eat(0x21 /* ! */)) {
3890 this.regexp_disjunction(state);
3891 if (!state.eat(0x29 /* ) */)) {
3892 state.raise("Unterminated group");
3893 }
3894 state.lastAssertionIsQuantifiable = !lookbehind;
3895 return true
3896 }
3897 }
3898
3899 state.pos = start;
3900 return false
3901 };
3902
3903 // https://www.ecma-international.org/ecma-262/8.0/#prod-Quantifier
3904 pp$1.regexp_eatQuantifier = function(state, noError) {
3905 if ( noError === void 0 ) noError = false;
3906
3907 if (this.regexp_eatQuantifierPrefix(state, noError)) {
3908 state.eat(0x3F /* ? */);
3909 return true
3910 }
3911 return false
3912 };
3913
3914 // https://www.ecma-international.org/ecma-262/8.0/#prod-QuantifierPrefix
3915 pp$1.regexp_eatQuantifierPrefix = function(state, noError) {
3916 return (
3917 state.eat(0x2A /* * */) ||
3918 state.eat(0x2B /* + */) ||
3919 state.eat(0x3F /* ? */) ||
3920 this.regexp_eatBracedQuantifier(state, noError)
3921 )
3922 };
3923 pp$1.regexp_eatBracedQuantifier = function(state, noError) {
3924 var start = state.pos;
3925 if (state.eat(0x7B /* { */)) {
3926 var min = 0, max = -1;
3927 if (this.regexp_eatDecimalDigits(state)) {
3928 min = state.lastIntValue;
3929 if (state.eat(0x2C /* , */) && this.regexp_eatDecimalDigits(state)) {
3930 max = state.lastIntValue;
3931 }
3932 if (state.eat(0x7D /* } */)) {
3933 // SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-term
3934 if (max !== -1 && max < min && !noError) {
3935 state.raise("numbers out of order in {} quantifier");
3936 }
3937 return true
3938 }
3939 }
3940 if (state.switchU && !noError) {
3941 state.raise("Incomplete quantifier");
3942 }
3943 state.pos = start;
3944 }
3945 return false
3946 };
3947
3948 // https://www.ecma-international.org/ecma-262/8.0/#prod-Atom
3949 pp$1.regexp_eatAtom = function(state) {
3950 return (
3951 this.regexp_eatPatternCharacters(state) ||
3952 state.eat(0x2E /* . */) ||
3953 this.regexp_eatReverseSolidusAtomEscape(state) ||
3954 this.regexp_eatCharacterClass(state) ||
3955 this.regexp_eatUncapturingGroup(state) ||
3956 this.regexp_eatCapturingGroup(state)
3957 )
3958 };
3959 pp$1.regexp_eatReverseSolidusAtomEscape = function(state) {
3960 var start = state.pos;
3961 if (state.eat(0x5C /* \ */)) {
3962 if (this.regexp_eatAtomEscape(state)) {
3963 return true
3964 }
3965 state.pos = start;
3966 }
3967 return false
3968 };
3969 pp$1.regexp_eatUncapturingGroup = function(state) {
3970 var start = state.pos;
3971 if (state.eat(0x28 /* ( */)) {
3972 if (state.eat(0x3F /* ? */) && state.eat(0x3A /* : */)) {
3973 this.regexp_disjunction(state);
3974 if (state.eat(0x29 /* ) */)) {
3975 return true
3976 }
3977 state.raise("Unterminated group");
3978 }
3979 state.pos = start;
3980 }
3981 return false
3982 };
3983 pp$1.regexp_eatCapturingGroup = function(state) {
3984 if (state.eat(0x28 /* ( */)) {
3985 if (this.options.ecmaVersion >= 9) {
3986 this.regexp_groupSpecifier(state);
3987 } else if (state.current() === 0x3F /* ? */) {
3988 state.raise("Invalid group");
3989 }
3990 this.regexp_disjunction(state);
3991 if (state.eat(0x29 /* ) */)) {
3992 state.numCapturingParens += 1;
3993 return true
3994 }
3995 state.raise("Unterminated group");
3996 }
3997 return false
3998 };
3999
4000 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom
4001 pp$1.regexp_eatExtendedAtom = function(state) {
4002 return (
4003 state.eat(0x2E /* . */) ||
4004 this.regexp_eatReverseSolidusAtomEscape(state) ||
4005 this.regexp_eatCharacterClass(state) ||
4006 this.regexp_eatUncapturingGroup(state) ||
4007 this.regexp_eatCapturingGroup(state) ||
4008 this.regexp_eatInvalidBracedQuantifier(state) ||
4009 this.regexp_eatExtendedPatternCharacter(state)
4010 )
4011 };
4012
4013 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-InvalidBracedQuantifier
4014 pp$1.regexp_eatInvalidBracedQuantifier = function(state) {
4015 if (this.regexp_eatBracedQuantifier(state, true)) {
4016 state.raise("Nothing to repeat");
4017 }
4018 return false
4019 };
4020
4021 // https://www.ecma-international.org/ecma-262/8.0/#prod-SyntaxCharacter
4022 pp$1.regexp_eatSyntaxCharacter = function(state) {
4023 var ch = state.current();
4024 if (isSyntaxCharacter(ch)) {
4025 state.lastIntValue = ch;
4026 state.advance();
4027 return true
4028 }
4029 return false
4030 };
4031 function isSyntaxCharacter(ch) {
4032 return (
4033 ch === 0x24 /* $ */ ||
4034 ch >= 0x28 /* ( */ && ch <= 0x2B /* + */ ||
4035 ch === 0x2E /* . */ ||
4036 ch === 0x3F /* ? */ ||
4037 ch >= 0x5B /* [ */ && ch <= 0x5E /* ^ */ ||
4038 ch >= 0x7B /* { */ && ch <= 0x7D /* } */
4039 )
4040 }
4041
4042 // https://www.ecma-international.org/ecma-262/8.0/#prod-PatternCharacter
4043 // But eat eager.
4044 pp$1.regexp_eatPatternCharacters = function(state) {
4045 var start = state.pos;
4046 var ch = 0;
4047 while ((ch = state.current()) !== -1 && !isSyntaxCharacter(ch)) {
4048 state.advance();
4049 }
4050 return state.pos !== start
4051 };
4052
4053 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedPatternCharacter
4054 pp$1.regexp_eatExtendedPatternCharacter = function(state) {
4055 var ch = state.current();
4056 if (
4057 ch !== -1 &&
4058 ch !== 0x24 /* $ */ &&
4059 !(ch >= 0x28 /* ( */ && ch <= 0x2B /* + */) &&
4060 ch !== 0x2E /* . */ &&
4061 ch !== 0x3F /* ? */ &&
4062 ch !== 0x5B /* [ */ &&
4063 ch !== 0x5E /* ^ */ &&
4064 ch !== 0x7C /* | */
4065 ) {
4066 state.advance();
4067 return true
4068 }
4069 return false
4070 };
4071
4072 // GroupSpecifier ::
4073 // [empty]
4074 // `?` GroupName
4075 pp$1.regexp_groupSpecifier = function(state) {
4076 if (state.eat(0x3F /* ? */)) {
4077 if (this.regexp_eatGroupName(state)) {
4078 if (state.groupNames.indexOf(state.lastStringValue) !== -1) {
4079 state.raise("Duplicate capture group name");
4080 }
4081 state.groupNames.push(state.lastStringValue);
4082 return
4083 }
4084 state.raise("Invalid group");
4085 }
4086 };
4087
4088 // GroupName ::
4089 // `<` RegExpIdentifierName `>`
4090 // Note: this updates `state.lastStringValue` property with the eaten name.
4091 pp$1.regexp_eatGroupName = function(state) {
4092 state.lastStringValue = "";
4093 if (state.eat(0x3C /* < */)) {
4094 if (this.regexp_eatRegExpIdentifierName(state) && state.eat(0x3E /* > */)) {
4095 return true
4096 }
4097 state.raise("Invalid capture group name");
4098 }
4099 return false
4100 };
4101
4102 // RegExpIdentifierName ::
4103 // RegExpIdentifierStart
4104 // RegExpIdentifierName RegExpIdentifierPart
4105 // Note: this updates `state.lastStringValue` property with the eaten name.
4106 pp$1.regexp_eatRegExpIdentifierName = function(state) {
4107 state.lastStringValue = "";
4108 if (this.regexp_eatRegExpIdentifierStart(state)) {
4109 state.lastStringValue += codePointToString$1(state.lastIntValue);
4110 while (this.regexp_eatRegExpIdentifierPart(state)) {
4111 state.lastStringValue += codePointToString$1(state.lastIntValue);
4112 }
4113 return true
4114 }
4115 return false
4116 };
4117
4118 // RegExpIdentifierStart ::
4119 // UnicodeIDStart
4120 // `$`
4121 // `_`
4122 // `\` RegExpUnicodeEscapeSequence[+U]
4123 pp$1.regexp_eatRegExpIdentifierStart = function(state) {
4124 var start = state.pos;
4125 var forceU = this.options.ecmaVersion >= 11;
4126 var ch = state.current(forceU);
4127 state.advance(forceU);
4128
4129 if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
4130 ch = state.lastIntValue;
4131 }
4132 if (isRegExpIdentifierStart(ch)) {
4133 state.lastIntValue = ch;
4134 return true
4135 }
4136
4137 state.pos = start;
4138 return false
4139 };
4140 function isRegExpIdentifierStart(ch) {
4141 return isIdentifierStart(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */
4142 }
4143
4144 // RegExpIdentifierPart ::
4145 // UnicodeIDContinue
4146 // `$`
4147 // `_`
4148 // `\` RegExpUnicodeEscapeSequence[+U]
4149 // <ZWNJ>
4150 // <ZWJ>
4151 pp$1.regexp_eatRegExpIdentifierPart = function(state) {
4152 var start = state.pos;
4153 var forceU = this.options.ecmaVersion >= 11;
4154 var ch = state.current(forceU);
4155 state.advance(forceU);
4156
4157 if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
4158 ch = state.lastIntValue;
4159 }
4160 if (isRegExpIdentifierPart(ch)) {
4161 state.lastIntValue = ch;
4162 return true
4163 }
4164
4165 state.pos = start;
4166 return false
4167 };
4168 function isRegExpIdentifierPart(ch) {
4169 return isIdentifierChar(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */ || ch === 0x200C /* <ZWNJ> */ || ch === 0x200D /* <ZWJ> */
4170 }
4171
4172 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-AtomEscape
4173 pp$1.regexp_eatAtomEscape = function(state) {
4174 if (
4175 this.regexp_eatBackReference(state) ||
4176 this.regexp_eatCharacterClassEscape(state) ||
4177 this.regexp_eatCharacterEscape(state) ||
4178 (state.switchN && this.regexp_eatKGroupName(state))
4179 ) {
4180 return true
4181 }
4182 if (state.switchU) {
4183 // Make the same message as V8.
4184 if (state.current() === 0x63 /* c */) {
4185 state.raise("Invalid unicode escape");
4186 }
4187 state.raise("Invalid escape");
4188 }
4189 return false
4190 };
4191 pp$1.regexp_eatBackReference = function(state) {
4192 var start = state.pos;
4193 if (this.regexp_eatDecimalEscape(state)) {
4194 var n = state.lastIntValue;
4195 if (state.switchU) {
4196 // For SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-atomescape
4197 if (n > state.maxBackReference) {
4198 state.maxBackReference = n;
4199 }
4200 return true
4201 }
4202 if (n <= state.numCapturingParens) {
4203 return true
4204 }
4205 state.pos = start;
4206 }
4207 return false
4208 };
4209 pp$1.regexp_eatKGroupName = function(state) {
4210 if (state.eat(0x6B /* k */)) {
4211 if (this.regexp_eatGroupName(state)) {
4212 state.backReferenceNames.push(state.lastStringValue);
4213 return true
4214 }
4215 state.raise("Invalid named reference");
4216 }
4217 return false
4218 };
4219
4220 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-CharacterEscape
4221 pp$1.regexp_eatCharacterEscape = function(state) {
4222 return (
4223 this.regexp_eatControlEscape(state) ||
4224 this.regexp_eatCControlLetter(state) ||
4225 this.regexp_eatZero(state) ||
4226 this.regexp_eatHexEscapeSequence(state) ||
4227 this.regexp_eatRegExpUnicodeEscapeSequence(state, false) ||
4228 (!state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state)) ||
4229 this.regexp_eatIdentityEscape(state)
4230 )
4231 };
4232 pp$1.regexp_eatCControlLetter = function(state) {
4233 var start = state.pos;
4234 if (state.eat(0x63 /* c */)) {
4235 if (this.regexp_eatControlLetter(state)) {
4236 return true
4237 }
4238 state.pos = start;
4239 }
4240 return false
4241 };
4242 pp$1.regexp_eatZero = function(state) {
4243 if (state.current() === 0x30 /* 0 */ && !isDecimalDigit(state.lookahead())) {
4244 state.lastIntValue = 0;
4245 state.advance();
4246 return true
4247 }
4248 return false
4249 };
4250
4251 // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlEscape
4252 pp$1.regexp_eatControlEscape = function(state) {
4253 var ch = state.current();
4254 if (ch === 0x74 /* t */) {
4255 state.lastIntValue = 0x09; /* \t */
4256 state.advance();
4257 return true
4258 }
4259 if (ch === 0x6E /* n */) {
4260 state.lastIntValue = 0x0A; /* \n */
4261 state.advance();
4262 return true
4263 }
4264 if (ch === 0x76 /* v */) {
4265 state.lastIntValue = 0x0B; /* \v */
4266 state.advance();
4267 return true
4268 }
4269 if (ch === 0x66 /* f */) {
4270 state.lastIntValue = 0x0C; /* \f */
4271 state.advance();
4272 return true
4273 }
4274 if (ch === 0x72 /* r */) {
4275 state.lastIntValue = 0x0D; /* \r */
4276 state.advance();
4277 return true
4278 }
4279 return false
4280 };
4281
4282 // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlLetter
4283 pp$1.regexp_eatControlLetter = function(state) {
4284 var ch = state.current();
4285 if (isControlLetter(ch)) {
4286 state.lastIntValue = ch % 0x20;
4287 state.advance();
4288 return true
4289 }
4290 return false
4291 };
4292 function isControlLetter(ch) {
4293 return (
4294 (ch >= 0x41 /* A */ && ch <= 0x5A /* Z */) ||
4295 (ch >= 0x61 /* a */ && ch <= 0x7A /* z */)
4296 )
4297 }
4298
4299 // https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence
4300 pp$1.regexp_eatRegExpUnicodeEscapeSequence = function(state, forceU) {
4301 if ( forceU === void 0 ) forceU = false;
4302
4303 var start = state.pos;
4304 var switchU = forceU || state.switchU;
4305
4306 if (state.eat(0x75 /* u */)) {
4307 if (this.regexp_eatFixedHexDigits(state, 4)) {
4308 var lead = state.lastIntValue;
4309 if (switchU && lead >= 0xD800 && lead <= 0xDBFF) {
4310 var leadSurrogateEnd = state.pos;
4311 if (state.eat(0x5C /* \ */) && state.eat(0x75 /* u */) && this.regexp_eatFixedHexDigits(state, 4)) {
4312 var trail = state.lastIntValue;
4313 if (trail >= 0xDC00 && trail <= 0xDFFF) {
4314 state.lastIntValue = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
4315 return true
4316 }
4317 }
4318 state.pos = leadSurrogateEnd;
4319 state.lastIntValue = lead;
4320 }
4321 return true
4322 }
4323 if (
4324 switchU &&
4325 state.eat(0x7B /* { */) &&
4326 this.regexp_eatHexDigits(state) &&
4327 state.eat(0x7D /* } */) &&
4328 isValidUnicode(state.lastIntValue)
4329 ) {
4330 return true
4331 }
4332 if (switchU) {
4333 state.raise("Invalid unicode escape");
4334 }
4335 state.pos = start;
4336 }
4337
4338 return false
4339 };
4340 function isValidUnicode(ch) {
4341 return ch >= 0 && ch <= 0x10FFFF
4342 }
4343
4344 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-IdentityEscape
4345 pp$1.regexp_eatIdentityEscape = function(state) {
4346 if (state.switchU) {
4347 if (this.regexp_eatSyntaxCharacter(state)) {
4348 return true
4349 }
4350 if (state.eat(0x2F /* / */)) {
4351 state.lastIntValue = 0x2F; /* / */
4352 return true
4353 }
4354 return false
4355 }
4356
4357 var ch = state.current();
4358 if (ch !== 0x63 /* c */ && (!state.switchN || ch !== 0x6B /* k */)) {
4359 state.lastIntValue = ch;
4360 state.advance();
4361 return true
4362 }
4363
4364 return false
4365 };
4366
4367 // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalEscape
4368 pp$1.regexp_eatDecimalEscape = function(state) {
4369 state.lastIntValue = 0;
4370 var ch = state.current();
4371 if (ch >= 0x31 /* 1 */ && ch <= 0x39 /* 9 */) {
4372 do {
4373 state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */);
4374 state.advance();
4375 } while ((ch = state.current()) >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */)
4376 return true
4377 }
4378 return false
4379 };
4380
4381 // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClassEscape
4382 pp$1.regexp_eatCharacterClassEscape = function(state) {
4383 var ch = state.current();
4384
4385 if (isCharacterClassEscape(ch)) {
4386 state.lastIntValue = -1;
4387 state.advance();
4388 return true
4389 }
4390
4391 if (
4392 state.switchU &&
4393 this.options.ecmaVersion >= 9 &&
4394 (ch === 0x50 /* P */ || ch === 0x70 /* p */)
4395 ) {
4396 state.lastIntValue = -1;
4397 state.advance();
4398 if (
4399 state.eat(0x7B /* { */) &&
4400 this.regexp_eatUnicodePropertyValueExpression(state) &&
4401 state.eat(0x7D /* } */)
4402 ) {
4403 return true
4404 }
4405 state.raise("Invalid property name");
4406 }
4407
4408 return false
4409 };
4410 function isCharacterClassEscape(ch) {
4411 return (
4412 ch === 0x64 /* d */ ||
4413 ch === 0x44 /* D */ ||
4414 ch === 0x73 /* s */ ||
4415 ch === 0x53 /* S */ ||
4416 ch === 0x77 /* w */ ||
4417 ch === 0x57 /* W */
4418 )
4419 }
4420
4421 // UnicodePropertyValueExpression ::
4422 // UnicodePropertyName `=` UnicodePropertyValue
4423 // LoneUnicodePropertyNameOrValue
4424 pp$1.regexp_eatUnicodePropertyValueExpression = function(state) {
4425 var start = state.pos;
4426
4427 // UnicodePropertyName `=` UnicodePropertyValue
4428 if (this.regexp_eatUnicodePropertyName(state) && state.eat(0x3D /* = */)) {
4429 var name = state.lastStringValue;
4430 if (this.regexp_eatUnicodePropertyValue(state)) {
4431 var value = state.lastStringValue;
4432 this.regexp_validateUnicodePropertyNameAndValue(state, name, value);
4433 return true
4434 }
4435 }
4436 state.pos = start;
4437
4438 // LoneUnicodePropertyNameOrValue
4439 if (this.regexp_eatLoneUnicodePropertyNameOrValue(state)) {
4440 var nameOrValue = state.lastStringValue;
4441 this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue);
4442 return true
4443 }
4444 return false
4445 };
4446 pp$1.regexp_validateUnicodePropertyNameAndValue = function(state, name, value) {
4447 if (!has(state.unicodeProperties.nonBinary, name))
4448 { state.raise("Invalid property name"); }
4449 if (!state.unicodeProperties.nonBinary[name].test(value))
4450 { state.raise("Invalid property value"); }
4451 };
4452 pp$1.regexp_validateUnicodePropertyNameOrValue = function(state, nameOrValue) {
4453 if (!state.unicodeProperties.binary.test(nameOrValue))
4454 { state.raise("Invalid property name"); }
4455 };
4456
4457 // UnicodePropertyName ::
4458 // UnicodePropertyNameCharacters
4459 pp$1.regexp_eatUnicodePropertyName = function(state) {
4460 var ch = 0;
4461 state.lastStringValue = "";
4462 while (isUnicodePropertyNameCharacter(ch = state.current())) {
4463 state.lastStringValue += codePointToString$1(ch);
4464 state.advance();
4465 }
4466 return state.lastStringValue !== ""
4467 };
4468 function isUnicodePropertyNameCharacter(ch) {
4469 return isControlLetter(ch) || ch === 0x5F /* _ */
4470 }
4471
4472 // UnicodePropertyValue ::
4473 // UnicodePropertyValueCharacters
4474 pp$1.regexp_eatUnicodePropertyValue = function(state) {
4475 var ch = 0;
4476 state.lastStringValue = "";
4477 while (isUnicodePropertyValueCharacter(ch = state.current())) {
4478 state.lastStringValue += codePointToString$1(ch);
4479 state.advance();
4480 }
4481 return state.lastStringValue !== ""
4482 };
4483 function isUnicodePropertyValueCharacter(ch) {
4484 return isUnicodePropertyNameCharacter(ch) || isDecimalDigit(ch)
4485 }
4486
4487 // LoneUnicodePropertyNameOrValue ::
4488 // UnicodePropertyValueCharacters
4489 pp$1.regexp_eatLoneUnicodePropertyNameOrValue = function(state) {
4490 return this.regexp_eatUnicodePropertyValue(state)
4491 };
4492
4493 // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClass
4494 pp$1.regexp_eatCharacterClass = function(state) {
4495 if (state.eat(0x5B /* [ */)) {
4496 state.eat(0x5E /* ^ */);
4497 this.regexp_classRanges(state);
4498 if (state.eat(0x5D /* ] */)) {
4499 return true
4500 }
4501 // Unreachable since it threw "unterminated regular expression" error before.
4502 state.raise("Unterminated character class");
4503 }
4504 return false
4505 };
4506
4507 // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassRanges
4508 // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRanges
4509 // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRangesNoDash
4510 pp$1.regexp_classRanges = function(state) {
4511 while (this.regexp_eatClassAtom(state)) {
4512 var left = state.lastIntValue;
4513 if (state.eat(0x2D /* - */) && this.regexp_eatClassAtom(state)) {
4514 var right = state.lastIntValue;
4515 if (state.switchU && (left === -1 || right === -1)) {
4516 state.raise("Invalid character class");
4517 }
4518 if (left !== -1 && right !== -1 && left > right) {
4519 state.raise("Range out of order in character class");
4520 }
4521 }
4522 }
4523 };
4524
4525 // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtom
4526 // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtomNoDash
4527 pp$1.regexp_eatClassAtom = function(state) {
4528 var start = state.pos;
4529
4530 if (state.eat(0x5C /* \ */)) {
4531 if (this.regexp_eatClassEscape(state)) {
4532 return true
4533 }
4534 if (state.switchU) {
4535 // Make the same message as V8.
4536 var ch$1 = state.current();
4537 if (ch$1 === 0x63 /* c */ || isOctalDigit(ch$1)) {
4538 state.raise("Invalid class escape");
4539 }
4540 state.raise("Invalid escape");
4541 }
4542 state.pos = start;
4543 }
4544
4545 var ch = state.current();
4546 if (ch !== 0x5D /* ] */) {
4547 state.lastIntValue = ch;
4548 state.advance();
4549 return true
4550 }
4551
4552 return false
4553 };
4554
4555 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassEscape
4556 pp$1.regexp_eatClassEscape = function(state) {
4557 var start = state.pos;
4558
4559 if (state.eat(0x62 /* b */)) {
4560 state.lastIntValue = 0x08; /* <BS> */
4561 return true
4562 }
4563
4564 if (state.switchU && state.eat(0x2D /* - */)) {
4565 state.lastIntValue = 0x2D; /* - */
4566 return true
4567 }
4568
4569 if (!state.switchU && state.eat(0x63 /* c */)) {
4570 if (this.regexp_eatClassControlLetter(state)) {
4571 return true
4572 }
4573 state.pos = start;
4574 }
4575
4576 return (
4577 this.regexp_eatCharacterClassEscape(state) ||
4578 this.regexp_eatCharacterEscape(state)
4579 )
4580 };
4581
4582 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassControlLetter
4583 pp$1.regexp_eatClassControlLetter = function(state) {
4584 var ch = state.current();
4585 if (isDecimalDigit(ch) || ch === 0x5F /* _ */) {
4586 state.lastIntValue = ch % 0x20;
4587 state.advance();
4588 return true
4589 }
4590 return false
4591 };
4592
4593 // https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
4594 pp$1.regexp_eatHexEscapeSequence = function(state) {
4595 var start = state.pos;
4596 if (state.eat(0x78 /* x */)) {
4597 if (this.regexp_eatFixedHexDigits(state, 2)) {
4598 return true
4599 }
4600 if (state.switchU) {
4601 state.raise("Invalid escape");
4602 }
4603 state.pos = start;
4604 }
4605 return false
4606 };
4607
4608 // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalDigits
4609 pp$1.regexp_eatDecimalDigits = function(state) {
4610 var start = state.pos;
4611 var ch = 0;
4612 state.lastIntValue = 0;
4613 while (isDecimalDigit(ch = state.current())) {
4614 state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */);
4615 state.advance();
4616 }
4617 return state.pos !== start
4618 };
4619 function isDecimalDigit(ch) {
4620 return ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */
4621 }
4622
4623 // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigits
4624 pp$1.regexp_eatHexDigits = function(state) {
4625 var start = state.pos;
4626 var ch = 0;
4627 state.lastIntValue = 0;
4628 while (isHexDigit(ch = state.current())) {
4629 state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
4630 state.advance();
4631 }
4632 return state.pos !== start
4633 };
4634 function isHexDigit(ch) {
4635 return (
4636 (ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */) ||
4637 (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) ||
4638 (ch >= 0x61 /* a */ && ch <= 0x66 /* f */)
4639 )
4640 }
4641 function hexToInt(ch) {
4642 if (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) {
4643 return 10 + (ch - 0x41 /* A */)
4644 }
4645 if (ch >= 0x61 /* a */ && ch <= 0x66 /* f */) {
4646 return 10 + (ch - 0x61 /* a */)
4647 }
4648 return ch - 0x30 /* 0 */
4649 }
4650
4651 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-LegacyOctalEscapeSequence
4652 // Allows only 0-377(octal) i.e. 0-255(decimal).
4653 pp$1.regexp_eatLegacyOctalEscapeSequence = function(state) {
4654 if (this.regexp_eatOctalDigit(state)) {
4655 var n1 = state.lastIntValue;
4656 if (this.regexp_eatOctalDigit(state)) {
4657 var n2 = state.lastIntValue;
4658 if (n1 <= 3 && this.regexp_eatOctalDigit(state)) {
4659 state.lastIntValue = n1 * 64 + n2 * 8 + state.lastIntValue;
4660 } else {
4661 state.lastIntValue = n1 * 8 + n2;
4662 }
4663 } else {
4664 state.lastIntValue = n1;
4665 }
4666 return true
4667 }
4668 return false
4669 };
4670
4671 // https://www.ecma-international.org/ecma-262/8.0/#prod-OctalDigit
4672 pp$1.regexp_eatOctalDigit = function(state) {
4673 var ch = state.current();
4674 if (isOctalDigit(ch)) {
4675 state.lastIntValue = ch - 0x30; /* 0 */
4676 state.advance();
4677 return true
4678 }
4679 state.lastIntValue = 0;
4680 return false
4681 };
4682 function isOctalDigit(ch) {
4683 return ch >= 0x30 /* 0 */ && ch <= 0x37 /* 7 */
4684 }
4685
4686 // https://www.ecma-international.org/ecma-262/8.0/#prod-Hex4Digits
4687 // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigit
4688 // And HexDigit HexDigit in https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
4689 pp$1.regexp_eatFixedHexDigits = function(state, length) {
4690 var start = state.pos;
4691 state.lastIntValue = 0;
4692 for (var i = 0; i < length; ++i) {
4693 var ch = state.current();
4694 if (!isHexDigit(ch)) {
4695 state.pos = start;
4696 return false
4697 }
4698 state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
4699 state.advance();
4700 }
4701 return true
4702 };
4703
4704 // Object type used to represent tokens. Note that normally, tokens
4705 // simply exist as properties on the parser object. This is only
4706 // used for the onToken callback and the external tokenizer.
4707
4708 var Token = function Token(p) {
4709 this.type = p.type;
4710 this.value = p.value;
4711 this.start = p.start;
4712 this.end = p.end;
4713 if (p.options.locations)
4714 { this.loc = new SourceLocation(p, p.startLoc, p.endLoc); }
4715 if (p.options.ranges)
4716 { this.range = [p.start, p.end]; }
4717 };
4718
4719 // ## Tokenizer
4720
4721 var pp = Parser.prototype;
4722
4723 // Move to the next token
4724
4725 pp.next = function(ignoreEscapeSequenceInKeyword) {
4726 if (!ignoreEscapeSequenceInKeyword && this.type.keyword && this.containsEsc)
4727 { this.raiseRecoverable(this.start, "Escape sequence in keyword " + this.type.keyword); }
4728 if (this.options.onToken)
4729 { this.options.onToken(new Token(this)); }
4730
4731 this.lastTokEnd = this.end;
4732 this.lastTokStart = this.start;
4733 this.lastTokEndLoc = this.endLoc;
4734 this.lastTokStartLoc = this.startLoc;
4735 this.nextToken();
4736 };
4737
4738 pp.getToken = function() {
4739 this.next();
4740 return new Token(this)
4741 };
4742
4743 // If we're in an ES6 environment, make parsers iterable
4744 if (typeof Symbol !== "undefined")
4745 { pp[Symbol.iterator] = function() {
4746 var this$1$1 = this;
4747
4748 return {
4749 next: function () {
4750 var token = this$1$1.getToken();
4751 return {
4752 done: token.type === types$1.eof,
4753 value: token
4754 }
4755 }
4756 }
4757 }; }
4758
4759 // Toggle strict mode. Re-reads the next number or string to please
4760 // pedantic tests (`"use strict"; 010;` should fail).
4761
4762 // Read a single token, updating the parser object's token-related
4763 // properties.
4764
4765 pp.nextToken = function() {
4766 var curContext = this.curContext();
4767 if (!curContext || !curContext.preserveSpace) { this.skipSpace(); }
4768
4769 this.start = this.pos;
4770 if (this.options.locations) { this.startLoc = this.curPosition(); }
4771 if (this.pos >= this.input.length) { return this.finishToken(types$1.eof) }
4772
4773 if (curContext.override) { return curContext.override(this) }
4774 else { this.readToken(this.fullCharCodeAtPos()); }
4775 };
4776
4777 pp.readToken = function(code) {
4778 // Identifier or keyword. '\uXXXX' sequences are allowed in
4779 // identifiers, so '\' also dispatches to that.
4780 if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */)
4781 { return this.readWord() }
4782
4783 return this.getTokenFromCode(code)
4784 };
4785
4786 pp.fullCharCodeAtPos = function() {
4787 var code = this.input.charCodeAt(this.pos);
4788 if (code <= 0xd7ff || code >= 0xdc00) { return code }
4789 var next = this.input.charCodeAt(this.pos + 1);
4790 return next <= 0xdbff || next >= 0xe000 ? code : (code << 10) + next - 0x35fdc00
4791 };
4792
4793 pp.skipBlockComment = function() {
4794 var startLoc = this.options.onComment && this.curPosition();
4795 var start = this.pos, end = this.input.indexOf("*/", this.pos += 2);
4796 if (end === -1) { this.raise(this.pos - 2, "Unterminated comment"); }
4797 this.pos = end + 2;
4798 if (this.options.locations) {
4799 lineBreakG.lastIndex = start;
4800 var match;
4801 while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) {
4802 ++this.curLine;
4803 this.lineStart = match.index + match[0].length;
4804 }
4805 }
4806 if (this.options.onComment)
4807 { this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos,
4808 startLoc, this.curPosition()); }
4809 };
4810
4811 pp.skipLineComment = function(startSkip) {
4812 var start = this.pos;
4813 var startLoc = this.options.onComment && this.curPosition();
4814 var ch = this.input.charCodeAt(this.pos += startSkip);
4815 while (this.pos < this.input.length && !isNewLine(ch)) {
4816 ch = this.input.charCodeAt(++this.pos);
4817 }
4818 if (this.options.onComment)
4819 { this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos,
4820 startLoc, this.curPosition()); }
4821 };
4822
4823 // Called at the start of the parse and after every token. Skips
4824 // whitespace and comments, and.
4825
4826 pp.skipSpace = function() {
4827 loop: while (this.pos < this.input.length) {
4828 var ch = this.input.charCodeAt(this.pos);
4829 switch (ch) {
4830 case 32: case 160: // ' '
4831 ++this.pos;
4832 break
4833 case 13:
4834 if (this.input.charCodeAt(this.pos + 1) === 10) {
4835 ++this.pos;
4836 }
4837 case 10: case 8232: case 8233:
4838 ++this.pos;
4839 if (this.options.locations) {
4840 ++this.curLine;
4841 this.lineStart = this.pos;
4842 }
4843 break
4844 case 47: // '/'
4845 switch (this.input.charCodeAt(this.pos + 1)) {
4846 case 42: // '*'
4847 this.skipBlockComment();
4848 break
4849 case 47:
4850 this.skipLineComment(2);
4851 break
4852 default:
4853 break loop
4854 }
4855 break
4856 default:
4857 if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {
4858 ++this.pos;
4859 } else {
4860 break loop
4861 }
4862 }
4863 }
4864 };
4865
4866 // Called at the end of every token. Sets `end`, `val`, and
4867 // maintains `context` and `exprAllowed`, and skips the space after
4868 // the token, so that the next one's `start` will point at the
4869 // right position.
4870
4871 pp.finishToken = function(type, val) {
4872 this.end = this.pos;
4873 if (this.options.locations) { this.endLoc = this.curPosition(); }
4874 var prevType = this.type;
4875 this.type = type;
4876 this.value = val;
4877
4878 this.updateContext(prevType);
4879 };
4880
4881 // ### Token reading
4882
4883 // This is the function that is called to fetch the next token. It
4884 // is somewhat obscure, because it works in character codes rather
4885 // than characters, and because operator parsing has been inlined
4886 // into it.
4887 //
4888 // All in the name of speed.
4889 //
4890 pp.readToken_dot = function() {
4891 var next = this.input.charCodeAt(this.pos + 1);
4892 if (next >= 48 && next <= 57) { return this.readNumber(true) }
4893 var next2 = this.input.charCodeAt(this.pos + 2);
4894 if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.'
4895 this.pos += 3;
4896 return this.finishToken(types$1.ellipsis)
4897 } else {
4898 ++this.pos;
4899 return this.finishToken(types$1.dot)
4900 }
4901 };
4902
4903 pp.readToken_slash = function() { // '/'
4904 var next = this.input.charCodeAt(this.pos + 1);
4905 if (this.exprAllowed) { ++this.pos; return this.readRegexp() }
4906 if (next === 61) { return this.finishOp(types$1.assign, 2) }
4907 return this.finishOp(types$1.slash, 1)
4908 };
4909
4910 pp.readToken_mult_modulo_exp = function(code) { // '%*'
4911 var next = this.input.charCodeAt(this.pos + 1);
4912 var size = 1;
4913 var tokentype = code === 42 ? types$1.star : types$1.modulo;
4914
4915 // exponentiation operator ** and **=
4916 if (this.options.ecmaVersion >= 7 && code === 42 && next === 42) {
4917 ++size;
4918 tokentype = types$1.starstar;
4919 next = this.input.charCodeAt(this.pos + 2);
4920 }
4921
4922 if (next === 61) { return this.finishOp(types$1.assign, size + 1) }
4923 return this.finishOp(tokentype, size)
4924 };
4925
4926 pp.readToken_pipe_amp = function(code) { // '|&'
4927 var next = this.input.charCodeAt(this.pos + 1);
4928 if (next === code) {
4929 if (this.options.ecmaVersion >= 12) {
4930 var next2 = this.input.charCodeAt(this.pos + 2);
4931 if (next2 === 61) { return this.finishOp(types$1.assign, 3) }
4932 }
4933 return this.finishOp(code === 124 ? types$1.logicalOR : types$1.logicalAND, 2)
4934 }
4935 if (next === 61) { return this.finishOp(types$1.assign, 2) }
4936 return this.finishOp(code === 124 ? types$1.bitwiseOR : types$1.bitwiseAND, 1)
4937 };
4938
4939 pp.readToken_caret = function() { // '^'
4940 var next = this.input.charCodeAt(this.pos + 1);
4941 if (next === 61) { return this.finishOp(types$1.assign, 2) }
4942 return this.finishOp(types$1.bitwiseXOR, 1)
4943 };
4944
4945 pp.readToken_plus_min = function(code) { // '+-'
4946 var next = this.input.charCodeAt(this.pos + 1);
4947 if (next === code) {
4948 if (next === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 &&
4949 (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) {
4950 // A `-->` line comment
4951 this.skipLineComment(3);
4952 this.skipSpace();
4953 return this.nextToken()
4954 }
4955 return this.finishOp(types$1.incDec, 2)
4956 }
4957 if (next === 61) { return this.finishOp(types$1.assign, 2) }
4958 return this.finishOp(types$1.plusMin, 1)
4959 };
4960
4961 pp.readToken_lt_gt = function(code) { // '<>'
4962 var next = this.input.charCodeAt(this.pos + 1);
4963 var size = 1;
4964 if (next === code) {
4965 size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;
4966 if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types$1.assign, size + 1) }
4967 return this.finishOp(types$1.bitShift, size)
4968 }
4969 if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 &&
4970 this.input.charCodeAt(this.pos + 3) === 45) {
4971 // `<!--`, an XML-style comment that should be interpreted as a line comment
4972 this.skipLineComment(4);
4973 this.skipSpace();
4974 return this.nextToken()
4975 }
4976 if (next === 61) { size = 2; }
4977 return this.finishOp(types$1.relational, size)
4978 };
4979
4980 pp.readToken_eq_excl = function(code) { // '=!'
4981 var next = this.input.charCodeAt(this.pos + 1);
4982 if (next === 61) { return this.finishOp(types$1.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2) }
4983 if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) { // '=>'
4984 this.pos += 2;
4985 return this.finishToken(types$1.arrow)
4986 }
4987 return this.finishOp(code === 61 ? types$1.eq : types$1.prefix, 1)
4988 };
4989
4990 pp.readToken_question = function() { // '?'
4991 var ecmaVersion = this.options.ecmaVersion;
4992 if (ecmaVersion >= 11) {
4993 var next = this.input.charCodeAt(this.pos + 1);
4994 if (next === 46) {
4995 var next2 = this.input.charCodeAt(this.pos + 2);
4996 if (next2 < 48 || next2 > 57) { return this.finishOp(types$1.questionDot, 2) }
4997 }
4998 if (next === 63) {
4999 if (ecmaVersion >= 12) {
5000 var next2$1 = this.input.charCodeAt(this.pos + 2);
5001 if (next2$1 === 61) { return this.finishOp(types$1.assign, 3) }
5002 }
5003 return this.finishOp(types$1.coalesce, 2)
5004 }
5005 }
5006 return this.finishOp(types$1.question, 1)
5007 };
5008
5009 pp.readToken_numberSign = function() { // '#'
5010 var ecmaVersion = this.options.ecmaVersion;
5011 var code = 35; // '#'
5012 if (ecmaVersion >= 13) {
5013 ++this.pos;
5014 code = this.fullCharCodeAtPos();
5015 if (isIdentifierStart(code, true) || code === 92 /* '\' */) {
5016 return this.finishToken(types$1.privateId, this.readWord1())
5017 }
5018 }
5019
5020 this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
5021 };
5022
5023 pp.getTokenFromCode = function(code) {
5024 switch (code) {
5025 // The interpretation of a dot depends on whether it is followed
5026 // by a digit or another two dots.
5027 case 46: // '.'
5028 return this.readToken_dot()
5029
5030 // Punctuation tokens.
5031 case 40: ++this.pos; return this.finishToken(types$1.parenL)
5032 case 41: ++this.pos; return this.finishToken(types$1.parenR)
5033 case 59: ++this.pos; return this.finishToken(types$1.semi)
5034 case 44: ++this.pos; return this.finishToken(types$1.comma)
5035 case 91: ++this.pos; return this.finishToken(types$1.bracketL)
5036 case 93: ++this.pos; return this.finishToken(types$1.bracketR)
5037 case 123: ++this.pos; return this.finishToken(types$1.braceL)
5038 case 125: ++this.pos; return this.finishToken(types$1.braceR)
5039 case 58: ++this.pos; return this.finishToken(types$1.colon)
5040
5041 case 96: // '`'
5042 if (this.options.ecmaVersion < 6) { break }
5043 ++this.pos;
5044 return this.finishToken(types$1.backQuote)
5045
5046 case 48: // '0'
5047 var next = this.input.charCodeAt(this.pos + 1);
5048 if (next === 120 || next === 88) { return this.readRadixNumber(16) } // '0x', '0X' - hex number
5049 if (this.options.ecmaVersion >= 6) {
5050 if (next === 111 || next === 79) { return this.readRadixNumber(8) } // '0o', '0O' - octal number
5051 if (next === 98 || next === 66) { return this.readRadixNumber(2) } // '0b', '0B' - binary number
5052 }
5053
5054 // Anything else beginning with a digit is an integer, octal
5055 // number, or float.
5056 case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: // 1-9
5057 return this.readNumber(false)
5058
5059 // Quotes produce strings.
5060 case 34: case 39: // '"', "'"
5061 return this.readString(code)
5062
5063 // Operators are parsed inline in tiny state machines. '=' (61) is
5064 // often referred to. `finishOp` simply skips the amount of
5065 // characters it is given as second argument, and returns a token
5066 // of the type given by its first argument.
5067 case 47: // '/'
5068 return this.readToken_slash()
5069
5070 case 37: case 42: // '%*'
5071 return this.readToken_mult_modulo_exp(code)
5072
5073 case 124: case 38: // '|&'
5074 return this.readToken_pipe_amp(code)
5075
5076 case 94: // '^'
5077 return this.readToken_caret()
5078
5079 case 43: case 45: // '+-'
5080 return this.readToken_plus_min(code)
5081
5082 case 60: case 62: // '<>'
5083 return this.readToken_lt_gt(code)
5084
5085 case 61: case 33: // '=!'
5086 return this.readToken_eq_excl(code)
5087
5088 case 63: // '?'
5089 return this.readToken_question()
5090
5091 case 126: // '~'
5092 return this.finishOp(types$1.prefix, 1)
5093
5094 case 35: // '#'
5095 return this.readToken_numberSign()
5096 }
5097
5098 this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
5099 };
5100
5101 pp.finishOp = function(type, size) {
5102 var str = this.input.slice(this.pos, this.pos + size);
5103 this.pos += size;
5104 return this.finishToken(type, str)
5105 };
5106
5107 pp.readRegexp = function() {
5108 var escaped, inClass, start = this.pos;
5109 for (;;) {
5110 if (this.pos >= this.input.length) { this.raise(start, "Unterminated regular expression"); }
5111 var ch = this.input.charAt(this.pos);
5112 if (lineBreak.test(ch)) { this.raise(start, "Unterminated regular expression"); }
5113 if (!escaped) {
5114 if (ch === "[") { inClass = true; }
5115 else if (ch === "]" && inClass) { inClass = false; }
5116 else if (ch === "/" && !inClass) { break }
5117 escaped = ch === "\\";
5118 } else { escaped = false; }
5119 ++this.pos;
5120 }
5121 var pattern = this.input.slice(start, this.pos);
5122 ++this.pos;
5123 var flagsStart = this.pos;
5124 var flags = this.readWord1();
5125 if (this.containsEsc) { this.unexpected(flagsStart); }
5126
5127 // Validate pattern
5128 var state = this.regexpState || (this.regexpState = new RegExpValidationState(this));
5129 state.reset(start, pattern, flags);
5130 this.validateRegExpFlags(state);
5131 this.validateRegExpPattern(state);
5132
5133 // Create Literal#value property value.
5134 var value = null;
5135 try {
5136 value = new RegExp(pattern, flags);
5137 } catch (e) {
5138 // ESTree requires null if it failed to instantiate RegExp object.
5139 // https://github.com/estree/estree/blob/a27003adf4fd7bfad44de9cef372a2eacd527b1c/es5.md#regexpliteral
5140 }
5141
5142 return this.finishToken(types$1.regexp, {pattern: pattern, flags: flags, value: value})
5143 };
5144
5145 // Read an integer in the given radix. Return null if zero digits
5146 // were read, the integer value otherwise. When `len` is given, this
5147 // will return `null` unless the integer has exactly `len` digits.
5148
5149 pp.readInt = function(radix, len, maybeLegacyOctalNumericLiteral) {
5150 // `len` is used for character escape sequences. In that case, disallow separators.
5151 var allowSeparators = this.options.ecmaVersion >= 12 && len === undefined;
5152
5153 // `maybeLegacyOctalNumericLiteral` is true if it doesn't have prefix (0x,0o,0b)
5154 // and isn't fraction part nor exponent part. In that case, if the first digit
5155 // is zero then disallow separators.
5156 var isLegacyOctalNumericLiteral = maybeLegacyOctalNumericLiteral && this.input.charCodeAt(this.pos) === 48;
5157
5158 var start = this.pos, total = 0, lastCode = 0;
5159 for (var i = 0, e = len == null ? Infinity : len; i < e; ++i, ++this.pos) {
5160 var code = this.input.charCodeAt(this.pos), val = (void 0);
5161
5162 if (allowSeparators && code === 95) {
5163 if (isLegacyOctalNumericLiteral) { this.raiseRecoverable(this.pos, "Numeric separator is not allowed in legacy octal numeric literals"); }
5164 if (lastCode === 95) { this.raiseRecoverable(this.pos, "Numeric separator must be exactly one underscore"); }
5165 if (i === 0) { this.raiseRecoverable(this.pos, "Numeric separator is not allowed at the first of digits"); }
5166 lastCode = code;
5167 continue
5168 }
5169
5170 if (code >= 97) { val = code - 97 + 10; } // a
5171 else if (code >= 65) { val = code - 65 + 10; } // A
5172 else if (code >= 48 && code <= 57) { val = code - 48; } // 0-9
5173 else { val = Infinity; }
5174 if (val >= radix) { break }
5175 lastCode = code;
5176 total = total * radix + val;
5177 }
5178
5179 if (allowSeparators && lastCode === 95) { this.raiseRecoverable(this.pos - 1, "Numeric separator is not allowed at the last of digits"); }
5180 if (this.pos === start || len != null && this.pos - start !== len) { return null }
5181
5182 return total
5183 };
5184
5185 function stringToNumber(str, isLegacyOctalNumericLiteral) {
5186 if (isLegacyOctalNumericLiteral) {
5187 return parseInt(str, 8)
5188 }
5189
5190 // `parseFloat(value)` stops parsing at the first numeric separator then returns a wrong value.
5191 return parseFloat(str.replace(/_/g, ""))
5192 }
5193
5194 function stringToBigInt(str) {
5195 if (typeof BigInt !== "function") {
5196 return null
5197 }
5198
5199 // `BigInt(value)` throws syntax error if the string contains numeric separators.
5200 return BigInt(str.replace(/_/g, ""))
5201 }
5202
5203 pp.readRadixNumber = function(radix) {
5204 var start = this.pos;
5205 this.pos += 2; // 0x
5206 var val = this.readInt(radix);
5207 if (val == null) { this.raise(this.start + 2, "Expected number in radix " + radix); }
5208 if (this.options.ecmaVersion >= 11 && this.input.charCodeAt(this.pos) === 110) {
5209 val = stringToBigInt(this.input.slice(start, this.pos));
5210 ++this.pos;
5211 } else if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
5212 return this.finishToken(types$1.num, val)
5213 };
5214
5215 // Read an integer, octal integer, or floating-point number.
5216
5217 pp.readNumber = function(startsWithDot) {
5218 var start = this.pos;
5219 if (!startsWithDot && this.readInt(10, undefined, true) === null) { this.raise(start, "Invalid number"); }
5220 var octal = this.pos - start >= 2 && this.input.charCodeAt(start) === 48;
5221 if (octal && this.strict) { this.raise(start, "Invalid number"); }
5222 var next = this.input.charCodeAt(this.pos);
5223 if (!octal && !startsWithDot && this.options.ecmaVersion >= 11 && next === 110) {
5224 var val$1 = stringToBigInt(this.input.slice(start, this.pos));
5225 ++this.pos;
5226 if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
5227 return this.finishToken(types$1.num, val$1)
5228 }
5229 if (octal && /[89]/.test(this.input.slice(start, this.pos))) { octal = false; }
5230 if (next === 46 && !octal) { // '.'
5231 ++this.pos;
5232 this.readInt(10);
5233 next = this.input.charCodeAt(this.pos);
5234 }
5235 if ((next === 69 || next === 101) && !octal) { // 'eE'
5236 next = this.input.charCodeAt(++this.pos);
5237 if (next === 43 || next === 45) { ++this.pos; } // '+-'
5238 if (this.readInt(10) === null) { this.raise(start, "Invalid number"); }
5239 }
5240 if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
5241
5242 var val = stringToNumber(this.input.slice(start, this.pos), octal);
5243 return this.finishToken(types$1.num, val)
5244 };
5245
5246 // Read a string value, interpreting backslash-escapes.
5247
5248 pp.readCodePoint = function() {
5249 var ch = this.input.charCodeAt(this.pos), code;
5250
5251 if (ch === 123) { // '{'
5252 if (this.options.ecmaVersion < 6) { this.unexpected(); }
5253 var codePos = ++this.pos;
5254 code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);
5255 ++this.pos;
5256 if (code > 0x10FFFF) { this.invalidStringToken(codePos, "Code point out of bounds"); }
5257 } else {
5258 code = this.readHexChar(4);
5259 }
5260 return code
5261 };
5262
5263 function codePointToString(code) {
5264 // UTF-16 Decoding
5265 if (code <= 0xFFFF) { return String.fromCharCode(code) }
5266 code -= 0x10000;
5267 return String.fromCharCode((code >> 10) + 0xD800, (code & 1023) + 0xDC00)
5268 }
5269
5270 pp.readString = function(quote) {
5271 var out = "", chunkStart = ++this.pos;
5272 for (;;) {
5273 if (this.pos >= this.input.length) { this.raise(this.start, "Unterminated string constant"); }
5274 var ch = this.input.charCodeAt(this.pos);
5275 if (ch === quote) { break }
5276 if (ch === 92) { // '\'
5277 out += this.input.slice(chunkStart, this.pos);
5278 out += this.readEscapedChar(false);
5279 chunkStart = this.pos;
5280 } else if (ch === 0x2028 || ch === 0x2029) {
5281 if (this.options.ecmaVersion < 10) { this.raise(this.start, "Unterminated string constant"); }
5282 ++this.pos;
5283 if (this.options.locations) {
5284 this.curLine++;
5285 this.lineStart = this.pos;
5286 }
5287 } else {
5288 if (isNewLine(ch)) { this.raise(this.start, "Unterminated string constant"); }
5289 ++this.pos;
5290 }
5291 }
5292 out += this.input.slice(chunkStart, this.pos++);
5293 return this.finishToken(types$1.string, out)
5294 };
5295
5296 // Reads template string tokens.
5297
5298 var INVALID_TEMPLATE_ESCAPE_ERROR = {};
5299
5300 pp.tryReadTemplateToken = function() {
5301 this.inTemplateElement = true;
5302 try {
5303 this.readTmplToken();
5304 } catch (err) {
5305 if (err === INVALID_TEMPLATE_ESCAPE_ERROR) {
5306 this.readInvalidTemplateToken();
5307 } else {
5308 throw err
5309 }
5310 }
5311
5312 this.inTemplateElement = false;
5313 };
5314
5315 pp.invalidStringToken = function(position, message) {
5316 if (this.inTemplateElement && this.options.ecmaVersion >= 9) {
5317 throw INVALID_TEMPLATE_ESCAPE_ERROR
5318 } else {
5319 this.raise(position, message);
5320 }
5321 };
5322
5323 pp.readTmplToken = function() {
5324 var out = "", chunkStart = this.pos;
5325 for (;;) {
5326 if (this.pos >= this.input.length) { this.raise(this.start, "Unterminated template"); }
5327 var ch = this.input.charCodeAt(this.pos);
5328 if (ch === 96 || ch === 36 && this.input.charCodeAt(this.pos + 1) === 123) { // '`', '${'
5329 if (this.pos === this.start && (this.type === types$1.template || this.type === types$1.invalidTemplate)) {
5330 if (ch === 36) {
5331 this.pos += 2;
5332 return this.finishToken(types$1.dollarBraceL)
5333 } else {
5334 ++this.pos;
5335 return this.finishToken(types$1.backQuote)
5336 }
5337 }
5338 out += this.input.slice(chunkStart, this.pos);
5339 return this.finishToken(types$1.template, out)
5340 }
5341 if (ch === 92) { // '\'
5342 out += this.input.slice(chunkStart, this.pos);
5343 out += this.readEscapedChar(true);
5344 chunkStart = this.pos;
5345 } else if (isNewLine(ch)) {
5346 out += this.input.slice(chunkStart, this.pos);
5347 ++this.pos;
5348 switch (ch) {
5349 case 13:
5350 if (this.input.charCodeAt(this.pos) === 10) { ++this.pos; }
5351 case 10:
5352 out += "\n";
5353 break
5354 default:
5355 out += String.fromCharCode(ch);
5356 break
5357 }
5358 if (this.options.locations) {
5359 ++this.curLine;
5360 this.lineStart = this.pos;
5361 }
5362 chunkStart = this.pos;
5363 } else {
5364 ++this.pos;
5365 }
5366 }
5367 };
5368
5369 // Reads a template token to search for the end, without validating any escape sequences
5370 pp.readInvalidTemplateToken = function() {
5371 for (; this.pos < this.input.length; this.pos++) {
5372 switch (this.input[this.pos]) {
5373 case "\\":
5374 ++this.pos;
5375 break
5376
5377 case "$":
5378 if (this.input[this.pos + 1] !== "{") {
5379 break
5380 }
5381
5382 // falls through
5383 case "`":
5384 return this.finishToken(types$1.invalidTemplate, this.input.slice(this.start, this.pos))
5385
5386 // no default
5387 }
5388 }
5389 this.raise(this.start, "Unterminated template");
5390 };
5391
5392 // Used to read escaped characters
5393
5394 pp.readEscapedChar = function(inTemplate) {
5395 var ch = this.input.charCodeAt(++this.pos);
5396 ++this.pos;
5397 switch (ch) {
5398 case 110: return "\n" // 'n' -> '\n'
5399 case 114: return "\r" // 'r' -> '\r'
5400 case 120: return String.fromCharCode(this.readHexChar(2)) // 'x'
5401 case 117: return codePointToString(this.readCodePoint()) // 'u'
5402 case 116: return "\t" // 't' -> '\t'
5403 case 98: return "\b" // 'b' -> '\b'
5404 case 118: return "\u000b" // 'v' -> '\u000b'
5405 case 102: return "\f" // 'f' -> '\f'
5406 case 13: if (this.input.charCodeAt(this.pos) === 10) { ++this.pos; } // '\r\n'
5407 case 10: // ' \n'
5408 if (this.options.locations) { this.lineStart = this.pos; ++this.curLine; }
5409 return ""
5410 case 56:
5411 case 57:
5412 if (this.strict) {
5413 this.invalidStringToken(
5414 this.pos - 1,
5415 "Invalid escape sequence"
5416 );
5417 }
5418 if (inTemplate) {
5419 var codePos = this.pos - 1;
5420
5421 this.invalidStringToken(
5422 codePos,
5423 "Invalid escape sequence in template string"
5424 );
5425
5426 return null
5427 }
5428 default:
5429 if (ch >= 48 && ch <= 55) {
5430 var octalStr = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0];
5431 var octal = parseInt(octalStr, 8);
5432 if (octal > 255) {
5433 octalStr = octalStr.slice(0, -1);
5434 octal = parseInt(octalStr, 8);
5435 }
5436 this.pos += octalStr.length - 1;
5437 ch = this.input.charCodeAt(this.pos);
5438 if ((octalStr !== "0" || ch === 56 || ch === 57) && (this.strict || inTemplate)) {
5439 this.invalidStringToken(
5440 this.pos - 1 - octalStr.length,
5441 inTemplate
5442 ? "Octal literal in template string"
5443 : "Octal literal in strict mode"
5444 );
5445 }
5446 return String.fromCharCode(octal)
5447 }
5448 if (isNewLine(ch)) {
5449 // Unicode new line characters after \ get removed from output in both
5450 // template literals and strings
5451 return ""
5452 }
5453 return String.fromCharCode(ch)
5454 }
5455 };
5456
5457 // Used to read character escape sequences ('\x', '\u', '\U').
5458
5459 pp.readHexChar = function(len) {
5460 var codePos = this.pos;
5461 var n = this.readInt(16, len);
5462 if (n === null) { this.invalidStringToken(codePos, "Bad character escape sequence"); }
5463 return n
5464 };
5465
5466 // Read an identifier, and return it as a string. Sets `this.containsEsc`
5467 // to whether the word contained a '\u' escape.
5468 //
5469 // Incrementally adds only escaped chars, adding other chunks as-is
5470 // as a micro-optimization.
5471
5472 pp.readWord1 = function() {
5473 this.containsEsc = false;
5474 var word = "", first = true, chunkStart = this.pos;
5475 var astral = this.options.ecmaVersion >= 6;
5476 while (this.pos < this.input.length) {
5477 var ch = this.fullCharCodeAtPos();
5478 if (isIdentifierChar(ch, astral)) {
5479 this.pos += ch <= 0xffff ? 1 : 2;
5480 } else if (ch === 92) { // "\"
5481 this.containsEsc = true;
5482 word += this.input.slice(chunkStart, this.pos);
5483 var escStart = this.pos;
5484 if (this.input.charCodeAt(++this.pos) !== 117) // "u"
5485 { this.invalidStringToken(this.pos, "Expecting Unicode escape sequence \\uXXXX"); }
5486 ++this.pos;
5487 var esc = this.readCodePoint();
5488 if (!(first ? isIdentifierStart : isIdentifierChar)(esc, astral))
5489 { this.invalidStringToken(escStart, "Invalid Unicode escape"); }
5490 word += codePointToString(esc);
5491 chunkStart = this.pos;
5492 } else {
5493 break
5494 }
5495 first = false;
5496 }
5497 return word + this.input.slice(chunkStart, this.pos)
5498 };
5499
5500 // Read an identifier or keyword token. Will check for reserved
5501 // words when necessary.
5502
5503 pp.readWord = function() {
5504 var word = this.readWord1();
5505 var type = types$1.name;
5506 if (this.keywords.test(word)) {
5507 type = keywords[word];
5508 }
5509 return this.finishToken(type, word)
5510 };
5511
5512 // Acorn is a tiny, fast JavaScript parser written in JavaScript.
5513
5514 var version = "8.6.0";
5515
5516 Parser.acorn = {
5517 Parser: Parser,
5518 version: version,
5519 defaultOptions: defaultOptions,
5520 Position: Position,
5521 SourceLocation: SourceLocation,
5522 getLineInfo: getLineInfo,
5523 Node: Node,
5524 TokenType: TokenType,
5525 tokTypes: types$1,
5526 keywordTypes: keywords,
5527 TokContext: TokContext,
5528 tokContexts: types,
5529 isIdentifierChar: isIdentifierChar,
5530 isIdentifierStart: isIdentifierStart,
5531 Token: Token,
5532 isNewLine: isNewLine,
5533 lineBreak: lineBreak,
5534 lineBreakG: lineBreakG,
5535 nonASCIIwhitespace: nonASCIIwhitespace
5536 };
5537
5538 // The main exported interface (under `self.acorn` when in the
5539 // browser) is a `parse` function that takes a code string and
5540 // returns an abstract syntax tree as specified by [Mozilla parser
5541 // API][api].
5542 //
5543 // [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
5544
5545 function parse(input, options) {
5546 return Parser.parse(input, options)
5547 }
5548
5549 // This function tries to parse a single expression at a given
5550 // offset in a string. Useful for parsing mixed-language formats
5551 // that embed JavaScript expressions.
5552
5553 function parseExpressionAt(input, pos, options) {
5554 return Parser.parseExpressionAt(input, pos, options)
5555 }
5556
5557 // Acorn is organized as a tokenizer and a recursive-descent parser.
5558 // The `tokenizer` export provides an interface to the tokenizer.
5559
5560 function tokenizer(input, options) {
5561 return Parser.tokenizer(input, options)
5562 }
5563
5564 exports.Node = Node;
5565 exports.Parser = Parser;
5566 exports.Position = Position;
5567 exports.SourceLocation = SourceLocation;
5568 exports.TokContext = TokContext;
5569 exports.Token = Token;
5570 exports.TokenType = TokenType;
5571 exports.defaultOptions = defaultOptions;
5572 exports.getLineInfo = getLineInfo;
5573 exports.isIdentifierChar = isIdentifierChar;
5574 exports.isIdentifierStart = isIdentifierStart;
5575 exports.isNewLine = isNewLine;
5576 exports.keywordTypes = keywords;
5577 exports.lineBreak = lineBreak;
5578 exports.lineBreakG = lineBreakG;
5579 exports.nonASCIIwhitespace = nonASCIIwhitespace;
5580 exports.parse = parse;
5581 exports.parseExpressionAt = parseExpressionAt;
5582 exports.tokContexts = types;
5583 exports.tokTypes = types$1;
5584 exports.tokenizer = tokenizer;
5585 exports.version = version;
5586
5587 Object.defineProperty(exports, '__esModule', { value: true });
5588
5589}));
Note: See TracBrowser for help on using the repository browser.