source: imaps-frontend/node_modules/acorn/dist/acorn.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

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