sprockets-rollup 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sprockets/buble.js +1167 -1124
- metadata +2 -2
data/lib/sprockets/buble.js
CHANGED
@@ -23,16 +23,16 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
23
23
|
7: "enum",
|
24
24
|
strict: "implements interface let package private protected public static yield",
|
25
25
|
strictBind: "eval arguments"
|
26
|
-
}
|
26
|
+
};
|
27
27
|
|
28
28
|
// And the keywords
|
29
29
|
|
30
|
-
var ecma5AndLessKeywords = "break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this"
|
30
|
+
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";
|
31
31
|
|
32
32
|
var keywords = {
|
33
33
|
5: ecma5AndLessKeywords,
|
34
34
|
6: ecma5AndLessKeywords + " const class extends export import super"
|
35
|
-
}
|
35
|
+
};
|
36
36
|
|
37
37
|
// ## Character categories
|
38
38
|
|
@@ -42,31 +42,31 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
42
42
|
// code point above 128.
|
43
43
|
// Generated by `bin/generate-identifier-regex.js`.
|
44
44
|
|
45
|
-
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\u0561-\u0587\u05d0-\u05ea\u05f0-\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\u08a0-\u08b4\u08b6-\u08bd\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\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\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\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fd5\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ae\ua7b0-\ua7b7\ua7f7-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\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-\uab65\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"
|
46
|
-
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\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d4-\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\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\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c03\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\u0d01-\u0d03\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\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\u1cf2-\u1cf4\u1cf8\u1cf9\u1dc0-\u1df5\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua900-\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"
|
45
|
+
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\u0561-\u0587\u05d0-\u05ea\u05f0-\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\u08a0-\u08b4\u08b6-\u08bd\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\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\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\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fd5\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ae\ua7b0-\ua7b7\ua7f7-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\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-\uab65\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";
|
46
|
+
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\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d4-\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\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\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c03\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\u0d01-\u0d03\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\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\u1cf2-\u1cf4\u1cf8\u1cf9\u1dc0-\u1df5\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua900-\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";
|
47
47
|
|
48
|
-
var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]")
|
49
|
-
var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]")
|
48
|
+
var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
|
49
|
+
var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
|
50
50
|
|
51
|
-
nonASCIIidentifierStartChars = nonASCIIidentifierChars = null
|
51
|
+
nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
|
52
52
|
|
53
53
|
// These are a run-length and offset encoded representation of the
|
54
54
|
// >0xffff code points that are a valid part of identifiers. The
|
55
55
|
// offset starts at 0x10000, and each pair of numbers represents an
|
56
56
|
// offset to the next range, and then a size of the range. They were
|
57
57
|
// generated by bin/generate-identifier-regex.js
|
58
|
-
var astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,17,26,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,26,45,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,785,52,76,44,33,24,27,35,42,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,25,391,63,32,0,449,56,264,8,2,36,18,0,50,29,881,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,881,68,12,0,67,12,65,0,32,6124,20,754,9486,1,3071,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,4149,196,60,67,1213,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,42710,42,4148,12,221,3,5761,10591,541]
|
59
|
-
var astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,1306,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,52,0,13,2,49,13,10,2,4,9,83,11,7,0,161,11,6,9,7,3,57,0,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,87,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,423,9,838,7,2,7,17,9,57,21,2,13,19882,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239]
|
58
|
+
var astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,17,26,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,26,45,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,785,52,76,44,33,24,27,35,42,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,25,391,63,32,0,449,56,264,8,2,36,18,0,50,29,881,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,881,68,12,0,67,12,65,0,32,6124,20,754,9486,1,3071,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,4149,196,60,67,1213,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,42710,42,4148,12,221,3,5761,10591,541];
|
59
|
+
var astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,1306,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,52,0,13,2,49,13,10,2,4,9,83,11,7,0,161,11,6,9,7,3,57,0,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,87,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,423,9,838,7,2,7,17,9,57,21,2,13,19882,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239];
|
60
60
|
|
61
61
|
// This has a complexity linear to the value of the code. The
|
62
62
|
// assumption is that looking up astral identifier characters is
|
63
63
|
// rare.
|
64
64
|
function isInAstralSet(code, set) {
|
65
|
-
var pos = 0x10000
|
65
|
+
var pos = 0x10000;
|
66
66
|
for (var i = 0; i < set.length; i += 2) {
|
67
|
-
pos += set[i]
|
67
|
+
pos += set[i];
|
68
68
|
if (pos > code) return false
|
69
|
-
pos += set[i + 1]
|
69
|
+
pos += set[i + 1];
|
70
70
|
if (pos >= code) return true
|
71
71
|
}
|
72
72
|
}
|
@@ -123,16 +123,16 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
123
123
|
var TokenType = function TokenType(label, conf) {
|
124
124
|
if ( conf === void 0 ) conf = {};
|
125
125
|
|
126
|
-
this.label = label
|
127
|
-
this.keyword = conf.keyword
|
128
|
-
this.beforeExpr = !!conf.beforeExpr
|
129
|
-
this.startsExpr = !!conf.startsExpr
|
130
|
-
this.isLoop = !!conf.isLoop
|
131
|
-
this.isAssign = !!conf.isAssign
|
132
|
-
this.prefix = !!conf.prefix
|
133
|
-
this.postfix = !!conf.postfix
|
134
|
-
this.binop = conf.binop || null
|
135
|
-
this.updateContext = null
|
126
|
+
this.label = label;
|
127
|
+
this.keyword = conf.keyword;
|
128
|
+
this.beforeExpr = !!conf.beforeExpr;
|
129
|
+
this.startsExpr = !!conf.startsExpr;
|
130
|
+
this.isLoop = !!conf.isLoop;
|
131
|
+
this.isAssign = !!conf.isAssign;
|
132
|
+
this.prefix = !!conf.prefix;
|
133
|
+
this.postfix = !!conf.postfix;
|
134
|
+
this.binop = conf.binop || null;
|
135
|
+
this.updateContext = null;
|
136
136
|
};
|
137
137
|
|
138
138
|
function binop(name, prec) {
|
@@ -142,13 +142,13 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
142
142
|
var startsExpr = {startsExpr: true};
|
143
143
|
// Map keyword names to token types.
|
144
144
|
|
145
|
-
var keywordTypes = {}
|
145
|
+
var keywordTypes = {};
|
146
146
|
|
147
147
|
// Succinct definitions of keyword token types
|
148
148
|
function kw(name, options) {
|
149
149
|
if ( options === void 0 ) options = {};
|
150
150
|
|
151
|
-
options.keyword = name
|
151
|
+
options.keyword = name;
|
152
152
|
return keywordTypes[name] = new TokenType(name, options)
|
153
153
|
}
|
154
154
|
|
@@ -245,21 +245,21 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
245
245
|
_typeof: kw("typeof", {beforeExpr: true, prefix: true, startsExpr: true}),
|
246
246
|
_void: kw("void", {beforeExpr: true, prefix: true, startsExpr: true}),
|
247
247
|
_delete: kw("delete", {beforeExpr: true, prefix: true, startsExpr: true})
|
248
|
-
}
|
248
|
+
};
|
249
249
|
|
250
250
|
// Matches a whole line break (where CRLF is considered a single
|
251
251
|
// line break). Used to count lines.
|
252
252
|
|
253
|
-
var lineBreak = /\r\n?|\n|\u2028|\u2029
|
254
|
-
var lineBreakG = new RegExp(lineBreak.source, "g")
|
253
|
+
var lineBreak = /\r\n?|\n|\u2028|\u2029/;
|
254
|
+
var lineBreakG = new RegExp(lineBreak.source, "g");
|
255
255
|
|
256
256
|
function isNewLine(code) {
|
257
257
|
return code === 10 || code === 13 || code === 0x2028 || code == 0x2029
|
258
258
|
}
|
259
259
|
|
260
|
-
var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]
|
260
|
+
var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
|
261
261
|
|
262
|
-
var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g
|
262
|
+
var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
|
263
263
|
|
264
264
|
function isArray(obj) {
|
265
265
|
return Object.prototype.toString.call(obj) === "[object Array]"
|
@@ -275,8 +275,8 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
275
275
|
// `startLoc` and `endLoc` properties.
|
276
276
|
|
277
277
|
var Position = function Position(line, col) {
|
278
|
-
this.line = line
|
279
|
-
this.column = col
|
278
|
+
this.line = line;
|
279
|
+
this.column = col;
|
280
280
|
};
|
281
281
|
|
282
282
|
Position.prototype.offset = function offset (n) {
|
@@ -284,9 +284,9 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
284
284
|
};
|
285
285
|
|
286
286
|
var SourceLocation = function SourceLocation(p, start, end) {
|
287
|
-
this.start = start
|
288
|
-
this.end = end
|
289
|
-
if (p.sourceFile !== null) this.source = p.sourceFile
|
287
|
+
this.start = start;
|
288
|
+
this.end = end;
|
289
|
+
if (p.sourceFile !== null) this.source = p.sourceFile;
|
290
290
|
};
|
291
291
|
|
292
292
|
// The `getLineInfo` function is mostly useful when the
|
@@ -297,11 +297,11 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
297
297
|
|
298
298
|
function getLineInfo(input, offset) {
|
299
299
|
for (var line = 1, cur = 0;;) {
|
300
|
-
lineBreakG.lastIndex = cur
|
301
|
-
var match = lineBreakG.exec(input)
|
300
|
+
lineBreakG.lastIndex = cur;
|
301
|
+
var match = lineBreakG.exec(input);
|
302
302
|
if (match && match.index < offset) {
|
303
|
-
++line
|
304
|
-
cur = match.index + match[0].length
|
303
|
+
++line;
|
304
|
+
cur = match.index + match[0].length;
|
305
305
|
} else {
|
306
306
|
return new Position(line, offset - cur)
|
307
307
|
}
|
@@ -389,23 +389,23 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
389
389
|
// (non-standard) ParenthesizedExpression nodes
|
390
390
|
preserveParens: false,
|
391
391
|
plugins: {}
|
392
|
-
}
|
392
|
+
};
|
393
393
|
|
394
394
|
// Interpret and default an options object
|
395
395
|
|
396
396
|
function getOptions(opts) {
|
397
|
-
var options = {}
|
397
|
+
var options = {};
|
398
398
|
for (var opt in defaultOptions)
|
399
|
-
options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt]
|
399
|
+
options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt];
|
400
400
|
if (options.allowReserved == null)
|
401
|
-
options.allowReserved = options.ecmaVersion < 5
|
401
|
+
options.allowReserved = options.ecmaVersion < 5;
|
402
402
|
|
403
403
|
if (isArray(options.onToken)) {
|
404
|
-
var tokens = options.onToken
|
405
|
-
options.onToken = function (token) { return tokens.push(token); }
|
404
|
+
var tokens = options.onToken;
|
405
|
+
options.onToken = function (token) { return tokens.push(token); };
|
406
406
|
}
|
407
407
|
if (isArray(options.onComment))
|
408
|
-
options.onComment = pushComment(options, options.onComment)
|
408
|
+
options.onComment = pushComment(options, options.onComment);
|
409
409
|
|
410
410
|
return options
|
411
411
|
}
|
@@ -417,89 +417,89 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
417
417
|
value: text,
|
418
418
|
start: start,
|
419
419
|
end: end
|
420
|
-
}
|
420
|
+
};
|
421
421
|
if (options.locations)
|
422
|
-
comment.loc = new SourceLocation(this, startLoc, endLoc)
|
422
|
+
comment.loc = new SourceLocation(this, startLoc, endLoc);
|
423
423
|
if (options.ranges)
|
424
|
-
comment.range = [start, end]
|
425
|
-
array.push(comment)
|
424
|
+
comment.range = [start, end];
|
425
|
+
array.push(comment);
|
426
426
|
}
|
427
427
|
}
|
428
428
|
|
429
429
|
// Registered plugins
|
430
|
-
var plugins = {}
|
430
|
+
var plugins = {};
|
431
431
|
|
432
432
|
function keywordRegexp(words) {
|
433
433
|
return new RegExp("^(" + words.replace(/ /g, "|") + ")$")
|
434
434
|
}
|
435
435
|
|
436
436
|
var Parser = function Parser(options, input, startPos) {
|
437
|
-
this.options = options = getOptions(options)
|
438
|
-
this.sourceFile = options.sourceFile
|
439
|
-
this.keywords = keywordRegexp(keywords[options.ecmaVersion >= 6 ? 6 : 5])
|
437
|
+
this.options = options = getOptions(options);
|
438
|
+
this.sourceFile = options.sourceFile;
|
439
|
+
this.keywords = keywordRegexp(keywords[options.ecmaVersion >= 6 ? 6 : 5]);
|
440
440
|
var reserved = options.allowReserved ? "" :
|
441
|
-
reservedWords[options.ecmaVersion] + (options.sourceType == "module" ? " await" : "")
|
442
|
-
this.reservedWords = keywordRegexp(reserved)
|
443
|
-
var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict
|
444
|
-
this.reservedWordsStrict = keywordRegexp(reservedStrict)
|
445
|
-
this.reservedWordsStrictBind = keywordRegexp(reservedStrict + " " + reservedWords.strictBind)
|
446
|
-
this.input = String(input)
|
441
|
+
reservedWords[options.ecmaVersion] + (options.sourceType == "module" ? " await" : "");
|
442
|
+
this.reservedWords = keywordRegexp(reserved);
|
443
|
+
var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict;
|
444
|
+
this.reservedWordsStrict = keywordRegexp(reservedStrict);
|
445
|
+
this.reservedWordsStrictBind = keywordRegexp(reservedStrict + " " + reservedWords.strictBind);
|
446
|
+
this.input = String(input);
|
447
447
|
|
448
448
|
// Used to signal to callers of `readWord1` whether the word
|
449
449
|
// contained any escape sequences. This is needed because words with
|
450
450
|
// escape sequences must not be interpreted as keywords.
|
451
|
-
this.containsEsc = false
|
451
|
+
this.containsEsc = false;
|
452
452
|
|
453
453
|
// Load plugins
|
454
|
-
this.loadPlugins(options.plugins)
|
454
|
+
this.loadPlugins(options.plugins);
|
455
455
|
|
456
456
|
// Set up token state
|
457
457
|
|
458
458
|
// The current position of the tokenizer in the input.
|
459
459
|
if (startPos) {
|
460
|
-
this.pos = startPos
|
461
|
-
this.lineStart = Math.max(0, this.input.lastIndexOf("\n", startPos))
|
462
|
-
this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length
|
460
|
+
this.pos = startPos;
|
461
|
+
this.lineStart = Math.max(0, this.input.lastIndexOf("\n", startPos));
|
462
|
+
this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;
|
463
463
|
} else {
|
464
|
-
this.pos = this.lineStart = 0
|
465
|
-
this.curLine = 1
|
464
|
+
this.pos = this.lineStart = 0;
|
465
|
+
this.curLine = 1;
|
466
466
|
}
|
467
467
|
|
468
468
|
// Properties of the current token:
|
469
469
|
// Its type
|
470
|
-
this.type = tt.eof
|
470
|
+
this.type = tt.eof;
|
471
471
|
// For tokens that include more information than their type, the value
|
472
|
-
this.value = null
|
472
|
+
this.value = null;
|
473
473
|
// Its start and end offset
|
474
|
-
this.start = this.end = this.pos
|
474
|
+
this.start = this.end = this.pos;
|
475
475
|
// And, if locations are used, the {line, column} object
|
476
476
|
// corresponding to those offsets
|
477
|
-
this.startLoc = this.endLoc = this.curPosition()
|
477
|
+
this.startLoc = this.endLoc = this.curPosition();
|
478
478
|
|
479
479
|
// Position information for the previous token
|
480
|
-
this.lastTokEndLoc = this.lastTokStartLoc = null
|
481
|
-
this.lastTokStart = this.lastTokEnd = this.pos
|
480
|
+
this.lastTokEndLoc = this.lastTokStartLoc = null;
|
481
|
+
this.lastTokStart = this.lastTokEnd = this.pos;
|
482
482
|
|
483
483
|
// The context stack is used to superficially track syntactic
|
484
484
|
// context to predict whether a regular expression is allowed in a
|
485
485
|
// given position.
|
486
|
-
this.context = this.initialContext()
|
487
|
-
this.exprAllowed = true
|
486
|
+
this.context = this.initialContext();
|
487
|
+
this.exprAllowed = true;
|
488
488
|
|
489
489
|
// Figure out if it's a module code.
|
490
|
-
this.strict = this.inModule = options.sourceType === "module"
|
490
|
+
this.strict = this.inModule = options.sourceType === "module";
|
491
491
|
|
492
492
|
// Used to signify the start of a potential arrow function
|
493
|
-
this.potentialArrowAt = -1
|
493
|
+
this.potentialArrowAt = -1;
|
494
494
|
|
495
495
|
// Flags to track whether we are in a function, a generator.
|
496
|
-
this.inFunction = this.inGenerator = false
|
496
|
+
this.inFunction = this.inGenerator = false;
|
497
497
|
// Labels in scope.
|
498
|
-
this.labels = []
|
498
|
+
this.labels = [];
|
499
499
|
|
500
500
|
// If enabled, skip leading hashbang line.
|
501
501
|
if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === '#!')
|
502
|
-
this.skipLineComment(2)
|
502
|
+
this.skipLineComment(2);
|
503
503
|
};
|
504
504
|
|
505
505
|
// DEPRECATED Kept for backwards compatibility until 3.0 in case a plugin uses them
|
@@ -507,26 +507,26 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
507
507
|
Parser.prototype.isReservedWord = function isReservedWord (word) { return this.reservedWords.test(word) };
|
508
508
|
|
509
509
|
Parser.prototype.extend = function extend (name, f) {
|
510
|
-
this[name] = f(this[name])
|
510
|
+
this[name] = f(this[name]);
|
511
511
|
};
|
512
512
|
|
513
513
|
Parser.prototype.loadPlugins = function loadPlugins (pluginConfigs) {
|
514
514
|
var this$1 = this;
|
515
515
|
|
516
516
|
for (var name in pluginConfigs) {
|
517
|
-
var plugin = plugins[name]
|
517
|
+
var plugin = plugins[name];
|
518
518
|
if (!plugin) throw new Error("Plugin '" + name + "' not found")
|
519
|
-
plugin(this$1, pluginConfigs[name])
|
519
|
+
plugin(this$1, pluginConfigs[name]);
|
520
520
|
}
|
521
521
|
};
|
522
522
|
|
523
523
|
Parser.prototype.parse = function parse () {
|
524
|
-
var node = this.options.program || this.startNode()
|
525
|
-
this.nextToken()
|
524
|
+
var node = this.options.program || this.startNode();
|
525
|
+
this.nextToken();
|
526
526
|
return this.parseTopLevel(node)
|
527
527
|
};
|
528
528
|
|
529
|
-
var pp = Parser.prototype
|
529
|
+
var pp = Parser.prototype;
|
530
530
|
|
531
531
|
// ## Parser utilities
|
532
532
|
|
@@ -536,37 +536,37 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
536
536
|
return this.options.ecmaVersion >= 5 && stmt.type === "ExpressionStatement" &&
|
537
537
|
stmt.expression.type === "Literal" &&
|
538
538
|
stmt.expression.raw.slice(1, -1) === "use strict"
|
539
|
-
}
|
539
|
+
};
|
540
540
|
|
541
541
|
// Predicate that tests whether the next token is of the given
|
542
542
|
// type, and if yes, consumes it as a side effect.
|
543
543
|
|
544
544
|
pp.eat = function(type) {
|
545
545
|
if (this.type === type) {
|
546
|
-
this.next()
|
546
|
+
this.next();
|
547
547
|
return true
|
548
548
|
} else {
|
549
549
|
return false
|
550
550
|
}
|
551
|
-
}
|
551
|
+
};
|
552
552
|
|
553
553
|
// Tests whether parsed token is a contextual keyword.
|
554
554
|
|
555
555
|
pp.isContextual = function(name) {
|
556
556
|
return this.type === tt.name && this.value === name
|
557
|
-
}
|
557
|
+
};
|
558
558
|
|
559
559
|
// Consumes contextual keyword if possible.
|
560
560
|
|
561
561
|
pp.eatContextual = function(name) {
|
562
562
|
return this.value === name && this.eat(tt.name)
|
563
|
-
}
|
563
|
+
};
|
564
564
|
|
565
565
|
// Asserts that following token is given contextual keyword.
|
566
566
|
|
567
567
|
pp.expectContextual = function(name) {
|
568
|
-
if (!this.eatContextual(name)) this.unexpected()
|
569
|
-
}
|
568
|
+
if (!this.eatContextual(name)) this.unexpected();
|
569
|
+
};
|
570
570
|
|
571
571
|
// Test whether a semicolon can be inserted at the current position.
|
572
572
|
|
@@ -574,63 +574,63 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
574
574
|
return this.type === tt.eof ||
|
575
575
|
this.type === tt.braceR ||
|
576
576
|
lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
|
577
|
-
}
|
577
|
+
};
|
578
578
|
|
579
579
|
pp.insertSemicolon = function() {
|
580
580
|
if (this.canInsertSemicolon()) {
|
581
581
|
if (this.options.onInsertedSemicolon)
|
582
|
-
this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc)
|
582
|
+
this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc);
|
583
583
|
return true
|
584
584
|
}
|
585
|
-
}
|
585
|
+
};
|
586
586
|
|
587
587
|
// Consume a semicolon, or, failing that, see if we are allowed to
|
588
588
|
// pretend that there is a semicolon at this position.
|
589
589
|
|
590
590
|
pp.semicolon = function() {
|
591
|
-
if (!this.eat(tt.semi) && !this.insertSemicolon()) this.unexpected()
|
592
|
-
}
|
591
|
+
if (!this.eat(tt.semi) && !this.insertSemicolon()) this.unexpected();
|
592
|
+
};
|
593
593
|
|
594
594
|
pp.afterTrailingComma = function(tokType) {
|
595
595
|
if (this.type == tokType) {
|
596
596
|
if (this.options.onTrailingComma)
|
597
|
-
this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc)
|
598
|
-
this.next()
|
597
|
+
this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc);
|
598
|
+
this.next();
|
599
599
|
return true
|
600
600
|
}
|
601
|
-
}
|
601
|
+
};
|
602
602
|
|
603
603
|
// Expect a token of a given type. If found, consume it, otherwise,
|
604
604
|
// raise an unexpected token error.
|
605
605
|
|
606
606
|
pp.expect = function(type) {
|
607
|
-
this.eat(type) || this.unexpected()
|
608
|
-
}
|
607
|
+
this.eat(type) || this.unexpected();
|
608
|
+
};
|
609
609
|
|
610
610
|
// Raise an unexpected token error.
|
611
611
|
|
612
612
|
pp.unexpected = function(pos) {
|
613
|
-
this.raise(pos != null ? pos : this.start, "Unexpected token")
|
614
|
-
}
|
613
|
+
this.raise(pos != null ? pos : this.start, "Unexpected token");
|
614
|
+
};
|
615
615
|
|
616
616
|
var DestructuringErrors = function DestructuringErrors() {
|
617
|
-
this.shorthandAssign = 0
|
618
|
-
this.trailingComma = 0
|
617
|
+
this.shorthandAssign = 0;
|
618
|
+
this.trailingComma = 0;
|
619
619
|
};
|
620
620
|
|
621
621
|
pp.checkPatternErrors = function(refDestructuringErrors, andThrow) {
|
622
|
-
var trailing = refDestructuringErrors && refDestructuringErrors.trailingComma
|
622
|
+
var trailing = refDestructuringErrors && refDestructuringErrors.trailingComma;
|
623
623
|
if (!andThrow) return !!trailing
|
624
|
-
if (trailing) this.raise(trailing, "Comma is not permitted after the rest element")
|
625
|
-
}
|
624
|
+
if (trailing) this.raise(trailing, "Comma is not permitted after the rest element");
|
625
|
+
};
|
626
626
|
|
627
627
|
pp.checkExpressionErrors = function(refDestructuringErrors, andThrow) {
|
628
|
-
var pos = refDestructuringErrors && refDestructuringErrors.shorthandAssign
|
628
|
+
var pos = refDestructuringErrors && refDestructuringErrors.shorthandAssign;
|
629
629
|
if (!andThrow) return !!pos
|
630
|
-
if (pos) this.raise(pos, "Shorthand property assignments are valid only in destructuring patterns")
|
631
|
-
}
|
630
|
+
if (pos) this.raise(pos, "Shorthand property assignments are valid only in destructuring patterns");
|
631
|
+
};
|
632
632
|
|
633
|
-
var pp$1 = Parser.prototype
|
633
|
+
var pp$1 = Parser.prototype;
|
634
634
|
|
635
635
|
// ### Statement parsing
|
636
636
|
|
@@ -642,38 +642,38 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
642
642
|
pp$1.parseTopLevel = function(node) {
|
643
643
|
var this$1 = this;
|
644
644
|
|
645
|
-
var first = true
|
646
|
-
if (!node.body) node.body = []
|
645
|
+
var first = true;
|
646
|
+
if (!node.body) node.body = [];
|
647
647
|
while (this.type !== tt.eof) {
|
648
|
-
var stmt = this$1.parseStatement(true, true)
|
649
|
-
node.body.push(stmt)
|
648
|
+
var stmt = this$1.parseStatement(true, true);
|
649
|
+
node.body.push(stmt);
|
650
650
|
if (first) {
|
651
|
-
if (this$1.isUseStrict(stmt)) this$1.setStrict(true)
|
652
|
-
first = false
|
651
|
+
if (this$1.isUseStrict(stmt)) this$1.setStrict(true);
|
652
|
+
first = false;
|
653
653
|
}
|
654
654
|
}
|
655
|
-
this.next()
|
655
|
+
this.next();
|
656
656
|
if (this.options.ecmaVersion >= 6) {
|
657
|
-
node.sourceType = this.options.sourceType
|
657
|
+
node.sourceType = this.options.sourceType;
|
658
658
|
}
|
659
659
|
return this.finishNode(node, "Program")
|
660
|
-
}
|
660
|
+
};
|
661
661
|
|
662
662
|
var loopLabel = {kind: "loop"};
|
663
663
|
var switchLabel = {kind: "switch"};
|
664
664
|
pp$1.isLet = function() {
|
665
665
|
if (this.type !== tt.name || this.options.ecmaVersion < 6 || this.value != "let") return false
|
666
|
-
skipWhiteSpace.lastIndex = this.pos
|
667
|
-
var skip = skipWhiteSpace.exec(this.input)
|
668
|
-
var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next)
|
666
|
+
skipWhiteSpace.lastIndex = this.pos;
|
667
|
+
var skip = skipWhiteSpace.exec(this.input);
|
668
|
+
var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
|
669
669
|
if (nextCh === 91 || nextCh == 123) return true // '{' and '['
|
670
670
|
if (isIdentifierStart(nextCh, true)) {
|
671
671
|
for (var pos = next + 1; isIdentifierChar(this.input.charCodeAt(pos), true); ++pos) {}
|
672
|
-
var ident = this.input.slice(next, pos)
|
672
|
+
var ident = this.input.slice(next, pos);
|
673
673
|
if (!this.isKeyword(ident)) return true
|
674
674
|
}
|
675
675
|
return false
|
676
|
-
}
|
676
|
+
};
|
677
677
|
|
678
678
|
// Parse a single statement.
|
679
679
|
//
|
@@ -683,11 +683,11 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
683
683
|
// does not help.
|
684
684
|
|
685
685
|
pp$1.parseStatement = function(declaration, topLevel) {
|
686
|
-
var starttype = this.type, node = this.startNode(), kind
|
686
|
+
var starttype = this.type, node = this.startNode(), kind;
|
687
687
|
|
688
688
|
if (this.isLet()) {
|
689
|
-
starttype = tt._var
|
690
|
-
kind = "let"
|
689
|
+
starttype = tt._var;
|
690
|
+
kind = "let";
|
691
691
|
}
|
692
692
|
|
693
693
|
// Most types of statements are recognized by the keyword they
|
@@ -700,10 +700,10 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
700
700
|
case tt._do: return this.parseDoStatement(node)
|
701
701
|
case tt._for: return this.parseForStatement(node)
|
702
702
|
case tt._function:
|
703
|
-
if (!declaration && this.options.ecmaVersion >= 6) this.unexpected()
|
703
|
+
if (!declaration && this.options.ecmaVersion >= 6) this.unexpected();
|
704
704
|
return this.parseFunctionStatement(node)
|
705
705
|
case tt._class:
|
706
|
-
if (!declaration) this.unexpected()
|
706
|
+
if (!declaration) this.unexpected();
|
707
707
|
return this.parseClass(node, true)
|
708
708
|
case tt._if: return this.parseIfStatement(node)
|
709
709
|
case tt._return: return this.parseReturnStatement(node)
|
@@ -711,8 +711,8 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
711
711
|
case tt._throw: return this.parseThrowStatement(node)
|
712
712
|
case tt._try: return this.parseTryStatement(node)
|
713
713
|
case tt._const: case tt._var:
|
714
|
-
kind = kind || this.value
|
715
|
-
if (!declaration && kind != "var") this.unexpected()
|
714
|
+
kind = kind || this.value;
|
715
|
+
if (!declaration && kind != "var") this.unexpected();
|
716
716
|
return this.parseVarStatement(node, kind)
|
717
717
|
case tt._while: return this.parseWhileStatement(node)
|
718
718
|
case tt._with: return this.parseWithStatement(node)
|
@@ -722,9 +722,9 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
722
722
|
case tt._import:
|
723
723
|
if (!this.options.allowImportExportEverywhere) {
|
724
724
|
if (!topLevel)
|
725
|
-
this.raise(this.start, "'import' and 'export' may only appear at the top level")
|
725
|
+
this.raise(this.start, "'import' and 'export' may only appear at the top level");
|
726
726
|
if (!this.inModule)
|
727
|
-
this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'")
|
727
|
+
this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'");
|
728
728
|
}
|
729
729
|
return starttype === tt._import ? this.parseImport(node) : this.parseExport(node)
|
730
730
|
|
@@ -734,57 +734,57 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
734
734
|
// next token is a colon and the expression was a simple
|
735
735
|
// Identifier node, we switch to interpreting it as a label.
|
736
736
|
default:
|
737
|
-
var maybeName = this.value, expr = this.parseExpression()
|
737
|
+
var maybeName = this.value, expr = this.parseExpression();
|
738
738
|
if (starttype === tt.name && expr.type === "Identifier" && this.eat(tt.colon))
|
739
739
|
return this.parseLabeledStatement(node, maybeName, expr)
|
740
740
|
else return this.parseExpressionStatement(node, expr)
|
741
741
|
}
|
742
|
-
}
|
742
|
+
};
|
743
743
|
|
744
744
|
pp$1.parseBreakContinueStatement = function(node, keyword) {
|
745
745
|
var this$1 = this;
|
746
746
|
|
747
|
-
var isBreak = keyword == "break"
|
748
|
-
this.next()
|
749
|
-
if (this.eat(tt.semi) || this.insertSemicolon()) node.label = null
|
750
|
-
else if (this.type !== tt.name) this.unexpected()
|
747
|
+
var isBreak = keyword == "break";
|
748
|
+
this.next();
|
749
|
+
if (this.eat(tt.semi) || this.insertSemicolon()) node.label = null;
|
750
|
+
else if (this.type !== tt.name) this.unexpected();
|
751
751
|
else {
|
752
|
-
node.label = this.parseIdent()
|
753
|
-
this.semicolon()
|
752
|
+
node.label = this.parseIdent();
|
753
|
+
this.semicolon();
|
754
754
|
}
|
755
755
|
|
756
756
|
// Verify that there is an actual destination to break or
|
757
757
|
// continue to.
|
758
758
|
for (var i = 0; i < this.labels.length; ++i) {
|
759
|
-
var lab = this$1.labels[i]
|
759
|
+
var lab = this$1.labels[i];
|
760
760
|
if (node.label == null || lab.name === node.label.name) {
|
761
761
|
if (lab.kind != null && (isBreak || lab.kind === "loop")) break
|
762
762
|
if (node.label && isBreak) break
|
763
763
|
}
|
764
764
|
}
|
765
|
-
if (i === this.labels.length) this.raise(node.start, "Unsyntactic " + keyword)
|
765
|
+
if (i === this.labels.length) this.raise(node.start, "Unsyntactic " + keyword);
|
766
766
|
return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement")
|
767
|
-
}
|
767
|
+
};
|
768
768
|
|
769
769
|
pp$1.parseDebuggerStatement = function(node) {
|
770
|
-
this.next()
|
771
|
-
this.semicolon()
|
770
|
+
this.next();
|
771
|
+
this.semicolon();
|
772
772
|
return this.finishNode(node, "DebuggerStatement")
|
773
|
-
}
|
773
|
+
};
|
774
774
|
|
775
775
|
pp$1.parseDoStatement = function(node) {
|
776
|
-
this.next()
|
777
|
-
this.labels.push(loopLabel)
|
778
|
-
node.body = this.parseStatement(false)
|
779
|
-
this.labels.pop()
|
780
|
-
this.expect(tt._while)
|
781
|
-
node.test = this.parseParenExpression()
|
776
|
+
this.next();
|
777
|
+
this.labels.push(loopLabel);
|
778
|
+
node.body = this.parseStatement(false);
|
779
|
+
this.labels.pop();
|
780
|
+
this.expect(tt._while);
|
781
|
+
node.test = this.parseParenExpression();
|
782
782
|
if (this.options.ecmaVersion >= 6)
|
783
|
-
this.eat(tt.semi)
|
783
|
+
this.eat(tt.semi);
|
784
784
|
else
|
785
|
-
this.semicolon()
|
785
|
+
this.semicolon();
|
786
786
|
return this.finishNode(node, "DoWhileStatement")
|
787
|
-
}
|
787
|
+
};
|
788
788
|
|
789
789
|
// Disambiguating between a `for` and a `for`/`in` or `for`/`of`
|
790
790
|
// loop is non-trivial. Basically, we have to parse the init `var`
|
@@ -795,69 +795,69 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
795
795
|
// is a regular `for` loop.
|
796
796
|
|
797
797
|
pp$1.parseForStatement = function(node) {
|
798
|
-
this.next()
|
799
|
-
this.labels.push(loopLabel)
|
800
|
-
this.expect(tt.parenL)
|
798
|
+
this.next();
|
799
|
+
this.labels.push(loopLabel);
|
800
|
+
this.expect(tt.parenL);
|
801
801
|
if (this.type === tt.semi) return this.parseFor(node, null)
|
802
|
-
var isLet = this.isLet()
|
802
|
+
var isLet = this.isLet();
|
803
803
|
if (this.type === tt._var || this.type === tt._const || isLet) {
|
804
|
-
var init$1 = this.startNode(), kind = isLet ? "let" : this.value
|
805
|
-
this.next()
|
806
|
-
this.parseVar(init$1, true, kind)
|
807
|
-
this.finishNode(init$1, "VariableDeclaration")
|
804
|
+
var init$1 = this.startNode(), kind = isLet ? "let" : this.value;
|
805
|
+
this.next();
|
806
|
+
this.parseVar(init$1, true, kind);
|
807
|
+
this.finishNode(init$1, "VariableDeclaration");
|
808
808
|
if ((this.type === tt._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1 &&
|
809
809
|
!(kind !== "var" && init$1.declarations[0].init))
|
810
810
|
return this.parseForIn(node, init$1)
|
811
811
|
return this.parseFor(node, init$1)
|
812
812
|
}
|
813
|
-
var refDestructuringErrors = new DestructuringErrors
|
814
|
-
var init = this.parseExpression(true, refDestructuringErrors)
|
813
|
+
var refDestructuringErrors = new DestructuringErrors;
|
814
|
+
var init = this.parseExpression(true, refDestructuringErrors);
|
815
815
|
if (this.type === tt._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
|
816
|
-
this.checkPatternErrors(refDestructuringErrors, true)
|
817
|
-
this.toAssignable(init)
|
818
|
-
this.checkLVal(init)
|
816
|
+
this.checkPatternErrors(refDestructuringErrors, true);
|
817
|
+
this.toAssignable(init);
|
818
|
+
this.checkLVal(init);
|
819
819
|
return this.parseForIn(node, init)
|
820
820
|
} else {
|
821
|
-
this.checkExpressionErrors(refDestructuringErrors, true)
|
821
|
+
this.checkExpressionErrors(refDestructuringErrors, true);
|
822
822
|
}
|
823
823
|
return this.parseFor(node, init)
|
824
|
-
}
|
824
|
+
};
|
825
825
|
|
826
826
|
pp$1.parseFunctionStatement = function(node) {
|
827
|
-
this.next()
|
827
|
+
this.next();
|
828
828
|
return this.parseFunction(node, true)
|
829
|
-
}
|
829
|
+
};
|
830
830
|
|
831
831
|
pp$1.parseIfStatement = function(node) {
|
832
|
-
this.next()
|
833
|
-
node.test = this.parseParenExpression()
|
834
|
-
node.consequent = this.parseStatement(false)
|
835
|
-
node.alternate = this.eat(tt._else) ? this.parseStatement(false) : null
|
832
|
+
this.next();
|
833
|
+
node.test = this.parseParenExpression();
|
834
|
+
node.consequent = this.parseStatement(false);
|
835
|
+
node.alternate = this.eat(tt._else) ? this.parseStatement(false) : null;
|
836
836
|
return this.finishNode(node, "IfStatement")
|
837
|
-
}
|
837
|
+
};
|
838
838
|
|
839
839
|
pp$1.parseReturnStatement = function(node) {
|
840
840
|
if (!this.inFunction && !this.options.allowReturnOutsideFunction)
|
841
|
-
this.raise(this.start, "'return' outside of function")
|
842
|
-
this.next()
|
841
|
+
this.raise(this.start, "'return' outside of function");
|
842
|
+
this.next();
|
843
843
|
|
844
844
|
// In `return` (and `break`/`continue`), the keywords with
|
845
845
|
// optional arguments, we eagerly look for a semicolon or the
|
846
846
|
// possibility to insert one.
|
847
847
|
|
848
|
-
if (this.eat(tt.semi) || this.insertSemicolon()) node.argument = null
|
849
|
-
else { node.argument = this.parseExpression(); this.semicolon() }
|
848
|
+
if (this.eat(tt.semi) || this.insertSemicolon()) node.argument = null;
|
849
|
+
else { node.argument = this.parseExpression(); this.semicolon(); }
|
850
850
|
return this.finishNode(node, "ReturnStatement")
|
851
|
-
}
|
851
|
+
};
|
852
852
|
|
853
853
|
pp$1.parseSwitchStatement = function(node) {
|
854
854
|
var this$1 = this;
|
855
855
|
|
856
|
-
this.next()
|
857
|
-
node.discriminant = this.parseParenExpression()
|
858
|
-
node.cases = []
|
859
|
-
this.expect(tt.braceL)
|
860
|
-
this.labels.push(switchLabel)
|
856
|
+
this.next();
|
857
|
+
node.discriminant = this.parseParenExpression();
|
858
|
+
node.cases = [];
|
859
|
+
this.expect(tt.braceL);
|
860
|
+
this.labels.push(switchLabel);
|
861
861
|
|
862
862
|
// Statements under must be grouped (by label) in SwitchCase
|
863
863
|
// nodes. `cur` is used to keep the node that we are currently
|
@@ -865,117 +865,117 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
865
865
|
|
866
866
|
for (var cur, sawDefault = false; this.type != tt.braceR;) {
|
867
867
|
if (this$1.type === tt._case || this$1.type === tt._default) {
|
868
|
-
var isCase = this$1.type === tt._case
|
869
|
-
if (cur) this$1.finishNode(cur, "SwitchCase")
|
870
|
-
node.cases.push(cur = this$1.startNode())
|
871
|
-
cur.consequent = []
|
872
|
-
this$1.next()
|
868
|
+
var isCase = this$1.type === tt._case;
|
869
|
+
if (cur) this$1.finishNode(cur, "SwitchCase");
|
870
|
+
node.cases.push(cur = this$1.startNode());
|
871
|
+
cur.consequent = [];
|
872
|
+
this$1.next();
|
873
873
|
if (isCase) {
|
874
|
-
cur.test = this$1.parseExpression()
|
874
|
+
cur.test = this$1.parseExpression();
|
875
875
|
} else {
|
876
|
-
if (sawDefault) this$1.raiseRecoverable(this$1.lastTokStart, "Multiple default clauses")
|
877
|
-
sawDefault = true
|
878
|
-
cur.test = null
|
876
|
+
if (sawDefault) this$1.raiseRecoverable(this$1.lastTokStart, "Multiple default clauses");
|
877
|
+
sawDefault = true;
|
878
|
+
cur.test = null;
|
879
879
|
}
|
880
|
-
this$1.expect(tt.colon)
|
880
|
+
this$1.expect(tt.colon);
|
881
881
|
} else {
|
882
|
-
if (!cur) this$1.unexpected()
|
883
|
-
cur.consequent.push(this$1.parseStatement(true))
|
882
|
+
if (!cur) this$1.unexpected();
|
883
|
+
cur.consequent.push(this$1.parseStatement(true));
|
884
884
|
}
|
885
885
|
}
|
886
|
-
if (cur) this.finishNode(cur, "SwitchCase")
|
887
|
-
this.next() // Closing brace
|
888
|
-
this.labels.pop()
|
886
|
+
if (cur) this.finishNode(cur, "SwitchCase");
|
887
|
+
this.next(); // Closing brace
|
888
|
+
this.labels.pop();
|
889
889
|
return this.finishNode(node, "SwitchStatement")
|
890
|
-
}
|
890
|
+
};
|
891
891
|
|
892
892
|
pp$1.parseThrowStatement = function(node) {
|
893
|
-
this.next()
|
893
|
+
this.next();
|
894
894
|
if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start)))
|
895
|
-
this.raise(this.lastTokEnd, "Illegal newline after throw")
|
896
|
-
node.argument = this.parseExpression()
|
897
|
-
this.semicolon()
|
895
|
+
this.raise(this.lastTokEnd, "Illegal newline after throw");
|
896
|
+
node.argument = this.parseExpression();
|
897
|
+
this.semicolon();
|
898
898
|
return this.finishNode(node, "ThrowStatement")
|
899
|
-
}
|
899
|
+
};
|
900
900
|
|
901
901
|
// Reused empty array added for node fields that are always empty.
|
902
902
|
|
903
|
-
var empty = []
|
903
|
+
var empty = [];
|
904
904
|
|
905
905
|
pp$1.parseTryStatement = function(node) {
|
906
|
-
this.next()
|
907
|
-
node.block = this.parseBlock()
|
908
|
-
node.handler = null
|
906
|
+
this.next();
|
907
|
+
node.block = this.parseBlock();
|
908
|
+
node.handler = null;
|
909
909
|
if (this.type === tt._catch) {
|
910
|
-
var clause = this.startNode()
|
911
|
-
this.next()
|
912
|
-
this.expect(tt.parenL)
|
913
|
-
clause.param = this.parseBindingAtom()
|
914
|
-
this.checkLVal(clause.param, true)
|
915
|
-
this.expect(tt.parenR)
|
916
|
-
clause.body = this.parseBlock()
|
917
|
-
node.handler = this.finishNode(clause, "CatchClause")
|
918
|
-
}
|
919
|
-
node.finalizer = this.eat(tt._finally) ? this.parseBlock() : null
|
910
|
+
var clause = this.startNode();
|
911
|
+
this.next();
|
912
|
+
this.expect(tt.parenL);
|
913
|
+
clause.param = this.parseBindingAtom();
|
914
|
+
this.checkLVal(clause.param, true);
|
915
|
+
this.expect(tt.parenR);
|
916
|
+
clause.body = this.parseBlock();
|
917
|
+
node.handler = this.finishNode(clause, "CatchClause");
|
918
|
+
}
|
919
|
+
node.finalizer = this.eat(tt._finally) ? this.parseBlock() : null;
|
920
920
|
if (!node.handler && !node.finalizer)
|
921
|
-
this.raise(node.start, "Missing catch or finally clause")
|
921
|
+
this.raise(node.start, "Missing catch or finally clause");
|
922
922
|
return this.finishNode(node, "TryStatement")
|
923
|
-
}
|
923
|
+
};
|
924
924
|
|
925
925
|
pp$1.parseVarStatement = function(node, kind) {
|
926
|
-
this.next()
|
927
|
-
this.parseVar(node, false, kind)
|
928
|
-
this.semicolon()
|
926
|
+
this.next();
|
927
|
+
this.parseVar(node, false, kind);
|
928
|
+
this.semicolon();
|
929
929
|
return this.finishNode(node, "VariableDeclaration")
|
930
|
-
}
|
930
|
+
};
|
931
931
|
|
932
932
|
pp$1.parseWhileStatement = function(node) {
|
933
|
-
this.next()
|
934
|
-
node.test = this.parseParenExpression()
|
935
|
-
this.labels.push(loopLabel)
|
936
|
-
node.body = this.parseStatement(false)
|
937
|
-
this.labels.pop()
|
933
|
+
this.next();
|
934
|
+
node.test = this.parseParenExpression();
|
935
|
+
this.labels.push(loopLabel);
|
936
|
+
node.body = this.parseStatement(false);
|
937
|
+
this.labels.pop();
|
938
938
|
return this.finishNode(node, "WhileStatement")
|
939
|
-
}
|
939
|
+
};
|
940
940
|
|
941
941
|
pp$1.parseWithStatement = function(node) {
|
942
|
-
if (this.strict) this.raise(this.start, "'with' in strict mode")
|
943
|
-
this.next()
|
944
|
-
node.object = this.parseParenExpression()
|
945
|
-
node.body = this.parseStatement(false)
|
942
|
+
if (this.strict) this.raise(this.start, "'with' in strict mode");
|
943
|
+
this.next();
|
944
|
+
node.object = this.parseParenExpression();
|
945
|
+
node.body = this.parseStatement(false);
|
946
946
|
return this.finishNode(node, "WithStatement")
|
947
|
-
}
|
947
|
+
};
|
948
948
|
|
949
949
|
pp$1.parseEmptyStatement = function(node) {
|
950
|
-
this.next()
|
950
|
+
this.next();
|
951
951
|
return this.finishNode(node, "EmptyStatement")
|
952
|
-
}
|
952
|
+
};
|
953
953
|
|
954
954
|
pp$1.parseLabeledStatement = function(node, maybeName, expr) {
|
955
955
|
var this$1 = this;
|
956
956
|
|
957
957
|
for (var i = 0; i < this.labels.length; ++i)
|
958
|
-
if (this$1.labels[i].name === maybeName) this$1.raise(expr.start, "Label '" + maybeName + "' is already declared")
|
959
|
-
var kind = this.type.isLoop ? "loop" : this.type === tt._switch ? "switch" : null
|
958
|
+
if (this$1.labels[i].name === maybeName) this$1.raise(expr.start, "Label '" + maybeName + "' is already declared");
|
959
|
+
var kind = this.type.isLoop ? "loop" : this.type === tt._switch ? "switch" : null;
|
960
960
|
for (var i$1 = this.labels.length - 1; i$1 >= 0; i$1--) {
|
961
|
-
var label = this$1.labels[i$1]
|
961
|
+
var label = this$1.labels[i$1];
|
962
962
|
if (label.statementStart == node.start) {
|
963
|
-
label.statementStart = this$1.start
|
964
|
-
label.kind = kind
|
963
|
+
label.statementStart = this$1.start;
|
964
|
+
label.kind = kind;
|
965
965
|
} else break
|
966
966
|
}
|
967
|
-
this.labels.push({name: maybeName, kind: kind, statementStart: this.start})
|
968
|
-
node.body = this.parseStatement(true)
|
969
|
-
this.labels.pop()
|
970
|
-
node.label = expr
|
967
|
+
this.labels.push({name: maybeName, kind: kind, statementStart: this.start});
|
968
|
+
node.body = this.parseStatement(true);
|
969
|
+
this.labels.pop();
|
970
|
+
node.label = expr;
|
971
971
|
return this.finishNode(node, "LabeledStatement")
|
972
|
-
}
|
972
|
+
};
|
973
973
|
|
974
974
|
pp$1.parseExpressionStatement = function(node, expr) {
|
975
|
-
node.expression = expr
|
976
|
-
this.semicolon()
|
975
|
+
node.expression = expr;
|
976
|
+
this.semicolon();
|
977
977
|
return this.finishNode(node, "ExpressionStatement")
|
978
|
-
}
|
978
|
+
};
|
979
979
|
|
980
980
|
// Parse a semicolon-enclosed block of statements, handling `"use
|
981
981
|
// strict"` declarations when `allowStrict` is true (used for
|
@@ -984,103 +984,103 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
984
984
|
pp$1.parseBlock = function(allowStrict) {
|
985
985
|
var this$1 = this;
|
986
986
|
|
987
|
-
var node = this.startNode(), first = true, oldStrict
|
988
|
-
node.body = []
|
989
|
-
this.expect(tt.braceL)
|
987
|
+
var node = this.startNode(), first = true, oldStrict;
|
988
|
+
node.body = [];
|
989
|
+
this.expect(tt.braceL);
|
990
990
|
while (!this.eat(tt.braceR)) {
|
991
|
-
var stmt = this$1.parseStatement(true)
|
992
|
-
node.body.push(stmt)
|
991
|
+
var stmt = this$1.parseStatement(true);
|
992
|
+
node.body.push(stmt);
|
993
993
|
if (first && allowStrict && this$1.isUseStrict(stmt)) {
|
994
|
-
oldStrict = this$1.strict
|
995
|
-
this$1.setStrict(this$1.strict = true)
|
994
|
+
oldStrict = this$1.strict;
|
995
|
+
this$1.setStrict(this$1.strict = true);
|
996
996
|
}
|
997
|
-
first = false
|
997
|
+
first = false;
|
998
998
|
}
|
999
|
-
if (oldStrict === false) this.setStrict(false)
|
999
|
+
if (oldStrict === false) this.setStrict(false);
|
1000
1000
|
return this.finishNode(node, "BlockStatement")
|
1001
|
-
}
|
1001
|
+
};
|
1002
1002
|
|
1003
1003
|
// Parse a regular `for` loop. The disambiguation code in
|
1004
1004
|
// `parseStatement` will already have parsed the init statement or
|
1005
1005
|
// expression.
|
1006
1006
|
|
1007
1007
|
pp$1.parseFor = function(node, init) {
|
1008
|
-
node.init = init
|
1009
|
-
this.expect(tt.semi)
|
1010
|
-
node.test = this.type === tt.semi ? null : this.parseExpression()
|
1011
|
-
this.expect(tt.semi)
|
1012
|
-
node.update = this.type === tt.parenR ? null : this.parseExpression()
|
1013
|
-
this.expect(tt.parenR)
|
1014
|
-
node.body = this.parseStatement(false)
|
1015
|
-
this.labels.pop()
|
1008
|
+
node.init = init;
|
1009
|
+
this.expect(tt.semi);
|
1010
|
+
node.test = this.type === tt.semi ? null : this.parseExpression();
|
1011
|
+
this.expect(tt.semi);
|
1012
|
+
node.update = this.type === tt.parenR ? null : this.parseExpression();
|
1013
|
+
this.expect(tt.parenR);
|
1014
|
+
node.body = this.parseStatement(false);
|
1015
|
+
this.labels.pop();
|
1016
1016
|
return this.finishNode(node, "ForStatement")
|
1017
|
-
}
|
1017
|
+
};
|
1018
1018
|
|
1019
1019
|
// Parse a `for`/`in` and `for`/`of` loop, which are almost
|
1020
1020
|
// same from parser's perspective.
|
1021
1021
|
|
1022
1022
|
pp$1.parseForIn = function(node, init) {
|
1023
|
-
var type = this.type === tt._in ? "ForInStatement" : "ForOfStatement"
|
1024
|
-
this.next()
|
1025
|
-
node.left = init
|
1026
|
-
node.right = this.parseExpression()
|
1027
|
-
this.expect(tt.parenR)
|
1028
|
-
node.body = this.parseStatement(false)
|
1029
|
-
this.labels.pop()
|
1023
|
+
var type = this.type === tt._in ? "ForInStatement" : "ForOfStatement";
|
1024
|
+
this.next();
|
1025
|
+
node.left = init;
|
1026
|
+
node.right = this.parseExpression();
|
1027
|
+
this.expect(tt.parenR);
|
1028
|
+
node.body = this.parseStatement(false);
|
1029
|
+
this.labels.pop();
|
1030
1030
|
return this.finishNode(node, type)
|
1031
|
-
}
|
1031
|
+
};
|
1032
1032
|
|
1033
1033
|
// Parse a list of variable declarations.
|
1034
1034
|
|
1035
1035
|
pp$1.parseVar = function(node, isFor, kind) {
|
1036
1036
|
var this$1 = this;
|
1037
1037
|
|
1038
|
-
node.declarations = []
|
1039
|
-
node.kind = kind
|
1038
|
+
node.declarations = [];
|
1039
|
+
node.kind = kind;
|
1040
1040
|
for (;;) {
|
1041
|
-
var decl = this$1.startNode()
|
1042
|
-
this$1.parseVarId(decl)
|
1041
|
+
var decl = this$1.startNode();
|
1042
|
+
this$1.parseVarId(decl);
|
1043
1043
|
if (this$1.eat(tt.eq)) {
|
1044
|
-
decl.init = this$1.parseMaybeAssign(isFor)
|
1044
|
+
decl.init = this$1.parseMaybeAssign(isFor);
|
1045
1045
|
} else if (kind === "const" && !(this$1.type === tt._in || (this$1.options.ecmaVersion >= 6 && this$1.isContextual("of")))) {
|
1046
|
-
this$1.unexpected()
|
1046
|
+
this$1.unexpected();
|
1047
1047
|
} else if (decl.id.type != "Identifier" && !(isFor && (this$1.type === tt._in || this$1.isContextual("of")))) {
|
1048
|
-
this$1.raise(this$1.lastTokEnd, "Complex binding patterns require an initialization value")
|
1048
|
+
this$1.raise(this$1.lastTokEnd, "Complex binding patterns require an initialization value");
|
1049
1049
|
} else {
|
1050
|
-
decl.init = null
|
1050
|
+
decl.init = null;
|
1051
1051
|
}
|
1052
|
-
node.declarations.push(this$1.finishNode(decl, "VariableDeclarator"))
|
1052
|
+
node.declarations.push(this$1.finishNode(decl, "VariableDeclarator"));
|
1053
1053
|
if (!this$1.eat(tt.comma)) break
|
1054
1054
|
}
|
1055
1055
|
return node
|
1056
|
-
}
|
1056
|
+
};
|
1057
1057
|
|
1058
1058
|
pp$1.parseVarId = function(decl) {
|
1059
|
-
decl.id = this.parseBindingAtom()
|
1060
|
-
this.checkLVal(decl.id, true)
|
1061
|
-
}
|
1059
|
+
decl.id = this.parseBindingAtom();
|
1060
|
+
this.checkLVal(decl.id, true);
|
1061
|
+
};
|
1062
1062
|
|
1063
1063
|
// Parse a function declaration or literal (depending on the
|
1064
1064
|
// `isStatement` parameter).
|
1065
1065
|
|
1066
1066
|
pp$1.parseFunction = function(node, isStatement, allowExpressionBody) {
|
1067
|
-
this.initFunction(node)
|
1067
|
+
this.initFunction(node);
|
1068
1068
|
if (this.options.ecmaVersion >= 6)
|
1069
|
-
node.generator = this.eat(tt.star)
|
1070
|
-
var oldInGen = this.inGenerator
|
1071
|
-
this.inGenerator = node.generator
|
1069
|
+
node.generator = this.eat(tt.star);
|
1070
|
+
var oldInGen = this.inGenerator;
|
1071
|
+
this.inGenerator = node.generator;
|
1072
1072
|
if (isStatement || this.type === tt.name)
|
1073
|
-
node.id = this.parseIdent()
|
1074
|
-
this.parseFunctionParams(node)
|
1075
|
-
this.parseFunctionBody(node, allowExpressionBody)
|
1076
|
-
this.inGenerator = oldInGen
|
1073
|
+
node.id = this.parseIdent();
|
1074
|
+
this.parseFunctionParams(node);
|
1075
|
+
this.parseFunctionBody(node, allowExpressionBody);
|
1076
|
+
this.inGenerator = oldInGen;
|
1077
1077
|
return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression")
|
1078
|
-
}
|
1078
|
+
};
|
1079
1079
|
|
1080
1080
|
pp$1.parseFunctionParams = function(node) {
|
1081
|
-
this.expect(tt.parenL)
|
1082
|
-
node.params = this.parseBindingList(tt.parenR, false, false, true)
|
1083
|
-
}
|
1081
|
+
this.expect(tt.parenL);
|
1082
|
+
node.params = this.parseBindingList(tt.parenR, false, false, true);
|
1083
|
+
};
|
1084
1084
|
|
1085
1085
|
// Parse a class declaration or literal (depending on the
|
1086
1086
|
// `isStatement` parameter).
|
@@ -1088,218 +1088,218 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
1088
1088
|
pp$1.parseClass = function(node, isStatement) {
|
1089
1089
|
var this$1 = this;
|
1090
1090
|
|
1091
|
-
this.next()
|
1092
|
-
this.parseClassId(node, isStatement)
|
1093
|
-
this.parseClassSuper(node)
|
1094
|
-
var classBody = this.startNode()
|
1095
|
-
var hadConstructor = false
|
1096
|
-
classBody.body = []
|
1097
|
-
this.expect(tt.braceL)
|
1091
|
+
this.next();
|
1092
|
+
this.parseClassId(node, isStatement);
|
1093
|
+
this.parseClassSuper(node);
|
1094
|
+
var classBody = this.startNode();
|
1095
|
+
var hadConstructor = false;
|
1096
|
+
classBody.body = [];
|
1097
|
+
this.expect(tt.braceL);
|
1098
1098
|
while (!this.eat(tt.braceR)) {
|
1099
1099
|
if (this$1.eat(tt.semi)) continue
|
1100
|
-
var method = this$1.startNode()
|
1101
|
-
var isGenerator = this$1.eat(tt.star)
|
1102
|
-
var isMaybeStatic = this$1.type === tt.name && this$1.value === "static"
|
1103
|
-
this$1.parsePropertyName(method)
|
1104
|
-
method.static = isMaybeStatic && this$1.type !== tt.parenL
|
1100
|
+
var method = this$1.startNode();
|
1101
|
+
var isGenerator = this$1.eat(tt.star);
|
1102
|
+
var isMaybeStatic = this$1.type === tt.name && this$1.value === "static";
|
1103
|
+
this$1.parsePropertyName(method);
|
1104
|
+
method.static = isMaybeStatic && this$1.type !== tt.parenL;
|
1105
1105
|
if (method.static) {
|
1106
|
-
if (isGenerator) this$1.unexpected()
|
1107
|
-
isGenerator = this$1.eat(tt.star)
|
1108
|
-
this$1.parsePropertyName(method)
|
1106
|
+
if (isGenerator) this$1.unexpected();
|
1107
|
+
isGenerator = this$1.eat(tt.star);
|
1108
|
+
this$1.parsePropertyName(method);
|
1109
1109
|
}
|
1110
|
-
method.kind = "method"
|
1111
|
-
var isGetSet = false
|
1110
|
+
method.kind = "method";
|
1111
|
+
var isGetSet = false;
|
1112
1112
|
if (!method.computed) {
|
1113
1113
|
var key = method.key;
|
1114
1114
|
if (!isGenerator && key.type === "Identifier" && this$1.type !== tt.parenL && (key.name === "get" || key.name === "set")) {
|
1115
|
-
isGetSet = true
|
1116
|
-
method.kind = key.name
|
1117
|
-
key = this$1.parsePropertyName(method)
|
1115
|
+
isGetSet = true;
|
1116
|
+
method.kind = key.name;
|
1117
|
+
key = this$1.parsePropertyName(method);
|
1118
1118
|
}
|
1119
1119
|
if (!method.static && (key.type === "Identifier" && key.name === "constructor" ||
|
1120
1120
|
key.type === "Literal" && key.value === "constructor")) {
|
1121
|
-
if (hadConstructor) this$1.raise(key.start, "Duplicate constructor in the same class")
|
1122
|
-
if (isGetSet) this$1.raise(key.start, "Constructor can't have get/set modifier")
|
1123
|
-
if (isGenerator) this$1.raise(key.start, "Constructor can't be a generator")
|
1124
|
-
method.kind = "constructor"
|
1125
|
-
hadConstructor = true
|
1121
|
+
if (hadConstructor) this$1.raise(key.start, "Duplicate constructor in the same class");
|
1122
|
+
if (isGetSet) this$1.raise(key.start, "Constructor can't have get/set modifier");
|
1123
|
+
if (isGenerator) this$1.raise(key.start, "Constructor can't be a generator");
|
1124
|
+
method.kind = "constructor";
|
1125
|
+
hadConstructor = true;
|
1126
1126
|
}
|
1127
1127
|
}
|
1128
|
-
this$1.parseClassMethod(classBody, method, isGenerator)
|
1128
|
+
this$1.parseClassMethod(classBody, method, isGenerator);
|
1129
1129
|
if (isGetSet) {
|
1130
|
-
var paramCount = method.kind === "get" ? 0 : 1
|
1130
|
+
var paramCount = method.kind === "get" ? 0 : 1;
|
1131
1131
|
if (method.value.params.length !== paramCount) {
|
1132
|
-
var start = method.value.start
|
1132
|
+
var start = method.value.start;
|
1133
1133
|
if (method.kind === "get")
|
1134
|
-
this$1.raiseRecoverable(start, "getter should have no params")
|
1134
|
+
this$1.raiseRecoverable(start, "getter should have no params");
|
1135
1135
|
else
|
1136
|
-
this$1.raiseRecoverable(start, "setter should have exactly one param")
|
1136
|
+
this$1.raiseRecoverable(start, "setter should have exactly one param");
|
1137
1137
|
}
|
1138
1138
|
if (method.kind === "set" && method.value.params[0].type === "RestElement")
|
1139
|
-
this$1.raise(method.value.params[0].start, "Setter cannot use rest params")
|
1139
|
+
this$1.raise(method.value.params[0].start, "Setter cannot use rest params");
|
1140
1140
|
}
|
1141
1141
|
}
|
1142
|
-
node.body = this.finishNode(classBody, "ClassBody")
|
1142
|
+
node.body = this.finishNode(classBody, "ClassBody");
|
1143
1143
|
return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression")
|
1144
|
-
}
|
1144
|
+
};
|
1145
1145
|
|
1146
1146
|
pp$1.parseClassMethod = function(classBody, method, isGenerator) {
|
1147
|
-
method.value = this.parseMethod(isGenerator)
|
1148
|
-
classBody.body.push(this.finishNode(method, "MethodDefinition"))
|
1149
|
-
}
|
1147
|
+
method.value = this.parseMethod(isGenerator);
|
1148
|
+
classBody.body.push(this.finishNode(method, "MethodDefinition"));
|
1149
|
+
};
|
1150
1150
|
|
1151
1151
|
pp$1.parseClassId = function(node, isStatement) {
|
1152
|
-
node.id = this.type === tt.name ? this.parseIdent() : isStatement ? this.unexpected() : null
|
1153
|
-
}
|
1152
|
+
node.id = this.type === tt.name ? this.parseIdent() : isStatement ? this.unexpected() : null;
|
1153
|
+
};
|
1154
1154
|
|
1155
1155
|
pp$1.parseClassSuper = function(node) {
|
1156
|
-
node.superClass = this.eat(tt._extends) ? this.parseExprSubscripts() : null
|
1157
|
-
}
|
1156
|
+
node.superClass = this.eat(tt._extends) ? this.parseExprSubscripts() : null;
|
1157
|
+
};
|
1158
1158
|
|
1159
1159
|
// Parses module export declaration.
|
1160
1160
|
|
1161
1161
|
pp$1.parseExport = function(node) {
|
1162
1162
|
var this$1 = this;
|
1163
1163
|
|
1164
|
-
this.next()
|
1164
|
+
this.next();
|
1165
1165
|
// export * from '...'
|
1166
1166
|
if (this.eat(tt.star)) {
|
1167
|
-
this.expectContextual("from")
|
1168
|
-
node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected()
|
1169
|
-
this.semicolon()
|
1167
|
+
this.expectContextual("from");
|
1168
|
+
node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();
|
1169
|
+
this.semicolon();
|
1170
1170
|
return this.finishNode(node, "ExportAllDeclaration")
|
1171
1171
|
}
|
1172
1172
|
if (this.eat(tt._default)) { // export default ...
|
1173
|
-
var parens = this.type == tt.parenL
|
1174
|
-
var expr = this.parseMaybeAssign()
|
1175
|
-
var needsSemi = true
|
1173
|
+
var parens = this.type == tt.parenL;
|
1174
|
+
var expr = this.parseMaybeAssign();
|
1175
|
+
var needsSemi = true;
|
1176
1176
|
if (!parens && (expr.type == "FunctionExpression" ||
|
1177
1177
|
expr.type == "ClassExpression")) {
|
1178
|
-
needsSemi = false
|
1178
|
+
needsSemi = false;
|
1179
1179
|
if (expr.id) {
|
1180
1180
|
expr.type = expr.type == "FunctionExpression"
|
1181
1181
|
? "FunctionDeclaration"
|
1182
|
-
: "ClassDeclaration"
|
1182
|
+
: "ClassDeclaration";
|
1183
1183
|
}
|
1184
1184
|
}
|
1185
|
-
node.declaration = expr
|
1186
|
-
if (needsSemi) this.semicolon()
|
1185
|
+
node.declaration = expr;
|
1186
|
+
if (needsSemi) this.semicolon();
|
1187
1187
|
return this.finishNode(node, "ExportDefaultDeclaration")
|
1188
1188
|
}
|
1189
1189
|
// export var|const|let|function|class ...
|
1190
1190
|
if (this.shouldParseExportStatement()) {
|
1191
|
-
node.declaration = this.parseStatement(true)
|
1192
|
-
node.specifiers = []
|
1193
|
-
node.source = null
|
1191
|
+
node.declaration = this.parseStatement(true);
|
1192
|
+
node.specifiers = [];
|
1193
|
+
node.source = null;
|
1194
1194
|
} else { // export { x, y as z } [from '...']
|
1195
|
-
node.declaration = null
|
1196
|
-
node.specifiers = this.parseExportSpecifiers()
|
1195
|
+
node.declaration = null;
|
1196
|
+
node.specifiers = this.parseExportSpecifiers();
|
1197
1197
|
if (this.eatContextual("from")) {
|
1198
|
-
node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected()
|
1198
|
+
node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();
|
1199
1199
|
} else {
|
1200
1200
|
// check for keywords used as local names
|
1201
1201
|
for (var i = 0; i < node.specifiers.length; i++) {
|
1202
1202
|
if (this$1.keywords.test(node.specifiers[i].local.name) || this$1.reservedWords.test(node.specifiers[i].local.name)) {
|
1203
|
-
this$1.unexpected(node.specifiers[i].local.start)
|
1203
|
+
this$1.unexpected(node.specifiers[i].local.start);
|
1204
1204
|
}
|
1205
1205
|
}
|
1206
1206
|
|
1207
|
-
node.source = null
|
1207
|
+
node.source = null;
|
1208
1208
|
}
|
1209
|
-
this.semicolon()
|
1209
|
+
this.semicolon();
|
1210
1210
|
}
|
1211
1211
|
return this.finishNode(node, "ExportNamedDeclaration")
|
1212
|
-
}
|
1212
|
+
};
|
1213
1213
|
|
1214
1214
|
pp$1.shouldParseExportStatement = function() {
|
1215
1215
|
return this.type.keyword || this.isLet()
|
1216
|
-
}
|
1216
|
+
};
|
1217
1217
|
|
1218
1218
|
// Parses a comma-separated list of module exports.
|
1219
1219
|
|
1220
1220
|
pp$1.parseExportSpecifiers = function() {
|
1221
1221
|
var this$1 = this;
|
1222
1222
|
|
1223
|
-
var nodes = [], first = true
|
1223
|
+
var nodes = [], first = true;
|
1224
1224
|
// export { x, y as z } [from '...']
|
1225
|
-
this.expect(tt.braceL)
|
1225
|
+
this.expect(tt.braceL);
|
1226
1226
|
while (!this.eat(tt.braceR)) {
|
1227
1227
|
if (!first) {
|
1228
|
-
this$1.expect(tt.comma)
|
1228
|
+
this$1.expect(tt.comma);
|
1229
1229
|
if (this$1.afterTrailingComma(tt.braceR)) break
|
1230
|
-
} else first = false
|
1230
|
+
} else first = false;
|
1231
1231
|
|
1232
|
-
var node = this$1.startNode()
|
1233
|
-
node.local = this$1.parseIdent(this$1.type === tt._default)
|
1234
|
-
node.exported = this$1.eatContextual("as") ? this$1.parseIdent(true) : node.local
|
1235
|
-
nodes.push(this$1.finishNode(node, "ExportSpecifier"))
|
1232
|
+
var node = this$1.startNode();
|
1233
|
+
node.local = this$1.parseIdent(this$1.type === tt._default);
|
1234
|
+
node.exported = this$1.eatContextual("as") ? this$1.parseIdent(true) : node.local;
|
1235
|
+
nodes.push(this$1.finishNode(node, "ExportSpecifier"));
|
1236
1236
|
}
|
1237
1237
|
return nodes
|
1238
|
-
}
|
1238
|
+
};
|
1239
1239
|
|
1240
1240
|
// Parses import declaration.
|
1241
1241
|
|
1242
1242
|
pp$1.parseImport = function(node) {
|
1243
|
-
this.next()
|
1243
|
+
this.next();
|
1244
1244
|
// import '...'
|
1245
1245
|
if (this.type === tt.string) {
|
1246
|
-
node.specifiers = empty
|
1247
|
-
node.source = this.parseExprAtom()
|
1246
|
+
node.specifiers = empty;
|
1247
|
+
node.source = this.parseExprAtom();
|
1248
1248
|
} else {
|
1249
|
-
node.specifiers = this.parseImportSpecifiers()
|
1250
|
-
this.expectContextual("from")
|
1251
|
-
node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected()
|
1249
|
+
node.specifiers = this.parseImportSpecifiers();
|
1250
|
+
this.expectContextual("from");
|
1251
|
+
node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();
|
1252
1252
|
}
|
1253
|
-
this.semicolon()
|
1253
|
+
this.semicolon();
|
1254
1254
|
return this.finishNode(node, "ImportDeclaration")
|
1255
|
-
}
|
1255
|
+
};
|
1256
1256
|
|
1257
1257
|
// Parses a comma-separated list of module imports.
|
1258
1258
|
|
1259
1259
|
pp$1.parseImportSpecifiers = function() {
|
1260
1260
|
var this$1 = this;
|
1261
1261
|
|
1262
|
-
var nodes = [], first = true
|
1262
|
+
var nodes = [], first = true;
|
1263
1263
|
if (this.type === tt.name) {
|
1264
1264
|
// import defaultObj, { x, y as z } from '...'
|
1265
|
-
var node = this.startNode()
|
1266
|
-
node.local = this.parseIdent()
|
1267
|
-
this.checkLVal(node.local, true)
|
1268
|
-
nodes.push(this.finishNode(node, "ImportDefaultSpecifier"))
|
1265
|
+
var node = this.startNode();
|
1266
|
+
node.local = this.parseIdent();
|
1267
|
+
this.checkLVal(node.local, true);
|
1268
|
+
nodes.push(this.finishNode(node, "ImportDefaultSpecifier"));
|
1269
1269
|
if (!this.eat(tt.comma)) return nodes
|
1270
1270
|
}
|
1271
1271
|
if (this.type === tt.star) {
|
1272
|
-
var node$1 = this.startNode()
|
1273
|
-
this.next()
|
1274
|
-
this.expectContextual("as")
|
1275
|
-
node$1.local = this.parseIdent()
|
1276
|
-
this.checkLVal(node$1.local, true)
|
1277
|
-
nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier"))
|
1272
|
+
var node$1 = this.startNode();
|
1273
|
+
this.next();
|
1274
|
+
this.expectContextual("as");
|
1275
|
+
node$1.local = this.parseIdent();
|
1276
|
+
this.checkLVal(node$1.local, true);
|
1277
|
+
nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier"));
|
1278
1278
|
return nodes
|
1279
1279
|
}
|
1280
|
-
this.expect(tt.braceL)
|
1280
|
+
this.expect(tt.braceL);
|
1281
1281
|
while (!this.eat(tt.braceR)) {
|
1282
1282
|
if (!first) {
|
1283
|
-
this$1.expect(tt.comma)
|
1283
|
+
this$1.expect(tt.comma);
|
1284
1284
|
if (this$1.afterTrailingComma(tt.braceR)) break
|
1285
|
-
} else first = false
|
1285
|
+
} else first = false;
|
1286
1286
|
|
1287
|
-
var node$2 = this$1.startNode()
|
1288
|
-
node$2.imported = this$1.parseIdent(true)
|
1287
|
+
var node$2 = this$1.startNode();
|
1288
|
+
node$2.imported = this$1.parseIdent(true);
|
1289
1289
|
if (this$1.eatContextual("as")) {
|
1290
|
-
node$2.local = this$1.parseIdent()
|
1290
|
+
node$2.local = this$1.parseIdent();
|
1291
1291
|
} else {
|
1292
|
-
node$2.local = node$2.imported
|
1293
|
-
if (this$1.isKeyword(node$2.local.name)) this$1.unexpected(node$2.local.start)
|
1294
|
-
if (this$1.reservedWordsStrict.test(node$2.local.name)) this$1.raise(node$2.local.start, "The keyword '" + node$2.local.name + "' is reserved")
|
1292
|
+
node$2.local = node$2.imported;
|
1293
|
+
if (this$1.isKeyword(node$2.local.name)) this$1.unexpected(node$2.local.start);
|
1294
|
+
if (this$1.reservedWordsStrict.test(node$2.local.name)) this$1.raise(node$2.local.start, "The keyword '" + node$2.local.name + "' is reserved");
|
1295
1295
|
}
|
1296
|
-
this$1.checkLVal(node$2.local, true)
|
1297
|
-
nodes.push(this$1.finishNode(node$2, "ImportSpecifier"))
|
1296
|
+
this$1.checkLVal(node$2.local, true);
|
1297
|
+
nodes.push(this$1.finishNode(node$2, "ImportSpecifier"));
|
1298
1298
|
}
|
1299
1299
|
return nodes
|
1300
|
-
}
|
1300
|
+
};
|
1301
1301
|
|
1302
|
-
var pp$2 = Parser.prototype
|
1302
|
+
var pp$2 = Parser.prototype;
|
1303
1303
|
|
1304
1304
|
// Convert existing expression atom to assignable pattern
|
1305
1305
|
// if possible.
|
@@ -1315,96 +1315,96 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
1315
1315
|
break
|
1316
1316
|
|
1317
1317
|
case "ObjectExpression":
|
1318
|
-
node.type = "ObjectPattern"
|
1318
|
+
node.type = "ObjectPattern";
|
1319
1319
|
for (var i = 0; i < node.properties.length; i++) {
|
1320
|
-
var prop = node.properties[i]
|
1321
|
-
if (prop.kind !== "init") this$1.raise(prop.key.start, "Object pattern can't contain getter or setter")
|
1322
|
-
this$1.toAssignable(prop.value, isBinding)
|
1320
|
+
var prop = node.properties[i];
|
1321
|
+
if (prop.kind !== "init") this$1.raise(prop.key.start, "Object pattern can't contain getter or setter");
|
1322
|
+
this$1.toAssignable(prop.value, isBinding);
|
1323
1323
|
}
|
1324
1324
|
break
|
1325
1325
|
|
1326
1326
|
case "ArrayExpression":
|
1327
|
-
node.type = "ArrayPattern"
|
1328
|
-
this.toAssignableList(node.elements, isBinding)
|
1327
|
+
node.type = "ArrayPattern";
|
1328
|
+
this.toAssignableList(node.elements, isBinding);
|
1329
1329
|
break
|
1330
1330
|
|
1331
1331
|
case "AssignmentExpression":
|
1332
1332
|
if (node.operator === "=") {
|
1333
|
-
node.type = "AssignmentPattern"
|
1334
|
-
delete node.operator
|
1333
|
+
node.type = "AssignmentPattern";
|
1334
|
+
delete node.operator;
|
1335
1335
|
// falls through to AssignmentPattern
|
1336
1336
|
} else {
|
1337
|
-
this.raise(node.left.end, "Only '=' operator can be used for specifying default value.")
|
1337
|
+
this.raise(node.left.end, "Only '=' operator can be used for specifying default value.");
|
1338
1338
|
break
|
1339
1339
|
}
|
1340
1340
|
|
1341
1341
|
case "AssignmentPattern":
|
1342
1342
|
if (node.right.type === "YieldExpression")
|
1343
|
-
this.raise(node.right.start, "Yield expression cannot be a default value")
|
1343
|
+
this.raise(node.right.start, "Yield expression cannot be a default value");
|
1344
1344
|
break
|
1345
1345
|
|
1346
1346
|
case "ParenthesizedExpression":
|
1347
|
-
node.expression = this.toAssignable(node.expression, isBinding)
|
1347
|
+
node.expression = this.toAssignable(node.expression, isBinding);
|
1348
1348
|
break
|
1349
1349
|
|
1350
1350
|
case "MemberExpression":
|
1351
1351
|
if (!isBinding) break
|
1352
1352
|
|
1353
1353
|
default:
|
1354
|
-
this.raise(node.start, "Assigning to rvalue")
|
1354
|
+
this.raise(node.start, "Assigning to rvalue");
|
1355
1355
|
}
|
1356
1356
|
}
|
1357
1357
|
return node
|
1358
|
-
}
|
1358
|
+
};
|
1359
1359
|
|
1360
1360
|
// Convert list of expression atoms to binding list.
|
1361
1361
|
|
1362
1362
|
pp$2.toAssignableList = function(exprList, isBinding) {
|
1363
1363
|
var this$1 = this;
|
1364
1364
|
|
1365
|
-
var end = exprList.length
|
1365
|
+
var end = exprList.length;
|
1366
1366
|
if (end) {
|
1367
|
-
var last = exprList[end - 1]
|
1367
|
+
var last = exprList[end - 1];
|
1368
1368
|
if (last && last.type == "RestElement") {
|
1369
|
-
--end
|
1369
|
+
--end;
|
1370
1370
|
} else if (last && last.type == "SpreadElement") {
|
1371
|
-
last.type = "RestElement"
|
1372
|
-
var arg = last.argument
|
1373
|
-
this.toAssignable(arg, isBinding)
|
1371
|
+
last.type = "RestElement";
|
1372
|
+
var arg = last.argument;
|
1373
|
+
this.toAssignable(arg, isBinding);
|
1374
1374
|
if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern")
|
1375
|
-
this.unexpected(arg.start)
|
1376
|
-
--end
|
1375
|
+
this.unexpected(arg.start);
|
1376
|
+
--end;
|
1377
1377
|
}
|
1378
1378
|
|
1379
1379
|
if (isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier")
|
1380
|
-
this.unexpected(last.argument.start)
|
1380
|
+
this.unexpected(last.argument.start);
|
1381
1381
|
}
|
1382
1382
|
for (var i = 0; i < end; i++) {
|
1383
|
-
var elt = exprList[i]
|
1384
|
-
if (elt) this$1.toAssignable(elt, isBinding)
|
1383
|
+
var elt = exprList[i];
|
1384
|
+
if (elt) this$1.toAssignable(elt, isBinding);
|
1385
1385
|
}
|
1386
1386
|
return exprList
|
1387
|
-
}
|
1387
|
+
};
|
1388
1388
|
|
1389
1389
|
// Parses spread element.
|
1390
1390
|
|
1391
1391
|
pp$2.parseSpread = function(refDestructuringErrors) {
|
1392
|
-
var node = this.startNode()
|
1393
|
-
this.next()
|
1394
|
-
node.argument = this.parseMaybeAssign(false, refDestructuringErrors)
|
1392
|
+
var node = this.startNode();
|
1393
|
+
this.next();
|
1394
|
+
node.argument = this.parseMaybeAssign(false, refDestructuringErrors);
|
1395
1395
|
return this.finishNode(node, "SpreadElement")
|
1396
|
-
}
|
1396
|
+
};
|
1397
1397
|
|
1398
1398
|
pp$2.parseRest = function(allowNonIdent) {
|
1399
|
-
var node = this.startNode()
|
1400
|
-
this.next()
|
1399
|
+
var node = this.startNode();
|
1400
|
+
this.next();
|
1401
1401
|
|
1402
1402
|
// RestElement inside of a function parameter must be an identifier
|
1403
|
-
if (allowNonIdent) node.argument = this.type === tt.name ? this.parseIdent() : this.unexpected()
|
1404
|
-
else node.argument = this.type === tt.name || this.type === tt.bracketL ? this.parseBindingAtom() : this.unexpected()
|
1403
|
+
if (allowNonIdent) node.argument = this.type === tt.name ? this.parseIdent() : this.unexpected();
|
1404
|
+
else node.argument = this.type === tt.name || this.type === tt.bracketL ? this.parseBindingAtom() : this.unexpected();
|
1405
1405
|
|
1406
1406
|
return this.finishNode(node, "RestElement")
|
1407
|
-
}
|
1407
|
+
};
|
1408
1408
|
|
1409
1409
|
// Parses lvalue (assignable) atom.
|
1410
1410
|
|
@@ -1415,60 +1415,60 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
1415
1415
|
return this.parseIdent()
|
1416
1416
|
|
1417
1417
|
case tt.bracketL:
|
1418
|
-
var node = this.startNode()
|
1419
|
-
this.next()
|
1420
|
-
node.elements = this.parseBindingList(tt.bracketR, true, true)
|
1418
|
+
var node = this.startNode();
|
1419
|
+
this.next();
|
1420
|
+
node.elements = this.parseBindingList(tt.bracketR, true, true);
|
1421
1421
|
return this.finishNode(node, "ArrayPattern")
|
1422
1422
|
|
1423
1423
|
case tt.braceL:
|
1424
1424
|
return this.parseObj(true)
|
1425
1425
|
|
1426
1426
|
default:
|
1427
|
-
this.unexpected()
|
1427
|
+
this.unexpected();
|
1428
1428
|
}
|
1429
|
-
}
|
1429
|
+
};
|
1430
1430
|
|
1431
1431
|
pp$2.parseBindingList = function(close, allowEmpty, allowTrailingComma, allowNonIdent) {
|
1432
1432
|
var this$1 = this;
|
1433
1433
|
|
1434
|
-
var elts = [], first = true
|
1434
|
+
var elts = [], first = true;
|
1435
1435
|
while (!this.eat(close)) {
|
1436
|
-
if (first) first = false
|
1437
|
-
else this$1.expect(tt.comma)
|
1436
|
+
if (first) first = false;
|
1437
|
+
else this$1.expect(tt.comma);
|
1438
1438
|
if (allowEmpty && this$1.type === tt.comma) {
|
1439
|
-
elts.push(null)
|
1439
|
+
elts.push(null);
|
1440
1440
|
} else if (allowTrailingComma && this$1.afterTrailingComma(close)) {
|
1441
1441
|
break
|
1442
1442
|
} else if (this$1.type === tt.ellipsis) {
|
1443
|
-
var rest = this$1.parseRest(allowNonIdent)
|
1444
|
-
this$1.parseBindingListItem(rest)
|
1445
|
-
elts.push(rest)
|
1446
|
-
if (this$1.type === tt.comma) this$1.raise(this$1.start, "Comma is not permitted after the rest element")
|
1447
|
-
this$1.expect(close)
|
1443
|
+
var rest = this$1.parseRest(allowNonIdent);
|
1444
|
+
this$1.parseBindingListItem(rest);
|
1445
|
+
elts.push(rest);
|
1446
|
+
if (this$1.type === tt.comma) this$1.raise(this$1.start, "Comma is not permitted after the rest element");
|
1447
|
+
this$1.expect(close);
|
1448
1448
|
break
|
1449
1449
|
} else {
|
1450
|
-
var elem = this$1.parseMaybeDefault(this$1.start, this$1.startLoc)
|
1451
|
-
this$1.parseBindingListItem(elem)
|
1452
|
-
elts.push(elem)
|
1450
|
+
var elem = this$1.parseMaybeDefault(this$1.start, this$1.startLoc);
|
1451
|
+
this$1.parseBindingListItem(elem);
|
1452
|
+
elts.push(elem);
|
1453
1453
|
}
|
1454
1454
|
}
|
1455
1455
|
return elts
|
1456
|
-
}
|
1456
|
+
};
|
1457
1457
|
|
1458
1458
|
pp$2.parseBindingListItem = function(param) {
|
1459
1459
|
return param
|
1460
|
-
}
|
1460
|
+
};
|
1461
1461
|
|
1462
1462
|
// Parses assignment pattern around given atom if possible.
|
1463
1463
|
|
1464
1464
|
pp$2.parseMaybeDefault = function(startPos, startLoc, left) {
|
1465
|
-
left = left || this.parseBindingAtom()
|
1465
|
+
left = left || this.parseBindingAtom();
|
1466
1466
|
if (this.options.ecmaVersion < 6 || !this.eat(tt.eq)) return left
|
1467
|
-
var node = this.startNodeAt(startPos, startLoc)
|
1468
|
-
node.left = left
|
1469
|
-
node.right = this.parseMaybeAssign()
|
1467
|
+
var node = this.startNodeAt(startPos, startLoc);
|
1468
|
+
node.left = left;
|
1469
|
+
node.right = this.parseMaybeAssign();
|
1470
1470
|
return this.finishNode(node, "AssignmentPattern")
|
1471
|
-
}
|
1471
|
+
};
|
1472
1472
|
|
1473
1473
|
// Verify that a node is an lval — something that can be assigned
|
1474
1474
|
// to.
|
@@ -1479,48 +1479,48 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
1479
1479
|
switch (expr.type) {
|
1480
1480
|
case "Identifier":
|
1481
1481
|
if (this.strict && this.reservedWordsStrictBind.test(expr.name))
|
1482
|
-
this.raiseRecoverable(expr.start, (isBinding ? "Binding " : "Assigning to ") + expr.name + " in strict mode")
|
1482
|
+
this.raiseRecoverable(expr.start, (isBinding ? "Binding " : "Assigning to ") + expr.name + " in strict mode");
|
1483
1483
|
if (checkClashes) {
|
1484
1484
|
if (has(checkClashes, expr.name))
|
1485
|
-
this.raiseRecoverable(expr.start, "Argument name clash")
|
1486
|
-
checkClashes[expr.name] = true
|
1485
|
+
this.raiseRecoverable(expr.start, "Argument name clash");
|
1486
|
+
checkClashes[expr.name] = true;
|
1487
1487
|
}
|
1488
1488
|
break
|
1489
1489
|
|
1490
1490
|
case "MemberExpression":
|
1491
|
-
if (isBinding) this.raiseRecoverable(expr.start, (isBinding ? "Binding" : "Assigning to") + " member expression")
|
1491
|
+
if (isBinding) this.raiseRecoverable(expr.start, (isBinding ? "Binding" : "Assigning to") + " member expression");
|
1492
1492
|
break
|
1493
1493
|
|
1494
1494
|
case "ObjectPattern":
|
1495
1495
|
for (var i = 0; i < expr.properties.length; i++)
|
1496
|
-
this$1.checkLVal(expr.properties[i].value, isBinding, checkClashes)
|
1496
|
+
this$1.checkLVal(expr.properties[i].value, isBinding, checkClashes);
|
1497
1497
|
break
|
1498
1498
|
|
1499
1499
|
case "ArrayPattern":
|
1500
1500
|
for (var i$1 = 0; i$1 < expr.elements.length; i$1++) {
|
1501
|
-
var elem = expr.elements[i$1]
|
1502
|
-
if (elem) this$1.checkLVal(elem, isBinding, checkClashes)
|
1501
|
+
var elem = expr.elements[i$1];
|
1502
|
+
if (elem) this$1.checkLVal(elem, isBinding, checkClashes);
|
1503
1503
|
}
|
1504
1504
|
break
|
1505
1505
|
|
1506
1506
|
case "AssignmentPattern":
|
1507
|
-
this.checkLVal(expr.left, isBinding, checkClashes)
|
1507
|
+
this.checkLVal(expr.left, isBinding, checkClashes);
|
1508
1508
|
break
|
1509
1509
|
|
1510
1510
|
case "RestElement":
|
1511
|
-
this.checkLVal(expr.argument, isBinding, checkClashes)
|
1511
|
+
this.checkLVal(expr.argument, isBinding, checkClashes);
|
1512
1512
|
break
|
1513
1513
|
|
1514
1514
|
case "ParenthesizedExpression":
|
1515
|
-
this.checkLVal(expr.expression, isBinding, checkClashes)
|
1515
|
+
this.checkLVal(expr.expression, isBinding, checkClashes);
|
1516
1516
|
break
|
1517
1517
|
|
1518
1518
|
default:
|
1519
|
-
this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " rvalue")
|
1519
|
+
this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " rvalue");
|
1520
1520
|
}
|
1521
|
-
}
|
1521
|
+
};
|
1522
1522
|
|
1523
|
-
var pp$3 = Parser.prototype
|
1523
|
+
var pp$3 = Parser.prototype;
|
1524
1524
|
|
1525
1525
|
// Check if property name clashes with already added.
|
1526
1526
|
// Object/class getters and setters are not allowed to clash —
|
@@ -1531,7 +1531,7 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
1531
1531
|
if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand))
|
1532
1532
|
return
|
1533
1533
|
var key = prop.key;
|
1534
|
-
var name
|
1534
|
+
var name;
|
1535
1535
|
switch (key.type) {
|
1536
1536
|
case "Identifier": name = key.name; break
|
1537
1537
|
case "Literal": name = String(key.value); break
|
@@ -1540,26 +1540,26 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
1540
1540
|
var kind = prop.kind;
|
1541
1541
|
if (this.options.ecmaVersion >= 6) {
|
1542
1542
|
if (name === "__proto__" && kind === "init") {
|
1543
|
-
if (propHash.proto) this.raiseRecoverable(key.start, "Redefinition of __proto__ property")
|
1544
|
-
propHash.proto = true
|
1543
|
+
if (propHash.proto) this.raiseRecoverable(key.start, "Redefinition of __proto__ property");
|
1544
|
+
propHash.proto = true;
|
1545
1545
|
}
|
1546
1546
|
return
|
1547
1547
|
}
|
1548
|
-
name = "$" + name
|
1549
|
-
var other = propHash[name]
|
1548
|
+
name = "$" + name;
|
1549
|
+
var other = propHash[name];
|
1550
1550
|
if (other) {
|
1551
|
-
var isGetSet = kind !== "init"
|
1551
|
+
var isGetSet = kind !== "init";
|
1552
1552
|
if ((this.strict || isGetSet) && other[kind] || !(isGetSet ^ other.init))
|
1553
|
-
this.raiseRecoverable(key.start, "Redefinition of property")
|
1553
|
+
this.raiseRecoverable(key.start, "Redefinition of property");
|
1554
1554
|
} else {
|
1555
1555
|
other = propHash[name] = {
|
1556
1556
|
init: false,
|
1557
1557
|
get: false,
|
1558
1558
|
set: false
|
1559
|
-
}
|
1559
|
+
};
|
1560
1560
|
}
|
1561
|
-
other[kind] = true
|
1562
|
-
}
|
1561
|
+
other[kind] = true;
|
1562
|
+
};
|
1563
1563
|
|
1564
1564
|
// ### Expression parsing
|
1565
1565
|
|
@@ -1579,16 +1579,16 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
1579
1579
|
pp$3.parseExpression = function(noIn, refDestructuringErrors) {
|
1580
1580
|
var this$1 = this;
|
1581
1581
|
|
1582
|
-
var startPos = this.start, startLoc = this.startLoc
|
1583
|
-
var expr = this.parseMaybeAssign(noIn, refDestructuringErrors)
|
1582
|
+
var startPos = this.start, startLoc = this.startLoc;
|
1583
|
+
var expr = this.parseMaybeAssign(noIn, refDestructuringErrors);
|
1584
1584
|
if (this.type === tt.comma) {
|
1585
|
-
var node = this.startNodeAt(startPos, startLoc)
|
1586
|
-
node.expressions = [expr]
|
1587
|
-
while (this.eat(tt.comma)) node.expressions.push(this$1.parseMaybeAssign(noIn, refDestructuringErrors))
|
1585
|
+
var node = this.startNodeAt(startPos, startLoc);
|
1586
|
+
node.expressions = [expr];
|
1587
|
+
while (this.eat(tt.comma)) node.expressions.push(this$1.parseMaybeAssign(noIn, refDestructuringErrors));
|
1588
1588
|
return this.finishNode(node, "SequenceExpression")
|
1589
1589
|
}
|
1590
1590
|
return expr
|
1591
|
-
}
|
1591
|
+
};
|
1592
1592
|
|
1593
1593
|
// Parse an assignment expression. This includes applications of
|
1594
1594
|
// operators like `+=`.
|
@@ -1596,58 +1596,58 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
1596
1596
|
pp$3.parseMaybeAssign = function(noIn, refDestructuringErrors, afterLeftParse) {
|
1597
1597
|
if (this.inGenerator && this.isContextual("yield")) return this.parseYield()
|
1598
1598
|
|
1599
|
-
var ownDestructuringErrors = false
|
1599
|
+
var ownDestructuringErrors = false;
|
1600
1600
|
if (!refDestructuringErrors) {
|
1601
|
-
refDestructuringErrors = new DestructuringErrors
|
1602
|
-
ownDestructuringErrors = true
|
1601
|
+
refDestructuringErrors = new DestructuringErrors;
|
1602
|
+
ownDestructuringErrors = true;
|
1603
1603
|
}
|
1604
|
-
var startPos = this.start, startLoc = this.startLoc
|
1604
|
+
var startPos = this.start, startLoc = this.startLoc;
|
1605
1605
|
if (this.type == tt.parenL || this.type == tt.name)
|
1606
|
-
this.potentialArrowAt = this.start
|
1607
|
-
var left = this.parseMaybeConditional(noIn, refDestructuringErrors)
|
1608
|
-
if (afterLeftParse) left = afterLeftParse.call(this, left, startPos, startLoc)
|
1606
|
+
this.potentialArrowAt = this.start;
|
1607
|
+
var left = this.parseMaybeConditional(noIn, refDestructuringErrors);
|
1608
|
+
if (afterLeftParse) left = afterLeftParse.call(this, left, startPos, startLoc);
|
1609
1609
|
if (this.type.isAssign) {
|
1610
|
-
this.checkPatternErrors(refDestructuringErrors, true)
|
1611
|
-
if (!ownDestructuringErrors) DestructuringErrors.call(refDestructuringErrors)
|
1612
|
-
var node = this.startNodeAt(startPos, startLoc)
|
1613
|
-
node.operator = this.value
|
1614
|
-
node.left = this.type === tt.eq ? this.toAssignable(left) : left
|
1615
|
-
refDestructuringErrors.shorthandAssign = 0 // reset because shorthand default was used correctly
|
1616
|
-
this.checkLVal(left)
|
1617
|
-
this.next()
|
1618
|
-
node.right = this.parseMaybeAssign(noIn)
|
1610
|
+
this.checkPatternErrors(refDestructuringErrors, true);
|
1611
|
+
if (!ownDestructuringErrors) DestructuringErrors.call(refDestructuringErrors);
|
1612
|
+
var node = this.startNodeAt(startPos, startLoc);
|
1613
|
+
node.operator = this.value;
|
1614
|
+
node.left = this.type === tt.eq ? this.toAssignable(left) : left;
|
1615
|
+
refDestructuringErrors.shorthandAssign = 0; // reset because shorthand default was used correctly
|
1616
|
+
this.checkLVal(left);
|
1617
|
+
this.next();
|
1618
|
+
node.right = this.parseMaybeAssign(noIn);
|
1619
1619
|
return this.finishNode(node, "AssignmentExpression")
|
1620
1620
|
} else {
|
1621
|
-
if (ownDestructuringErrors) this.checkExpressionErrors(refDestructuringErrors, true)
|
1621
|
+
if (ownDestructuringErrors) this.checkExpressionErrors(refDestructuringErrors, true);
|
1622
1622
|
}
|
1623
1623
|
return left
|
1624
|
-
}
|
1624
|
+
};
|
1625
1625
|
|
1626
1626
|
// Parse a ternary conditional (`?:`) operator.
|
1627
1627
|
|
1628
1628
|
pp$3.parseMaybeConditional = function(noIn, refDestructuringErrors) {
|
1629
|
-
var startPos = this.start, startLoc = this.startLoc
|
1630
|
-
var expr = this.parseExprOps(noIn, refDestructuringErrors)
|
1629
|
+
var startPos = this.start, startLoc = this.startLoc;
|
1630
|
+
var expr = this.parseExprOps(noIn, refDestructuringErrors);
|
1631
1631
|
if (this.checkExpressionErrors(refDestructuringErrors)) return expr
|
1632
1632
|
if (this.eat(tt.question)) {
|
1633
|
-
var node = this.startNodeAt(startPos, startLoc)
|
1634
|
-
node.test = expr
|
1635
|
-
node.consequent = this.parseMaybeAssign()
|
1636
|
-
this.expect(tt.colon)
|
1637
|
-
node.alternate = this.parseMaybeAssign(noIn)
|
1633
|
+
var node = this.startNodeAt(startPos, startLoc);
|
1634
|
+
node.test = expr;
|
1635
|
+
node.consequent = this.parseMaybeAssign();
|
1636
|
+
this.expect(tt.colon);
|
1637
|
+
node.alternate = this.parseMaybeAssign(noIn);
|
1638
1638
|
return this.finishNode(node, "ConditionalExpression")
|
1639
1639
|
}
|
1640
1640
|
return expr
|
1641
|
-
}
|
1641
|
+
};
|
1642
1642
|
|
1643
1643
|
// Start the precedence parser.
|
1644
1644
|
|
1645
1645
|
pp$3.parseExprOps = function(noIn, refDestructuringErrors) {
|
1646
|
-
var startPos = this.start, startLoc = this.startLoc
|
1647
|
-
var expr = this.parseMaybeUnary(refDestructuringErrors, false)
|
1646
|
+
var startPos = this.start, startLoc = this.startLoc;
|
1647
|
+
var expr = this.parseMaybeUnary(refDestructuringErrors, false);
|
1648
1648
|
if (this.checkExpressionErrors(refDestructuringErrors)) return expr
|
1649
1649
|
return this.parseExprOp(expr, startPos, startLoc, -1, noIn)
|
1650
|
-
}
|
1650
|
+
};
|
1651
1651
|
|
1652
1652
|
// Parse binary operators with the operator precedence parsing
|
1653
1653
|
// algorithm. `left` is the left-hand side of the operator.
|
@@ -1656,59 +1656,59 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
1656
1656
|
// operator that has a lower precedence than the set it is parsing.
|
1657
1657
|
|
1658
1658
|
pp$3.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, noIn) {
|
1659
|
-
var prec = this.type.binop
|
1659
|
+
var prec = this.type.binop;
|
1660
1660
|
if (prec != null && (!noIn || this.type !== tt._in)) {
|
1661
1661
|
if (prec > minPrec) {
|
1662
|
-
var logical = this.type === tt.logicalOR || this.type === tt.logicalAND
|
1663
|
-
var op = this.value
|
1664
|
-
this.next()
|
1665
|
-
var startPos = this.start, startLoc = this.startLoc
|
1666
|
-
var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn)
|
1667
|
-
var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical)
|
1662
|
+
var logical = this.type === tt.logicalOR || this.type === tt.logicalAND;
|
1663
|
+
var op = this.value;
|
1664
|
+
this.next();
|
1665
|
+
var startPos = this.start, startLoc = this.startLoc;
|
1666
|
+
var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn);
|
1667
|
+
var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical);
|
1668
1668
|
return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn)
|
1669
1669
|
}
|
1670
1670
|
}
|
1671
1671
|
return left
|
1672
|
-
}
|
1672
|
+
};
|
1673
1673
|
|
1674
1674
|
pp$3.buildBinary = function(startPos, startLoc, left, right, op, logical) {
|
1675
|
-
var node = this.startNodeAt(startPos, startLoc)
|
1676
|
-
node.left = left
|
1677
|
-
node.operator = op
|
1678
|
-
node.right = right
|
1675
|
+
var node = this.startNodeAt(startPos, startLoc);
|
1676
|
+
node.left = left;
|
1677
|
+
node.operator = op;
|
1678
|
+
node.right = right;
|
1679
1679
|
return this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression")
|
1680
|
-
}
|
1680
|
+
};
|
1681
1681
|
|
1682
1682
|
// Parse unary operators, both prefix and postfix.
|
1683
1683
|
|
1684
1684
|
pp$3.parseMaybeUnary = function(refDestructuringErrors, sawUnary) {
|
1685
1685
|
var this$1 = this;
|
1686
1686
|
|
1687
|
-
var startPos = this.start, startLoc = this.startLoc, expr
|
1687
|
+
var startPos = this.start, startLoc = this.startLoc, expr;
|
1688
1688
|
if (this.type.prefix) {
|
1689
|
-
var node = this.startNode(), update = this.type === tt.incDec
|
1690
|
-
node.operator = this.value
|
1691
|
-
node.prefix = true
|
1692
|
-
this.next()
|
1693
|
-
node.argument = this.parseMaybeUnary(null, true)
|
1694
|
-
this.checkExpressionErrors(refDestructuringErrors, true)
|
1695
|
-
if (update) this.checkLVal(node.argument)
|
1689
|
+
var node = this.startNode(), update = this.type === tt.incDec;
|
1690
|
+
node.operator = this.value;
|
1691
|
+
node.prefix = true;
|
1692
|
+
this.next();
|
1693
|
+
node.argument = this.parseMaybeUnary(null, true);
|
1694
|
+
this.checkExpressionErrors(refDestructuringErrors, true);
|
1695
|
+
if (update) this.checkLVal(node.argument);
|
1696
1696
|
else if (this.strict && node.operator === "delete" &&
|
1697
1697
|
node.argument.type === "Identifier")
|
1698
|
-
this.raiseRecoverable(node.start, "Deleting local variable in strict mode")
|
1699
|
-
else sawUnary = true
|
1700
|
-
expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression")
|
1698
|
+
this.raiseRecoverable(node.start, "Deleting local variable in strict mode");
|
1699
|
+
else sawUnary = true;
|
1700
|
+
expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
|
1701
1701
|
} else {
|
1702
|
-
expr = this.parseExprSubscripts(refDestructuringErrors)
|
1702
|
+
expr = this.parseExprSubscripts(refDestructuringErrors);
|
1703
1703
|
if (this.checkExpressionErrors(refDestructuringErrors)) return expr
|
1704
1704
|
while (this.type.postfix && !this.canInsertSemicolon()) {
|
1705
|
-
var node$1 = this$1.startNodeAt(startPos, startLoc)
|
1706
|
-
node$1.operator = this$1.value
|
1707
|
-
node$1.prefix = false
|
1708
|
-
node$1.argument = expr
|
1709
|
-
this$1.checkLVal(expr)
|
1710
|
-
this$1.next()
|
1711
|
-
expr = this$1.finishNode(node$1, "UpdateExpression")
|
1705
|
+
var node$1 = this$1.startNodeAt(startPos, startLoc);
|
1706
|
+
node$1.operator = this$1.value;
|
1707
|
+
node$1.prefix = false;
|
1708
|
+
node$1.argument = expr;
|
1709
|
+
this$1.checkLVal(expr);
|
1710
|
+
this$1.next();
|
1711
|
+
expr = this$1.finishNode(node$1, "UpdateExpression");
|
1712
1712
|
}
|
1713
1713
|
}
|
1714
1714
|
|
@@ -1716,50 +1716,50 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
1716
1716
|
return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false), "**", false)
|
1717
1717
|
else
|
1718
1718
|
return expr
|
1719
|
-
}
|
1719
|
+
};
|
1720
1720
|
|
1721
1721
|
// Parse call, dot, and `[]`-subscript expressions.
|
1722
1722
|
|
1723
1723
|
pp$3.parseExprSubscripts = function(refDestructuringErrors) {
|
1724
|
-
var startPos = this.start, startLoc = this.startLoc
|
1725
|
-
var expr = this.parseExprAtom(refDestructuringErrors)
|
1726
|
-
var skipArrowSubscripts = expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")"
|
1724
|
+
var startPos = this.start, startLoc = this.startLoc;
|
1725
|
+
var expr = this.parseExprAtom(refDestructuringErrors);
|
1726
|
+
var skipArrowSubscripts = expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")";
|
1727
1727
|
if (this.checkExpressionErrors(refDestructuringErrors) || skipArrowSubscripts) return expr
|
1728
1728
|
return this.parseSubscripts(expr, startPos, startLoc)
|
1729
|
-
}
|
1729
|
+
};
|
1730
1730
|
|
1731
1731
|
pp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) {
|
1732
1732
|
var this$1 = this;
|
1733
1733
|
|
1734
1734
|
for (;;) {
|
1735
1735
|
if (this$1.eat(tt.dot)) {
|
1736
|
-
var node = this$1.startNodeAt(startPos, startLoc)
|
1737
|
-
node.object = base
|
1738
|
-
node.property = this$1.parseIdent(true)
|
1739
|
-
node.computed = false
|
1740
|
-
base = this$1.finishNode(node, "MemberExpression")
|
1736
|
+
var node = this$1.startNodeAt(startPos, startLoc);
|
1737
|
+
node.object = base;
|
1738
|
+
node.property = this$1.parseIdent(true);
|
1739
|
+
node.computed = false;
|
1740
|
+
base = this$1.finishNode(node, "MemberExpression");
|
1741
1741
|
} else if (this$1.eat(tt.bracketL)) {
|
1742
|
-
var node$1 = this$1.startNodeAt(startPos, startLoc)
|
1743
|
-
node$1.object = base
|
1744
|
-
node$1.property = this$1.parseExpression()
|
1745
|
-
node$1.computed = true
|
1746
|
-
this$1.expect(tt.bracketR)
|
1747
|
-
base = this$1.finishNode(node$1, "MemberExpression")
|
1742
|
+
var node$1 = this$1.startNodeAt(startPos, startLoc);
|
1743
|
+
node$1.object = base;
|
1744
|
+
node$1.property = this$1.parseExpression();
|
1745
|
+
node$1.computed = true;
|
1746
|
+
this$1.expect(tt.bracketR);
|
1747
|
+
base = this$1.finishNode(node$1, "MemberExpression");
|
1748
1748
|
} else if (!noCalls && this$1.eat(tt.parenL)) {
|
1749
|
-
var node$2 = this$1.startNodeAt(startPos, startLoc)
|
1750
|
-
node$2.callee = base
|
1751
|
-
node$2.arguments = this$1.parseExprList(tt.parenR, false)
|
1752
|
-
base = this$1.finishNode(node$2, "CallExpression")
|
1749
|
+
var node$2 = this$1.startNodeAt(startPos, startLoc);
|
1750
|
+
node$2.callee = base;
|
1751
|
+
node$2.arguments = this$1.parseExprList(tt.parenR, false);
|
1752
|
+
base = this$1.finishNode(node$2, "CallExpression");
|
1753
1753
|
} else if (this$1.type === tt.backQuote) {
|
1754
|
-
var node$3 = this$1.startNodeAt(startPos, startLoc)
|
1755
|
-
node$3.tag = base
|
1756
|
-
node$3.quasi = this$1.parseTemplate()
|
1757
|
-
base = this$1.finishNode(node$3, "TaggedTemplateExpression")
|
1754
|
+
var node$3 = this$1.startNodeAt(startPos, startLoc);
|
1755
|
+
node$3.tag = base;
|
1756
|
+
node$3.quasi = this$1.parseTemplate();
|
1757
|
+
base = this$1.finishNode(node$3, "TaggedTemplateExpression");
|
1758
1758
|
} else {
|
1759
1759
|
return base
|
1760
1760
|
}
|
1761
1761
|
}
|
1762
|
-
}
|
1762
|
+
};
|
1763
1763
|
|
1764
1764
|
// Parse an atomic expression — either a single token that is an
|
1765
1765
|
// expression, an expression started by a keyword like `function` or
|
@@ -1767,56 +1767,56 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
1767
1767
|
// or `{}`.
|
1768
1768
|
|
1769
1769
|
pp$3.parseExprAtom = function(refDestructuringErrors) {
|
1770
|
-
var node, canBeArrow = this.potentialArrowAt == this.start
|
1770
|
+
var node, canBeArrow = this.potentialArrowAt == this.start;
|
1771
1771
|
switch (this.type) {
|
1772
1772
|
case tt._super:
|
1773
1773
|
if (!this.inFunction)
|
1774
|
-
this.raise(this.start, "'super' outside of function or class")
|
1774
|
+
this.raise(this.start, "'super' outside of function or class");
|
1775
1775
|
|
1776
1776
|
case tt._this:
|
1777
|
-
var type = this.type === tt._this ? "ThisExpression" : "Super"
|
1778
|
-
node = this.startNode()
|
1779
|
-
this.next()
|
1777
|
+
var type = this.type === tt._this ? "ThisExpression" : "Super";
|
1778
|
+
node = this.startNode();
|
1779
|
+
this.next();
|
1780
1780
|
return this.finishNode(node, type)
|
1781
1781
|
|
1782
1782
|
case tt.name:
|
1783
|
-
var startPos = this.start, startLoc = this.startLoc
|
1784
|
-
var id = this.parseIdent(this.type !== tt.name)
|
1783
|
+
var startPos = this.start, startLoc = this.startLoc;
|
1784
|
+
var id = this.parseIdent(this.type !== tt.name);
|
1785
1785
|
if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow))
|
1786
1786
|
return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id])
|
1787
1787
|
return id
|
1788
1788
|
|
1789
1789
|
case tt.regexp:
|
1790
|
-
var value = this.value
|
1791
|
-
node = this.parseLiteral(value.value)
|
1792
|
-
node.regex = {pattern: value.pattern, flags: value.flags}
|
1790
|
+
var value = this.value;
|
1791
|
+
node = this.parseLiteral(value.value);
|
1792
|
+
node.regex = {pattern: value.pattern, flags: value.flags};
|
1793
1793
|
return node
|
1794
1794
|
|
1795
1795
|
case tt.num: case tt.string:
|
1796
1796
|
return this.parseLiteral(this.value)
|
1797
1797
|
|
1798
1798
|
case tt._null: case tt._true: case tt._false:
|
1799
|
-
node = this.startNode()
|
1800
|
-
node.value = this.type === tt._null ? null : this.type === tt._true
|
1801
|
-
node.raw = this.type.keyword
|
1802
|
-
this.next()
|
1799
|
+
node = this.startNode();
|
1800
|
+
node.value = this.type === tt._null ? null : this.type === tt._true;
|
1801
|
+
node.raw = this.type.keyword;
|
1802
|
+
this.next();
|
1803
1803
|
return this.finishNode(node, "Literal")
|
1804
1804
|
|
1805
1805
|
case tt.parenL:
|
1806
1806
|
return this.parseParenAndDistinguishExpression(canBeArrow)
|
1807
1807
|
|
1808
1808
|
case tt.bracketL:
|
1809
|
-
node = this.startNode()
|
1810
|
-
this.next()
|
1811
|
-
node.elements = this.parseExprList(tt.bracketR, true, true, refDestructuringErrors)
|
1809
|
+
node = this.startNode();
|
1810
|
+
this.next();
|
1811
|
+
node.elements = this.parseExprList(tt.bracketR, true, true, refDestructuringErrors);
|
1812
1812
|
return this.finishNode(node, "ArrayExpression")
|
1813
1813
|
|
1814
1814
|
case tt.braceL:
|
1815
1815
|
return this.parseObj(false, refDestructuringErrors)
|
1816
1816
|
|
1817
1817
|
case tt._function:
|
1818
|
-
node = this.startNode()
|
1819
|
-
this.next()
|
1818
|
+
node = this.startNode();
|
1819
|
+
this.next();
|
1820
1820
|
return this.parseFunction(node, false)
|
1821
1821
|
|
1822
1822
|
case tt._class:
|
@@ -1829,88 +1829,88 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
1829
1829
|
return this.parseTemplate()
|
1830
1830
|
|
1831
1831
|
default:
|
1832
|
-
this.unexpected()
|
1832
|
+
this.unexpected();
|
1833
1833
|
}
|
1834
|
-
}
|
1834
|
+
};
|
1835
1835
|
|
1836
1836
|
pp$3.parseLiteral = function(value) {
|
1837
|
-
var node = this.startNode()
|
1838
|
-
node.value = value
|
1839
|
-
node.raw = this.input.slice(this.start, this.end)
|
1840
|
-
this.next()
|
1837
|
+
var node = this.startNode();
|
1838
|
+
node.value = value;
|
1839
|
+
node.raw = this.input.slice(this.start, this.end);
|
1840
|
+
this.next();
|
1841
1841
|
return this.finishNode(node, "Literal")
|
1842
|
-
}
|
1842
|
+
};
|
1843
1843
|
|
1844
1844
|
pp$3.parseParenExpression = function() {
|
1845
|
-
this.expect(tt.parenL)
|
1846
|
-
var val = this.parseExpression()
|
1847
|
-
this.expect(tt.parenR)
|
1845
|
+
this.expect(tt.parenL);
|
1846
|
+
var val = this.parseExpression();
|
1847
|
+
this.expect(tt.parenR);
|
1848
1848
|
return val
|
1849
|
-
}
|
1849
|
+
};
|
1850
1850
|
|
1851
1851
|
pp$3.parseParenAndDistinguishExpression = function(canBeArrow) {
|
1852
1852
|
var this$1 = this;
|
1853
1853
|
|
1854
|
-
var startPos = this.start, startLoc = this.startLoc, val
|
1854
|
+
var startPos = this.start, startLoc = this.startLoc, val;
|
1855
1855
|
if (this.options.ecmaVersion >= 6) {
|
1856
|
-
this.next()
|
1856
|
+
this.next();
|
1857
1857
|
|
1858
|
-
var innerStartPos = this.start, innerStartLoc = this.startLoc
|
1859
|
-
var exprList = [], first = true
|
1860
|
-
var refDestructuringErrors = new DestructuringErrors, spreadStart, innerParenStart
|
1858
|
+
var innerStartPos = this.start, innerStartLoc = this.startLoc;
|
1859
|
+
var exprList = [], first = true;
|
1860
|
+
var refDestructuringErrors = new DestructuringErrors, spreadStart, innerParenStart;
|
1861
1861
|
while (this.type !== tt.parenR) {
|
1862
|
-
first ? first = false : this$1.expect(tt.comma)
|
1862
|
+
first ? first = false : this$1.expect(tt.comma);
|
1863
1863
|
if (this$1.type === tt.ellipsis) {
|
1864
|
-
spreadStart = this$1.start
|
1865
|
-
exprList.push(this$1.parseParenItem(this$1.parseRest()))
|
1864
|
+
spreadStart = this$1.start;
|
1865
|
+
exprList.push(this$1.parseParenItem(this$1.parseRest()));
|
1866
1866
|
break
|
1867
1867
|
} else {
|
1868
1868
|
if (this$1.type === tt.parenL && !innerParenStart) {
|
1869
|
-
innerParenStart = this$1.start
|
1869
|
+
innerParenStart = this$1.start;
|
1870
1870
|
}
|
1871
|
-
exprList.push(this$1.parseMaybeAssign(false, refDestructuringErrors, this$1.parseParenItem))
|
1871
|
+
exprList.push(this$1.parseMaybeAssign(false, refDestructuringErrors, this$1.parseParenItem));
|
1872
1872
|
}
|
1873
1873
|
}
|
1874
|
-
var innerEndPos = this.start, innerEndLoc = this.startLoc
|
1875
|
-
this.expect(tt.parenR)
|
1874
|
+
var innerEndPos = this.start, innerEndLoc = this.startLoc;
|
1875
|
+
this.expect(tt.parenR);
|
1876
1876
|
|
1877
1877
|
if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) {
|
1878
|
-
this.checkPatternErrors(refDestructuringErrors, true)
|
1879
|
-
if (innerParenStart) this.unexpected(innerParenStart)
|
1878
|
+
this.checkPatternErrors(refDestructuringErrors, true);
|
1879
|
+
if (innerParenStart) this.unexpected(innerParenStart);
|
1880
1880
|
return this.parseParenArrowList(startPos, startLoc, exprList)
|
1881
1881
|
}
|
1882
1882
|
|
1883
|
-
if (!exprList.length) this.unexpected(this.lastTokStart)
|
1884
|
-
if (spreadStart) this.unexpected(spreadStart)
|
1885
|
-
this.checkExpressionErrors(refDestructuringErrors, true)
|
1883
|
+
if (!exprList.length) this.unexpected(this.lastTokStart);
|
1884
|
+
if (spreadStart) this.unexpected(spreadStart);
|
1885
|
+
this.checkExpressionErrors(refDestructuringErrors, true);
|
1886
1886
|
|
1887
1887
|
if (exprList.length > 1) {
|
1888
|
-
val = this.startNodeAt(innerStartPos, innerStartLoc)
|
1889
|
-
val.expressions = exprList
|
1890
|
-
this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc)
|
1888
|
+
val = this.startNodeAt(innerStartPos, innerStartLoc);
|
1889
|
+
val.expressions = exprList;
|
1890
|
+
this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc);
|
1891
1891
|
} else {
|
1892
|
-
val = exprList[0]
|
1892
|
+
val = exprList[0];
|
1893
1893
|
}
|
1894
1894
|
} else {
|
1895
|
-
val = this.parseParenExpression()
|
1895
|
+
val = this.parseParenExpression();
|
1896
1896
|
}
|
1897
1897
|
|
1898
1898
|
if (this.options.preserveParens) {
|
1899
|
-
var par = this.startNodeAt(startPos, startLoc)
|
1900
|
-
par.expression = val
|
1899
|
+
var par = this.startNodeAt(startPos, startLoc);
|
1900
|
+
par.expression = val;
|
1901
1901
|
return this.finishNode(par, "ParenthesizedExpression")
|
1902
1902
|
} else {
|
1903
1903
|
return val
|
1904
1904
|
}
|
1905
|
-
}
|
1905
|
+
};
|
1906
1906
|
|
1907
1907
|
pp$3.parseParenItem = function(item) {
|
1908
1908
|
return item
|
1909
|
-
}
|
1909
|
+
};
|
1910
1910
|
|
1911
1911
|
pp$3.parseParenArrowList = function(startPos, startLoc, exprList) {
|
1912
1912
|
return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList)
|
1913
|
-
}
|
1913
|
+
};
|
1914
1914
|
|
1915
1915
|
// New's precedence is slightly tricky. It must allow its argument to
|
1916
1916
|
// be a `[]` or dot subscript expression, but not a call — at least,
|
@@ -1918,203 +1918,203 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
1918
1918
|
// argument to parseSubscripts to prevent it from consuming the
|
1919
1919
|
// argument list.
|
1920
1920
|
|
1921
|
-
var empty$1 = []
|
1921
|
+
var empty$1 = [];
|
1922
1922
|
|
1923
1923
|
pp$3.parseNew = function() {
|
1924
|
-
var node = this.startNode()
|
1925
|
-
var meta = this.parseIdent(true)
|
1924
|
+
var node = this.startNode();
|
1925
|
+
var meta = this.parseIdent(true);
|
1926
1926
|
if (this.options.ecmaVersion >= 6 && this.eat(tt.dot)) {
|
1927
|
-
node.meta = meta
|
1928
|
-
node.property = this.parseIdent(true)
|
1927
|
+
node.meta = meta;
|
1928
|
+
node.property = this.parseIdent(true);
|
1929
1929
|
if (node.property.name !== "target")
|
1930
|
-
this.raiseRecoverable(node.property.start, "The only valid meta property for new is new.target")
|
1930
|
+
this.raiseRecoverable(node.property.start, "The only valid meta property for new is new.target");
|
1931
1931
|
if (!this.inFunction)
|
1932
|
-
this.raiseRecoverable(node.start, "new.target can only be used in functions")
|
1932
|
+
this.raiseRecoverable(node.start, "new.target can only be used in functions");
|
1933
1933
|
return this.finishNode(node, "MetaProperty")
|
1934
1934
|
}
|
1935
|
-
var startPos = this.start, startLoc = this.startLoc
|
1936
|
-
node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true)
|
1937
|
-
if (this.eat(tt.parenL)) node.arguments = this.parseExprList(tt.parenR, false)
|
1938
|
-
else node.arguments = empty$1
|
1935
|
+
var startPos = this.start, startLoc = this.startLoc;
|
1936
|
+
node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true);
|
1937
|
+
if (this.eat(tt.parenL)) node.arguments = this.parseExprList(tt.parenR, false);
|
1938
|
+
else node.arguments = empty$1;
|
1939
1939
|
return this.finishNode(node, "NewExpression")
|
1940
|
-
}
|
1940
|
+
};
|
1941
1941
|
|
1942
1942
|
// Parse template expression.
|
1943
1943
|
|
1944
1944
|
pp$3.parseTemplateElement = function() {
|
1945
|
-
var elem = this.startNode()
|
1945
|
+
var elem = this.startNode();
|
1946
1946
|
elem.value = {
|
1947
1947
|
raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, '\n'),
|
1948
1948
|
cooked: this.value
|
1949
|
-
}
|
1950
|
-
this.next()
|
1951
|
-
elem.tail = this.type === tt.backQuote
|
1949
|
+
};
|
1950
|
+
this.next();
|
1951
|
+
elem.tail = this.type === tt.backQuote;
|
1952
1952
|
return this.finishNode(elem, "TemplateElement")
|
1953
|
-
}
|
1953
|
+
};
|
1954
1954
|
|
1955
1955
|
pp$3.parseTemplate = function() {
|
1956
1956
|
var this$1 = this;
|
1957
1957
|
|
1958
|
-
var node = this.startNode()
|
1959
|
-
this.next()
|
1960
|
-
node.expressions = []
|
1961
|
-
var curElt = this.parseTemplateElement()
|
1962
|
-
node.quasis = [curElt]
|
1958
|
+
var node = this.startNode();
|
1959
|
+
this.next();
|
1960
|
+
node.expressions = [];
|
1961
|
+
var curElt = this.parseTemplateElement();
|
1962
|
+
node.quasis = [curElt];
|
1963
1963
|
while (!curElt.tail) {
|
1964
|
-
this$1.expect(tt.dollarBraceL)
|
1965
|
-
node.expressions.push(this$1.parseExpression())
|
1966
|
-
this$1.expect(tt.braceR)
|
1967
|
-
node.quasis.push(curElt = this$1.parseTemplateElement())
|
1964
|
+
this$1.expect(tt.dollarBraceL);
|
1965
|
+
node.expressions.push(this$1.parseExpression());
|
1966
|
+
this$1.expect(tt.braceR);
|
1967
|
+
node.quasis.push(curElt = this$1.parseTemplateElement());
|
1968
1968
|
}
|
1969
|
-
this.next()
|
1969
|
+
this.next();
|
1970
1970
|
return this.finishNode(node, "TemplateLiteral")
|
1971
|
-
}
|
1971
|
+
};
|
1972
1972
|
|
1973
1973
|
// Parse an object literal or binding pattern.
|
1974
1974
|
|
1975
1975
|
pp$3.parseObj = function(isPattern, refDestructuringErrors) {
|
1976
1976
|
var this$1 = this;
|
1977
1977
|
|
1978
|
-
var node = this.startNode(), first = true, propHash = {}
|
1979
|
-
node.properties = []
|
1980
|
-
this.next()
|
1978
|
+
var node = this.startNode(), first = true, propHash = {};
|
1979
|
+
node.properties = [];
|
1980
|
+
this.next();
|
1981
1981
|
while (!this.eat(tt.braceR)) {
|
1982
1982
|
if (!first) {
|
1983
|
-
this$1.expect(tt.comma)
|
1983
|
+
this$1.expect(tt.comma);
|
1984
1984
|
if (this$1.afterTrailingComma(tt.braceR)) break
|
1985
|
-
} else first = false
|
1985
|
+
} else first = false;
|
1986
1986
|
|
1987
|
-
var prop = this$1.startNode(), isGenerator, startPos, startLoc
|
1987
|
+
var prop = this$1.startNode(), isGenerator, startPos, startLoc;
|
1988
1988
|
if (this$1.options.ecmaVersion >= 6) {
|
1989
|
-
prop.method = false
|
1990
|
-
prop.shorthand = false
|
1989
|
+
prop.method = false;
|
1990
|
+
prop.shorthand = false;
|
1991
1991
|
if (isPattern || refDestructuringErrors) {
|
1992
|
-
startPos = this$1.start
|
1993
|
-
startLoc = this$1.startLoc
|
1992
|
+
startPos = this$1.start;
|
1993
|
+
startLoc = this$1.startLoc;
|
1994
1994
|
}
|
1995
1995
|
if (!isPattern)
|
1996
|
-
isGenerator = this$1.eat(tt.star)
|
1996
|
+
isGenerator = this$1.eat(tt.star);
|
1997
1997
|
}
|
1998
|
-
this$1.parsePropertyName(prop)
|
1999
|
-
this$1.parsePropertyValue(prop, isPattern, isGenerator, startPos, startLoc, refDestructuringErrors)
|
2000
|
-
this$1.checkPropClash(prop, propHash)
|
2001
|
-
node.properties.push(this$1.finishNode(prop, "Property"))
|
1998
|
+
this$1.parsePropertyName(prop);
|
1999
|
+
this$1.parsePropertyValue(prop, isPattern, isGenerator, startPos, startLoc, refDestructuringErrors);
|
2000
|
+
this$1.checkPropClash(prop, propHash);
|
2001
|
+
node.properties.push(this$1.finishNode(prop, "Property"));
|
2002
2002
|
}
|
2003
2003
|
return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression")
|
2004
|
-
}
|
2004
|
+
};
|
2005
2005
|
|
2006
2006
|
pp$3.parsePropertyValue = function(prop, isPattern, isGenerator, startPos, startLoc, refDestructuringErrors) {
|
2007
2007
|
if (this.eat(tt.colon)) {
|
2008
|
-
prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors)
|
2009
|
-
prop.kind = "init"
|
2008
|
+
prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors);
|
2009
|
+
prop.kind = "init";
|
2010
2010
|
} else if (this.options.ecmaVersion >= 6 && this.type === tt.parenL) {
|
2011
|
-
if (isPattern) this.unexpected()
|
2012
|
-
prop.kind = "init"
|
2013
|
-
prop.method = true
|
2014
|
-
prop.value = this.parseMethod(isGenerator)
|
2011
|
+
if (isPattern) this.unexpected();
|
2012
|
+
prop.kind = "init";
|
2013
|
+
prop.method = true;
|
2014
|
+
prop.value = this.parseMethod(isGenerator);
|
2015
2015
|
} else if (this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" &&
|
2016
2016
|
(prop.key.name === "get" || prop.key.name === "set") &&
|
2017
2017
|
(this.type != tt.comma && this.type != tt.braceR)) {
|
2018
|
-
if (isGenerator || isPattern) this.unexpected()
|
2019
|
-
prop.kind = prop.key.name
|
2020
|
-
this.parsePropertyName(prop)
|
2021
|
-
prop.value = this.parseMethod(false)
|
2022
|
-
var paramCount = prop.kind === "get" ? 0 : 1
|
2018
|
+
if (isGenerator || isPattern) this.unexpected();
|
2019
|
+
prop.kind = prop.key.name;
|
2020
|
+
this.parsePropertyName(prop);
|
2021
|
+
prop.value = this.parseMethod(false);
|
2022
|
+
var paramCount = prop.kind === "get" ? 0 : 1;
|
2023
2023
|
if (prop.value.params.length !== paramCount) {
|
2024
|
-
var start = prop.value.start
|
2024
|
+
var start = prop.value.start;
|
2025
2025
|
if (prop.kind === "get")
|
2026
|
-
this.raiseRecoverable(start, "getter should have no params")
|
2026
|
+
this.raiseRecoverable(start, "getter should have no params");
|
2027
2027
|
else
|
2028
|
-
this.raiseRecoverable(start, "setter should have exactly one param")
|
2028
|
+
this.raiseRecoverable(start, "setter should have exactly one param");
|
2029
2029
|
}
|
2030
2030
|
if (prop.kind === "set" && prop.value.params[0].type === "RestElement")
|
2031
|
-
this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params")
|
2031
|
+
this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params");
|
2032
2032
|
} else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
|
2033
2033
|
if (this.keywords.test(prop.key.name) ||
|
2034
2034
|
(this.strict ? this.reservedWordsStrictBind : this.reservedWords).test(prop.key.name) ||
|
2035
2035
|
(this.inGenerator && prop.key.name == "yield"))
|
2036
|
-
this.raiseRecoverable(prop.key.start, "'" + prop.key.name + "' can not be used as shorthand property")
|
2037
|
-
prop.kind = "init"
|
2036
|
+
this.raiseRecoverable(prop.key.start, "'" + prop.key.name + "' can not be used as shorthand property");
|
2037
|
+
prop.kind = "init";
|
2038
2038
|
if (isPattern) {
|
2039
|
-
prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key)
|
2039
|
+
prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key);
|
2040
2040
|
} else if (this.type === tt.eq && refDestructuringErrors) {
|
2041
2041
|
if (!refDestructuringErrors.shorthandAssign)
|
2042
|
-
refDestructuringErrors.shorthandAssign = this.start
|
2043
|
-
prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key)
|
2042
|
+
refDestructuringErrors.shorthandAssign = this.start;
|
2043
|
+
prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key);
|
2044
2044
|
} else {
|
2045
|
-
prop.value = prop.key
|
2045
|
+
prop.value = prop.key;
|
2046
2046
|
}
|
2047
|
-
prop.shorthand = true
|
2048
|
-
} else this.unexpected()
|
2049
|
-
}
|
2047
|
+
prop.shorthand = true;
|
2048
|
+
} else this.unexpected();
|
2049
|
+
};
|
2050
2050
|
|
2051
2051
|
pp$3.parsePropertyName = function(prop) {
|
2052
2052
|
if (this.options.ecmaVersion >= 6) {
|
2053
2053
|
if (this.eat(tt.bracketL)) {
|
2054
|
-
prop.computed = true
|
2055
|
-
prop.key = this.parseMaybeAssign()
|
2056
|
-
this.expect(tt.bracketR)
|
2054
|
+
prop.computed = true;
|
2055
|
+
prop.key = this.parseMaybeAssign();
|
2056
|
+
this.expect(tt.bracketR);
|
2057
2057
|
return prop.key
|
2058
2058
|
} else {
|
2059
|
-
prop.computed = false
|
2059
|
+
prop.computed = false;
|
2060
2060
|
}
|
2061
2061
|
}
|
2062
2062
|
return prop.key = this.type === tt.num || this.type === tt.string ? this.parseExprAtom() : this.parseIdent(true)
|
2063
|
-
}
|
2063
|
+
};
|
2064
2064
|
|
2065
2065
|
// Initialize empty function node.
|
2066
2066
|
|
2067
2067
|
pp$3.initFunction = function(node) {
|
2068
|
-
node.id = null
|
2068
|
+
node.id = null;
|
2069
2069
|
if (this.options.ecmaVersion >= 6) {
|
2070
|
-
node.generator = false
|
2071
|
-
node.expression = false
|
2070
|
+
node.generator = false;
|
2071
|
+
node.expression = false;
|
2072
2072
|
}
|
2073
|
-
}
|
2073
|
+
};
|
2074
2074
|
|
2075
2075
|
// Parse object or class method.
|
2076
2076
|
|
2077
2077
|
pp$3.parseMethod = function(isGenerator) {
|
2078
|
-
var node = this.startNode(), oldInGen = this.inGenerator
|
2079
|
-
this.inGenerator = isGenerator
|
2080
|
-
this.initFunction(node)
|
2081
|
-
this.expect(tt.parenL)
|
2082
|
-
node.params = this.parseBindingList(tt.parenR, false, false)
|
2078
|
+
var node = this.startNode(), oldInGen = this.inGenerator;
|
2079
|
+
this.inGenerator = isGenerator;
|
2080
|
+
this.initFunction(node);
|
2081
|
+
this.expect(tt.parenL);
|
2082
|
+
node.params = this.parseBindingList(tt.parenR, false, false);
|
2083
2083
|
if (this.options.ecmaVersion >= 6)
|
2084
|
-
node.generator = isGenerator
|
2085
|
-
this.parseFunctionBody(node, false)
|
2086
|
-
this.inGenerator = oldInGen
|
2084
|
+
node.generator = isGenerator;
|
2085
|
+
this.parseFunctionBody(node, false);
|
2086
|
+
this.inGenerator = oldInGen;
|
2087
2087
|
return this.finishNode(node, "FunctionExpression")
|
2088
|
-
}
|
2088
|
+
};
|
2089
2089
|
|
2090
2090
|
// Parse arrow function expression with given parameters.
|
2091
2091
|
|
2092
2092
|
pp$3.parseArrowExpression = function(node, params) {
|
2093
|
-
var oldInGen = this.inGenerator
|
2094
|
-
this.inGenerator = false
|
2095
|
-
this.initFunction(node)
|
2096
|
-
node.params = this.toAssignableList(params, true)
|
2097
|
-
this.parseFunctionBody(node, true)
|
2098
|
-
this.inGenerator = oldInGen
|
2093
|
+
var oldInGen = this.inGenerator;
|
2094
|
+
this.inGenerator = false;
|
2095
|
+
this.initFunction(node);
|
2096
|
+
node.params = this.toAssignableList(params, true);
|
2097
|
+
this.parseFunctionBody(node, true);
|
2098
|
+
this.inGenerator = oldInGen;
|
2099
2099
|
return this.finishNode(node, "ArrowFunctionExpression")
|
2100
|
-
}
|
2100
|
+
};
|
2101
2101
|
|
2102
2102
|
// Parse function body and check parameters.
|
2103
2103
|
|
2104
2104
|
pp$3.parseFunctionBody = function(node, isArrowFunction) {
|
2105
|
-
var isExpression = isArrowFunction && this.type !== tt.braceL
|
2105
|
+
var isExpression = isArrowFunction && this.type !== tt.braceL;
|
2106
2106
|
|
2107
2107
|
if (isExpression) {
|
2108
|
-
node.body = this.parseMaybeAssign()
|
2109
|
-
node.expression = true
|
2108
|
+
node.body = this.parseMaybeAssign();
|
2109
|
+
node.expression = true;
|
2110
2110
|
} else {
|
2111
2111
|
// Start a new scope with regard to labels and the `inFunction`
|
2112
2112
|
// flag (restore them to their old value afterwards).
|
2113
|
-
var oldInFunc = this.inFunction, oldLabels = this.labels
|
2114
|
-
this.inFunction = true; this.labels = []
|
2115
|
-
node.body = this.parseBlock(true)
|
2116
|
-
node.expression = false
|
2117
|
-
this.inFunction = oldInFunc; this.labels = oldLabels
|
2113
|
+
var oldInFunc = this.inFunction, oldLabels = this.labels;
|
2114
|
+
this.inFunction = true; this.labels = [];
|
2115
|
+
node.body = this.parseBlock(true);
|
2116
|
+
node.expression = false;
|
2117
|
+
this.inFunction = oldInFunc; this.labels = oldLabels;
|
2118
2118
|
}
|
2119
2119
|
|
2120
2120
|
// If this is a strict mode function, verify that argument names
|
@@ -2122,16 +2122,16 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
2122
2122
|
// or `arguments`.
|
2123
2123
|
var useStrict = (!isExpression && node.body.body.length && this.isUseStrict(node.body.body[0])) ? node.body.body[0] : null;
|
2124
2124
|
if (this.strict || useStrict) {
|
2125
|
-
var oldStrict = this.strict
|
2126
|
-
this.strict = true
|
2125
|
+
var oldStrict = this.strict;
|
2126
|
+
this.strict = true;
|
2127
2127
|
if (node.id)
|
2128
|
-
this.checkLVal(node.id, true)
|
2129
|
-
this.checkParams(node, useStrict)
|
2130
|
-
this.strict = oldStrict
|
2128
|
+
this.checkLVal(node.id, true);
|
2129
|
+
this.checkParams(node, useStrict);
|
2130
|
+
this.strict = oldStrict;
|
2131
2131
|
} else if (isArrowFunction) {
|
2132
|
-
this.checkParams(node, useStrict)
|
2132
|
+
this.checkParams(node, useStrict);
|
2133
2133
|
}
|
2134
|
-
}
|
2134
|
+
};
|
2135
2135
|
|
2136
2136
|
// Checks function params for various disallowed patterns such as using "eval"
|
2137
2137
|
// or "arguments" and duplicate parameters.
|
@@ -2139,13 +2139,13 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
2139
2139
|
pp$3.checkParams = function(node, useStrict) {
|
2140
2140
|
var this$1 = this;
|
2141
2141
|
|
2142
|
-
var nameHash = {}
|
2142
|
+
var nameHash = {};
|
2143
2143
|
for (var i = 0; i < node.params.length; i++) {
|
2144
2144
|
if (useStrict && this$1.options.ecmaVersion >= 7 && node.params[i].type !== "Identifier")
|
2145
2145
|
this$1.raiseRecoverable(useStrict.start, "Illegal 'use strict' directive in function with non-simple parameter list");
|
2146
|
-
this$1.checkLVal(node.params[i], true, nameHash)
|
2146
|
+
this$1.checkLVal(node.params[i], true, nameHash);
|
2147
2147
|
}
|
2148
|
-
}
|
2148
|
+
};
|
2149
2149
|
|
2150
2150
|
// Parses a comma-separated list of expressions, and returns them as
|
2151
2151
|
// an array. `close` is the token type that ends the list, and
|
@@ -2156,68 +2156,68 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
2156
2156
|
pp$3.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) {
|
2157
2157
|
var this$1 = this;
|
2158
2158
|
|
2159
|
-
var elts = [], first = true
|
2159
|
+
var elts = [], first = true;
|
2160
2160
|
while (!this.eat(close)) {
|
2161
2161
|
if (!first) {
|
2162
|
-
this$1.expect(tt.comma)
|
2162
|
+
this$1.expect(tt.comma);
|
2163
2163
|
if (allowTrailingComma && this$1.afterTrailingComma(close)) break
|
2164
|
-
} else first = false
|
2164
|
+
} else first = false;
|
2165
2165
|
|
2166
|
-
var elt
|
2166
|
+
var elt;
|
2167
2167
|
if (allowEmpty && this$1.type === tt.comma)
|
2168
|
-
elt = null
|
2168
|
+
elt = null;
|
2169
2169
|
else if (this$1.type === tt.ellipsis) {
|
2170
|
-
elt = this$1.parseSpread(refDestructuringErrors)
|
2170
|
+
elt = this$1.parseSpread(refDestructuringErrors);
|
2171
2171
|
if (this$1.type === tt.comma && refDestructuringErrors && !refDestructuringErrors.trailingComma) {
|
2172
|
-
refDestructuringErrors.trailingComma = this$1.lastTokStart
|
2172
|
+
refDestructuringErrors.trailingComma = this$1.lastTokStart;
|
2173
2173
|
}
|
2174
2174
|
} else
|
2175
|
-
elt = this$1.parseMaybeAssign(false, refDestructuringErrors)
|
2176
|
-
elts.push(elt)
|
2175
|
+
elt = this$1.parseMaybeAssign(false, refDestructuringErrors);
|
2176
|
+
elts.push(elt);
|
2177
2177
|
}
|
2178
2178
|
return elts
|
2179
|
-
}
|
2179
|
+
};
|
2180
2180
|
|
2181
2181
|
// Parse the next token as an identifier. If `liberal` is true (used
|
2182
2182
|
// when parsing properties), it will also convert keywords into
|
2183
2183
|
// identifiers.
|
2184
2184
|
|
2185
2185
|
pp$3.parseIdent = function(liberal) {
|
2186
|
-
var node = this.startNode()
|
2187
|
-
if (liberal && this.options.allowReserved == "never") liberal = false
|
2186
|
+
var node = this.startNode();
|
2187
|
+
if (liberal && this.options.allowReserved == "never") liberal = false;
|
2188
2188
|
if (this.type === tt.name) {
|
2189
2189
|
if (!liberal && (this.strict ? this.reservedWordsStrict : this.reservedWords).test(this.value) &&
|
2190
2190
|
(this.options.ecmaVersion >= 6 ||
|
2191
2191
|
this.input.slice(this.start, this.end).indexOf("\\") == -1))
|
2192
|
-
this.raiseRecoverable(this.start, "The keyword '" + this.value + "' is reserved")
|
2192
|
+
this.raiseRecoverable(this.start, "The keyword '" + this.value + "' is reserved");
|
2193
2193
|
if (!liberal && this.inGenerator && this.value === "yield")
|
2194
|
-
this.raiseRecoverable(this.start, "Can not use 'yield' as identifier inside a generator")
|
2195
|
-
node.name = this.value
|
2194
|
+
this.raiseRecoverable(this.start, "Can not use 'yield' as identifier inside a generator");
|
2195
|
+
node.name = this.value;
|
2196
2196
|
} else if (liberal && this.type.keyword) {
|
2197
|
-
node.name = this.type.keyword
|
2197
|
+
node.name = this.type.keyword;
|
2198
2198
|
} else {
|
2199
|
-
this.unexpected()
|
2199
|
+
this.unexpected();
|
2200
2200
|
}
|
2201
|
-
this.next()
|
2201
|
+
this.next();
|
2202
2202
|
return this.finishNode(node, "Identifier")
|
2203
|
-
}
|
2203
|
+
};
|
2204
2204
|
|
2205
2205
|
// Parses yield expression inside generator.
|
2206
2206
|
|
2207
2207
|
pp$3.parseYield = function() {
|
2208
|
-
var node = this.startNode()
|
2209
|
-
this.next()
|
2208
|
+
var node = this.startNode();
|
2209
|
+
this.next();
|
2210
2210
|
if (this.type == tt.semi || this.canInsertSemicolon() || (this.type != tt.star && !this.type.startsExpr)) {
|
2211
|
-
node.delegate = false
|
2212
|
-
node.argument = null
|
2211
|
+
node.delegate = false;
|
2212
|
+
node.argument = null;
|
2213
2213
|
} else {
|
2214
|
-
node.delegate = this.eat(tt.star)
|
2215
|
-
node.argument = this.parseMaybeAssign()
|
2214
|
+
node.delegate = this.eat(tt.star);
|
2215
|
+
node.argument = this.parseMaybeAssign();
|
2216
2216
|
}
|
2217
2217
|
return this.finishNode(node, "YieldExpression")
|
2218
|
-
}
|
2218
|
+
};
|
2219
2219
|
|
2220
|
-
var pp$4 = Parser.prototype
|
2220
|
+
var pp$4 = Parser.prototype;
|
2221
2221
|
|
2222
2222
|
// This function is used to raise exceptions on parse errors. It
|
2223
2223
|
// takes an offset integer (into the current `input`) to indicate
|
@@ -2226,72 +2226,72 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
2226
2226
|
// message.
|
2227
2227
|
|
2228
2228
|
pp$4.raise = function(pos, message) {
|
2229
|
-
var loc = getLineInfo(this.input, pos)
|
2230
|
-
message += " (" + loc.line + ":" + loc.column + ")"
|
2231
|
-
var err = new SyntaxError(message)
|
2232
|
-
err.pos = pos; err.loc = loc; err.raisedAt = this.pos
|
2229
|
+
var loc = getLineInfo(this.input, pos);
|
2230
|
+
message += " (" + loc.line + ":" + loc.column + ")";
|
2231
|
+
var err = new SyntaxError(message);
|
2232
|
+
err.pos = pos; err.loc = loc; err.raisedAt = this.pos;
|
2233
2233
|
throw err
|
2234
|
-
}
|
2234
|
+
};
|
2235
2235
|
|
2236
|
-
pp$4.raiseRecoverable = pp$4.raise
|
2236
|
+
pp$4.raiseRecoverable = pp$4.raise;
|
2237
2237
|
|
2238
2238
|
pp$4.curPosition = function() {
|
2239
2239
|
if (this.options.locations) {
|
2240
2240
|
return new Position(this.curLine, this.pos - this.lineStart)
|
2241
2241
|
}
|
2242
|
-
}
|
2242
|
+
};
|
2243
2243
|
|
2244
2244
|
var Node = function Node(parser, pos, loc) {
|
2245
|
-
this.type = ""
|
2246
|
-
this.start = pos
|
2247
|
-
this.end = 0
|
2245
|
+
this.type = "";
|
2246
|
+
this.start = pos;
|
2247
|
+
this.end = 0;
|
2248
2248
|
if (parser.options.locations)
|
2249
|
-
this.loc = new SourceLocation(parser, loc)
|
2249
|
+
this.loc = new SourceLocation(parser, loc);
|
2250
2250
|
if (parser.options.directSourceFile)
|
2251
|
-
this.sourceFile = parser.options.directSourceFile
|
2251
|
+
this.sourceFile = parser.options.directSourceFile;
|
2252
2252
|
if (parser.options.ranges)
|
2253
|
-
this.range = [pos, 0]
|
2253
|
+
this.range = [pos, 0];
|
2254
2254
|
};
|
2255
2255
|
|
2256
2256
|
// Start an AST node, attaching a start offset.
|
2257
2257
|
|
2258
|
-
var pp$5 = Parser.prototype
|
2258
|
+
var pp$5 = Parser.prototype;
|
2259
2259
|
|
2260
2260
|
pp$5.startNode = function() {
|
2261
2261
|
return new Node(this, this.start, this.startLoc)
|
2262
|
-
}
|
2262
|
+
};
|
2263
2263
|
|
2264
2264
|
pp$5.startNodeAt = function(pos, loc) {
|
2265
2265
|
return new Node(this, pos, loc)
|
2266
|
-
}
|
2266
|
+
};
|
2267
2267
|
|
2268
2268
|
// Finish an AST node, adding `type` and `end` properties.
|
2269
2269
|
|
2270
2270
|
function finishNodeAt(node, type, pos, loc) {
|
2271
|
-
node.type = type
|
2272
|
-
node.end = pos
|
2271
|
+
node.type = type;
|
2272
|
+
node.end = pos;
|
2273
2273
|
if (this.options.locations)
|
2274
|
-
node.loc.end = loc
|
2274
|
+
node.loc.end = loc;
|
2275
2275
|
if (this.options.ranges)
|
2276
|
-
node.range[1] = pos
|
2276
|
+
node.range[1] = pos;
|
2277
2277
|
return node
|
2278
2278
|
}
|
2279
2279
|
|
2280
2280
|
pp$5.finishNode = function(node, type) {
|
2281
2281
|
return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc)
|
2282
|
-
}
|
2282
|
+
};
|
2283
2283
|
|
2284
2284
|
// Finish node at given position
|
2285
2285
|
|
2286
2286
|
pp$5.finishNodeAt = function(node, type, pos, loc) {
|
2287
2287
|
return finishNodeAt.call(this, node, type, pos, loc)
|
2288
|
-
}
|
2288
|
+
};
|
2289
2289
|
|
2290
2290
|
var TokContext = function TokContext(token, isExpr, preserveSpace, override) {
|
2291
|
-
this.token = token
|
2292
|
-
this.isExpr = !!isExpr
|
2293
|
-
this.preserveSpace = !!preserveSpace
|
2294
|
-
this.override = override
|
2291
|
+
this.token = token;
|
2292
|
+
this.isExpr = !!isExpr;
|
2293
|
+
this.preserveSpace = !!preserveSpace;
|
2294
|
+
this.override = override;
|
2295
2295
|
};
|
2296
2296
|
|
2297
2297
|
var types = {
|
@@ -2302,17 +2302,17 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
2302
2302
|
p_expr: new TokContext("(", true),
|
2303
2303
|
q_tmpl: new TokContext("`", true, true, function (p) { return p.readTmplToken(); }),
|
2304
2304
|
f_expr: new TokContext("function", true)
|
2305
|
-
}
|
2305
|
+
};
|
2306
2306
|
|
2307
|
-
var pp$6 = Parser.prototype
|
2307
|
+
var pp$6 = Parser.prototype;
|
2308
2308
|
|
2309
2309
|
pp$6.initialContext = function() {
|
2310
2310
|
return [types.b_stat]
|
2311
|
-
}
|
2311
|
+
};
|
2312
2312
|
|
2313
2313
|
pp$6.braceIsBlock = function(prevType) {
|
2314
2314
|
if (prevType === tt.colon) {
|
2315
|
-
var parent = this.curContext()
|
2315
|
+
var parent = this.curContext();
|
2316
2316
|
if (parent === types.b_stat || parent === types.b_expr)
|
2317
2317
|
return !parent.isExpr
|
2318
2318
|
}
|
@@ -2323,123 +2323,123 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
2323
2323
|
if (prevType == tt.braceL)
|
2324
2324
|
return this.curContext() === types.b_stat
|
2325
2325
|
return !this.exprAllowed
|
2326
|
-
}
|
2326
|
+
};
|
2327
2327
|
|
2328
2328
|
pp$6.updateContext = function(prevType) {
|
2329
|
-
var update, type = this.type
|
2329
|
+
var update, type = this.type;
|
2330
2330
|
if (type.keyword && prevType == tt.dot)
|
2331
|
-
this.exprAllowed = false
|
2331
|
+
this.exprAllowed = false;
|
2332
2332
|
else if (update = type.updateContext)
|
2333
|
-
update.call(this, prevType)
|
2333
|
+
update.call(this, prevType);
|
2334
2334
|
else
|
2335
|
-
this.exprAllowed = type.beforeExpr
|
2336
|
-
}
|
2335
|
+
this.exprAllowed = type.beforeExpr;
|
2336
|
+
};
|
2337
2337
|
|
2338
2338
|
// Token-specific context update code
|
2339
2339
|
|
2340
2340
|
tt.parenR.updateContext = tt.braceR.updateContext = function() {
|
2341
2341
|
if (this.context.length == 1) {
|
2342
|
-
this.exprAllowed = true
|
2342
|
+
this.exprAllowed = true;
|
2343
2343
|
return
|
2344
2344
|
}
|
2345
|
-
var out = this.context.pop()
|
2345
|
+
var out = this.context.pop();
|
2346
2346
|
if (out === types.b_stat && this.curContext() === types.f_expr) {
|
2347
|
-
this.context.pop()
|
2348
|
-
this.exprAllowed = false
|
2347
|
+
this.context.pop();
|
2348
|
+
this.exprAllowed = false;
|
2349
2349
|
} else if (out === types.b_tmpl) {
|
2350
|
-
this.exprAllowed = true
|
2350
|
+
this.exprAllowed = true;
|
2351
2351
|
} else {
|
2352
|
-
this.exprAllowed = !out.isExpr
|
2352
|
+
this.exprAllowed = !out.isExpr;
|
2353
2353
|
}
|
2354
|
-
}
|
2354
|
+
};
|
2355
2355
|
|
2356
2356
|
tt.braceL.updateContext = function(prevType) {
|
2357
|
-
this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr)
|
2358
|
-
this.exprAllowed = true
|
2359
|
-
}
|
2357
|
+
this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr);
|
2358
|
+
this.exprAllowed = true;
|
2359
|
+
};
|
2360
2360
|
|
2361
2361
|
tt.dollarBraceL.updateContext = function() {
|
2362
|
-
this.context.push(types.b_tmpl)
|
2363
|
-
this.exprAllowed = true
|
2364
|
-
}
|
2362
|
+
this.context.push(types.b_tmpl);
|
2363
|
+
this.exprAllowed = true;
|
2364
|
+
};
|
2365
2365
|
|
2366
2366
|
tt.parenL.updateContext = function(prevType) {
|
2367
|
-
var statementParens = prevType === tt._if || prevType === tt._for || prevType === tt._with || prevType === tt._while
|
2368
|
-
this.context.push(statementParens ? types.p_stat : types.p_expr)
|
2369
|
-
this.exprAllowed = true
|
2370
|
-
}
|
2367
|
+
var statementParens = prevType === tt._if || prevType === tt._for || prevType === tt._with || prevType === tt._while;
|
2368
|
+
this.context.push(statementParens ? types.p_stat : types.p_expr);
|
2369
|
+
this.exprAllowed = true;
|
2370
|
+
};
|
2371
2371
|
|
2372
2372
|
tt.incDec.updateContext = function() {
|
2373
2373
|
// tokExprAllowed stays unchanged
|
2374
|
-
}
|
2374
|
+
};
|
2375
2375
|
|
2376
2376
|
tt._function.updateContext = function(prevType) {
|
2377
2377
|
if (prevType.beforeExpr && prevType !== tt.semi && prevType !== tt._else &&
|
2378
2378
|
!((prevType === tt.colon || prevType === tt.braceL) && this.curContext() === types.b_stat))
|
2379
|
-
this.context.push(types.f_expr)
|
2380
|
-
this.exprAllowed = false
|
2381
|
-
}
|
2379
|
+
this.context.push(types.f_expr);
|
2380
|
+
this.exprAllowed = false;
|
2381
|
+
};
|
2382
2382
|
|
2383
2383
|
tt.backQuote.updateContext = function() {
|
2384
2384
|
if (this.curContext() === types.q_tmpl)
|
2385
|
-
this.context.pop()
|
2385
|
+
this.context.pop();
|
2386
2386
|
else
|
2387
|
-
this.context.push(types.q_tmpl)
|
2388
|
-
this.exprAllowed = false
|
2389
|
-
}
|
2387
|
+
this.context.push(types.q_tmpl);
|
2388
|
+
this.exprAllowed = false;
|
2389
|
+
};
|
2390
2390
|
|
2391
2391
|
// Object type used to represent tokens. Note that normally, tokens
|
2392
2392
|
// simply exist as properties on the parser object. This is only
|
2393
2393
|
// used for the onToken callback and the external tokenizer.
|
2394
2394
|
|
2395
2395
|
var Token = function Token(p) {
|
2396
|
-
this.type = p.type
|
2397
|
-
this.value = p.value
|
2398
|
-
this.start = p.start
|
2399
|
-
this.end = p.end
|
2396
|
+
this.type = p.type;
|
2397
|
+
this.value = p.value;
|
2398
|
+
this.start = p.start;
|
2399
|
+
this.end = p.end;
|
2400
2400
|
if (p.options.locations)
|
2401
|
-
this.loc = new SourceLocation(p, p.startLoc, p.endLoc)
|
2401
|
+
this.loc = new SourceLocation(p, p.startLoc, p.endLoc);
|
2402
2402
|
if (p.options.ranges)
|
2403
|
-
this.range = [p.start, p.end]
|
2403
|
+
this.range = [p.start, p.end];
|
2404
2404
|
};
|
2405
2405
|
|
2406
2406
|
// ## Tokenizer
|
2407
2407
|
|
2408
|
-
var pp$7 = Parser.prototype
|
2408
|
+
var pp$7 = Parser.prototype;
|
2409
2409
|
|
2410
2410
|
// Are we running under Rhino?
|
2411
|
-
var isRhino = typeof Packages == "object" && Object.prototype.toString.call(Packages) == "[object JavaPackage]"
|
2411
|
+
var isRhino = typeof Packages == "object" && Object.prototype.toString.call(Packages) == "[object JavaPackage]";
|
2412
2412
|
|
2413
2413
|
// Move to the next token
|
2414
2414
|
|
2415
2415
|
pp$7.next = function() {
|
2416
2416
|
if (this.options.onToken)
|
2417
|
-
this.options.onToken(new Token(this))
|
2417
|
+
this.options.onToken(new Token(this));
|
2418
2418
|
|
2419
|
-
this.lastTokEnd = this.end
|
2420
|
-
this.lastTokStart = this.start
|
2421
|
-
this.lastTokEndLoc = this.endLoc
|
2422
|
-
this.lastTokStartLoc = this.startLoc
|
2423
|
-
this.nextToken()
|
2424
|
-
}
|
2419
|
+
this.lastTokEnd = this.end;
|
2420
|
+
this.lastTokStart = this.start;
|
2421
|
+
this.lastTokEndLoc = this.endLoc;
|
2422
|
+
this.lastTokStartLoc = this.startLoc;
|
2423
|
+
this.nextToken();
|
2424
|
+
};
|
2425
2425
|
|
2426
2426
|
pp$7.getToken = function() {
|
2427
|
-
this.next()
|
2427
|
+
this.next();
|
2428
2428
|
return new Token(this)
|
2429
|
-
}
|
2429
|
+
};
|
2430
2430
|
|
2431
2431
|
// If we're in an ES6 environment, make parsers iterable
|
2432
2432
|
if (typeof Symbol !== "undefined")
|
2433
2433
|
pp$7[Symbol.iterator] = function () {
|
2434
|
-
var self = this
|
2434
|
+
var self = this;
|
2435
2435
|
return {next: function () {
|
2436
|
-
var token = self.getToken()
|
2436
|
+
var token = self.getToken();
|
2437
2437
|
return {
|
2438
2438
|
done: token.type === tt.eof,
|
2439
2439
|
value: token
|
2440
2440
|
}
|
2441
2441
|
}}
|
2442
|
-
}
|
2442
|
+
};
|
2443
2443
|
|
2444
2444
|
// Toggle strict mode. Re-reads the next number or string to please
|
2445
2445
|
// pedantic tests (`"use strict"; 010;` should fail).
|
@@ -2447,36 +2447,36 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
2447
2447
|
pp$7.setStrict = function(strict) {
|
2448
2448
|
var this$1 = this;
|
2449
2449
|
|
2450
|
-
this.strict = strict
|
2450
|
+
this.strict = strict;
|
2451
2451
|
if (this.type !== tt.num && this.type !== tt.string) return
|
2452
|
-
this.pos = this.start
|
2452
|
+
this.pos = this.start;
|
2453
2453
|
if (this.options.locations) {
|
2454
2454
|
while (this.pos < this.lineStart) {
|
2455
|
-
this$1.lineStart = this$1.input.lastIndexOf("\n", this$1.lineStart - 2) + 1
|
2456
|
-
--this$1.curLine
|
2455
|
+
this$1.lineStart = this$1.input.lastIndexOf("\n", this$1.lineStart - 2) + 1;
|
2456
|
+
--this$1.curLine;
|
2457
2457
|
}
|
2458
2458
|
}
|
2459
|
-
this.nextToken()
|
2460
|
-
}
|
2459
|
+
this.nextToken();
|
2460
|
+
};
|
2461
2461
|
|
2462
2462
|
pp$7.curContext = function() {
|
2463
2463
|
return this.context[this.context.length - 1]
|
2464
|
-
}
|
2464
|
+
};
|
2465
2465
|
|
2466
2466
|
// Read a single token, updating the parser object's token-related
|
2467
2467
|
// properties.
|
2468
2468
|
|
2469
2469
|
pp$7.nextToken = function() {
|
2470
|
-
var curContext = this.curContext()
|
2471
|
-
if (!curContext || !curContext.preserveSpace) this.skipSpace()
|
2470
|
+
var curContext = this.curContext();
|
2471
|
+
if (!curContext || !curContext.preserveSpace) this.skipSpace();
|
2472
2472
|
|
2473
|
-
this.start = this.pos
|
2474
|
-
if (this.options.locations) this.startLoc = this.curPosition()
|
2473
|
+
this.start = this.pos;
|
2474
|
+
if (this.options.locations) this.startLoc = this.curPosition();
|
2475
2475
|
if (this.pos >= this.input.length) return this.finishToken(tt.eof)
|
2476
2476
|
|
2477
2477
|
if (curContext.override) return curContext.override(this)
|
2478
|
-
else this.readToken(this.fullCharCodeAtPos())
|
2479
|
-
}
|
2478
|
+
else this.readToken(this.fullCharCodeAtPos());
|
2479
|
+
};
|
2480
2480
|
|
2481
2481
|
pp$7.readToken = function(code) {
|
2482
2482
|
// Identifier or keyword. '\uXXXX' sequences are allowed in
|
@@ -2485,49 +2485,49 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
2485
2485
|
return this.readWord()
|
2486
2486
|
|
2487
2487
|
return this.getTokenFromCode(code)
|
2488
|
-
}
|
2488
|
+
};
|
2489
2489
|
|
2490
2490
|
pp$7.fullCharCodeAtPos = function() {
|
2491
|
-
var code = this.input.charCodeAt(this.pos)
|
2491
|
+
var code = this.input.charCodeAt(this.pos);
|
2492
2492
|
if (code <= 0xd7ff || code >= 0xe000) return code
|
2493
|
-
var next = this.input.charCodeAt(this.pos + 1)
|
2493
|
+
var next = this.input.charCodeAt(this.pos + 1);
|
2494
2494
|
return (code << 10) + next - 0x35fdc00
|
2495
|
-
}
|
2495
|
+
};
|
2496
2496
|
|
2497
2497
|
pp$7.skipBlockComment = function() {
|
2498
2498
|
var this$1 = this;
|
2499
2499
|
|
2500
|
-
var startLoc = this.options.onComment && this.curPosition()
|
2501
|
-
var start = this.pos, end = this.input.indexOf("*/", this.pos += 2)
|
2502
|
-
if (end === -1) this.raise(this.pos - 2, "Unterminated comment")
|
2503
|
-
this.pos = end + 2
|
2500
|
+
var startLoc = this.options.onComment && this.curPosition();
|
2501
|
+
var start = this.pos, end = this.input.indexOf("*/", this.pos += 2);
|
2502
|
+
if (end === -1) this.raise(this.pos - 2, "Unterminated comment");
|
2503
|
+
this.pos = end + 2;
|
2504
2504
|
if (this.options.locations) {
|
2505
|
-
lineBreakG.lastIndex = start
|
2506
|
-
var match
|
2505
|
+
lineBreakG.lastIndex = start;
|
2506
|
+
var match;
|
2507
2507
|
while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) {
|
2508
|
-
++this$1.curLine
|
2509
|
-
this$1.lineStart = match.index + match[0].length
|
2508
|
+
++this$1.curLine;
|
2509
|
+
this$1.lineStart = match.index + match[0].length;
|
2510
2510
|
}
|
2511
2511
|
}
|
2512
2512
|
if (this.options.onComment)
|
2513
2513
|
this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos,
|
2514
|
-
startLoc, this.curPosition())
|
2515
|
-
}
|
2514
|
+
startLoc, this.curPosition());
|
2515
|
+
};
|
2516
2516
|
|
2517
2517
|
pp$7.skipLineComment = function(startSkip) {
|
2518
2518
|
var this$1 = this;
|
2519
2519
|
|
2520
|
-
var start = this.pos
|
2521
|
-
var startLoc = this.options.onComment && this.curPosition()
|
2522
|
-
var ch = this.input.charCodeAt(this.pos+=startSkip)
|
2520
|
+
var start = this.pos;
|
2521
|
+
var startLoc = this.options.onComment && this.curPosition();
|
2522
|
+
var ch = this.input.charCodeAt(this.pos+=startSkip);
|
2523
2523
|
while (this.pos < this.input.length && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233) {
|
2524
|
-
++this$1.pos
|
2525
|
-
ch = this$1.input.charCodeAt(this$1.pos)
|
2524
|
+
++this$1.pos;
|
2525
|
+
ch = this$1.input.charCodeAt(this$1.pos);
|
2526
2526
|
}
|
2527
2527
|
if (this.options.onComment)
|
2528
2528
|
this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos,
|
2529
|
-
startLoc, this.curPosition())
|
2530
|
-
}
|
2529
|
+
startLoc, this.curPosition());
|
2530
|
+
};
|
2531
2531
|
|
2532
2532
|
// Called at the start of the parse and after every token. Skips
|
2533
2533
|
// whitespace and comments, and.
|
@@ -2536,29 +2536,29 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
2536
2536
|
var this$1 = this;
|
2537
2537
|
|
2538
2538
|
loop: while (this.pos < this.input.length) {
|
2539
|
-
var ch = this$1.input.charCodeAt(this$1.pos)
|
2539
|
+
var ch = this$1.input.charCodeAt(this$1.pos);
|
2540
2540
|
switch (ch) {
|
2541
2541
|
case 32: case 160: // ' '
|
2542
|
-
++this$1.pos
|
2542
|
+
++this$1.pos;
|
2543
2543
|
break
|
2544
2544
|
case 13:
|
2545
2545
|
if (this$1.input.charCodeAt(this$1.pos + 1) === 10) {
|
2546
|
-
++this$1.pos
|
2546
|
+
++this$1.pos;
|
2547
2547
|
}
|
2548
2548
|
case 10: case 8232: case 8233:
|
2549
|
-
++this$1.pos
|
2549
|
+
++this$1.pos;
|
2550
2550
|
if (this$1.options.locations) {
|
2551
|
-
++this$1.curLine
|
2552
|
-
this$1.lineStart = this$1.pos
|
2551
|
+
++this$1.curLine;
|
2552
|
+
this$1.lineStart = this$1.pos;
|
2553
2553
|
}
|
2554
2554
|
break
|
2555
2555
|
case 47: // '/'
|
2556
2556
|
switch (this$1.input.charCodeAt(this$1.pos + 1)) {
|
2557
2557
|
case 42: // '*'
|
2558
|
-
this$1.skipBlockComment()
|
2558
|
+
this$1.skipBlockComment();
|
2559
2559
|
break
|
2560
2560
|
case 47:
|
2561
|
-
this$1.skipLineComment(2)
|
2561
|
+
this$1.skipLineComment(2);
|
2562
2562
|
break
|
2563
2563
|
default:
|
2564
2564
|
break loop
|
@@ -2566,13 +2566,13 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
2566
2566
|
break
|
2567
2567
|
default:
|
2568
2568
|
if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {
|
2569
|
-
++this$1.pos
|
2569
|
+
++this$1.pos;
|
2570
2570
|
} else {
|
2571
2571
|
break loop
|
2572
2572
|
}
|
2573
2573
|
}
|
2574
2574
|
}
|
2575
|
-
}
|
2575
|
+
};
|
2576
2576
|
|
2577
2577
|
// Called at the end of every token. Sets `end`, `val`, and
|
2578
2578
|
// maintains `context` and `exprAllowed`, and skips the space after
|
@@ -2580,14 +2580,14 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
2580
2580
|
// right position.
|
2581
2581
|
|
2582
2582
|
pp$7.finishToken = function(type, val) {
|
2583
|
-
this.end = this.pos
|
2584
|
-
if (this.options.locations) this.endLoc = this.curPosition()
|
2585
|
-
var prevType = this.type
|
2586
|
-
this.type = type
|
2587
|
-
this.value = val
|
2583
|
+
this.end = this.pos;
|
2584
|
+
if (this.options.locations) this.endLoc = this.curPosition();
|
2585
|
+
var prevType = this.type;
|
2586
|
+
this.type = type;
|
2587
|
+
this.value = val;
|
2588
2588
|
|
2589
|
-
this.updateContext(prevType)
|
2590
|
-
}
|
2589
|
+
this.updateContext(prevType);
|
2590
|
+
};
|
2591
2591
|
|
2592
2592
|
// ### Token reading
|
2593
2593
|
|
@@ -2599,99 +2599,99 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
2599
2599
|
// All in the name of speed.
|
2600
2600
|
//
|
2601
2601
|
pp$7.readToken_dot = function() {
|
2602
|
-
var next = this.input.charCodeAt(this.pos + 1)
|
2602
|
+
var next = this.input.charCodeAt(this.pos + 1);
|
2603
2603
|
if (next >= 48 && next <= 57) return this.readNumber(true)
|
2604
|
-
var next2 = this.input.charCodeAt(this.pos + 2)
|
2604
|
+
var next2 = this.input.charCodeAt(this.pos + 2);
|
2605
2605
|
if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.'
|
2606
|
-
this.pos += 3
|
2606
|
+
this.pos += 3;
|
2607
2607
|
return this.finishToken(tt.ellipsis)
|
2608
2608
|
} else {
|
2609
|
-
++this.pos
|
2609
|
+
++this.pos;
|
2610
2610
|
return this.finishToken(tt.dot)
|
2611
2611
|
}
|
2612
|
-
}
|
2612
|
+
};
|
2613
2613
|
|
2614
2614
|
pp$7.readToken_slash = function() { // '/'
|
2615
|
-
var next = this.input.charCodeAt(this.pos + 1)
|
2615
|
+
var next = this.input.charCodeAt(this.pos + 1);
|
2616
2616
|
if (this.exprAllowed) {++this.pos; return this.readRegexp()}
|
2617
2617
|
if (next === 61) return this.finishOp(tt.assign, 2)
|
2618
2618
|
return this.finishOp(tt.slash, 1)
|
2619
|
-
}
|
2619
|
+
};
|
2620
2620
|
|
2621
2621
|
pp$7.readToken_mult_modulo_exp = function(code) { // '%*'
|
2622
|
-
var next = this.input.charCodeAt(this.pos + 1)
|
2623
|
-
var size = 1
|
2624
|
-
var tokentype = code === 42 ? tt.star : tt.modulo
|
2622
|
+
var next = this.input.charCodeAt(this.pos + 1);
|
2623
|
+
var size = 1;
|
2624
|
+
var tokentype = code === 42 ? tt.star : tt.modulo;
|
2625
2625
|
|
2626
2626
|
// exponentiation operator ** and **=
|
2627
2627
|
if (this.options.ecmaVersion >= 7 && next === 42) {
|
2628
|
-
++size
|
2629
|
-
tokentype = tt.starstar
|
2630
|
-
next = this.input.charCodeAt(this.pos + 2)
|
2628
|
+
++size;
|
2629
|
+
tokentype = tt.starstar;
|
2630
|
+
next = this.input.charCodeAt(this.pos + 2);
|
2631
2631
|
}
|
2632
2632
|
|
2633
2633
|
if (next === 61) return this.finishOp(tt.assign, size + 1)
|
2634
2634
|
return this.finishOp(tokentype, size)
|
2635
|
-
}
|
2635
|
+
};
|
2636
2636
|
|
2637
2637
|
pp$7.readToken_pipe_amp = function(code) { // '|&'
|
2638
|
-
var next = this.input.charCodeAt(this.pos + 1)
|
2638
|
+
var next = this.input.charCodeAt(this.pos + 1);
|
2639
2639
|
if (next === code) return this.finishOp(code === 124 ? tt.logicalOR : tt.logicalAND, 2)
|
2640
2640
|
if (next === 61) return this.finishOp(tt.assign, 2)
|
2641
2641
|
return this.finishOp(code === 124 ? tt.bitwiseOR : tt.bitwiseAND, 1)
|
2642
|
-
}
|
2642
|
+
};
|
2643
2643
|
|
2644
2644
|
pp$7.readToken_caret = function() { // '^'
|
2645
|
-
var next = this.input.charCodeAt(this.pos + 1)
|
2645
|
+
var next = this.input.charCodeAt(this.pos + 1);
|
2646
2646
|
if (next === 61) return this.finishOp(tt.assign, 2)
|
2647
2647
|
return this.finishOp(tt.bitwiseXOR, 1)
|
2648
|
-
}
|
2648
|
+
};
|
2649
2649
|
|
2650
2650
|
pp$7.readToken_plus_min = function(code) { // '+-'
|
2651
|
-
var next = this.input.charCodeAt(this.pos + 1)
|
2651
|
+
var next = this.input.charCodeAt(this.pos + 1);
|
2652
2652
|
if (next === code) {
|
2653
2653
|
if (next == 45 && this.input.charCodeAt(this.pos + 2) == 62 &&
|
2654
2654
|
lineBreak.test(this.input.slice(this.lastTokEnd, this.pos))) {
|
2655
2655
|
// A `-->` line comment
|
2656
|
-
this.skipLineComment(3)
|
2657
|
-
this.skipSpace()
|
2656
|
+
this.skipLineComment(3);
|
2657
|
+
this.skipSpace();
|
2658
2658
|
return this.nextToken()
|
2659
2659
|
}
|
2660
2660
|
return this.finishOp(tt.incDec, 2)
|
2661
2661
|
}
|
2662
2662
|
if (next === 61) return this.finishOp(tt.assign, 2)
|
2663
2663
|
return this.finishOp(tt.plusMin, 1)
|
2664
|
-
}
|
2664
|
+
};
|
2665
2665
|
|
2666
2666
|
pp$7.readToken_lt_gt = function(code) { // '<>'
|
2667
|
-
var next = this.input.charCodeAt(this.pos + 1)
|
2668
|
-
var size = 1
|
2667
|
+
var next = this.input.charCodeAt(this.pos + 1);
|
2668
|
+
var size = 1;
|
2669
2669
|
if (next === code) {
|
2670
|
-
size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2
|
2670
|
+
size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;
|
2671
2671
|
if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1)
|
2672
2672
|
return this.finishOp(tt.bitShift, size)
|
2673
2673
|
}
|
2674
2674
|
if (next == 33 && code == 60 && this.input.charCodeAt(this.pos + 2) == 45 &&
|
2675
2675
|
this.input.charCodeAt(this.pos + 3) == 45) {
|
2676
|
-
if (this.inModule) this.unexpected()
|
2676
|
+
if (this.inModule) this.unexpected();
|
2677
2677
|
// `<!--`, an XML-style comment that should be interpreted as a line comment
|
2678
|
-
this.skipLineComment(4)
|
2679
|
-
this.skipSpace()
|
2678
|
+
this.skipLineComment(4);
|
2679
|
+
this.skipSpace();
|
2680
2680
|
return this.nextToken()
|
2681
2681
|
}
|
2682
|
-
if (next === 61) size = 2
|
2682
|
+
if (next === 61) size = 2;
|
2683
2683
|
return this.finishOp(tt.relational, size)
|
2684
|
-
}
|
2684
|
+
};
|
2685
2685
|
|
2686
2686
|
pp$7.readToken_eq_excl = function(code) { // '=!'
|
2687
|
-
var next = this.input.charCodeAt(this.pos + 1)
|
2687
|
+
var next = this.input.charCodeAt(this.pos + 1);
|
2688
2688
|
if (next === 61) return this.finishOp(tt.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2)
|
2689
2689
|
if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) { // '=>'
|
2690
|
-
this.pos += 2
|
2690
|
+
this.pos += 2;
|
2691
2691
|
return this.finishToken(tt.arrow)
|
2692
2692
|
}
|
2693
2693
|
return this.finishOp(code === 61 ? tt.eq : tt.prefix, 1)
|
2694
|
-
}
|
2694
|
+
};
|
2695
2695
|
|
2696
2696
|
pp$7.getTokenFromCode = function(code) {
|
2697
2697
|
switch (code) {
|
@@ -2714,11 +2714,11 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
2714
2714
|
|
2715
2715
|
case 96: // '`'
|
2716
2716
|
if (this.options.ecmaVersion < 6) break
|
2717
|
-
++this.pos
|
2717
|
+
++this.pos;
|
2718
2718
|
return this.finishToken(tt.backQuote)
|
2719
2719
|
|
2720
2720
|
case 48: // '0'
|
2721
|
-
var next = this.input.charCodeAt(this.pos + 1)
|
2721
|
+
var next = this.input.charCodeAt(this.pos + 1);
|
2722
2722
|
if (next === 120 || next === 88) return this.readRadixNumber(16) // '0x', '0X' - hex number
|
2723
2723
|
if (this.options.ecmaVersion >= 6) {
|
2724
2724
|
if (next === 111 || next === 79) return this.readRadixNumber(8) // '0o', '0O' - octal number
|
@@ -2763,14 +2763,14 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
2763
2763
|
return this.finishOp(tt.prefix, 1)
|
2764
2764
|
}
|
2765
2765
|
|
2766
|
-
this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'")
|
2767
|
-
}
|
2766
|
+
this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
|
2767
|
+
};
|
2768
2768
|
|
2769
2769
|
pp$7.finishOp = function(type, size) {
|
2770
|
-
var str = this.input.slice(this.pos, this.pos + size)
|
2771
|
-
this.pos += size
|
2770
|
+
var str = this.input.slice(this.pos, this.pos + size);
|
2771
|
+
this.pos += size;
|
2772
2772
|
return this.finishToken(type, str)
|
2773
|
-
}
|
2773
|
+
};
|
2774
2774
|
|
2775
2775
|
// Parse a regular expression. Some context-awareness is necessary,
|
2776
2776
|
// since a '/' inside a '[]' set does not end the expression.
|
@@ -2780,43 +2780,43 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
2780
2780
|
return new RegExp(src, flags)
|
2781
2781
|
} catch (e) {
|
2782
2782
|
if (throwErrorAt !== undefined) {
|
2783
|
-
if (e instanceof SyntaxError) parser.raise(throwErrorAt, "Error parsing regular expression: " + e.message)
|
2783
|
+
if (e instanceof SyntaxError) parser.raise(throwErrorAt, "Error parsing regular expression: " + e.message);
|
2784
2784
|
throw e
|
2785
2785
|
}
|
2786
2786
|
}
|
2787
2787
|
}
|
2788
2788
|
|
2789
|
-
var regexpUnicodeSupport = !!tryCreateRegexp("\uffff", "u")
|
2789
|
+
var regexpUnicodeSupport = !!tryCreateRegexp("\uffff", "u");
|
2790
2790
|
|
2791
2791
|
pp$7.readRegexp = function() {
|
2792
2792
|
var this$1 = this;
|
2793
2793
|
|
2794
|
-
var escaped, inClass, start = this.pos
|
2794
|
+
var escaped, inClass, start = this.pos;
|
2795
2795
|
for (;;) {
|
2796
|
-
if (this$1.pos >= this$1.input.length) this$1.raise(start, "Unterminated regular expression")
|
2797
|
-
var ch = this$1.input.charAt(this$1.pos)
|
2798
|
-
if (lineBreak.test(ch)) this$1.raise(start, "Unterminated regular expression")
|
2796
|
+
if (this$1.pos >= this$1.input.length) this$1.raise(start, "Unterminated regular expression");
|
2797
|
+
var ch = this$1.input.charAt(this$1.pos);
|
2798
|
+
if (lineBreak.test(ch)) this$1.raise(start, "Unterminated regular expression");
|
2799
2799
|
if (!escaped) {
|
2800
|
-
if (ch === "[") inClass = true
|
2801
|
-
else if (ch === "]" && inClass) inClass = false
|
2800
|
+
if (ch === "[") inClass = true;
|
2801
|
+
else if (ch === "]" && inClass) inClass = false;
|
2802
2802
|
else if (ch === "/" && !inClass) break
|
2803
|
-
escaped = ch === "\\"
|
2804
|
-
} else escaped = false
|
2805
|
-
++this$1.pos
|
2803
|
+
escaped = ch === "\\";
|
2804
|
+
} else escaped = false;
|
2805
|
+
++this$1.pos;
|
2806
2806
|
}
|
2807
|
-
var content = this.input.slice(start, this.pos)
|
2808
|
-
++this.pos
|
2807
|
+
var content = this.input.slice(start, this.pos);
|
2808
|
+
++this.pos;
|
2809
2809
|
// Need to use `readWord1` because '\uXXXX' sequences are allowed
|
2810
2810
|
// here (don't ask).
|
2811
|
-
var mods = this.readWord1()
|
2812
|
-
var tmp = content, tmpFlags = ""
|
2811
|
+
var mods = this.readWord1();
|
2812
|
+
var tmp = content, tmpFlags = "";
|
2813
2813
|
if (mods) {
|
2814
|
-
var validFlags = /^[gim]
|
2815
|
-
if (this.options.ecmaVersion >= 6) validFlags = /^[gimuy]
|
2816
|
-
if (!validFlags.test(mods)) this.raise(start, "Invalid regular expression flag")
|
2814
|
+
var validFlags = /^[gim]*$/;
|
2815
|
+
if (this.options.ecmaVersion >= 6) validFlags = /^[gimuy]*$/;
|
2816
|
+
if (!validFlags.test(mods)) this.raise(start, "Invalid regular expression flag");
|
2817
2817
|
if (mods.indexOf("u") >= 0) {
|
2818
2818
|
if (regexpUnicodeSupport) {
|
2819
|
-
tmpFlags = "u"
|
2819
|
+
tmpFlags = "u";
|
2820
2820
|
} else {
|
2821
2821
|
// Replace each astral symbol and every Unicode escape sequence that
|
2822
2822
|
// possibly represents an astral symbol or a paired surrogate with a
|
@@ -2827,27 +2827,27 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
2827
2827
|
// perfectly valid pattern that is equivalent to `[a-b]`, but it would
|
2828
2828
|
// be replaced by `[x-b]` which throws an error.
|
2829
2829
|
tmp = tmp.replace(/\\u\{([0-9a-fA-F]+)\}/g, function (_match, code, offset) {
|
2830
|
-
code = Number("0x" + code)
|
2831
|
-
if (code > 0x10FFFF) this$1.raise(start + offset + 3, "Code point out of bounds")
|
2830
|
+
code = Number("0x" + code);
|
2831
|
+
if (code > 0x10FFFF) this$1.raise(start + offset + 3, "Code point out of bounds");
|
2832
2832
|
return "x"
|
2833
|
-
})
|
2834
|
-
tmp = tmp.replace(/\\u([a-fA-F0-9]{4})|[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "x")
|
2835
|
-
tmpFlags = tmpFlags.replace("u", "")
|
2833
|
+
});
|
2834
|
+
tmp = tmp.replace(/\\u([a-fA-F0-9]{4})|[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "x");
|
2835
|
+
tmpFlags = tmpFlags.replace("u", "");
|
2836
2836
|
}
|
2837
2837
|
}
|
2838
2838
|
}
|
2839
2839
|
// Detect invalid regular expressions.
|
2840
|
-
var value = null
|
2840
|
+
var value = null;
|
2841
2841
|
// Rhino's regular expression parser is flaky and throws uncatchable exceptions,
|
2842
2842
|
// so don't do detection if we are running under Rhino
|
2843
2843
|
if (!isRhino) {
|
2844
|
-
tryCreateRegexp(tmp, tmpFlags, start, this)
|
2844
|
+
tryCreateRegexp(tmp, tmpFlags, start, this);
|
2845
2845
|
// Get a regular expression object for this pattern-flag pair, or `null` in
|
2846
2846
|
// case the current environment doesn't support the flags it uses.
|
2847
|
-
value = tryCreateRegexp(content, mods)
|
2847
|
+
value = tryCreateRegexp(content, mods);
|
2848
2848
|
}
|
2849
2849
|
return this.finishToken(tt.regexp, {pattern: content, flags: mods, value: value})
|
2850
|
-
}
|
2850
|
+
};
|
2851
2851
|
|
2852
2852
|
// Read an integer in the given radix. Return null if zero digits
|
2853
2853
|
// were read, the integer value otherwise. When `len` is given, this
|
@@ -2856,158 +2856,158 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
2856
2856
|
pp$7.readInt = function(radix, len) {
|
2857
2857
|
var this$1 = this;
|
2858
2858
|
|
2859
|
-
var start = this.pos, total = 0
|
2859
|
+
var start = this.pos, total = 0;
|
2860
2860
|
for (var i = 0, e = len == null ? Infinity : len; i < e; ++i) {
|
2861
|
-
var code = this$1.input.charCodeAt(this$1.pos), val
|
2862
|
-
if (code >= 97) val = code - 97 + 10 // a
|
2863
|
-
else if (code >= 65) val = code - 65 + 10 // A
|
2864
|
-
else if (code >= 48 && code <= 57) val = code - 48 // 0-9
|
2865
|
-
else val = Infinity
|
2861
|
+
var code = this$1.input.charCodeAt(this$1.pos), val;
|
2862
|
+
if (code >= 97) val = code - 97 + 10; // a
|
2863
|
+
else if (code >= 65) val = code - 65 + 10; // A
|
2864
|
+
else if (code >= 48 && code <= 57) val = code - 48; // 0-9
|
2865
|
+
else val = Infinity;
|
2866
2866
|
if (val >= radix) break
|
2867
|
-
++this$1.pos
|
2868
|
-
total = total * radix + val
|
2867
|
+
++this$1.pos;
|
2868
|
+
total = total * radix + val;
|
2869
2869
|
}
|
2870
2870
|
if (this.pos === start || len != null && this.pos - start !== len) return null
|
2871
2871
|
|
2872
2872
|
return total
|
2873
|
-
}
|
2873
|
+
};
|
2874
2874
|
|
2875
2875
|
pp$7.readRadixNumber = function(radix) {
|
2876
|
-
this.pos += 2 // 0x
|
2877
|
-
var val = this.readInt(radix)
|
2878
|
-
if (val == null) this.raise(this.start + 2, "Expected number in radix " + radix)
|
2879
|
-
if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number")
|
2876
|
+
this.pos += 2; // 0x
|
2877
|
+
var val = this.readInt(radix);
|
2878
|
+
if (val == null) this.raise(this.start + 2, "Expected number in radix " + radix);
|
2879
|
+
if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number");
|
2880
2880
|
return this.finishToken(tt.num, val)
|
2881
|
-
}
|
2881
|
+
};
|
2882
2882
|
|
2883
2883
|
// Read an integer, octal integer, or floating-point number.
|
2884
2884
|
|
2885
2885
|
pp$7.readNumber = function(startsWithDot) {
|
2886
|
-
var start = this.pos, isFloat = false, octal = this.input.charCodeAt(this.pos) === 48
|
2887
|
-
if (!startsWithDot && this.readInt(10) === null) this.raise(start, "Invalid number")
|
2888
|
-
var next = this.input.charCodeAt(this.pos)
|
2886
|
+
var start = this.pos, isFloat = false, octal = this.input.charCodeAt(this.pos) === 48;
|
2887
|
+
if (!startsWithDot && this.readInt(10) === null) this.raise(start, "Invalid number");
|
2888
|
+
var next = this.input.charCodeAt(this.pos);
|
2889
2889
|
if (next === 46) { // '.'
|
2890
|
-
++this.pos
|
2891
|
-
this.readInt(10)
|
2892
|
-
isFloat = true
|
2893
|
-
next = this.input.charCodeAt(this.pos)
|
2890
|
+
++this.pos;
|
2891
|
+
this.readInt(10);
|
2892
|
+
isFloat = true;
|
2893
|
+
next = this.input.charCodeAt(this.pos);
|
2894
2894
|
}
|
2895
2895
|
if (next === 69 || next === 101) { // 'eE'
|
2896
|
-
next = this.input.charCodeAt(++this.pos)
|
2897
|
-
if (next === 43 || next === 45) ++this.pos // '+-'
|
2898
|
-
if (this.readInt(10) === null) this.raise(start, "Invalid number")
|
2899
|
-
isFloat = true
|
2900
|
-
}
|
2901
|
-
if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number")
|
2902
|
-
|
2903
|
-
var str = this.input.slice(start, this.pos), val
|
2904
|
-
if (isFloat) val = parseFloat(str)
|
2905
|
-
else if (!octal || str.length === 1) val = parseInt(str, 10)
|
2906
|
-
else if (/[89]/.test(str) || this.strict) this.raise(start, "Invalid number")
|
2907
|
-
else val = parseInt(str, 8)
|
2896
|
+
next = this.input.charCodeAt(++this.pos);
|
2897
|
+
if (next === 43 || next === 45) ++this.pos; // '+-'
|
2898
|
+
if (this.readInt(10) === null) this.raise(start, "Invalid number");
|
2899
|
+
isFloat = true;
|
2900
|
+
}
|
2901
|
+
if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number");
|
2902
|
+
|
2903
|
+
var str = this.input.slice(start, this.pos), val;
|
2904
|
+
if (isFloat) val = parseFloat(str);
|
2905
|
+
else if (!octal || str.length === 1) val = parseInt(str, 10);
|
2906
|
+
else if (/[89]/.test(str) || this.strict) this.raise(start, "Invalid number");
|
2907
|
+
else val = parseInt(str, 8);
|
2908
2908
|
return this.finishToken(tt.num, val)
|
2909
|
-
}
|
2909
|
+
};
|
2910
2910
|
|
2911
2911
|
// Read a string value, interpreting backslash-escapes.
|
2912
2912
|
|
2913
2913
|
pp$7.readCodePoint = function() {
|
2914
|
-
var ch = this.input.charCodeAt(this.pos), code
|
2914
|
+
var ch = this.input.charCodeAt(this.pos), code;
|
2915
2915
|
|
2916
2916
|
if (ch === 123) {
|
2917
|
-
if (this.options.ecmaVersion < 6) this.unexpected()
|
2918
|
-
var codePos = ++this.pos
|
2919
|
-
code = this.readHexChar(this.input.indexOf('}', this.pos) - this.pos)
|
2920
|
-
++this.pos
|
2921
|
-
if (code > 0x10FFFF) this.raise(codePos, "Code point out of bounds")
|
2917
|
+
if (this.options.ecmaVersion < 6) this.unexpected();
|
2918
|
+
var codePos = ++this.pos;
|
2919
|
+
code = this.readHexChar(this.input.indexOf('}', this.pos) - this.pos);
|
2920
|
+
++this.pos;
|
2921
|
+
if (code > 0x10FFFF) this.raise(codePos, "Code point out of bounds");
|
2922
2922
|
} else {
|
2923
|
-
code = this.readHexChar(4)
|
2923
|
+
code = this.readHexChar(4);
|
2924
2924
|
}
|
2925
2925
|
return code
|
2926
|
-
}
|
2926
|
+
};
|
2927
2927
|
|
2928
2928
|
function codePointToString(code) {
|
2929
2929
|
// UTF-16 Decoding
|
2930
2930
|
if (code <= 0xFFFF) return String.fromCharCode(code)
|
2931
|
-
code -= 0x10000
|
2931
|
+
code -= 0x10000;
|
2932
2932
|
return String.fromCharCode((code >> 10) + 0xD800, (code & 1023) + 0xDC00)
|
2933
2933
|
}
|
2934
2934
|
|
2935
2935
|
pp$7.readString = function(quote) {
|
2936
2936
|
var this$1 = this;
|
2937
2937
|
|
2938
|
-
var out = "", chunkStart = ++this.pos
|
2938
|
+
var out = "", chunkStart = ++this.pos;
|
2939
2939
|
for (;;) {
|
2940
|
-
if (this$1.pos >= this$1.input.length) this$1.raise(this$1.start, "Unterminated string constant")
|
2941
|
-
var ch = this$1.input.charCodeAt(this$1.pos)
|
2940
|
+
if (this$1.pos >= this$1.input.length) this$1.raise(this$1.start, "Unterminated string constant");
|
2941
|
+
var ch = this$1.input.charCodeAt(this$1.pos);
|
2942
2942
|
if (ch === quote) break
|
2943
2943
|
if (ch === 92) { // '\'
|
2944
|
-
out += this$1.input.slice(chunkStart, this$1.pos)
|
2945
|
-
out += this$1.readEscapedChar(false)
|
2946
|
-
chunkStart = this$1.pos
|
2944
|
+
out += this$1.input.slice(chunkStart, this$1.pos);
|
2945
|
+
out += this$1.readEscapedChar(false);
|
2946
|
+
chunkStart = this$1.pos;
|
2947
2947
|
} else {
|
2948
|
-
if (isNewLine(ch)) this$1.raise(this$1.start, "Unterminated string constant")
|
2949
|
-
++this$1.pos
|
2948
|
+
if (isNewLine(ch)) this$1.raise(this$1.start, "Unterminated string constant");
|
2949
|
+
++this$1.pos;
|
2950
2950
|
}
|
2951
2951
|
}
|
2952
|
-
out += this.input.slice(chunkStart, this.pos++)
|
2952
|
+
out += this.input.slice(chunkStart, this.pos++);
|
2953
2953
|
return this.finishToken(tt.string, out)
|
2954
|
-
}
|
2954
|
+
};
|
2955
2955
|
|
2956
2956
|
// Reads template string tokens.
|
2957
2957
|
|
2958
2958
|
pp$7.readTmplToken = function() {
|
2959
2959
|
var this$1 = this;
|
2960
2960
|
|
2961
|
-
var out = "", chunkStart = this.pos
|
2961
|
+
var out = "", chunkStart = this.pos;
|
2962
2962
|
for (;;) {
|
2963
|
-
if (this$1.pos >= this$1.input.length) this$1.raise(this$1.start, "Unterminated template")
|
2964
|
-
var ch = this$1.input.charCodeAt(this$1.pos)
|
2963
|
+
if (this$1.pos >= this$1.input.length) this$1.raise(this$1.start, "Unterminated template");
|
2964
|
+
var ch = this$1.input.charCodeAt(this$1.pos);
|
2965
2965
|
if (ch === 96 || ch === 36 && this$1.input.charCodeAt(this$1.pos + 1) === 123) { // '`', '${'
|
2966
2966
|
if (this$1.pos === this$1.start && this$1.type === tt.template) {
|
2967
2967
|
if (ch === 36) {
|
2968
|
-
this$1.pos += 2
|
2968
|
+
this$1.pos += 2;
|
2969
2969
|
return this$1.finishToken(tt.dollarBraceL)
|
2970
2970
|
} else {
|
2971
|
-
++this$1.pos
|
2971
|
+
++this$1.pos;
|
2972
2972
|
return this$1.finishToken(tt.backQuote)
|
2973
2973
|
}
|
2974
2974
|
}
|
2975
|
-
out += this$1.input.slice(chunkStart, this$1.pos)
|
2975
|
+
out += this$1.input.slice(chunkStart, this$1.pos);
|
2976
2976
|
return this$1.finishToken(tt.template, out)
|
2977
2977
|
}
|
2978
2978
|
if (ch === 92) { // '\'
|
2979
|
-
out += this$1.input.slice(chunkStart, this$1.pos)
|
2980
|
-
out += this$1.readEscapedChar(true)
|
2981
|
-
chunkStart = this$1.pos
|
2979
|
+
out += this$1.input.slice(chunkStart, this$1.pos);
|
2980
|
+
out += this$1.readEscapedChar(true);
|
2981
|
+
chunkStart = this$1.pos;
|
2982
2982
|
} else if (isNewLine(ch)) {
|
2983
|
-
out += this$1.input.slice(chunkStart, this$1.pos)
|
2984
|
-
++this$1.pos
|
2983
|
+
out += this$1.input.slice(chunkStart, this$1.pos);
|
2984
|
+
++this$1.pos;
|
2985
2985
|
switch (ch) {
|
2986
2986
|
case 13:
|
2987
|
-
if (this$1.input.charCodeAt(this$1.pos) === 10) ++this$1.pos
|
2987
|
+
if (this$1.input.charCodeAt(this$1.pos) === 10) ++this$1.pos;
|
2988
2988
|
case 10:
|
2989
|
-
out += "\n"
|
2989
|
+
out += "\n";
|
2990
2990
|
break
|
2991
2991
|
default:
|
2992
|
-
out += String.fromCharCode(ch)
|
2992
|
+
out += String.fromCharCode(ch);
|
2993
2993
|
break
|
2994
2994
|
}
|
2995
2995
|
if (this$1.options.locations) {
|
2996
|
-
++this$1.curLine
|
2997
|
-
this$1.lineStart = this$1.pos
|
2996
|
+
++this$1.curLine;
|
2997
|
+
this$1.lineStart = this$1.pos;
|
2998
2998
|
}
|
2999
|
-
chunkStart = this$1.pos
|
2999
|
+
chunkStart = this$1.pos;
|
3000
3000
|
} else {
|
3001
|
-
++this$1.pos
|
3001
|
+
++this$1.pos;
|
3002
3002
|
}
|
3003
3003
|
}
|
3004
|
-
}
|
3004
|
+
};
|
3005
3005
|
|
3006
3006
|
// Used to read escaped characters
|
3007
3007
|
|
3008
3008
|
pp$7.readEscapedChar = function(inTemplate) {
|
3009
|
-
var ch = this.input.charCodeAt(++this.pos)
|
3010
|
-
++this.pos
|
3009
|
+
var ch = this.input.charCodeAt(++this.pos);
|
3010
|
+
++this.pos;
|
3011
3011
|
switch (ch) {
|
3012
3012
|
case 110: return "\n" // 'n' -> '\n'
|
3013
3013
|
case 114: return "\r" // 'r' -> '\r'
|
@@ -3017,36 +3017,36 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
3017
3017
|
case 98: return "\b" // 'b' -> '\b'
|
3018
3018
|
case 118: return "\u000b" // 'v' -> '\u000b'
|
3019
3019
|
case 102: return "\f" // 'f' -> '\f'
|
3020
|
-
case 13: if (this.input.charCodeAt(this.pos) === 10) ++this.pos // '\r\n'
|
3020
|
+
case 13: if (this.input.charCodeAt(this.pos) === 10) ++this.pos; // '\r\n'
|
3021
3021
|
case 10: // ' \n'
|
3022
|
-
if (this.options.locations) { this.lineStart = this.pos; ++this.curLine }
|
3022
|
+
if (this.options.locations) { this.lineStart = this.pos; ++this.curLine; }
|
3023
3023
|
return ""
|
3024
3024
|
default:
|
3025
3025
|
if (ch >= 48 && ch <= 55) {
|
3026
|
-
var octalStr = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0]
|
3027
|
-
var octal = parseInt(octalStr, 8)
|
3026
|
+
var octalStr = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0];
|
3027
|
+
var octal = parseInt(octalStr, 8);
|
3028
3028
|
if (octal > 255) {
|
3029
|
-
octalStr = octalStr.slice(0, -1)
|
3030
|
-
octal = parseInt(octalStr, 8)
|
3029
|
+
octalStr = octalStr.slice(0, -1);
|
3030
|
+
octal = parseInt(octalStr, 8);
|
3031
3031
|
}
|
3032
3032
|
if (octalStr !== "0" && (this.strict || inTemplate)) {
|
3033
|
-
this.raise(this.pos - 2, "Octal literal in strict mode")
|
3033
|
+
this.raise(this.pos - 2, "Octal literal in strict mode");
|
3034
3034
|
}
|
3035
|
-
this.pos += octalStr.length - 1
|
3035
|
+
this.pos += octalStr.length - 1;
|
3036
3036
|
return String.fromCharCode(octal)
|
3037
3037
|
}
|
3038
3038
|
return String.fromCharCode(ch)
|
3039
3039
|
}
|
3040
|
-
}
|
3040
|
+
};
|
3041
3041
|
|
3042
3042
|
// Used to read character escape sequences ('\x', '\u', '\U').
|
3043
3043
|
|
3044
3044
|
pp$7.readHexChar = function(len) {
|
3045
|
-
var codePos = this.pos
|
3046
|
-
var n = this.readInt(16, len)
|
3047
|
-
if (n === null) this.raise(codePos, "Bad character escape sequence")
|
3045
|
+
var codePos = this.pos;
|
3046
|
+
var n = this.readInt(16, len);
|
3047
|
+
if (n === null) this.raise(codePos, "Bad character escape sequence");
|
3048
3048
|
return n
|
3049
|
-
}
|
3049
|
+
};
|
3050
3050
|
|
3051
3051
|
// Read an identifier, and return it as a string. Sets `this.containsEsc`
|
3052
3052
|
// to whether the word contained a '\u' escape.
|
@@ -3057,45 +3057,45 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
3057
3057
|
pp$7.readWord1 = function() {
|
3058
3058
|
var this$1 = this;
|
3059
3059
|
|
3060
|
-
this.containsEsc = false
|
3061
|
-
var word = "", first = true, chunkStart = this.pos
|
3062
|
-
var astral = this.options.ecmaVersion >= 6
|
3060
|
+
this.containsEsc = false;
|
3061
|
+
var word = "", first = true, chunkStart = this.pos;
|
3062
|
+
var astral = this.options.ecmaVersion >= 6;
|
3063
3063
|
while (this.pos < this.input.length) {
|
3064
|
-
var ch = this$1.fullCharCodeAtPos()
|
3064
|
+
var ch = this$1.fullCharCodeAtPos();
|
3065
3065
|
if (isIdentifierChar(ch, astral)) {
|
3066
|
-
this$1.pos += ch <= 0xffff ? 1 : 2
|
3066
|
+
this$1.pos += ch <= 0xffff ? 1 : 2;
|
3067
3067
|
} else if (ch === 92) { // "\"
|
3068
|
-
this$1.containsEsc = true
|
3069
|
-
word += this$1.input.slice(chunkStart, this$1.pos)
|
3070
|
-
var escStart = this$1.pos
|
3068
|
+
this$1.containsEsc = true;
|
3069
|
+
word += this$1.input.slice(chunkStart, this$1.pos);
|
3070
|
+
var escStart = this$1.pos;
|
3071
3071
|
if (this$1.input.charCodeAt(++this$1.pos) != 117) // "u"
|
3072
|
-
this$1.raise(this$1.pos, "Expecting Unicode escape sequence \\uXXXX")
|
3073
|
-
++this$1.pos
|
3074
|
-
var esc = this$1.readCodePoint()
|
3072
|
+
this$1.raise(this$1.pos, "Expecting Unicode escape sequence \\uXXXX");
|
3073
|
+
++this$1.pos;
|
3074
|
+
var esc = this$1.readCodePoint();
|
3075
3075
|
if (!(first ? isIdentifierStart : isIdentifierChar)(esc, astral))
|
3076
|
-
this$1.raise(escStart, "Invalid Unicode escape")
|
3077
|
-
word += codePointToString(esc)
|
3078
|
-
chunkStart = this$1.pos
|
3076
|
+
this$1.raise(escStart, "Invalid Unicode escape");
|
3077
|
+
word += codePointToString(esc);
|
3078
|
+
chunkStart = this$1.pos;
|
3079
3079
|
} else {
|
3080
3080
|
break
|
3081
3081
|
}
|
3082
|
-
first = false
|
3082
|
+
first = false;
|
3083
3083
|
}
|
3084
3084
|
return word + this.input.slice(chunkStart, this.pos)
|
3085
|
-
}
|
3085
|
+
};
|
3086
3086
|
|
3087
3087
|
// Read an identifier or keyword token. Will check for reserved
|
3088
3088
|
// words when necessary.
|
3089
3089
|
|
3090
3090
|
pp$7.readWord = function() {
|
3091
|
-
var word = this.readWord1()
|
3092
|
-
var type = tt.name
|
3091
|
+
var word = this.readWord1();
|
3092
|
+
var type = tt.name;
|
3093
3093
|
if ((this.options.ecmaVersion >= 6 || !this.containsEsc) && this.keywords.test(word))
|
3094
|
-
type = keywordTypes[word]
|
3094
|
+
type = keywordTypes[word];
|
3095
3095
|
return this.finishToken(type, word)
|
3096
|
-
}
|
3096
|
+
};
|
3097
3097
|
|
3098
|
-
var version = "3.3.0"
|
3098
|
+
var version = "3.3.0";
|
3099
3099
|
|
3100
3100
|
// The main exported interface (under `self.acorn` when in the
|
3101
3101
|
// browser) is a `parse` function that takes a code string and
|
@@ -3113,8 +3113,8 @@ var acorn = __commonjs(function (module, exports, global) {
|
|
3113
3113
|
// that embed JavaScript expressions.
|
3114
3114
|
|
3115
3115
|
function parseExpressionAt(input, pos, options) {
|
3116
|
-
var p = new Parser(options, input, pos)
|
3117
|
-
p.nextToken()
|
3116
|
+
var p = new Parser(options, input, pos);
|
3117
|
+
p.nextToken();
|
3118
3118
|
return p.parseExpression()
|
3119
3119
|
}
|
3120
3120
|
|
@@ -3863,38 +3863,38 @@ module.exports = function(acorn) {
|
|
3863
3863
|
function parseObj(isPattern, refDestructuringErrors) {
|
3864
3864
|
var this$1 = this;
|
3865
3865
|
|
3866
|
-
var node = this.startNode(), first = true, propHash = {}
|
3867
|
-
node.properties = []
|
3868
|
-
this.next()
|
3866
|
+
var node = this.startNode(), first = true, propHash = {};
|
3867
|
+
node.properties = [];
|
3868
|
+
this.next();
|
3869
3869
|
while (!this$1.eat(tt.braceR)) {
|
3870
3870
|
if (!first) {
|
3871
|
-
this$1.expect(tt.comma)
|
3871
|
+
this$1.expect(tt.comma);
|
3872
3872
|
if (this$1.afterTrailingComma(tt.braceR)) break
|
3873
|
-
} else first = false
|
3873
|
+
} else first = false;
|
3874
3874
|
|
3875
|
-
var prop = this$1.startNode(), isGenerator, startPos, startLoc
|
3875
|
+
var prop = this$1.startNode(), isGenerator, startPos, startLoc;
|
3876
3876
|
if (this$1.options.ecmaVersion >= 6) {
|
3877
3877
|
// ...the spread logic borrowed from babylon :)
|
3878
3878
|
if (this$1.type === tt.ellipsis) {
|
3879
|
-
prop = this$1.parseSpread()
|
3880
|
-
prop.type = isPattern ? "RestProperty" : "SpreadProperty"
|
3881
|
-
node.properties.push(prop)
|
3879
|
+
prop = this$1.parseSpread();
|
3880
|
+
prop.type = isPattern ? "RestProperty" : "SpreadProperty";
|
3881
|
+
node.properties.push(prop);
|
3882
3882
|
continue
|
3883
3883
|
}
|
3884
3884
|
|
3885
|
-
prop.method = false
|
3886
|
-
prop.shorthand = false
|
3885
|
+
prop.method = false;
|
3886
|
+
prop.shorthand = false;
|
3887
3887
|
if (isPattern || refDestructuringErrors) {
|
3888
|
-
startPos = this$1.start
|
3889
|
-
startLoc = this$1.startLoc
|
3888
|
+
startPos = this$1.start;
|
3889
|
+
startLoc = this$1.startLoc;
|
3890
3890
|
}
|
3891
3891
|
if (!isPattern)
|
3892
|
-
isGenerator = this$1.eat(tt.star)
|
3892
|
+
isGenerator = this$1.eat(tt.star);
|
3893
3893
|
}
|
3894
|
-
this$1.parsePropertyName(prop)
|
3895
|
-
this$1.parsePropertyValue(prop, isPattern, isGenerator, startPos, startLoc, refDestructuringErrors)
|
3896
|
-
this$1.checkPropClash(prop, propHash)
|
3897
|
-
node.properties.push(this$1.finishNode(prop, "Property"))
|
3894
|
+
this$1.parsePropertyName(prop);
|
3895
|
+
this$1.parsePropertyValue(prop, isPattern, isGenerator, startPos, startLoc, refDestructuringErrors);
|
3896
|
+
this$1.checkPropClash(prop, propHash);
|
3897
|
+
node.properties.push(this$1.finishNode(prop, "Property"));
|
3898
3898
|
}
|
3899
3899
|
return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression")
|
3900
3900
|
}
|
@@ -5323,6 +5323,14 @@ var ArrayExpression = (function (Node$$1) {
|
|
5323
5323
|
|
5324
5324
|
ArrayExpression.prototype.transpile = function transpile ( code, transforms ) {
|
5325
5325
|
if ( transforms.spreadRest ) {
|
5326
|
+
// erase trailing comma after last array element if not an array hole
|
5327
|
+
if ( this.elements.length ) {
|
5328
|
+
var lastElement = this.elements[ this.elements.length - 1 ];
|
5329
|
+
if ( lastElement && /\s*,/.test( code.original.slice( lastElement.end, this.end ) ) ) {
|
5330
|
+
code.overwrite( lastElement.end, this.end - 1, ' ' );
|
5331
|
+
}
|
5332
|
+
}
|
5333
|
+
|
5326
5334
|
if ( this.elements.length === 1 ) {
|
5327
5335
|
var element = this.elements[0];
|
5328
5336
|
|
@@ -5336,7 +5344,6 @@ var ArrayExpression = (function (Node$$1) {
|
|
5336
5344
|
}
|
5337
5345
|
}
|
5338
5346
|
}
|
5339
|
-
|
5340
5347
|
else {
|
5341
5348
|
var hasSpreadElements = spread( code, this.elements, this.start, this.argumentsArrayAlias );
|
5342
5349
|
|
@@ -5981,7 +5988,10 @@ var ClassBody = (function (Node$$1) {
|
|
5981
5988
|
return;
|
5982
5989
|
}
|
5983
5990
|
|
5984
|
-
if ( method.static )
|
5991
|
+
if ( method.static ) {
|
5992
|
+
var len = code.original[ method.start + 6 ] == ' ' ? 7 : 6;
|
5993
|
+
code.remove( method.start, method.start + len );
|
5994
|
+
}
|
5985
5995
|
|
5986
5996
|
var isAccessor = method.kind !== 'method';
|
5987
5997
|
var lhs;
|
@@ -5989,6 +5999,14 @@ var ClassBody = (function (Node$$1) {
|
|
5989
5999
|
var methodName = method.key.name;
|
5990
6000
|
if ( scope.contains( methodName ) || reserved[ methodName ] ) methodName = scope.createIdentifier( methodName );
|
5991
6001
|
|
6002
|
+
// when method name is a string or a number let's pretend it's a computed method
|
6003
|
+
|
6004
|
+
var fake_computed = false;
|
6005
|
+
if ( ! method.computed && method.key.type === 'Literal' ) {
|
6006
|
+
fake_computed = true;
|
6007
|
+
method.computed = true;
|
6008
|
+
}
|
6009
|
+
|
5992
6010
|
if ( isAccessor ) {
|
5993
6011
|
if ( method.computed ) {
|
5994
6012
|
throw new Error( 'Computed accessor properties are not currently supported' );
|
@@ -6022,8 +6040,13 @@ var ClassBody = (function (Node$$1) {
|
|
6022
6040
|
|
6023
6041
|
var c = method.key.end;
|
6024
6042
|
if ( method.computed ) {
|
6025
|
-
|
6026
|
-
|
6043
|
+
if ( fake_computed ) {
|
6044
|
+
code.insertRight( method.key.start, '[' );
|
6045
|
+
code.insertLeft( method.key.end, ']' );
|
6046
|
+
} else {
|
6047
|
+
while ( code.original[c] !== ']' ) c += 1;
|
6048
|
+
c += 1;
|
6049
|
+
}
|
6027
6050
|
}
|
6028
6051
|
|
6029
6052
|
code.insertRight( method.start, lhs );
|
@@ -7065,8 +7088,12 @@ var JSXElement = (function (Node$$1) {
|
|
7065
7088
|
for ( i = 0; i < children.length; i += 1 ) {
|
7066
7089
|
var child = children[i];
|
7067
7090
|
|
7068
|
-
|
7069
|
-
|
7091
|
+
if ( child.type === 'JSXExpressionContainer' && child.expression.type === 'JSXEmptyExpression' ) {
|
7092
|
+
// empty block is a no op
|
7093
|
+
} else {
|
7094
|
+
var tail = code.original[ c ] === '\n' && child.type !== 'Literal' ? '' : ' ';
|
7095
|
+
code.insertLeft( c, ("," + tail) );
|
7096
|
+
}
|
7070
7097
|
|
7071
7098
|
if ( child.type === 'Literal' ) {
|
7072
7099
|
var str = normalise( child.value, i === children.length - 1 );
|
@@ -10075,7 +10102,7 @@ var regjsgen = __commonjs(function (module, exports, global) {
|
|
10075
10102
|
case null:
|
10076
10103
|
switch (min) {
|
10077
10104
|
case 0:
|
10078
|
-
quantifier = '*'
|
10105
|
+
quantifier = '*';
|
10079
10106
|
break;
|
10080
10107
|
case 1:
|
10081
10108
|
quantifier = '+';
|
@@ -10625,8 +10652,6 @@ var ObjectExpression = (function (Node$$1) {
|
|
10625
10652
|
if ( prop$2.method && transforms.conciseMethodProperty ) {
|
10626
10653
|
code.insertRight( prop$2.value.start, 'function ' );
|
10627
10654
|
}
|
10628
|
-
|
10629
|
-
deindent( prop$2.value, code );
|
10630
10655
|
}
|
10631
10656
|
}
|
10632
10657
|
|
@@ -10658,7 +10683,13 @@ var Property = (function (Node$$1) {
|
|
10658
10683
|
if ( this.shorthand ) {
|
10659
10684
|
code.insertRight( this.start, ((this.key.name) + ": ") );
|
10660
10685
|
} else if ( this.method ) {
|
10661
|
-
var name
|
10686
|
+
var name;
|
10687
|
+
if ( this.key.type === 'Literal' && typeof this.key.value === 'number' ) {
|
10688
|
+
name = "";
|
10689
|
+
} else {
|
10690
|
+
name = this.findScope( true ).createIdentifier( this.key.type === 'Identifier' ? this.key.name : this.key.value );
|
10691
|
+
}
|
10692
|
+
|
10662
10693
|
if ( this.value.generator ) code.remove( this.start, this.key.start );
|
10663
10694
|
code.insertLeft( this.key.end, (": function" + (this.value.generator ? '*' : '') + " " + name) );
|
10664
10695
|
}
|
@@ -11119,15 +11150,25 @@ var VariableDeclarator = (function (Node$$1) {
|
|
11119
11150
|
|
11120
11151
|
VariableDeclarator.prototype.transpile = function transpile ( code, transforms ) {
|
11121
11152
|
if ( !this.init && transforms.letConst && this.parent.kind !== 'var' ) {
|
11122
|
-
var inLoop = this.findNearest( /Function|^
|
11123
|
-
if ( inLoop && ! /Function/.test( inLoop.type ) ) {
|
11124
|
-
code.insertLeft( this.id.end, ' = void 0' );
|
11153
|
+
var inLoop = this.findNearest( /Function|^For(In|Of)?Statement|^(?:Do)?WhileStatement/ );
|
11154
|
+
if ( inLoop && ! /Function/.test( inLoop.type ) && ! this.isLeftDeclaratorOfLoop() ) {
|
11155
|
+
code.insertLeft( this.id.end, ' = (void 0)' );
|
11125
11156
|
}
|
11126
11157
|
}
|
11127
11158
|
|
11128
11159
|
if ( this.init ) this.init.transpile( code, transforms );
|
11129
11160
|
};
|
11130
11161
|
|
11162
|
+
VariableDeclarator.prototype.isLeftDeclaratorOfLoop = function isLeftDeclaratorOfLoop () {
|
11163
|
+
return this.parent
|
11164
|
+
&& this.parent.type === 'VariableDeclaration'
|
11165
|
+
&& this.parent.parent
|
11166
|
+
&& (this.parent.parent.type === 'ForInStatement'
|
11167
|
+
|| this.parent.parent.type === 'ForOfStatement')
|
11168
|
+
&& this.parent.parent.left
|
11169
|
+
&& this.parent.parent.left.declarations[0] === this;
|
11170
|
+
};
|
11171
|
+
|
11131
11172
|
return VariableDeclarator;
|
11132
11173
|
}(Node));
|
11133
11174
|
|
@@ -11307,6 +11348,8 @@ Scope.prototype = {
|
|
11307
11348
|
createIdentifier: function createIdentifier ( base ) {
|
11308
11349
|
var this$1 = this;
|
11309
11350
|
|
11351
|
+
if ( typeof base === 'number' ) base = base.toString();
|
11352
|
+
|
11310
11353
|
base = base
|
11311
11354
|
.replace( /\s/g, '' )
|
11312
11355
|
.replace( /\[([^\]]+)\]/g, '_$1' )
|
@@ -11790,7 +11833,7 @@ var features = [
|
|
11790
11833
|
'reservedProperties'
|
11791
11834
|
];
|
11792
11835
|
|
11793
|
-
var version = "0.14.
|
11836
|
+
var version = "0.14.2";
|
11794
11837
|
|
11795
11838
|
var ref = [
|
11796
11839
|
acornObjectSpread,
|