1 // This file was generated. Do not modify manually!
2 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, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 19306, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 262, 6, 10, 9, 357, 0, 62, 13, 1495, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
4 // This file was generated. Do not modify manually!
5 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, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 68, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 85, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 190, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1070, 4050, 582, 8634, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8936, 3, 2, 6, 2, 1, 2, 290, 46, 2, 18, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 482, 44, 11, 6, 17, 0, 322, 29, 19, 43, 1269, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4152, 8, 221, 3, 5761, 15, 7472, 3104, 541, 1507, 4938];
7 // This file was generated. Do not modify manually!
8 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\u0898-\u089f\u08ca-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3c\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\u1ace\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f";
10 // This file was generated. Do not modify manually!
11 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\u0870-\u0887\u0889-\u088e\u08a0-\u08c9\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u1711\u171f-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4c\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ca\ua7d0\ua7d1\ua7d3\ua7d5-\ua7d9\ua7f2-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
13 // These are a run-length and offset encoded representation of the
15 // Reserved word lists for various dialects of the language
18 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",
19 5: "class enum extends super const export import",
21 strict: "implements interface let package private protected public static yield",
22 strictBind: "eval arguments"
27 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";
30 5: ecma5AndLessKeywords,
31 "5module": ecma5AndLessKeywords + " export import",
32 6: ecma5AndLessKeywords + " const class extends export import super"
35 var keywordRelationalOperator = /^in(stanceof)?$/;
37 // ## Character categories
39 var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
40 var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
42 // This has a complexity linear to the value of the code. The
43 // assumption is that looking up astral identifier characters is
45 function isInAstralSet(code, set) {
47 for (var i = 0; i < set.length; i += 2) {
49 if (pos > code) { return false }
51 if (pos >= code) { return true }
55 // Test whether a given character code starts an identifier.
57 function isIdentifierStart(code, astral) {
58 if (code < 65) { return code === 36 }
59 if (code < 91) { return true }
60 if (code < 97) { return code === 95 }
61 if (code < 123) { return true }
62 if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)) }
63 if (astral === false) { return false }
64 return isInAstralSet(code, astralIdentifierStartCodes)
67 // Test whether a given character is part of an identifier.
69 function isIdentifierChar(code, astral) {
70 if (code < 48) { return code === 36 }
71 if (code < 58) { return true }
72 if (code < 65) { return false }
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 && nonASCIIidentifier.test(String.fromCharCode(code)) }
77 if (astral === false) { return false }
78 return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes)
83 // The assignment of fine-grained, information-carrying type objects
84 // allows the tokenizer to store the information it has about a
85 // token in a way that is very cheap for the parser to look up.
87 // All token type variables start with an underscore, to make them
90 // The `beforeExpr` property is used to disambiguate between regular
91 // expressions and divisions. It is set on all token types that can
92 // be followed by an expression (thus, a slash after them would be a
93 // regular expression).
95 // The `startsExpr` property is used to check if the token ends a
96 // `yield` expression. It is set on all token types that either can
97 // directly start an expression (like a quotation mark) or can
98 // continue an expression (like the body of a string).
100 // `isLoop` marks a keyword as starting a loop, which is important
101 // to know when parsing a label, in order to allow or disallow
102 // continue jumps to that label.
104 var TokenType = function TokenType(label, conf) {
105 if ( conf === void 0 ) conf = {};
108 this.keyword = conf.keyword;
109 this.beforeExpr = !!conf.beforeExpr;
110 this.startsExpr = !!conf.startsExpr;
111 this.isLoop = !!conf.isLoop;
112 this.isAssign = !!conf.isAssign;
113 this.prefix = !!conf.prefix;
114 this.postfix = !!conf.postfix;
115 this.binop = conf.binop || null;
116 this.updateContext = null;
119 function binop(name, prec) {
120 return new TokenType(name, {beforeExpr: true, binop: prec})
122 var beforeExpr = {beforeExpr: true}, startsExpr = {startsExpr: true};
124 // Map keyword names to token types.
128 // Succinct definitions of keyword token types
129 function kw(name, options) {
130 if ( options === void 0 ) options = {};
132 options.keyword = name;
133 return keywords[name] = new TokenType(name, options)
137 num: new TokenType("num", startsExpr),
138 regexp: new TokenType("regexp", startsExpr),
139 string: new TokenType("string", startsExpr),
140 name: new TokenType("name", startsExpr),
141 privateId: new TokenType("privateId", startsExpr),
142 eof: new TokenType("eof"),
144 // Punctuation token types.
145 bracketL: new TokenType("[", {beforeExpr: true, startsExpr: true}),
146 bracketR: new TokenType("]"),
147 braceL: new TokenType("{", {beforeExpr: true, startsExpr: true}),
148 braceR: new TokenType("}"),
149 parenL: new TokenType("(", {beforeExpr: true, startsExpr: true}),
150 parenR: new TokenType(")"),
151 comma: new TokenType(",", beforeExpr),
152 semi: new TokenType(";", beforeExpr),
153 colon: new TokenType(":", beforeExpr),
154 dot: new TokenType("."),
155 question: new TokenType("?", beforeExpr),
156 questionDot: new TokenType("?."),
157 arrow: new TokenType("=>", beforeExpr),
158 template: new TokenType("template"),
159 invalidTemplate: new TokenType("invalidTemplate"),
160 ellipsis: new TokenType("...", beforeExpr),
161 backQuote: new TokenType("`", startsExpr),
162 dollarBraceL: new TokenType("${", {beforeExpr: true, startsExpr: true}),
164 // Operators. These carry several kinds of properties to help the
165 // parser use them properly (the presence of these properties is
166 // what categorizes them as operators).
168 // `binop`, when present, specifies that this operator is a binary
169 // operator, and will refer to its precedence.
171 // `prefix` and `postfix` mark the operator as a prefix or postfix
174 // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as
175 // binary operators with a very low precedence, that should result
176 // in AssignmentExpression nodes.
178 eq: new TokenType("=", {beforeExpr: true, isAssign: true}),
179 assign: new TokenType("_=", {beforeExpr: true, isAssign: true}),
180 incDec: new TokenType("++/--", {prefix: true, postfix: true, startsExpr: true}),
181 prefix: new TokenType("!/~", {beforeExpr: true, prefix: true, startsExpr: true}),
182 logicalOR: binop("||", 1),
183 logicalAND: binop("&&", 2),
184 bitwiseOR: binop("|", 3),
185 bitwiseXOR: binop("^", 4),
186 bitwiseAND: binop("&", 5),
187 equality: binop("==/!=/===/!==", 6),
188 relational: binop("</>/<=/>=", 7),
189 bitShift: binop("<</>>/>>>", 8),
190 plusMin: new TokenType("+/-", {beforeExpr: true, binop: 9, prefix: true, startsExpr: true}),
191 modulo: binop("%", 10),
192 star: binop("*", 10),
193 slash: binop("/", 10),
194 starstar: new TokenType("**", {beforeExpr: true}),
195 coalesce: binop("??", 1),
197 // Keyword token types.
199 _case: kw("case", beforeExpr),
201 _continue: kw("continue"),
202 _debugger: kw("debugger"),
203 _default: kw("default", beforeExpr),
204 _do: kw("do", {isLoop: true, beforeExpr: true}),
205 _else: kw("else", beforeExpr),
206 _finally: kw("finally"),
207 _for: kw("for", {isLoop: true}),
208 _function: kw("function", startsExpr),
210 _return: kw("return", beforeExpr),
211 _switch: kw("switch"),
212 _throw: kw("throw", beforeExpr),
216 _while: kw("while", {isLoop: true}),
218 _new: kw("new", {beforeExpr: true, startsExpr: true}),
219 _this: kw("this", startsExpr),
220 _super: kw("super", startsExpr),
221 _class: kw("class", startsExpr),
222 _extends: kw("extends", beforeExpr),
223 _export: kw("export"),
224 _import: kw("import", startsExpr),
225 _null: kw("null", startsExpr),
226 _true: kw("true", startsExpr),
227 _false: kw("false", startsExpr),
228 _in: kw("in", {beforeExpr: true, binop: 7}),
229 _instanceof: kw("instanceof", {beforeExpr: true, binop: 7}),
230 _typeof: kw("typeof", {beforeExpr: true, prefix: true, startsExpr: true}),
231 _void: kw("void", {beforeExpr: true, prefix: true, startsExpr: true}),
232 _delete: kw("delete", {beforeExpr: true, prefix: true, startsExpr: true})
235 // Matches a whole line break (where CRLF is considered a single
236 // line break). Used to count lines.
238 var lineBreak = /\r\n?|\n|\u2028|\u2029/;
239 var lineBreakG = new RegExp(lineBreak.source, "g");
241 function isNewLine(code) {
242 return code === 10 || code === 13 || code === 0x2028 || code === 0x2029
245 function nextLineBreak(code, from, end) {
246 if ( end === void 0 ) end = code.length;
248 for (var i = from; i < end; i++) {
249 var next = code.charCodeAt(i);
251 { return i < end - 1 && next === 13 && code.charCodeAt(i + 1) === 10 ? i + 2 : i + 1 }
256 var nonASCIIwhitespace = /[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
258 var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
260 var ref = Object.prototype;
261 var hasOwnProperty = ref.hasOwnProperty;
262 var toString = ref.toString;
264 var hasOwn = Object.hasOwn || (function (obj, propName) { return (
265 hasOwnProperty.call(obj, propName)
268 var isArray = Array.isArray || (function (obj) { return (
269 toString.call(obj) === "[object Array]"
272 function wordsRegexp(words) {
273 return new RegExp("^(?:" + words.replace(/ /g, "|") + ")$")
276 function codePointToString(code) {
278 if (code <= 0xFFFF) { return String.fromCharCode(code) }
280 return String.fromCharCode((code >> 10) + 0xD800, (code & 1023) + 0xDC00)
283 var loneSurrogate = /(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/;
285 // These are used when `options.locations` is on, for the
286 // `startLoc` and `endLoc` properties.
288 var Position = function Position(line, col) {
293 Position.prototype.offset = function offset (n) {
294 return new Position(this.line, this.column + n)
297 var SourceLocation = function SourceLocation(p, start, end) {
300 if (p.sourceFile !== null) { this.source = p.sourceFile; }
303 // The `getLineInfo` function is mostly useful when the
304 // `locations` option is off (for performance reasons) and you
305 // want to find the line/column position for a given character
306 // offset. `input` should be the code string that the offset refers
309 function getLineInfo(input, offset) {
310 for (var line = 1, cur = 0;;) {
311 var nextBreak = nextLineBreak(input, cur, offset);
312 if (nextBreak < 0) { return new Position(line, offset - cur) }
318 // A second argument must be given to configure the parser process.
319 // These options are recognized (only `ecmaVersion` is required):
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.
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
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.
347 // When enabled, a return at the top level is not considered an
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
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.
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.
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
393 // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678
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.
401 // When `locations` is on, you can pass this to record the source
402 // file in every node's `loc` object.
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
412 // Interpret and default an options object
414 var warnedAboutEcmaVersion = false;
416 function getOptions(opts) {
419 for (var opt in defaultOptions)
420 { options[opt] = opts && hasOwn(opts, opt) ? opts[opt] : defaultOptions[opt]; }
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.");
429 options.ecmaVersion = 11;
430 } else if (options.ecmaVersion >= 2015) {
431 options.ecmaVersion -= 2009;
434 if (options.allowReserved == null)
435 { options.allowReserved = options.ecmaVersion < 5; }
437 if (isArray(options.onToken)) {
438 var tokens = options.onToken;
439 options.onToken = function (token) { return tokens.push(token); };
441 if (isArray(options.onComment))
442 { options.onComment = pushComment(options, options.onComment); }
447 function pushComment(options, array) {
448 return function(block, text, start, end, startLoc, endLoc) {
450 type: block ? "Block" : "Line",
455 if (options.locations)
456 { comment.loc = new SourceLocation(this, startLoc, endLoc); }
458 { comment.range = [start, end]; }
463 // Each scope gets a bitset that may contain these flags
470 SCOPE_SIMPLE_CATCH = 32,
472 SCOPE_DIRECT_SUPER = 128,
473 SCOPE_CLASS_STATIC_BLOCK = 256,
474 SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK;
476 function functionFlags(async, generator) {
477 return SCOPE_FUNCTION | (async ? SCOPE_ASYNC : 0) | (generator ? SCOPE_GENERATOR : 0)
480 // Used in checkLVal* and declareName to determine the type of a binding
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
489 var Parser = function Parser(options, input, startPos) {
490 this.options = options = getOptions(options);
491 this.sourceFile = options.sourceFile;
492 this.keywords = wordsRegexp(keywords$1[options.ecmaVersion >= 6 ? 6 : options.sourceType === "module" ? "5module" : 5]);
494 if (options.allowReserved !== true) {
495 reserved = reservedWords[options.ecmaVersion >= 6 ? 6 : options.ecmaVersion === 5 ? 5 : 3];
496 if (options.sourceType === "module") { reserved += " await"; }
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);
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;
509 // Set up token state
511 // The current position of the tokenizer in the input.
514 this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1;
515 this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;
517 this.pos = this.lineStart = 0;
521 // Properties of the current token:
523 this.type = types$1.eof;
524 // For tokens that include more information than their type, the value
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();
532 // Position information for the previous token
533 this.lastTokEndLoc = this.lastTokStartLoc = null;
534 this.lastTokStart = this.lastTokEnd = this.pos;
536 // The context stack is used to superficially track syntactic
537 // context to predict whether a regular expression is allowed in a
539 this.context = this.initialContext();
540 this.exprAllowed = true;
542 // Figure out if it's a module code.
543 this.inModule = options.sourceType === "module";
544 this.strict = this.inModule || this.strictDirective(this.pos);
546 // Used to signify the start of a potential arrow function
547 this.potentialArrowAt = -1;
548 this.potentialArrowInForAwait = false;
550 // Positions to delayed-check that yield/await does not exist in default parameters.
551 this.yieldPos = this.awaitPos = this.awaitIdentPos = 0;
554 // Thus-far undefined exports.
555 this.undefinedExports = Object.create(null);
557 // If enabled, skip leading hashbang line.
558 if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === "#!")
559 { this.skipLineComment(2); }
561 // Scope tracking for duplicate variable names (see scope.js)
562 this.scopeStack = [];
563 this.enterScope(SCOPE_TOP);
565 // For RegExp validation
566 this.regexpState = null;
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 = [];
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 } };
576 Parser.prototype.parse = function parse () {
577 var node = this.options.program || this.startNode();
579 return this.parseTopLevel(node)
582 prototypeAccessors.inFunction.get = function () { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 };
584 prototypeAccessors.inGenerator.get = function () { return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 && !this.currentVarScope().inClassFieldInit };
586 prototypeAccessors.inAsync.get = function () { return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 && !this.currentVarScope().inClassFieldInit };
588 prototypeAccessors.canAwait.get = function () {
589 for (var i = this.scopeStack.length - 1; i >= 0; i--) {
590 var scope = this.scopeStack[i];
591 if (scope.inClassFieldInit || scope.flags & SCOPE_CLASS_STATIC_BLOCK) { return false }
592 if (scope.flags & SCOPE_FUNCTION) { return (scope.flags & SCOPE_ASYNC) > 0 }
594 return (this.inModule && this.options.ecmaVersion >= 13) || this.options.allowAwaitOutsideFunction
597 prototypeAccessors.allowSuper.get = function () {
598 var ref = this.currentThisScope();
599 var flags = ref.flags;
600 var inClassFieldInit = ref.inClassFieldInit;
601 return (flags & SCOPE_SUPER) > 0 || inClassFieldInit || this.options.allowSuperOutsideMethod
604 prototypeAccessors.allowDirectSuper.get = function () { return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0 };
606 prototypeAccessors.treatFunctionsAsVar.get = function () { return this.treatFunctionsAsVarInScope(this.currentScope()) };
608 prototypeAccessors.allowNewDotTarget.get = function () {
609 var ref = this.currentThisScope();
610 var flags = ref.flags;
611 var inClassFieldInit = ref.inClassFieldInit;
612 return (flags & (SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK)) > 0 || inClassFieldInit
615 prototypeAccessors.inClassStaticBlock.get = function () {
616 return (this.currentVarScope().flags & SCOPE_CLASS_STATIC_BLOCK) > 0
619 Parser.extend = function extend () {
620 var plugins = [], len = arguments.length;
621 while ( len-- ) plugins[ len ] = arguments[ len ];
624 for (var i = 0; i < plugins.length; i++) { cls = plugins[i](cls); }
628 Parser.parse = function parse (input, options) {
629 return new this(options, input).parse()
632 Parser.parseExpressionAt = function parseExpressionAt (input, pos, options) {
633 var parser = new this(options, input, pos);
635 return parser.parseExpression()
638 Parser.tokenizer = function tokenizer (input, options) {
639 return new this(options, input)
642 Object.defineProperties( Parser.prototype, prototypeAccessors );
644 var pp$9 = Parser.prototype;
646 // ## Parser utilities
648 var literal = /^(?:'((?:\\.|[^'\\])*?)'|"((?:\\.|[^"\\])*?)")/;
649 pp$9.strictDirective = function(start) {
650 if (this.options.ecmaVersion < 5) { return false }
652 // Try to find string literal.
653 skipWhiteSpace.lastIndex = start;
654 start += skipWhiteSpace.exec(this.input)[0].length;
655 var match = literal.exec(this.input.slice(start));
656 if (!match) { return false }
657 if ((match[1] || match[2]) === "use strict") {
658 skipWhiteSpace.lastIndex = start + match[0].length;
659 var spaceAfter = skipWhiteSpace.exec(this.input), end = spaceAfter.index + spaceAfter[0].length;
660 var next = this.input.charAt(end);
661 return next === ";" || next === "}" ||
662 (lineBreak.test(spaceAfter[0]) &&
663 !(/[(`.[+\-/*%<>=,?^&]/.test(next) || next === "!" && this.input.charAt(end + 1) === "="))
665 start += match[0].length;
667 // Skip semicolon, if any.
668 skipWhiteSpace.lastIndex = start;
669 start += skipWhiteSpace.exec(this.input)[0].length;
670 if (this.input[start] === ";")
675 // Predicate that tests whether the next token is of the given
676 // type, and if yes, consumes it as a side effect.
678 pp$9.eat = function(type) {
679 if (this.type === type) {
687 // Tests whether parsed token is a contextual keyword.
689 pp$9.isContextual = function(name) {
690 return this.type === types$1.name && this.value === name && !this.containsEsc
693 // Consumes contextual keyword if possible.
695 pp$9.eatContextual = function(name) {
696 if (!this.isContextual(name)) { return false }
701 // Asserts that following token is given contextual keyword.
703 pp$9.expectContextual = function(name) {
704 if (!this.eatContextual(name)) { this.unexpected(); }
707 // Test whether a semicolon can be inserted at the current position.
709 pp$9.canInsertSemicolon = function() {
710 return this.type === types$1.eof ||
711 this.type === types$1.braceR ||
712 lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
715 pp$9.insertSemicolon = function() {
716 if (this.canInsertSemicolon()) {
717 if (this.options.onInsertedSemicolon)
718 { this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc); }
723 // Consume a semicolon, or, failing that, see if we are allowed to
724 // pretend that there is a semicolon at this position.
726 pp$9.semicolon = function() {
727 if (!this.eat(types$1.semi) && !this.insertSemicolon()) { this.unexpected(); }
730 pp$9.afterTrailingComma = function(tokType, notNext) {
731 if (this.type === tokType) {
732 if (this.options.onTrailingComma)
733 { this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc); }
740 // Expect a token of a given type. If found, consume it, otherwise,
741 // raise an unexpected token error.
743 pp$9.expect = function(type) {
744 this.eat(type) || this.unexpected();
747 // Raise an unexpected token error.
749 pp$9.unexpected = function(pos) {
750 this.raise(pos != null ? pos : this.start, "Unexpected token");
753 var DestructuringErrors = function DestructuringErrors() {
754 this.shorthandAssign =
756 this.parenthesizedAssign =
757 this.parenthesizedBind =
762 pp$9.checkPatternErrors = function(refDestructuringErrors, isAssign) {
763 if (!refDestructuringErrors) { return }
764 if (refDestructuringErrors.trailingComma > -1)
765 { this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element"); }
766 var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind;
767 if (parens > -1) { this.raiseRecoverable(parens, "Parenthesized pattern"); }
770 pp$9.checkExpressionErrors = function(refDestructuringErrors, andThrow) {
771 if (!refDestructuringErrors) { return false }
772 var shorthandAssign = refDestructuringErrors.shorthandAssign;
773 var doubleProto = refDestructuringErrors.doubleProto;
774 if (!andThrow) { return shorthandAssign >= 0 || doubleProto >= 0 }
775 if (shorthandAssign >= 0)
776 { this.raise(shorthandAssign, "Shorthand property assignments are valid only in destructuring patterns"); }
777 if (doubleProto >= 0)
778 { this.raiseRecoverable(doubleProto, "Redefinition of __proto__ property"); }
781 pp$9.checkYieldAwaitInDefaultParams = function() {
782 if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos))
783 { this.raise(this.yieldPos, "Yield expression cannot be a default value"); }
785 { this.raise(this.awaitPos, "Await expression cannot be a default value"); }
788 pp$9.isSimpleAssignTarget = function(expr) {
789 if (expr.type === "ParenthesizedExpression")
790 { return this.isSimpleAssignTarget(expr.expression) }
791 return expr.type === "Identifier" || expr.type === "MemberExpression"
794 var pp$8 = Parser.prototype;
796 // ### Statement parsing
798 // Parse a program. Initializes the parser, reads any number of
799 // statements, and wraps them in a Program node. Optionally takes a
800 // `program` argument. If present, the statements will be appended
801 // to its body instead of creating a new node.
803 pp$8.parseTopLevel = function(node) {
804 var exports = Object.create(null);
805 if (!node.body) { node.body = []; }
806 while (this.type !== types$1.eof) {
807 var stmt = this.parseStatement(null, true, exports);
808 node.body.push(stmt);
811 { for (var i = 0, list = Object.keys(this.undefinedExports); i < list.length; i += 1)
815 this.raiseRecoverable(this.undefinedExports[name].start, ("Export '" + name + "' is not defined"));
817 this.adaptDirectivePrologue(node.body);
819 node.sourceType = this.options.sourceType;
820 return this.finishNode(node, "Program")
823 var loopLabel = {kind: "loop"}, switchLabel = {kind: "switch"};
825 pp$8.isLet = function(context) {
826 if (this.options.ecmaVersion < 6 || !this.isContextual("let")) { return false }
827 skipWhiteSpace.lastIndex = this.pos;
828 var skip = skipWhiteSpace.exec(this.input);
829 var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
830 // For ambiguous cases, determine if a LexicalDeclaration (or only a
831 // Statement) is allowed here. If context is not empty then only a Statement
832 // is allowed. However, `let [` is an explicit negative lookahead for
833 // ExpressionStatement, so special-case it first.
834 if (nextCh === 91 || nextCh === 92 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true } // '[', '/', astral
835 if (context) { return false }
837 if (nextCh === 123) { return true } // '{'
838 if (isIdentifierStart(nextCh, true)) {
840 while (isIdentifierChar(nextCh = this.input.charCodeAt(pos), true)) { ++pos; }
841 if (nextCh === 92 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true }
842 var ident = this.input.slice(next, pos);
843 if (!keywordRelationalOperator.test(ident)) { return true }
848 // check 'async [no LineTerminator here] function'
849 // - 'async /*foo*/ function' is OK.
850 // - 'async /*\n*/ function' is invalid.
851 pp$8.isAsyncFunction = function() {
852 if (this.options.ecmaVersion < 8 || !this.isContextual("async"))
855 skipWhiteSpace.lastIndex = this.pos;
856 var skip = skipWhiteSpace.exec(this.input);
857 var next = this.pos + skip[0].length, after;
858 return !lineBreak.test(this.input.slice(this.pos, next)) &&
859 this.input.slice(next, next + 8) === "function" &&
860 (next + 8 === this.input.length ||
861 !(isIdentifierChar(after = this.input.charCodeAt(next + 8)) || after > 0xd7ff && after < 0xdc00))
864 // Parse a single statement.
866 // If expecting a statement and finding a slash operator, parse a
867 // regular expression literal. This is to handle cases like
868 // `if (foo) /blah/.exec(foo)`, where looking at the previous token
871 pp$8.parseStatement = function(context, topLevel, exports) {
872 var starttype = this.type, node = this.startNode(), kind;
874 if (this.isLet(context)) {
875 starttype = types$1._var;
879 // Most types of statements are recognized by the keyword they
880 // start with. Many are trivial to parse, some require a bit of
884 case types$1._break: case types$1._continue: return this.parseBreakContinueStatement(node, starttype.keyword)
885 case types$1._debugger: return this.parseDebuggerStatement(node)
886 case types$1._do: return this.parseDoStatement(node)
887 case types$1._for: return this.parseForStatement(node)
888 case types$1._function:
889 // Function as sole body of either an if statement or a labeled statement
890 // works, but not when it is part of a labeled statement that is the sole
891 // body of an if statement.
892 if ((context && (this.strict || context !== "if" && context !== "label")) && this.options.ecmaVersion >= 6) { this.unexpected(); }
893 return this.parseFunctionStatement(node, false, !context)
895 if (context) { this.unexpected(); }
896 return this.parseClass(node, true)
897 case types$1._if: return this.parseIfStatement(node)
898 case types$1._return: return this.parseReturnStatement(node)
899 case types$1._switch: return this.parseSwitchStatement(node)
900 case types$1._throw: return this.parseThrowStatement(node)
901 case types$1._try: return this.parseTryStatement(node)
902 case types$1._const: case types$1._var:
903 kind = kind || this.value;
904 if (context && kind !== "var") { this.unexpected(); }
905 return this.parseVarStatement(node, kind)
906 case types$1._while: return this.parseWhileStatement(node)
907 case types$1._with: return this.parseWithStatement(node)
908 case types$1.braceL: return this.parseBlock(true, node)
909 case types$1.semi: return this.parseEmptyStatement(node)
910 case types$1._export:
911 case types$1._import:
912 if (this.options.ecmaVersion > 10 && starttype === types$1._import) {
913 skipWhiteSpace.lastIndex = this.pos;
914 var skip = skipWhiteSpace.exec(this.input);
915 var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
916 if (nextCh === 40 || nextCh === 46) // '(' or '.'
917 { return this.parseExpressionStatement(node, this.parseExpression()) }
920 if (!this.options.allowImportExportEverywhere) {
922 { this.raise(this.start, "'import' and 'export' may only appear at the top level"); }
924 { this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'"); }
926 return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports)
928 // If the statement does not start with a statement keyword or a
929 // brace, it's an ExpressionStatement or LabeledStatement. We
930 // simply start parsing an expression, and afterwards, if the
931 // next token is a colon and the expression was a simple
932 // Identifier node, we switch to interpreting it as a label.
934 if (this.isAsyncFunction()) {
935 if (context) { this.unexpected(); }
937 return this.parseFunctionStatement(node, true, !context)
940 var maybeName = this.value, expr = this.parseExpression();
941 if (starttype === types$1.name && expr.type === "Identifier" && this.eat(types$1.colon))
942 { return this.parseLabeledStatement(node, maybeName, expr, context) }
943 else { return this.parseExpressionStatement(node, expr) }
947 pp$8.parseBreakContinueStatement = function(node, keyword) {
948 var isBreak = keyword === "break";
950 if (this.eat(types$1.semi) || this.insertSemicolon()) { node.label = null; }
951 else if (this.type !== types$1.name) { this.unexpected(); }
953 node.label = this.parseIdent();
957 // Verify that there is an actual destination to break or
960 for (; i < this.labels.length; ++i) {
961 var lab = this.labels[i];
962 if (node.label == null || lab.name === node.label.name) {
963 if (lab.kind != null && (isBreak || lab.kind === "loop")) { break }
964 if (node.label && isBreak) { break }
967 if (i === this.labels.length) { this.raise(node.start, "Unsyntactic " + keyword); }
968 return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement")
971 pp$8.parseDebuggerStatement = function(node) {
974 return this.finishNode(node, "DebuggerStatement")
977 pp$8.parseDoStatement = function(node) {
979 this.labels.push(loopLabel);
980 node.body = this.parseStatement("do");
982 this.expect(types$1._while);
983 node.test = this.parseParenExpression();
984 if (this.options.ecmaVersion >= 6)
985 { this.eat(types$1.semi); }
987 { this.semicolon(); }
988 return this.finishNode(node, "DoWhileStatement")
991 // Disambiguating between a `for` and a `for`/`in` or `for`/`of`
992 // loop is non-trivial. Basically, we have to parse the init `var`
993 // statement or expression, disallowing the `in` operator (see
994 // the second parameter to `parseExpression`), and then check
995 // whether the next token is `in` or `of`. When there is no init
996 // part (semicolon immediately after the opening parenthesis), it
997 // is a regular `for` loop.
999 pp$8.parseForStatement = function(node) {
1001 var awaitAt = (this.options.ecmaVersion >= 9 && this.canAwait && this.eatContextual("await")) ? this.lastTokStart : -1;
1002 this.labels.push(loopLabel);
1004 this.expect(types$1.parenL);
1005 if (this.type === types$1.semi) {
1006 if (awaitAt > -1) { this.unexpected(awaitAt); }
1007 return this.parseFor(node, null)
1009 var isLet = this.isLet();
1010 if (this.type === types$1._var || this.type === types$1._const || isLet) {
1011 var init$1 = this.startNode(), kind = isLet ? "let" : this.value;
1013 this.parseVar(init$1, true, kind);
1014 this.finishNode(init$1, "VariableDeclaration");
1015 if ((this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1) {
1016 if (this.options.ecmaVersion >= 9) {
1017 if (this.type === types$1._in) {
1018 if (awaitAt > -1) { this.unexpected(awaitAt); }
1019 } else { node.await = awaitAt > -1; }
1021 return this.parseForIn(node, init$1)
1023 if (awaitAt > -1) { this.unexpected(awaitAt); }
1024 return this.parseFor(node, init$1)
1026 var startsWithLet = this.isContextual("let"), isForOf = false;
1027 var refDestructuringErrors = new DestructuringErrors;
1028 var init = this.parseExpression(awaitAt > -1 ? "await" : true, refDestructuringErrors);
1029 if (this.type === types$1._in || (isForOf = this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
1030 if (this.options.ecmaVersion >= 9) {
1031 if (this.type === types$1._in) {
1032 if (awaitAt > -1) { this.unexpected(awaitAt); }
1033 } else { node.await = awaitAt > -1; }
1035 if (startsWithLet && isForOf) { this.raise(init.start, "The left-hand side of a for-of loop may not start with 'let'."); }
1036 this.toAssignable(init, false, refDestructuringErrors);
1037 this.checkLValPattern(init);
1038 return this.parseForIn(node, init)
1040 this.checkExpressionErrors(refDestructuringErrors, true);
1042 if (awaitAt > -1) { this.unexpected(awaitAt); }
1043 return this.parseFor(node, init)
1046 pp$8.parseFunctionStatement = function(node, isAsync, declarationPosition) {
1048 return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync)
1051 pp$8.parseIfStatement = function(node) {
1053 node.test = this.parseParenExpression();
1054 // allow function declarations in branches, but only in non-strict mode
1055 node.consequent = this.parseStatement("if");
1056 node.alternate = this.eat(types$1._else) ? this.parseStatement("if") : null;
1057 return this.finishNode(node, "IfStatement")
1060 pp$8.parseReturnStatement = function(node) {
1061 if (!this.inFunction && !this.options.allowReturnOutsideFunction)
1062 { this.raise(this.start, "'return' outside of function"); }
1065 // In `return` (and `break`/`continue`), the keywords with
1066 // optional arguments, we eagerly look for a semicolon or the
1067 // possibility to insert one.
1069 if (this.eat(types$1.semi) || this.insertSemicolon()) { node.argument = null; }
1070 else { node.argument = this.parseExpression(); this.semicolon(); }
1071 return this.finishNode(node, "ReturnStatement")
1074 pp$8.parseSwitchStatement = function(node) {
1076 node.discriminant = this.parseParenExpression();
1078 this.expect(types$1.braceL);
1079 this.labels.push(switchLabel);
1082 // Statements under must be grouped (by label) in SwitchCase
1083 // nodes. `cur` is used to keep the node that we are currently
1084 // adding statements to.
1087 for (var sawDefault = false; this.type !== types$1.braceR;) {
1088 if (this.type === types$1._case || this.type === types$1._default) {
1089 var isCase = this.type === types$1._case;
1090 if (cur) { this.finishNode(cur, "SwitchCase"); }
1091 node.cases.push(cur = this.startNode());
1092 cur.consequent = [];
1095 cur.test = this.parseExpression();
1097 if (sawDefault) { this.raiseRecoverable(this.lastTokStart, "Multiple default clauses"); }
1101 this.expect(types$1.colon);
1103 if (!cur) { this.unexpected(); }
1104 cur.consequent.push(this.parseStatement(null));
1108 if (cur) { this.finishNode(cur, "SwitchCase"); }
1109 this.next(); // Closing brace
1111 return this.finishNode(node, "SwitchStatement")
1114 pp$8.parseThrowStatement = function(node) {
1116 if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start)))
1117 { this.raise(this.lastTokEnd, "Illegal newline after throw"); }
1118 node.argument = this.parseExpression();
1120 return this.finishNode(node, "ThrowStatement")
1123 // Reused empty array added for node fields that are always empty.
1127 pp$8.parseTryStatement = function(node) {
1129 node.block = this.parseBlock();
1130 node.handler = null;
1131 if (this.type === types$1._catch) {
1132 var clause = this.startNode();
1134 if (this.eat(types$1.parenL)) {
1135 clause.param = this.parseBindingAtom();
1136 var simple = clause.param.type === "Identifier";
1137 this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0);
1138 this.checkLValPattern(clause.param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL);
1139 this.expect(types$1.parenR);
1141 if (this.options.ecmaVersion < 10) { this.unexpected(); }
1142 clause.param = null;
1145 clause.body = this.parseBlock(false);
1147 node.handler = this.finishNode(clause, "CatchClause");
1149 node.finalizer = this.eat(types$1._finally) ? this.parseBlock() : null;
1150 if (!node.handler && !node.finalizer)
1151 { this.raise(node.start, "Missing catch or finally clause"); }
1152 return this.finishNode(node, "TryStatement")
1155 pp$8.parseVarStatement = function(node, kind) {
1157 this.parseVar(node, false, kind);
1159 return this.finishNode(node, "VariableDeclaration")
1162 pp$8.parseWhileStatement = function(node) {
1164 node.test = this.parseParenExpression();
1165 this.labels.push(loopLabel);
1166 node.body = this.parseStatement("while");
1168 return this.finishNode(node, "WhileStatement")
1171 pp$8.parseWithStatement = function(node) {
1172 if (this.strict) { this.raise(this.start, "'with' in strict mode"); }
1174 node.object = this.parseParenExpression();
1175 node.body = this.parseStatement("with");
1176 return this.finishNode(node, "WithStatement")
1179 pp$8.parseEmptyStatement = function(node) {
1181 return this.finishNode(node, "EmptyStatement")
1184 pp$8.parseLabeledStatement = function(node, maybeName, expr, context) {
1185 for (var i$1 = 0, list = this.labels; i$1 < list.length; i$1 += 1)
1187 var label = list[i$1];
1189 if (label.name === maybeName)
1190 { this.raise(expr.start, "Label '" + maybeName + "' is already declared");
1192 var kind = this.type.isLoop ? "loop" : this.type === types$1._switch ? "switch" : null;
1193 for (var i = this.labels.length - 1; i >= 0; i--) {
1194 var label$1 = this.labels[i];
1195 if (label$1.statementStart === node.start) {
1196 // Update information about previous labels on this node
1197 label$1.statementStart = this.start;
1198 label$1.kind = kind;
1201 this.labels.push({name: maybeName, kind: kind, statementStart: this.start});
1202 node.body = this.parseStatement(context ? context.indexOf("label") === -1 ? context + "label" : context : "label");
1205 return this.finishNode(node, "LabeledStatement")
1208 pp$8.parseExpressionStatement = function(node, expr) {
1209 node.expression = expr;
1211 return this.finishNode(node, "ExpressionStatement")
1214 // Parse a semicolon-enclosed block of statements, handling `"use
1215 // strict"` declarations when `allowStrict` is true (used for
1216 // function bodies).
1218 pp$8.parseBlock = function(createNewLexicalScope, node, exitStrict) {
1219 if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true;
1220 if ( node === void 0 ) node = this.startNode();
1223 this.expect(types$1.braceL);
1224 if (createNewLexicalScope) { this.enterScope(0); }
1225 while (this.type !== types$1.braceR) {
1226 var stmt = this.parseStatement(null);
1227 node.body.push(stmt);
1229 if (exitStrict) { this.strict = false; }
1231 if (createNewLexicalScope) { this.exitScope(); }
1232 return this.finishNode(node, "BlockStatement")
1235 // Parse a regular `for` loop. The disambiguation code in
1236 // `parseStatement` will already have parsed the init statement or
1239 pp$8.parseFor = function(node, init) {
1241 this.expect(types$1.semi);
1242 node.test = this.type === types$1.semi ? null : this.parseExpression();
1243 this.expect(types$1.semi);
1244 node.update = this.type === types$1.parenR ? null : this.parseExpression();
1245 this.expect(types$1.parenR);
1246 node.body = this.parseStatement("for");
1249 return this.finishNode(node, "ForStatement")
1252 // Parse a `for`/`in` and `for`/`of` loop, which are almost
1253 // same from parser's perspective.
1255 pp$8.parseForIn = function(node, init) {
1256 var isForIn = this.type === types$1._in;
1260 init.type === "VariableDeclaration" &&
1261 init.declarations[0].init != null &&
1264 this.options.ecmaVersion < 8 ||
1266 init.kind !== "var" ||
1267 init.declarations[0].id.type !== "Identifier"
1272 ((isForIn ? "for-in" : "for-of") + " loop variable declaration may not have an initializer")
1276 node.right = isForIn ? this.parseExpression() : this.parseMaybeAssign();
1277 this.expect(types$1.parenR);
1278 node.body = this.parseStatement("for");
1281 return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement")
1284 // Parse a list of variable declarations.
1286 pp$8.parseVar = function(node, isFor, kind) {
1287 node.declarations = [];
1290 var decl = this.startNode();
1291 this.parseVarId(decl, kind);
1292 if (this.eat(types$1.eq)) {
1293 decl.init = this.parseMaybeAssign(isFor);
1294 } else if (kind === "const" && !(this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of")))) {
1296 } else if (decl.id.type !== "Identifier" && !(isFor && (this.type === types$1._in || this.isContextual("of")))) {
1297 this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");
1301 node.declarations.push(this.finishNode(decl, "VariableDeclarator"));
1302 if (!this.eat(types$1.comma)) { break }
1307 pp$8.parseVarId = function(decl, kind) {
1308 decl.id = this.parseBindingAtom();
1309 this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false);
1312 var FUNC_STATEMENT = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID = 4;
1314 // Parse a function declaration or literal (depending on the
1315 // `statement & FUNC_STATEMENT`).
1317 // Remove `allowExpressionBody` for 7.0.0, as it is only called with false
1318 pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, forInit) {
1319 this.initFunction(node);
1320 if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) {
1321 if (this.type === types$1.star && (statement & FUNC_HANGING_STATEMENT))
1322 { this.unexpected(); }
1323 node.generator = this.eat(types$1.star);
1325 if (this.options.ecmaVersion >= 8)
1326 { node.async = !!isAsync; }
1328 if (statement & FUNC_STATEMENT) {
1329 node.id = (statement & FUNC_NULLABLE_ID) && this.type !== types$1.name ? null : this.parseIdent();
1330 if (node.id && !(statement & FUNC_HANGING_STATEMENT))
1331 // If it is a regular function declaration in sloppy mode, then it is
1332 // subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding
1333 // mode depends on properties of the current scope (see
1334 // treatFunctionsAsVar).
1335 { this.checkLValSimple(node.id, (this.strict || node.generator || node.async) ? this.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION); }
1338 var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
1341 this.awaitIdentPos = 0;
1342 this.enterScope(functionFlags(node.async, node.generator));
1344 if (!(statement & FUNC_STATEMENT))
1345 { node.id = this.type === types$1.name ? this.parseIdent() : null; }
1347 this.parseFunctionParams(node);
1348 this.parseFunctionBody(node, allowExpressionBody, false, forInit);
1350 this.yieldPos = oldYieldPos;
1351 this.awaitPos = oldAwaitPos;
1352 this.awaitIdentPos = oldAwaitIdentPos;
1353 return this.finishNode(node, (statement & FUNC_STATEMENT) ? "FunctionDeclaration" : "FunctionExpression")
1356 pp$8.parseFunctionParams = function(node) {
1357 this.expect(types$1.parenL);
1358 node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8);
1359 this.checkYieldAwaitInDefaultParams();
1362 // Parse a class declaration or literal (depending on the
1363 // `isStatement` parameter).
1365 pp$8.parseClass = function(node, isStatement) {
1368 // ecma-262 14.6 Class Definitions
1369 // A class definition is always strict mode code.
1370 var oldStrict = this.strict;
1373 this.parseClassId(node, isStatement);
1374 this.parseClassSuper(node);
1375 var privateNameMap = this.enterClassBody();
1376 var classBody = this.startNode();
1377 var hadConstructor = false;
1378 classBody.body = [];
1379 this.expect(types$1.braceL);
1380 while (this.type !== types$1.braceR) {
1381 var element = this.parseClassElement(node.superClass !== null);
1383 classBody.body.push(element);
1384 if (element.type === "MethodDefinition" && element.kind === "constructor") {
1385 if (hadConstructor) { this.raise(element.start, "Duplicate constructor in the same class"); }
1386 hadConstructor = true;
1387 } else if (element.key && element.key.type === "PrivateIdentifier" && isPrivateNameConflicted(privateNameMap, element)) {
1388 this.raiseRecoverable(element.key.start, ("Identifier '#" + (element.key.name) + "' has already been declared"));
1392 this.strict = oldStrict;
1394 node.body = this.finishNode(classBody, "ClassBody");
1395 this.exitClassBody();
1396 return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression")
1399 pp$8.parseClassElement = function(constructorAllowsSuper) {
1400 if (this.eat(types$1.semi)) { return null }
1402 var ecmaVersion = this.options.ecmaVersion;
1403 var node = this.startNode();
1405 var isGenerator = false;
1406 var isAsync = false;
1407 var kind = "method";
1408 var isStatic = false;
1410 if (this.eatContextual("static")) {
1411 // Parse static init block
1412 if (ecmaVersion >= 13 && this.eat(types$1.braceL)) {
1413 this.parseClassStaticBlock(node);
1416 if (this.isClassElementNameStart() || this.type === types$1.star) {
1422 node.static = isStatic;
1423 if (!keyName && ecmaVersion >= 8 && this.eatContextual("async")) {
1424 if ((this.isClassElementNameStart() || this.type === types$1.star) && !this.canInsertSemicolon()) {
1430 if (!keyName && (ecmaVersion >= 9 || !isAsync) && this.eat(types$1.star)) {
1433 if (!keyName && !isAsync && !isGenerator) {
1434 var lastValue = this.value;
1435 if (this.eatContextual("get") || this.eatContextual("set")) {
1436 if (this.isClassElementNameStart()) {
1439 keyName = lastValue;
1444 // Parse element name
1446 // 'async', 'get', 'set', or 'static' were not a keyword contextually.
1447 // The last token is any of those. Make it the element name.
1448 node.computed = false;
1449 node.key = this.startNodeAt(this.lastTokStart, this.lastTokStartLoc);
1450 node.key.name = keyName;
1451 this.finishNode(node.key, "Identifier");
1453 this.parseClassElementName(node);
1456 // Parse element value
1457 if (ecmaVersion < 13 || this.type === types$1.parenL || kind !== "method" || isGenerator || isAsync) {
1458 var isConstructor = !node.static && checkKeyName(node, "constructor");
1459 var allowsDirectSuper = isConstructor && constructorAllowsSuper;
1460 // Couldn't move this check into the 'parseClassMethod' method for backward compatibility.
1461 if (isConstructor && kind !== "method") { this.raise(node.key.start, "Constructor can't have get/set modifier"); }
1462 node.kind = isConstructor ? "constructor" : kind;
1463 this.parseClassMethod(node, isGenerator, isAsync, allowsDirectSuper);
1465 this.parseClassField(node);
1471 pp$8.isClassElementNameStart = function() {
1473 this.type === types$1.name ||
1474 this.type === types$1.privateId ||
1475 this.type === types$1.num ||
1476 this.type === types$1.string ||
1477 this.type === types$1.bracketL ||
1482 pp$8.parseClassElementName = function(element) {
1483 if (this.type === types$1.privateId) {
1484 if (this.value === "constructor") {
1485 this.raise(this.start, "Classes can't have an element named '#constructor'");
1487 element.computed = false;
1488 element.key = this.parsePrivateIdent();
1490 this.parsePropertyName(element);
1494 pp$8.parseClassMethod = function(method, isGenerator, isAsync, allowsDirectSuper) {
1495 // Check key and flags
1496 var key = method.key;
1497 if (method.kind === "constructor") {
1498 if (isGenerator) { this.raise(key.start, "Constructor can't be a generator"); }
1499 if (isAsync) { this.raise(key.start, "Constructor can't be an async method"); }
1500 } else if (method.static && checkKeyName(method, "prototype")) {
1501 this.raise(key.start, "Classes may not have a static property named prototype");
1505 var value = method.value = this.parseMethod(isGenerator, isAsync, allowsDirectSuper);
1508 if (method.kind === "get" && value.params.length !== 0)
1509 { this.raiseRecoverable(value.start, "getter should have no params"); }
1510 if (method.kind === "set" && value.params.length !== 1)
1511 { this.raiseRecoverable(value.start, "setter should have exactly one param"); }
1512 if (method.kind === "set" && value.params[0].type === "RestElement")
1513 { this.raiseRecoverable(value.params[0].start, "Setter cannot use rest params"); }
1515 return this.finishNode(method, "MethodDefinition")
1518 pp$8.parseClassField = function(field) {
1519 if (checkKeyName(field, "constructor")) {
1520 this.raise(field.key.start, "Classes can't have a field named 'constructor'");
1521 } else if (field.static && checkKeyName(field, "prototype")) {
1522 this.raise(field.key.start, "Classes can't have a static field named 'prototype'");
1525 if (this.eat(types$1.eq)) {
1526 // To raise SyntaxError if 'arguments' exists in the initializer.
1527 var scope = this.currentThisScope();
1528 var inClassFieldInit = scope.inClassFieldInit;
1529 scope.inClassFieldInit = true;
1530 field.value = this.parseMaybeAssign();
1531 scope.inClassFieldInit = inClassFieldInit;
1537 return this.finishNode(field, "PropertyDefinition")
1540 pp$8.parseClassStaticBlock = function(node) {
1543 var oldLabels = this.labels;
1545 this.enterScope(SCOPE_CLASS_STATIC_BLOCK | SCOPE_SUPER);
1546 while (this.type !== types$1.braceR) {
1547 var stmt = this.parseStatement(null);
1548 node.body.push(stmt);
1552 this.labels = oldLabels;
1554 return this.finishNode(node, "StaticBlock")
1557 pp$8.parseClassId = function(node, isStatement) {
1558 if (this.type === types$1.name) {
1559 node.id = this.parseIdent();
1561 { this.checkLValSimple(node.id, BIND_LEXICAL, false); }
1563 if (isStatement === true)
1564 { this.unexpected(); }
1569 pp$8.parseClassSuper = function(node) {
1570 node.superClass = this.eat(types$1._extends) ? this.parseExprSubscripts(false) : null;
1573 pp$8.enterClassBody = function() {
1574 var element = {declared: Object.create(null), used: []};
1575 this.privateNameStack.push(element);
1576 return element.declared
1579 pp$8.exitClassBody = function() {
1580 var ref = this.privateNameStack.pop();
1581 var declared = ref.declared;
1582 var used = ref.used;
1583 var len = this.privateNameStack.length;
1584 var parent = len === 0 ? null : this.privateNameStack[len - 1];
1585 for (var i = 0; i < used.length; ++i) {
1587 if (!hasOwn(declared, id.name)) {
1589 parent.used.push(id);
1591 this.raiseRecoverable(id.start, ("Private field '#" + (id.name) + "' must be declared in an enclosing class"));
1597 function isPrivateNameConflicted(privateNameMap, element) {
1598 var name = element.key.name;
1599 var curr = privateNameMap[name];
1602 if (element.type === "MethodDefinition" && (element.kind === "get" || element.kind === "set")) {
1603 next = (element.static ? "s" : "i") + element.kind;
1606 // `class { get #a(){}; static set #a(_){} }` is also conflict.
1608 curr === "iget" && next === "iset" ||
1609 curr === "iset" && next === "iget" ||
1610 curr === "sget" && next === "sset" ||
1611 curr === "sset" && next === "sget"
1613 privateNameMap[name] = "true";
1616 privateNameMap[name] = next;
1623 function checkKeyName(node, name) {
1624 var computed = node.computed;
1626 return !computed && (
1627 key.type === "Identifier" && key.name === name ||
1628 key.type === "Literal" && key.value === name
1632 // Parses module export declaration.
1634 pp$8.parseExport = function(node, exports) {
1636 // export * from '...'
1637 if (this.eat(types$1.star)) {
1638 if (this.options.ecmaVersion >= 11) {
1639 if (this.eatContextual("as")) {
1640 node.exported = this.parseModuleExportName();
1641 this.checkExport(exports, node.exported, this.lastTokStart);
1643 node.exported = null;
1646 this.expectContextual("from");
1647 if (this.type !== types$1.string) { this.unexpected(); }
1648 node.source = this.parseExprAtom();
1650 return this.finishNode(node, "ExportAllDeclaration")
1652 if (this.eat(types$1._default)) { // export default ...
1653 this.checkExport(exports, "default", this.lastTokStart);
1655 if (this.type === types$1._function || (isAsync = this.isAsyncFunction())) {
1656 var fNode = this.startNode();
1658 if (isAsync) { this.next(); }
1659 node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);
1660 } else if (this.type === types$1._class) {
1661 var cNode = this.startNode();
1662 node.declaration = this.parseClass(cNode, "nullableID");
1664 node.declaration = this.parseMaybeAssign();
1667 return this.finishNode(node, "ExportDefaultDeclaration")
1669 // export var|const|let|function|class ...
1670 if (this.shouldParseExportStatement()) {
1671 node.declaration = this.parseStatement(null);
1672 if (node.declaration.type === "VariableDeclaration")
1673 { this.checkVariableExport(exports, node.declaration.declarations); }
1675 { this.checkExport(exports, node.declaration.id, node.declaration.id.start); }
1676 node.specifiers = [];
1678 } else { // export { x, y as z } [from '...']
1679 node.declaration = null;
1680 node.specifiers = this.parseExportSpecifiers(exports);
1681 if (this.eatContextual("from")) {
1682 if (this.type !== types$1.string) { this.unexpected(); }
1683 node.source = this.parseExprAtom();
1685 for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
1686 // check for keywords used as local names
1689 this.checkUnreserved(spec.local);
1690 // check if export is defined
1691 this.checkLocalExport(spec.local);
1693 if (spec.local.type === "Literal") {
1694 this.raise(spec.local.start, "A string literal cannot be used as an exported binding without `from`.");
1702 return this.finishNode(node, "ExportNamedDeclaration")
1705 pp$8.checkExport = function(exports, name, pos) {
1706 if (!exports) { return }
1707 if (typeof name !== "string")
1708 { name = name.type === "Identifier" ? name.name : name.value; }
1709 if (hasOwn(exports, name))
1710 { this.raiseRecoverable(pos, "Duplicate export '" + name + "'"); }
1711 exports[name] = true;
1714 pp$8.checkPatternExport = function(exports, pat) {
1715 var type = pat.type;
1716 if (type === "Identifier")
1717 { this.checkExport(exports, pat, pat.start); }
1718 else if (type === "ObjectPattern")
1719 { for (var i = 0, list = pat.properties; i < list.length; i += 1)
1723 this.checkPatternExport(exports, prop);
1725 else if (type === "ArrayPattern")
1726 { for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
1727 var elt = list$1[i$1];
1729 if (elt) { this.checkPatternExport(exports, elt); }
1731 else if (type === "Property")
1732 { this.checkPatternExport(exports, pat.value); }
1733 else if (type === "AssignmentPattern")
1734 { this.checkPatternExport(exports, pat.left); }
1735 else if (type === "RestElement")
1736 { this.checkPatternExport(exports, pat.argument); }
1737 else if (type === "ParenthesizedExpression")
1738 { this.checkPatternExport(exports, pat.expression); }
1741 pp$8.checkVariableExport = function(exports, decls) {
1742 if (!exports) { return }
1743 for (var i = 0, list = decls; i < list.length; i += 1)
1747 this.checkPatternExport(exports, decl.id);
1751 pp$8.shouldParseExportStatement = function() {
1752 return this.type.keyword === "var" ||
1753 this.type.keyword === "const" ||
1754 this.type.keyword === "class" ||
1755 this.type.keyword === "function" ||
1757 this.isAsyncFunction()
1760 // Parses a comma-separated list of module exports.
1762 pp$8.parseExportSpecifiers = function(exports) {
1763 var nodes = [], first = true;
1764 // export { x, y as z } [from '...']
1765 this.expect(types$1.braceL);
1766 while (!this.eat(types$1.braceR)) {
1768 this.expect(types$1.comma);
1769 if (this.afterTrailingComma(types$1.braceR)) { break }
1770 } else { first = false; }
1772 var node = this.startNode();
1773 node.local = this.parseModuleExportName();
1774 node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local;
1780 nodes.push(this.finishNode(node, "ExportSpecifier"));
1785 // Parses import declaration.
1787 pp$8.parseImport = function(node) {
1790 if (this.type === types$1.string) {
1791 node.specifiers = empty$1;
1792 node.source = this.parseExprAtom();
1794 node.specifiers = this.parseImportSpecifiers();
1795 this.expectContextual("from");
1796 node.source = this.type === types$1.string ? this.parseExprAtom() : this.unexpected();
1799 return this.finishNode(node, "ImportDeclaration")
1802 // Parses a comma-separated list of module imports.
1804 pp$8.parseImportSpecifiers = function() {
1805 var nodes = [], first = true;
1806 if (this.type === types$1.name) {
1807 // import defaultObj, { x, y as z } from '...'
1808 var node = this.startNode();
1809 node.local = this.parseIdent();
1810 this.checkLValSimple(node.local, BIND_LEXICAL);
1811 nodes.push(this.finishNode(node, "ImportDefaultSpecifier"));
1812 if (!this.eat(types$1.comma)) { return nodes }
1814 if (this.type === types$1.star) {
1815 var node$1 = this.startNode();
1817 this.expectContextual("as");
1818 node$1.local = this.parseIdent();
1819 this.checkLValSimple(node$1.local, BIND_LEXICAL);
1820 nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier"));
1823 this.expect(types$1.braceL);
1824 while (!this.eat(types$1.braceR)) {
1826 this.expect(types$1.comma);
1827 if (this.afterTrailingComma(types$1.braceR)) { break }
1828 } else { first = false; }
1830 var node$2 = this.startNode();
1831 node$2.imported = this.parseModuleExportName();
1832 if (this.eatContextual("as")) {
1833 node$2.local = this.parseIdent();
1835 this.checkUnreserved(node$2.imported);
1836 node$2.local = node$2.imported;
1838 this.checkLValSimple(node$2.local, BIND_LEXICAL);
1839 nodes.push(this.finishNode(node$2, "ImportSpecifier"));
1844 pp$8.parseModuleExportName = function() {
1845 if (this.options.ecmaVersion >= 13 && this.type === types$1.string) {
1846 var stringLiteral = this.parseLiteral(this.value);
1847 if (loneSurrogate.test(stringLiteral.value)) {
1848 this.raise(stringLiteral.start, "An export name cannot include a lone surrogate.");
1850 return stringLiteral
1852 return this.parseIdent(true)
1855 // Set `ExpressionStatement#directive` property for directive prologues.
1856 pp$8.adaptDirectivePrologue = function(statements) {
1857 for (var i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i) {
1858 statements[i].directive = statements[i].expression.raw.slice(1, -1);
1861 pp$8.isDirectiveCandidate = function(statement) {
1863 statement.type === "ExpressionStatement" &&
1864 statement.expression.type === "Literal" &&
1865 typeof statement.expression.value === "string" &&
1866 // Reject parenthesized strings.
1867 (this.input[statement.start] === "\"" || this.input[statement.start] === "'")
1871 var pp$7 = Parser.prototype;
1873 // Convert existing expression atom to assignable pattern
1876 pp$7.toAssignable = function(node, isBinding, refDestructuringErrors) {
1877 if (this.options.ecmaVersion >= 6 && node) {
1878 switch (node.type) {
1880 if (this.inAsync && node.name === "await")
1881 { this.raise(node.start, "Cannot use 'await' as identifier inside an async function"); }
1884 case "ObjectPattern":
1885 case "ArrayPattern":
1886 case "AssignmentPattern":
1890 case "ObjectExpression":
1891 node.type = "ObjectPattern";
1892 if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
1893 for (var i = 0, list = node.properties; i < list.length; i += 1) {
1896 this.toAssignable(prop, isBinding);
1898 // AssignmentRestProperty[Yield, Await] :
1899 // `...` DestructuringAssignmentTarget[Yield, Await]
1901 // It is a Syntax Error if |DestructuringAssignmentTarget| is an |ArrayLiteral| or an |ObjectLiteral|.
1903 prop.type === "RestElement" &&
1904 (prop.argument.type === "ArrayPattern" || prop.argument.type === "ObjectPattern")
1906 this.raise(prop.argument.start, "Unexpected token");
1912 // AssignmentProperty has type === "Property"
1913 if (node.kind !== "init") { this.raise(node.key.start, "Object pattern can't contain getter or setter"); }
1914 this.toAssignable(node.value, isBinding);
1917 case "ArrayExpression":
1918 node.type = "ArrayPattern";
1919 if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
1920 this.toAssignableList(node.elements, isBinding);
1923 case "SpreadElement":
1924 node.type = "RestElement";
1925 this.toAssignable(node.argument, isBinding);
1926 if (node.argument.type === "AssignmentPattern")
1927 { this.raise(node.argument.start, "Rest elements cannot have a default value"); }
1930 case "AssignmentExpression":
1931 if (node.operator !== "=") { this.raise(node.left.end, "Only '=' operator can be used for specifying default value."); }
1932 node.type = "AssignmentPattern";
1933 delete node.operator;
1934 this.toAssignable(node.left, isBinding);
1937 case "ParenthesizedExpression":
1938 this.toAssignable(node.expression, isBinding, refDestructuringErrors);
1941 case "ChainExpression":
1942 this.raiseRecoverable(node.start, "Optional chaining cannot appear in left-hand side");
1945 case "MemberExpression":
1946 if (!isBinding) { break }
1949 this.raise(node.start, "Assigning to rvalue");
1951 } else if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
1955 // Convert list of expression atoms to binding list.
1957 pp$7.toAssignableList = function(exprList, isBinding) {
1958 var end = exprList.length;
1959 for (var i = 0; i < end; i++) {
1960 var elt = exprList[i];
1961 if (elt) { this.toAssignable(elt, isBinding); }
1964 var last = exprList[end - 1];
1965 if (this.options.ecmaVersion === 6 && isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier")
1966 { this.unexpected(last.argument.start); }
1971 // Parses spread element.
1973 pp$7.parseSpread = function(refDestructuringErrors) {
1974 var node = this.startNode();
1976 node.argument = this.parseMaybeAssign(false, refDestructuringErrors);
1977 return this.finishNode(node, "SpreadElement")
1980 pp$7.parseRestBinding = function() {
1981 var node = this.startNode();
1984 // RestElement inside of a function parameter must be an identifier
1985 if (this.options.ecmaVersion === 6 && this.type !== types$1.name)
1986 { this.unexpected(); }
1988 node.argument = this.parseBindingAtom();
1990 return this.finishNode(node, "RestElement")
1993 // Parses lvalue (assignable) atom.
1995 pp$7.parseBindingAtom = function() {
1996 if (this.options.ecmaVersion >= 6) {
1997 switch (this.type) {
1998 case types$1.bracketL:
1999 var node = this.startNode();
2001 node.elements = this.parseBindingList(types$1.bracketR, true, true);
2002 return this.finishNode(node, "ArrayPattern")
2004 case types$1.braceL:
2005 return this.parseObj(true)
2008 return this.parseIdent()
2011 pp$7.parseBindingList = function(close, allowEmpty, allowTrailingComma) {
2012 var elts = [], first = true;
2013 while (!this.eat(close)) {
2014 if (first) { first = false; }
2015 else { this.expect(types$1.comma); }
2016 if (allowEmpty && this.type === types$1.comma) {
2018 } else if (allowTrailingComma && this.afterTrailingComma(close)) {
2020 } else if (this.type === types$1.ellipsis) {
2021 var rest = this.parseRestBinding();
2022 this.parseBindingListItem(rest);
2024 if (this.type === types$1.comma) { this.raise(this.start, "Comma is not permitted after the rest element"); }
2028 var elem = this.parseMaybeDefault(this.start, this.startLoc);
2029 this.parseBindingListItem(elem);
2036 pp$7.parseBindingListItem = function(param) {
2040 // Parses assignment pattern around given atom if possible.
2042 pp$7.parseMaybeDefault = function(startPos, startLoc, left) {
2043 left = left || this.parseBindingAtom();
2044 if (this.options.ecmaVersion < 6 || !this.eat(types$1.eq)) { return left }
2045 var node = this.startNodeAt(startPos, startLoc);
2047 node.right = this.parseMaybeAssign();
2048 return this.finishNode(node, "AssignmentPattern")
2051 // The following three functions all verify that a node is an lvalue —
2052 // something that can be bound, or assigned to. In order to do so, they perform
2053 // a variety of checks:
2055 // - Check that none of the bound/assigned-to identifiers are reserved words.
2056 // - Record name declarations for bindings in the appropriate scope.
2057 // - Check duplicate argument names, if checkClashes is set.
2059 // If a complex binding pattern is encountered (e.g., object and array
2060 // destructuring), the entire pattern is recursively checked.
2062 // There are three versions of checkLVal*() appropriate for different
2065 // - checkLValSimple() shall be used if the syntactic construct supports
2066 // nothing other than identifiers and member expressions. Parenthesized
2067 // expressions are also correctly handled. This is generally appropriate for
2068 // constructs for which the spec says
2070 // > It is a Syntax Error if AssignmentTargetType of [the production] is not
2073 // It is also appropriate for checking if an identifier is valid and not
2074 // defined elsewhere, like import declarations or function/class identifiers.
2076 // Examples where this is used include:
2078 // import a from '…';
2079 // where a is the node to be checked.
2081 // - checkLValPattern() shall be used if the syntactic construct supports
2082 // anything checkLValSimple() supports, as well as object and array
2083 // destructuring patterns. This is generally appropriate for constructs for
2084 // which the spec says
2086 // > It is a Syntax Error if [the production] is neither an ObjectLiteral nor
2087 // > an ArrayLiteral and AssignmentTargetType of [the production] is not
2090 // Examples where this is used include:
2093 // try { … } catch (a) { … }
2094 // where a is the node to be checked.
2096 // - checkLValInnerPattern() shall be used if the syntactic construct supports
2097 // anything checkLValPattern() supports, as well as default assignment
2098 // patterns, rest elements, and other constructs that may appear within an
2099 // object or array destructuring pattern.
2101 // As a special case, function parameters also use checkLValInnerPattern(),
2102 // as they also support defaults and rest constructs.
2104 // These functions deliberately support both assignment and binding constructs,
2105 // as the logic for both is exceedingly similar. If the node is the target of
2106 // an assignment, then bindingType should be set to BIND_NONE. Otherwise, it
2107 // should be set to the appropriate BIND_* constant, like BIND_VAR or
2110 // If the function is called with a non-BIND_NONE bindingType, then
2111 // additionally a checkClashes object may be specified to allow checking for
2112 // duplicate argument names. checkClashes is ignored if the provided construct
2113 // is an assignment (i.e., bindingType is BIND_NONE).
2115 pp$7.checkLValSimple = function(expr, bindingType, checkClashes) {
2116 if ( bindingType === void 0 ) bindingType = BIND_NONE;
2118 var isBind = bindingType !== BIND_NONE;
2120 switch (expr.type) {
2122 if (this.strict && this.reservedWordsStrictBind.test(expr.name))
2123 { this.raiseRecoverable(expr.start, (isBind ? "Binding " : "Assigning to ") + expr.name + " in strict mode"); }
2125 if (bindingType === BIND_LEXICAL && expr.name === "let")
2126 { this.raiseRecoverable(expr.start, "let is disallowed as a lexically bound name"); }
2128 if (hasOwn(checkClashes, expr.name))
2129 { this.raiseRecoverable(expr.start, "Argument name clash"); }
2130 checkClashes[expr.name] = true;
2132 if (bindingType !== BIND_OUTSIDE) { this.declareName(expr.name, bindingType, expr.start); }
2136 case "ChainExpression":
2137 this.raiseRecoverable(expr.start, "Optional chaining cannot appear in left-hand side");
2140 case "MemberExpression":
2141 if (isBind) { this.raiseRecoverable(expr.start, "Binding member expression"); }
2144 case "ParenthesizedExpression":
2145 if (isBind) { this.raiseRecoverable(expr.start, "Binding parenthesized expression"); }
2146 return this.checkLValSimple(expr.expression, bindingType, checkClashes)
2149 this.raise(expr.start, (isBind ? "Binding" : "Assigning to") + " rvalue");
2153 pp$7.checkLValPattern = function(expr, bindingType, checkClashes) {
2154 if ( bindingType === void 0 ) bindingType = BIND_NONE;
2156 switch (expr.type) {
2157 case "ObjectPattern":
2158 for (var i = 0, list = expr.properties; i < list.length; i += 1) {
2161 this.checkLValInnerPattern(prop, bindingType, checkClashes);
2165 case "ArrayPattern":
2166 for (var i$1 = 0, list$1 = expr.elements; i$1 < list$1.length; i$1 += 1) {
2167 var elem = list$1[i$1];
2169 if (elem) { this.checkLValInnerPattern(elem, bindingType, checkClashes); }
2174 this.checkLValSimple(expr, bindingType, checkClashes);
2178 pp$7.checkLValInnerPattern = function(expr, bindingType, checkClashes) {
2179 if ( bindingType === void 0 ) bindingType = BIND_NONE;
2181 switch (expr.type) {
2183 // AssignmentProperty has type === "Property"
2184 this.checkLValInnerPattern(expr.value, bindingType, checkClashes);
2187 case "AssignmentPattern":
2188 this.checkLValPattern(expr.left, bindingType, checkClashes);
2192 this.checkLValPattern(expr.argument, bindingType, checkClashes);
2196 this.checkLValPattern(expr, bindingType, checkClashes);
2200 // The algorithm used to determine whether a regexp can appear at a
2202 var TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) {
2204 this.isExpr = !!isExpr;
2205 this.preserveSpace = !!preserveSpace;
2206 this.override = override;
2207 this.generator = !!generator;
2211 b_stat: new TokContext("{", false),
2212 b_expr: new TokContext("{", true),
2213 b_tmpl: new TokContext("${", false),
2214 p_stat: new TokContext("(", false),
2215 p_expr: new TokContext("(", true),
2216 q_tmpl: new TokContext("`", true, true, function (p) { return p.tryReadTemplateToken(); }),
2217 f_stat: new TokContext("function", false),
2218 f_expr: new TokContext("function", true),
2219 f_expr_gen: new TokContext("function", true, false, null, true),
2220 f_gen: new TokContext("function", false, false, null, true)
2223 var pp$6 = Parser.prototype;
2225 pp$6.initialContext = function() {
2226 return [types.b_stat]
2229 pp$6.curContext = function() {
2230 return this.context[this.context.length - 1]
2233 pp$6.braceIsBlock = function(prevType) {
2234 var parent = this.curContext();
2235 if (parent === types.f_expr || parent === types.f_stat)
2237 if (prevType === types$1.colon && (parent === types.b_stat || parent === types.b_expr))
2238 { return !parent.isExpr }
2240 // The check for `tt.name && exprAllowed` detects whether we are
2241 // after a `yield` or `of` construct. See the `updateContext` for
2243 if (prevType === types$1._return || prevType === types$1.name && this.exprAllowed)
2244 { return lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) }
2245 if (prevType === types$1._else || prevType === types$1.semi || prevType === types$1.eof || prevType === types$1.parenR || prevType === types$1.arrow)
2247 if (prevType === types$1.braceL)
2248 { return parent === types.b_stat }
2249 if (prevType === types$1._var || prevType === types$1._const || prevType === types$1.name)
2251 return !this.exprAllowed
2254 pp$6.inGeneratorContext = function() {
2255 for (var i = this.context.length - 1; i >= 1; i--) {
2256 var context = this.context[i];
2257 if (context.token === "function")
2258 { return context.generator }
2263 pp$6.updateContext = function(prevType) {
2264 var update, type = this.type;
2265 if (type.keyword && prevType === types$1.dot)
2266 { this.exprAllowed = false; }
2267 else if (update = type.updateContext)
2268 { update.call(this, prevType); }
2270 { this.exprAllowed = type.beforeExpr; }
2273 // Used to handle egde case when token context could not be inferred correctly in tokenize phase
2274 pp$6.overrideContext = function(tokenCtx) {
2275 if (this.curContext() !== tokenCtx) {
2276 this.context[this.context.length - 1] = tokenCtx;
2280 // Token-specific context update code
2282 types$1.parenR.updateContext = types$1.braceR.updateContext = function() {
2283 if (this.context.length === 1) {
2284 this.exprAllowed = true;
2287 var out = this.context.pop();
2288 if (out === types.b_stat && this.curContext().token === "function") {
2289 out = this.context.pop();
2291 this.exprAllowed = !out.isExpr;
2294 types$1.braceL.updateContext = function(prevType) {
2295 this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr);
2296 this.exprAllowed = true;
2299 types$1.dollarBraceL.updateContext = function() {
2300 this.context.push(types.b_tmpl);
2301 this.exprAllowed = true;
2304 types$1.parenL.updateContext = function(prevType) {
2305 var statementParens = prevType === types$1._if || prevType === types$1._for || prevType === types$1._with || prevType === types$1._while;
2306 this.context.push(statementParens ? types.p_stat : types.p_expr);
2307 this.exprAllowed = true;
2310 types$1.incDec.updateContext = function() {
2311 // tokExprAllowed stays unchanged
2314 types$1._function.updateContext = types$1._class.updateContext = function(prevType) {
2315 if (prevType.beforeExpr && prevType !== types$1._else &&
2316 !(prevType === types$1.semi && this.curContext() !== types.p_stat) &&
2317 !(prevType === types$1._return && lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) &&
2318 !((prevType === types$1.colon || prevType === types$1.braceL) && this.curContext() === types.b_stat))
2319 { this.context.push(types.f_expr); }
2321 { this.context.push(types.f_stat); }
2322 this.exprAllowed = false;
2325 types$1.backQuote.updateContext = function() {
2326 if (this.curContext() === types.q_tmpl)
2327 { this.context.pop(); }
2329 { this.context.push(types.q_tmpl); }
2330 this.exprAllowed = false;
2333 types$1.star.updateContext = function(prevType) {
2334 if (prevType === types$1._function) {
2335 var index = this.context.length - 1;
2336 if (this.context[index] === types.f_expr)
2337 { this.context[index] = types.f_expr_gen; }
2339 { this.context[index] = types.f_gen; }
2341 this.exprAllowed = true;
2344 types$1.name.updateContext = function(prevType) {
2345 var allowed = false;
2346 if (this.options.ecmaVersion >= 6 && prevType !== types$1.dot) {
2347 if (this.value === "of" && !this.exprAllowed ||
2348 this.value === "yield" && this.inGeneratorContext())
2351 this.exprAllowed = allowed;
2354 // A recursive descent parser operates by defining functions for all
2356 var pp$5 = Parser.prototype;
2358 // Check if property name clashes with already added.
2359 // Object/class getters and setters are not allowed to clash —
2360 // either with each other or with an init property — and in
2361 // strict mode, init properties are also not allowed to be repeated.
2363 pp$5.checkPropClash = function(prop, propHash, refDestructuringErrors) {
2364 if (this.options.ecmaVersion >= 9 && prop.type === "SpreadElement")
2366 if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand))
2371 case "Identifier": name = key.name; break
2372 case "Literal": name = String(key.value); break
2375 var kind = prop.kind;
2376 if (this.options.ecmaVersion >= 6) {
2377 if (name === "__proto__" && kind === "init") {
2378 if (propHash.proto) {
2379 if (refDestructuringErrors) {
2380 if (refDestructuringErrors.doubleProto < 0) {
2381 refDestructuringErrors.doubleProto = key.start;
2384 this.raiseRecoverable(key.start, "Redefinition of __proto__ property");
2387 propHash.proto = true;
2392 var other = propHash[name];
2395 if (kind === "init") {
2396 redefinition = this.strict && other.init || other.get || other.set;
2398 redefinition = other.init || other[kind];
2401 { this.raiseRecoverable(key.start, "Redefinition of property"); }
2403 other = propHash[name] = {
2412 // ### Expression parsing
2414 // These nest, from the most general expression type at the top to
2415 // 'atomic', nondivisible expression types at the bottom. Most of
2416 // the functions will simply let the function(s) below them parse,
2417 // and, *if* the syntactic construct they handle is present, wrap
2418 // the AST node that the inner parser gave them in another node.
2420 // Parse a full expression. The optional arguments are used to
2421 // forbid the `in` operator (in for loops initalization expressions)
2422 // and provide reference for storing '=' operator inside shorthand
2423 // property assignment in contexts where both object expression
2424 // and object pattern might appear (so it's possible to raise
2425 // delayed syntax error at correct position).
2427 pp$5.parseExpression = function(forInit, refDestructuringErrors) {
2428 var startPos = this.start, startLoc = this.startLoc;
2429 var expr = this.parseMaybeAssign(forInit, refDestructuringErrors);
2430 if (this.type === types$1.comma) {
2431 var node = this.startNodeAt(startPos, startLoc);
2432 node.expressions = [expr];
2433 while (this.eat(types$1.comma)) { node.expressions.push(this.parseMaybeAssign(forInit, refDestructuringErrors)); }
2434 return this.finishNode(node, "SequenceExpression")
2439 // Parse an assignment expression. This includes applications of
2440 // operators like `+=`.
2442 pp$5.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse) {
2443 if (this.isContextual("yield")) {
2444 if (this.inGenerator) { return this.parseYield(forInit) }
2445 // The tokenizer will assume an expression is allowed after
2446 // `yield`, but this isn't that kind of yield
2447 else { this.exprAllowed = false; }
2450 var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1, oldDoubleProto = -1;
2451 if (refDestructuringErrors) {
2452 oldParenAssign = refDestructuringErrors.parenthesizedAssign;
2453 oldTrailingComma = refDestructuringErrors.trailingComma;
2454 oldDoubleProto = refDestructuringErrors.doubleProto;
2455 refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1;
2457 refDestructuringErrors = new DestructuringErrors;
2458 ownDestructuringErrors = true;
2461 var startPos = this.start, startLoc = this.startLoc;
2462 if (this.type === types$1.parenL || this.type === types$1.name) {
2463 this.potentialArrowAt = this.start;
2464 this.potentialArrowInForAwait = forInit === "await";
2466 var left = this.parseMaybeConditional(forInit, refDestructuringErrors);
2467 if (afterLeftParse) { left = afterLeftParse.call(this, left, startPos, startLoc); }
2468 if (this.type.isAssign) {
2469 var node = this.startNodeAt(startPos, startLoc);
2470 node.operator = this.value;
2471 if (this.type === types$1.eq)
2472 { left = this.toAssignable(left, false, refDestructuringErrors); }
2473 if (!ownDestructuringErrors) {
2474 refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.doubleProto = -1;
2476 if (refDestructuringErrors.shorthandAssign >= left.start)
2477 { refDestructuringErrors.shorthandAssign = -1; } // reset because shorthand default was used correctly
2478 if (this.type === types$1.eq)
2479 { this.checkLValPattern(left); }
2481 { this.checkLValSimple(left); }
2484 node.right = this.parseMaybeAssign(forInit);
2485 if (oldDoubleProto > -1) { refDestructuringErrors.doubleProto = oldDoubleProto; }
2486 return this.finishNode(node, "AssignmentExpression")
2488 if (ownDestructuringErrors) { this.checkExpressionErrors(refDestructuringErrors, true); }
2490 if (oldParenAssign > -1) { refDestructuringErrors.parenthesizedAssign = oldParenAssign; }
2491 if (oldTrailingComma > -1) { refDestructuringErrors.trailingComma = oldTrailingComma; }
2495 // Parse a ternary conditional (`?:`) operator.
2497 pp$5.parseMaybeConditional = function(forInit, refDestructuringErrors) {
2498 var startPos = this.start, startLoc = this.startLoc;
2499 var expr = this.parseExprOps(forInit, refDestructuringErrors);
2500 if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
2501 if (this.eat(types$1.question)) {
2502 var node = this.startNodeAt(startPos, startLoc);
2504 node.consequent = this.parseMaybeAssign();
2505 this.expect(types$1.colon);
2506 node.alternate = this.parseMaybeAssign(forInit);
2507 return this.finishNode(node, "ConditionalExpression")
2512 // Start the precedence parser.
2514 pp$5.parseExprOps = function(forInit, refDestructuringErrors) {
2515 var startPos = this.start, startLoc = this.startLoc;
2516 var expr = this.parseMaybeUnary(refDestructuringErrors, false, false, forInit);
2517 if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
2518 return expr.start === startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, forInit)
2521 // Parse binary operators with the operator precedence parsing
2522 // algorithm. `left` is the left-hand side of the operator.
2523 // `minPrec` provides context that allows the function to stop and
2524 // defer further parser to one of its callers when it encounters an
2525 // operator that has a lower precedence than the set it is parsing.
2527 pp$5.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, forInit) {
2528 var prec = this.type.binop;
2529 if (prec != null && (!forInit || this.type !== types$1._in)) {
2530 if (prec > minPrec) {
2531 var logical = this.type === types$1.logicalOR || this.type === types$1.logicalAND;
2532 var coalesce = this.type === types$1.coalesce;
2534 // Handle the precedence of `tt.coalesce` as equal to the range of logical expressions.
2535 // In other words, `node.right` shouldn't contain logical expressions in order to check the mixed error.
2536 prec = types$1.logicalAND.binop;
2538 var op = this.value;
2540 var startPos = this.start, startLoc = this.startLoc;
2541 var right = this.parseExprOp(this.parseMaybeUnary(null, false, false, forInit), startPos, startLoc, prec, forInit);
2542 var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical || coalesce);
2543 if ((logical && this.type === types$1.coalesce) || (coalesce && (this.type === types$1.logicalOR || this.type === types$1.logicalAND))) {
2544 this.raiseRecoverable(this.start, "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses");
2546 return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, forInit)
2552 pp$5.buildBinary = function(startPos, startLoc, left, right, op, logical) {
2553 if (right.type === "PrivateIdentifier") { this.raise(right.start, "Private identifier can only be left side of binary expression"); }
2554 var node = this.startNodeAt(startPos, startLoc);
2558 return this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression")
2561 // Parse unary operators, both prefix and postfix.
2563 pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forInit) {
2564 var startPos = this.start, startLoc = this.startLoc, expr;
2565 if (this.isContextual("await") && this.canAwait) {
2566 expr = this.parseAwait(forInit);
2568 } else if (this.type.prefix) {
2569 var node = this.startNode(), update = this.type === types$1.incDec;
2570 node.operator = this.value;
2573 node.argument = this.parseMaybeUnary(null, true, update, forInit);
2574 this.checkExpressionErrors(refDestructuringErrors, true);
2575 if (update) { this.checkLValSimple(node.argument); }
2576 else if (this.strict && node.operator === "delete" &&
2577 node.argument.type === "Identifier")
2578 { this.raiseRecoverable(node.start, "Deleting local variable in strict mode"); }
2579 else if (node.operator === "delete" && isPrivateFieldAccess(node.argument))
2580 { this.raiseRecoverable(node.start, "Private fields can not be deleted"); }
2581 else { sawUnary = true; }
2582 expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
2583 } else if (!sawUnary && this.type === types$1.privateId) {
2584 if (forInit || this.privateNameStack.length === 0) { this.unexpected(); }
2585 expr = this.parsePrivateIdent();
2586 // only could be private fields in 'in', such as #x in obj
2587 if (this.type !== types$1._in) { this.unexpected(); }
2589 expr = this.parseExprSubscripts(refDestructuringErrors, forInit);
2590 if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
2591 while (this.type.postfix && !this.canInsertSemicolon()) {
2592 var node$1 = this.startNodeAt(startPos, startLoc);
2593 node$1.operator = this.value;
2594 node$1.prefix = false;
2595 node$1.argument = expr;
2596 this.checkLValSimple(expr);
2598 expr = this.finishNode(node$1, "UpdateExpression");
2602 if (!incDec && this.eat(types$1.starstar)) {
2604 { this.unexpected(this.lastTokStart); }
2606 { return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false, false, forInit), "**", false) }
2612 function isPrivateFieldAccess(node) {
2614 node.type === "MemberExpression" && node.property.type === "PrivateIdentifier" ||
2615 node.type === "ChainExpression" && isPrivateFieldAccess(node.expression)
2619 // Parse call, dot, and `[]`-subscript expressions.
2621 pp$5.parseExprSubscripts = function(refDestructuringErrors, forInit) {
2622 var startPos = this.start, startLoc = this.startLoc;
2623 var expr = this.parseExprAtom(refDestructuringErrors, forInit);
2624 if (expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")")
2626 var result = this.parseSubscripts(expr, startPos, startLoc, false, forInit);
2627 if (refDestructuringErrors && result.type === "MemberExpression") {
2628 if (refDestructuringErrors.parenthesizedAssign >= result.start) { refDestructuringErrors.parenthesizedAssign = -1; }
2629 if (refDestructuringErrors.parenthesizedBind >= result.start) { refDestructuringErrors.parenthesizedBind = -1; }
2630 if (refDestructuringErrors.trailingComma >= result.start) { refDestructuringErrors.trailingComma = -1; }
2635 pp$5.parseSubscripts = function(base, startPos, startLoc, noCalls, forInit) {
2636 var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" &&
2637 this.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 &&
2638 this.potentialArrowAt === base.start;
2639 var optionalChained = false;
2642 var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit);
2644 if (element.optional) { optionalChained = true; }
2645 if (element === base || element.type === "ArrowFunctionExpression") {
2646 if (optionalChained) {
2647 var chainNode = this.startNodeAt(startPos, startLoc);
2648 chainNode.expression = element;
2649 element = this.finishNode(chainNode, "ChainExpression");
2658 pp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit) {
2659 var optionalSupported = this.options.ecmaVersion >= 11;
2660 var optional = optionalSupported && this.eat(types$1.questionDot);
2661 if (noCalls && optional) { this.raise(this.lastTokStart, "Optional chaining cannot appear in the callee of new expressions"); }
2663 var computed = this.eat(types$1.bracketL);
2664 if (computed || (optional && this.type !== types$1.parenL && this.type !== types$1.backQuote) || this.eat(types$1.dot)) {
2665 var node = this.startNodeAt(startPos, startLoc);
2668 node.property = this.parseExpression();
2669 this.expect(types$1.bracketR);
2670 } else if (this.type === types$1.privateId && base.type !== "Super") {
2671 node.property = this.parsePrivateIdent();
2673 node.property = this.parseIdent(this.options.allowReserved !== "never");
2675 node.computed = !!computed;
2676 if (optionalSupported) {
2677 node.optional = optional;
2679 base = this.finishNode(node, "MemberExpression");
2680 } else if (!noCalls && this.eat(types$1.parenL)) {
2681 var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
2684 this.awaitIdentPos = 0;
2685 var exprList = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors);
2686 if (maybeAsyncArrow && !optional && !this.canInsertSemicolon() && this.eat(types$1.arrow)) {
2687 this.checkPatternErrors(refDestructuringErrors, false);
2688 this.checkYieldAwaitInDefaultParams();
2689 if (this.awaitIdentPos > 0)
2690 { this.raise(this.awaitIdentPos, "Cannot use 'await' as identifier inside an async function"); }
2691 this.yieldPos = oldYieldPos;
2692 this.awaitPos = oldAwaitPos;
2693 this.awaitIdentPos = oldAwaitIdentPos;
2694 return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true, forInit)
2696 this.checkExpressionErrors(refDestructuringErrors, true);
2697 this.yieldPos = oldYieldPos || this.yieldPos;
2698 this.awaitPos = oldAwaitPos || this.awaitPos;
2699 this.awaitIdentPos = oldAwaitIdentPos || this.awaitIdentPos;
2700 var node$1 = this.startNodeAt(startPos, startLoc);
2701 node$1.callee = base;
2702 node$1.arguments = exprList;
2703 if (optionalSupported) {
2704 node$1.optional = optional;
2706 base = this.finishNode(node$1, "CallExpression");
2707 } else if (this.type === types$1.backQuote) {
2708 if (optional || optionalChained) {
2709 this.raise(this.start, "Optional chaining cannot appear in the tag of tagged template expressions");
2711 var node$2 = this.startNodeAt(startPos, startLoc);
2713 node$2.quasi = this.parseTemplate({isTagged: true});
2714 base = this.finishNode(node$2, "TaggedTemplateExpression");
2719 // Parse an atomic expression — either a single token that is an
2720 // expression, an expression started by a keyword like `function` or
2721 // `new`, or an expression wrapped in punctuation like `()`, `[]`,
2724 pp$5.parseExprAtom = function(refDestructuringErrors, forInit) {
2725 // If a division operator appears in an expression position, the
2726 // tokenizer got confused, and we force it to read a regexp instead.
2727 if (this.type === types$1.slash) { this.readRegexp(); }
2729 var node, canBeArrow = this.potentialArrowAt === this.start;
2730 switch (this.type) {
2731 case types$1._super:
2732 if (!this.allowSuper)
2733 { this.raise(this.start, "'super' keyword outside a method"); }
2734 node = this.startNode();
2736 if (this.type === types$1.parenL && !this.allowDirectSuper)
2737 { this.raise(node.start, "super() call outside constructor of a subclass"); }
2738 // The `super` keyword can appear at below:
2740 // super [ Expression ]
2741 // super . IdentifierName
2743 // super ( Arguments )
2744 if (this.type !== types$1.dot && this.type !== types$1.bracketL && this.type !== types$1.parenL)
2745 { this.unexpected(); }
2746 return this.finishNode(node, "Super")
2749 node = this.startNode();
2751 return this.finishNode(node, "ThisExpression")
2754 var startPos = this.start, startLoc = this.startLoc, containsEsc = this.containsEsc;
2755 var id = this.parseIdent(false);
2756 if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === "async" && !this.canInsertSemicolon() && this.eat(types$1._function)) {
2757 this.overrideContext(types.f_expr);
2758 return this.parseFunction(this.startNodeAt(startPos, startLoc), 0, false, true, forInit)
2760 if (canBeArrow && !this.canInsertSemicolon()) {
2761 if (this.eat(types$1.arrow))
2762 { return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false, forInit) }
2763 if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === types$1.name && !containsEsc &&
2764 (!this.potentialArrowInForAwait || this.value !== "of" || this.containsEsc)) {
2765 id = this.parseIdent(false);
2766 if (this.canInsertSemicolon() || !this.eat(types$1.arrow))
2767 { this.unexpected(); }
2768 return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true, forInit)
2773 case types$1.regexp:
2774 var value = this.value;
2775 node = this.parseLiteral(value.value);
2776 node.regex = {pattern: value.pattern, flags: value.flags};
2779 case types$1.num: case types$1.string:
2780 return this.parseLiteral(this.value)
2782 case types$1._null: case types$1._true: case types$1._false:
2783 node = this.startNode();
2784 node.value = this.type === types$1._null ? null : this.type === types$1._true;
2785 node.raw = this.type.keyword;
2787 return this.finishNode(node, "Literal")
2789 case types$1.parenL:
2790 var start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow, forInit);
2791 if (refDestructuringErrors) {
2792 if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr))
2793 { refDestructuringErrors.parenthesizedAssign = start; }
2794 if (refDestructuringErrors.parenthesizedBind < 0)
2795 { refDestructuringErrors.parenthesizedBind = start; }
2799 case types$1.bracketL:
2800 node = this.startNode();
2802 node.elements = this.parseExprList(types$1.bracketR, true, true, refDestructuringErrors);
2803 return this.finishNode(node, "ArrayExpression")
2805 case types$1.braceL:
2806 this.overrideContext(types.b_expr);
2807 return this.parseObj(false, refDestructuringErrors)
2809 case types$1._function:
2810 node = this.startNode();
2812 return this.parseFunction(node, 0)
2814 case types$1._class:
2815 return this.parseClass(this.startNode(), false)
2818 return this.parseNew()
2820 case types$1.backQuote:
2821 return this.parseTemplate()
2823 case types$1._import:
2824 if (this.options.ecmaVersion >= 11) {
2825 return this.parseExprImport()
2827 return this.unexpected()
2835 pp$5.parseExprImport = function() {
2836 var node = this.startNode();
2838 // Consume `import` as an identifier for `import.meta`.
2839 // Because `this.parseIdent(true)` doesn't check escape sequences, it needs the check of `this.containsEsc`.
2840 if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword import"); }
2841 var meta = this.parseIdent(true);
2843 switch (this.type) {
2844 case types$1.parenL:
2845 return this.parseDynamicImport(node)
2848 return this.parseImportMeta(node)
2854 pp$5.parseDynamicImport = function(node) {
2855 this.next(); // skip `(`
2857 // Parse node.source.
2858 node.source = this.parseMaybeAssign();
2861 if (!this.eat(types$1.parenR)) {
2862 var errorPos = this.start;
2863 if (this.eat(types$1.comma) && this.eat(types$1.parenR)) {
2864 this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()");
2866 this.unexpected(errorPos);
2870 return this.finishNode(node, "ImportExpression")
2873 pp$5.parseImportMeta = function(node) {
2874 this.next(); // skip `.`
2876 var containsEsc = this.containsEsc;
2877 node.property = this.parseIdent(true);
2879 if (node.property.name !== "meta")
2880 { this.raiseRecoverable(node.property.start, "The only valid meta property for import is 'import.meta'"); }
2882 { this.raiseRecoverable(node.start, "'import.meta' must not contain escaped characters"); }
2883 if (this.options.sourceType !== "module" && !this.options.allowImportExportEverywhere)
2884 { this.raiseRecoverable(node.start, "Cannot use 'import.meta' outside a module"); }
2886 return this.finishNode(node, "MetaProperty")
2889 pp$5.parseLiteral = function(value) {
2890 var node = this.startNode();
2892 node.raw = this.input.slice(this.start, this.end);
2893 if (node.raw.charCodeAt(node.raw.length - 1) === 110) { node.bigint = node.raw.slice(0, -1).replace(/_/g, ""); }
2895 return this.finishNode(node, "Literal")
2898 pp$5.parseParenExpression = function() {
2899 this.expect(types$1.parenL);
2900 var val = this.parseExpression();
2901 this.expect(types$1.parenR);
2905 pp$5.parseParenAndDistinguishExpression = function(canBeArrow, forInit) {
2906 var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8;
2907 if (this.options.ecmaVersion >= 6) {
2910 var innerStartPos = this.start, innerStartLoc = this.startLoc;
2911 var exprList = [], first = true, lastIsComma = false;
2912 var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart;
2915 // Do not save awaitIdentPos to allow checking awaits nested in parameters
2916 while (this.type !== types$1.parenR) {
2917 first ? first = false : this.expect(types$1.comma);
2918 if (allowTrailingComma && this.afterTrailingComma(types$1.parenR, true)) {
2921 } else if (this.type === types$1.ellipsis) {
2922 spreadStart = this.start;
2923 exprList.push(this.parseParenItem(this.parseRestBinding()));
2924 if (this.type === types$1.comma) { this.raise(this.start, "Comma is not permitted after the rest element"); }
2927 exprList.push(this.parseMaybeAssign(false, refDestructuringErrors, this.parseParenItem));
2930 var innerEndPos = this.lastTokEnd, innerEndLoc = this.lastTokEndLoc;
2931 this.expect(types$1.parenR);
2933 if (canBeArrow && !this.canInsertSemicolon() && this.eat(types$1.arrow)) {
2934 this.checkPatternErrors(refDestructuringErrors, false);
2935 this.checkYieldAwaitInDefaultParams();
2936 this.yieldPos = oldYieldPos;
2937 this.awaitPos = oldAwaitPos;
2938 return this.parseParenArrowList(startPos, startLoc, exprList, forInit)
2941 if (!exprList.length || lastIsComma) { this.unexpected(this.lastTokStart); }
2942 if (spreadStart) { this.unexpected(spreadStart); }
2943 this.checkExpressionErrors(refDestructuringErrors, true);
2944 this.yieldPos = oldYieldPos || this.yieldPos;
2945 this.awaitPos = oldAwaitPos || this.awaitPos;
2947 if (exprList.length > 1) {
2948 val = this.startNodeAt(innerStartPos, innerStartLoc);
2949 val.expressions = exprList;
2950 this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc);
2955 val = this.parseParenExpression();
2958 if (this.options.preserveParens) {
2959 var par = this.startNodeAt(startPos, startLoc);
2960 par.expression = val;
2961 return this.finishNode(par, "ParenthesizedExpression")
2967 pp$5.parseParenItem = function(item) {
2971 pp$5.parseParenArrowList = function(startPos, startLoc, exprList, forInit) {
2972 return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, false, forInit)
2975 // New's precedence is slightly tricky. It must allow its argument to
2976 // be a `[]` or dot subscript expression, but not a call — at least,
2977 // not without wrapping it in parentheses. Thus, it uses the noCalls
2978 // argument to parseSubscripts to prevent it from consuming the
2983 pp$5.parseNew = function() {
2984 if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword new"); }
2985 var node = this.startNode();
2986 var meta = this.parseIdent(true);
2987 if (this.options.ecmaVersion >= 6 && this.eat(types$1.dot)) {
2989 var containsEsc = this.containsEsc;
2990 node.property = this.parseIdent(true);
2991 if (node.property.name !== "target")
2992 { this.raiseRecoverable(node.property.start, "The only valid meta property for new is 'new.target'"); }
2994 { this.raiseRecoverable(node.start, "'new.target' must not contain escaped characters"); }
2995 if (!this.allowNewDotTarget)
2996 { this.raiseRecoverable(node.start, "'new.target' can only be used in functions and class static block"); }
2997 return this.finishNode(node, "MetaProperty")
2999 var startPos = this.start, startLoc = this.startLoc, isImport = this.type === types$1._import;
3000 node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true, false);
3001 if (isImport && node.callee.type === "ImportExpression") {
3002 this.raise(startPos, "Cannot use new with import()");
3004 if (this.eat(types$1.parenL)) { node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false); }
3005 else { node.arguments = empty; }
3006 return this.finishNode(node, "NewExpression")
3009 // Parse template expression.
3011 pp$5.parseTemplateElement = function(ref) {
3012 var isTagged = ref.isTagged;
3014 var elem = this.startNode();
3015 if (this.type === types$1.invalidTemplate) {
3017 this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal");
3025 raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, "\n"),
3030 elem.tail = this.type === types$1.backQuote;
3031 return this.finishNode(elem, "TemplateElement")
3034 pp$5.parseTemplate = function(ref) {
3035 if ( ref === void 0 ) ref = {};
3036 var isTagged = ref.isTagged; if ( isTagged === void 0 ) isTagged = false;
3038 var node = this.startNode();
3040 node.expressions = [];
3041 var curElt = this.parseTemplateElement({isTagged: isTagged});
3042 node.quasis = [curElt];
3043 while (!curElt.tail) {
3044 if (this.type === types$1.eof) { this.raise(this.pos, "Unterminated template literal"); }
3045 this.expect(types$1.dollarBraceL);
3046 node.expressions.push(this.parseExpression());
3047 this.expect(types$1.braceR);
3048 node.quasis.push(curElt = this.parseTemplateElement({isTagged: isTagged}));
3051 return this.finishNode(node, "TemplateLiteral")
3054 pp$5.isAsyncProp = function(prop) {
3055 return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" &&
3056 (this.type === types$1.name || this.type === types$1.num || this.type === types$1.string || this.type === types$1.bracketL || this.type.keyword || (this.options.ecmaVersion >= 9 && this.type === types$1.star)) &&
3057 !lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
3060 // Parse an object literal or binding pattern.
3062 pp$5.parseObj = function(isPattern, refDestructuringErrors) {
3063 var node = this.startNode(), first = true, propHash = {};
3064 node.properties = [];
3066 while (!this.eat(types$1.braceR)) {
3068 this.expect(types$1.comma);
3069 if (this.options.ecmaVersion >= 5 && this.afterTrailingComma(types$1.braceR)) { break }
3070 } else { first = false; }
3072 var prop = this.parseProperty(isPattern, refDestructuringErrors);
3073 if (!isPattern) { this.checkPropClash(prop, propHash, refDestructuringErrors); }
3074 node.properties.push(prop);
3076 return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression")
3079 pp$5.parseProperty = function(isPattern, refDestructuringErrors) {
3080 var prop = this.startNode(), isGenerator, isAsync, startPos, startLoc;
3081 if (this.options.ecmaVersion >= 9 && this.eat(types$1.ellipsis)) {
3083 prop.argument = this.parseIdent(false);
3084 if (this.type === types$1.comma) {
3085 this.raise(this.start, "Comma is not permitted after the rest element");
3087 return this.finishNode(prop, "RestElement")
3089 // To disallow parenthesized identifier via `this.toAssignable()`.
3090 if (this.type === types$1.parenL && refDestructuringErrors) {
3091 if (refDestructuringErrors.parenthesizedAssign < 0) {
3092 refDestructuringErrors.parenthesizedAssign = this.start;
3094 if (refDestructuringErrors.parenthesizedBind < 0) {
3095 refDestructuringErrors.parenthesizedBind = this.start;
3099 prop.argument = this.parseMaybeAssign(false, refDestructuringErrors);
3100 // To disallow trailing comma via `this.toAssignable()`.
3101 if (this.type === types$1.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0) {
3102 refDestructuringErrors.trailingComma = this.start;
3105 return this.finishNode(prop, "SpreadElement")
3107 if (this.options.ecmaVersion >= 6) {
3108 prop.method = false;
3109 prop.shorthand = false;
3110 if (isPattern || refDestructuringErrors) {
3111 startPos = this.start;
3112 startLoc = this.startLoc;
3115 { isGenerator = this.eat(types$1.star); }
3117 var containsEsc = this.containsEsc;
3118 this.parsePropertyName(prop);
3119 if (!isPattern && !containsEsc && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) {
3121 isGenerator = this.options.ecmaVersion >= 9 && this.eat(types$1.star);
3122 this.parsePropertyName(prop, refDestructuringErrors);
3126 this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc);
3127 return this.finishNode(prop, "Property")
3130 pp$5.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) {
3131 if ((isGenerator || isAsync) && this.type === types$1.colon)
3132 { this.unexpected(); }
3134 if (this.eat(types$1.colon)) {
3135 prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors);
3137 } else if (this.options.ecmaVersion >= 6 && this.type === types$1.parenL) {
3138 if (isPattern) { this.unexpected(); }
3141 prop.value = this.parseMethod(isGenerator, isAsync);
3142 } else if (!isPattern && !containsEsc &&
3143 this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" &&
3144 (prop.key.name === "get" || prop.key.name === "set") &&
3145 (this.type !== types$1.comma && this.type !== types$1.braceR && this.type !== types$1.eq)) {
3146 if (isGenerator || isAsync) { this.unexpected(); }
3147 prop.kind = prop.key.name;
3148 this.parsePropertyName(prop);
3149 prop.value = this.parseMethod(false);
3150 var paramCount = prop.kind === "get" ? 0 : 1;
3151 if (prop.value.params.length !== paramCount) {
3152 var start = prop.value.start;
3153 if (prop.kind === "get")
3154 { this.raiseRecoverable(start, "getter should have no params"); }
3156 { this.raiseRecoverable(start, "setter should have exactly one param"); }
3158 if (prop.kind === "set" && prop.value.params[0].type === "RestElement")
3159 { this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params"); }
3161 } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
3162 if (isGenerator || isAsync) { this.unexpected(); }
3163 this.checkUnreserved(prop.key);
3164 if (prop.key.name === "await" && !this.awaitIdentPos)
3165 { this.awaitIdentPos = startPos; }
3168 prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key));
3169 } else if (this.type === types$1.eq && refDestructuringErrors) {
3170 if (refDestructuringErrors.shorthandAssign < 0)
3171 { refDestructuringErrors.shorthandAssign = this.start; }
3172 prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key));
3174 prop.value = this.copyNode(prop.key);
3176 prop.shorthand = true;
3177 } else { this.unexpected(); }
3180 pp$5.parsePropertyName = function(prop) {
3181 if (this.options.ecmaVersion >= 6) {
3182 if (this.eat(types$1.bracketL)) {
3183 prop.computed = true;
3184 prop.key = this.parseMaybeAssign();
3185 this.expect(types$1.bracketR);
3188 prop.computed = false;
3191 return prop.key = this.type === types$1.num || this.type === types$1.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never")
3194 // Initialize empty function node.
3196 pp$5.initFunction = function(node) {
3198 if (this.options.ecmaVersion >= 6) { node.generator = node.expression = false; }
3199 if (this.options.ecmaVersion >= 8) { node.async = false; }
3202 // Parse object or class method.
3204 pp$5.parseMethod = function(isGenerator, isAsync, allowDirectSuper) {
3205 var node = this.startNode(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
3207 this.initFunction(node);
3208 if (this.options.ecmaVersion >= 6)
3209 { node.generator = isGenerator; }
3210 if (this.options.ecmaVersion >= 8)
3211 { node.async = !!isAsync; }
3215 this.awaitIdentPos = 0;
3216 this.enterScope(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0));
3218 this.expect(types$1.parenL);
3219 node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8);
3220 this.checkYieldAwaitInDefaultParams();
3221 this.parseFunctionBody(node, false, true, false);
3223 this.yieldPos = oldYieldPos;
3224 this.awaitPos = oldAwaitPos;
3225 this.awaitIdentPos = oldAwaitIdentPos;
3226 return this.finishNode(node, "FunctionExpression")
3229 // Parse arrow function expression with given parameters.
3231 pp$5.parseArrowExpression = function(node, params, isAsync, forInit) {
3232 var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
3234 this.enterScope(functionFlags(isAsync, false) | SCOPE_ARROW);
3235 this.initFunction(node);
3236 if (this.options.ecmaVersion >= 8) { node.async = !!isAsync; }
3240 this.awaitIdentPos = 0;
3242 node.params = this.toAssignableList(params, true);
3243 this.parseFunctionBody(node, true, false, forInit);
3245 this.yieldPos = oldYieldPos;
3246 this.awaitPos = oldAwaitPos;
3247 this.awaitIdentPos = oldAwaitIdentPos;
3248 return this.finishNode(node, "ArrowFunctionExpression")
3251 // Parse function body and check parameters.
3253 pp$5.parseFunctionBody = function(node, isArrowFunction, isMethod, forInit) {
3254 var isExpression = isArrowFunction && this.type !== types$1.braceL;
3255 var oldStrict = this.strict, useStrict = false;
3258 node.body = this.parseMaybeAssign(forInit);
3259 node.expression = true;
3260 this.checkParams(node, false);
3262 var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params);
3263 if (!oldStrict || nonSimple) {
3264 useStrict = this.strictDirective(this.end);
3265 // If this is a strict mode function, verify that argument names
3266 // are not repeated, and it does not try to bind the words `eval`
3268 if (useStrict && nonSimple)
3269 { this.raiseRecoverable(node.start, "Illegal 'use strict' directive in function with non-simple parameter list"); }
3271 // Start a new scope with regard to labels and the `inFunction`
3272 // flag (restore them to their old value afterwards).
3273 var oldLabels = this.labels;
3275 if (useStrict) { this.strict = true; }
3277 // Add the params to varDeclaredNames to ensure that an error is thrown
3278 // if a let/const declaration in the function clashes with one of the params.
3279 this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params));
3280 // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval'
3281 if (this.strict && node.id) { this.checkLValSimple(node.id, BIND_OUTSIDE); }
3282 node.body = this.parseBlock(false, undefined, useStrict && !oldStrict);
3283 node.expression = false;
3284 this.adaptDirectivePrologue(node.body.body);
3285 this.labels = oldLabels;
3290 pp$5.isSimpleParamList = function(params) {
3291 for (var i = 0, list = params; i < list.length; i += 1)
3293 var param = list[i];
3295 if (param.type !== "Identifier") { return false
3300 // Checks function params for various disallowed patterns such as using "eval"
3301 // or "arguments" and duplicate parameters.
3303 pp$5.checkParams = function(node, allowDuplicates) {
3304 var nameHash = Object.create(null);
3305 for (var i = 0, list = node.params; i < list.length; i += 1)
3307 var param = list[i];
3309 this.checkLValInnerPattern(param, BIND_VAR, allowDuplicates ? null : nameHash);
3313 // Parses a comma-separated list of expressions, and returns them as
3314 // an array. `close` is the token type that ends the list, and
3315 // `allowEmpty` can be turned on to allow subsequent commas with
3316 // nothing in between them to be parsed as `null` (which is needed
3317 // for array literals).
3319 pp$5.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) {
3320 var elts = [], first = true;
3321 while (!this.eat(close)) {
3323 this.expect(types$1.comma);
3324 if (allowTrailingComma && this.afterTrailingComma(close)) { break }
3325 } else { first = false; }
3328 if (allowEmpty && this.type === types$1.comma)
3330 else if (this.type === types$1.ellipsis) {
3331 elt = this.parseSpread(refDestructuringErrors);
3332 if (refDestructuringErrors && this.type === types$1.comma && refDestructuringErrors.trailingComma < 0)
3333 { refDestructuringErrors.trailingComma = this.start; }
3335 elt = this.parseMaybeAssign(false, refDestructuringErrors);
3342 pp$5.checkUnreserved = function(ref) {
3343 var start = ref.start;
3345 var name = ref.name;
3347 if (this.inGenerator && name === "yield")
3348 { this.raiseRecoverable(start, "Cannot use 'yield' as identifier inside a generator"); }
3349 if (this.inAsync && name === "await")
3350 { this.raiseRecoverable(start, "Cannot use 'await' as identifier inside an async function"); }
3351 if (this.currentThisScope().inClassFieldInit && name === "arguments")
3352 { this.raiseRecoverable(start, "Cannot use 'arguments' in class field initializer"); }
3353 if (this.inClassStaticBlock && (name === "arguments" || name === "await"))
3354 { this.raise(start, ("Cannot use " + name + " in class static initialization block")); }
3355 if (this.keywords.test(name))
3356 { this.raise(start, ("Unexpected keyword '" + name + "'")); }
3357 if (this.options.ecmaVersion < 6 &&
3358 this.input.slice(start, end).indexOf("\\") !== -1) { return }
3359 var re = this.strict ? this.reservedWordsStrict : this.reservedWords;
3360 if (re.test(name)) {
3361 if (!this.inAsync && name === "await")
3362 { this.raiseRecoverable(start, "Cannot use keyword 'await' outside an async function"); }
3363 this.raiseRecoverable(start, ("The keyword '" + name + "' is reserved"));
3367 // Parse the next token as an identifier. If `liberal` is true (used
3368 // when parsing properties), it will also convert keywords into
3371 pp$5.parseIdent = function(liberal, isBinding) {
3372 var node = this.startNode();
3373 if (this.type === types$1.name) {
3374 node.name = this.value;
3375 } else if (this.type.keyword) {
3376 node.name = this.type.keyword;
3378 // To fix https://github.com/acornjs/acorn/issues/575
3379 // `class` and `function` keywords push new context into this.context.
3380 // But there is no chance to pop the context if the keyword is consumed as an identifier such as a property name.
3381 // If the previous token is a dot, this does not apply because the context-managing code already ignored the keyword
3382 if ((node.name === "class" || node.name === "function") &&
3383 (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) {
3389 this.next(!!liberal);
3390 this.finishNode(node, "Identifier");
3392 this.checkUnreserved(node);
3393 if (node.name === "await" && !this.awaitIdentPos)
3394 { this.awaitIdentPos = node.start; }
3399 pp$5.parsePrivateIdent = function() {
3400 var node = this.startNode();
3401 if (this.type === types$1.privateId) {
3402 node.name = this.value;
3407 this.finishNode(node, "PrivateIdentifier");
3409 // For validating existence
3410 if (this.privateNameStack.length === 0) {
3411 this.raise(node.start, ("Private field '#" + (node.name) + "' must be declared in an enclosing class"));
3413 this.privateNameStack[this.privateNameStack.length - 1].used.push(node);
3419 // Parses yield expression inside generator.
3421 pp$5.parseYield = function(forInit) {
3422 if (!this.yieldPos) { this.yieldPos = this.start; }
3424 var node = this.startNode();
3426 if (this.type === types$1.semi || this.canInsertSemicolon() || (this.type !== types$1.star && !this.type.startsExpr)) {
3427 node.delegate = false;
3428 node.argument = null;
3430 node.delegate = this.eat(types$1.star);
3431 node.argument = this.parseMaybeAssign(forInit);
3433 return this.finishNode(node, "YieldExpression")
3436 pp$5.parseAwait = function(forInit) {
3437 if (!this.awaitPos) { this.awaitPos = this.start; }
3439 var node = this.startNode();
3441 node.argument = this.parseMaybeUnary(null, true, false, forInit);
3442 return this.finishNode(node, "AwaitExpression")
3445 var pp$4 = Parser.prototype;
3447 // This function is used to raise exceptions on parse errors. It
3448 // takes an offset integer (into the current `input`) to indicate
3449 // the location of the error, attaches the position to the end
3450 // of the error message, and then raises a `SyntaxError` with that
3453 pp$4.raise = function(pos, message) {
3454 var loc = getLineInfo(this.input, pos);
3455 message += " (" + loc.line + ":" + loc.column + ")";
3456 var err = new SyntaxError(message);
3457 err.pos = pos; err.loc = loc; err.raisedAt = this.pos;
3461 pp$4.raiseRecoverable = pp$4.raise;
3463 pp$4.curPosition = function() {
3464 if (this.options.locations) {
3465 return new Position(this.curLine, this.pos - this.lineStart)
3469 var pp$3 = Parser.prototype;
3471 var Scope = function Scope(flags) {
3473 // A list of var-declared names in the current lexical scope
3475 // A list of lexically-declared names in the current lexical scope
3477 // A list of lexically-declared FunctionDeclaration names in the current lexical scope
3478 this.functions = [];
3479 // A switch to disallow the identifier reference 'arguments'
3480 this.inClassFieldInit = false;
3483 // The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names.
3485 pp$3.enterScope = function(flags) {
3486 this.scopeStack.push(new Scope(flags));
3489 pp$3.exitScope = function() {
3490 this.scopeStack.pop();
3494 // > At the top level of a function, or script, function declarations are
3495 // > treated like var declarations rather than like lexical declarations.
3496 pp$3.treatFunctionsAsVarInScope = function(scope) {
3497 return (scope.flags & SCOPE_FUNCTION) || !this.inModule && (scope.flags & SCOPE_TOP)
3500 pp$3.declareName = function(name, bindingType, pos) {
3501 var redeclared = false;
3502 if (bindingType === BIND_LEXICAL) {
3503 var scope = this.currentScope();
3504 redeclared = scope.lexical.indexOf(name) > -1 || scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1;
3505 scope.lexical.push(name);
3506 if (this.inModule && (scope.flags & SCOPE_TOP))
3507 { delete this.undefinedExports[name]; }
3508 } else if (bindingType === BIND_SIMPLE_CATCH) {
3509 var scope$1 = this.currentScope();
3510 scope$1.lexical.push(name);
3511 } else if (bindingType === BIND_FUNCTION) {
3512 var scope$2 = this.currentScope();
3513 if (this.treatFunctionsAsVar)
3514 { redeclared = scope$2.lexical.indexOf(name) > -1; }
3516 { redeclared = scope$2.lexical.indexOf(name) > -1 || scope$2.var.indexOf(name) > -1; }
3517 scope$2.functions.push(name);
3519 for (var i = this.scopeStack.length - 1; i >= 0; --i) {
3520 var scope$3 = this.scopeStack[i];
3521 if (scope$3.lexical.indexOf(name) > -1 && !((scope$3.flags & SCOPE_SIMPLE_CATCH) && scope$3.lexical[0] === name) ||
3522 !this.treatFunctionsAsVarInScope(scope$3) && scope$3.functions.indexOf(name) > -1) {
3526 scope$3.var.push(name);
3527 if (this.inModule && (scope$3.flags & SCOPE_TOP))
3528 { delete this.undefinedExports[name]; }
3529 if (scope$3.flags & SCOPE_VAR) { break }
3532 if (redeclared) { this.raiseRecoverable(pos, ("Identifier '" + name + "' has already been declared")); }
3535 pp$3.checkLocalExport = function(id) {
3536 // scope.functions must be empty as Module code is always strict.
3537 if (this.scopeStack[0].lexical.indexOf(id.name) === -1 &&
3538 this.scopeStack[0].var.indexOf(id.name) === -1) {
3539 this.undefinedExports[id.name] = id;
3543 pp$3.currentScope = function() {
3544 return this.scopeStack[this.scopeStack.length - 1]
3547 pp$3.currentVarScope = function() {
3548 for (var i = this.scopeStack.length - 1;; i--) {
3549 var scope = this.scopeStack[i];
3550 if (scope.flags & SCOPE_VAR) { return scope }
3554 // Could be useful for `this`, `new.target`, `super()`, `super.property`, and `super[property]`.
3555 pp$3.currentThisScope = function() {
3556 for (var i = this.scopeStack.length - 1;; i--) {
3557 var scope = this.scopeStack[i];
3558 if (scope.flags & SCOPE_VAR && !(scope.flags & SCOPE_ARROW)) { return scope }
3562 var Node = function Node(parser, pos, loc) {
3566 if (parser.options.locations)
3567 { this.loc = new SourceLocation(parser, loc); }
3568 if (parser.options.directSourceFile)
3569 { this.sourceFile = parser.options.directSourceFile; }
3570 if (parser.options.ranges)
3571 { this.range = [pos, 0]; }
3574 // Start an AST node, attaching a start offset.
3576 var pp$2 = Parser.prototype;
3578 pp$2.startNode = function() {
3579 return new Node(this, this.start, this.startLoc)
3582 pp$2.startNodeAt = function(pos, loc) {
3583 return new Node(this, pos, loc)
3586 // Finish an AST node, adding `type` and `end` properties.
3588 function finishNodeAt(node, type, pos, loc) {
3591 if (this.options.locations)
3592 { node.loc.end = loc; }
3593 if (this.options.ranges)
3594 { node.range[1] = pos; }
3598 pp$2.finishNode = function(node, type) {
3599 return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc)
3602 // Finish node at given position
3604 pp$2.finishNodeAt = function(node, type, pos, loc) {
3605 return finishNodeAt.call(this, node, type, pos, loc)
3608 pp$2.copyNode = function(node) {
3609 var newNode = new Node(this, node.start, this.startLoc);
3610 for (var prop in node) { newNode[prop] = node[prop]; }
3614 // This file contains Unicode properties extracted from the ECMAScript
3615 // specification. The lists are extracted like so:
3616 // $$('#table-binary-unicode-properties > figure > table > tbody > tr > td:nth-child(1) code').map(el => el.innerText)
3618 // #table-binary-unicode-properties
3619 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";
3620 var ecma10BinaryProperties = ecma9BinaryProperties + " Extended_Pictographic";
3621 var ecma11BinaryProperties = ecma10BinaryProperties;
3622 var ecma12BinaryProperties = ecma11BinaryProperties + " EBase EComp EMod EPres ExtPict";
3623 var ecma13BinaryProperties = ecma12BinaryProperties;
3624 var unicodeBinaryProperties = {
3625 9: ecma9BinaryProperties,
3626 10: ecma10BinaryProperties,
3627 11: ecma11BinaryProperties,
3628 12: ecma12BinaryProperties,
3629 13: ecma13BinaryProperties
3632 // #table-unicode-general-category-values
3633 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";
3635 // #table-unicode-script-values
3636 var ecma9ScriptValues = "Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham 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 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";
3637 var ecma10ScriptValues = ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd";
3638 var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho";
3639 var ecma12ScriptValues = ecma11ScriptValues + " Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi";
3640 var ecma13ScriptValues = ecma12ScriptValues + " Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith";
3641 var unicodeScriptValues = {
3642 9: ecma9ScriptValues,
3643 10: ecma10ScriptValues,
3644 11: ecma11ScriptValues,
3645 12: ecma12ScriptValues,
3646 13: ecma13ScriptValues
3650 function buildUnicodeData(ecmaVersion) {
3651 var d = data[ecmaVersion] = {
3652 binary: wordsRegexp(unicodeBinaryProperties[ecmaVersion] + " " + unicodeGeneralCategoryValues),
3654 General_Category: wordsRegexp(unicodeGeneralCategoryValues),
3655 Script: wordsRegexp(unicodeScriptValues[ecmaVersion])
3658 d.nonBinary.Script_Extensions = d.nonBinary.Script;
3660 d.nonBinary.gc = d.nonBinary.General_Category;
3661 d.nonBinary.sc = d.nonBinary.Script;
3662 d.nonBinary.scx = d.nonBinary.Script_Extensions;
3665 for (var i = 0, list = [9, 10, 11, 12, 13]; i < list.length; i += 1) {
3666 var ecmaVersion = list[i];
3668 buildUnicodeData(ecmaVersion);
3671 var pp$1 = Parser.prototype;
3673 var RegExpValidationState = function RegExpValidationState(parser) {
3674 this.parser = parser;
3675 this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "");
3676 this.unicodeProperties = data[parser.options.ecmaVersion >= 13 ? 13 : parser.options.ecmaVersion];
3680 this.switchU = false;
3681 this.switchN = false;
3683 this.lastIntValue = 0;
3684 this.lastStringValue = "";
3685 this.lastAssertionIsQuantifiable = false;
3686 this.numCapturingParens = 0;
3687 this.maxBackReference = 0;
3688 this.groupNames = [];
3689 this.backReferenceNames = [];
3692 RegExpValidationState.prototype.reset = function reset (start, pattern, flags) {
3693 var unicode = flags.indexOf("u") !== -1;
3694 this.start = start | 0;
3695 this.source = pattern + "";
3697 this.switchU = unicode && this.parser.options.ecmaVersion >= 6;
3698 this.switchN = unicode && this.parser.options.ecmaVersion >= 9;
3701 RegExpValidationState.prototype.raise = function raise (message) {
3702 this.parser.raiseRecoverable(this.start, ("Invalid regular expression: /" + (this.source) + "/: " + message));
3705 // If u flag is given, this returns the code point at the index (it combines a surrogate pair).
3706 // Otherwise, this returns the code unit of the index (can be a part of a surrogate pair).
3707 RegExpValidationState.prototype.at = function at (i, forceU) {
3708 if ( forceU === void 0 ) forceU = false;
3710 var s = this.source;
3715 var c = s.charCodeAt(i);
3716 if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) {
3719 var next = s.charCodeAt(i + 1);
3720 return next >= 0xDC00 && next <= 0xDFFF ? (c << 10) + next - 0x35FDC00 : c
3723 RegExpValidationState.prototype.nextIndex = function nextIndex (i, forceU) {
3724 if ( forceU === void 0 ) forceU = false;
3726 var s = this.source;
3731 var c = s.charCodeAt(i), next;
3732 if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l ||
3733 (next = s.charCodeAt(i + 1)) < 0xDC00 || next > 0xDFFF) {
3739 RegExpValidationState.prototype.current = function current (forceU) {
3740 if ( forceU === void 0 ) forceU = false;
3742 return this.at(this.pos, forceU)
3745 RegExpValidationState.prototype.lookahead = function lookahead (forceU) {
3746 if ( forceU === void 0 ) forceU = false;
3748 return this.at(this.nextIndex(this.pos, forceU), forceU)
3751 RegExpValidationState.prototype.advance = function advance (forceU) {
3752 if ( forceU === void 0 ) forceU = false;
3754 this.pos = this.nextIndex(this.pos, forceU);
3757 RegExpValidationState.prototype.eat = function eat (ch, forceU) {
3758 if ( forceU === void 0 ) forceU = false;
3760 if (this.current(forceU) === ch) {
3761 this.advance(forceU);
3768 * Validate the flags part of a given RegExpLiteral.
3770 * @param {RegExpValidationState} state The state to validate RegExp.
3773 pp$1.validateRegExpFlags = function(state) {
3774 var validFlags = state.validFlags;
3775 var flags = state.flags;
3777 for (var i = 0; i < flags.length; i++) {
3778 var flag = flags.charAt(i);
3779 if (validFlags.indexOf(flag) === -1) {
3780 this.raise(state.start, "Invalid regular expression flag");
3782 if (flags.indexOf(flag, i + 1) > -1) {
3783 this.raise(state.start, "Duplicate regular expression flag");
3789 * Validate the pattern part of a given RegExpLiteral.
3791 * @param {RegExpValidationState} state The state to validate RegExp.
3794 pp$1.validateRegExpPattern = function(state) {
3795 this.regexp_pattern(state);
3797 // The goal symbol for the parse is |Pattern[~U, ~N]|. If the result of
3798 // parsing contains a |GroupName|, reparse with the goal symbol
3799 // |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError*
3800 // exception if _P_ did not conform to the grammar, if any elements of _P_
3801 // were not matched by the parse, or if any Early Error conditions exist.
3802 if (!state.switchN && this.options.ecmaVersion >= 9 && state.groupNames.length > 0) {
3803 state.switchN = true;
3804 this.regexp_pattern(state);
3808 // https://www.ecma-international.org/ecma-262/8.0/#prod-Pattern
3809 pp$1.regexp_pattern = function(state) {
3811 state.lastIntValue = 0;
3812 state.lastStringValue = "";
3813 state.lastAssertionIsQuantifiable = false;
3814 state.numCapturingParens = 0;
3815 state.maxBackReference = 0;
3816 state.groupNames.length = 0;
3817 state.backReferenceNames.length = 0;
3819 this.regexp_disjunction(state);
3821 if (state.pos !== state.source.length) {
3822 // Make the same messages as V8.
3823 if (state.eat(0x29 /* ) */)) {
3824 state.raise("Unmatched ')'");
3826 if (state.eat(0x5D /* ] */) || state.eat(0x7D /* } */)) {
3827 state.raise("Lone quantifier brackets");
3830 if (state.maxBackReference > state.numCapturingParens) {
3831 state.raise("Invalid escape");
3833 for (var i = 0, list = state.backReferenceNames; i < list.length; i += 1) {
3836 if (state.groupNames.indexOf(name) === -1) {
3837 state.raise("Invalid named capture referenced");
3842 // https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction
3843 pp$1.regexp_disjunction = function(state) {
3844 this.regexp_alternative(state);
3845 while (state.eat(0x7C /* | */)) {
3846 this.regexp_alternative(state);
3849 // Make the same message as V8.
3850 if (this.regexp_eatQuantifier(state, true)) {
3851 state.raise("Nothing to repeat");
3853 if (state.eat(0x7B /* { */)) {
3854 state.raise("Lone quantifier brackets");
3858 // https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative
3859 pp$1.regexp_alternative = function(state) {
3860 while (state.pos < state.source.length && this.regexp_eatTerm(state))
3864 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term
3865 pp$1.regexp_eatTerm = function(state) {
3866 if (this.regexp_eatAssertion(state)) {
3867 // Handle `QuantifiableAssertion Quantifier` alternative.
3868 // `state.lastAssertionIsQuantifiable` is true if the last eaten Assertion
3869 // is a QuantifiableAssertion.
3870 if (state.lastAssertionIsQuantifiable && this.regexp_eatQuantifier(state)) {
3871 // Make the same message as V8.
3872 if (state.switchU) {
3873 state.raise("Invalid quantifier");
3879 if (state.switchU ? this.regexp_eatAtom(state) : this.regexp_eatExtendedAtom(state)) {
3880 this.regexp_eatQuantifier(state);
3887 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Assertion
3888 pp$1.regexp_eatAssertion = function(state) {
3889 var start = state.pos;
3890 state.lastAssertionIsQuantifiable = false;
3893 if (state.eat(0x5E /* ^ */) || state.eat(0x24 /* $ */)) {
3898 if (state.eat(0x5C /* \ */)) {
3899 if (state.eat(0x42 /* B */) || state.eat(0x62 /* b */)) {
3905 // Lookahead / Lookbehind
3906 if (state.eat(0x28 /* ( */) && state.eat(0x3F /* ? */)) {
3907 var lookbehind = false;
3908 if (this.options.ecmaVersion >= 9) {
3909 lookbehind = state.eat(0x3C /* < */);
3911 if (state.eat(0x3D /* = */) || state.eat(0x21 /* ! */)) {
3912 this.regexp_disjunction(state);
3913 if (!state.eat(0x29 /* ) */)) {
3914 state.raise("Unterminated group");
3916 state.lastAssertionIsQuantifiable = !lookbehind;
3925 // https://www.ecma-international.org/ecma-262/8.0/#prod-Quantifier
3926 pp$1.regexp_eatQuantifier = function(state, noError) {
3927 if ( noError === void 0 ) noError = false;
3929 if (this.regexp_eatQuantifierPrefix(state, noError)) {
3930 state.eat(0x3F /* ? */);
3936 // https://www.ecma-international.org/ecma-262/8.0/#prod-QuantifierPrefix
3937 pp$1.regexp_eatQuantifierPrefix = function(state, noError) {
3939 state.eat(0x2A /* * */) ||
3940 state.eat(0x2B /* + */) ||
3941 state.eat(0x3F /* ? */) ||
3942 this.regexp_eatBracedQuantifier(state, noError)
3945 pp$1.regexp_eatBracedQuantifier = function(state, noError) {
3946 var start = state.pos;
3947 if (state.eat(0x7B /* { */)) {
3948 var min = 0, max = -1;
3949 if (this.regexp_eatDecimalDigits(state)) {
3950 min = state.lastIntValue;
3951 if (state.eat(0x2C /* , */) && this.regexp_eatDecimalDigits(state)) {
3952 max = state.lastIntValue;
3954 if (state.eat(0x7D /* } */)) {
3955 // SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-term
3956 if (max !== -1 && max < min && !noError) {
3957 state.raise("numbers out of order in {} quantifier");
3962 if (state.switchU && !noError) {
3963 state.raise("Incomplete quantifier");
3970 // https://www.ecma-international.org/ecma-262/8.0/#prod-Atom
3971 pp$1.regexp_eatAtom = function(state) {
3973 this.regexp_eatPatternCharacters(state) ||
3974 state.eat(0x2E /* . */) ||
3975 this.regexp_eatReverseSolidusAtomEscape(state) ||
3976 this.regexp_eatCharacterClass(state) ||
3977 this.regexp_eatUncapturingGroup(state) ||
3978 this.regexp_eatCapturingGroup(state)
3981 pp$1.regexp_eatReverseSolidusAtomEscape = function(state) {
3982 var start = state.pos;
3983 if (state.eat(0x5C /* \ */)) {
3984 if (this.regexp_eatAtomEscape(state)) {
3991 pp$1.regexp_eatUncapturingGroup = function(state) {
3992 var start = state.pos;
3993 if (state.eat(0x28 /* ( */)) {
3994 if (state.eat(0x3F /* ? */) && state.eat(0x3A /* : */)) {
3995 this.regexp_disjunction(state);
3996 if (state.eat(0x29 /* ) */)) {
3999 state.raise("Unterminated group");
4005 pp$1.regexp_eatCapturingGroup = function(state) {
4006 if (state.eat(0x28 /* ( */)) {
4007 if (this.options.ecmaVersion >= 9) {
4008 this.regexp_groupSpecifier(state);
4009 } else if (state.current() === 0x3F /* ? */) {
4010 state.raise("Invalid group");
4012 this.regexp_disjunction(state);
4013 if (state.eat(0x29 /* ) */)) {
4014 state.numCapturingParens += 1;
4017 state.raise("Unterminated group");
4022 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom
4023 pp$1.regexp_eatExtendedAtom = function(state) {
4025 state.eat(0x2E /* . */) ||
4026 this.regexp_eatReverseSolidusAtomEscape(state) ||
4027 this.regexp_eatCharacterClass(state) ||
4028 this.regexp_eatUncapturingGroup(state) ||
4029 this.regexp_eatCapturingGroup(state) ||
4030 this.regexp_eatInvalidBracedQuantifier(state) ||
4031 this.regexp_eatExtendedPatternCharacter(state)
4035 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-InvalidBracedQuantifier
4036 pp$1.regexp_eatInvalidBracedQuantifier = function(state) {
4037 if (this.regexp_eatBracedQuantifier(state, true)) {
4038 state.raise("Nothing to repeat");
4043 // https://www.ecma-international.org/ecma-262/8.0/#prod-SyntaxCharacter
4044 pp$1.regexp_eatSyntaxCharacter = function(state) {
4045 var ch = state.current();
4046 if (isSyntaxCharacter(ch)) {
4047 state.lastIntValue = ch;
4053 function isSyntaxCharacter(ch) {
4055 ch === 0x24 /* $ */ ||
4056 ch >= 0x28 /* ( */ && ch <= 0x2B /* + */ ||
4057 ch === 0x2E /* . */ ||
4058 ch === 0x3F /* ? */ ||
4059 ch >= 0x5B /* [ */ && ch <= 0x5E /* ^ */ ||
4060 ch >= 0x7B /* { */ && ch <= 0x7D /* } */
4064 // https://www.ecma-international.org/ecma-262/8.0/#prod-PatternCharacter
4066 pp$1.regexp_eatPatternCharacters = function(state) {
4067 var start = state.pos;
4069 while ((ch = state.current()) !== -1 && !isSyntaxCharacter(ch)) {
4072 return state.pos !== start
4075 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedPatternCharacter
4076 pp$1.regexp_eatExtendedPatternCharacter = function(state) {
4077 var ch = state.current();
4080 ch !== 0x24 /* $ */ &&
4081 !(ch >= 0x28 /* ( */ && ch <= 0x2B /* + */) &&
4082 ch !== 0x2E /* . */ &&
4083 ch !== 0x3F /* ? */ &&
4084 ch !== 0x5B /* [ */ &&
4085 ch !== 0x5E /* ^ */ &&
4094 // GroupSpecifier ::
4097 pp$1.regexp_groupSpecifier = function(state) {
4098 if (state.eat(0x3F /* ? */)) {
4099 if (this.regexp_eatGroupName(state)) {
4100 if (state.groupNames.indexOf(state.lastStringValue) !== -1) {
4101 state.raise("Duplicate capture group name");
4103 state.groupNames.push(state.lastStringValue);
4106 state.raise("Invalid group");
4111 // `<` RegExpIdentifierName `>`
4112 // Note: this updates `state.lastStringValue` property with the eaten name.
4113 pp$1.regexp_eatGroupName = function(state) {
4114 state.lastStringValue = "";
4115 if (state.eat(0x3C /* < */)) {
4116 if (this.regexp_eatRegExpIdentifierName(state) && state.eat(0x3E /* > */)) {
4119 state.raise("Invalid capture group name");
4124 // RegExpIdentifierName ::
4125 // RegExpIdentifierStart
4126 // RegExpIdentifierName RegExpIdentifierPart
4127 // Note: this updates `state.lastStringValue` property with the eaten name.
4128 pp$1.regexp_eatRegExpIdentifierName = function(state) {
4129 state.lastStringValue = "";
4130 if (this.regexp_eatRegExpIdentifierStart(state)) {
4131 state.lastStringValue += codePointToString(state.lastIntValue);
4132 while (this.regexp_eatRegExpIdentifierPart(state)) {
4133 state.lastStringValue += codePointToString(state.lastIntValue);
4140 // RegExpIdentifierStart ::
4144 // `\` RegExpUnicodeEscapeSequence[+U]
4145 pp$1.regexp_eatRegExpIdentifierStart = function(state) {
4146 var start = state.pos;
4147 var forceU = this.options.ecmaVersion >= 11;
4148 var ch = state.current(forceU);
4149 state.advance(forceU);
4151 if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
4152 ch = state.lastIntValue;
4154 if (isRegExpIdentifierStart(ch)) {
4155 state.lastIntValue = ch;
4162 function isRegExpIdentifierStart(ch) {
4163 return isIdentifierStart(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */
4166 // RegExpIdentifierPart ::
4167 // UnicodeIDContinue
4170 // `\` RegExpUnicodeEscapeSequence[+U]
4173 pp$1.regexp_eatRegExpIdentifierPart = function(state) {
4174 var start = state.pos;
4175 var forceU = this.options.ecmaVersion >= 11;
4176 var ch = state.current(forceU);
4177 state.advance(forceU);
4179 if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
4180 ch = state.lastIntValue;
4182 if (isRegExpIdentifierPart(ch)) {
4183 state.lastIntValue = ch;
4190 function isRegExpIdentifierPart(ch) {
4191 return isIdentifierChar(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */ || ch === 0x200C /* <ZWNJ> */ || ch === 0x200D /* <ZWJ> */
4194 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-AtomEscape
4195 pp$1.regexp_eatAtomEscape = function(state) {
4197 this.regexp_eatBackReference(state) ||
4198 this.regexp_eatCharacterClassEscape(state) ||
4199 this.regexp_eatCharacterEscape(state) ||
4200 (state.switchN && this.regexp_eatKGroupName(state))
4204 if (state.switchU) {
4205 // Make the same message as V8.
4206 if (state.current() === 0x63 /* c */) {
4207 state.raise("Invalid unicode escape");
4209 state.raise("Invalid escape");
4213 pp$1.regexp_eatBackReference = function(state) {
4214 var start = state.pos;
4215 if (this.regexp_eatDecimalEscape(state)) {
4216 var n = state.lastIntValue;
4217 if (state.switchU) {
4218 // For SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-atomescape
4219 if (n > state.maxBackReference) {
4220 state.maxBackReference = n;
4224 if (n <= state.numCapturingParens) {
4231 pp$1.regexp_eatKGroupName = function(state) {
4232 if (state.eat(0x6B /* k */)) {
4233 if (this.regexp_eatGroupName(state)) {
4234 state.backReferenceNames.push(state.lastStringValue);
4237 state.raise("Invalid named reference");
4242 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-CharacterEscape
4243 pp$1.regexp_eatCharacterEscape = function(state) {
4245 this.regexp_eatControlEscape(state) ||
4246 this.regexp_eatCControlLetter(state) ||
4247 this.regexp_eatZero(state) ||
4248 this.regexp_eatHexEscapeSequence(state) ||
4249 this.regexp_eatRegExpUnicodeEscapeSequence(state, false) ||
4250 (!state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state)) ||
4251 this.regexp_eatIdentityEscape(state)
4254 pp$1.regexp_eatCControlLetter = function(state) {
4255 var start = state.pos;
4256 if (state.eat(0x63 /* c */)) {
4257 if (this.regexp_eatControlLetter(state)) {
4264 pp$1.regexp_eatZero = function(state) {
4265 if (state.current() === 0x30 /* 0 */ && !isDecimalDigit(state.lookahead())) {
4266 state.lastIntValue = 0;
4273 // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlEscape
4274 pp$1.regexp_eatControlEscape = function(state) {
4275 var ch = state.current();
4276 if (ch === 0x74 /* t */) {
4277 state.lastIntValue = 0x09; /* \t */
4281 if (ch === 0x6E /* n */) {
4282 state.lastIntValue = 0x0A; /* \n */
4286 if (ch === 0x76 /* v */) {
4287 state.lastIntValue = 0x0B; /* \v */
4291 if (ch === 0x66 /* f */) {
4292 state.lastIntValue = 0x0C; /* \f */
4296 if (ch === 0x72 /* r */) {
4297 state.lastIntValue = 0x0D; /* \r */
4304 // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlLetter
4305 pp$1.regexp_eatControlLetter = function(state) {
4306 var ch = state.current();
4307 if (isControlLetter(ch)) {
4308 state.lastIntValue = ch % 0x20;
4314 function isControlLetter(ch) {
4316 (ch >= 0x41 /* A */ && ch <= 0x5A /* Z */) ||
4317 (ch >= 0x61 /* a */ && ch <= 0x7A /* z */)
4321 // https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence
4322 pp$1.regexp_eatRegExpUnicodeEscapeSequence = function(state, forceU) {
4323 if ( forceU === void 0 ) forceU = false;
4325 var start = state.pos;
4326 var switchU = forceU || state.switchU;
4328 if (state.eat(0x75 /* u */)) {
4329 if (this.regexp_eatFixedHexDigits(state, 4)) {
4330 var lead = state.lastIntValue;
4331 if (switchU && lead >= 0xD800 && lead <= 0xDBFF) {
4332 var leadSurrogateEnd = state.pos;
4333 if (state.eat(0x5C /* \ */) && state.eat(0x75 /* u */) && this.regexp_eatFixedHexDigits(state, 4)) {
4334 var trail = state.lastIntValue;
4335 if (trail >= 0xDC00 && trail <= 0xDFFF) {
4336 state.lastIntValue = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
4340 state.pos = leadSurrogateEnd;
4341 state.lastIntValue = lead;
4347 state.eat(0x7B /* { */) &&
4348 this.regexp_eatHexDigits(state) &&
4349 state.eat(0x7D /* } */) &&
4350 isValidUnicode(state.lastIntValue)
4355 state.raise("Invalid unicode escape");
4362 function isValidUnicode(ch) {
4363 return ch >= 0 && ch <= 0x10FFFF
4366 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-IdentityEscape
4367 pp$1.regexp_eatIdentityEscape = function(state) {
4368 if (state.switchU) {
4369 if (this.regexp_eatSyntaxCharacter(state)) {
4372 if (state.eat(0x2F /* / */)) {
4373 state.lastIntValue = 0x2F; /* / */
4379 var ch = state.current();
4380 if (ch !== 0x63 /* c */ && (!state.switchN || ch !== 0x6B /* k */)) {
4381 state.lastIntValue = ch;
4389 // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalEscape
4390 pp$1.regexp_eatDecimalEscape = function(state) {
4391 state.lastIntValue = 0;
4392 var ch = state.current();
4393 if (ch >= 0x31 /* 1 */ && ch <= 0x39 /* 9 */) {
4395 state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */);
4397 } while ((ch = state.current()) >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */)
4403 // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClassEscape
4404 pp$1.regexp_eatCharacterClassEscape = function(state) {
4405 var ch = state.current();
4407 if (isCharacterClassEscape(ch)) {
4408 state.lastIntValue = -1;
4415 this.options.ecmaVersion >= 9 &&
4416 (ch === 0x50 /* P */ || ch === 0x70 /* p */)
4418 state.lastIntValue = -1;
4421 state.eat(0x7B /* { */) &&
4422 this.regexp_eatUnicodePropertyValueExpression(state) &&
4423 state.eat(0x7D /* } */)
4427 state.raise("Invalid property name");
4432 function isCharacterClassEscape(ch) {
4434 ch === 0x64 /* d */ ||
4435 ch === 0x44 /* D */ ||
4436 ch === 0x73 /* s */ ||
4437 ch === 0x53 /* S */ ||
4438 ch === 0x77 /* w */ ||
4443 // UnicodePropertyValueExpression ::
4444 // UnicodePropertyName `=` UnicodePropertyValue
4445 // LoneUnicodePropertyNameOrValue
4446 pp$1.regexp_eatUnicodePropertyValueExpression = function(state) {
4447 var start = state.pos;
4449 // UnicodePropertyName `=` UnicodePropertyValue
4450 if (this.regexp_eatUnicodePropertyName(state) && state.eat(0x3D /* = */)) {
4451 var name = state.lastStringValue;
4452 if (this.regexp_eatUnicodePropertyValue(state)) {
4453 var value = state.lastStringValue;
4454 this.regexp_validateUnicodePropertyNameAndValue(state, name, value);
4460 // LoneUnicodePropertyNameOrValue
4461 if (this.regexp_eatLoneUnicodePropertyNameOrValue(state)) {
4462 var nameOrValue = state.lastStringValue;
4463 this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue);
4468 pp$1.regexp_validateUnicodePropertyNameAndValue = function(state, name, value) {
4469 if (!hasOwn(state.unicodeProperties.nonBinary, name))
4470 { state.raise("Invalid property name"); }
4471 if (!state.unicodeProperties.nonBinary[name].test(value))
4472 { state.raise("Invalid property value"); }
4474 pp$1.regexp_validateUnicodePropertyNameOrValue = function(state, nameOrValue) {
4475 if (!state.unicodeProperties.binary.test(nameOrValue))
4476 { state.raise("Invalid property name"); }
4479 // UnicodePropertyName ::
4480 // UnicodePropertyNameCharacters
4481 pp$1.regexp_eatUnicodePropertyName = function(state) {
4483 state.lastStringValue = "";
4484 while (isUnicodePropertyNameCharacter(ch = state.current())) {
4485 state.lastStringValue += codePointToString(ch);
4488 return state.lastStringValue !== ""
4490 function isUnicodePropertyNameCharacter(ch) {
4491 return isControlLetter(ch) || ch === 0x5F /* _ */
4494 // UnicodePropertyValue ::
4495 // UnicodePropertyValueCharacters
4496 pp$1.regexp_eatUnicodePropertyValue = function(state) {
4498 state.lastStringValue = "";
4499 while (isUnicodePropertyValueCharacter(ch = state.current())) {
4500 state.lastStringValue += codePointToString(ch);
4503 return state.lastStringValue !== ""
4505 function isUnicodePropertyValueCharacter(ch) {
4506 return isUnicodePropertyNameCharacter(ch) || isDecimalDigit(ch)
4509 // LoneUnicodePropertyNameOrValue ::
4510 // UnicodePropertyValueCharacters
4511 pp$1.regexp_eatLoneUnicodePropertyNameOrValue = function(state) {
4512 return this.regexp_eatUnicodePropertyValue(state)
4515 // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClass
4516 pp$1.regexp_eatCharacterClass = function(state) {
4517 if (state.eat(0x5B /* [ */)) {
4518 state.eat(0x5E /* ^ */);
4519 this.regexp_classRanges(state);
4520 if (state.eat(0x5D /* ] */)) {
4523 // Unreachable since it threw "unterminated regular expression" error before.
4524 state.raise("Unterminated character class");
4529 // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassRanges
4530 // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRanges
4531 // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRangesNoDash
4532 pp$1.regexp_classRanges = function(state) {
4533 while (this.regexp_eatClassAtom(state)) {
4534 var left = state.lastIntValue;
4535 if (state.eat(0x2D /* - */) && this.regexp_eatClassAtom(state)) {
4536 var right = state.lastIntValue;
4537 if (state.switchU && (left === -1 || right === -1)) {
4538 state.raise("Invalid character class");
4540 if (left !== -1 && right !== -1 && left > right) {
4541 state.raise("Range out of order in character class");
4547 // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtom
4548 // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtomNoDash
4549 pp$1.regexp_eatClassAtom = function(state) {
4550 var start = state.pos;
4552 if (state.eat(0x5C /* \ */)) {
4553 if (this.regexp_eatClassEscape(state)) {
4556 if (state.switchU) {
4557 // Make the same message as V8.
4558 var ch$1 = state.current();
4559 if (ch$1 === 0x63 /* c */ || isOctalDigit(ch$1)) {
4560 state.raise("Invalid class escape");
4562 state.raise("Invalid escape");
4567 var ch = state.current();
4568 if (ch !== 0x5D /* ] */) {
4569 state.lastIntValue = ch;
4577 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassEscape
4578 pp$1.regexp_eatClassEscape = function(state) {
4579 var start = state.pos;
4581 if (state.eat(0x62 /* b */)) {
4582 state.lastIntValue = 0x08; /* <BS> */
4586 if (state.switchU && state.eat(0x2D /* - */)) {
4587 state.lastIntValue = 0x2D; /* - */
4591 if (!state.switchU && state.eat(0x63 /* c */)) {
4592 if (this.regexp_eatClassControlLetter(state)) {
4599 this.regexp_eatCharacterClassEscape(state) ||
4600 this.regexp_eatCharacterEscape(state)
4604 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassControlLetter
4605 pp$1.regexp_eatClassControlLetter = function(state) {
4606 var ch = state.current();
4607 if (isDecimalDigit(ch) || ch === 0x5F /* _ */) {
4608 state.lastIntValue = ch % 0x20;
4615 // https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
4616 pp$1.regexp_eatHexEscapeSequence = function(state) {
4617 var start = state.pos;
4618 if (state.eat(0x78 /* x */)) {
4619 if (this.regexp_eatFixedHexDigits(state, 2)) {
4622 if (state.switchU) {
4623 state.raise("Invalid escape");
4630 // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalDigits
4631 pp$1.regexp_eatDecimalDigits = function(state) {
4632 var start = state.pos;
4634 state.lastIntValue = 0;
4635 while (isDecimalDigit(ch = state.current())) {
4636 state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */);
4639 return state.pos !== start
4641 function isDecimalDigit(ch) {
4642 return ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */
4645 // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigits
4646 pp$1.regexp_eatHexDigits = function(state) {
4647 var start = state.pos;
4649 state.lastIntValue = 0;
4650 while (isHexDigit(ch = state.current())) {
4651 state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
4654 return state.pos !== start
4656 function isHexDigit(ch) {
4658 (ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */) ||
4659 (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) ||
4660 (ch >= 0x61 /* a */ && ch <= 0x66 /* f */)
4663 function hexToInt(ch) {
4664 if (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) {
4665 return 10 + (ch - 0x41 /* A */)
4667 if (ch >= 0x61 /* a */ && ch <= 0x66 /* f */) {
4668 return 10 + (ch - 0x61 /* a */)
4670 return ch - 0x30 /* 0 */
4673 // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-LegacyOctalEscapeSequence
4674 // Allows only 0-377(octal) i.e. 0-255(decimal).
4675 pp$1.regexp_eatLegacyOctalEscapeSequence = function(state) {
4676 if (this.regexp_eatOctalDigit(state)) {
4677 var n1 = state.lastIntValue;
4678 if (this.regexp_eatOctalDigit(state)) {
4679 var n2 = state.lastIntValue;
4680 if (n1 <= 3 && this.regexp_eatOctalDigit(state)) {
4681 state.lastIntValue = n1 * 64 + n2 * 8 + state.lastIntValue;
4683 state.lastIntValue = n1 * 8 + n2;
4686 state.lastIntValue = n1;
4693 // https://www.ecma-international.org/ecma-262/8.0/#prod-OctalDigit
4694 pp$1.regexp_eatOctalDigit = function(state) {
4695 var ch = state.current();
4696 if (isOctalDigit(ch)) {
4697 state.lastIntValue = ch - 0x30; /* 0 */
4701 state.lastIntValue = 0;
4704 function isOctalDigit(ch) {
4705 return ch >= 0x30 /* 0 */ && ch <= 0x37 /* 7 */
4708 // https://www.ecma-international.org/ecma-262/8.0/#prod-Hex4Digits
4709 // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigit
4710 // And HexDigit HexDigit in https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
4711 pp$1.regexp_eatFixedHexDigits = function(state, length) {
4712 var start = state.pos;
4713 state.lastIntValue = 0;
4714 for (var i = 0; i < length; ++i) {
4715 var ch = state.current();
4716 if (!isHexDigit(ch)) {
4720 state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
4726 // Object type used to represent tokens. Note that normally, tokens
4727 // simply exist as properties on the parser object. This is only
4728 // used for the onToken callback and the external tokenizer.
4730 var Token = function Token(p) {
4732 this.value = p.value;
4733 this.start = p.start;
4735 if (p.options.locations)
4736 { this.loc = new SourceLocation(p, p.startLoc, p.endLoc); }
4737 if (p.options.ranges)
4738 { this.range = [p.start, p.end]; }
4743 var pp = Parser.prototype;
4745 // Move to the next token
4747 pp.next = function(ignoreEscapeSequenceInKeyword) {
4748 if (!ignoreEscapeSequenceInKeyword && this.type.keyword && this.containsEsc)
4749 { this.raiseRecoverable(this.start, "Escape sequence in keyword " + this.type.keyword); }
4750 if (this.options.onToken)
4751 { this.options.onToken(new Token(this)); }
4753 this.lastTokEnd = this.end;
4754 this.lastTokStart = this.start;
4755 this.lastTokEndLoc = this.endLoc;
4756 this.lastTokStartLoc = this.startLoc;
4760 pp.getToken = function() {
4762 return new Token(this)
4765 // If we're in an ES6 environment, make parsers iterable
4766 if (typeof Symbol !== "undefined")
4767 { pp[Symbol.iterator] = function() {
4768 var this$1$1 = this;
4772 var token = this$1$1.getToken();
4774 done: token.type === types$1.eof,
4781 // Toggle strict mode. Re-reads the next number or string to please
4782 // pedantic tests (`"use strict"; 010;` should fail).
4784 // Read a single token, updating the parser object's token-related
4787 pp.nextToken = function() {
4788 var curContext = this.curContext();
4789 if (!curContext || !curContext.preserveSpace) { this.skipSpace(); }
4791 this.start = this.pos;
4792 if (this.options.locations) { this.startLoc = this.curPosition(); }
4793 if (this.pos >= this.input.length) { return this.finishToken(types$1.eof) }
4795 if (curContext.override) { return curContext.override(this) }
4796 else { this.readToken(this.fullCharCodeAtPos()); }
4799 pp.readToken = function(code) {
4800 // Identifier or keyword. '\uXXXX' sequences are allowed in
4801 // identifiers, so '\' also dispatches to that.
4802 if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */)
4803 { return this.readWord() }
4805 return this.getTokenFromCode(code)
4808 pp.fullCharCodeAtPos = function() {
4809 var code = this.input.charCodeAt(this.pos);
4810 if (code <= 0xd7ff || code >= 0xdc00) { return code }
4811 var next = this.input.charCodeAt(this.pos + 1);
4812 return next <= 0xdbff || next >= 0xe000 ? code : (code << 10) + next - 0x35fdc00
4815 pp.skipBlockComment = function() {
4816 var startLoc = this.options.onComment && this.curPosition();
4817 var start = this.pos, end = this.input.indexOf("*/", this.pos += 2);
4818 if (end === -1) { this.raise(this.pos - 2, "Unterminated comment"); }
4820 if (this.options.locations) {
4821 for (var nextBreak = (void 0), pos = start; (nextBreak = nextLineBreak(this.input, pos, this.pos)) > -1;) {
4823 pos = this.lineStart = nextBreak;
4826 if (this.options.onComment)
4827 { this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos,
4828 startLoc, this.curPosition()); }
4831 pp.skipLineComment = function(startSkip) {
4832 var start = this.pos;
4833 var startLoc = this.options.onComment && this.curPosition();
4834 var ch = this.input.charCodeAt(this.pos += startSkip);
4835 while (this.pos < this.input.length && !isNewLine(ch)) {
4836 ch = this.input.charCodeAt(++this.pos);
4838 if (this.options.onComment)
4839 { this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos,
4840 startLoc, this.curPosition()); }
4843 // Called at the start of the parse and after every token. Skips
4844 // whitespace and comments, and.
4846 pp.skipSpace = function() {
4847 loop: while (this.pos < this.input.length) {
4848 var ch = this.input.charCodeAt(this.pos);
4850 case 32: case 160: // ' '
4854 if (this.input.charCodeAt(this.pos + 1) === 10) {
4857 case 10: case 8232: case 8233:
4859 if (this.options.locations) {
4861 this.lineStart = this.pos;
4865 switch (this.input.charCodeAt(this.pos + 1)) {
4867 this.skipBlockComment();
4870 this.skipLineComment(2);
4877 if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {
4886 // Called at the end of every token. Sets `end`, `val`, and
4887 // maintains `context` and `exprAllowed`, and skips the space after
4888 // the token, so that the next one's `start` will point at the
4891 pp.finishToken = function(type, val) {
4892 this.end = this.pos;
4893 if (this.options.locations) { this.endLoc = this.curPosition(); }
4894 var prevType = this.type;
4898 this.updateContext(prevType);
4901 // ### Token reading
4903 // This is the function that is called to fetch the next token. It
4904 // is somewhat obscure, because it works in character codes rather
4905 // than characters, and because operator parsing has been inlined
4908 // All in the name of speed.
4910 pp.readToken_dot = function() {
4911 var next = this.input.charCodeAt(this.pos + 1);
4912 if (next >= 48 && next <= 57) { return this.readNumber(true) }
4913 var next2 = this.input.charCodeAt(this.pos + 2);
4914 if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.'
4916 return this.finishToken(types$1.ellipsis)
4919 return this.finishToken(types$1.dot)
4923 pp.readToken_slash = function() { // '/'
4924 var next = this.input.charCodeAt(this.pos + 1);
4925 if (this.exprAllowed) { ++this.pos; return this.readRegexp() }
4926 if (next === 61) { return this.finishOp(types$1.assign, 2) }
4927 return this.finishOp(types$1.slash, 1)
4930 pp.readToken_mult_modulo_exp = function(code) { // '%*'
4931 var next = this.input.charCodeAt(this.pos + 1);
4933 var tokentype = code === 42 ? types$1.star : types$1.modulo;
4935 // exponentiation operator ** and **=
4936 if (this.options.ecmaVersion >= 7 && code === 42 && next === 42) {
4938 tokentype = types$1.starstar;
4939 next = this.input.charCodeAt(this.pos + 2);
4942 if (next === 61) { return this.finishOp(types$1.assign, size + 1) }
4943 return this.finishOp(tokentype, size)
4946 pp.readToken_pipe_amp = function(code) { // '|&'
4947 var next = this.input.charCodeAt(this.pos + 1);
4948 if (next === code) {
4949 if (this.options.ecmaVersion >= 12) {
4950 var next2 = this.input.charCodeAt(this.pos + 2);
4951 if (next2 === 61) { return this.finishOp(types$1.assign, 3) }
4953 return this.finishOp(code === 124 ? types$1.logicalOR : types$1.logicalAND, 2)
4955 if (next === 61) { return this.finishOp(types$1.assign, 2) }
4956 return this.finishOp(code === 124 ? types$1.bitwiseOR : types$1.bitwiseAND, 1)
4959 pp.readToken_caret = function() { // '^'
4960 var next = this.input.charCodeAt(this.pos + 1);
4961 if (next === 61) { return this.finishOp(types$1.assign, 2) }
4962 return this.finishOp(types$1.bitwiseXOR, 1)
4965 pp.readToken_plus_min = function(code) { // '+-'
4966 var next = this.input.charCodeAt(this.pos + 1);
4967 if (next === code) {
4968 if (next === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 &&
4969 (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) {
4970 // A `-->` line comment
4971 this.skipLineComment(3);
4973 return this.nextToken()
4975 return this.finishOp(types$1.incDec, 2)
4977 if (next === 61) { return this.finishOp(types$1.assign, 2) }
4978 return this.finishOp(types$1.plusMin, 1)
4981 pp.readToken_lt_gt = function(code) { // '<>'
4982 var next = this.input.charCodeAt(this.pos + 1);
4984 if (next === code) {
4985 size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;
4986 if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types$1.assign, size + 1) }
4987 return this.finishOp(types$1.bitShift, size)
4989 if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 &&
4990 this.input.charCodeAt(this.pos + 3) === 45) {
4991 // `<!--`, an XML-style comment that should be interpreted as a line comment
4992 this.skipLineComment(4);
4994 return this.nextToken()
4996 if (next === 61) { size = 2; }
4997 return this.finishOp(types$1.relational, size)
5000 pp.readToken_eq_excl = function(code) { // '=!'
5001 var next = this.input.charCodeAt(this.pos + 1);
5002 if (next === 61) { return this.finishOp(types$1.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2) }
5003 if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) { // '=>'
5005 return this.finishToken(types$1.arrow)
5007 return this.finishOp(code === 61 ? types$1.eq : types$1.prefix, 1)
5010 pp.readToken_question = function() { // '?'
5011 var ecmaVersion = this.options.ecmaVersion;
5012 if (ecmaVersion >= 11) {
5013 var next = this.input.charCodeAt(this.pos + 1);
5015 var next2 = this.input.charCodeAt(this.pos + 2);
5016 if (next2 < 48 || next2 > 57) { return this.finishOp(types$1.questionDot, 2) }
5019 if (ecmaVersion >= 12) {
5020 var next2$1 = this.input.charCodeAt(this.pos + 2);
5021 if (next2$1 === 61) { return this.finishOp(types$1.assign, 3) }
5023 return this.finishOp(types$1.coalesce, 2)
5026 return this.finishOp(types$1.question, 1)
5029 pp.readToken_numberSign = function() { // '#'
5030 var ecmaVersion = this.options.ecmaVersion;
5031 var code = 35; // '#'
5032 if (ecmaVersion >= 13) {
5034 code = this.fullCharCodeAtPos();
5035 if (isIdentifierStart(code, true) || code === 92 /* '\' */) {
5036 return this.finishToken(types$1.privateId, this.readWord1())
5040 this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
5043 pp.getTokenFromCode = function(code) {
5045 // The interpretation of a dot depends on whether it is followed
5046 // by a digit or another two dots.
5048 return this.readToken_dot()
5050 // Punctuation tokens.
5051 case 40: ++this.pos; return this.finishToken(types$1.parenL)
5052 case 41: ++this.pos; return this.finishToken(types$1.parenR)
5053 case 59: ++this.pos; return this.finishToken(types$1.semi)
5054 case 44: ++this.pos; return this.finishToken(types$1.comma)
5055 case 91: ++this.pos; return this.finishToken(types$1.bracketL)
5056 case 93: ++this.pos; return this.finishToken(types$1.bracketR)
5057 case 123: ++this.pos; return this.finishToken(types$1.braceL)
5058 case 125: ++this.pos; return this.finishToken(types$1.braceR)
5059 case 58: ++this.pos; return this.finishToken(types$1.colon)
5062 if (this.options.ecmaVersion < 6) { break }
5064 return this.finishToken(types$1.backQuote)
5067 var next = this.input.charCodeAt(this.pos + 1);
5068 if (next === 120 || next === 88) { return this.readRadixNumber(16) } // '0x', '0X' - hex number
5069 if (this.options.ecmaVersion >= 6) {
5070 if (next === 111 || next === 79) { return this.readRadixNumber(8) } // '0o', '0O' - octal number
5071 if (next === 98 || next === 66) { return this.readRadixNumber(2) } // '0b', '0B' - binary number
5074 // Anything else beginning with a digit is an integer, octal
5075 // number, or float.
5076 case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: // 1-9
5077 return this.readNumber(false)
5079 // Quotes produce strings.
5080 case 34: case 39: // '"', "'"
5081 return this.readString(code)
5083 // Operators are parsed inline in tiny state machines. '=' (61) is
5084 // often referred to. `finishOp` simply skips the amount of
5085 // characters it is given as second argument, and returns a token
5086 // of the type given by its first argument.
5088 return this.readToken_slash()
5090 case 37: case 42: // '%*'
5091 return this.readToken_mult_modulo_exp(code)
5093 case 124: case 38: // '|&'
5094 return this.readToken_pipe_amp(code)
5097 return this.readToken_caret()
5099 case 43: case 45: // '+-'
5100 return this.readToken_plus_min(code)
5102 case 60: case 62: // '<>'
5103 return this.readToken_lt_gt(code)
5105 case 61: case 33: // '=!'
5106 return this.readToken_eq_excl(code)
5109 return this.readToken_question()
5112 return this.finishOp(types$1.prefix, 1)
5115 return this.readToken_numberSign()
5118 this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
5121 pp.finishOp = function(type, size) {
5122 var str = this.input.slice(this.pos, this.pos + size);
5124 return this.finishToken(type, str)
5127 pp.readRegexp = function() {
5128 var escaped, inClass, start = this.pos;
5130 if (this.pos >= this.input.length) { this.raise(start, "Unterminated regular expression"); }
5131 var ch = this.input.charAt(this.pos);
5132 if (lineBreak.test(ch)) { this.raise(start, "Unterminated regular expression"); }
5134 if (ch === "[") { inClass = true; }
5135 else if (ch === "]" && inClass) { inClass = false; }
5136 else if (ch === "/" && !inClass) { break }
5137 escaped = ch === "\\";
5138 } else { escaped = false; }
5141 var pattern = this.input.slice(start, this.pos);
5143 var flagsStart = this.pos;
5144 var flags = this.readWord1();
5145 if (this.containsEsc) { this.unexpected(flagsStart); }
5148 var state = this.regexpState || (this.regexpState = new RegExpValidationState(this));
5149 state.reset(start, pattern, flags);
5150 this.validateRegExpFlags(state);
5151 this.validateRegExpPattern(state);
5153 // Create Literal#value property value.
5156 value = new RegExp(pattern, flags);
5158 // ESTree requires null if it failed to instantiate RegExp object.
5159 // https://github.com/estree/estree/blob/a27003adf4fd7bfad44de9cef372a2eacd527b1c/es5.md#regexpliteral
5162 return this.finishToken(types$1.regexp, {pattern: pattern, flags: flags, value: value})
5165 // Read an integer in the given radix. Return null if zero digits
5166 // were read, the integer value otherwise. When `len` is given, this
5167 // will return `null` unless the integer has exactly `len` digits.
5169 pp.readInt = function(radix, len, maybeLegacyOctalNumericLiteral) {
5170 // `len` is used for character escape sequences. In that case, disallow separators.
5171 var allowSeparators = this.options.ecmaVersion >= 12 && len === undefined;
5173 // `maybeLegacyOctalNumericLiteral` is true if it doesn't have prefix (0x,0o,0b)
5174 // and isn't fraction part nor exponent part. In that case, if the first digit
5175 // is zero then disallow separators.
5176 var isLegacyOctalNumericLiteral = maybeLegacyOctalNumericLiteral && this.input.charCodeAt(this.pos) === 48;
5178 var start = this.pos, total = 0, lastCode = 0;
5179 for (var i = 0, e = len == null ? Infinity : len; i < e; ++i, ++this.pos) {
5180 var code = this.input.charCodeAt(this.pos), val = (void 0);
5182 if (allowSeparators && code === 95) {
5183 if (isLegacyOctalNumericLiteral) { this.raiseRecoverable(this.pos, "Numeric separator is not allowed in legacy octal numeric literals"); }
5184 if (lastCode === 95) { this.raiseRecoverable(this.pos, "Numeric separator must be exactly one underscore"); }
5185 if (i === 0) { this.raiseRecoverable(this.pos, "Numeric separator is not allowed at the first of digits"); }
5190 if (code >= 97) { val = code - 97 + 10; } // a
5191 else if (code >= 65) { val = code - 65 + 10; } // A
5192 else if (code >= 48 && code <= 57) { val = code - 48; } // 0-9
5193 else { val = Infinity; }
5194 if (val >= radix) { break }
5196 total = total * radix + val;
5199 if (allowSeparators && lastCode === 95) { this.raiseRecoverable(this.pos - 1, "Numeric separator is not allowed at the last of digits"); }
5200 if (this.pos === start || len != null && this.pos - start !== len) { return null }
5205 function stringToNumber(str, isLegacyOctalNumericLiteral) {
5206 if (isLegacyOctalNumericLiteral) {
5207 return parseInt(str, 8)
5210 // `parseFloat(value)` stops parsing at the first numeric separator then returns a wrong value.
5211 return parseFloat(str.replace(/_/g, ""))
5214 function stringToBigInt(str) {
5215 if (typeof BigInt !== "function") {
5219 // `BigInt(value)` throws syntax error if the string contains numeric separators.
5220 return BigInt(str.replace(/_/g, ""))
5223 pp.readRadixNumber = function(radix) {
5224 var start = this.pos;
5225 this.pos += 2; // 0x
5226 var val = this.readInt(radix);
5227 if (val == null) { this.raise(this.start + 2, "Expected number in radix " + radix); }
5228 if (this.options.ecmaVersion >= 11 && this.input.charCodeAt(this.pos) === 110) {
5229 val = stringToBigInt(this.input.slice(start, this.pos));
5231 } else if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
5232 return this.finishToken(types$1.num, val)
5235 // Read an integer, octal integer, or floating-point number.
5237 pp.readNumber = function(startsWithDot) {
5238 var start = this.pos;
5239 if (!startsWithDot && this.readInt(10, undefined, true) === null) { this.raise(start, "Invalid number"); }
5240 var octal = this.pos - start >= 2 && this.input.charCodeAt(start) === 48;
5241 if (octal && this.strict) { this.raise(start, "Invalid number"); }
5242 var next = this.input.charCodeAt(this.pos);
5243 if (!octal && !startsWithDot && this.options.ecmaVersion >= 11 && next === 110) {
5244 var val$1 = stringToBigInt(this.input.slice(start, this.pos));
5246 if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
5247 return this.finishToken(types$1.num, val$1)
5249 if (octal && /[89]/.test(this.input.slice(start, this.pos))) { octal = false; }
5250 if (next === 46 && !octal) { // '.'
5253 next = this.input.charCodeAt(this.pos);
5255 if ((next === 69 || next === 101) && !octal) { // 'eE'
5256 next = this.input.charCodeAt(++this.pos);
5257 if (next === 43 || next === 45) { ++this.pos; } // '+-'
5258 if (this.readInt(10) === null) { this.raise(start, "Invalid number"); }
5260 if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
5262 var val = stringToNumber(this.input.slice(start, this.pos), octal);
5263 return this.finishToken(types$1.num, val)
5266 // Read a string value, interpreting backslash-escapes.
5268 pp.readCodePoint = function() {
5269 var ch = this.input.charCodeAt(this.pos), code;
5271 if (ch === 123) { // '{'
5272 if (this.options.ecmaVersion < 6) { this.unexpected(); }
5273 var codePos = ++this.pos;
5274 code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);
5276 if (code > 0x10FFFF) { this.invalidStringToken(codePos, "Code point out of bounds"); }
5278 code = this.readHexChar(4);
5283 pp.readString = function(quote) {
5284 var out = "", chunkStart = ++this.pos;
5286 if (this.pos >= this.input.length) { this.raise(this.start, "Unterminated string constant"); }
5287 var ch = this.input.charCodeAt(this.pos);
5288 if (ch === quote) { break }
5289 if (ch === 92) { // '\'
5290 out += this.input.slice(chunkStart, this.pos);
5291 out += this.readEscapedChar(false);
5292 chunkStart = this.pos;
5293 } else if (ch === 0x2028 || ch === 0x2029) {
5294 if (this.options.ecmaVersion < 10) { this.raise(this.start, "Unterminated string constant"); }
5296 if (this.options.locations) {
5298 this.lineStart = this.pos;
5301 if (isNewLine(ch)) { this.raise(this.start, "Unterminated string constant"); }
5305 out += this.input.slice(chunkStart, this.pos++);
5306 return this.finishToken(types$1.string, out)
5309 // Reads template string tokens.
5311 var INVALID_TEMPLATE_ESCAPE_ERROR = {};
5313 pp.tryReadTemplateToken = function() {
5314 this.inTemplateElement = true;
5316 this.readTmplToken();
5318 if (err === INVALID_TEMPLATE_ESCAPE_ERROR) {
5319 this.readInvalidTemplateToken();
5325 this.inTemplateElement = false;
5328 pp.invalidStringToken = function(position, message) {
5329 if (this.inTemplateElement && this.options.ecmaVersion >= 9) {
5330 throw INVALID_TEMPLATE_ESCAPE_ERROR
5332 this.raise(position, message);
5336 pp.readTmplToken = function() {
5337 var out = "", chunkStart = this.pos;
5339 if (this.pos >= this.input.length) { this.raise(this.start, "Unterminated template"); }
5340 var ch = this.input.charCodeAt(this.pos);
5341 if (ch === 96 || ch === 36 && this.input.charCodeAt(this.pos + 1) === 123) { // '`', '${'
5342 if (this.pos === this.start && (this.type === types$1.template || this.type === types$1.invalidTemplate)) {
5345 return this.finishToken(types$1.dollarBraceL)
5348 return this.finishToken(types$1.backQuote)
5351 out += this.input.slice(chunkStart, this.pos);
5352 return this.finishToken(types$1.template, out)
5354 if (ch === 92) { // '\'
5355 out += this.input.slice(chunkStart, this.pos);
5356 out += this.readEscapedChar(true);
5357 chunkStart = this.pos;
5358 } else if (isNewLine(ch)) {
5359 out += this.input.slice(chunkStart, this.pos);
5363 if (this.input.charCodeAt(this.pos) === 10) { ++this.pos; }
5368 out += String.fromCharCode(ch);
5371 if (this.options.locations) {
5373 this.lineStart = this.pos;
5375 chunkStart = this.pos;
5382 // Reads a template token to search for the end, without validating any escape sequences
5383 pp.readInvalidTemplateToken = function() {
5384 for (; this.pos < this.input.length; this.pos++) {
5385 switch (this.input[this.pos]) {
5391 if (this.input[this.pos + 1] !== "{") {
5397 return this.finishToken(types$1.invalidTemplate, this.input.slice(this.start, this.pos))
5402 this.raise(this.start, "Unterminated template");
5405 // Used to read escaped characters
5407 pp.readEscapedChar = function(inTemplate) {
5408 var ch = this.input.charCodeAt(++this.pos);
5411 case 110: return "\n" // 'n' -> '\n'
5412 case 114: return "\r" // 'r' -> '\r'
5413 case 120: return String.fromCharCode(this.readHexChar(2)) // 'x'
5414 case 117: return codePointToString(this.readCodePoint()) // 'u'
5415 case 116: return "\t" // 't' -> '\t'
5416 case 98: return "\b" // 'b' -> '\b'
5417 case 118: return "\u000b" // 'v' -> '\u000b'
5418 case 102: return "\f" // 'f' -> '\f'
5419 case 13: if (this.input.charCodeAt(this.pos) === 10) { ++this.pos; } // '\r\n'
5421 if (this.options.locations) { this.lineStart = this.pos; ++this.curLine; }
5426 this.invalidStringToken(
5428 "Invalid escape sequence"
5432 var codePos = this.pos - 1;
5434 this.invalidStringToken(
5436 "Invalid escape sequence in template string"
5442 if (ch >= 48 && ch <= 55) {
5443 var octalStr = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0];
5444 var octal = parseInt(octalStr, 8);
5446 octalStr = octalStr.slice(0, -1);
5447 octal = parseInt(octalStr, 8);
5449 this.pos += octalStr.length - 1;
5450 ch = this.input.charCodeAt(this.pos);
5451 if ((octalStr !== "0" || ch === 56 || ch === 57) && (this.strict || inTemplate)) {
5452 this.invalidStringToken(
5453 this.pos - 1 - octalStr.length,
5455 ? "Octal literal in template string"
5456 : "Octal literal in strict mode"
5459 return String.fromCharCode(octal)
5461 if (isNewLine(ch)) {
5462 // Unicode new line characters after \ get removed from output in both
5463 // template literals and strings
5466 return String.fromCharCode(ch)
5470 // Used to read character escape sequences ('\x', '\u', '\U').
5472 pp.readHexChar = function(len) {
5473 var codePos = this.pos;
5474 var n = this.readInt(16, len);
5475 if (n === null) { this.invalidStringToken(codePos, "Bad character escape sequence"); }
5479 // Read an identifier, and return it as a string. Sets `this.containsEsc`
5480 // to whether the word contained a '\u' escape.
5482 // Incrementally adds only escaped chars, adding other chunks as-is
5483 // as a micro-optimization.
5485 pp.readWord1 = function() {
5486 this.containsEsc = false;
5487 var word = "", first = true, chunkStart = this.pos;
5488 var astral = this.options.ecmaVersion >= 6;
5489 while (this.pos < this.input.length) {
5490 var ch = this.fullCharCodeAtPos();
5491 if (isIdentifierChar(ch, astral)) {
5492 this.pos += ch <= 0xffff ? 1 : 2;
5493 } else if (ch === 92) { // "\"
5494 this.containsEsc = true;
5495 word += this.input.slice(chunkStart, this.pos);
5496 var escStart = this.pos;
5497 if (this.input.charCodeAt(++this.pos) !== 117) // "u"
5498 { this.invalidStringToken(this.pos, "Expecting Unicode escape sequence \\uXXXX"); }
5500 var esc = this.readCodePoint();
5501 if (!(first ? isIdentifierStart : isIdentifierChar)(esc, astral))
5502 { this.invalidStringToken(escStart, "Invalid Unicode escape"); }
5503 word += codePointToString(esc);
5504 chunkStart = this.pos;
5510 return word + this.input.slice(chunkStart, this.pos)
5513 // Read an identifier or keyword token. Will check for reserved
5514 // words when necessary.
5516 pp.readWord = function() {
5517 var word = this.readWord1();
5518 var type = types$1.name;
5519 if (this.keywords.test(word)) {
5520 type = keywords[word];
5522 return this.finishToken(type, word)
5525 // Acorn is a tiny, fast JavaScript parser written in JavaScript.
5527 var version = "8.7.1";
5532 defaultOptions: defaultOptions,
5534 SourceLocation: SourceLocation,
5535 getLineInfo: getLineInfo,
5537 TokenType: TokenType,
5539 keywordTypes: keywords,
5540 TokContext: TokContext,
5542 isIdentifierChar: isIdentifierChar,
5543 isIdentifierStart: isIdentifierStart,
5545 isNewLine: isNewLine,
5546 lineBreak: lineBreak,
5547 lineBreakG: lineBreakG,
5548 nonASCIIwhitespace: nonASCIIwhitespace
5551 // The main exported interface (under `self.acorn` when in the
5552 // browser) is a `parse` function that takes a code string and
5553 // returns an abstract syntax tree as specified by [Mozilla parser
5556 // [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
5558 function parse(input, options) {
5559 return Parser.parse(input, options)
5562 // This function tries to parse a single expression at a given
5563 // offset in a string. Useful for parsing mixed-language formats
5564 // that embed JavaScript expressions.
5566 function parseExpressionAt(input, pos, options) {
5567 return Parser.parseExpressionAt(input, pos, options)
5570 // Acorn is organized as a tokenizer and a recursive-descent parser.
5571 // The `tokenizer` export provides an interface to the tokenizer.
5573 function tokenizer(input, options) {
5574 return Parser.tokenizer(input, options)
5577 export { Node, Parser, Position, SourceLocation, TokContext, Token, TokenType, defaultOptions, getLineInfo, isIdentifierChar, isIdentifierStart, isNewLine, keywords as keywordTypes, lineBreak, lineBreakG, nonASCIIwhitespace, parse, parseExpressionAt, types as tokContexts, types$1 as tokTypes, tokenizer, version };