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

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

initial commit

  • Property mode set to 100644
File size: 210.0 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 = 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 = {
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$1 = {};
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$1[name] = new TokenType(name, options)
148 }
149
150 var types = {
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[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.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 prototypeAccessors.inGenerator.get = function () { return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 && !this.currentVarScope().inClassFieldInit };
584 prototypeAccessors.inAsync.get = function () { return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 && !this.currentVarScope().inClassFieldInit };
585 prototypeAccessors.canAwait.get = function () {
586 for (var i = this.scopeStack.length - 1; i >= 0; i--) {
587 var scope = this.scopeStack[i];
588 if (scope.inClassFieldInit || scope.flags & SCOPE_CLASS_STATIC_BLOCK) { return false }
589 if (scope.flags & SCOPE_FUNCTION) { return (scope.flags & SCOPE_ASYNC) > 0 }
590 }
591 return (this.inModule && this.options.ecmaVersion >= 13) || this.options.allowAwaitOutsideFunction
592 };
593 prototypeAccessors.allowSuper.get = function () {
594 var ref = this.currentThisScope();
595 var flags = ref.flags;
596 var inClassFieldInit = ref.inClassFieldInit;
597 return (flags & SCOPE_SUPER) > 0 || inClassFieldInit || this.options.allowSuperOutsideMethod
598 };
599 prototypeAccessors.allowDirectSuper.get = function () { return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0 };
600 prototypeAccessors.treatFunctionsAsVar.get = function () { return this.treatFunctionsAsVarInScope(this.currentScope()) };
601 prototypeAccessors.allowNewDotTarget.get = function () {
602 var ref = this.currentThisScope();
603 var flags = ref.flags;
604 var inClassFieldInit = ref.inClassFieldInit;
605 return (flags & (SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK)) > 0 || inClassFieldInit
606 };
607 prototypeAccessors.inClassStaticBlock.get = function () {
608 return (this.currentVarScope().flags & SCOPE_CLASS_STATIC_BLOCK) > 0
609 };
610
611 Parser.extend = function extend () {
612 var plugins = [], len = arguments.length;
613 while ( len-- ) plugins[ len ] = arguments[ len ];
614
615 var cls = this;
616 for (var i = 0; i < plugins.length; i++) { cls = plugins[i](cls); }
617 return cls
618 };
619
620 Parser.parse = function parse (input, options) {
621 return new this(options, input).parse()
622 };
623
624 Parser.parseExpressionAt = function parseExpressionAt (input, pos, options) {
625 var parser = new this(options, input, pos);
626 parser.nextToken();
627 return parser.parseExpression()
628 };
629
630 Parser.tokenizer = function tokenizer (input, options) {
631 return new this(options, input)
632 };
633
634 Object.defineProperties( Parser.prototype, prototypeAccessors );
635
636 var pp = Parser.prototype;
637
638 // ## Parser utilities
639
640 var literal = /^(?:'((?:\\.|[^'\\])*?)'|"((?:\\.|[^"\\])*?)")/;
641 pp.strictDirective = function(start) {
642 for (;;) {
643 // Try to find string literal.
644 skipWhiteSpace.lastIndex = start;
645 start += skipWhiteSpace.exec(this.input)[0].length;
646 var match = literal.exec(this.input.slice(start));
647 if (!match) { return false }
648 if ((match[1] || match[2]) === "use strict") {
649 skipWhiteSpace.lastIndex = start + match[0].length;
650 var spaceAfter = skipWhiteSpace.exec(this.input), end = spaceAfter.index + spaceAfter[0].length;
651 var next = this.input.charAt(end);
652 return next === ";" || next === "}" ||
653 (lineBreak.test(spaceAfter[0]) &&
654 !(/[(`.[+\-/*%<>=,?^&]/.test(next) || next === "!" && this.input.charAt(end + 1) === "="))
655 }
656 start += match[0].length;
657
658 // Skip semicolon, if any.
659 skipWhiteSpace.lastIndex = start;
660 start += skipWhiteSpace.exec(this.input)[0].length;
661 if (this.input[start] === ";")
662 { start++; }
663 }
664 };
665
666 // Predicate that tests whether the next token is of the given
667 // type, and if yes, consumes it as a side effect.
668
669 pp.eat = function(type) {
670 if (this.type === type) {
671 this.next();
672 return true
673 } else {
674 return false
675 }
676 };
677
678 // Tests whether parsed token is a contextual keyword.
679
680 pp.isContextual = function(name) {
681 return this.type === types.name && this.value === name && !this.containsEsc
682 };
683
684 // Consumes contextual keyword if possible.
685
686 pp.eatContextual = function(name) {
687 if (!this.isContextual(name)) { return false }
688 this.next();
689 return true
690 };
691
692 // Asserts that following token is given contextual keyword.
693
694 pp.expectContextual = function(name) {
695 if (!this.eatContextual(name)) { this.unexpected(); }
696 };
697
698 // Test whether a semicolon can be inserted at the current position.
699
700 pp.canInsertSemicolon = function() {
701 return this.type === types.eof ||
702 this.type === types.braceR ||
703 lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
704 };
705
706 pp.insertSemicolon = function() {
707 if (this.canInsertSemicolon()) {
708 if (this.options.onInsertedSemicolon)
709 { this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc); }
710 return true
711 }
712 };
713
714 // Consume a semicolon, or, failing that, see if we are allowed to
715 // pretend that there is a semicolon at this position.
716
717 pp.semicolon = function() {
718 if (!this.eat(types.semi) && !this.insertSemicolon()) { this.unexpected(); }
719 };
720
721 pp.afterTrailingComma = function(tokType, notNext) {
722 if (this.type === tokType) {
723 if (this.options.onTrailingComma)
724 { this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc); }
725 if (!notNext)
726 { this.next(); }
727 return true
728 }
729 };
730
731 // Expect a token of a given type. If found, consume it, otherwise,
732 // raise an unexpected token error.
733
734 pp.expect = function(type) {
735 this.eat(type) || this.unexpected();
736 };
737
738 // Raise an unexpected token error.
739
740 pp.unexpected = function(pos) {
741 this.raise(pos != null ? pos : this.start, "Unexpected token");
742 };
743
744 function DestructuringErrors() {
745 this.shorthandAssign =
746 this.trailingComma =
747 this.parenthesizedAssign =
748 this.parenthesizedBind =
749 this.doubleProto =
750 -1;
751 }
752
753 pp.checkPatternErrors = function(refDestructuringErrors, isAssign) {
754 if (!refDestructuringErrors) { return }
755 if (refDestructuringErrors.trailingComma > -1)
756 { this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element"); }
757 var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind;
758 if (parens > -1) { this.raiseRecoverable(parens, "Parenthesized pattern"); }
759 };
760
761 pp.checkExpressionErrors = function(refDestructuringErrors, andThrow) {
762 if (!refDestructuringErrors) { return false }
763 var shorthandAssign = refDestructuringErrors.shorthandAssign;
764 var doubleProto = refDestructuringErrors.doubleProto;
765 if (!andThrow) { return shorthandAssign >= 0 || doubleProto >= 0 }
766 if (shorthandAssign >= 0)
767 { this.raise(shorthandAssign, "Shorthand property assignments are valid only in destructuring patterns"); }
768 if (doubleProto >= 0)
769 { this.raiseRecoverable(doubleProto, "Redefinition of __proto__ property"); }
770 };
771
772 pp.checkYieldAwaitInDefaultParams = function() {
773 if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos))
774 { this.raise(this.yieldPos, "Yield expression cannot be a default value"); }
775 if (this.awaitPos)
776 { this.raise(this.awaitPos, "Await expression cannot be a default value"); }
777 };
778
779 pp.isSimpleAssignTarget = function(expr) {
780 if (expr.type === "ParenthesizedExpression")
781 { return this.isSimpleAssignTarget(expr.expression) }
782 return expr.type === "Identifier" || expr.type === "MemberExpression"
783 };
784
785 var pp$1 = Parser.prototype;
786
787 // ### Statement parsing
788
789 // Parse a program. Initializes the parser, reads any number of
790 // statements, and wraps them in a Program node. Optionally takes a
791 // `program` argument. If present, the statements will be appended
792 // to its body instead of creating a new node.
793
794 pp$1.parseTopLevel = function(node) {
795 var exports = Object.create(null);
796 if (!node.body) { node.body = []; }
797 while (this.type !== types.eof) {
798 var stmt = this.parseStatement(null, true, exports);
799 node.body.push(stmt);
800 }
801 if (this.inModule)
802 { for (var i = 0, list = Object.keys(this.undefinedExports); i < list.length; i += 1)
803 {
804 var name = list[i];
805
806 this.raiseRecoverable(this.undefinedExports[name].start, ("Export '" + name + "' is not defined"));
807 } }
808 this.adaptDirectivePrologue(node.body);
809 this.next();
810 node.sourceType = this.options.sourceType;
811 return this.finishNode(node, "Program")
812 };
813
814 var loopLabel = {kind: "loop"}, switchLabel = {kind: "switch"};
815
816 pp$1.isLet = function(context) {
817 if (this.options.ecmaVersion < 6 || !this.isContextual("let")) { return false }
818 skipWhiteSpace.lastIndex = this.pos;
819 var skip = skipWhiteSpace.exec(this.input);
820 var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
821 // For ambiguous cases, determine if a LexicalDeclaration (or only a
822 // Statement) is allowed here. If context is not empty then only a Statement
823 // is allowed. However, `let [` is an explicit negative lookahead for
824 // ExpressionStatement, so special-case it first.
825 if (nextCh === 91 || nextCh === 92 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true } // '[', '/', astral
826 if (context) { return false }
827
828 if (nextCh === 123) { return true } // '{'
829 if (isIdentifierStart(nextCh, true)) {
830 var pos = next + 1;
831 while (isIdentifierChar(nextCh = this.input.charCodeAt(pos), true)) { ++pos; }
832 if (nextCh === 92 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true }
833 var ident = this.input.slice(next, pos);
834 if (!keywordRelationalOperator.test(ident)) { return true }
835 }
836 return false
837 };
838
839 // check 'async [no LineTerminator here] function'
840 // - 'async /*foo*/ function' is OK.
841 // - 'async /*\n*/ function' is invalid.
842 pp$1.isAsyncFunction = function() {
843 if (this.options.ecmaVersion < 8 || !this.isContextual("async"))
844 { return false }
845
846 skipWhiteSpace.lastIndex = this.pos;
847 var skip = skipWhiteSpace.exec(this.input);
848 var next = this.pos + skip[0].length, after;
849 return !lineBreak.test(this.input.slice(this.pos, next)) &&
850 this.input.slice(next, next + 8) === "function" &&
851 (next + 8 === this.input.length ||
852 !(isIdentifierChar(after = this.input.charCodeAt(next + 8)) || after > 0xd7ff && after < 0xdc00))
853 };
854
855 // Parse a single statement.
856 //
857 // If expecting a statement and finding a slash operator, parse a
858 // regular expression literal. This is to handle cases like
859 // `if (foo) /blah/.exec(foo)`, where looking at the previous token
860 // does not help.
861
862 pp$1.parseStatement = function(context, topLevel, exports) {
863 var starttype = this.type, node = this.startNode(), kind;
864
865 if (this.isLet(context)) {
866 starttype = types._var;
867 kind = "let";
868 }
869
870 // Most types of statements are recognized by the keyword they
871 // start with. Many are trivial to parse, some require a bit of
872 // complexity.
873
874 switch (starttype) {
875 case types._break: case types._continue: return this.parseBreakContinueStatement(node, starttype.keyword)
876 case types._debugger: return this.parseDebuggerStatement(node)
877 case types._do: return this.parseDoStatement(node)
878 case types._for: return this.parseForStatement(node)
879 case types._function:
880 // Function as sole body of either an if statement or a labeled statement
881 // works, but not when it is part of a labeled statement that is the sole
882 // body of an if statement.
883 if ((context && (this.strict || context !== "if" && context !== "label")) && this.options.ecmaVersion >= 6) { this.unexpected(); }
884 return this.parseFunctionStatement(node, false, !context)
885 case types._class:
886 if (context) { this.unexpected(); }
887 return this.parseClass(node, true)
888 case types._if: return this.parseIfStatement(node)
889 case types._return: return this.parseReturnStatement(node)
890 case types._switch: return this.parseSwitchStatement(node)
891 case types._throw: return this.parseThrowStatement(node)
892 case types._try: return this.parseTryStatement(node)
893 case types._const: case types._var:
894 kind = kind || this.value;
895 if (context && kind !== "var") { this.unexpected(); }
896 return this.parseVarStatement(node, kind)
897 case types._while: return this.parseWhileStatement(node)
898 case types._with: return this.parseWithStatement(node)
899 case types.braceL: return this.parseBlock(true, node)
900 case types.semi: return this.parseEmptyStatement(node)
901 case types._export:
902 case types._import:
903 if (this.options.ecmaVersion > 10 && starttype === types._import) {
904 skipWhiteSpace.lastIndex = this.pos;
905 var skip = skipWhiteSpace.exec(this.input);
906 var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
907 if (nextCh === 40 || nextCh === 46) // '(' or '.'
908 { return this.parseExpressionStatement(node, this.parseExpression()) }
909 }
910
911 if (!this.options.allowImportExportEverywhere) {
912 if (!topLevel)
913 { this.raise(this.start, "'import' and 'export' may only appear at the top level"); }
914 if (!this.inModule)
915 { this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'"); }
916 }
917 return starttype === types._import ? this.parseImport(node) : this.parseExport(node, exports)
918
919 // If the statement does not start with a statement keyword or a
920 // brace, it's an ExpressionStatement or LabeledStatement. We
921 // simply start parsing an expression, and afterwards, if the
922 // next token is a colon and the expression was a simple
923 // Identifier node, we switch to interpreting it as a label.
924 default:
925 if (this.isAsyncFunction()) {
926 if (context) { this.unexpected(); }
927 this.next();
928 return this.parseFunctionStatement(node, true, !context)
929 }
930
931 var maybeName = this.value, expr = this.parseExpression();
932 if (starttype === types.name && expr.type === "Identifier" && this.eat(types.colon))
933 { return this.parseLabeledStatement(node, maybeName, expr, context) }
934 else { return this.parseExpressionStatement(node, expr) }
935 }
936 };
937
938 pp$1.parseBreakContinueStatement = function(node, keyword) {
939 var isBreak = keyword === "break";
940 this.next();
941 if (this.eat(types.semi) || this.insertSemicolon()) { node.label = null; }
942 else if (this.type !== types.name) { this.unexpected(); }
943 else {
944 node.label = this.parseIdent();
945 this.semicolon();
946 }
947
948 // Verify that there is an actual destination to break or
949 // continue to.
950 var i = 0;
951 for (; i < this.labels.length; ++i) {
952 var lab = this.labels[i];
953 if (node.label == null || lab.name === node.label.name) {
954 if (lab.kind != null && (isBreak || lab.kind === "loop")) { break }
955 if (node.label && isBreak) { break }
956 }
957 }
958 if (i === this.labels.length) { this.raise(node.start, "Unsyntactic " + keyword); }
959 return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement")
960 };
961
962 pp$1.parseDebuggerStatement = function(node) {
963 this.next();
964 this.semicolon();
965 return this.finishNode(node, "DebuggerStatement")
966 };
967
968 pp$1.parseDoStatement = function(node) {
969 this.next();
970 this.labels.push(loopLabel);
971 node.body = this.parseStatement("do");
972 this.labels.pop();
973 this.expect(types._while);
974 node.test = this.parseParenExpression();
975 if (this.options.ecmaVersion >= 6)
976 { this.eat(types.semi); }
977 else
978 { this.semicolon(); }
979 return this.finishNode(node, "DoWhileStatement")
980 };
981
982 // Disambiguating between a `for` and a `for`/`in` or `for`/`of`
983 // loop is non-trivial. Basically, we have to parse the init `var`
984 // statement or expression, disallowing the `in` operator (see
985 // the second parameter to `parseExpression`), and then check
986 // whether the next token is `in` or `of`. When there is no init
987 // part (semicolon immediately after the opening parenthesis), it
988 // is a regular `for` loop.
989
990 pp$1.parseForStatement = function(node) {
991 this.next();
992 var awaitAt = (this.options.ecmaVersion >= 9 && this.canAwait && this.eatContextual("await")) ? this.lastTokStart : -1;
993 this.labels.push(loopLabel);
994 this.enterScope(0);
995 this.expect(types.parenL);
996 if (this.type === types.semi) {
997 if (awaitAt > -1) { this.unexpected(awaitAt); }
998 return this.parseFor(node, null)
999 }
1000 var isLet = this.isLet();
1001 if (this.type === types._var || this.type === types._const || isLet) {
1002 var init$1 = this.startNode(), kind = isLet ? "let" : this.value;
1003 this.next();
1004 this.parseVar(init$1, true, kind);
1005 this.finishNode(init$1, "VariableDeclaration");
1006 if ((this.type === types._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1) {
1007 if (this.options.ecmaVersion >= 9) {
1008 if (this.type === types._in) {
1009 if (awaitAt > -1) { this.unexpected(awaitAt); }
1010 } else { node.await = awaitAt > -1; }
1011 }
1012 return this.parseForIn(node, init$1)
1013 }
1014 if (awaitAt > -1) { this.unexpected(awaitAt); }
1015 return this.parseFor(node, init$1)
1016 }
1017 var startsWithLet = this.isContextual("let"), isForOf = false;
1018 var refDestructuringErrors = new DestructuringErrors;
1019 var init = this.parseExpression(awaitAt > -1 ? "await" : true, refDestructuringErrors);
1020 if (this.type === types._in || (isForOf = this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
1021 if (this.options.ecmaVersion >= 9) {
1022 if (this.type === types._in) {
1023 if (awaitAt > -1) { this.unexpected(awaitAt); }
1024 } else { node.await = awaitAt > -1; }
1025 }
1026 if (startsWithLet && isForOf) { this.raise(init.start, "The left-hand side of a for-of loop may not start with 'let'."); }
1027 this.toAssignable(init, false, refDestructuringErrors);
1028 this.checkLValPattern(init);
1029 return this.parseForIn(node, init)
1030 } else {
1031 this.checkExpressionErrors(refDestructuringErrors, true);
1032 }
1033 if (awaitAt > -1) { this.unexpected(awaitAt); }
1034 return this.parseFor(node, init)
1035 };
1036
1037 pp$1.parseFunctionStatement = function(node, isAsync, declarationPosition) {
1038 this.next();
1039 return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync)
1040 };
1041
1042 pp$1.parseIfStatement = function(node) {
1043 this.next();
1044 node.test = this.parseParenExpression();
1045 // allow function declarations in branches, but only in non-strict mode
1046 node.consequent = this.parseStatement("if");
1047 node.alternate = this.eat(types._else) ? this.parseStatement("if") : null;
1048 return this.finishNode(node, "IfStatement")
1049 };
1050
1051 pp$1.parseReturnStatement = function(node) {
1052 if (!this.inFunction && !this.options.allowReturnOutsideFunction)
1053 { this.raise(this.start, "'return' outside of function"); }
1054 this.next();
1055
1056 // In `return` (and `break`/`continue`), the keywords with
1057 // optional arguments, we eagerly look for a semicolon or the
1058 // possibility to insert one.
1059
1060 if (this.eat(types.semi) || this.insertSemicolon()) { node.argument = null; }
1061 else { node.argument = this.parseExpression(); this.semicolon(); }
1062 return this.finishNode(node, "ReturnStatement")
1063 };
1064
1065 pp$1.parseSwitchStatement = function(node) {
1066 this.next();
1067 node.discriminant = this.parseParenExpression();
1068 node.cases = [];
1069 this.expect(types.braceL);
1070 this.labels.push(switchLabel);
1071 this.enterScope(0);
1072
1073 // Statements under must be grouped (by label) in SwitchCase
1074 // nodes. `cur` is used to keep the node that we are currently
1075 // adding statements to.
1076
1077 var cur;
1078 for (var sawDefault = false; this.type !== types.braceR;) {
1079 if (this.type === types._case || this.type === types._default) {
1080 var isCase = this.type === types._case;
1081 if (cur) { this.finishNode(cur, "SwitchCase"); }
1082 node.cases.push(cur = this.startNode());
1083 cur.consequent = [];
1084 this.next();
1085 if (isCase) {
1086 cur.test = this.parseExpression();
1087 } else {
1088 if (sawDefault) { this.raiseRecoverable(this.lastTokStart, "Multiple default clauses"); }
1089 sawDefault = true;
1090 cur.test = null;
1091 }
1092 this.expect(types.colon);
1093 } else {
1094 if (!cur) { this.unexpected(); }
1095 cur.consequent.push(this.parseStatement(null));
1096 }
1097 }
1098 this.exitScope();
1099 if (cur) { this.finishNode(cur, "SwitchCase"); }
1100 this.next(); // Closing brace
1101 this.labels.pop();
1102 return this.finishNode(node, "SwitchStatement")
1103 };
1104
1105 pp$1.parseThrowStatement = function(node) {
1106 this.next();
1107 if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start)))
1108 { this.raise(this.lastTokEnd, "Illegal newline after throw"); }
1109 node.argument = this.parseExpression();
1110 this.semicolon();
1111 return this.finishNode(node, "ThrowStatement")
1112 };
1113
1114 // Reused empty array added for node fields that are always empty.
1115
1116 var empty = [];
1117
1118 pp$1.parseTryStatement = function(node) {
1119 this.next();
1120 node.block = this.parseBlock();
1121 node.handler = null;
1122 if (this.type === types._catch) {
1123 var clause = this.startNode();
1124 this.next();
1125 if (this.eat(types.parenL)) {
1126 clause.param = this.parseBindingAtom();
1127 var simple = clause.param.type === "Identifier";
1128 this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0);
1129 this.checkLValPattern(clause.param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL);
1130 this.expect(types.parenR);
1131 } else {
1132 if (this.options.ecmaVersion < 10) { this.unexpected(); }
1133 clause.param = null;
1134 this.enterScope(0);
1135 }
1136 clause.body = this.parseBlock(false);
1137 this.exitScope();
1138 node.handler = this.finishNode(clause, "CatchClause");
1139 }
1140 node.finalizer = this.eat(types._finally) ? this.parseBlock() : null;
1141 if (!node.handler && !node.finalizer)
1142 { this.raise(node.start, "Missing catch or finally clause"); }
1143 return this.finishNode(node, "TryStatement")
1144 };
1145
1146 pp$1.parseVarStatement = function(node, kind) {
1147 this.next();
1148 this.parseVar(node, false, kind);
1149 this.semicolon();
1150 return this.finishNode(node, "VariableDeclaration")
1151 };
1152
1153 pp$1.parseWhileStatement = function(node) {
1154 this.next();
1155 node.test = this.parseParenExpression();
1156 this.labels.push(loopLabel);
1157 node.body = this.parseStatement("while");
1158 this.labels.pop();
1159 return this.finishNode(node, "WhileStatement")
1160 };
1161
1162 pp$1.parseWithStatement = function(node) {
1163 if (this.strict) { this.raise(this.start, "'with' in strict mode"); }
1164 this.next();
1165 node.object = this.parseParenExpression();
1166 node.body = this.parseStatement("with");
1167 return this.finishNode(node, "WithStatement")
1168 };
1169
1170 pp$1.parseEmptyStatement = function(node) {
1171 this.next();
1172 return this.finishNode(node, "EmptyStatement")
1173 };
1174
1175 pp$1.parseLabeledStatement = function(node, maybeName, expr, context) {
1176 for (var i$1 = 0, list = this.labels; i$1 < list.length; i$1 += 1)
1177 {
1178 var label = list[i$1];
1179
1180 if (label.name === maybeName)
1181 { this.raise(expr.start, "Label '" + maybeName + "' is already declared");
1182 } }
1183 var kind = this.type.isLoop ? "loop" : this.type === types._switch ? "switch" : null;
1184 for (var i = this.labels.length - 1; i >= 0; i--) {
1185 var label$1 = this.labels[i];
1186 if (label$1.statementStart === node.start) {
1187 // Update information about previous labels on this node
1188 label$1.statementStart = this.start;
1189 label$1.kind = kind;
1190 } else { break }
1191 }
1192 this.labels.push({name: maybeName, kind: kind, statementStart: this.start});
1193 node.body = this.parseStatement(context ? context.indexOf("label") === -1 ? context + "label" : context : "label");
1194 this.labels.pop();
1195 node.label = expr;
1196 return this.finishNode(node, "LabeledStatement")
1197 };
1198
1199 pp$1.parseExpressionStatement = function(node, expr) {
1200 node.expression = expr;
1201 this.semicolon();
1202 return this.finishNode(node, "ExpressionStatement")
1203 };
1204
1205 // Parse a semicolon-enclosed block of statements, handling `"use
1206 // strict"` declarations when `allowStrict` is true (used for
1207 // function bodies).
1208
1209 pp$1.parseBlock = function(createNewLexicalScope, node, exitStrict) {
1210 if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true;
1211 if ( node === void 0 ) node = this.startNode();
1212
1213 node.body = [];
1214 this.expect(types.braceL);
1215 if (createNewLexicalScope) { this.enterScope(0); }
1216 while (this.type !== types.braceR) {
1217 var stmt = this.parseStatement(null);
1218 node.body.push(stmt);
1219 }
1220 if (exitStrict) { this.strict = false; }
1221 this.next();
1222 if (createNewLexicalScope) { this.exitScope(); }
1223 return this.finishNode(node, "BlockStatement")
1224 };
1225
1226 // Parse a regular `for` loop. The disambiguation code in
1227 // `parseStatement` will already have parsed the init statement or
1228 // expression.
1229
1230 pp$1.parseFor = function(node, init) {
1231 node.init = init;
1232 this.expect(types.semi);
1233 node.test = this.type === types.semi ? null : this.parseExpression();
1234 this.expect(types.semi);
1235 node.update = this.type === types.parenR ? null : this.parseExpression();
1236 this.expect(types.parenR);
1237 node.body = this.parseStatement("for");
1238 this.exitScope();
1239 this.labels.pop();
1240 return this.finishNode(node, "ForStatement")
1241 };
1242
1243 // Parse a `for`/`in` and `for`/`of` loop, which are almost
1244 // same from parser's perspective.
1245
1246 pp$1.parseForIn = function(node, init) {
1247 var isForIn = this.type === types._in;
1248 this.next();
1249
1250 if (
1251 init.type === "VariableDeclaration" &&
1252 init.declarations[0].init != null &&
1253 (
1254 !isForIn ||
1255 this.options.ecmaVersion < 8 ||
1256 this.strict ||
1257 init.kind !== "var" ||
1258 init.declarations[0].id.type !== "Identifier"
1259 )
1260 ) {
1261 this.raise(
1262 init.start,
1263 ((isForIn ? "for-in" : "for-of") + " loop variable declaration may not have an initializer")
1264 );
1265 }
1266 node.left = init;
1267 node.right = isForIn ? this.parseExpression() : this.parseMaybeAssign();
1268 this.expect(types.parenR);
1269 node.body = this.parseStatement("for");
1270 this.exitScope();
1271 this.labels.pop();
1272 return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement")
1273 };
1274
1275 // Parse a list of variable declarations.
1276
1277 pp$1.parseVar = function(node, isFor, kind) {
1278 node.declarations = [];
1279 node.kind = kind;
1280 for (;;) {
1281 var decl = this.startNode();
1282 this.parseVarId(decl, kind);
1283 if (this.eat(types.eq)) {
1284 decl.init = this.parseMaybeAssign(isFor);
1285 } else if (kind === "const" && !(this.type === types._in || (this.options.ecmaVersion >= 6 && this.isContextual("of")))) {
1286 this.unexpected();
1287 } else if (decl.id.type !== "Identifier" && !(isFor && (this.type === types._in || this.isContextual("of")))) {
1288 this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");
1289 } else {
1290 decl.init = null;
1291 }
1292 node.declarations.push(this.finishNode(decl, "VariableDeclarator"));
1293 if (!this.eat(types.comma)) { break }
1294 }
1295 return node
1296 };
1297
1298 pp$1.parseVarId = function(decl, kind) {
1299 decl.id = this.parseBindingAtom();
1300 this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false);
1301 };
1302
1303 var FUNC_STATEMENT = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID = 4;
1304
1305 // Parse a function declaration or literal (depending on the
1306 // `statement & FUNC_STATEMENT`).
1307
1308 // Remove `allowExpressionBody` for 7.0.0, as it is only called with false
1309 pp$1.parseFunction = function(node, statement, allowExpressionBody, isAsync, forInit) {
1310 this.initFunction(node);
1311 if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) {
1312 if (this.type === types.star && (statement & FUNC_HANGING_STATEMENT))
1313 { this.unexpected(); }
1314 node.generator = this.eat(types.star);
1315 }
1316 if (this.options.ecmaVersion >= 8)
1317 { node.async = !!isAsync; }
1318
1319 if (statement & FUNC_STATEMENT) {
1320 node.id = (statement & FUNC_NULLABLE_ID) && this.type !== types.name ? null : this.parseIdent();
1321 if (node.id && !(statement & FUNC_HANGING_STATEMENT))
1322 // If it is a regular function declaration in sloppy mode, then it is
1323 // subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding
1324 // mode depends on properties of the current scope (see
1325 // treatFunctionsAsVar).
1326 { this.checkLValSimple(node.id, (this.strict || node.generator || node.async) ? this.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION); }
1327 }
1328
1329 var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
1330 this.yieldPos = 0;
1331 this.awaitPos = 0;
1332 this.awaitIdentPos = 0;
1333 this.enterScope(functionFlags(node.async, node.generator));
1334
1335 if (!(statement & FUNC_STATEMENT))
1336 { node.id = this.type === types.name ? this.parseIdent() : null; }
1337
1338 this.parseFunctionParams(node);
1339 this.parseFunctionBody(node, allowExpressionBody, false, forInit);
1340
1341 this.yieldPos = oldYieldPos;
1342 this.awaitPos = oldAwaitPos;
1343 this.awaitIdentPos = oldAwaitIdentPos;
1344 return this.finishNode(node, (statement & FUNC_STATEMENT) ? "FunctionDeclaration" : "FunctionExpression")
1345 };
1346
1347 pp$1.parseFunctionParams = function(node) {
1348 this.expect(types.parenL);
1349 node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8);
1350 this.checkYieldAwaitInDefaultParams();
1351 };
1352
1353 // Parse a class declaration or literal (depending on the
1354 // `isStatement` parameter).
1355
1356 pp$1.parseClass = function(node, isStatement) {
1357 this.next();
1358
1359 // ecma-262 14.6 Class Definitions
1360 // A class definition is always strict mode code.
1361 var oldStrict = this.strict;
1362 this.strict = true;
1363
1364 this.parseClassId(node, isStatement);
1365 this.parseClassSuper(node);
1366 var privateNameMap = this.enterClassBody();
1367 var classBody = this.startNode();
1368 var hadConstructor = false;
1369 classBody.body = [];
1370 this.expect(types.braceL);
1371 while (this.type !== types.braceR) {
1372 var element = this.parseClassElement(node.superClass !== null);
1373 if (element) {
1374 classBody.body.push(element);
1375 if (element.type === "MethodDefinition" && element.kind === "constructor") {
1376 if (hadConstructor) { this.raise(element.start, "Duplicate constructor in the same class"); }
1377 hadConstructor = true;
1378 } else if (element.key && element.key.type === "PrivateIdentifier" && isPrivateNameConflicted(privateNameMap, element)) {
1379 this.raiseRecoverable(element.key.start, ("Identifier '#" + (element.key.name) + "' has already been declared"));
1380 }
1381 }
1382 }
1383 this.strict = oldStrict;
1384 this.next();
1385 node.body = this.finishNode(classBody, "ClassBody");
1386 this.exitClassBody();
1387 return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression")
1388 };
1389
1390 pp$1.parseClassElement = function(constructorAllowsSuper) {
1391 if (this.eat(types.semi)) { return null }
1392
1393 var ecmaVersion = this.options.ecmaVersion;
1394 var node = this.startNode();
1395 var keyName = "";
1396 var isGenerator = false;
1397 var isAsync = false;
1398 var kind = "method";
1399 var isStatic = false;
1400
1401 if (this.eatContextual("static")) {
1402 // Parse static init block
1403 if (ecmaVersion >= 13 && this.eat(types.braceL)) {
1404 this.parseClassStaticBlock(node);
1405 return node
1406 }
1407 if (this.isClassElementNameStart() || this.type === types.star) {
1408 isStatic = true;
1409 } else {
1410 keyName = "static";
1411 }
1412 }
1413 node.static = isStatic;
1414 if (!keyName && ecmaVersion >= 8 && this.eatContextual("async")) {
1415 if ((this.isClassElementNameStart() || this.type === types.star) && !this.canInsertSemicolon()) {
1416 isAsync = true;
1417 } else {
1418 keyName = "async";
1419 }
1420 }
1421 if (!keyName && (ecmaVersion >= 9 || !isAsync) && this.eat(types.star)) {
1422 isGenerator = true;
1423 }
1424 if (!keyName && !isAsync && !isGenerator) {
1425 var lastValue = this.value;
1426 if (this.eatContextual("get") || this.eatContextual("set")) {
1427 if (this.isClassElementNameStart()) {
1428 kind = lastValue;
1429 } else {
1430 keyName = lastValue;
1431 }
1432 }
1433 }
1434
1435 // Parse element name
1436 if (keyName) {
1437 // 'async', 'get', 'set', or 'static' were not a keyword contextually.
1438 // The last token is any of those. Make it the element name.
1439 node.computed = false;
1440 node.key = this.startNodeAt(this.lastTokStart, this.lastTokStartLoc);
1441 node.key.name = keyName;
1442 this.finishNode(node.key, "Identifier");
1443 } else {
1444 this.parseClassElementName(node);
1445 }
1446
1447 // Parse element value
1448 if (ecmaVersion < 13 || this.type === types.parenL || kind !== "method" || isGenerator || isAsync) {
1449 var isConstructor = !node.static && checkKeyName(node, "constructor");
1450 var allowsDirectSuper = isConstructor && constructorAllowsSuper;
1451 // Couldn't move this check into the 'parseClassMethod' method for backward compatibility.
1452 if (isConstructor && kind !== "method") { this.raise(node.key.start, "Constructor can't have get/set modifier"); }
1453 node.kind = isConstructor ? "constructor" : kind;
1454 this.parseClassMethod(node, isGenerator, isAsync, allowsDirectSuper);
1455 } else {
1456 this.parseClassField(node);
1457 }
1458
1459 return node
1460 };
1461
1462 pp$1.isClassElementNameStart = function() {
1463 return (
1464 this.type === types.name ||
1465 this.type === types.privateId ||
1466 this.type === types.num ||
1467 this.type === types.string ||
1468 this.type === types.bracketL ||
1469 this.type.keyword
1470 )
1471 };
1472
1473 pp$1.parseClassElementName = function(element) {
1474 if (this.type === types.privateId) {
1475 if (this.value === "constructor") {
1476 this.raise(this.start, "Classes can't have an element named '#constructor'");
1477 }
1478 element.computed = false;
1479 element.key = this.parsePrivateIdent();
1480 } else {
1481 this.parsePropertyName(element);
1482 }
1483 };
1484
1485 pp$1.parseClassMethod = function(method, isGenerator, isAsync, allowsDirectSuper) {
1486 // Check key and flags
1487 var key = method.key;
1488 if (method.kind === "constructor") {
1489 if (isGenerator) { this.raise(key.start, "Constructor can't be a generator"); }
1490 if (isAsync) { this.raise(key.start, "Constructor can't be an async method"); }
1491 } else if (method.static && checkKeyName(method, "prototype")) {
1492 this.raise(key.start, "Classes may not have a static property named prototype");
1493 }
1494
1495 // Parse value
1496 var value = method.value = this.parseMethod(isGenerator, isAsync, allowsDirectSuper);
1497
1498 // Check value
1499 if (method.kind === "get" && value.params.length !== 0)
1500 { this.raiseRecoverable(value.start, "getter should have no params"); }
1501 if (method.kind === "set" && value.params.length !== 1)
1502 { this.raiseRecoverable(value.start, "setter should have exactly one param"); }
1503 if (method.kind === "set" && value.params[0].type === "RestElement")
1504 { this.raiseRecoverable(value.params[0].start, "Setter cannot use rest params"); }
1505
1506 return this.finishNode(method, "MethodDefinition")
1507 };
1508
1509 pp$1.parseClassField = function(field) {
1510 if (checkKeyName(field, "constructor")) {
1511 this.raise(field.key.start, "Classes can't have a field named 'constructor'");
1512 } else if (field.static && checkKeyName(field, "prototype")) {
1513 this.raise(field.key.start, "Classes can't have a static field named 'prototype'");
1514 }
1515
1516 if (this.eat(types.eq)) {
1517 // To raise SyntaxError if 'arguments' exists in the initializer.
1518 var scope = this.currentThisScope();
1519 var inClassFieldInit = scope.inClassFieldInit;
1520 scope.inClassFieldInit = true;
1521 field.value = this.parseMaybeAssign();
1522 scope.inClassFieldInit = inClassFieldInit;
1523 } else {
1524 field.value = null;
1525 }
1526 this.semicolon();
1527
1528 return this.finishNode(field, "PropertyDefinition")
1529 };
1530
1531 pp$1.parseClassStaticBlock = function(node) {
1532 node.body = [];
1533
1534 var oldLabels = this.labels;
1535 this.labels = [];
1536 this.enterScope(SCOPE_CLASS_STATIC_BLOCK | SCOPE_SUPER);
1537 while (this.type !== types.braceR) {
1538 var stmt = this.parseStatement(null);
1539 node.body.push(stmt);
1540 }
1541 this.next();
1542 this.exitScope();
1543 this.labels = oldLabels;
1544
1545 return this.finishNode(node, "StaticBlock")
1546 };
1547
1548 pp$1.parseClassId = function(node, isStatement) {
1549 if (this.type === types.name) {
1550 node.id = this.parseIdent();
1551 if (isStatement)
1552 { this.checkLValSimple(node.id, BIND_LEXICAL, false); }
1553 } else {
1554 if (isStatement === true)
1555 { this.unexpected(); }
1556 node.id = null;
1557 }
1558 };
1559
1560 pp$1.parseClassSuper = function(node) {
1561 node.superClass = this.eat(types._extends) ? this.parseExprSubscripts(false) : null;
1562 };
1563
1564 pp$1.enterClassBody = function() {
1565 var element = {declared: Object.create(null), used: []};
1566 this.privateNameStack.push(element);
1567 return element.declared
1568 };
1569
1570 pp$1.exitClassBody = function() {
1571 var ref = this.privateNameStack.pop();
1572 var declared = ref.declared;
1573 var used = ref.used;
1574 var len = this.privateNameStack.length;
1575 var parent = len === 0 ? null : this.privateNameStack[len - 1];
1576 for (var i = 0; i < used.length; ++i) {
1577 var id = used[i];
1578 if (!has(declared, id.name)) {
1579 if (parent) {
1580 parent.used.push(id);
1581 } else {
1582 this.raiseRecoverable(id.start, ("Private field '#" + (id.name) + "' must be declared in an enclosing class"));
1583 }
1584 }
1585 }
1586 };
1587
1588 function isPrivateNameConflicted(privateNameMap, element) {
1589 var name = element.key.name;
1590 var curr = privateNameMap[name];
1591
1592 var next = "true";
1593 if (element.type === "MethodDefinition" && (element.kind === "get" || element.kind === "set")) {
1594 next = (element.static ? "s" : "i") + element.kind;
1595 }
1596
1597 // `class { get #a(){}; static set #a(_){} }` is also conflict.
1598 if (
1599 curr === "iget" && next === "iset" ||
1600 curr === "iset" && next === "iget" ||
1601 curr === "sget" && next === "sset" ||
1602 curr === "sset" && next === "sget"
1603 ) {
1604 privateNameMap[name] = "true";
1605 return false
1606 } else if (!curr) {
1607 privateNameMap[name] = next;
1608 return false
1609 } else {
1610 return true
1611 }
1612 }
1613
1614 function checkKeyName(node, name) {
1615 var computed = node.computed;
1616 var key = node.key;
1617 return !computed && (
1618 key.type === "Identifier" && key.name === name ||
1619 key.type === "Literal" && key.value === name
1620 )
1621 }
1622
1623 // Parses module export declaration.
1624
1625 pp$1.parseExport = function(node, exports) {
1626 this.next();
1627 // export * from '...'
1628 if (this.eat(types.star)) {
1629 if (this.options.ecmaVersion >= 11) {
1630 if (this.eatContextual("as")) {
1631 node.exported = this.parseIdent(true);
1632 this.checkExport(exports, node.exported.name, this.lastTokStart);
1633 } else {
1634 node.exported = null;
1635 }
1636 }
1637 this.expectContextual("from");
1638 if (this.type !== types.string) { this.unexpected(); }
1639 node.source = this.parseExprAtom();
1640 this.semicolon();
1641 return this.finishNode(node, "ExportAllDeclaration")
1642 }
1643 if (this.eat(types._default)) { // export default ...
1644 this.checkExport(exports, "default", this.lastTokStart);
1645 var isAsync;
1646 if (this.type === types._function || (isAsync = this.isAsyncFunction())) {
1647 var fNode = this.startNode();
1648 this.next();
1649 if (isAsync) { this.next(); }
1650 node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);
1651 } else if (this.type === types._class) {
1652 var cNode = this.startNode();
1653 node.declaration = this.parseClass(cNode, "nullableID");
1654 } else {
1655 node.declaration = this.parseMaybeAssign();
1656 this.semicolon();
1657 }
1658 return this.finishNode(node, "ExportDefaultDeclaration")
1659 }
1660 // export var|const|let|function|class ...
1661 if (this.shouldParseExportStatement()) {
1662 node.declaration = this.parseStatement(null);
1663 if (node.declaration.type === "VariableDeclaration")
1664 { this.checkVariableExport(exports, node.declaration.declarations); }
1665 else
1666 { this.checkExport(exports, node.declaration.id.name, node.declaration.id.start); }
1667 node.specifiers = [];
1668 node.source = null;
1669 } else { // export { x, y as z } [from '...']
1670 node.declaration = null;
1671 node.specifiers = this.parseExportSpecifiers(exports);
1672 if (this.eatContextual("from")) {
1673 if (this.type !== types.string) { this.unexpected(); }
1674 node.source = this.parseExprAtom();
1675 } else {
1676 for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
1677 // check for keywords used as local names
1678 var spec = list[i];
1679
1680 this.checkUnreserved(spec.local);
1681 // check if export is defined
1682 this.checkLocalExport(spec.local);
1683 }
1684
1685 node.source = null;
1686 }
1687 this.semicolon();
1688 }
1689 return this.finishNode(node, "ExportNamedDeclaration")
1690 };
1691
1692 pp$1.checkExport = function(exports, name, pos) {
1693 if (!exports) { return }
1694 if (has(exports, name))
1695 { this.raiseRecoverable(pos, "Duplicate export '" + name + "'"); }
1696 exports[name] = true;
1697 };
1698
1699 pp$1.checkPatternExport = function(exports, pat) {
1700 var type = pat.type;
1701 if (type === "Identifier")
1702 { this.checkExport(exports, pat.name, pat.start); }
1703 else if (type === "ObjectPattern")
1704 { for (var i = 0, list = pat.properties; i < list.length; i += 1)
1705 {
1706 var prop = list[i];
1707
1708 this.checkPatternExport(exports, prop);
1709 } }
1710 else if (type === "ArrayPattern")
1711 { for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
1712 var elt = list$1[i$1];
1713
1714 if (elt) { this.checkPatternExport(exports, elt); }
1715 } }
1716 else if (type === "Property")
1717 { this.checkPatternExport(exports, pat.value); }
1718 else if (type === "AssignmentPattern")
1719 { this.checkPatternExport(exports, pat.left); }
1720 else if (type === "RestElement")
1721 { this.checkPatternExport(exports, pat.argument); }
1722 else if (type === "ParenthesizedExpression")
1723 { this.checkPatternExport(exports, pat.expression); }
1724 };
1725
1726 pp$1.checkVariableExport = function(exports, decls) {
1727 if (!exports) { return }
1728 for (var i = 0, list = decls; i < list.length; i += 1)
1729 {
1730 var decl = list[i];
1731
1732 this.checkPatternExport(exports, decl.id);
1733 }
1734 };
1735
1736 pp$1.shouldParseExportStatement = function() {
1737 return this.type.keyword === "var" ||
1738 this.type.keyword === "const" ||
1739 this.type.keyword === "class" ||
1740 this.type.keyword === "function" ||
1741 this.isLet() ||
1742 this.isAsyncFunction()
1743 };
1744
1745 // Parses a comma-separated list of module exports.
1746
1747 pp$1.parseExportSpecifiers = function(exports) {
1748 var nodes = [], first = true;
1749 // export { x, y as z } [from '...']
1750 this.expect(types.braceL);
1751 while (!this.eat(types.braceR)) {
1752 if (!first) {
1753 this.expect(types.comma);
1754 if (this.afterTrailingComma(types.braceR)) { break }
1755 } else { first = false; }
1756
1757 var node = this.startNode();
1758 node.local = this.parseIdent(true);
1759 node.exported = this.eatContextual("as") ? this.parseIdent(true) : node.local;
1760 this.checkExport(exports, node.exported.name, node.exported.start);
1761 nodes.push(this.finishNode(node, "ExportSpecifier"));
1762 }
1763 return nodes
1764 };
1765
1766 // Parses import declaration.
1767
1768 pp$1.parseImport = function(node) {
1769 this.next();
1770 // import '...'
1771 if (this.type === types.string) {
1772 node.specifiers = empty;
1773 node.source = this.parseExprAtom();
1774 } else {
1775 node.specifiers = this.parseImportSpecifiers();
1776 this.expectContextual("from");
1777 node.source = this.type === types.string ? this.parseExprAtom() : this.unexpected();
1778 }
1779 this.semicolon();
1780 return this.finishNode(node, "ImportDeclaration")
1781 };
1782
1783 // Parses a comma-separated list of module imports.
1784
1785 pp$1.parseImportSpecifiers = function() {
1786 var nodes = [], first = true;
1787 if (this.type === types.name) {
1788 // import defaultObj, { x, y as z } from '...'
1789 var node = this.startNode();
1790 node.local = this.parseIdent();
1791 this.checkLValSimple(node.local, BIND_LEXICAL);
1792 nodes.push(this.finishNode(node, "ImportDefaultSpecifier"));
1793 if (!this.eat(types.comma)) { return nodes }
1794 }
1795 if (this.type === types.star) {
1796 var node$1 = this.startNode();
1797 this.next();
1798 this.expectContextual("as");
1799 node$1.local = this.parseIdent();
1800 this.checkLValSimple(node$1.local, BIND_LEXICAL);
1801 nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier"));
1802 return nodes
1803 }
1804 this.expect(types.braceL);
1805 while (!this.eat(types.braceR)) {
1806 if (!first) {
1807 this.expect(types.comma);
1808 if (this.afterTrailingComma(types.braceR)) { break }
1809 } else { first = false; }
1810
1811 var node$2 = this.startNode();
1812 node$2.imported = this.parseIdent(true);
1813 if (this.eatContextual("as")) {
1814 node$2.local = this.parseIdent();
1815 } else {
1816 this.checkUnreserved(node$2.imported);
1817 node$2.local = node$2.imported;
1818 }
1819 this.checkLValSimple(node$2.local, BIND_LEXICAL);
1820 nodes.push(this.finishNode(node$2, "ImportSpecifier"));
1821 }
1822 return nodes
1823 };
1824
1825 // Set `ExpressionStatement#directive` property for directive prologues.
1826 pp$1.adaptDirectivePrologue = function(statements) {
1827 for (var i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i) {
1828 statements[i].directive = statements[i].expression.raw.slice(1, -1);
1829 }
1830 };
1831 pp$1.isDirectiveCandidate = function(statement) {
1832 return (
1833 statement.type === "ExpressionStatement" &&
1834 statement.expression.type === "Literal" &&
1835 typeof statement.expression.value === "string" &&
1836 // Reject parenthesized strings.
1837 (this.input[statement.start] === "\"" || this.input[statement.start] === "'")
1838 )
1839 };
1840
1841 var pp$2 = Parser.prototype;
1842
1843 // Convert existing expression atom to assignable pattern
1844 // if possible.
1845
1846 pp$2.toAssignable = function(node, isBinding, refDestructuringErrors) {
1847 if (this.options.ecmaVersion >= 6 && node) {
1848 switch (node.type) {
1849 case "Identifier":
1850 if (this.inAsync && node.name === "await")
1851 { this.raise(node.start, "Cannot use 'await' as identifier inside an async function"); }
1852 break
1853
1854 case "ObjectPattern":
1855 case "ArrayPattern":
1856 case "AssignmentPattern":
1857 case "RestElement":
1858 break
1859
1860 case "ObjectExpression":
1861 node.type = "ObjectPattern";
1862 if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
1863 for (var i = 0, list = node.properties; i < list.length; i += 1) {
1864 var prop = list[i];
1865
1866 this.toAssignable(prop, isBinding);
1867 // Early error:
1868 // AssignmentRestProperty[Yield, Await] :
1869 // `...` DestructuringAssignmentTarget[Yield, Await]
1870 //
1871 // It is a Syntax Error if |DestructuringAssignmentTarget| is an |ArrayLiteral| or an |ObjectLiteral|.
1872 if (
1873 prop.type === "RestElement" &&
1874 (prop.argument.type === "ArrayPattern" || prop.argument.type === "ObjectPattern")
1875 ) {
1876 this.raise(prop.argument.start, "Unexpected token");
1877 }
1878 }
1879 break
1880
1881 case "Property":
1882 // AssignmentProperty has type === "Property"
1883 if (node.kind !== "init") { this.raise(node.key.start, "Object pattern can't contain getter or setter"); }
1884 this.toAssignable(node.value, isBinding);
1885 break
1886
1887 case "ArrayExpression":
1888 node.type = "ArrayPattern";
1889 if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
1890 this.toAssignableList(node.elements, isBinding);
1891 break
1892
1893 case "SpreadElement":
1894 node.type = "RestElement";
1895 this.toAssignable(node.argument, isBinding);
1896 if (node.argument.type === "AssignmentPattern")
1897 { this.raise(node.argument.start, "Rest elements cannot have a default value"); }
1898 break
1899
1900 case "AssignmentExpression":
1901 if (node.operator !== "=") { this.raise(node.left.end, "Only '=' operator can be used for specifying default value."); }
1902 node.type = "AssignmentPattern";
1903 delete node.operator;
1904 this.toAssignable(node.left, isBinding);
1905 break
1906
1907 case "ParenthesizedExpression":
1908 this.toAssignable(node.expression, isBinding, refDestructuringErrors);
1909 break
1910
1911 case "ChainExpression":
1912 this.raiseRecoverable(node.start, "Optional chaining cannot appear in left-hand side");
1913 break
1914
1915 case "MemberExpression":
1916 if (!isBinding) { break }
1917
1918 default:
1919 this.raise(node.start, "Assigning to rvalue");
1920 }
1921 } else if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
1922 return node
1923 };
1924
1925 // Convert list of expression atoms to binding list.
1926
1927 pp$2.toAssignableList = function(exprList, isBinding) {
1928 var end = exprList.length;
1929 for (var i = 0; i < end; i++) {
1930 var elt = exprList[i];
1931 if (elt) { this.toAssignable(elt, isBinding); }
1932 }
1933 if (end) {
1934 var last = exprList[end - 1];
1935 if (this.options.ecmaVersion === 6 && isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier")
1936 { this.unexpected(last.argument.start); }
1937 }
1938 return exprList
1939 };
1940
1941 // Parses spread element.
1942
1943 pp$2.parseSpread = function(refDestructuringErrors) {
1944 var node = this.startNode();
1945 this.next();
1946 node.argument = this.parseMaybeAssign(false, refDestructuringErrors);
1947 return this.finishNode(node, "SpreadElement")
1948 };
1949
1950 pp$2.parseRestBinding = function() {
1951 var node = this.startNode();
1952 this.next();
1953
1954 // RestElement inside of a function parameter must be an identifier
1955 if (this.options.ecmaVersion === 6 && this.type !== types.name)
1956 { this.unexpected(); }
1957
1958 node.argument = this.parseBindingAtom();
1959
1960 return this.finishNode(node, "RestElement")
1961 };
1962
1963 // Parses lvalue (assignable) atom.
1964
1965 pp$2.parseBindingAtom = function() {
1966 if (this.options.ecmaVersion >= 6) {
1967 switch (this.type) {
1968 case types.bracketL:
1969 var node = this.startNode();
1970 this.next();
1971 node.elements = this.parseBindingList(types.bracketR, true, true);
1972 return this.finishNode(node, "ArrayPattern")
1973
1974 case types.braceL:
1975 return this.parseObj(true)
1976 }
1977 }
1978 return this.parseIdent()
1979 };
1980
1981 pp$2.parseBindingList = function(close, allowEmpty, allowTrailingComma) {
1982 var elts = [], first = true;
1983 while (!this.eat(close)) {
1984 if (first) { first = false; }
1985 else { this.expect(types.comma); }
1986 if (allowEmpty && this.type === types.comma) {
1987 elts.push(null);
1988 } else if (allowTrailingComma && this.afterTrailingComma(close)) {
1989 break
1990 } else if (this.type === types.ellipsis) {
1991 var rest = this.parseRestBinding();
1992 this.parseBindingListItem(rest);
1993 elts.push(rest);
1994 if (this.type === types.comma) { this.raise(this.start, "Comma is not permitted after the rest element"); }
1995 this.expect(close);
1996 break
1997 } else {
1998 var elem = this.parseMaybeDefault(this.start, this.startLoc);
1999 this.parseBindingListItem(elem);
2000 elts.push(elem);
2001 }
2002 }
2003 return elts
2004 };
2005
2006 pp$2.parseBindingListItem = function(param) {
2007 return param
2008 };
2009
2010 // Parses assignment pattern around given atom if possible.
2011
2012 pp$2.parseMaybeDefault = function(startPos, startLoc, left) {
2013 left = left || this.parseBindingAtom();
2014 if (this.options.ecmaVersion < 6 || !this.eat(types.eq)) { return left }
2015 var node = this.startNodeAt(startPos, startLoc);
2016 node.left = left;
2017 node.right = this.parseMaybeAssign();
2018 return this.finishNode(node, "AssignmentPattern")
2019 };
2020
2021 // The following three functions all verify that a node is an lvalue —
2022 // something that can be bound, or assigned to. In order to do so, they perform
2023 // a variety of checks:
2024 //
2025 // - Check that none of the bound/assigned-to identifiers are reserved words.
2026 // - Record name declarations for bindings in the appropriate scope.
2027 // - Check duplicate argument names, if checkClashes is set.
2028 //
2029 // If a complex binding pattern is encountered (e.g., object and array
2030 // destructuring), the entire pattern is recursively checked.
2031 //
2032 // There are three versions of checkLVal*() appropriate for different
2033 // circumstances:
2034 //
2035 // - checkLValSimple() shall be used if the syntactic construct supports
2036 // nothing other than identifiers and member expressions. Parenthesized
2037 // expressions are also correctly handled. This is generally appropriate for
2038 // constructs for which the spec says
2039 //
2040 // > It is a Syntax Error if AssignmentTargetType of [the production] is not
2041 // > simple.
2042 //
2043 // It is also appropriate for checking if an identifier is valid and not
2044 // defined elsewhere, like import declarations or function/class identifiers.
2045 //
2046 // Examples where this is used include:
2047 // a += …;
2048 // import a from '…';
2049 // where a is the node to be checked.
2050 //
2051 // - checkLValPattern() shall be used if the syntactic construct supports
2052 // anything checkLValSimple() supports, as well as object and array
2053 // destructuring patterns. This is generally appropriate for constructs for
2054 // which the spec says
2055 //
2056 // > It is a Syntax Error if [the production] is neither an ObjectLiteral nor
2057 // > an ArrayLiteral and AssignmentTargetType of [the production] is not
2058 // > simple.
2059 //
2060 // Examples where this is used include:
2061 // (a = …);
2062 // const a = …;
2063 // try { … } catch (a) { … }
2064 // where a is the node to be checked.
2065 //
2066 // - checkLValInnerPattern() shall be used if the syntactic construct supports
2067 // anything checkLValPattern() supports, as well as default assignment
2068 // patterns, rest elements, and other constructs that may appear within an
2069 // object or array destructuring pattern.
2070 //
2071 // As a special case, function parameters also use checkLValInnerPattern(),
2072 // as they also support defaults and rest constructs.
2073 //
2074 // These functions deliberately support both assignment and binding constructs,
2075 // as the logic for both is exceedingly similar. If the node is the target of
2076 // an assignment, then bindingType should be set to BIND_NONE. Otherwise, it
2077 // should be set to the appropriate BIND_* constant, like BIND_VAR or
2078 // BIND_LEXICAL.
2079 //
2080 // If the function is called with a non-BIND_NONE bindingType, then
2081 // additionally a checkClashes object may be specified to allow checking for
2082 // duplicate argument names. checkClashes is ignored if the provided construct
2083 // is an assignment (i.e., bindingType is BIND_NONE).
2084
2085 pp$2.checkLValSimple = function(expr, bindingType, checkClashes) {
2086 if ( bindingType === void 0 ) bindingType = BIND_NONE;
2087
2088 var isBind = bindingType !== BIND_NONE;
2089
2090 switch (expr.type) {
2091 case "Identifier":
2092 if (this.strict && this.reservedWordsStrictBind.test(expr.name))
2093 { this.raiseRecoverable(expr.start, (isBind ? "Binding " : "Assigning to ") + expr.name + " in strict mode"); }
2094 if (isBind) {
2095 if (bindingType === BIND_LEXICAL && expr.name === "let")
2096 { this.raiseRecoverable(expr.start, "let is disallowed as a lexically bound name"); }
2097 if (checkClashes) {
2098 if (has(checkClashes, expr.name))
2099 { this.raiseRecoverable(expr.start, "Argument name clash"); }
2100 checkClashes[expr.name] = true;
2101 }
2102 if (bindingType !== BIND_OUTSIDE) { this.declareName(expr.name, bindingType, expr.start); }
2103 }
2104 break
2105
2106 case "ChainExpression":
2107 this.raiseRecoverable(expr.start, "Optional chaining cannot appear in left-hand side");
2108 break
2109
2110 case "MemberExpression":
2111 if (isBind) { this.raiseRecoverable(expr.start, "Binding member expression"); }
2112 break
2113
2114 case "ParenthesizedExpression":
2115 if (isBind) { this.raiseRecoverable(expr.start, "Binding parenthesized expression"); }
2116 return this.checkLValSimple(expr.expression, bindingType, checkClashes)
2117
2118 default:
2119 this.raise(expr.start, (isBind ? "Binding" : "Assigning to") + " rvalue");
2120 }
2121 };
2122
2123 pp$2.checkLValPattern = function(expr, bindingType, checkClashes) {
2124 if ( bindingType === void 0 ) bindingType = BIND_NONE;
2125
2126 switch (expr.type) {
2127 case "ObjectPattern":
2128 for (var i = 0, list = expr.properties; i < list.length; i += 1) {
2129 var prop = list[i];
2130
2131 this.checkLValInnerPattern(prop, bindingType, checkClashes);
2132 }
2133 break
2134
2135 case "ArrayPattern":
2136 for (var i$1 = 0, list$1 = expr.elements; i$1 < list$1.length; i$1 += 1) {
2137 var elem = list$1[i$1];
2138
2139 if (elem) { this.checkLValInnerPattern(elem, bindingType, checkClashes); }
2140 }
2141 break
2142
2143 default:
2144 this.checkLValSimple(expr, bindingType, checkClashes);
2145 }
2146 };
2147
2148 pp$2.checkLValInnerPattern = function(expr, bindingType, checkClashes) {
2149 if ( bindingType === void 0 ) bindingType = BIND_NONE;
2150
2151 switch (expr.type) {
2152 case "Property":
2153 // AssignmentProperty has type === "Property"
2154 this.checkLValInnerPattern(expr.value, bindingType, checkClashes);
2155 break
2156
2157 case "AssignmentPattern":
2158 this.checkLValPattern(expr.left, bindingType, checkClashes);
2159 break
2160
2161 case "RestElement":
2162 this.checkLValPattern(expr.argument, bindingType, checkClashes);
2163 break
2164
2165 default:
2166 this.checkLValPattern(expr, bindingType, checkClashes);
2167 }
2168 };
2169
2170 // The algorithm used to determine whether a regexp can appear at a
2171
2172 var TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) {
2173 this.token = token;
2174 this.isExpr = !!isExpr;
2175 this.preserveSpace = !!preserveSpace;
2176 this.override = override;
2177 this.generator = !!generator;
2178 };
2179
2180 var types$1 = {
2181 b_stat: new TokContext("{", false),
2182 b_expr: new TokContext("{", true),
2183 b_tmpl: new TokContext("${", false),
2184 p_stat: new TokContext("(", false),
2185 p_expr: new TokContext("(", true),
2186 q_tmpl: new TokContext("`", true, true, function (p) { return p.tryReadTemplateToken(); }),
2187 f_stat: new TokContext("function", false),
2188 f_expr: new TokContext("function", true),
2189 f_expr_gen: new TokContext("function", true, false, null, true),
2190 f_gen: new TokContext("function", false, false, null, true)
2191 };
2192
2193 var pp$3 = Parser.prototype;
2194
2195 pp$3.initialContext = function() {
2196 return [types$1.b_stat]
2197 };
2198
2199 pp$3.curContext = function() {
2200 return this.context[this.context.length - 1]
2201 };
2202
2203 pp$3.braceIsBlock = function(prevType) {
2204 var parent = this.curContext();
2205 if (parent === types$1.f_expr || parent === types$1.f_stat)
2206 { return true }
2207 if (prevType === types.colon && (parent === types$1.b_stat || parent === types$1.b_expr))
2208 { return !parent.isExpr }
2209
2210 // The check for `tt.name && exprAllowed` detects whether we are
2211 // after a `yield` or `of` construct. See the `updateContext` for
2212 // `tt.name`.
2213 if (prevType === types._return || prevType === types.name && this.exprAllowed)
2214 { return lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) }
2215 if (prevType === types._else || prevType === types.semi || prevType === types.eof || prevType === types.parenR || prevType === types.arrow)
2216 { return true }
2217 if (prevType === types.braceL)
2218 { return parent === types$1.b_stat }
2219 if (prevType === types._var || prevType === types._const || prevType === types.name)
2220 { return false }
2221 return !this.exprAllowed
2222 };
2223
2224 pp$3.inGeneratorContext = function() {
2225 for (var i = this.context.length - 1; i >= 1; i--) {
2226 var context = this.context[i];
2227 if (context.token === "function")
2228 { return context.generator }
2229 }
2230 return false
2231 };
2232
2233 pp$3.updateContext = function(prevType) {
2234 var update, type = this.type;
2235 if (type.keyword && prevType === types.dot)
2236 { this.exprAllowed = false; }
2237 else if (update = type.updateContext)
2238 { update.call(this, prevType); }
2239 else
2240 { this.exprAllowed = type.beforeExpr; }
2241 };
2242
2243 // Used to handle egde case when token context could not be inferred correctly in tokenize phase
2244 pp$3.overrideContext = function(tokenCtx) {
2245 if (this.curContext() !== tokenCtx) {
2246 this.context[this.context.length - 1] = tokenCtx;
2247 }
2248 };
2249
2250 // Token-specific context update code
2251
2252 types.parenR.updateContext = types.braceR.updateContext = function() {
2253 if (this.context.length === 1) {
2254 this.exprAllowed = true;
2255 return
2256 }
2257 var out = this.context.pop();
2258 if (out === types$1.b_stat && this.curContext().token === "function") {
2259 out = this.context.pop();
2260 }
2261 this.exprAllowed = !out.isExpr;
2262 };
2263
2264 types.braceL.updateContext = function(prevType) {
2265 this.context.push(this.braceIsBlock(prevType) ? types$1.b_stat : types$1.b_expr);
2266 this.exprAllowed = true;
2267 };
2268
2269 types.dollarBraceL.updateContext = function() {
2270 this.context.push(types$1.b_tmpl);
2271 this.exprAllowed = true;
2272 };
2273
2274 types.parenL.updateContext = function(prevType) {
2275 var statementParens = prevType === types._if || prevType === types._for || prevType === types._with || prevType === types._while;
2276 this.context.push(statementParens ? types$1.p_stat : types$1.p_expr);
2277 this.exprAllowed = true;
2278 };
2279
2280 types.incDec.updateContext = function() {
2281 // tokExprAllowed stays unchanged
2282 };
2283
2284 types._function.updateContext = types._class.updateContext = function(prevType) {
2285 if (prevType.beforeExpr && prevType !== types._else &&
2286 !(prevType === types.semi && this.curContext() !== types$1.p_stat) &&
2287 !(prevType === types._return && lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) &&
2288 !((prevType === types.colon || prevType === types.braceL) && this.curContext() === types$1.b_stat))
2289 { this.context.push(types$1.f_expr); }
2290 else
2291 { this.context.push(types$1.f_stat); }
2292 this.exprAllowed = false;
2293 };
2294
2295 types.backQuote.updateContext = function() {
2296 if (this.curContext() === types$1.q_tmpl)
2297 { this.context.pop(); }
2298 else
2299 { this.context.push(types$1.q_tmpl); }
2300 this.exprAllowed = false;
2301 };
2302
2303 types.star.updateContext = function(prevType) {
2304 if (prevType === types._function) {
2305 var index = this.context.length - 1;
2306 if (this.context[index] === types$1.f_expr)
2307 { this.context[index] = types$1.f_expr_gen; }
2308 else
2309 { this.context[index] = types$1.f_gen; }
2310 }
2311 this.exprAllowed = true;
2312 };
2313
2314 types.name.updateContext = function(prevType) {
2315 var allowed = false;
2316 if (this.options.ecmaVersion >= 6 && prevType !== types.dot) {
2317 if (this.value === "of" && !this.exprAllowed ||
2318 this.value === "yield" && this.inGeneratorContext())
2319 { allowed = true; }
2320 }
2321 this.exprAllowed = allowed;
2322 };
2323
2324 // A recursive descent parser operates by defining functions for all
2325
2326 var pp$4 = Parser.prototype;
2327
2328 // Check if property name clashes with already added.
2329 // Object/class getters and setters are not allowed to clash —
2330 // either with each other or with an init property — and in
2331 // strict mode, init properties are also not allowed to be repeated.
2332
2333 pp$4.checkPropClash = function(prop, propHash, refDestructuringErrors) {
2334 if (this.options.ecmaVersion >= 9 && prop.type === "SpreadElement")
2335 { return }
2336 if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand))
2337 { return }
2338 var key = prop.key;
2339 var name;
2340 switch (key.type) {
2341 case "Identifier": name = key.name; break
2342 case "Literal": name = String(key.value); break
2343 default: return
2344 }
2345 var kind = prop.kind;
2346 if (this.options.ecmaVersion >= 6) {
2347 if (name === "__proto__" && kind === "init") {
2348 if (propHash.proto) {
2349 if (refDestructuringErrors) {
2350 if (refDestructuringErrors.doubleProto < 0)
2351 { refDestructuringErrors.doubleProto = key.start; }
2352 // Backwards-compat kludge. Can be removed in version 6.0
2353 } else { this.raiseRecoverable(key.start, "Redefinition of __proto__ property"); }
2354 }
2355 propHash.proto = true;
2356 }
2357 return
2358 }
2359 name = "$" + name;
2360 var other = propHash[name];
2361 if (other) {
2362 var redefinition;
2363 if (kind === "init") {
2364 redefinition = this.strict && other.init || other.get || other.set;
2365 } else {
2366 redefinition = other.init || other[kind];
2367 }
2368 if (redefinition)
2369 { this.raiseRecoverable(key.start, "Redefinition of property"); }
2370 } else {
2371 other = propHash[name] = {
2372 init: false,
2373 get: false,
2374 set: false
2375 };
2376 }
2377 other[kind] = true;
2378 };
2379
2380 // ### Expression parsing
2381
2382 // These nest, from the most general expression type at the top to
2383 // 'atomic', nondivisible expression types at the bottom. Most of
2384 // the functions will simply let the function(s) below them parse,
2385 // and, *if* the syntactic construct they handle is present, wrap
2386 // the AST node that the inner parser gave them in another node.
2387
2388 // Parse a full expression. The optional arguments are used to
2389 // forbid the `in` operator (in for loops initalization expressions)
2390 // and provide reference for storing '=' operator inside shorthand
2391 // property assignment in contexts where both object expression
2392 // and object pattern might appear (so it's possible to raise
2393 // delayed syntax error at correct position).
2394
2395 pp$4.parseExpression = function(forInit, refDestructuringErrors) {
2396 var startPos = this.start, startLoc = this.startLoc;
2397 var expr = this.parseMaybeAssign(forInit, refDestructuringErrors);
2398 if (this.type === types.comma) {
2399 var node = this.startNodeAt(startPos, startLoc);
2400 node.expressions = [expr];
2401 while (this.eat(types.comma)) { node.expressions.push(this.parseMaybeAssign(forInit, refDestructuringErrors)); }
2402 return this.finishNode(node, "SequenceExpression")
2403 }
2404 return expr
2405 };
2406
2407 // Parse an assignment expression. This includes applications of
2408 // operators like `+=`.
2409
2410 pp$4.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse) {
2411 if (this.isContextual("yield")) {
2412 if (this.inGenerator) { return this.parseYield(forInit) }
2413 // The tokenizer will assume an expression is allowed after
2414 // `yield`, but this isn't that kind of yield
2415 else { this.exprAllowed = false; }
2416 }
2417
2418 var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1;
2419 if (refDestructuringErrors) {
2420 oldParenAssign = refDestructuringErrors.parenthesizedAssign;
2421 oldTrailingComma = refDestructuringErrors.trailingComma;
2422 refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1;
2423 } else {
2424 refDestructuringErrors = new DestructuringErrors;
2425 ownDestructuringErrors = true;
2426 }
2427
2428 var startPos = this.start, startLoc = this.startLoc;
2429 if (this.type === types.parenL || this.type === types.name) {
2430 this.potentialArrowAt = this.start;
2431 this.potentialArrowInForAwait = forInit === "await";
2432 }
2433 var left = this.parseMaybeConditional(forInit, refDestructuringErrors);
2434 if (afterLeftParse) { left = afterLeftParse.call(this, left, startPos, startLoc); }
2435 if (this.type.isAssign) {
2436 var node = this.startNodeAt(startPos, startLoc);
2437 node.operator = this.value;
2438 if (this.type === types.eq)
2439 { left = this.toAssignable(left, false, refDestructuringErrors); }
2440 if (!ownDestructuringErrors) {
2441 refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.doubleProto = -1;
2442 }
2443 if (refDestructuringErrors.shorthandAssign >= left.start)
2444 { refDestructuringErrors.shorthandAssign = -1; } // reset because shorthand default was used correctly
2445 if (this.type === types.eq)
2446 { this.checkLValPattern(left); }
2447 else
2448 { this.checkLValSimple(left); }
2449 node.left = left;
2450 this.next();
2451 node.right = this.parseMaybeAssign(forInit);
2452 return this.finishNode(node, "AssignmentExpression")
2453 } else {
2454 if (ownDestructuringErrors) { this.checkExpressionErrors(refDestructuringErrors, true); }
2455 }
2456 if (oldParenAssign > -1) { refDestructuringErrors.parenthesizedAssign = oldParenAssign; }
2457 if (oldTrailingComma > -1) { refDestructuringErrors.trailingComma = oldTrailingComma; }
2458 return left
2459 };
2460
2461 // Parse a ternary conditional (`?:`) operator.
2462
2463 pp$4.parseMaybeConditional = function(forInit, refDestructuringErrors) {
2464 var startPos = this.start, startLoc = this.startLoc;
2465 var expr = this.parseExprOps(forInit, refDestructuringErrors);
2466 if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
2467 if (this.eat(types.question)) {
2468 var node = this.startNodeAt(startPos, startLoc);
2469 node.test = expr;
2470 node.consequent = this.parseMaybeAssign();
2471 this.expect(types.colon);
2472 node.alternate = this.parseMaybeAssign(forInit);
2473 return this.finishNode(node, "ConditionalExpression")
2474 }
2475 return expr
2476 };
2477
2478 // Start the precedence parser.
2479
2480 pp$4.parseExprOps = function(forInit, refDestructuringErrors) {
2481 var startPos = this.start, startLoc = this.startLoc;
2482 var expr = this.parseMaybeUnary(refDestructuringErrors, false, false, forInit);
2483 if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
2484 return expr.start === startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, forInit)
2485 };
2486
2487 // Parse binary operators with the operator precedence parsing
2488 // algorithm. `left` is the left-hand side of the operator.
2489 // `minPrec` provides context that allows the function to stop and
2490 // defer further parser to one of its callers when it encounters an
2491 // operator that has a lower precedence than the set it is parsing.
2492
2493 pp$4.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, forInit) {
2494 var prec = this.type.binop;
2495 if (prec != null && (!forInit || this.type !== types._in)) {
2496 if (prec > minPrec) {
2497 var logical = this.type === types.logicalOR || this.type === types.logicalAND;
2498 var coalesce = this.type === types.coalesce;
2499 if (coalesce) {
2500 // Handle the precedence of `tt.coalesce` as equal to the range of logical expressions.
2501 // In other words, `node.right` shouldn't contain logical expressions in order to check the mixed error.
2502 prec = types.logicalAND.binop;
2503 }
2504 var op = this.value;
2505 this.next();
2506 var startPos = this.start, startLoc = this.startLoc;
2507 var right = this.parseExprOp(this.parseMaybeUnary(null, false, false, forInit), startPos, startLoc, prec, forInit);
2508 var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical || coalesce);
2509 if ((logical && this.type === types.coalesce) || (coalesce && (this.type === types.logicalOR || this.type === types.logicalAND))) {
2510 this.raiseRecoverable(this.start, "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses");
2511 }
2512 return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, forInit)
2513 }
2514 }
2515 return left
2516 };
2517
2518 pp$4.buildBinary = function(startPos, startLoc, left, right, op, logical) {
2519 var node = this.startNodeAt(startPos, startLoc);
2520 node.left = left;
2521 node.operator = op;
2522 node.right = right;
2523 return this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression")
2524 };
2525
2526 // Parse unary operators, both prefix and postfix.
2527
2528 pp$4.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forInit) {
2529 var startPos = this.start, startLoc = this.startLoc, expr;
2530 if (this.isContextual("await") && this.canAwait) {
2531 expr = this.parseAwait(forInit);
2532 sawUnary = true;
2533 } else if (this.type.prefix) {
2534 var node = this.startNode(), update = this.type === types.incDec;
2535 node.operator = this.value;
2536 node.prefix = true;
2537 this.next();
2538 node.argument = this.parseMaybeUnary(null, true, update, forInit);
2539 this.checkExpressionErrors(refDestructuringErrors, true);
2540 if (update) { this.checkLValSimple(node.argument); }
2541 else if (this.strict && node.operator === "delete" &&
2542 node.argument.type === "Identifier")
2543 { this.raiseRecoverable(node.start, "Deleting local variable in strict mode"); }
2544 else if (node.operator === "delete" && isPrivateFieldAccess(node.argument))
2545 { this.raiseRecoverable(node.start, "Private fields can not be deleted"); }
2546 else { sawUnary = true; }
2547 expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
2548 } else {
2549 expr = this.parseExprSubscripts(refDestructuringErrors, forInit);
2550 if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
2551 while (this.type.postfix && !this.canInsertSemicolon()) {
2552 var node$1 = this.startNodeAt(startPos, startLoc);
2553 node$1.operator = this.value;
2554 node$1.prefix = false;
2555 node$1.argument = expr;
2556 this.checkLValSimple(expr);
2557 this.next();
2558 expr = this.finishNode(node$1, "UpdateExpression");
2559 }
2560 }
2561
2562 if (!incDec && this.eat(types.starstar)) {
2563 if (sawUnary)
2564 { this.unexpected(this.lastTokStart); }
2565 else
2566 { return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false, false, forInit), "**", false) }
2567 } else {
2568 return expr
2569 }
2570 };
2571
2572 function isPrivateFieldAccess(node) {
2573 return (
2574 node.type === "MemberExpression" && node.property.type === "PrivateIdentifier" ||
2575 node.type === "ChainExpression" && isPrivateFieldAccess(node.expression)
2576 )
2577 }
2578
2579 // Parse call, dot, and `[]`-subscript expressions.
2580
2581 pp$4.parseExprSubscripts = function(refDestructuringErrors, forInit) {
2582 var startPos = this.start, startLoc = this.startLoc;
2583 var expr = this.parseExprAtom(refDestructuringErrors, forInit);
2584 if (expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")")
2585 { return expr }
2586 var result = this.parseSubscripts(expr, startPos, startLoc, false, forInit);
2587 if (refDestructuringErrors && result.type === "MemberExpression") {
2588 if (refDestructuringErrors.parenthesizedAssign >= result.start) { refDestructuringErrors.parenthesizedAssign = -1; }
2589 if (refDestructuringErrors.parenthesizedBind >= result.start) { refDestructuringErrors.parenthesizedBind = -1; }
2590 if (refDestructuringErrors.trailingComma >= result.start) { refDestructuringErrors.trailingComma = -1; }
2591 }
2592 return result
2593 };
2594
2595 pp$4.parseSubscripts = function(base, startPos, startLoc, noCalls, forInit) {
2596 var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" &&
2597 this.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 &&
2598 this.potentialArrowAt === base.start;
2599 var optionalChained = false;
2600
2601 while (true) {
2602 var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit);
2603
2604 if (element.optional) { optionalChained = true; }
2605 if (element === base || element.type === "ArrowFunctionExpression") {
2606 if (optionalChained) {
2607 var chainNode = this.startNodeAt(startPos, startLoc);
2608 chainNode.expression = element;
2609 element = this.finishNode(chainNode, "ChainExpression");
2610 }
2611 return element
2612 }
2613
2614 base = element;
2615 }
2616 };
2617
2618 pp$4.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit) {
2619 var optionalSupported = this.options.ecmaVersion >= 11;
2620 var optional = optionalSupported && this.eat(types.questionDot);
2621 if (noCalls && optional) { this.raise(this.lastTokStart, "Optional chaining cannot appear in the callee of new expressions"); }
2622
2623 var computed = this.eat(types.bracketL);
2624 if (computed || (optional && this.type !== types.parenL && this.type !== types.backQuote) || this.eat(types.dot)) {
2625 var node = this.startNodeAt(startPos, startLoc);
2626 node.object = base;
2627 if (computed) {
2628 node.property = this.parseExpression();
2629 this.expect(types.bracketR);
2630 } else if (this.type === types.privateId && base.type !== "Super") {
2631 node.property = this.parsePrivateIdent();
2632 } else {
2633 node.property = this.parseIdent(this.options.allowReserved !== "never");
2634 }
2635 node.computed = !!computed;
2636 if (optionalSupported) {
2637 node.optional = optional;
2638 }
2639 base = this.finishNode(node, "MemberExpression");
2640 } else if (!noCalls && this.eat(types.parenL)) {
2641 var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
2642 this.yieldPos = 0;
2643 this.awaitPos = 0;
2644 this.awaitIdentPos = 0;
2645 var exprList = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors);
2646 if (maybeAsyncArrow && !optional && !this.canInsertSemicolon() && this.eat(types.arrow)) {
2647 this.checkPatternErrors(refDestructuringErrors, false);
2648 this.checkYieldAwaitInDefaultParams();
2649 if (this.awaitIdentPos > 0)
2650 { this.raise(this.awaitIdentPos, "Cannot use 'await' as identifier inside an async function"); }
2651 this.yieldPos = oldYieldPos;
2652 this.awaitPos = oldAwaitPos;
2653 this.awaitIdentPos = oldAwaitIdentPos;
2654 return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true, forInit)
2655 }
2656 this.checkExpressionErrors(refDestructuringErrors, true);
2657 this.yieldPos = oldYieldPos || this.yieldPos;
2658 this.awaitPos = oldAwaitPos || this.awaitPos;
2659 this.awaitIdentPos = oldAwaitIdentPos || this.awaitIdentPos;
2660 var node$1 = this.startNodeAt(startPos, startLoc);
2661 node$1.callee = base;
2662 node$1.arguments = exprList;
2663 if (optionalSupported) {
2664 node$1.optional = optional;
2665 }
2666 base = this.finishNode(node$1, "CallExpression");
2667 } else if (this.type === types.backQuote) {
2668 if (optional || optionalChained) {
2669 this.raise(this.start, "Optional chaining cannot appear in the tag of tagged template expressions");
2670 }
2671 var node$2 = this.startNodeAt(startPos, startLoc);
2672 node$2.tag = base;
2673 node$2.quasi = this.parseTemplate({isTagged: true});
2674 base = this.finishNode(node$2, "TaggedTemplateExpression");
2675 }
2676 return base
2677 };
2678
2679 // Parse an atomic expression — either a single token that is an
2680 // expression, an expression started by a keyword like `function` or
2681 // `new`, or an expression wrapped in punctuation like `()`, `[]`,
2682 // or `{}`.
2683
2684 pp$4.parseExprAtom = function(refDestructuringErrors, forInit) {
2685 // If a division operator appears in an expression position, the
2686 // tokenizer got confused, and we force it to read a regexp instead.
2687 if (this.type === types.slash) { this.readRegexp(); }
2688
2689 var node, canBeArrow = this.potentialArrowAt === this.start;
2690 switch (this.type) {
2691 case types._super:
2692 if (!this.allowSuper)
2693 { this.raise(this.start, "'super' keyword outside a method"); }
2694 node = this.startNode();
2695 this.next();
2696 if (this.type === types.parenL && !this.allowDirectSuper)
2697 { this.raise(node.start, "super() call outside constructor of a subclass"); }
2698 // The `super` keyword can appear at below:
2699 // SuperProperty:
2700 // super [ Expression ]
2701 // super . IdentifierName
2702 // SuperCall:
2703 // super ( Arguments )
2704 if (this.type !== types.dot && this.type !== types.bracketL && this.type !== types.parenL)
2705 { this.unexpected(); }
2706 return this.finishNode(node, "Super")
2707
2708 case types._this:
2709 node = this.startNode();
2710 this.next();
2711 return this.finishNode(node, "ThisExpression")
2712
2713 case types.name:
2714 var startPos = this.start, startLoc = this.startLoc, containsEsc = this.containsEsc;
2715 var id = this.parseIdent(false);
2716 if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === "async" && !this.canInsertSemicolon() && this.eat(types._function)) {
2717 this.overrideContext(types$1.f_expr);
2718 return this.parseFunction(this.startNodeAt(startPos, startLoc), 0, false, true, forInit)
2719 }
2720 if (canBeArrow && !this.canInsertSemicolon()) {
2721 if (this.eat(types.arrow))
2722 { return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false, forInit) }
2723 if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === types.name && !containsEsc &&
2724 (!this.potentialArrowInForAwait || this.value !== "of" || this.containsEsc)) {
2725 id = this.parseIdent(false);
2726 if (this.canInsertSemicolon() || !this.eat(types.arrow))
2727 { this.unexpected(); }
2728 return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true, forInit)
2729 }
2730 }
2731 return id
2732
2733 case types.regexp:
2734 var value = this.value;
2735 node = this.parseLiteral(value.value);
2736 node.regex = {pattern: value.pattern, flags: value.flags};
2737 return node
2738
2739 case types.num: case types.string:
2740 return this.parseLiteral(this.value)
2741
2742 case types._null: case types._true: case types._false:
2743 node = this.startNode();
2744 node.value = this.type === types._null ? null : this.type === types._true;
2745 node.raw = this.type.keyword;
2746 this.next();
2747 return this.finishNode(node, "Literal")
2748
2749 case types.parenL:
2750 var start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow, forInit);
2751 if (refDestructuringErrors) {
2752 if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr))
2753 { refDestructuringErrors.parenthesizedAssign = start; }
2754 if (refDestructuringErrors.parenthesizedBind < 0)
2755 { refDestructuringErrors.parenthesizedBind = start; }
2756 }
2757 return expr
2758
2759 case types.bracketL:
2760 node = this.startNode();
2761 this.next();
2762 node.elements = this.parseExprList(types.bracketR, true, true, refDestructuringErrors);
2763 return this.finishNode(node, "ArrayExpression")
2764
2765 case types.braceL:
2766 this.overrideContext(types$1.b_expr);
2767 return this.parseObj(false, refDestructuringErrors)
2768
2769 case types._function:
2770 node = this.startNode();
2771 this.next();
2772 return this.parseFunction(node, 0)
2773
2774 case types._class:
2775 return this.parseClass(this.startNode(), false)
2776
2777 case types._new:
2778 return this.parseNew()
2779
2780 case types.backQuote:
2781 return this.parseTemplate()
2782
2783 case types._import:
2784 if (this.options.ecmaVersion >= 11) {
2785 return this.parseExprImport()
2786 } else {
2787 return this.unexpected()
2788 }
2789
2790 default:
2791 this.unexpected();
2792 }
2793 };
2794
2795 pp$4.parseExprImport = function() {
2796 var node = this.startNode();
2797
2798 // Consume `import` as an identifier for `import.meta`.
2799 // Because `this.parseIdent(true)` doesn't check escape sequences, it needs the check of `this.containsEsc`.
2800 if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword import"); }
2801 var meta = this.parseIdent(true);
2802
2803 switch (this.type) {
2804 case types.parenL:
2805 return this.parseDynamicImport(node)
2806 case types.dot:
2807 node.meta = meta;
2808 return this.parseImportMeta(node)
2809 default:
2810 this.unexpected();
2811 }
2812 };
2813
2814 pp$4.parseDynamicImport = function(node) {
2815 this.next(); // skip `(`
2816
2817 // Parse node.source.
2818 node.source = this.parseMaybeAssign();
2819
2820 // Verify ending.
2821 if (!this.eat(types.parenR)) {
2822 var errorPos = this.start;
2823 if (this.eat(types.comma) && this.eat(types.parenR)) {
2824 this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()");
2825 } else {
2826 this.unexpected(errorPos);
2827 }
2828 }
2829
2830 return this.finishNode(node, "ImportExpression")
2831 };
2832
2833 pp$4.parseImportMeta = function(node) {
2834 this.next(); // skip `.`
2835
2836 var containsEsc = this.containsEsc;
2837 node.property = this.parseIdent(true);
2838
2839 if (node.property.name !== "meta")
2840 { this.raiseRecoverable(node.property.start, "The only valid meta property for import is 'import.meta'"); }
2841 if (containsEsc)
2842 { this.raiseRecoverable(node.start, "'import.meta' must not contain escaped characters"); }
2843 if (this.options.sourceType !== "module" && !this.options.allowImportExportEverywhere)
2844 { this.raiseRecoverable(node.start, "Cannot use 'import.meta' outside a module"); }
2845
2846 return this.finishNode(node, "MetaProperty")
2847 };
2848
2849 pp$4.parseLiteral = function(value) {
2850 var node = this.startNode();
2851 node.value = value;
2852 node.raw = this.input.slice(this.start, this.end);
2853 if (node.raw.charCodeAt(node.raw.length - 1) === 110) { node.bigint = node.raw.slice(0, -1).replace(/_/g, ""); }
2854 this.next();
2855 return this.finishNode(node, "Literal")
2856 };
2857
2858 pp$4.parseParenExpression = function() {
2859 this.expect(types.parenL);
2860 var val = this.parseExpression();
2861 this.expect(types.parenR);
2862 return val
2863 };
2864
2865 pp$4.parseParenAndDistinguishExpression = function(canBeArrow, forInit) {
2866 var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8;
2867 if (this.options.ecmaVersion >= 6) {
2868 this.next();
2869
2870 var innerStartPos = this.start, innerStartLoc = this.startLoc;
2871 var exprList = [], first = true, lastIsComma = false;
2872 var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart;
2873 this.yieldPos = 0;
2874 this.awaitPos = 0;
2875 // Do not save awaitIdentPos to allow checking awaits nested in parameters
2876 while (this.type !== types.parenR) {
2877 first ? first = false : this.expect(types.comma);
2878 if (allowTrailingComma && this.afterTrailingComma(types.parenR, true)) {
2879 lastIsComma = true;
2880 break
2881 } else if (this.type === types.ellipsis) {
2882 spreadStart = this.start;
2883 exprList.push(this.parseParenItem(this.parseRestBinding()));
2884 if (this.type === types.comma) { this.raise(this.start, "Comma is not permitted after the rest element"); }
2885 break
2886 } else {
2887 exprList.push(this.parseMaybeAssign(false, refDestructuringErrors, this.parseParenItem));
2888 }
2889 }
2890 var innerEndPos = this.lastTokEnd, innerEndLoc = this.lastTokEndLoc;
2891 this.expect(types.parenR);
2892
2893 if (canBeArrow && !this.canInsertSemicolon() && this.eat(types.arrow)) {
2894 this.checkPatternErrors(refDestructuringErrors, false);
2895 this.checkYieldAwaitInDefaultParams();
2896 this.yieldPos = oldYieldPos;
2897 this.awaitPos = oldAwaitPos;
2898 return this.parseParenArrowList(startPos, startLoc, exprList, forInit)
2899 }
2900
2901 if (!exprList.length || lastIsComma) { this.unexpected(this.lastTokStart); }
2902 if (spreadStart) { this.unexpected(spreadStart); }
2903 this.checkExpressionErrors(refDestructuringErrors, true);
2904 this.yieldPos = oldYieldPos || this.yieldPos;
2905 this.awaitPos = oldAwaitPos || this.awaitPos;
2906
2907 if (exprList.length > 1) {
2908 val = this.startNodeAt(innerStartPos, innerStartLoc);
2909 val.expressions = exprList;
2910 this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc);
2911 } else {
2912 val = exprList[0];
2913 }
2914 } else {
2915 val = this.parseParenExpression();
2916 }
2917
2918 if (this.options.preserveParens) {
2919 var par = this.startNodeAt(startPos, startLoc);
2920 par.expression = val;
2921 return this.finishNode(par, "ParenthesizedExpression")
2922 } else {
2923 return val
2924 }
2925 };
2926
2927 pp$4.parseParenItem = function(item) {
2928 return item
2929 };
2930
2931 pp$4.parseParenArrowList = function(startPos, startLoc, exprList, forInit) {
2932 return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, forInit)
2933 };
2934
2935 // New's precedence is slightly tricky. It must allow its argument to
2936 // be a `[]` or dot subscript expression, but not a call — at least,
2937 // not without wrapping it in parentheses. Thus, it uses the noCalls
2938 // argument to parseSubscripts to prevent it from consuming the
2939 // argument list.
2940
2941 var empty$1 = [];
2942
2943 pp$4.parseNew = function() {
2944 if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword new"); }
2945 var node = this.startNode();
2946 var meta = this.parseIdent(true);
2947 if (this.options.ecmaVersion >= 6 && this.eat(types.dot)) {
2948 node.meta = meta;
2949 var containsEsc = this.containsEsc;
2950 node.property = this.parseIdent(true);
2951 if (node.property.name !== "target")
2952 { this.raiseRecoverable(node.property.start, "The only valid meta property for new is 'new.target'"); }
2953 if (containsEsc)
2954 { this.raiseRecoverable(node.start, "'new.target' must not contain escaped characters"); }
2955 if (!this.allowNewDotTarget)
2956 { this.raiseRecoverable(node.start, "'new.target' can only be used in functions and class static block"); }
2957 return this.finishNode(node, "MetaProperty")
2958 }
2959 var startPos = this.start, startLoc = this.startLoc, isImport = this.type === types._import;
2960 node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true, false);
2961 if (isImport && node.callee.type === "ImportExpression") {
2962 this.raise(startPos, "Cannot use new with import()");
2963 }
2964 if (this.eat(types.parenL)) { node.arguments = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8, false); }
2965 else { node.arguments = empty$1; }
2966 return this.finishNode(node, "NewExpression")
2967 };
2968
2969 // Parse template expression.
2970
2971 pp$4.parseTemplateElement = function(ref) {
2972 var isTagged = ref.isTagged;
2973
2974 var elem = this.startNode();
2975 if (this.type === types.invalidTemplate) {
2976 if (!isTagged) {
2977 this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal");
2978 }
2979 elem.value = {
2980 raw: this.value,
2981 cooked: null
2982 };
2983 } else {
2984 elem.value = {
2985 raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, "\n"),
2986 cooked: this.value
2987 };
2988 }
2989 this.next();
2990 elem.tail = this.type === types.backQuote;
2991 return this.finishNode(elem, "TemplateElement")
2992 };
2993
2994 pp$4.parseTemplate = function(ref) {
2995 if ( ref === void 0 ) ref = {};
2996 var isTagged = ref.isTagged; if ( isTagged === void 0 ) isTagged = false;
2997
2998 var node = this.startNode();
2999 this.next();
3000 node.expressions = [];
3001 var curElt = this.parseTemplateElement({isTagged: isTagged});
3002 node.quasis = [curElt];
3003 while (!curElt.tail) {
3004 if (this.type === types.eof) { this.raise(this.pos, "Unterminated template literal"); }
3005 this.expect(types.dollarBraceL);
3006 node.expressions.push(this.parseExpression());
3007 this.expect(types.braceR);
3008 node.quasis.push(curElt = this.parseTemplateElement({isTagged: isTagged}));
3009 }
3010 this.next();
3011 return this.finishNode(node, "TemplateLiteral")
3012 };
3013
3014 pp$4.isAsyncProp = function(prop) {
3015 return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" &&
3016 (this.type === types.name || this.type === types.num || this.type === types.string || this.type === types.bracketL || this.type.keyword || (this.options.ecmaVersion >= 9 && this.type === types.star)) &&
3017 !lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
3018 };
3019
3020 // Parse an object literal or binding pattern.
3021
3022 pp$4.parseObj = function(isPattern, refDestructuringErrors) {
3023 var node = this.startNode(), first = true, propHash = {};
3024 node.properties = [];
3025 this.next();
3026 while (!this.eat(types.braceR)) {
3027 if (!first) {
3028 this.expect(types.comma);
3029 if (this.options.ecmaVersion >= 5 && this.afterTrailingComma(types.braceR)) { break }
3030 } else { first = false; }
3031
3032 var prop = this.parseProperty(isPattern, refDestructuringErrors);
3033 if (!isPattern) { this.checkPropClash(prop, propHash, refDestructuringErrors); }
3034 node.properties.push(prop);
3035 }
3036 return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression")
3037 };
3038
3039 pp$4.parseProperty = function(isPattern, refDestructuringErrors) {
3040 var prop = this.startNode(), isGenerator, isAsync, startPos, startLoc;
3041 if (this.options.ecmaVersion >= 9 && this.eat(types.ellipsis)) {
3042 if (isPattern) {
3043 prop.argument = this.parseIdent(false);
3044 if (this.type === types.comma) {
3045 this.raise(this.start, "Comma is not permitted after the rest element");
3046 }
3047 return this.finishNode(prop, "RestElement")
3048 }
3049 // To disallow parenthesized identifier via `this.toAssignable()`.
3050 if (this.type === types.parenL && refDestructuringErrors) {
3051 if (refDestructuringErrors.parenthesizedAssign < 0) {
3052 refDestructuringErrors.parenthesizedAssign = this.start;
3053 }
3054 if (refDestructuringErrors.parenthesizedBind < 0) {
3055 refDestructuringErrors.parenthesizedBind = this.start;
3056 }
3057 }
3058 // Parse argument.
3059 prop.argument = this.parseMaybeAssign(false, refDestructuringErrors);
3060 // To disallow trailing comma via `this.toAssignable()`.
3061 if (this.type === types.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0) {
3062 refDestructuringErrors.trailingComma = this.start;
3063 }
3064 // Finish
3065 return this.finishNode(prop, "SpreadElement")
3066 }
3067 if (this.options.ecmaVersion >= 6) {
3068 prop.method = false;
3069 prop.shorthand = false;
3070 if (isPattern || refDestructuringErrors) {
3071 startPos = this.start;
3072 startLoc = this.startLoc;
3073 }
3074 if (!isPattern)
3075 { isGenerator = this.eat(types.star); }
3076 }
3077 var containsEsc = this.containsEsc;
3078 this.parsePropertyName(prop);
3079 if (!isPattern && !containsEsc && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) {
3080 isAsync = true;
3081 isGenerator = this.options.ecmaVersion >= 9 && this.eat(types.star);
3082 this.parsePropertyName(prop, refDestructuringErrors);
3083 } else {
3084 isAsync = false;
3085 }
3086 this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc);
3087 return this.finishNode(prop, "Property")
3088 };
3089
3090 pp$4.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) {
3091 if ((isGenerator || isAsync) && this.type === types.colon)
3092 { this.unexpected(); }
3093
3094 if (this.eat(types.colon)) {
3095 prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors);
3096 prop.kind = "init";
3097 } else if (this.options.ecmaVersion >= 6 && this.type === types.parenL) {
3098 if (isPattern) { this.unexpected(); }
3099 prop.kind = "init";
3100 prop.method = true;
3101 prop.value = this.parseMethod(isGenerator, isAsync);
3102 } else if (!isPattern && !containsEsc &&
3103 this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" &&
3104 (prop.key.name === "get" || prop.key.name === "set") &&
3105 (this.type !== types.comma && this.type !== types.braceR && this.type !== types.eq)) {
3106 if (isGenerator || isAsync) { this.unexpected(); }
3107 prop.kind = prop.key.name;
3108 this.parsePropertyName(prop);
3109 prop.value = this.parseMethod(false);
3110 var paramCount = prop.kind === "get" ? 0 : 1;
3111 if (prop.value.params.length !== paramCount) {
3112 var start = prop.value.start;
3113 if (prop.kind === "get")
3114 { this.raiseRecoverable(start, "getter should have no params"); }
3115 else
3116 { this.raiseRecoverable(start, "setter should have exactly one param"); }
3117 } else {
3118 if (prop.kind === "set" && prop.value.params[0].type === "RestElement")
3119 { this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params"); }
3120 }
3121 } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
3122 if (isGenerator || isAsync) { this.unexpected(); }
3123 this.checkUnreserved(prop.key);
3124 if (prop.key.name === "await" && !this.awaitIdentPos)
3125 { this.awaitIdentPos = startPos; }
3126 prop.kind = "init";
3127 if (isPattern) {
3128 prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key));
3129 } else if (this.type === types.eq && refDestructuringErrors) {
3130 if (refDestructuringErrors.shorthandAssign < 0)
3131 { refDestructuringErrors.shorthandAssign = this.start; }
3132 prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key));
3133 } else {
3134 prop.value = this.copyNode(prop.key);
3135 }
3136 prop.shorthand = true;
3137 } else { this.unexpected(); }
3138 };
3139
3140 pp$4.parsePropertyName = function(prop) {
3141 if (this.options.ecmaVersion >= 6) {
3142 if (this.eat(types.bracketL)) {
3143 prop.computed = true;
3144 prop.key = this.parseMaybeAssign();
3145 this.expect(types.bracketR);
3146 return prop.key
3147 } else {
3148 prop.computed = false;
3149 }
3150 }
3151 return prop.key = this.type === types.num || this.type === types.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never")
3152 };
3153
3154 // Initialize empty function node.
3155
3156 pp$4.initFunction = function(node) {
3157 node.id = null;
3158 if (this.options.ecmaVersion >= 6) { node.generator = node.expression = false; }
3159 if (this.options.ecmaVersion >= 8) { node.async = false; }
3160 };
3161
3162 // Parse object or class method.
3163
3164 pp$4.parseMethod = function(isGenerator, isAsync, allowDirectSuper) {
3165 var node = this.startNode(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
3166
3167 this.initFunction(node);
3168 if (this.options.ecmaVersion >= 6)
3169 { node.generator = isGenerator; }
3170 if (this.options.ecmaVersion >= 8)
3171 { node.async = !!isAsync; }
3172
3173 this.yieldPos = 0;
3174 this.awaitPos = 0;
3175 this.awaitIdentPos = 0;
3176 this.enterScope(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0));
3177
3178 this.expect(types.parenL);
3179 node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8);
3180 this.checkYieldAwaitInDefaultParams();
3181 this.parseFunctionBody(node, false, true, false);
3182
3183 this.yieldPos = oldYieldPos;
3184 this.awaitPos = oldAwaitPos;
3185 this.awaitIdentPos = oldAwaitIdentPos;
3186 return this.finishNode(node, "FunctionExpression")
3187 };
3188
3189 // Parse arrow function expression with given parameters.
3190
3191 pp$4.parseArrowExpression = function(node, params, isAsync, forInit) {
3192 var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
3193
3194 this.enterScope(functionFlags(isAsync, false) | SCOPE_ARROW);
3195 this.initFunction(node);
3196 if (this.options.ecmaVersion >= 8) { node.async = !!isAsync; }
3197
3198 this.yieldPos = 0;
3199 this.awaitPos = 0;
3200 this.awaitIdentPos = 0;
3201
3202 node.params = this.toAssignableList(params, true);
3203 this.parseFunctionBody(node, true, false, forInit);
3204
3205 this.yieldPos = oldYieldPos;
3206 this.awaitPos = oldAwaitPos;
3207 this.awaitIdentPos = oldAwaitIdentPos;
3208 return this.finishNode(node, "ArrowFunctionExpression")
3209 };
3210
3211 // Parse function body and check parameters.
3212
3213 pp$4.parseFunctionBody = function(node, isArrowFunction, isMethod, forInit) {
3214 var isExpression = isArrowFunction && this.type !== types.braceL;
3215 var oldStrict = this.strict, useStrict = false;
3216
3217 if (isExpression) {
3218 node.body = this.parseMaybeAssign(forInit);
3219 node.expression = true;
3220 this.checkParams(node, false);
3221 } else {
3222 var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params);
3223 if (!oldStrict || nonSimple) {
3224 useStrict = this.strictDirective(this.end);
3225 // If this is a strict mode function, verify that argument names
3226 // are not repeated, and it does not try to bind the words `eval`
3227 // or `arguments`.
3228 if (useStrict && nonSimple)
3229 { this.raiseRecoverable(node.start, "Illegal 'use strict' directive in function with non-simple parameter list"); }
3230 }
3231 // Start a new scope with regard to labels and the `inFunction`
3232 // flag (restore them to their old value afterwards).
3233 var oldLabels = this.labels;
3234 this.labels = [];
3235 if (useStrict) { this.strict = true; }
3236
3237 // Add the params to varDeclaredNames to ensure that an error is thrown
3238 // if a let/const declaration in the function clashes with one of the params.
3239 this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params));
3240 // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval'
3241 if (this.strict && node.id) { this.checkLValSimple(node.id, BIND_OUTSIDE); }
3242 node.body = this.parseBlock(false, undefined, useStrict && !oldStrict);
3243 node.expression = false;
3244 this.adaptDirectivePrologue(node.body.body);
3245 this.labels = oldLabels;
3246 }
3247 this.exitScope();
3248 };
3249
3250 pp$4.isSimpleParamList = function(params) {
3251 for (var i = 0, list = params; i < list.length; i += 1)
3252 {
3253 var param = list[i];
3254
3255 if (param.type !== "Identifier") { return false
3256 } }
3257 return true
3258 };
3259
3260 // Checks function params for various disallowed patterns such as using "eval"
3261 // or "arguments" and duplicate parameters.
3262
3263 pp$4.checkParams = function(node, allowDuplicates) {
3264 var nameHash = Object.create(null);
3265 for (var i = 0, list = node.params; i < list.length; i += 1)
3266 {
3267 var param = list[i];
3268
3269 this.checkLValInnerPattern(param, BIND_VAR, allowDuplicates ? null : nameHash);
3270 }
3271 };
3272
3273 // Parses a comma-separated list of expressions, and returns them as
3274 // an array. `close` is the token type that ends the list, and
3275 // `allowEmpty` can be turned on to allow subsequent commas with
3276 // nothing in between them to be parsed as `null` (which is needed
3277 // for array literals).
3278
3279 pp$4.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) {
3280 var elts = [], first = true;
3281 while (!this.eat(close)) {
3282 if (!first) {
3283 this.expect(types.comma);
3284 if (allowTrailingComma && this.afterTrailingComma(close)) { break }
3285 } else { first = false; }
3286
3287 var elt = (void 0);
3288 if (allowEmpty && this.type === types.comma)
3289 { elt = null; }
3290 else if (this.type === types.ellipsis) {
3291 elt = this.parseSpread(refDestructuringErrors);
3292 if (refDestructuringErrors && this.type === types.comma && refDestructuringErrors.trailingComma < 0)
3293 { refDestructuringErrors.trailingComma = this.start; }
3294 } else {
3295 elt = this.parseMaybeAssign(false, refDestructuringErrors);
3296 }
3297 elts.push(elt);
3298 }
3299 return elts
3300 };
3301
3302 pp$4.checkUnreserved = function(ref) {
3303 var start = ref.start;
3304 var end = ref.end;
3305 var name = ref.name;
3306
3307 if (this.inGenerator && name === "yield")
3308 { this.raiseRecoverable(start, "Cannot use 'yield' as identifier inside a generator"); }
3309 if (this.inAsync && name === "await")
3310 { this.raiseRecoverable(start, "Cannot use 'await' as identifier inside an async function"); }
3311 if (this.currentThisScope().inClassFieldInit && name === "arguments")
3312 { this.raiseRecoverable(start, "Cannot use 'arguments' in class field initializer"); }
3313 if (this.inClassStaticBlock && (name === "arguments" || name === "await"))
3314 { this.raise(start, ("Cannot use " + name + " in class static initialization block")); }
3315 if (this.keywords.test(name))
3316 { this.raise(start, ("Unexpected keyword '" + name + "'")); }
3317 if (this.options.ecmaVersion < 6 &&
3318 this.input.slice(start, end).indexOf("\\") !== -1) { return }
3319 var re = this.strict ? this.reservedWordsStrict : this.reservedWords;
3320 if (re.test(name)) {
3321 if (!this.inAsync && name === "await")
3322 { this.raiseRecoverable(start, "Cannot use keyword 'await' outside an async function"); }
3323 this.raiseRecoverable(start, ("The keyword '" + name + "' is reserved"));
3324 }
3325 };
3326
3327 // Parse the next token as an identifier. If `liberal` is true (used
3328 // when parsing properties), it will also convert keywords into
3329 // identifiers.
3330
3331 pp$4.parseIdent = function(liberal, isBinding) {
3332 var node = this.startNode();
3333 if (this.type === types.name) {
3334 node.name = this.value;
3335 } else if (this.type.keyword) {
3336 node.name = this.type.keyword;
3337
3338 // To fix https://github.com/acornjs/acorn/issues/575
3339 // `class` and `function` keywords push new context into this.context.
3340 // But there is no chance to pop the context if the keyword is consumed as an identifier such as a property name.
3341 // If the previous token is a dot, this does not apply because the context-managing code already ignored the keyword
3342 if ((node.name === "class" || node.name === "function") &&
3343 (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) {
3344 this.context.pop();
3345 }
3346 } else {
3347 this.unexpected();
3348 }
3349 this.next(!!liberal);
3350 this.finishNode(node, "Identifier");
3351 if (!liberal) {
3352 this.checkUnreserved(node);
3353 if (node.name === "await" && !this.awaitIdentPos)
3354 { this.awaitIdentPos = node.start; }
3355 }
3356 return node
3357 };
3358
3359 pp$4.parsePrivateIdent = function() {
3360 var node = this.startNode();
3361 if (this.type === types.privateId) {
3362 node.name = this.value;
3363 } else {
3364 this.unexpected();
3365 }
3366 this.next();
3367 this.finishNode(node, "PrivateIdentifier");
3368
3369 // For validating existence
3370 if (this.privateNameStack.length === 0) {
3371 this.raise(node.start, ("Private field '#" + (node.name) + "' must be declared in an enclosing class"));
3372 } else {
3373 this.privateNameStack[this.privateNameStack.length - 1].used.push(node);
3374 }
3375
3376 return node
3377 };
3378
3379 // Parses yield expression inside generator.
3380
3381 pp$4.parseYield = function(forInit) {
3382 if (!this.yieldPos) { this.yieldPos = this.start; }
3383
3384 var node = this.startNode();
3385 this.next();
3386 if (this.type === types.semi || this.canInsertSemicolon() || (this.type !== types.star && !this.type.startsExpr)) {
3387 node.delegate = false;
3388 node.argument = null;
3389 } else {
3390 node.delegate = this.eat(types.star);
3391 node.argument = this.parseMaybeAssign(forInit);
3392 }
3393 return this.finishNode(node, "YieldExpression")
3394 };
3395
3396 pp$4.parseAwait = function(forInit) {
3397 if (!this.awaitPos) { this.awaitPos = this.start; }
3398
3399 var node = this.startNode();
3400 this.next();
3401 node.argument = this.parseMaybeUnary(null, true, false, forInit);
3402 return this.finishNode(node, "AwaitExpression")
3403 };
3404
3405 var pp$5 = Parser.prototype;
3406
3407 // This function is used to raise exceptions on parse errors. It
3408 // takes an offset integer (into the current `input`) to indicate
3409 // the location of the error, attaches the position to the end
3410 // of the error message, and then raises a `SyntaxError` with that
3411 // message.
3412
3413 pp$5.raise = function(pos, message) {
3414 var loc = getLineInfo(this.input, pos);
3415 message += " (" + loc.line + ":" + loc.column + ")";
3416 var err = new SyntaxError(message);
3417 err.pos = pos; err.loc = loc; err.raisedAt = this.pos;
3418 throw err
3419 };
3420
3421 pp$5.raiseRecoverable = pp$5.raise;
3422
3423 pp$5.curPosition = function() {
3424 if (this.options.locations) {
3425 return new Position(this.curLine, this.pos - this.lineStart)
3426 }
3427 };
3428
3429 var pp$6 = Parser.prototype;
3430
3431 var Scope = function Scope(flags) {
3432 this.flags = flags;
3433 // A list of var-declared names in the current lexical scope
3434 this.var = [];
3435 // A list of lexically-declared names in the current lexical scope
3436 this.lexical = [];
3437 // A list of lexically-declared FunctionDeclaration names in the current lexical scope
3438 this.functions = [];
3439 // A switch to disallow the identifier reference 'arguments'
3440 this.inClassFieldInit = false;
3441 };
3442
3443 // The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names.
3444
3445 pp$6.enterScope = function(flags) {
3446 this.scopeStack.push(new Scope(flags));
3447 };
3448
3449 pp$6.exitScope = function() {
3450 this.scopeStack.pop();
3451 };
3452
3453 // The spec says:
3454 // > At the top level of a function, or script, function declarations are
3455 // > treated like var declarations rather than like lexical declarations.
3456 pp$6.treatFunctionsAsVarInScope = function(scope) {
3457 return (scope.flags & SCOPE_FUNCTION) || !this.inModule && (scope.flags & SCOPE_TOP)
3458 };
3459
3460 pp$6.declareName = function(name, bindingType, pos) {
3461 var redeclared = false;
3462 if (bindingType === BIND_LEXICAL) {
3463 var scope = this.currentScope();
3464 redeclared = scope.lexical.indexOf(name) > -1 || scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1;
3465 scope.lexical.push(name);
3466 if (this.inModule && (scope.flags & SCOPE_TOP))
3467 { delete this.undefinedExports[name]; }
3468 } else if (bindingType === BIND_SIMPLE_CATCH) {
3469 var scope$1 = this.currentScope();
3470 scope$1.lexical.push(name);
3471 } else if (bindingType === BIND_FUNCTION) {
3472 var scope$2 = this.currentScope();
3473 if (this.treatFunctionsAsVar)
3474 { redeclared = scope$2.lexical.indexOf(name) > -1; }
3475 else
3476 { redeclared = scope$2.lexical.indexOf(name) > -1 || scope$2.var.indexOf(name) > -1; }
3477 scope$2.functions.push(name);
3478 } else {
3479 for (var i = this.scopeStack.length - 1; i >= 0; --i) {
3480 var scope$3 = this.scopeStack[i];
3481 if (scope$3.lexical.indexOf(name) > -1 && !((scope$3.flags & SCOPE_SIMPLE_CATCH) && scope$3.lexical[0] === name) ||
3482 !this.treatFunctionsAsVarInScope(scope$3) && scope$3.functions.indexOf(name) > -1) {
3483 redeclared = true;
3484 break
3485 }
3486 scope$3.var.push(name);
3487 if (this.inModule && (scope$3.flags & SCOPE_TOP))
3488 { delete this.undefinedExports[name]; }
3489 if (scope$3.flags & SCOPE_VAR) { break }
3490 }
3491 }
3492 if (redeclared) { this.raiseRecoverable(pos, ("Identifier '" + name + "' has already been declared")); }
3493 };
3494
3495 pp$6.checkLocalExport = function(id) {
3496 // scope.functions must be empty as Module code is always strict.
3497 if (this.scopeStack[0].lexical.indexOf(id.name) === -1 &&
3498 this.scopeStack[0].var.indexOf(id.name) === -1) {
3499 this.undefinedExports[id.name] = id;
3500 }
3501 };
3502
3503 pp$6.currentScope = function() {
3504 return this.scopeStack[this.scopeStack.length - 1]
3505 };
3506
3507 pp$6.currentVarScope = function() {
3508 for (var i = this.scopeStack.length - 1;; i--) {
3509 var scope = this.scopeStack[i];
3510 if (scope.flags & SCOPE_VAR) { return scope }
3511 }
3512 };
3513
3514 // Could be useful for `this`, `new.target`, `super()`, `super.property`, and `super[property]`.
3515 pp$6.currentThisScope = function() {
3516 for (var i = this.scopeStack.length - 1;; i--) {
3517 var scope = this.scopeStack[i];
3518 if (scope.flags & SCOPE_VAR && !(scope.flags & SCOPE_ARROW)) { return scope }
3519 }
3520 };
3521
3522 var Node = function Node(parser, pos, loc) {
3523 this.type = "";
3524 this.start = pos;
3525 this.end = 0;
3526 if (parser.options.locations)
3527 { this.loc = new SourceLocation(parser, loc); }
3528 if (parser.options.directSourceFile)
3529 { this.sourceFile = parser.options.directSourceFile; }
3530 if (parser.options.ranges)
3531 { this.range = [pos, 0]; }
3532 };
3533
3534 // Start an AST node, attaching a start offset.
3535
3536 var pp$7 = Parser.prototype;
3537
3538 pp$7.startNode = function() {
3539 return new Node(this, this.start, this.startLoc)
3540 };
3541
3542 pp$7.startNodeAt = function(pos, loc) {
3543 return new Node(this, pos, loc)
3544 };
3545
3546 // Finish an AST node, adding `type` and `end` properties.
3547
3548 function finishNodeAt(node, type, pos, loc) {
3549 node.type = type;
3550 node.end = pos;
3551 if (this.options.locations)
3552 { node.loc.end = loc; }
3553 if (this.options.ranges)
3554 { node.range[1] = pos; }
3555 return node
3556 }
3557
3558 pp$7.finishNode = function(node, type) {
3559 return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc)
3560 };
3561
3562 // Finish node at given position
3563
3564 pp$7.finishNodeAt = function(node, type, pos, loc) {
3565 return finishNodeAt.call(this, node, type, pos, loc)
3566 };
3567
3568 pp$7.copyNode = function(node) {
3569 var newNode = new Node(this, node.start, this.startLoc);
3570 for (var prop in node) { newNode[prop] = node[prop]; }
3571 return newNode
3572 };
3573
3574 // This file contains Unicode properties extracted from the ECMAScript
3575 // specification. The lists are extracted like so:
3576 // $$('#table-binary-unicode-properties > figure > table > tbody > tr > td:nth-child(1) code').map(el => el.innerText)
3577
3578 // #table-binary-unicode-properties
3579 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";
3580 var ecma10BinaryProperties = ecma9BinaryProperties + " Extended_Pictographic";
3581 var ecma11BinaryProperties = ecma10BinaryProperties;
3582 var ecma12BinaryProperties = ecma11BinaryProperties + " EBase EComp EMod EPres ExtPict";
3583 var unicodeBinaryProperties = {
3584 9: ecma9BinaryProperties,
3585 10: ecma10BinaryProperties,
3586 11: ecma11BinaryProperties,
3587 12: ecma12BinaryProperties
3588 };
3589
3590 // #table-unicode-general-category-values
3591 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";
3592
3593 // #table-unicode-script-values
3594 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";
3595 var ecma10ScriptValues = ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd";
3596 var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho";
3597 var ecma12ScriptValues = ecma11ScriptValues + " Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi";
3598 var unicodeScriptValues = {
3599 9: ecma9ScriptValues,
3600 10: ecma10ScriptValues,
3601 11: ecma11ScriptValues,
3602 12: ecma12ScriptValues
3603 };
3604
3605 var data = {};
3606 function buildUnicodeData(ecmaVersion) {
3607 var d = data[ecmaVersion] = {
3608 binary: wordsRegexp(unicodeBinaryProperties[ecmaVersion] + " " + unicodeGeneralCategoryValues),
3609 nonBinary: {
3610 General_Category: wordsRegexp(unicodeGeneralCategoryValues),
3611 Script: wordsRegexp(unicodeScriptValues[ecmaVersion])
3612 }
3613 };
3614 d.nonBinary.Script_Extensions = d.nonBinary.Script;
3615
3616 d.nonBinary.gc = d.nonBinary.General_Category;
3617 d.nonBinary.sc = d.nonBinary.Script;
3618 d.nonBinary.scx = d.nonBinary.Script_Extensions;
3619 }
3620 buildUnicodeData(9);
3621 buildUnicodeData(10);
3622 buildUnicodeData(11);
3623 buildUnicodeData(12);
3624
3625 var pp$8 = Parser.prototype;
3626
3627 var RegExpValidationState = function RegExpValidationState(parser) {
3628 this.parser = parser;
3629 this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "");
3630 this.unicodeProperties = data[parser.options.ecmaVersion >= 12 ? 12 : parser.options.ecmaVersion];
3631 this.source = "";
3632 this.flags = "";
3633 this.start = 0;
3634 this.switchU = false;
3635 this.switchN = false;
3636 this.pos = 0;
3637 this.lastIntValue = 0;
3638 this.lastStringValue = "";
3639 this.lastAssertionIsQuantifiable = false;
3640 this.numCapturingParens = 0;
3641 this.maxBackReference = 0;
3642 this.groupNames = [];
3643 this.backReferenceNames = [];
3644 };
3645
3646 RegExpValidationState.prototype.reset = function reset (start, pattern, flags) {
3647 var unicode = flags.indexOf("u") !== -1;
3648 this.start = start | 0;
3649 this.source = pattern + "";
3650 this.flags = flags;
3651 this.switchU = unicode && this.parser.options.ecmaVersion >= 6;
3652 this.switchN = unicode && this.parser.options.ecmaVersion >= 9;
3653 };
3654
3655 RegExpValidationState.prototype.raise = function raise (message) {
3656 this.parser.raiseRecoverable(this.start, ("Invalid regular expression: /" + (this.source) + "/: " + message));
3657 };
3658
3659 // If u flag is given, this returns the code point at the index (it combines a surrogate pair).
3660 // Otherwise, this returns the code unit of the index (can be a part of a surrogate pair).
3661 RegExpValidationState.prototype.at = function at (i, forceU) {
3662 if ( forceU === void 0 ) forceU = false;
3663
3664 var s = this.source;
3665 var l = s.length;
3666 if (i >= l) {
3667 return -1
3668 }
3669 var c = s.charCodeAt(i);
3670 if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) {
3671 return c
3672 }
3673 var next = s.charCodeAt(i + 1);
3674 return next >= 0xDC00 && next <= 0xDFFF ? (c << 10) + next - 0x35FDC00 : c
3675 };
3676
3677 RegExpValidationState.prototype.nextIndex = function nextIndex (i, forceU) {
3678 if ( forceU === void 0 ) forceU = false;
3679
3680 var s = this.source;
3681 var l = s.length;
3682 if (i >= l) {
3683 return l
3684 }
3685 var c = s.charCodeAt(i), next;
3686 if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l ||
3687 (next = s.charCodeAt(i + 1)) < 0xDC00 || next > 0xDFFF) {
3688 return i + 1
3689 }
3690 return i + 2
3691 };
3692
3693 RegExpValidationState.prototype.current = function current (forceU) {
3694 if ( forceU === void 0 ) forceU = false;
3695
3696 return this.at(this.pos, forceU)
3697 };
3698
3699 RegExpValidationState.prototype.lookahead = function lookahead (forceU) {
3700 if ( forceU === void 0 ) forceU = false;
3701
3702 return this.at(this.nextIndex(this.pos, forceU), forceU)
3703 };
3704
3705 RegExpValidationState.prototype.advance = function advance (forceU) {
3706 if ( forceU === void 0 ) forceU = false;
3707
3708 this.pos = this.nextIndex(this.pos, forceU);
3709 };
3710
3711 RegExpValidationState.prototype.eat = function eat (ch, forceU) {
3712 if ( forceU === void 0 ) forceU = false;
3713
3714 if (this.current(forceU) === ch) {
3715 this.advance(forceU);
3716 return true
3717 }
3718 return false
3719 };
3720
3721 function codePointToString(ch) {
3722 if (ch <= 0xFFFF) { return String.fromCharCode(ch) }
3723 ch -= 0x10000;
3724 return String.fromCharCode((ch >> 10) + 0xD800, (ch & 0x03FF) + 0xDC00)
3725 }
3726
3727 /**
3728 * Validate the flags part of a given RegExpLiteral.
3729 *
3730 * @param {RegExpValidationState} state The state to validate RegExp.
3731 * @returns {void}
3732 */
3733 pp$8.validateRegExpFlags = function(state) {
3734 var validFlags = state.validFlags;
3735 var flags = state.flags;
3736
3737 for (var i = 0; i < flags.length; i++) {
3738 var flag = flags.charAt(i);
3739 if (validFlags.indexOf(flag) === -1) {
3740 this.raise(state.start, "Invalid regular expression flag");
3741 }
3742 if (flags.indexOf(flag, i + 1) > -1) {
3743 this.raise(state.start, "Duplicate regular expression flag");
3744 }
3745 }
3746 };
3747
3748 /**
3749 * Validate the pattern part of a given RegExpLiteral.
3750 *
3751 * @param {RegExpValidationState} state The state to validate RegExp.
3752 * @returns {void}
3753 */
3754 pp$8.validateRegExpPattern = function(state) {
3755 this.regexp_pattern(state);
3756
3757 // The goal symbol for the parse is |Pattern[~U, ~N]|. If the result of
3758 // parsing contains a |GroupName|, reparse with the goal symbol
3759 // |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError*
3760 // exception if _P_ did not conform to the grammar, if any elements of _P_
3761 // were not matched by the parse, or if any Early Error conditions exist.
3762 if (!state.switchN && this.options.ecmaVersion >= 9 && state.groupNames.length > 0) {
3763 state.switchN = true;
3764 this.regexp_pattern(state);
3765 }
3766 };
3767
3768 // https://www.ecma-international.org/ecma-262/8.0/#prod-Pattern
3769 pp$8.regexp_pattern = function(state) {
3770 state.pos = 0;
3771 state.lastIntValue = 0;
3772 state.lastStringValue = "";
3773 state.lastAssertionIsQuantifiable = false;
3774 state.numCapturingParens = 0;
3775 state.maxBackReference = 0;
3776 state.groupNames.length = 0;
3777 state.backReferenceNames.length = 0;
3778
3779 this.regexp_disjunction(state);
3780
3781 if (state.pos !== state.source.length) {
3782 // Make the same messages as V8.
3783 if (state.eat(0x29 /* ) */)) {
3784 state.raise("Unmatched ')'");
3785 }
3786 if (state.eat(0x5D /* ] */) || state.eat(0x7D /* } */)) {
3787 state.raise("Lone quantifier brackets");
3788 }
3789 }
3790 if (state.maxBackReference > state.numCapturingParens) {
3791 state.raise("Invalid escape");
3792 }
3793 for (var i = 0, list = state.backReferenceNames; i < list.length; i += 1) {
3794 var name = list[i];
3795
3796 if (state.groupNames.indexOf(name) === -1) {
3797 state.raise("Invalid named capture referenced");
3798 }
3799 }
3800 };
3801
3802 // https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction
3803 pp$8.regexp_disjunction = function(state) {
3804 this.regexp_alternative(state);
3805 while (state.eat(0x7C /* | */)) {
3806 this.regexp_alternative(state);
3807 }
3808
3809 // Make the same message as V8.
3810 if (this.regexp_eatQuantifier(state, true)) {
3811 state.raise("Nothing to repeat");
3812 }
3813 if (state.eat(0x7B /* { */)) {
3814 state.raise("Lone quantifier brackets");
3815 }
3816 };
3817
3818 // https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative
3819 pp$8.regexp_alternative = function(state) {
3820 while (state.pos < state.source.length && this.regexp_eatTerm(state))
3821 { }
3822 };
3823
3824 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term
3825 pp$8.regexp_eatTerm = function(state) {
3826 if (this.regexp_eatAssertion(state)) {
3827 // Handle `QuantifiableAssertion Quantifier` alternative.
3828 // `state.lastAssertionIsQuantifiable` is true if the last eaten Assertion
3829 // is a QuantifiableAssertion.
3830 if (state.lastAssertionIsQuantifiable && this.regexp_eatQuantifier(state)) {
3831 // Make the same message as V8.
3832 if (state.switchU) {
3833 state.raise("Invalid quantifier");
3834 }
3835 }
3836 return true
3837 }
3838
3839 if (state.switchU ? this.regexp_eatAtom(state) : this.regexp_eatExtendedAtom(state)) {
3840 this.regexp_eatQuantifier(state);
3841 return true
3842 }
3843
3844 return false
3845 };
3846
3847 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Assertion
3848 pp$8.regexp_eatAssertion = function(state) {
3849 var start = state.pos;
3850 state.lastAssertionIsQuantifiable = false;
3851
3852 // ^, $
3853 if (state.eat(0x5E /* ^ */) || state.eat(0x24 /* $ */)) {
3854 return true
3855 }
3856
3857 // \b \B
3858 if (state.eat(0x5C /* \ */)) {
3859 if (state.eat(0x42 /* B */) || state.eat(0x62 /* b */)) {
3860 return true
3861 }
3862 state.pos = start;
3863 }
3864
3865 // Lookahead / Lookbehind
3866 if (state.eat(0x28 /* ( */) && state.eat(0x3F /* ? */)) {
3867 var lookbehind = false;
3868 if (this.options.ecmaVersion >= 9) {
3869 lookbehind = state.eat(0x3C /* < */);
3870 }
3871 if (state.eat(0x3D /* = */) || state.eat(0x21 /* ! */)) {
3872 this.regexp_disjunction(state);
3873 if (!state.eat(0x29 /* ) */)) {
3874 state.raise("Unterminated group");
3875 }
3876 state.lastAssertionIsQuantifiable = !lookbehind;
3877 return true
3878 }
3879 }
3880
3881 state.pos = start;
3882 return false
3883 };
3884
3885 // https://www.ecma-international.org/ecma-262/8.0/#prod-Quantifier
3886 pp$8.regexp_eatQuantifier = function(state, noError) {
3887 if ( noError === void 0 ) noError = false;
3888
3889 if (this.regexp_eatQuantifierPrefix(state, noError)) {
3890 state.eat(0x3F /* ? */);
3891 return true
3892 }
3893 return false
3894 };
3895
3896 // https://www.ecma-international.org/ecma-262/8.0/#prod-QuantifierPrefix
3897 pp$8.regexp_eatQuantifierPrefix = function(state, noError) {
3898 return (
3899 state.eat(0x2A /* * */) ||
3900 state.eat(0x2B /* + */) ||
3901 state.eat(0x3F /* ? */) ||
3902 this.regexp_eatBracedQuantifier(state, noError)
3903 )
3904 };
3905 pp$8.regexp_eatBracedQuantifier = function(state, noError) {
3906 var start = state.pos;
3907 if (state.eat(0x7B /* { */)) {
3908 var min = 0, max = -1;
3909 if (this.regexp_eatDecimalDigits(state)) {
3910 min = state.lastIntValue;
3911 if (state.eat(0x2C /* , */) && this.regexp_eatDecimalDigits(state)) {
3912 max = state.lastIntValue;
3913 }
3914 if (state.eat(0x7D /* } */)) {
3915 // SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-term
3916 if (max !== -1 && max < min && !noError) {
3917 state.raise("numbers out of order in {} quantifier");
3918 }
3919 return true
3920 }
3921 }
3922 if (state.switchU && !noError) {
3923 state.raise("Incomplete quantifier");
3924 }
3925 state.pos = start;
3926 }
3927 return false
3928 };
3929
3930 // https://www.ecma-international.org/ecma-262/8.0/#prod-Atom
3931 pp$8.regexp_eatAtom = function(state) {
3932 return (
3933 this.regexp_eatPatternCharacters(state) ||
3934 state.eat(0x2E /* . */) ||
3935 this.regexp_eatReverseSolidusAtomEscape(state) ||
3936 this.regexp_eatCharacterClass(state) ||
3937 this.regexp_eatUncapturingGroup(state) ||
3938 this.regexp_eatCapturingGroup(state)
3939 )
3940 };
3941 pp$8.regexp_eatReverseSolidusAtomEscape = function(state) {
3942 var start = state.pos;
3943 if (state.eat(0x5C /* \ */)) {
3944 if (this.regexp_eatAtomEscape(state)) {
3945 return true
3946 }
3947 state.pos = start;
3948 }
3949 return false
3950 };
3951 pp$8.regexp_eatUncapturingGroup = function(state) {
3952 var start = state.pos;
3953 if (state.eat(0x28 /* ( */)) {
3954 if (state.eat(0x3F /* ? */) && state.eat(0x3A /* : */)) {
3955 this.regexp_disjunction(state);
3956 if (state.eat(0x29 /* ) */)) {
3957 return true
3958 }
3959 state.raise("Unterminated group");
3960 }
3961 state.pos = start;
3962 }
3963 return false
3964 };
3965 pp$8.regexp_eatCapturingGroup = function(state) {
3966 if (state.eat(0x28 /* ( */)) {
3967 if (this.options.ecmaVersion >= 9) {
3968 this.regexp_groupSpecifier(state);
3969 } else if (state.current() === 0x3F /* ? */) {
3970 state.raise("Invalid group");
3971 }
3972 this.regexp_disjunction(state);
3973 if (state.eat(0x29 /* ) */)) {
3974 state.numCapturingParens += 1;
3975 return true
3976 }
3977 state.raise("Unterminated group");
3978 }
3979 return false
3980 };
3981
3982 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom
3983 pp$8.regexp_eatExtendedAtom = function(state) {
3984 return (
3985 state.eat(0x2E /* . */) ||
3986 this.regexp_eatReverseSolidusAtomEscape(state) ||
3987 this.regexp_eatCharacterClass(state) ||
3988 this.regexp_eatUncapturingGroup(state) ||
3989 this.regexp_eatCapturingGroup(state) ||
3990 this.regexp_eatInvalidBracedQuantifier(state) ||
3991 this.regexp_eatExtendedPatternCharacter(state)
3992 )
3993 };
3994
3995 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-InvalidBracedQuantifier
3996 pp$8.regexp_eatInvalidBracedQuantifier = function(state) {
3997 if (this.regexp_eatBracedQuantifier(state, true)) {
3998 state.raise("Nothing to repeat");
3999 }
4000 return false
4001 };
4002
4003 // https://www.ecma-international.org/ecma-262/8.0/#prod-SyntaxCharacter
4004 pp$8.regexp_eatSyntaxCharacter = function(state) {
4005 var ch = state.current();
4006 if (isSyntaxCharacter(ch)) {
4007 state.lastIntValue = ch;
4008 state.advance();
4009 return true
4010 }
4011 return false
4012 };
4013 function isSyntaxCharacter(ch) {
4014 return (
4015 ch === 0x24 /* $ */ ||
4016 ch >= 0x28 /* ( */ && ch <= 0x2B /* + */ ||
4017 ch === 0x2E /* . */ ||
4018 ch === 0x3F /* ? */ ||
4019 ch >= 0x5B /* [ */ && ch <= 0x5E /* ^ */ ||
4020 ch >= 0x7B /* { */ && ch <= 0x7D /* } */
4021 )
4022 }
4023
4024 // https://www.ecma-international.org/ecma-262/8.0/#prod-PatternCharacter
4025 // But eat eager.
4026 pp$8.regexp_eatPatternCharacters = function(state) {
4027 var start = state.pos;
4028 var ch = 0;
4029 while ((ch = state.current()) !== -1 && !isSyntaxCharacter(ch)) {
4030 state.advance();
4031 }
4032 return state.pos !== start
4033 };
4034
4035 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedPatternCharacter
4036 pp$8.regexp_eatExtendedPatternCharacter = function(state) {
4037 var ch = state.current();
4038 if (
4039 ch !== -1 &&
4040 ch !== 0x24 /* $ */ &&
4041 !(ch >= 0x28 /* ( */ && ch <= 0x2B /* + */) &&
4042 ch !== 0x2E /* . */ &&
4043 ch !== 0x3F /* ? */ &&
4044 ch !== 0x5B /* [ */ &&
4045 ch !== 0x5E /* ^ */ &&
4046 ch !== 0x7C /* | */
4047 ) {
4048 state.advance();
4049 return true
4050 }
4051 return false
4052 };
4053
4054 // GroupSpecifier ::
4055 // [empty]
4056 // `?` GroupName
4057 pp$8.regexp_groupSpecifier = function(state) {
4058 if (state.eat(0x3F /* ? */)) {
4059 if (this.regexp_eatGroupName(state)) {
4060 if (state.groupNames.indexOf(state.lastStringValue) !== -1) {
4061 state.raise("Duplicate capture group name");
4062 }
4063 state.groupNames.push(state.lastStringValue);
4064 return
4065 }
4066 state.raise("Invalid group");
4067 }
4068 };
4069
4070 // GroupName ::
4071 // `<` RegExpIdentifierName `>`
4072 // Note: this updates `state.lastStringValue` property with the eaten name.
4073 pp$8.regexp_eatGroupName = function(state) {
4074 state.lastStringValue = "";
4075 if (state.eat(0x3C /* < */)) {
4076 if (this.regexp_eatRegExpIdentifierName(state) && state.eat(0x3E /* > */)) {
4077 return true
4078 }
4079 state.raise("Invalid capture group name");
4080 }
4081 return false
4082 };
4083
4084 // RegExpIdentifierName ::
4085 // RegExpIdentifierStart
4086 // RegExpIdentifierName RegExpIdentifierPart
4087 // Note: this updates `state.lastStringValue` property with the eaten name.
4088 pp$8.regexp_eatRegExpIdentifierName = function(state) {
4089 state.lastStringValue = "";
4090 if (this.regexp_eatRegExpIdentifierStart(state)) {
4091 state.lastStringValue += codePointToString(state.lastIntValue);
4092 while (this.regexp_eatRegExpIdentifierPart(state)) {
4093 state.lastStringValue += codePointToString(state.lastIntValue);
4094 }
4095 return true
4096 }
4097 return false
4098 };
4099
4100 // RegExpIdentifierStart ::
4101 // UnicodeIDStart
4102 // `$`
4103 // `_`
4104 // `\` RegExpUnicodeEscapeSequence[+U]
4105 pp$8.regexp_eatRegExpIdentifierStart = function(state) {
4106 var start = state.pos;
4107 var forceU = this.options.ecmaVersion >= 11;
4108 var ch = state.current(forceU);
4109 state.advance(forceU);
4110
4111 if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
4112 ch = state.lastIntValue;
4113 }
4114 if (isRegExpIdentifierStart(ch)) {
4115 state.lastIntValue = ch;
4116 return true
4117 }
4118
4119 state.pos = start;
4120 return false
4121 };
4122 function isRegExpIdentifierStart(ch) {
4123 return isIdentifierStart(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */
4124 }
4125
4126 // RegExpIdentifierPart ::
4127 // UnicodeIDContinue
4128 // `$`
4129 // `_`
4130 // `\` RegExpUnicodeEscapeSequence[+U]
4131 // <ZWNJ>
4132 // <ZWJ>
4133 pp$8.regexp_eatRegExpIdentifierPart = function(state) {
4134 var start = state.pos;
4135 var forceU = this.options.ecmaVersion >= 11;
4136 var ch = state.current(forceU);
4137 state.advance(forceU);
4138
4139 if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
4140 ch = state.lastIntValue;
4141 }
4142 if (isRegExpIdentifierPart(ch)) {
4143 state.lastIntValue = ch;
4144 return true
4145 }
4146
4147 state.pos = start;
4148 return false
4149 };
4150 function isRegExpIdentifierPart(ch) {
4151 return isIdentifierChar(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */ || ch === 0x200C /* <ZWNJ> */ || ch === 0x200D /* <ZWJ> */
4152 }
4153
4154 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-AtomEscape
4155 pp$8.regexp_eatAtomEscape = function(state) {
4156 if (
4157 this.regexp_eatBackReference(state) ||
4158 this.regexp_eatCharacterClassEscape(state) ||
4159 this.regexp_eatCharacterEscape(state) ||
4160 (state.switchN && this.regexp_eatKGroupName(state))
4161 ) {
4162 return true
4163 }
4164 if (state.switchU) {
4165 // Make the same message as V8.
4166 if (state.current() === 0x63 /* c */) {
4167 state.raise("Invalid unicode escape");
4168 }
4169 state.raise("Invalid escape");
4170 }
4171 return false
4172 };
4173 pp$8.regexp_eatBackReference = function(state) {
4174 var start = state.pos;
4175 if (this.regexp_eatDecimalEscape(state)) {
4176 var n = state.lastIntValue;
4177 if (state.switchU) {
4178 // For SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-atomescape
4179 if (n > state.maxBackReference) {
4180 state.maxBackReference = n;
4181 }
4182 return true
4183 }
4184 if (n <= state.numCapturingParens) {
4185 return true
4186 }
4187 state.pos = start;
4188 }
4189 return false
4190 };
4191 pp$8.regexp_eatKGroupName = function(state) {
4192 if (state.eat(0x6B /* k */)) {
4193 if (this.regexp_eatGroupName(state)) {
4194 state.backReferenceNames.push(state.lastStringValue);
4195 return true
4196 }
4197 state.raise("Invalid named reference");
4198 }
4199 return false
4200 };
4201
4202 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-CharacterEscape
4203 pp$8.regexp_eatCharacterEscape = function(state) {
4204 return (
4205 this.regexp_eatControlEscape(state) ||
4206 this.regexp_eatCControlLetter(state) ||
4207 this.regexp_eatZero(state) ||
4208 this.regexp_eatHexEscapeSequence(state) ||
4209 this.regexp_eatRegExpUnicodeEscapeSequence(state, false) ||
4210 (!state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state)) ||
4211 this.regexp_eatIdentityEscape(state)
4212 )
4213 };
4214 pp$8.regexp_eatCControlLetter = function(state) {
4215 var start = state.pos;
4216 if (state.eat(0x63 /* c */)) {
4217 if (this.regexp_eatControlLetter(state)) {
4218 return true
4219 }
4220 state.pos = start;
4221 }
4222 return false
4223 };
4224 pp$8.regexp_eatZero = function(state) {
4225 if (state.current() === 0x30 /* 0 */ && !isDecimalDigit(state.lookahead())) {
4226 state.lastIntValue = 0;
4227 state.advance();
4228 return true
4229 }
4230 return false
4231 };
4232
4233 // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlEscape
4234 pp$8.regexp_eatControlEscape = function(state) {
4235 var ch = state.current();
4236 if (ch === 0x74 /* t */) {
4237 state.lastIntValue = 0x09; /* \t */
4238 state.advance();
4239 return true
4240 }
4241 if (ch === 0x6E /* n */) {
4242 state.lastIntValue = 0x0A; /* \n */
4243 state.advance();
4244 return true
4245 }
4246 if (ch === 0x76 /* v */) {
4247 state.lastIntValue = 0x0B; /* \v */
4248 state.advance();
4249 return true
4250 }
4251 if (ch === 0x66 /* f */) {
4252 state.lastIntValue = 0x0C; /* \f */
4253 state.advance();
4254 return true
4255 }
4256 if (ch === 0x72 /* r */) {
4257 state.lastIntValue = 0x0D; /* \r */
4258 state.advance();
4259 return true
4260 }
4261 return false
4262 };
4263
4264 // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlLetter
4265 pp$8.regexp_eatControlLetter = function(state) {
4266 var ch = state.current();
4267 if (isControlLetter(ch)) {
4268 state.lastIntValue = ch % 0x20;
4269 state.advance();
4270 return true
4271 }
4272 return false
4273 };
4274 function isControlLetter(ch) {
4275 return (
4276 (ch >= 0x41 /* A */ && ch <= 0x5A /* Z */) ||
4277 (ch >= 0x61 /* a */ && ch <= 0x7A /* z */)
4278 )
4279 }
4280
4281 // https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence
4282 pp$8.regexp_eatRegExpUnicodeEscapeSequence = function(state, forceU) {
4283 if ( forceU === void 0 ) forceU = false;
4284
4285 var start = state.pos;
4286 var switchU = forceU || state.switchU;
4287
4288 if (state.eat(0x75 /* u */)) {
4289 if (this.regexp_eatFixedHexDigits(state, 4)) {
4290 var lead = state.lastIntValue;
4291 if (switchU && lead >= 0xD800 && lead <= 0xDBFF) {
4292 var leadSurrogateEnd = state.pos;
4293 if (state.eat(0x5C /* \ */) && state.eat(0x75 /* u */) && this.regexp_eatFixedHexDigits(state, 4)) {
4294 var trail = state.lastIntValue;
4295 if (trail >= 0xDC00 && trail <= 0xDFFF) {
4296 state.lastIntValue = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
4297 return true
4298 }
4299 }
4300 state.pos = leadSurrogateEnd;
4301 state.lastIntValue = lead;
4302 }
4303 return true
4304 }
4305 if (
4306 switchU &&
4307 state.eat(0x7B /* { */) &&
4308 this.regexp_eatHexDigits(state) &&
4309 state.eat(0x7D /* } */) &&
4310 isValidUnicode(state.lastIntValue)
4311 ) {
4312 return true
4313 }
4314 if (switchU) {
4315 state.raise("Invalid unicode escape");
4316 }
4317 state.pos = start;
4318 }
4319
4320 return false
4321 };
4322 function isValidUnicode(ch) {
4323 return ch >= 0 && ch <= 0x10FFFF
4324 }
4325
4326 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-IdentityEscape
4327 pp$8.regexp_eatIdentityEscape = function(state) {
4328 if (state.switchU) {
4329 if (this.regexp_eatSyntaxCharacter(state)) {
4330 return true
4331 }
4332 if (state.eat(0x2F /* / */)) {
4333 state.lastIntValue = 0x2F; /* / */
4334 return true
4335 }
4336 return false
4337 }
4338
4339 var ch = state.current();
4340 if (ch !== 0x63 /* c */ && (!state.switchN || ch !== 0x6B /* k */)) {
4341 state.lastIntValue = ch;
4342 state.advance();
4343 return true
4344 }
4345
4346 return false
4347 };
4348
4349 // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalEscape
4350 pp$8.regexp_eatDecimalEscape = function(state) {
4351 state.lastIntValue = 0;
4352 var ch = state.current();
4353 if (ch >= 0x31 /* 1 */ && ch <= 0x39 /* 9 */) {
4354 do {
4355 state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */);
4356 state.advance();
4357 } while ((ch = state.current()) >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */)
4358 return true
4359 }
4360 return false
4361 };
4362
4363 // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClassEscape
4364 pp$8.regexp_eatCharacterClassEscape = function(state) {
4365 var ch = state.current();
4366
4367 if (isCharacterClassEscape(ch)) {
4368 state.lastIntValue = -1;
4369 state.advance();
4370 return true
4371 }
4372
4373 if (
4374 state.switchU &&
4375 this.options.ecmaVersion >= 9 &&
4376 (ch === 0x50 /* P */ || ch === 0x70 /* p */)
4377 ) {
4378 state.lastIntValue = -1;
4379 state.advance();
4380 if (
4381 state.eat(0x7B /* { */) &&
4382 this.regexp_eatUnicodePropertyValueExpression(state) &&
4383 state.eat(0x7D /* } */)
4384 ) {
4385 return true
4386 }
4387 state.raise("Invalid property name");
4388 }
4389
4390 return false
4391 };
4392 function isCharacterClassEscape(ch) {
4393 return (
4394 ch === 0x64 /* d */ ||
4395 ch === 0x44 /* D */ ||
4396 ch === 0x73 /* s */ ||
4397 ch === 0x53 /* S */ ||
4398 ch === 0x77 /* w */ ||
4399 ch === 0x57 /* W */
4400 )
4401 }
4402
4403 // UnicodePropertyValueExpression ::
4404 // UnicodePropertyName `=` UnicodePropertyValue
4405 // LoneUnicodePropertyNameOrValue
4406 pp$8.regexp_eatUnicodePropertyValueExpression = function(state) {
4407 var start = state.pos;
4408
4409 // UnicodePropertyName `=` UnicodePropertyValue
4410 if (this.regexp_eatUnicodePropertyName(state) && state.eat(0x3D /* = */)) {
4411 var name = state.lastStringValue;
4412 if (this.regexp_eatUnicodePropertyValue(state)) {
4413 var value = state.lastStringValue;
4414 this.regexp_validateUnicodePropertyNameAndValue(state, name, value);
4415 return true
4416 }
4417 }
4418 state.pos = start;
4419
4420 // LoneUnicodePropertyNameOrValue
4421 if (this.regexp_eatLoneUnicodePropertyNameOrValue(state)) {
4422 var nameOrValue = state.lastStringValue;
4423 this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue);
4424 return true
4425 }
4426 return false
4427 };
4428 pp$8.regexp_validateUnicodePropertyNameAndValue = function(state, name, value) {
4429 if (!has(state.unicodeProperties.nonBinary, name))
4430 { state.raise("Invalid property name"); }
4431 if (!state.unicodeProperties.nonBinary[name].test(value))
4432 { state.raise("Invalid property value"); }
4433 };
4434 pp$8.regexp_validateUnicodePropertyNameOrValue = function(state, nameOrValue) {
4435 if (!state.unicodeProperties.binary.test(nameOrValue))
4436 { state.raise("Invalid property name"); }
4437 };
4438
4439 // UnicodePropertyName ::
4440 // UnicodePropertyNameCharacters
4441 pp$8.regexp_eatUnicodePropertyName = function(state) {
4442 var ch = 0;
4443 state.lastStringValue = "";
4444 while (isUnicodePropertyNameCharacter(ch = state.current())) {
4445 state.lastStringValue += codePointToString(ch);
4446 state.advance();
4447 }
4448 return state.lastStringValue !== ""
4449 };
4450 function isUnicodePropertyNameCharacter(ch) {
4451 return isControlLetter(ch) || ch === 0x5F /* _ */
4452 }
4453
4454 // UnicodePropertyValue ::
4455 // UnicodePropertyValueCharacters
4456 pp$8.regexp_eatUnicodePropertyValue = function(state) {
4457 var ch = 0;
4458 state.lastStringValue = "";
4459 while (isUnicodePropertyValueCharacter(ch = state.current())) {
4460 state.lastStringValue += codePointToString(ch);
4461 state.advance();
4462 }
4463 return state.lastStringValue !== ""
4464 };
4465 function isUnicodePropertyValueCharacter(ch) {
4466 return isUnicodePropertyNameCharacter(ch) || isDecimalDigit(ch)
4467 }
4468
4469 // LoneUnicodePropertyNameOrValue ::
4470 // UnicodePropertyValueCharacters
4471 pp$8.regexp_eatLoneUnicodePropertyNameOrValue = function(state) {
4472 return this.regexp_eatUnicodePropertyValue(state)
4473 };
4474
4475 // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClass
4476 pp$8.regexp_eatCharacterClass = function(state) {
4477 if (state.eat(0x5B /* [ */)) {
4478 state.eat(0x5E /* ^ */);
4479 this.regexp_classRanges(state);
4480 if (state.eat(0x5D /* ] */)) {
4481 return true
4482 }
4483 // Unreachable since it threw "unterminated regular expression" error before.
4484 state.raise("Unterminated character class");
4485 }
4486 return false
4487 };
4488
4489 // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassRanges
4490 // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRanges
4491 // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRangesNoDash
4492 pp$8.regexp_classRanges = function(state) {
4493 while (this.regexp_eatClassAtom(state)) {
4494 var left = state.lastIntValue;
4495 if (state.eat(0x2D /* - */) && this.regexp_eatClassAtom(state)) {
4496 var right = state.lastIntValue;
4497 if (state.switchU && (left === -1 || right === -1)) {
4498 state.raise("Invalid character class");
4499 }
4500 if (left !== -1 && right !== -1 && left > right) {
4501 state.raise("Range out of order in character class");
4502 }
4503 }
4504 }
4505 };
4506
4507 // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtom
4508 // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtomNoDash
4509 pp$8.regexp_eatClassAtom = function(state) {
4510 var start = state.pos;
4511
4512 if (state.eat(0x5C /* \ */)) {
4513 if (this.regexp_eatClassEscape(state)) {
4514 return true
4515 }
4516 if (state.switchU) {
4517 // Make the same message as V8.
4518 var ch$1 = state.current();
4519 if (ch$1 === 0x63 /* c */ || isOctalDigit(ch$1)) {
4520 state.raise("Invalid class escape");
4521 }
4522 state.raise("Invalid escape");
4523 }
4524 state.pos = start;
4525 }
4526
4527 var ch = state.current();
4528 if (ch !== 0x5D /* ] */) {
4529 state.lastIntValue = ch;
4530 state.advance();
4531 return true
4532 }
4533
4534 return false
4535 };
4536
4537 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassEscape
4538 pp$8.regexp_eatClassEscape = function(state) {
4539 var start = state.pos;
4540
4541 if (state.eat(0x62 /* b */)) {
4542 state.lastIntValue = 0x08; /* <BS> */
4543 return true
4544 }
4545
4546 if (state.switchU && state.eat(0x2D /* - */)) {
4547 state.lastIntValue = 0x2D; /* - */
4548 return true
4549 }
4550
4551 if (!state.switchU && state.eat(0x63 /* c */)) {
4552 if (this.regexp_eatClassControlLetter(state)) {
4553 return true
4554 }
4555 state.pos = start;
4556 }
4557
4558 return (
4559 this.regexp_eatCharacterClassEscape(state) ||
4560 this.regexp_eatCharacterEscape(state)
4561 )
4562 };
4563
4564 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassControlLetter
4565 pp$8.regexp_eatClassControlLetter = function(state) {
4566 var ch = state.current();
4567 if (isDecimalDigit(ch) || ch === 0x5F /* _ */) {
4568 state.lastIntValue = ch % 0x20;
4569 state.advance();
4570 return true
4571 }
4572 return false
4573 };
4574
4575 // https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
4576 pp$8.regexp_eatHexEscapeSequence = function(state) {
4577 var start = state.pos;
4578 if (state.eat(0x78 /* x */)) {
4579 if (this.regexp_eatFixedHexDigits(state, 2)) {
4580 return true
4581 }
4582 if (state.switchU) {
4583 state.raise("Invalid escape");
4584 }
4585 state.pos = start;
4586 }
4587 return false
4588 };
4589
4590 // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalDigits
4591 pp$8.regexp_eatDecimalDigits = function(state) {
4592 var start = state.pos;
4593 var ch = 0;
4594 state.lastIntValue = 0;
4595 while (isDecimalDigit(ch = state.current())) {
4596 state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */);
4597 state.advance();
4598 }
4599 return state.pos !== start
4600 };
4601 function isDecimalDigit(ch) {
4602 return ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */
4603 }
4604
4605 // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigits
4606 pp$8.regexp_eatHexDigits = function(state) {
4607 var start = state.pos;
4608 var ch = 0;
4609 state.lastIntValue = 0;
4610 while (isHexDigit(ch = state.current())) {
4611 state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
4612 state.advance();
4613 }
4614 return state.pos !== start
4615 };
4616 function isHexDigit(ch) {
4617 return (
4618 (ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */) ||
4619 (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) ||
4620 (ch >= 0x61 /* a */ && ch <= 0x66 /* f */)
4621 )
4622 }
4623 function hexToInt(ch) {
4624 if (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) {
4625 return 10 + (ch - 0x41 /* A */)
4626 }
4627 if (ch >= 0x61 /* a */ && ch <= 0x66 /* f */) {
4628 return 10 + (ch - 0x61 /* a */)
4629 }
4630 return ch - 0x30 /* 0 */
4631 }
4632
4633 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-LegacyOctalEscapeSequence
4634 // Allows only 0-377(octal) i.e. 0-255(decimal).
4635 pp$8.regexp_eatLegacyOctalEscapeSequence = function(state) {
4636 if (this.regexp_eatOctalDigit(state)) {
4637 var n1 = state.lastIntValue;
4638 if (this.regexp_eatOctalDigit(state)) {
4639 var n2 = state.lastIntValue;
4640 if (n1 <= 3 && this.regexp_eatOctalDigit(state)) {
4641 state.lastIntValue = n1 * 64 + n2 * 8 + state.lastIntValue;
4642 } else {
4643 state.lastIntValue = n1 * 8 + n2;
4644 }
4645 } else {
4646 state.lastIntValue = n1;
4647 }
4648 return true
4649 }
4650 return false
4651 };
4652
4653 // https://www.ecma-international.org/ecma-262/8.0/#prod-OctalDigit
4654 pp$8.regexp_eatOctalDigit = function(state) {
4655 var ch = state.current();
4656 if (isOctalDigit(ch)) {
4657 state.lastIntValue = ch - 0x30; /* 0 */
4658 state.advance();
4659 return true
4660 }
4661 state.lastIntValue = 0;
4662 return false
4663 };
4664 function isOctalDigit(ch) {
4665 return ch >= 0x30 /* 0 */ && ch <= 0x37 /* 7 */
4666 }
4667
4668 // https://www.ecma-international.org/ecma-262/8.0/#prod-Hex4Digits
4669 // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigit
4670 // And HexDigit HexDigit in https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
4671 pp$8.regexp_eatFixedHexDigits = function(state, length) {
4672 var start = state.pos;
4673 state.lastIntValue = 0;
4674 for (var i = 0; i < length; ++i) {
4675 var ch = state.current();
4676 if (!isHexDigit(ch)) {
4677 state.pos = start;
4678 return false
4679 }
4680 state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
4681 state.advance();
4682 }
4683 return true
4684 };
4685
4686 // Object type used to represent tokens. Note that normally, tokens
4687 // simply exist as properties on the parser object. This is only
4688 // used for the onToken callback and the external tokenizer.
4689
4690 var Token = function Token(p) {
4691 this.type = p.type;
4692 this.value = p.value;
4693 this.start = p.start;
4694 this.end = p.end;
4695 if (p.options.locations)
4696 { this.loc = new SourceLocation(p, p.startLoc, p.endLoc); }
4697 if (p.options.ranges)
4698 { this.range = [p.start, p.end]; }
4699 };
4700
4701 // ## Tokenizer
4702
4703 var pp$9 = Parser.prototype;
4704
4705 // Move to the next token
4706
4707 pp$9.next = function(ignoreEscapeSequenceInKeyword) {
4708 if (!ignoreEscapeSequenceInKeyword && this.type.keyword && this.containsEsc)
4709 { this.raiseRecoverable(this.start, "Escape sequence in keyword " + this.type.keyword); }
4710 if (this.options.onToken)
4711 { this.options.onToken(new Token(this)); }
4712
4713 this.lastTokEnd = this.end;
4714 this.lastTokStart = this.start;
4715 this.lastTokEndLoc = this.endLoc;
4716 this.lastTokStartLoc = this.startLoc;
4717 this.nextToken();
4718 };
4719
4720 pp$9.getToken = function() {
4721 this.next();
4722 return new Token(this)
4723 };
4724
4725 // If we're in an ES6 environment, make parsers iterable
4726 if (typeof Symbol !== "undefined")
4727 { pp$9[Symbol.iterator] = function() {
4728 var this$1 = this;
4729
4730 return {
4731 next: function () {
4732 var token = this$1.getToken();
4733 return {
4734 done: token.type === types.eof,
4735 value: token
4736 }
4737 }
4738 }
4739 }; }
4740
4741 // Toggle strict mode. Re-reads the next number or string to please
4742 // pedantic tests (`"use strict"; 010;` should fail).
4743
4744 // Read a single token, updating the parser object's token-related
4745 // properties.
4746
4747 pp$9.nextToken = function() {
4748 var curContext = this.curContext();
4749 if (!curContext || !curContext.preserveSpace) { this.skipSpace(); }
4750
4751 this.start = this.pos;
4752 if (this.options.locations) { this.startLoc = this.curPosition(); }
4753 if (this.pos >= this.input.length) { return this.finishToken(types.eof) }
4754
4755 if (curContext.override) { return curContext.override(this) }
4756 else { this.readToken(this.fullCharCodeAtPos()); }
4757 };
4758
4759 pp$9.readToken = function(code) {
4760 // Identifier or keyword. '\uXXXX' sequences are allowed in
4761 // identifiers, so '\' also dispatches to that.
4762 if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */)
4763 { return this.readWord() }
4764
4765 return this.getTokenFromCode(code)
4766 };
4767
4768 pp$9.fullCharCodeAtPos = function() {
4769 var code = this.input.charCodeAt(this.pos);
4770 if (code <= 0xd7ff || code >= 0xdc00) { return code }
4771 var next = this.input.charCodeAt(this.pos + 1);
4772 return next <= 0xdbff || next >= 0xe000 ? code : (code << 10) + next - 0x35fdc00
4773 };
4774
4775 pp$9.skipBlockComment = function() {
4776 var startLoc = this.options.onComment && this.curPosition();
4777 var start = this.pos, end = this.input.indexOf("*/", this.pos += 2);
4778 if (end === -1) { this.raise(this.pos - 2, "Unterminated comment"); }
4779 this.pos = end + 2;
4780 if (this.options.locations) {
4781 lineBreakG.lastIndex = start;
4782 var match;
4783 while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) {
4784 ++this.curLine;
4785 this.lineStart = match.index + match[0].length;
4786 }
4787 }
4788 if (this.options.onComment)
4789 { this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos,
4790 startLoc, this.curPosition()); }
4791 };
4792
4793 pp$9.skipLineComment = function(startSkip) {
4794 var start = this.pos;
4795 var startLoc = this.options.onComment && this.curPosition();
4796 var ch = this.input.charCodeAt(this.pos += startSkip);
4797 while (this.pos < this.input.length && !isNewLine(ch)) {
4798 ch = this.input.charCodeAt(++this.pos);
4799 }
4800 if (this.options.onComment)
4801 { this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos,
4802 startLoc, this.curPosition()); }
4803 };
4804
4805 // Called at the start of the parse and after every token. Skips
4806 // whitespace and comments, and.
4807
4808 pp$9.skipSpace = function() {
4809 loop: while (this.pos < this.input.length) {
4810 var ch = this.input.charCodeAt(this.pos);
4811 switch (ch) {
4812 case 32: case 160: // ' '
4813 ++this.pos;
4814 break
4815 case 13:
4816 if (this.input.charCodeAt(this.pos + 1) === 10) {
4817 ++this.pos;
4818 }
4819 case 10: case 8232: case 8233:
4820 ++this.pos;
4821 if (this.options.locations) {
4822 ++this.curLine;
4823 this.lineStart = this.pos;
4824 }
4825 break
4826 case 47: // '/'
4827 switch (this.input.charCodeAt(this.pos + 1)) {
4828 case 42: // '*'
4829 this.skipBlockComment();
4830 break
4831 case 47:
4832 this.skipLineComment(2);
4833 break
4834 default:
4835 break loop
4836 }
4837 break
4838 default:
4839 if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {
4840 ++this.pos;
4841 } else {
4842 break loop
4843 }
4844 }
4845 }
4846 };
4847
4848 // Called at the end of every token. Sets `end`, `val`, and
4849 // maintains `context` and `exprAllowed`, and skips the space after
4850 // the token, so that the next one's `start` will point at the
4851 // right position.
4852
4853 pp$9.finishToken = function(type, val) {
4854 this.end = this.pos;
4855 if (this.options.locations) { this.endLoc = this.curPosition(); }
4856 var prevType = this.type;
4857 this.type = type;
4858 this.value = val;
4859
4860 this.updateContext(prevType);
4861 };
4862
4863 // ### Token reading
4864
4865 // This is the function that is called to fetch the next token. It
4866 // is somewhat obscure, because it works in character codes rather
4867 // than characters, and because operator parsing has been inlined
4868 // into it.
4869 //
4870 // All in the name of speed.
4871 //
4872 pp$9.readToken_dot = function() {
4873 var next = this.input.charCodeAt(this.pos + 1);
4874 if (next >= 48 && next <= 57) { return this.readNumber(true) }
4875 var next2 = this.input.charCodeAt(this.pos + 2);
4876 if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.'
4877 this.pos += 3;
4878 return this.finishToken(types.ellipsis)
4879 } else {
4880 ++this.pos;
4881 return this.finishToken(types.dot)
4882 }
4883 };
4884
4885 pp$9.readToken_slash = function() { // '/'
4886 var next = this.input.charCodeAt(this.pos + 1);
4887 if (this.exprAllowed) { ++this.pos; return this.readRegexp() }
4888 if (next === 61) { return this.finishOp(types.assign, 2) }
4889 return this.finishOp(types.slash, 1)
4890 };
4891
4892 pp$9.readToken_mult_modulo_exp = function(code) { // '%*'
4893 var next = this.input.charCodeAt(this.pos + 1);
4894 var size = 1;
4895 var tokentype = code === 42 ? types.star : types.modulo;
4896
4897 // exponentiation operator ** and **=
4898 if (this.options.ecmaVersion >= 7 && code === 42 && next === 42) {
4899 ++size;
4900 tokentype = types.starstar;
4901 next = this.input.charCodeAt(this.pos + 2);
4902 }
4903
4904 if (next === 61) { return this.finishOp(types.assign, size + 1) }
4905 return this.finishOp(tokentype, size)
4906 };
4907
4908 pp$9.readToken_pipe_amp = function(code) { // '|&'
4909 var next = this.input.charCodeAt(this.pos + 1);
4910 if (next === code) {
4911 if (this.options.ecmaVersion >= 12) {
4912 var next2 = this.input.charCodeAt(this.pos + 2);
4913 if (next2 === 61) { return this.finishOp(types.assign, 3) }
4914 }
4915 return this.finishOp(code === 124 ? types.logicalOR : types.logicalAND, 2)
4916 }
4917 if (next === 61) { return this.finishOp(types.assign, 2) }
4918 return this.finishOp(code === 124 ? types.bitwiseOR : types.bitwiseAND, 1)
4919 };
4920
4921 pp$9.readToken_caret = function() { // '^'
4922 var next = this.input.charCodeAt(this.pos + 1);
4923 if (next === 61) { return this.finishOp(types.assign, 2) }
4924 return this.finishOp(types.bitwiseXOR, 1)
4925 };
4926
4927 pp$9.readToken_plus_min = function(code) { // '+-'
4928 var next = this.input.charCodeAt(this.pos + 1);
4929 if (next === code) {
4930 if (next === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 &&
4931 (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) {
4932 // A `-->` line comment
4933 this.skipLineComment(3);
4934 this.skipSpace();
4935 return this.nextToken()
4936 }
4937 return this.finishOp(types.incDec, 2)
4938 }
4939 if (next === 61) { return this.finishOp(types.assign, 2) }
4940 return this.finishOp(types.plusMin, 1)
4941 };
4942
4943 pp$9.readToken_lt_gt = function(code) { // '<>'
4944 var next = this.input.charCodeAt(this.pos + 1);
4945 var size = 1;
4946 if (next === code) {
4947 size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;
4948 if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types.assign, size + 1) }
4949 return this.finishOp(types.bitShift, size)
4950 }
4951 if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 &&
4952 this.input.charCodeAt(this.pos + 3) === 45) {
4953 // `<!--`, an XML-style comment that should be interpreted as a line comment
4954 this.skipLineComment(4);
4955 this.skipSpace();
4956 return this.nextToken()
4957 }
4958 if (next === 61) { size = 2; }
4959 return this.finishOp(types.relational, size)
4960 };
4961
4962 pp$9.readToken_eq_excl = function(code) { // '=!'
4963 var next = this.input.charCodeAt(this.pos + 1);
4964 if (next === 61) { return this.finishOp(types.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2) }
4965 if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) { // '=>'
4966 this.pos += 2;
4967 return this.finishToken(types.arrow)
4968 }
4969 return this.finishOp(code === 61 ? types.eq : types.prefix, 1)
4970 };
4971
4972 pp$9.readToken_question = function() { // '?'
4973 var ecmaVersion = this.options.ecmaVersion;
4974 if (ecmaVersion >= 11) {
4975 var next = this.input.charCodeAt(this.pos + 1);
4976 if (next === 46) {
4977 var next2 = this.input.charCodeAt(this.pos + 2);
4978 if (next2 < 48 || next2 > 57) { return this.finishOp(types.questionDot, 2) }
4979 }
4980 if (next === 63) {
4981 if (ecmaVersion >= 12) {
4982 var next2$1 = this.input.charCodeAt(this.pos + 2);
4983 if (next2$1 === 61) { return this.finishOp(types.assign, 3) }
4984 }
4985 return this.finishOp(types.coalesce, 2)
4986 }
4987 }
4988 return this.finishOp(types.question, 1)
4989 };
4990
4991 pp$9.readToken_numberSign = function() { // '#'
4992 var ecmaVersion = this.options.ecmaVersion;
4993 var code = 35; // '#'
4994 if (ecmaVersion >= 13) {
4995 ++this.pos;
4996 code = this.fullCharCodeAtPos();
4997 if (isIdentifierStart(code, true) || code === 92 /* '\' */) {
4998 return this.finishToken(types.privateId, this.readWord1())
4999 }
5000 }
5001
5002 this.raise(this.pos, "Unexpected character '" + codePointToString$1(code) + "'");
5003 };
5004
5005 pp$9.getTokenFromCode = function(code) {
5006 switch (code) {
5007 // The interpretation of a dot depends on whether it is followed
5008 // by a digit or another two dots.
5009 case 46: // '.'
5010 return this.readToken_dot()
5011
5012 // Punctuation tokens.
5013 case 40: ++this.pos; return this.finishToken(types.parenL)
5014 case 41: ++this.pos; return this.finishToken(types.parenR)
5015 case 59: ++this.pos; return this.finishToken(types.semi)
5016 case 44: ++this.pos; return this.finishToken(types.comma)
5017 case 91: ++this.pos; return this.finishToken(types.bracketL)
5018 case 93: ++this.pos; return this.finishToken(types.bracketR)
5019 case 123: ++this.pos; return this.finishToken(types.braceL)
5020 case 125: ++this.pos; return this.finishToken(types.braceR)
5021 case 58: ++this.pos; return this.finishToken(types.colon)
5022
5023 case 96: // '`'
5024 if (this.options.ecmaVersion < 6) { break }
5025 ++this.pos;
5026 return this.finishToken(types.backQuote)
5027
5028 case 48: // '0'
5029 var next = this.input.charCodeAt(this.pos + 1);
5030 if (next === 120 || next === 88) { return this.readRadixNumber(16) } // '0x', '0X' - hex number
5031 if (this.options.ecmaVersion >= 6) {
5032 if (next === 111 || next === 79) { return this.readRadixNumber(8) } // '0o', '0O' - octal number
5033 if (next === 98 || next === 66) { return this.readRadixNumber(2) } // '0b', '0B' - binary number
5034 }
5035
5036 // Anything else beginning with a digit is an integer, octal
5037 // number, or float.
5038 case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: // 1-9
5039 return this.readNumber(false)
5040
5041 // Quotes produce strings.
5042 case 34: case 39: // '"', "'"
5043 return this.readString(code)
5044
5045 // Operators are parsed inline in tiny state machines. '=' (61) is
5046 // often referred to. `finishOp` simply skips the amount of
5047 // characters it is given as second argument, and returns a token
5048 // of the type given by its first argument.
5049
5050 case 47: // '/'
5051 return this.readToken_slash()
5052
5053 case 37: case 42: // '%*'
5054 return this.readToken_mult_modulo_exp(code)
5055
5056 case 124: case 38: // '|&'
5057 return this.readToken_pipe_amp(code)
5058
5059 case 94: // '^'
5060 return this.readToken_caret()
5061
5062 case 43: case 45: // '+-'
5063 return this.readToken_plus_min(code)
5064
5065 case 60: case 62: // '<>'
5066 return this.readToken_lt_gt(code)
5067
5068 case 61: case 33: // '=!'
5069 return this.readToken_eq_excl(code)
5070
5071 case 63: // '?'
5072 return this.readToken_question()
5073
5074 case 126: // '~'
5075 return this.finishOp(types.prefix, 1)
5076
5077 case 35: // '#'
5078 return this.readToken_numberSign()
5079 }
5080
5081 this.raise(this.pos, "Unexpected character '" + codePointToString$1(code) + "'");
5082 };
5083
5084 pp$9.finishOp = function(type, size) {
5085 var str = this.input.slice(this.pos, this.pos + size);
5086 this.pos += size;
5087 return this.finishToken(type, str)
5088 };
5089
5090 pp$9.readRegexp = function() {
5091 var escaped, inClass, start = this.pos;
5092 for (;;) {
5093 if (this.pos >= this.input.length) { this.raise(start, "Unterminated regular expression"); }
5094 var ch = this.input.charAt(this.pos);
5095 if (lineBreak.test(ch)) { this.raise(start, "Unterminated regular expression"); }
5096 if (!escaped) {
5097 if (ch === "[") { inClass = true; }
5098 else if (ch === "]" && inClass) { inClass = false; }
5099 else if (ch === "/" && !inClass) { break }
5100 escaped = ch === "\\";
5101 } else { escaped = false; }
5102 ++this.pos;
5103 }
5104 var pattern = this.input.slice(start, this.pos);
5105 ++this.pos;
5106 var flagsStart = this.pos;
5107 var flags = this.readWord1();
5108 if (this.containsEsc) { this.unexpected(flagsStart); }
5109
5110 // Validate pattern
5111 var state = this.regexpState || (this.regexpState = new RegExpValidationState(this));
5112 state.reset(start, pattern, flags);
5113 this.validateRegExpFlags(state);
5114 this.validateRegExpPattern(state);
5115
5116 // Create Literal#value property value.
5117 var value = null;
5118 try {
5119 value = new RegExp(pattern, flags);
5120 } catch (e) {
5121 // ESTree requires null if it failed to instantiate RegExp object.
5122 // https://github.com/estree/estree/blob/a27003adf4fd7bfad44de9cef372a2eacd527b1c/es5.md#regexpliteral
5123 }
5124
5125 return this.finishToken(types.regexp, {pattern: pattern, flags: flags, value: value})
5126 };
5127
5128 // Read an integer in the given radix. Return null if zero digits
5129 // were read, the integer value otherwise. When `len` is given, this
5130 // will return `null` unless the integer has exactly `len` digits.
5131
5132 pp$9.readInt = function(radix, len, maybeLegacyOctalNumericLiteral) {
5133 // `len` is used for character escape sequences. In that case, disallow separators.
5134 var allowSeparators = this.options.ecmaVersion >= 12 && len === undefined;
5135
5136 // `maybeLegacyOctalNumericLiteral` is true if it doesn't have prefix (0x,0o,0b)
5137 // and isn't fraction part nor exponent part. In that case, if the first digit
5138 // is zero then disallow separators.
5139 var isLegacyOctalNumericLiteral = maybeLegacyOctalNumericLiteral && this.input.charCodeAt(this.pos) === 48;
5140
5141 var start = this.pos, total = 0, lastCode = 0;
5142 for (var i = 0, e = len == null ? Infinity : len; i < e; ++i, ++this.pos) {
5143 var code = this.input.charCodeAt(this.pos), val = (void 0);
5144
5145 if (allowSeparators && code === 95) {
5146 if (isLegacyOctalNumericLiteral) { this.raiseRecoverable(this.pos, "Numeric separator is not allowed in legacy octal numeric literals"); }
5147 if (lastCode === 95) { this.raiseRecoverable(this.pos, "Numeric separator must be exactly one underscore"); }
5148 if (i === 0) { this.raiseRecoverable(this.pos, "Numeric separator is not allowed at the first of digits"); }
5149 lastCode = code;
5150 continue
5151 }
5152
5153 if (code >= 97) { val = code - 97 + 10; } // a
5154 else if (code >= 65) { val = code - 65 + 10; } // A
5155 else if (code >= 48 && code <= 57) { val = code - 48; } // 0-9
5156 else { val = Infinity; }
5157 if (val >= radix) { break }
5158 lastCode = code;
5159 total = total * radix + val;
5160 }
5161
5162 if (allowSeparators && lastCode === 95) { this.raiseRecoverable(this.pos - 1, "Numeric separator is not allowed at the last of digits"); }
5163 if (this.pos === start || len != null && this.pos - start !== len) { return null }
5164
5165 return total
5166 };
5167
5168 function stringToNumber(str, isLegacyOctalNumericLiteral) {
5169 if (isLegacyOctalNumericLiteral) {
5170 return parseInt(str, 8)
5171 }
5172
5173 // `parseFloat(value)` stops parsing at the first numeric separator then returns a wrong value.
5174 return parseFloat(str.replace(/_/g, ""))
5175 }
5176
5177 function stringToBigInt(str) {
5178 if (typeof BigInt !== "function") {
5179 return null
5180 }
5181
5182 // `BigInt(value)` throws syntax error if the string contains numeric separators.
5183 return BigInt(str.replace(/_/g, ""))
5184 }
5185
5186 pp$9.readRadixNumber = function(radix) {
5187 var start = this.pos;
5188 this.pos += 2; // 0x
5189 var val = this.readInt(radix);
5190 if (val == null) { this.raise(this.start + 2, "Expected number in radix " + radix); }
5191 if (this.options.ecmaVersion >= 11 && this.input.charCodeAt(this.pos) === 110) {
5192 val = stringToBigInt(this.input.slice(start, this.pos));
5193 ++this.pos;
5194 } else if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
5195 return this.finishToken(types.num, val)
5196 };
5197
5198 // Read an integer, octal integer, or floating-point number.
5199
5200 pp$9.readNumber = function(startsWithDot) {
5201 var start = this.pos;
5202 if (!startsWithDot && this.readInt(10, undefined, true) === null) { this.raise(start, "Invalid number"); }
5203 var octal = this.pos - start >= 2 && this.input.charCodeAt(start) === 48;
5204 if (octal && this.strict) { this.raise(start, "Invalid number"); }
5205 var next = this.input.charCodeAt(this.pos);
5206 if (!octal && !startsWithDot && this.options.ecmaVersion >= 11 && next === 110) {
5207 var val$1 = stringToBigInt(this.input.slice(start, this.pos));
5208 ++this.pos;
5209 if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
5210 return this.finishToken(types.num, val$1)
5211 }
5212 if (octal && /[89]/.test(this.input.slice(start, this.pos))) { octal = false; }
5213 if (next === 46 && !octal) { // '.'
5214 ++this.pos;
5215 this.readInt(10);
5216 next = this.input.charCodeAt(this.pos);
5217 }
5218 if ((next === 69 || next === 101) && !octal) { // 'eE'
5219 next = this.input.charCodeAt(++this.pos);
5220 if (next === 43 || next === 45) { ++this.pos; } // '+-'
5221 if (this.readInt(10) === null) { this.raise(start, "Invalid number"); }
5222 }
5223 if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
5224
5225 var val = stringToNumber(this.input.slice(start, this.pos), octal);
5226 return this.finishToken(types.num, val)
5227 };
5228
5229 // Read a string value, interpreting backslash-escapes.
5230
5231 pp$9.readCodePoint = function() {
5232 var ch = this.input.charCodeAt(this.pos), code;
5233
5234 if (ch === 123) { // '{'
5235 if (this.options.ecmaVersion < 6) { this.unexpected(); }
5236 var codePos = ++this.pos;
5237 code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);
5238 ++this.pos;
5239 if (code > 0x10FFFF) { this.invalidStringToken(codePos, "Code point out of bounds"); }
5240 } else {
5241 code = this.readHexChar(4);
5242 }
5243 return code
5244 };
5245
5246 function codePointToString$1(code) {
5247 // UTF-16 Decoding
5248 if (code <= 0xFFFF) { return String.fromCharCode(code) }
5249 code -= 0x10000;
5250 return String.fromCharCode((code >> 10) + 0xD800, (code & 1023) + 0xDC00)
5251 }
5252
5253 pp$9.readString = function(quote) {
5254 var out = "", chunkStart = ++this.pos;
5255 for (;;) {
5256 if (this.pos >= this.input.length) { this.raise(this.start, "Unterminated string constant"); }
5257 var ch = this.input.charCodeAt(this.pos);
5258 if (ch === quote) { break }
5259 if (ch === 92) { // '\'
5260 out += this.input.slice(chunkStart, this.pos);
5261 out += this.readEscapedChar(false);
5262 chunkStart = this.pos;
5263 } else if (ch === 0x2028 || ch === 0x2029) {
5264 if (this.options.ecmaVersion < 10) { this.raise(this.start, "Unterminated string constant"); }
5265 ++this.pos;
5266 if (this.options.locations) {
5267 this.curLine++;
5268 this.lineStart = this.pos;
5269 }
5270 } else {
5271 if (isNewLine(ch)) { this.raise(this.start, "Unterminated string constant"); }
5272 ++this.pos;
5273 }
5274 }
5275 out += this.input.slice(chunkStart, this.pos++);
5276 return this.finishToken(types.string, out)
5277 };
5278
5279 // Reads template string tokens.
5280
5281 var INVALID_TEMPLATE_ESCAPE_ERROR = {};
5282
5283 pp$9.tryReadTemplateToken = function() {
5284 this.inTemplateElement = true;
5285 try {
5286 this.readTmplToken();
5287 } catch (err) {
5288 if (err === INVALID_TEMPLATE_ESCAPE_ERROR) {
5289 this.readInvalidTemplateToken();
5290 } else {
5291 throw err
5292 }
5293 }
5294
5295 this.inTemplateElement = false;
5296 };
5297
5298 pp$9.invalidStringToken = function(position, message) {
5299 if (this.inTemplateElement && this.options.ecmaVersion >= 9) {
5300 throw INVALID_TEMPLATE_ESCAPE_ERROR
5301 } else {
5302 this.raise(position, message);
5303 }
5304 };
5305
5306 pp$9.readTmplToken = function() {
5307 var out = "", chunkStart = this.pos;
5308 for (;;) {
5309 if (this.pos >= this.input.length) { this.raise(this.start, "Unterminated template"); }
5310 var ch = this.input.charCodeAt(this.pos);
5311 if (ch === 96 || ch === 36 && this.input.charCodeAt(this.pos + 1) === 123) { // '`', '${'
5312 if (this.pos === this.start && (this.type === types.template || this.type === types.invalidTemplate)) {
5313 if (ch === 36) {
5314 this.pos += 2;
5315 return this.finishToken(types.dollarBraceL)
5316 } else {
5317 ++this.pos;
5318 return this.finishToken(types.backQuote)
5319 }
5320 }
5321 out += this.input.slice(chunkStart, this.pos);
5322 return this.finishToken(types.template, out)
5323 }
5324 if (ch === 92) { // '\'
5325 out += this.input.slice(chunkStart, this.pos);
5326 out += this.readEscapedChar(true);
5327 chunkStart = this.pos;
5328 } else if (isNewLine(ch)) {
5329 out += this.input.slice(chunkStart, this.pos);
5330 ++this.pos;
5331 switch (ch) {
5332 case 13:
5333 if (this.input.charCodeAt(this.pos) === 10) { ++this.pos; }
5334 case 10:
5335 out += "\n";
5336 break
5337 default:
5338 out += String.fromCharCode(ch);
5339 break
5340 }
5341 if (this.options.locations) {
5342 ++this.curLine;
5343 this.lineStart = this.pos;
5344 }
5345 chunkStart = this.pos;
5346 } else {
5347 ++this.pos;
5348 }
5349 }
5350 };
5351
5352 // Reads a template token to search for the end, without validating any escape sequences
5353 pp$9.readInvalidTemplateToken = function() {
5354 for (; this.pos < this.input.length; this.pos++) {
5355 switch (this.input[this.pos]) {
5356 case "\\":
5357 ++this.pos;
5358 break
5359
5360 case "$":
5361 if (this.input[this.pos + 1] !== "{") {
5362 break
5363 }
5364 // falls through
5365
5366 case "`":
5367 return this.finishToken(types.invalidTemplate, this.input.slice(this.start, this.pos))
5368
5369 // no default
5370 }
5371 }
5372 this.raise(this.start, "Unterminated template");
5373 };
5374
5375 // Used to read escaped characters
5376
5377 pp$9.readEscapedChar = function(inTemplate) {
5378 var ch = this.input.charCodeAt(++this.pos);
5379 ++this.pos;
5380 switch (ch) {
5381 case 110: return "\n" // 'n' -> '\n'
5382 case 114: return "\r" // 'r' -> '\r'
5383 case 120: return String.fromCharCode(this.readHexChar(2)) // 'x'
5384 case 117: return codePointToString$1(this.readCodePoint()) // 'u'
5385 case 116: return "\t" // 't' -> '\t'
5386 case 98: return "\b" // 'b' -> '\b'
5387 case 118: return "\u000b" // 'v' -> '\u000b'
5388 case 102: return "\f" // 'f' -> '\f'
5389 case 13: if (this.input.charCodeAt(this.pos) === 10) { ++this.pos; } // '\r\n'
5390 case 10: // ' \n'
5391 if (this.options.locations) { this.lineStart = this.pos; ++this.curLine; }
5392 return ""
5393 case 56:
5394 case 57:
5395 if (this.strict) {
5396 this.invalidStringToken(
5397 this.pos - 1,
5398 "Invalid escape sequence"
5399 );
5400 }
5401 if (inTemplate) {
5402 var codePos = this.pos - 1;
5403
5404 this.invalidStringToken(
5405 codePos,
5406 "Invalid escape sequence in template string"
5407 );
5408
5409 return null
5410 }
5411 default:
5412 if (ch >= 48 && ch <= 55) {
5413 var octalStr = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0];
5414 var octal = parseInt(octalStr, 8);
5415 if (octal > 255) {
5416 octalStr = octalStr.slice(0, -1);
5417 octal = parseInt(octalStr, 8);
5418 }
5419 this.pos += octalStr.length - 1;
5420 ch = this.input.charCodeAt(this.pos);
5421 if ((octalStr !== "0" || ch === 56 || ch === 57) && (this.strict || inTemplate)) {
5422 this.invalidStringToken(
5423 this.pos - 1 - octalStr.length,
5424 inTemplate
5425 ? "Octal literal in template string"
5426 : "Octal literal in strict mode"
5427 );
5428 }
5429 return String.fromCharCode(octal)
5430 }
5431 if (isNewLine(ch)) {
5432 // Unicode new line characters after \ get removed from output in both
5433 // template literals and strings
5434 return ""
5435 }
5436 return String.fromCharCode(ch)
5437 }
5438 };
5439
5440 // Used to read character escape sequences ('\x', '\u', '\U').
5441
5442 pp$9.readHexChar = function(len) {
5443 var codePos = this.pos;
5444 var n = this.readInt(16, len);
5445 if (n === null) { this.invalidStringToken(codePos, "Bad character escape sequence"); }
5446 return n
5447 };
5448
5449 // Read an identifier, and return it as a string. Sets `this.containsEsc`
5450 // to whether the word contained a '\u' escape.
5451 //
5452 // Incrementally adds only escaped chars, adding other chunks as-is
5453 // as a micro-optimization.
5454
5455 pp$9.readWord1 = function() {
5456 this.containsEsc = false;
5457 var word = "", first = true, chunkStart = this.pos;
5458 var astral = this.options.ecmaVersion >= 6;
5459 while (this.pos < this.input.length) {
5460 var ch = this.fullCharCodeAtPos();
5461 if (isIdentifierChar(ch, astral)) {
5462 this.pos += ch <= 0xffff ? 1 : 2;
5463 } else if (ch === 92) { // "\"
5464 this.containsEsc = true;
5465 word += this.input.slice(chunkStart, this.pos);
5466 var escStart = this.pos;
5467 if (this.input.charCodeAt(++this.pos) !== 117) // "u"
5468 { this.invalidStringToken(this.pos, "Expecting Unicode escape sequence \\uXXXX"); }
5469 ++this.pos;
5470 var esc = this.readCodePoint();
5471 if (!(first ? isIdentifierStart : isIdentifierChar)(esc, astral))
5472 { this.invalidStringToken(escStart, "Invalid Unicode escape"); }
5473 word += codePointToString$1(esc);
5474 chunkStart = this.pos;
5475 } else {
5476 break
5477 }
5478 first = false;
5479 }
5480 return word + this.input.slice(chunkStart, this.pos)
5481 };
5482
5483 // Read an identifier or keyword token. Will check for reserved
5484 // words when necessary.
5485
5486 pp$9.readWord = function() {
5487 var word = this.readWord1();
5488 var type = types.name;
5489 if (this.keywords.test(word)) {
5490 type = keywords$1[word];
5491 }
5492 return this.finishToken(type, word)
5493 };
5494
5495 // Acorn is a tiny, fast JavaScript parser written in JavaScript.
5496
5497 var version = "8.5.0";
5498
5499 Parser.acorn = {
5500 Parser: Parser,
5501 version: version,
5502 defaultOptions: defaultOptions,
5503 Position: Position,
5504 SourceLocation: SourceLocation,
5505 getLineInfo: getLineInfo,
5506 Node: Node,
5507 TokenType: TokenType,
5508 tokTypes: types,
5509 keywordTypes: keywords$1,
5510 TokContext: TokContext,
5511 tokContexts: types$1,
5512 isIdentifierChar: isIdentifierChar,
5513 isIdentifierStart: isIdentifierStart,
5514 Token: Token,
5515 isNewLine: isNewLine,
5516 lineBreak: lineBreak,
5517 lineBreakG: lineBreakG,
5518 nonASCIIwhitespace: nonASCIIwhitespace
5519 };
5520
5521 // The main exported interface (under `self.acorn` when in the
5522 // browser) is a `parse` function that takes a code string and
5523 // returns an abstract syntax tree as specified by [Mozilla parser
5524 // API][api].
5525 //
5526 // [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
5527
5528 function parse(input, options) {
5529 return Parser.parse(input, options)
5530 }
5531
5532 // This function tries to parse a single expression at a given
5533 // offset in a string. Useful for parsing mixed-language formats
5534 // that embed JavaScript expressions.
5535
5536 function parseExpressionAt(input, pos, options) {
5537 return Parser.parseExpressionAt(input, pos, options)
5538 }
5539
5540 // Acorn is organized as a tokenizer and a recursive-descent parser.
5541 // The `tokenizer` export provides an interface to the tokenizer.
5542
5543 function tokenizer(input, options) {
5544 return Parser.tokenizer(input, options)
5545 }
5546
5547 exports.Node = Node;
5548 exports.Parser = Parser;
5549 exports.Position = Position;
5550 exports.SourceLocation = SourceLocation;
5551 exports.TokContext = TokContext;
5552 exports.Token = Token;
5553 exports.TokenType = TokenType;
5554 exports.defaultOptions = defaultOptions;
5555 exports.getLineInfo = getLineInfo;
5556 exports.isIdentifierChar = isIdentifierChar;
5557 exports.isIdentifierStart = isIdentifierStart;
5558 exports.isNewLine = isNewLine;
5559 exports.keywordTypes = keywords$1;
5560 exports.lineBreak = lineBreak;
5561 exports.lineBreakG = lineBreakG;
5562 exports.nonASCIIwhitespace = nonASCIIwhitespace;
5563 exports.parse = parse;
5564 exports.parseExpressionAt = parseExpressionAt;
5565 exports.tokContexts = types$1;
5566 exports.tokTypes = types;
5567 exports.tokenizer = tokenizer;
5568 exports.version = version;
5569
5570 Object.defineProperty(exports, '__esModule', { value: true });
5571
5572})));
Note: See TracBrowser for help on using the repository browser.