BVB Source Codes

reactide Show acorn.js Source code

Return Download reactide: download acorn.js Source code - Download reactide Source code - Type:.js
  1. (function (global, factory) {
  2.   typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  3.   typeof define === 'function' && define.amd ? define(['exports'], factory) :
  4.   (factory((global.acorn = global.acorn || {})));
  5. }(this, function (exports) { 'use strict';
  6.  
  7.   // Reserved word lists for various dialects of the language
  8.  
  9.   var reservedWords = {
  10.     3: "abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",
  11.     5: "class enum extends super const export import",
  12.     6: "enum",
  13.     7: "enum",
  14.     strict: "implements interface let package private protected public static yield",
  15.     strictBind: "eval arguments"
  16.   }
  17.  
  18.   // And the keywords
  19.  
  20.   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"
  21.  
  22.   var keywords = {
  23.     5: ecma5AndLessKeywords,
  24.     6: ecma5AndLessKeywords + " const class extends export import super"
  25.   }
  26.  
  27.   // ## Character categories
  28.  
  29.   // Big ugly regular expressions that match characters in the
  30.   // whitespace, identifier, and identifier-start categories. These
  31.   // are only applied when a character is found to actually have a
  32.   // code point above 128.
  33.   // Generated by `bin/generate-identifier-regex.js`.
  34.  
  35.   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"
  36.   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"
  37.  
  38.   var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]")
  39.   var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]")
  40.  
  41.   nonASCIIidentifierStartChars = nonASCIIidentifierChars = null
  42.  
  43.   // These are a run-length and offset encoded representation of the
  44.   // >0xffff code points that are a valid part of identifiers. The
  45.   // offset starts at 0x10000, and each pair of numbers represents an
  46.   // offset to the next range, and then a size of the range. They were
  47.   // generated by bin/generate-identifier-regex.js
  48.   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]
  49.   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]
  50.  
  51.   // This has a complexity linear to the value of the code. The
  52.   // assumption is that looking up astral identifier characters is
  53.   // rare.
  54.   function isInAstralSet(code, set) {
  55.     var pos = 0x10000
  56.     for (var i = 0; i < set.length; i += 2) {
  57.       pos += set[i]
  58.       if (pos > code) return false
  59.       pos += set[i + 1]
  60.       if (pos >= code) return true
  61.     }
  62.   }
  63.  
  64.   // Test whether a given character code starts an identifier.
  65.  
  66.   function isIdentifierStart(code, astral) {
  67.     if (code < 65) return code === 36
  68.     if (code < 91) return true
  69.     if (code < 97) return code === 95
  70.     if (code < 123) return true
  71.     if (code <= 0xffff) return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code))
  72.     if (astral === false) return false
  73.     return isInAstralSet(code, astralIdentifierStartCodes)
  74.   }
  75.  
  76.   // Test whether a given character is part of an identifier.
  77.  
  78.   function isIdentifierChar(code, astral) {
  79.     if (code < 48) return code === 36
  80.     if (code < 58) return true
  81.     if (code < 65) return false
  82.     if (code < 91) return true
  83.     if (code < 97) return code === 95
  84.     if (code < 123) return true
  85.     if (code <= 0xffff) return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code))
  86.     if (astral === false) return false
  87.     return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes)
  88.   }
  89.  
  90.   // ## Token types
  91.  
  92.   // The assignment of fine-grained, information-carrying type objects
  93.   // allows the tokenizer to store the information it has about a
  94.   // token in a way that is very cheap for the parser to look up.
  95.  
  96.   // All token type variables start with an underscore, to make them
  97.   // easy to recognize.
  98.  
  99.   // The `beforeExpr` property is used to disambiguate between regular
  100.   // expressions and divisions. It is set on all token types that can
  101.   // be followed by an expression (thus, a slash after them would be a
  102.   // regular expression).
  103.   //
  104.   // The `startsExpr` property is used to check if the token ends a
  105.   // `yield` expression. It is set on all token types that either can
  106.   // directly start an expression (like a quotation mark) or can
  107.   // continue an expression (like the body of a string).
  108.   //
  109.   // `isLoop` marks a keyword as starting a loop, which is important
  110.   // to know when parsing a label, in order to allow or disallow
  111.   // continue jumps to that label.
  112.  
  113.   var TokenType = function TokenType(label, conf) {
  114.     if ( conf === void 0 ) conf = {};
  115.  
  116.     this.label = label
  117.     this.keyword = conf.keyword
  118.     this.beforeExpr = !!conf.beforeExpr
  119.     this.startsExpr = !!conf.startsExpr
  120.     this.isLoop = !!conf.isLoop
  121.     this.isAssign = !!conf.isAssign
  122.     this.prefix = !!conf.prefix
  123.     this.postfix = !!conf.postfix
  124.     this.binop = conf.binop || null
  125.     this.updateContext = null
  126.   };
  127.  
  128.   function binop(name, prec) {
  129.     return new TokenType(name, {beforeExpr: true, binop: prec})
  130.   }
  131.   var beforeExpr = {beforeExpr: true};
  132.   var startsExpr = {startsExpr: true};
  133.   // Map keyword names to token types.
  134.  
  135.   var keywordTypes = {}
  136.  
  137.   // Succinct definitions of keyword token types
  138.   function kw(name, options) {
  139.     if ( options === void 0 ) options = {};
  140.  
  141.     options.keyword = name
  142.     return keywordTypes[name] = new TokenType(name, options)
  143.   }
  144.  
  145.   var tt = {
  146.     num: new TokenType("num", startsExpr),
  147.     regexp: new TokenType("regexp", startsExpr),
  148.     string: new TokenType("string", startsExpr),
  149.     name: new TokenType("name", startsExpr),
  150.     eof: new TokenType("eof"),
  151.  
  152.     // Punctuation token types.
  153.     bracketL: new TokenType("[", {beforeExpr: true, startsExpr: true}),
  154.     bracketR: new TokenType("]"),
  155.     braceL: new TokenType("{", {beforeExpr: true, startsExpr: true}),
  156.     braceR: new TokenType("}"),
  157.     parenL: new TokenType("(", {beforeExpr: true, startsExpr: true}),
  158.     parenR: new TokenType(")"),
  159.     comma: new TokenType(",", beforeExpr),
  160.     semi: new TokenType(";", beforeExpr),
  161.     colon: new TokenType(":", beforeExpr),
  162.     dot: new TokenType("."),
  163.     question: new TokenType("?", beforeExpr),
  164.     arrow: new TokenType("=>", beforeExpr),
  165.     template: new TokenType("template"),
  166.     ellipsis: new TokenType("...", beforeExpr),
  167.     backQuote: new TokenType("`", startsExpr),
  168.     dollarBraceL: new TokenType("${", {beforeExpr: true, startsExpr: true}),
  169.  
  170.     // Operators. These carry several kinds of properties to help the
  171.     // parser use them properly (the presence of these properties is
  172.     // what categorizes them as operators).
  173.     //
  174.     // `binop`, when present, specifies that this operator is a binary
  175.     // operator, and will refer to its precedence.
  176.     //
  177.     // `prefix` and `postfix` mark the operator as a prefix or postfix
  178.     // unary operator.
  179.     //
  180.     // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as
  181.     // binary operators with a very low precedence, that should result
  182.     // in AssignmentExpression nodes.
  183.  
  184.     eq: new TokenType("=", {beforeExpr: true, isAssign: true}),
  185.     assign: new TokenType("_=", {beforeExpr: true, isAssign: true}),
  186.     incDec: new TokenType("++/--", {prefix: true, postfix: true, startsExpr: true}),
  187.     prefix: new TokenType("prefix", {beforeExpr: true, prefix: true, startsExpr: true}),
  188.     logicalOR: binop("||", 1),
  189.     logicalAND: binop("&&", 2),
  190.     bitwiseOR: binop("|", 3),
  191.     bitwiseXOR: binop("^", 4),
  192.     bitwiseAND: binop("&", 5),
  193.     equality: binop("==/!=", 6),
  194.     relational: binop("</>", 7),
  195.     bitShift: binop("<</>>", 8),
  196.     plusMin: new TokenType("+/-", {beforeExpr: true, binop: 9, prefix: true, startsExpr: true}),
  197.     modulo: binop("%", 10),
  198.     star: binop("*", 10),
  199.     slash: binop("/", 10),
  200.     starstar: new TokenType("**", {beforeExpr: true}),
  201.  
  202.     // Keyword token types.
  203.     _break: kw("break"),
  204.     _case: kw("case", beforeExpr),
  205.     _catch: kw("catch"),
  206.     _continue: kw("continue"),
  207.     _debugger: kw("debugger"),
  208.     _default: kw("default", beforeExpr),
  209.     _do: kw("do", {isLoop: true, beforeExpr: true}),
  210.     _else: kw("else", beforeExpr),
  211.     _finally: kw("finally"),
  212.     _for: kw("for", {isLoop: true}),
  213.     _function: kw("function", startsExpr),
  214.     _if: kw("if"),
  215.     _return: kw("return", beforeExpr),
  216.     _switch: kw("switch"),
  217.     _throw: kw("throw", beforeExpr),
  218.     _try: kw("try"),
  219.     _var: kw("var"),
  220.     _const: kw("const"),
  221.     _while: kw("while", {isLoop: true}),
  222.     _with: kw("with"),
  223.     _new: kw("new", {beforeExpr: true, startsExpr: true}),
  224.     _this: kw("this", startsExpr),
  225.     _super: kw("super", startsExpr),
  226.     _class: kw("class"),
  227.     _extends: kw("extends", beforeExpr),
  228.     _export: kw("export"),
  229.     _import: kw("import"),
  230.     _null: kw("null", startsExpr),
  231.     _true: kw("true", startsExpr),
  232.     _false: kw("false", startsExpr),
  233.     _in: kw("in", {beforeExpr: true, binop: 7}),
  234.     _instanceof: kw("instanceof", {beforeExpr: true, binop: 7}),
  235.     _typeof: kw("typeof", {beforeExpr: true, prefix: true, startsExpr: true}),
  236.     _void: kw("void", {beforeExpr: true, prefix: true, startsExpr: true}),
  237.     _delete: kw("delete", {beforeExpr: true, prefix: true, startsExpr: true})
  238.   }
  239.  
  240.   // Matches a whole line break (where CRLF is considered a single
  241.   // line break). Used to count lines.
  242.  
  243.   var lineBreak = /\r\n?|\n|\u2028|\u2029/
  244.   var lineBreakG = new RegExp(lineBreak.source, "g")
  245.  
  246.   function isNewLine(code) {
  247.     return code === 10 || code === 13 || code === 0x2028 || code == 0x2029
  248.   }
  249.  
  250.   var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/
  251.  
  252.   var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g
  253.  
  254.   function isArray(obj) {
  255.     return Object.prototype.toString.call(obj) === "[object Array]"
  256.   }
  257.  
  258.   // Checks if an object has a property.
  259.  
  260.   function has(obj, propName) {
  261.     return Object.prototype.hasOwnProperty.call(obj, propName)
  262.   }
  263.  
  264.   // These are used when `options.locations` is on, for the
  265.   // `startLoc` and `endLoc` properties.
  266.  
  267.   var Position = function Position(line, col) {
  268.     this.line = line
  269.     this.column = col
  270.   };
  271.  
  272.   Position.prototype.offset = function offset (n) {
  273.     return new Position(this.line, this.column + n)
  274.   };
  275.  
  276.   var SourceLocation = function SourceLocation(p, start, end) {
  277.     this.start = start
  278.     this.end = end
  279.     if (p.sourceFile !== null) this.source = p.sourceFile
  280.   };
  281.  
  282.   // The `getLineInfo` function is mostly useful when the
  283.   // `locations` option is off (for performance reasons) and you
  284.   // want to find the line/column position for a given character
  285.   // offset. `input` should be the code string that the offset refers
  286.   // into.
  287.  
  288.   function getLineInfo(input, offset) {
  289.     for (var line = 1, cur = 0;;) {
  290.       lineBreakG.lastIndex = cur
  291.       var match = lineBreakG.exec(input)
  292.       if (match && match.index < offset) {
  293.         ++line
  294.         cur = match.index + match[0].length
  295.       } else {
  296.         return new Position(line, offset - cur)
  297.       }
  298.     }
  299.   }
  300.  
  301.   // A second optional argument can be given to further configure
  302.   // the parser process. These options are recognized:
  303.  
  304.   var defaultOptions = {
  305.     // `ecmaVersion` indicates the ECMAScript version to parse. Must
  306.     // be either 3, or 5, or 6. This influences support for strict
  307.     // mode, the set of reserved words, support for getters and
  308.     // setters and other features. The default is 6.
  309.     ecmaVersion: 6,
  310.     // Source type ("script" or "module") for different semantics
  311.     sourceType: "script",
  312.     // `onInsertedSemicolon` can be a callback that will be called
  313.     // when a semicolon is automatically inserted. It will be passed
  314.     // th position of the comma as an offset, and if `locations` is
  315.     // enabled, it is given the location as a `{line, column}` object
  316.     // as second argument.
  317.     onInsertedSemicolon: null,
  318.     // `onTrailingComma` is similar to `onInsertedSemicolon`, but for
  319.     // trailing commas.
  320.     onTrailingComma: null,
  321.     // By default, reserved words are only enforced if ecmaVersion >= 5.
  322.     // Set `allowReserved` to a boolean value to explicitly turn this on
  323.     // an off. When this option has the value "never", reserved words
  324.     // and keywords can also not be used as property names.
  325.     allowReserved: null,
  326.     // When enabled, a return at the top level is not considered an
  327.     // error.
  328.     allowReturnOutsideFunction: false,
  329.     // When enabled, import/export statements are not constrained to
  330.     // appearing at the top of the program.
  331.     allowImportExportEverywhere: false,
  332.     // When enabled, hashbang directive in the beginning of file
  333.     // is allowed and treated as a line comment.
  334.     allowHashBang: false,
  335.     // When `locations` is on, `loc` properties holding objects with
  336.     // `start` and `end` properties in `{line, column}` form (with
  337.     // line being 1-based and column 0-based) will be attached to the
  338.     // nodes.
  339.     locations: false,
  340.     // A function can be passed as `onToken` option, which will
  341.     // cause Acorn to call that function with object in the same
  342.     // format as tokens returned from `tokenizer().getToken()`. Note
  343.     // that you are not allowed to call the parser from the
  344.     // callback鈥攖hat will corrupt its internal state.
  345.     onToken: null,
  346.     // A function can be passed as `onComment` option, which will
  347.     // cause Acorn to call that function with `(block, text, start,
  348.     // end)` parameters whenever a comment is skipped. `block` is a
  349.     // boolean indicating whether this is a block (`/* */`) comment,
  350.     // `text` is the content of the comment, and `start` and `end` are
  351.     // character offsets that denote the start and end of the comment.
  352.     // When the `locations` option is on, two more parameters are
  353.     // passed, the full `{line, column}` locations of the start and
  354.     // end of the comments. Note that you are not allowed to call the
  355.     // parser from the callback鈥攖hat will corrupt its internal state.
  356.     onComment: null,
  357.     // Nodes have their start and end characters offsets recorded in
  358.     // `start` and `end` properties (directly on the node, rather than
  359.     // the `loc` object, which holds line/column data. To also add a
  360.     // [semi-standardized][range] `range` property holding a `[start,
  361.     // end]` array with the same numbers, set the `ranges` option to
  362.     // `true`.
  363.     //
  364.     // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678
  365.     ranges: false,
  366.     // It is possible to parse multiple files into a single AST by
  367.     // passing the tree produced by parsing the first file as
  368.     // `program` option in subsequent parses. This will add the
  369.     // toplevel forms of the parsed file to the `Program` (top) node
  370.     // of an existing parse tree.
  371.     program: null,
  372.     // When `locations` is on, you can pass this to record the source
  373.     // file in every node's `loc` object.
  374.     sourceFile: null,
  375.     // This value, if given, is stored in every node, whether
  376.     // `locations` is on or off.
  377.     directSourceFile: null,
  378.     // When enabled, parenthesized expressions are represented by
  379.     // (non-standard) ParenthesizedExpression nodes
  380.     preserveParens: false,
  381.     plugins: {}
  382.   }
  383.  
  384.   // Interpret and default an options object
  385.  
  386.   function getOptions(opts) {
  387.     var options = {}
  388.     for (var opt in defaultOptions)
  389.       options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt]
  390.     if (options.allowReserved == null)
  391.       options.allowReserved = options.ecmaVersion < 5
  392.  
  393.     if (isArray(options.onToken)) {
  394.       var tokens = options.onToken
  395.       options.onToken = function (token) { return tokens.push(token); }
  396.     }
  397.     if (isArray(options.onComment))
  398.       options.onComment = pushComment(options, options.onComment)
  399.  
  400.     return options
  401.   }
  402.  
  403.   function pushComment(options, array) {
  404.     return function (block, text, start, end, startLoc, endLoc) {
  405.       var comment = {
  406.         type: block ? 'Block' : 'Line',
  407.         value: text,
  408.         start: start,
  409.         end: end
  410.       }
  411.       if (options.locations)
  412.         comment.loc = new SourceLocation(this, startLoc, endLoc)
  413.       if (options.ranges)
  414.         comment.range = [start, end]
  415.       array.push(comment)
  416.     }
  417.   }
  418.  
  419.   // Registered plugins
  420.   var plugins = {}
  421.  
  422.   function keywordRegexp(words) {
  423.     return new RegExp("^(" + words.replace(/ /g, "|") + ")$")
  424.   }
  425.  
  426.   var Parser = function Parser(options, input, startPos) {
  427.     this.options = options = getOptions(options)
  428.     this.sourceFile = options.sourceFile
  429.     this.keywords = keywordRegexp(keywords[options.ecmaVersion >= 6 ? 6 : 5])
  430.     var reserved = options.allowReserved ? "" :
  431.         reservedWords[options.ecmaVersion] + (options.sourceType == "module" ? " await" : "")
  432.     this.reservedWords = keywordRegexp(reserved)
  433.     var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict
  434.     this.reservedWordsStrict = keywordRegexp(reservedStrict)
  435.     this.reservedWordsStrictBind = keywordRegexp(reservedStrict + " " + reservedWords.strictBind)
  436.     this.input = String(input)
  437.  
  438.     // Used to signal to callers of `readWord1` whether the word
  439.     // contained any escape sequences. This is needed because words with
  440.     // escape sequences must not be interpreted as keywords.
  441.     this.containsEsc = false
  442.  
  443.     // Load plugins
  444.     this.loadPlugins(options.plugins)
  445.  
  446.     // Set up token state
  447.  
  448.     // The current position of the tokenizer in the input.
  449.     if (startPos) {
  450.       this.pos = startPos
  451.       this.lineStart = Math.max(0, this.input.lastIndexOf("\n", startPos))
  452.       this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length
  453.     } else {
  454.       this.pos = this.lineStart = 0
  455.       this.curLine = 1
  456.     }
  457.  
  458.     // Properties of the current token:
  459.     // Its type
  460.     this.type = tt.eof
  461.     // For tokens that include more information than their type, the value
  462.     this.value = null
  463.     // Its start and end offset
  464.     this.start = this.end = this.pos
  465.     // And, if locations are used, the {line, column} object
  466.     // corresponding to those offsets
  467.     this.startLoc = this.endLoc = this.curPosition()
  468.  
  469.     // Position information for the previous token
  470.     this.lastTokEndLoc = this.lastTokStartLoc = null
  471.     this.lastTokStart = this.lastTokEnd = this.pos
  472.  
  473.     // The context stack is used to superficially track syntactic
  474.     // context to predict whether a regular expression is allowed in a
  475.     // given position.
  476.     this.context = this.initialContext()
  477.     this.exprAllowed = true
  478.  
  479.     // Figure out if it's a module code.
  480.     this.strict = this.inModule = options.sourceType === "module"
  481.  
  482.     // Used to signify the start of a potential arrow function
  483.     this.potentialArrowAt = -1
  484.  
  485.     // Flags to track whether we are in a function, a generator.
  486.     this.inFunction = this.inGenerator = false
  487.     // Labels in scope.
  488.     this.labels = []
  489.  
  490.     // If enabled, skip leading hashbang line.
  491.     if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === '#!')
  492.       this.skipLineComment(2)
  493.   };
  494.  
  495.   // DEPRECATED Kept for backwards compatibility until 3.0 in case a plugin uses them
  496.   Parser.prototype.isKeyword = function isKeyword (word) { return this.keywords.test(word) };
  497.   Parser.prototype.isReservedWord = function isReservedWord (word) { return this.reservedWords.test(word) };
  498.  
  499.   Parser.prototype.extend = function extend (name, f) {
  500.     this[name] = f(this[name])
  501.   };
  502.  
  503.   Parser.prototype.loadPlugins = function loadPlugins (pluginConfigs) {
  504.       var this$1 = this;
  505.  
  506.     for (var name in pluginConfigs) {
  507.       var plugin = plugins[name]
  508.       if (!plugin) throw new Error("Plugin '" + name + "' not found")
  509.       plugin(this$1, pluginConfigs[name])
  510.     }
  511.   };
  512.  
  513.   Parser.prototype.parse = function parse () {
  514.     var node = this.options.program || this.startNode()
  515.     this.nextToken()
  516.     return this.parseTopLevel(node)
  517.   };
  518.  
  519.   var pp = Parser.prototype
  520.  
  521.   // ## Parser utilities
  522.  
  523.   // Test whether a statement node is the string literal `"use strict"`.
  524.  
  525.   pp.isUseStrict = function(stmt) {
  526.     return this.options.ecmaVersion >= 5 && stmt.type === "ExpressionStatement" &&
  527.       stmt.expression.type === "Literal" &&
  528.       stmt.expression.raw.slice(1, -1) === "use strict"
  529.   }
  530.  
  531.   // Predicate that tests whether the next token is of the given
  532.   // type, and if yes, consumes it as a side effect.
  533.  
  534.   pp.eat = function(type) {
  535.     if (this.type === type) {
  536.       this.next()
  537.       return true
  538.     } else {
  539.       return false
  540.     }
  541.   }
  542.  
  543.   // Tests whether parsed token is a contextual keyword.
  544.  
  545.   pp.isContextual = function(name) {
  546.     return this.type === tt.name && this.value === name
  547.   }
  548.  
  549.   // Consumes contextual keyword if possible.
  550.  
  551.   pp.eatContextual = function(name) {
  552.     return this.value === name && this.eat(tt.name)
  553.   }
  554.  
  555.   // Asserts that following token is given contextual keyword.
  556.  
  557.   pp.expectContextual = function(name) {
  558.     if (!this.eatContextual(name)) this.unexpected()
  559.   }
  560.  
  561.   // Test whether a semicolon can be inserted at the current position.
  562.  
  563.   pp.canInsertSemicolon = function() {
  564.     return this.type === tt.eof ||
  565.       this.type === tt.braceR ||
  566.       lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
  567.   }
  568.  
  569.   pp.insertSemicolon = function() {
  570.     if (this.canInsertSemicolon()) {
  571.       if (this.options.onInsertedSemicolon)
  572.         this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc)
  573.       return true
  574.     }
  575.   }
  576.  
  577.   // Consume a semicolon, or, failing that, see if we are allowed to
  578.   // pretend that there is a semicolon at this position.
  579.  
  580.   pp.semicolon = function() {
  581.     if (!this.eat(tt.semi) && !this.insertSemicolon()) this.unexpected()
  582.   }
  583.  
  584.   pp.afterTrailingComma = function(tokType) {
  585.     if (this.type == tokType) {
  586.       if (this.options.onTrailingComma)
  587.         this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc)
  588.       this.next()
  589.       return true
  590.     }
  591.   }
  592.  
  593.   // Expect a token of a given type. If found, consume it, otherwise,
  594.   // raise an unexpected token error.
  595.  
  596.   pp.expect = function(type) {
  597.     this.eat(type) || this.unexpected()
  598.   }
  599.  
  600.   // Raise an unexpected token error.
  601.  
  602.   pp.unexpected = function(pos) {
  603.     this.raise(pos != null ? pos : this.start, "Unexpected token")
  604.   }
  605.  
  606.   var DestructuringErrors = function DestructuringErrors() {
  607.     this.shorthandAssign = 0
  608.     this.trailingComma = 0
  609.   };
  610.  
  611.   pp.checkPatternErrors = function(refDestructuringErrors, andThrow) {
  612.     var trailing = refDestructuringErrors && refDestructuringErrors.trailingComma
  613.     if (!andThrow) return !!trailing
  614.     if (trailing) this.raise(trailing, "Comma is not permitted after the rest element")
  615.   }
  616.  
  617.   pp.checkExpressionErrors = function(refDestructuringErrors, andThrow) {
  618.     var pos = refDestructuringErrors && refDestructuringErrors.shorthandAssign
  619.     if (!andThrow) return !!pos
  620.     if (pos) this.raise(pos, "Shorthand property assignments are valid only in destructuring patterns")
  621.   }
  622.  
  623.   var pp$1 = Parser.prototype
  624.  
  625.   // ### Statement parsing
  626.  
  627.   // Parse a program. Initializes the parser, reads any number of
  628.   // statements, and wraps them in a Program node.  Optionally takes a
  629.   // `program` argument.  If present, the statements will be appended
  630.   // to its body instead of creating a new node.
  631.  
  632.   pp$1.parseTopLevel = function(node) {
  633.     var this$1 = this;
  634.  
  635.     var first = true
  636.     if (!node.body) node.body = []
  637.     while (this.type !== tt.eof) {
  638.       var stmt = this$1.parseStatement(true, true)
  639.       node.body.push(stmt)
  640.       if (first) {
  641.         if (this$1.isUseStrict(stmt)) this$1.setStrict(true)
  642.         first = false
  643.       }
  644.     }
  645.     this.next()
  646.     if (this.options.ecmaVersion >= 6) {
  647.       node.sourceType = this.options.sourceType
  648.     }
  649.     return this.finishNode(node, "Program")
  650.   }
  651.  
  652.   var loopLabel = {kind: "loop"};
  653.   var switchLabel = {kind: "switch"};
  654.   pp$1.isLet = function() {
  655.     if (this.type !== tt.name || this.options.ecmaVersion < 6 || this.value != "let") return false
  656.     skipWhiteSpace.lastIndex = this.pos
  657.     var skip = skipWhiteSpace.exec(this.input)
  658.     var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next)
  659.     if (nextCh === 91 || nextCh == 123) return true // '{' and '['
  660.     if (isIdentifierStart(nextCh, true)) {
  661.       for (var pos = next + 1; isIdentifierChar(this.input.charCodeAt(pos), true); ++pos) {}
  662.       var ident = this.input.slice(next, pos)
  663.       if (!this.isKeyword(ident)) return true
  664.     }
  665.     return false
  666.   }
  667.  
  668.   // Parse a single statement.
  669.   //
  670.   // If expecting a statement and finding a slash operator, parse a
  671.   // regular expression literal. This is to handle cases like
  672.   // `if (foo) /blah/.exec(foo)`, where looking at the previous token
  673.   // does not help.
  674.  
  675.   pp$1.parseStatement = function(declaration, topLevel) {
  676.     var starttype = this.type, node = this.startNode(), kind
  677.  
  678.     if (this.isLet()) {
  679.       starttype = tt._var
  680.       kind = "let"
  681.     }
  682.  
  683.     // Most types of statements are recognized by the keyword they
  684.     // start with. Many are trivial to parse, some require a bit of
  685.     // complexity.
  686.  
  687.     switch (starttype) {
  688.     case tt._break: case tt._continue: return this.parseBreakContinueStatement(node, starttype.keyword)
  689.     case tt._debugger: return this.parseDebuggerStatement(node)
  690.     case tt._do: return this.parseDoStatement(node)
  691.     case tt._for: return this.parseForStatement(node)
  692.     case tt._function:
  693.       if (!declaration && this.options.ecmaVersion >= 6) this.unexpected()
  694.       return this.parseFunctionStatement(node)
  695.     case tt._class:
  696.       if (!declaration) this.unexpected()
  697.       return this.parseClass(node, true)
  698.     case tt._if: return this.parseIfStatement(node)
  699.     case tt._return: return this.parseReturnStatement(node)
  700.     case tt._switch: return this.parseSwitchStatement(node)
  701.     case tt._throw: return this.parseThrowStatement(node)
  702.     case tt._try: return this.parseTryStatement(node)
  703.     case tt._const: case tt._var:
  704.       kind = kind || this.value
  705.       if (!declaration && kind != "var") this.unexpected()
  706.       return this.parseVarStatement(node, kind)
  707.     case tt._while: return this.parseWhileStatement(node)
  708.     case tt._with: return this.parseWithStatement(node)
  709.     case tt.braceL: return this.parseBlock()
  710.     case tt.semi: return this.parseEmptyStatement(node)
  711.     case tt._export:
  712.     case tt._import:
  713.       if (!this.options.allowImportExportEverywhere) {
  714.         if (!topLevel)
  715.           this.raise(this.start, "'import' and 'export' may only appear at the top level")
  716.         if (!this.inModule)
  717.           this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'")
  718.       }
  719.       return starttype === tt._import ? this.parseImport(node) : this.parseExport(node)
  720.  
  721.       // If the statement does not start with a statement keyword or a
  722.       // brace, it's an ExpressionStatement or LabeledStatement. We
  723.       // simply start parsing an expression, and afterwards, if the
  724.       // next token is a colon and the expression was a simple
  725.       // Identifier node, we switch to interpreting it as a label.
  726.     default:
  727.       var maybeName = this.value, expr = this.parseExpression()
  728.       if (starttype === tt.name && expr.type === "Identifier" && this.eat(tt.colon))
  729.         return this.parseLabeledStatement(node, maybeName, expr)
  730.       else return this.parseExpressionStatement(node, expr)
  731.     }
  732.   }
  733.  
  734.   pp$1.parseBreakContinueStatement = function(node, keyword) {
  735.     var this$1 = this;
  736.  
  737.     var isBreak = keyword == "break"
  738.     this.next()
  739.     if (this.eat(tt.semi) || this.insertSemicolon()) node.label = null
  740.     else if (this.type !== tt.name) this.unexpected()
  741.     else {
  742.       node.label = this.parseIdent()
  743.       this.semicolon()
  744.     }
  745.  
  746.     // Verify that there is an actual destination to break or
  747.     // continue to.
  748.     for (var i = 0; i < this.labels.length; ++i) {
  749.       var lab = this$1.labels[i]
  750.       if (node.label == null || lab.name === node.label.name) {
  751.         if (lab.kind != null && (isBreak || lab.kind === "loop")) break
  752.         if (node.label && isBreak) break
  753.       }
  754.     }
  755.     if (i === this.labels.length) this.raise(node.start, "Unsyntactic " + keyword)
  756.     return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement")
  757.   }
  758.  
  759.   pp$1.parseDebuggerStatement = function(node) {
  760.     this.next()
  761.     this.semicolon()
  762.     return this.finishNode(node, "DebuggerStatement")
  763.   }
  764.  
  765.   pp$1.parseDoStatement = function(node) {
  766.     this.next()
  767.     this.labels.push(loopLabel)
  768.     node.body = this.parseStatement(false)
  769.     this.labels.pop()
  770.     this.expect(tt._while)
  771.     node.test = this.parseParenExpression()
  772.     if (this.options.ecmaVersion >= 6)
  773.       this.eat(tt.semi)
  774.     else
  775.       this.semicolon()
  776.     return this.finishNode(node, "DoWhileStatement")
  777.   }
  778.  
  779.   // Disambiguating between a `for` and a `for`/`in` or `for`/`of`
  780.   // loop is non-trivial. Basically, we have to parse the init `var`
  781.   // statement or expression, disallowing the `in` operator (see
  782.   // the second parameter to `parseExpression`), and then check
  783.   // whether the next token is `in` or `of`. When there is no init
  784.   // part (semicolon immediately after the opening parenthesis), it
  785.   // is a regular `for` loop.
  786.  
  787.   pp$1.parseForStatement = function(node) {
  788.     this.next()
  789.     this.labels.push(loopLabel)
  790.     this.expect(tt.parenL)
  791.     if (this.type === tt.semi) return this.parseFor(node, null)
  792.     var isLet = this.isLet()
  793.     if (this.type === tt._var || this.type === tt._const || isLet) {
  794.       var init$1 = this.startNode(), kind = isLet ? "let" : this.value
  795.       this.next()
  796.       this.parseVar(init$1, true, kind)
  797.       this.finishNode(init$1, "VariableDeclaration")
  798.       if ((this.type === tt._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1 &&
  799.           !(kind !== "var" && init$1.declarations[0].init))
  800.         return this.parseForIn(node, init$1)
  801.       return this.parseFor(node, init$1)
  802.     }
  803.     var refDestructuringErrors = new DestructuringErrors
  804.     var init = this.parseExpression(true, refDestructuringErrors)
  805.     if (this.type === tt._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
  806.       this.checkPatternErrors(refDestructuringErrors, true)
  807.       this.toAssignable(init)
  808.       this.checkLVal(init)
  809.       return this.parseForIn(node, init)
  810.     } else {
  811.       this.checkExpressionErrors(refDestructuringErrors, true)
  812.     }
  813.     return this.parseFor(node, init)
  814.   }
  815.  
  816.   pp$1.parseFunctionStatement = function(node) {
  817.     this.next()
  818.     return this.parseFunction(node, true)
  819.   }
  820.  
  821.   pp$1.parseIfStatement = function(node) {
  822.     this.next()
  823.     node.test = this.parseParenExpression()
  824.     node.consequent = this.parseStatement(false)
  825.     node.alternate = this.eat(tt._else) ? this.parseStatement(false) : null
  826.     return this.finishNode(node, "IfStatement")
  827.   }
  828.  
  829.   pp$1.parseReturnStatement = function(node) {
  830.     if (!this.inFunction && !this.options.allowReturnOutsideFunction)
  831.       this.raise(this.start, "'return' outside of function")
  832.     this.next()
  833.  
  834.     // In `return` (and `break`/`continue`), the keywords with
  835.     // optional arguments, we eagerly look for a semicolon or the
  836.     // possibility to insert one.
  837.  
  838.     if (this.eat(tt.semi) || this.insertSemicolon()) node.argument = null
  839.     else { node.argument = this.parseExpression(); this.semicolon() }
  840.     return this.finishNode(node, "ReturnStatement")
  841.   }
  842.  
  843.   pp$1.parseSwitchStatement = function(node) {
  844.     var this$1 = this;
  845.  
  846.     this.next()
  847.     node.discriminant = this.parseParenExpression()
  848.     node.cases = []
  849.     this.expect(tt.braceL)
  850.     this.labels.push(switchLabel)
  851.  
  852.     // Statements under must be grouped (by label) in SwitchCase
  853.     // nodes. `cur` is used to keep the node that we are currently
  854.     // adding statements to.
  855.  
  856.     for (var cur, sawDefault = false; this.type != tt.braceR;) {
  857.       if (this$1.type === tt._case || this$1.type === tt._default) {
  858.         var isCase = this$1.type === tt._case
  859.         if (cur) this$1.finishNode(cur, "SwitchCase")
  860.         node.cases.push(cur = this$1.startNode())
  861.         cur.consequent = []
  862.         this$1.next()
  863.         if (isCase) {
  864.           cur.test = this$1.parseExpression()
  865.         } else {
  866.           if (sawDefault) this$1.raiseRecoverable(this$1.lastTokStart, "Multiple default clauses")
  867.           sawDefault = true
  868.           cur.test = null
  869.         }
  870.         this$1.expect(tt.colon)
  871.       } else {
  872.         if (!cur) this$1.unexpected()
  873.         cur.consequent.push(this$1.parseStatement(true))
  874.       }
  875.     }
  876.     if (cur) this.finishNode(cur, "SwitchCase")
  877.     this.next() // Closing brace
  878.     this.labels.pop()
  879.     return this.finishNode(node, "SwitchStatement")
  880.   }
  881.  
  882.   pp$1.parseThrowStatement = function(node) {
  883.     this.next()
  884.     if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start)))
  885.       this.raise(this.lastTokEnd, "Illegal newline after throw")
  886.     node.argument = this.parseExpression()
  887.     this.semicolon()
  888.     return this.finishNode(node, "ThrowStatement")
  889.   }
  890.  
  891.   // Reused empty array added for node fields that are always empty.
  892.  
  893.   var empty = []
  894.  
  895.   pp$1.parseTryStatement = function(node) {
  896.     this.next()
  897.     node.block = this.parseBlock()
  898.     node.handler = null
  899.     if (this.type === tt._catch) {
  900.       var clause = this.startNode()
  901.       this.next()
  902.       this.expect(tt.parenL)
  903.       clause.param = this.parseBindingAtom()
  904.       this.checkLVal(clause.param, true)
  905.       this.expect(tt.parenR)
  906.       clause.body = this.parseBlock()
  907.       node.handler = this.finishNode(clause, "CatchClause")
  908.     }
  909.     node.finalizer = this.eat(tt._finally) ? this.parseBlock() : null
  910.     if (!node.handler && !node.finalizer)
  911.       this.raise(node.start, "Missing catch or finally clause")
  912.     return this.finishNode(node, "TryStatement")
  913.   }
  914.  
  915.   pp$1.parseVarStatement = function(node, kind) {
  916.     this.next()
  917.     this.parseVar(node, false, kind)
  918.     this.semicolon()
  919.     return this.finishNode(node, "VariableDeclaration")
  920.   }
  921.  
  922.   pp$1.parseWhileStatement = function(node) {
  923.     this.next()
  924.     node.test = this.parseParenExpression()
  925.     this.labels.push(loopLabel)
  926.     node.body = this.parseStatement(false)
  927.     this.labels.pop()
  928.     return this.finishNode(node, "WhileStatement")
  929.   }
  930.  
  931.   pp$1.parseWithStatement = function(node) {
  932.     if (this.strict) this.raise(this.start, "'with' in strict mode")
  933.     this.next()
  934.     node.object = this.parseParenExpression()
  935.     node.body = this.parseStatement(false)
  936.     return this.finishNode(node, "WithStatement")
  937.   }
  938.  
  939.   pp$1.parseEmptyStatement = function(node) {
  940.     this.next()
  941.     return this.finishNode(node, "EmptyStatement")
  942.   }
  943.  
  944.   pp$1.parseLabeledStatement = function(node, maybeName, expr) {
  945.     var this$1 = this;
  946.  
  947.     for (var i = 0; i < this.labels.length; ++i)
  948.       if (this$1.labels[i].name === maybeName) this$1.raise(expr.start, "Label '" + maybeName + "' is already declared")
  949.     var kind = this.type.isLoop ? "loop" : this.type === tt._switch ? "switch" : null
  950.     for (var i$1 = this.labels.length - 1; i$1 >= 0; i$1--) {
  951.       var label = this$1.labels[i$1]
  952.       if (label.statementStart == node.start) {
  953.         label.statementStart = this$1.start
  954.         label.kind = kind
  955.       } else break
  956.     }
  957.     this.labels.push({name: maybeName, kind: kind, statementStart: this.start})
  958.     node.body = this.parseStatement(true)
  959.     this.labels.pop()
  960.     node.label = expr
  961.     return this.finishNode(node, "LabeledStatement")
  962.   }
  963.  
  964.   pp$1.parseExpressionStatement = function(node, expr) {
  965.     node.expression = expr
  966.     this.semicolon()
  967.     return this.finishNode(node, "ExpressionStatement")
  968.   }
  969.  
  970.   // Parse a semicolon-enclosed block of statements, handling `"use
  971.   // strict"` declarations when `allowStrict` is true (used for
  972.   // function bodies).
  973.  
  974.   pp$1.parseBlock = function(allowStrict) {
  975.     var this$1 = this;
  976.  
  977.     var node = this.startNode(), first = true, oldStrict
  978.     node.body = []
  979.     this.expect(tt.braceL)
  980.     while (!this.eat(tt.braceR)) {
  981.       var stmt = this$1.parseStatement(true)
  982.       node.body.push(stmt)
  983.       if (first && allowStrict && this$1.isUseStrict(stmt)) {
  984.         oldStrict = this$1.strict
  985.         this$1.setStrict(this$1.strict = true)
  986.       }
  987.       first = false
  988.     }
  989.     if (oldStrict === false) this.setStrict(false)
  990.     return this.finishNode(node, "BlockStatement")
  991.   }
  992.  
  993.   // Parse a regular `for` loop. The disambiguation code in
  994.   // `parseStatement` will already have parsed the init statement or
  995.   // expression.
  996.  
  997.   pp$1.parseFor = function(node, init) {
  998.     node.init = init
  999.     this.expect(tt.semi)
  1000.     node.test = this.type === tt.semi ? null : this.parseExpression()
  1001.     this.expect(tt.semi)
  1002.     node.update = this.type === tt.parenR ? null : this.parseExpression()
  1003.     this.expect(tt.parenR)
  1004.     node.body = this.parseStatement(false)
  1005.     this.labels.pop()
  1006.     return this.finishNode(node, "ForStatement")
  1007.   }
  1008.  
  1009.   // Parse a `for`/`in` and `for`/`of` loop, which are almost
  1010.   // same from parser's perspective.
  1011.  
  1012.   pp$1.parseForIn = function(node, init) {
  1013.     var type = this.type === tt._in ? "ForInStatement" : "ForOfStatement"
  1014.     this.next()
  1015.     node.left = init
  1016.     node.right = this.parseExpression()
  1017.     this.expect(tt.parenR)
  1018.     node.body = this.parseStatement(false)
  1019.     this.labels.pop()
  1020.     return this.finishNode(node, type)
  1021.   }
  1022.  
  1023.   // Parse a list of variable declarations.
  1024.  
  1025.   pp$1.parseVar = function(node, isFor, kind) {
  1026.     var this$1 = this;
  1027.  
  1028.     node.declarations = []
  1029.     node.kind = kind
  1030.     for (;;) {
  1031.       var decl = this$1.startNode()
  1032.       this$1.parseVarId(decl)
  1033.       if (this$1.eat(tt.eq)) {
  1034.         decl.init = this$1.parseMaybeAssign(isFor)
  1035.       } else if (kind === "const" && !(this$1.type === tt._in || (this$1.options.ecmaVersion >= 6 && this$1.isContextual("of")))) {
  1036.         this$1.unexpected()
  1037.       } else if (decl.id.type != "Identifier" && !(isFor && (this$1.type === tt._in || this$1.isContextual("of")))) {
  1038.         this$1.raise(this$1.lastTokEnd, "Complex binding patterns require an initialization value")
  1039.       } else {
  1040.         decl.init = null
  1041.       }
  1042.       node.declarations.push(this$1.finishNode(decl, "VariableDeclarator"))
  1043.       if (!this$1.eat(tt.comma)) break
  1044.     }
  1045.     return node
  1046.   }
  1047.  
  1048.   pp$1.parseVarId = function(decl) {
  1049.     decl.id = this.parseBindingAtom()
  1050.     this.checkLVal(decl.id, true)
  1051.   }
  1052.  
  1053.   // Parse a function declaration or literal (depending on the
  1054.   // `isStatement` parameter).
  1055.  
  1056.   pp$1.parseFunction = function(node, isStatement, allowExpressionBody) {
  1057.     this.initFunction(node)
  1058.     if (this.options.ecmaVersion >= 6)
  1059.       node.generator = this.eat(tt.star)
  1060.     var oldInGen = this.inGenerator
  1061.     this.inGenerator = node.generator
  1062.     if (isStatement || this.type === tt.name)
  1063.       node.id = this.parseIdent()
  1064.     this.parseFunctionParams(node)
  1065.     this.parseFunctionBody(node, allowExpressionBody)
  1066.     this.inGenerator = oldInGen
  1067.     return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression")
  1068.   }
  1069.  
  1070.   pp$1.parseFunctionParams = function(node) {
  1071.     this.expect(tt.parenL)
  1072.     node.params = this.parseBindingList(tt.parenR, false, false, true)
  1073.   }
  1074.  
  1075.   // Parse a class declaration or literal (depending on the
  1076.   // `isStatement` parameter).
  1077.  
  1078.   pp$1.parseClass = function(node, isStatement) {
  1079.     var this$1 = this;
  1080.  
  1081.     this.next()
  1082.     this.parseClassId(node, isStatement)
  1083.     this.parseClassSuper(node)
  1084.     var classBody = this.startNode()
  1085.     var hadConstructor = false
  1086.     classBody.body = []
  1087.     this.expect(tt.braceL)
  1088.     while (!this.eat(tt.braceR)) {
  1089.       if (this$1.eat(tt.semi)) continue
  1090.       var method = this$1.startNode()
  1091.       var isGenerator = this$1.eat(tt.star)
  1092.       var isMaybeStatic = this$1.type === tt.name && this$1.value === "static"
  1093.       this$1.parsePropertyName(method)
  1094.       method.static = isMaybeStatic && this$1.type !== tt.parenL
  1095.       if (method.static) {
  1096.         if (isGenerator) this$1.unexpected()
  1097.         isGenerator = this$1.eat(tt.star)
  1098.         this$1.parsePropertyName(method)
  1099.       }
  1100.       method.kind = "method"
  1101.       var isGetSet = false
  1102.       if (!method.computed) {
  1103.         var key = method.key;
  1104.         if (!isGenerator && key.type === "Identifier" && this$1.type !== tt.parenL && (key.name === "get" || key.name === "set")) {
  1105.           isGetSet = true
  1106.           method.kind = key.name
  1107.           key = this$1.parsePropertyName(method)
  1108.         }
  1109.         if (!method.static && (key.type === "Identifier" && key.name === "constructor" ||
  1110.             key.type === "Literal" && key.value === "constructor")) {
  1111.           if (hadConstructor) this$1.raise(key.start, "Duplicate constructor in the same class")
  1112.           if (isGetSet) this$1.raise(key.start, "Constructor can't have get/set modifier")
  1113.           if (isGenerator) this$1.raise(key.start, "Constructor can't be a generator")
  1114.           method.kind = "constructor"
  1115.           hadConstructor = true
  1116.         }
  1117.       }
  1118.       this$1.parseClassMethod(classBody, method, isGenerator)
  1119.       if (isGetSet) {
  1120.         var paramCount = method.kind === "get" ? 0 : 1
  1121.         if (method.value.params.length !== paramCount) {
  1122.           var start = method.value.start
  1123.           if (method.kind === "get")
  1124.             this$1.raiseRecoverable(start, "getter should have no params")
  1125.           else
  1126.             this$1.raiseRecoverable(start, "setter should have exactly one param")
  1127.         }
  1128.         if (method.kind === "set" && method.value.params[0].type === "RestElement")
  1129.           this$1.raise(method.value.params[0].start, "Setter cannot use rest params")
  1130.       }
  1131.     }
  1132.     node.body = this.finishNode(classBody, "ClassBody")
  1133.     return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression")
  1134.   }
  1135.  
  1136.   pp$1.parseClassMethod = function(classBody, method, isGenerator) {
  1137.     method.value = this.parseMethod(isGenerator)
  1138.     classBody.body.push(this.finishNode(method, "MethodDefinition"))
  1139.   }
  1140.  
  1141.   pp$1.parseClassId = function(node, isStatement) {
  1142.     node.id = this.type === tt.name ? this.parseIdent() : isStatement ? this.unexpected() : null
  1143.   }
  1144.  
  1145.   pp$1.parseClassSuper = function(node) {
  1146.     node.superClass = this.eat(tt._extends) ? this.parseExprSubscripts() : null
  1147.   }
  1148.  
  1149.   // Parses module export declaration.
  1150.  
  1151.   pp$1.parseExport = function(node) {
  1152.     var this$1 = this;
  1153.  
  1154.     this.next()
  1155.     // export * from '...'
  1156.     if (this.eat(tt.star)) {
  1157.       this.expectContextual("from")
  1158.       node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected()
  1159.       this.semicolon()
  1160.       return this.finishNode(node, "ExportAllDeclaration")
  1161.     }
  1162.     if (this.eat(tt._default)) { // export default ...
  1163.       var parens = this.type == tt.parenL
  1164.       var expr = this.parseMaybeAssign()
  1165.       var needsSemi = true
  1166.       if (!parens && (expr.type == "FunctionExpression" ||
  1167.                       expr.type == "ClassExpression")) {
  1168.         needsSemi = false
  1169.         if (expr.id) {
  1170.           expr.type = expr.type == "FunctionExpression"
  1171.             ? "FunctionDeclaration"
  1172.             : "ClassDeclaration"
  1173.         }
  1174.       }
  1175.       node.declaration = expr
  1176.       if (needsSemi) this.semicolon()
  1177.       return this.finishNode(node, "ExportDefaultDeclaration")
  1178.     }
  1179.     // export var|const|let|function|class ...
  1180.     if (this.shouldParseExportStatement()) {
  1181.       node.declaration = this.parseStatement(true)
  1182.       node.specifiers = []
  1183.       node.source = null
  1184.     } else { // export { x, y as z } [from '...']
  1185.       node.declaration = null
  1186.       node.specifiers = this.parseExportSpecifiers()
  1187.       if (this.eatContextual("from")) {
  1188.         node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected()
  1189.       } else {
  1190.         // check for keywords used as local names
  1191.         for (var i = 0; i < node.specifiers.length; i++) {
  1192.           if (this$1.keywords.test(node.specifiers[i].local.name) || this$1.reservedWords.test(node.specifiers[i].local.name)) {
  1193.             this$1.unexpected(node.specifiers[i].local.start)
  1194.           }
  1195.         }
  1196.  
  1197.         node.source = null
  1198.       }
  1199.       this.semicolon()
  1200.     }
  1201.     return this.finishNode(node, "ExportNamedDeclaration")
  1202.   }
  1203.  
  1204.   pp$1.shouldParseExportStatement = function() {
  1205.     return this.type.keyword || this.isLet()
  1206.   }
  1207.  
  1208.   // Parses a comma-separated list of module exports.
  1209.  
  1210.   pp$1.parseExportSpecifiers = function() {
  1211.     var this$1 = this;
  1212.  
  1213.     var nodes = [], first = true
  1214.     // export { x, y as z } [from '...']
  1215.     this.expect(tt.braceL)
  1216.     while (!this.eat(tt.braceR)) {
  1217.       if (!first) {
  1218.         this$1.expect(tt.comma)
  1219.         if (this$1.afterTrailingComma(tt.braceR)) break
  1220.       } else first = false
  1221.  
  1222.       var node = this$1.startNode()
  1223.       node.local = this$1.parseIdent(this$1.type === tt._default)
  1224.       node.exported = this$1.eatContextual("as") ? this$1.parseIdent(true) : node.local
  1225.       nodes.push(this$1.finishNode(node, "ExportSpecifier"))
  1226.     }
  1227.     return nodes
  1228.   }
  1229.  
  1230.   // Parses import declaration.
  1231.  
  1232.   pp$1.parseImport = function(node) {
  1233.     this.next()
  1234.     // import '...'
  1235.     if (this.type === tt.string) {
  1236.       node.specifiers = empty
  1237.       node.source = this.parseExprAtom()
  1238.     } else {
  1239.       node.specifiers = this.parseImportSpecifiers()
  1240.       this.expectContextual("from")
  1241.       node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected()
  1242.     }
  1243.     this.semicolon()
  1244.     return this.finishNode(node, "ImportDeclaration")
  1245.   }
  1246.  
  1247.   // Parses a comma-separated list of module imports.
  1248.  
  1249.   pp$1.parseImportSpecifiers = function() {
  1250.     var this$1 = this;
  1251.  
  1252.     var nodes = [], first = true
  1253.     if (this.type === tt.name) {
  1254.       // import defaultObj, { x, y as z } from '...'
  1255.       var node = this.startNode()
  1256.       node.local = this.parseIdent()
  1257.       this.checkLVal(node.local, true)
  1258.       nodes.push(this.finishNode(node, "ImportDefaultSpecifier"))
  1259.       if (!this.eat(tt.comma)) return nodes
  1260.     }
  1261.     if (this.type === tt.star) {
  1262.       var node$1 = this.startNode()
  1263.       this.next()
  1264.       this.expectContextual("as")
  1265.       node$1.local = this.parseIdent()
  1266.       this.checkLVal(node$1.local, true)
  1267.       nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier"))
  1268.       return nodes
  1269.     }
  1270.     this.expect(tt.braceL)
  1271.     while (!this.eat(tt.braceR)) {
  1272.       if (!first) {
  1273.         this$1.expect(tt.comma)
  1274.         if (this$1.afterTrailingComma(tt.braceR)) break
  1275.       } else first = false
  1276.  
  1277.       var node$2 = this$1.startNode()
  1278.       node$2.imported = this$1.parseIdent(true)
  1279.       if (this$1.eatContextual("as")) {
  1280.         node$2.local = this$1.parseIdent()
  1281.       } else {
  1282.         node$2.local = node$2.imported
  1283.         if (this$1.isKeyword(node$2.local.name)) this$1.unexpected(node$2.local.start)
  1284.         if (this$1.reservedWordsStrict.test(node$2.local.name)) this$1.raise(node$2.local.start, "The keyword '" + node$2.local.name + "' is reserved")
  1285.       }
  1286.       this$1.checkLVal(node$2.local, true)
  1287.       nodes.push(this$1.finishNode(node$2, "ImportSpecifier"))
  1288.     }
  1289.     return nodes
  1290.   }
  1291.  
  1292.   var pp$2 = Parser.prototype
  1293.  
  1294.   // Convert existing expression atom to assignable pattern
  1295.   // if possible.
  1296.  
  1297.   pp$2.toAssignable = function(node, isBinding) {
  1298.     var this$1 = this;
  1299.  
  1300.     if (this.options.ecmaVersion >= 6 && node) {
  1301.       switch (node.type) {
  1302.       case "Identifier":
  1303.       case "ObjectPattern":
  1304.       case "ArrayPattern":
  1305.         break
  1306.  
  1307.       case "ObjectExpression":
  1308.         node.type = "ObjectPattern"
  1309.         for (var i = 0; i < node.properties.length; i++) {
  1310.           var prop = node.properties[i]
  1311.           if (prop.kind !== "init") this$1.raise(prop.key.start, "Object pattern can't contain getter or setter")
  1312.           this$1.toAssignable(prop.value, isBinding)
  1313.         }
  1314.         break
  1315.  
  1316.       case "ArrayExpression":
  1317.         node.type = "ArrayPattern"
  1318.         this.toAssignableList(node.elements, isBinding)
  1319.         break
  1320.  
  1321.       case "AssignmentExpression":
  1322.         if (node.operator === "=") {
  1323.           node.type = "AssignmentPattern"
  1324.           delete node.operator
  1325.           // falls through to AssignmentPattern
  1326.         } else {
  1327.           this.raise(node.left.end, "Only '=' operator can be used for specifying default value.")
  1328.           break
  1329.         }
  1330.  
  1331.       case "AssignmentPattern":
  1332.         if (node.right.type === "YieldExpression")
  1333.           this.raise(node.right.start, "Yield expression cannot be a default value")
  1334.         break
  1335.  
  1336.       case "ParenthesizedExpression":
  1337.         node.expression = this.toAssignable(node.expression, isBinding)
  1338.         break
  1339.  
  1340.       case "MemberExpression":
  1341.         if (!isBinding) break
  1342.  
  1343.       default:
  1344.         this.raise(node.start, "Assigning to rvalue")
  1345.       }
  1346.     }
  1347.     return node
  1348.   }
  1349.  
  1350.   // Convert list of expression atoms to binding list.
  1351.  
  1352.   pp$2.toAssignableList = function(exprList, isBinding) {
  1353.     var this$1 = this;
  1354.  
  1355.     var end = exprList.length
  1356.     if (end) {
  1357.       var last = exprList[end - 1]
  1358.       if (last && last.type == "RestElement") {
  1359.         --end
  1360.       } else if (last && last.type == "SpreadElement") {
  1361.         last.type = "RestElement"
  1362.         var arg = last.argument
  1363.         this.toAssignable(arg, isBinding)
  1364.         if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern")
  1365.           this.unexpected(arg.start)
  1366.         --end
  1367.       }
  1368.  
  1369.       if (isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier")
  1370.         this.unexpected(last.argument.start)
  1371.     }
  1372.     for (var i = 0; i < end; i++) {
  1373.       var elt = exprList[i]
  1374.       if (elt) this$1.toAssignable(elt, isBinding)
  1375.     }
  1376.     return exprList
  1377.   }
  1378.  
  1379.   // Parses spread element.
  1380.  
  1381.   pp$2.parseSpread = function(refDestructuringErrors) {
  1382.     var node = this.startNode()
  1383.     this.next()
  1384.     node.argument = this.parseMaybeAssign(false, refDestructuringErrors)
  1385.     return this.finishNode(node, "SpreadElement")
  1386.   }
  1387.  
  1388.   pp$2.parseRest = function(allowNonIdent) {
  1389.     var node = this.startNode()
  1390.     this.next()
  1391.  
  1392.     // RestElement inside of a function parameter must be an identifier
  1393.     if (allowNonIdent) node.argument = this.type === tt.name ? this.parseIdent() : this.unexpected()
  1394.     else node.argument = this.type === tt.name || this.type === tt.bracketL ? this.parseBindingAtom() : this.unexpected()
  1395.  
  1396.     return this.finishNode(node, "RestElement")
  1397.   }
  1398.  
  1399.   // Parses lvalue (assignable) atom.
  1400.  
  1401.   pp$2.parseBindingAtom = function() {
  1402.     if (this.options.ecmaVersion < 6) return this.parseIdent()
  1403.     switch (this.type) {
  1404.     case tt.name:
  1405.       return this.parseIdent()
  1406.  
  1407.     case tt.bracketL:
  1408.       var node = this.startNode()
  1409.       this.next()
  1410.       node.elements = this.parseBindingList(tt.bracketR, true, true)
  1411.       return this.finishNode(node, "ArrayPattern")
  1412.  
  1413.     case tt.braceL:
  1414.       return this.parseObj(true)
  1415.  
  1416.     default:
  1417.       this.unexpected()
  1418.     }
  1419.   }
  1420.  
  1421.   pp$2.parseBindingList = function(close, allowEmpty, allowTrailingComma, allowNonIdent) {
  1422.     var this$1 = this;
  1423.  
  1424.     var elts = [], first = true
  1425.     while (!this.eat(close)) {
  1426.       if (first) first = false
  1427.       else this$1.expect(tt.comma)
  1428.       if (allowEmpty && this$1.type === tt.comma) {
  1429.         elts.push(null)
  1430.       } else if (allowTrailingComma && this$1.afterTrailingComma(close)) {
  1431.         break
  1432.       } else if (this$1.type === tt.ellipsis) {
  1433.         var rest = this$1.parseRest(allowNonIdent)
  1434.         this$1.parseBindingListItem(rest)
  1435.         elts.push(rest)
  1436.         if (this$1.type === tt.comma) this$1.raise(this$1.start, "Comma is not permitted after the rest element")
  1437.         this$1.expect(close)
  1438.         break
  1439.       } else {
  1440.         var elem = this$1.parseMaybeDefault(this$1.start, this$1.startLoc)
  1441.         this$1.parseBindingListItem(elem)
  1442.         elts.push(elem)
  1443.       }
  1444.     }
  1445.     return elts
  1446.   }
  1447.  
  1448.   pp$2.parseBindingListItem = function(param) {
  1449.     return param
  1450.   }
  1451.  
  1452.   // Parses assignment pattern around given atom if possible.
  1453.  
  1454.   pp$2.parseMaybeDefault = function(startPos, startLoc, left) {
  1455.     left = left || this.parseBindingAtom()
  1456.     if (this.options.ecmaVersion < 6 || !this.eat(tt.eq)) return left
  1457.     var node = this.startNodeAt(startPos, startLoc)
  1458.     node.left = left
  1459.     node.right = this.parseMaybeAssign()
  1460.     return this.finishNode(node, "AssignmentPattern")
  1461.   }
  1462.  
  1463.   // Verify that a node is an lval 鈥 something that can be assigned
  1464.   // to.
  1465.  
  1466.   pp$2.checkLVal = function(expr, isBinding, checkClashes) {
  1467.     var this$1 = this;
  1468.  
  1469.     switch (expr.type) {
  1470.     case "Identifier":
  1471.       if (this.strict && this.reservedWordsStrictBind.test(expr.name))
  1472.         this.raiseRecoverable(expr.start, (isBinding ? "Binding " : "Assigning to ") + expr.name + " in strict mode")
  1473.       if (checkClashes) {
  1474.         if (has(checkClashes, expr.name))
  1475.           this.raiseRecoverable(expr.start, "Argument name clash")
  1476.         checkClashes[expr.name] = true
  1477.       }
  1478.       break
  1479.  
  1480.     case "MemberExpression":
  1481.       if (isBinding) this.raiseRecoverable(expr.start, (isBinding ? "Binding" : "Assigning to") + " member expression")
  1482.       break
  1483.  
  1484.     case "ObjectPattern":
  1485.       for (var i = 0; i < expr.properties.length; i++)
  1486.         this$1.checkLVal(expr.properties[i].value, isBinding, checkClashes)
  1487.       break
  1488.  
  1489.     case "ArrayPattern":
  1490.       for (var i$1 = 0; i$1 < expr.elements.length; i$1++) {
  1491.         var elem = expr.elements[i$1]
  1492.         if (elem) this$1.checkLVal(elem, isBinding, checkClashes)
  1493.       }
  1494.       break
  1495.  
  1496.     case "AssignmentPattern":
  1497.       this.checkLVal(expr.left, isBinding, checkClashes)
  1498.       break
  1499.  
  1500.     case "RestElement":
  1501.       this.checkLVal(expr.argument, isBinding, checkClashes)
  1502.       break
  1503.  
  1504.     case "ParenthesizedExpression":
  1505.       this.checkLVal(expr.expression, isBinding, checkClashes)
  1506.       break
  1507.  
  1508.     default:
  1509.       this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " rvalue")
  1510.     }
  1511.   }
  1512.  
  1513.   var pp$3 = Parser.prototype
  1514.  
  1515.   // Check if property name clashes with already added.
  1516.   // Object/class getters and setters are not allowed to clash 鈥
  1517.   // either with each other or with an init property 鈥 and in
  1518.   // strict mode, init properties are also not allowed to be repeated.
  1519.  
  1520.   pp$3.checkPropClash = function(prop, propHash) {
  1521.     if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand))
  1522.       return
  1523.     var key = prop.key;
  1524.     var name
  1525.     switch (key.type) {
  1526.     case "Identifier": name = key.name; break
  1527.     case "Literal": name = String(key.value); break
  1528.     default: return
  1529.     }
  1530.     var kind = prop.kind;
  1531.     if (this.options.ecmaVersion >= 6) {
  1532.       if (name === "__proto__" && kind === "init") {
  1533.         if (propHash.proto) this.raiseRecoverable(key.start, "Redefinition of __proto__ property")
  1534.         propHash.proto = true
  1535.       }
  1536.       return
  1537.     }
  1538.     name = "$" + name
  1539.     var other = propHash[name]
  1540.     if (other) {
  1541.       var isGetSet = kind !== "init"
  1542.       if ((this.strict || isGetSet) && other[kind] || !(isGetSet ^ other.init))
  1543.         this.raiseRecoverable(key.start, "Redefinition of property")
  1544.     } else {
  1545.       other = propHash[name] = {
  1546.         init: false,
  1547.         get: false,
  1548.         set: false
  1549.       }
  1550.     }
  1551.     other[kind] = true
  1552.   }
  1553.  
  1554.   // ### Expression parsing
  1555.  
  1556.   // These nest, from the most general expression type at the top to
  1557.   // 'atomic', nondivisible expression types at the bottom. Most of
  1558.   // the functions will simply let the function(s) below them parse,
  1559.   // and, *if* the syntactic construct they handle is present, wrap
  1560.   // the AST node that the inner parser gave them in another node.
  1561.  
  1562.   // Parse a full expression. The optional arguments are used to
  1563.   // forbid the `in` operator (in for loops initalization expressions)
  1564.   // and provide reference for storing '=' operator inside shorthand
  1565.   // property assignment in contexts where both object expression
  1566.   // and object pattern might appear (so it's possible to raise
  1567.   // delayed syntax error at correct position).
  1568.  
  1569.   pp$3.parseExpression = function(noIn, refDestructuringErrors) {
  1570.     var this$1 = this;
  1571.  
  1572.     var startPos = this.start, startLoc = this.startLoc
  1573.     var expr = this.parseMaybeAssign(noIn, refDestructuringErrors)
  1574.     if (this.type === tt.comma) {
  1575.       var node = this.startNodeAt(startPos, startLoc)
  1576.       node.expressions = [expr]
  1577.       while (this.eat(tt.comma)) node.expressions.push(this$1.parseMaybeAssign(noIn, refDestructuringErrors))
  1578.       return this.finishNode(node, "SequenceExpression")
  1579.     }
  1580.     return expr
  1581.   }
  1582.  
  1583.   // Parse an assignment expression. This includes applications of
  1584.   // operators like `+=`.
  1585.  
  1586.   pp$3.parseMaybeAssign = function(noIn, refDestructuringErrors, afterLeftParse) {
  1587.     if (this.inGenerator && this.isContextual("yield")) return this.parseYield()
  1588.  
  1589.     var ownDestructuringErrors = false
  1590.     if (!refDestructuringErrors) {
  1591.       refDestructuringErrors = new DestructuringErrors
  1592.       ownDestructuringErrors = true
  1593.     }
  1594.     var startPos = this.start, startLoc = this.startLoc
  1595.     if (this.type == tt.parenL || this.type == tt.name)
  1596.       this.potentialArrowAt = this.start
  1597.     var left = this.parseMaybeConditional(noIn, refDestructuringErrors)
  1598.     if (afterLeftParse) left = afterLeftParse.call(this, left, startPos, startLoc)
  1599.     if (this.type.isAssign) {
  1600.       this.checkPatternErrors(refDestructuringErrors, true)
  1601.       if (!ownDestructuringErrors) DestructuringErrors.call(refDestructuringErrors)
  1602.       var node = this.startNodeAt(startPos, startLoc)
  1603.       node.operator = this.value
  1604.       node.left = this.type === tt.eq ? this.toAssignable(left) : left
  1605.       refDestructuringErrors.shorthandAssign = 0 // reset because shorthand default was used correctly
  1606.       this.checkLVal(left)
  1607.       this.next()
  1608.       node.right = this.parseMaybeAssign(noIn)
  1609.       return this.finishNode(node, "AssignmentExpression")
  1610.     } else {
  1611.       if (ownDestructuringErrors) this.checkExpressionErrors(refDestructuringErrors, true)
  1612.     }
  1613.     return left
  1614.   }
  1615.  
  1616.   // Parse a ternary conditional (`?:`) operator.
  1617.  
  1618.   pp$3.parseMaybeConditional = function(noIn, refDestructuringErrors) {
  1619.     var startPos = this.start, startLoc = this.startLoc
  1620.     var expr = this.parseExprOps(noIn, refDestructuringErrors)
  1621.     if (this.checkExpressionErrors(refDestructuringErrors)) return expr
  1622.     if (this.eat(tt.question)) {
  1623.       var node = this.startNodeAt(startPos, startLoc)
  1624.       node.test = expr
  1625.       node.consequent = this.parseMaybeAssign()
  1626.       this.expect(tt.colon)
  1627.       node.alternate = this.parseMaybeAssign(noIn)
  1628.       return this.finishNode(node, "ConditionalExpression")
  1629.     }
  1630.     return expr
  1631.   }
  1632.  
  1633.   // Start the precedence parser.
  1634.  
  1635.   pp$3.parseExprOps = function(noIn, refDestructuringErrors) {
  1636.     var startPos = this.start, startLoc = this.startLoc
  1637.     var expr = this.parseMaybeUnary(refDestructuringErrors, false)
  1638.     if (this.checkExpressionErrors(refDestructuringErrors)) return expr
  1639.     return this.parseExprOp(expr, startPos, startLoc, -1, noIn)
  1640.   }
  1641.  
  1642.   // Parse binary operators with the operator precedence parsing
  1643.   // algorithm. `left` is the left-hand side of the operator.
  1644.   // `minPrec` provides context that allows the function to stop and
  1645.   // defer further parser to one of its callers when it encounters an
  1646.   // operator that has a lower precedence than the set it is parsing.
  1647.  
  1648.   pp$3.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, noIn) {
  1649.     var prec = this.type.binop
  1650.     if (prec != null && (!noIn || this.type !== tt._in)) {
  1651.       if (prec > minPrec) {
  1652.         var logical = this.type === tt.logicalOR || this.type === tt.logicalAND
  1653.         var op = this.value
  1654.         this.next()
  1655.         var startPos = this.start, startLoc = this.startLoc
  1656.         var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn)
  1657.         var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical)
  1658.         return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn)
  1659.       }
  1660.     }
  1661.     return left
  1662.   }
  1663.  
  1664.   pp$3.buildBinary = function(startPos, startLoc, left, right, op, logical) {
  1665.     var node = this.startNodeAt(startPos, startLoc)
  1666.     node.left = left
  1667.     node.operator = op
  1668.     node.right = right
  1669.     return this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression")
  1670.   }
  1671.  
  1672.   // Parse unary operators, both prefix and postfix.
  1673.  
  1674.   pp$3.parseMaybeUnary = function(refDestructuringErrors, sawUnary) {
  1675.     var this$1 = this;
  1676.  
  1677.     var startPos = this.start, startLoc = this.startLoc, expr
  1678.     if (this.type.prefix) {
  1679.       var node = this.startNode(), update = this.type === tt.incDec
  1680.       node.operator = this.value
  1681.       node.prefix = true
  1682.       this.next()
  1683.       node.argument = this.parseMaybeUnary(null, true)
  1684.       this.checkExpressionErrors(refDestructuringErrors, true)
  1685.       if (update) this.checkLVal(node.argument)
  1686.       else if (this.strict && node.operator === "delete" &&
  1687.                node.argument.type === "Identifier")
  1688.         this.raiseRecoverable(node.start, "Deleting local variable in strict mode")
  1689.       else sawUnary = true
  1690.       expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression")
  1691.     } else {
  1692.       expr = this.parseExprSubscripts(refDestructuringErrors)
  1693.       if (this.checkExpressionErrors(refDestructuringErrors)) return expr
  1694.       while (this.type.postfix && !this.canInsertSemicolon()) {
  1695.         var node$1 = this$1.startNodeAt(startPos, startLoc)
  1696.         node$1.operator = this$1.value
  1697.         node$1.prefix = false
  1698.         node$1.argument = expr
  1699.         this$1.checkLVal(expr)
  1700.         this$1.next()
  1701.         expr = this$1.finishNode(node$1, "UpdateExpression")
  1702.       }
  1703.     }
  1704.  
  1705.     if (!sawUnary && this.eat(tt.starstar))
  1706.       return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false), "**", false)
  1707.     else
  1708.       return expr
  1709.   }
  1710.  
  1711.   // Parse call, dot, and `[]`-subscript expressions.
  1712.  
  1713.   pp$3.parseExprSubscripts = function(refDestructuringErrors) {
  1714.     var startPos = this.start, startLoc = this.startLoc
  1715.     var expr = this.parseExprAtom(refDestructuringErrors)
  1716.     var skipArrowSubscripts = expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")"
  1717.     if (this.checkExpressionErrors(refDestructuringErrors) || skipArrowSubscripts) return expr
  1718.     return this.parseSubscripts(expr, startPos, startLoc)
  1719.   }
  1720.  
  1721.   pp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) {
  1722.     var this$1 = this;
  1723.  
  1724.     for (;;) {
  1725.       if (this$1.eat(tt.dot)) {
  1726.         var node = this$1.startNodeAt(startPos, startLoc)
  1727.         node.object = base
  1728.         node.property = this$1.parseIdent(true)
  1729.         node.computed = false
  1730.         base = this$1.finishNode(node, "MemberExpression")
  1731.       } else if (this$1.eat(tt.bracketL)) {
  1732.         var node$1 = this$1.startNodeAt(startPos, startLoc)
  1733.         node$1.object = base
  1734.         node$1.property = this$1.parseExpression()
  1735.         node$1.computed = true
  1736.         this$1.expect(tt.bracketR)
  1737.         base = this$1.finishNode(node$1, "MemberExpression")
  1738.       } else if (!noCalls && this$1.eat(tt.parenL)) {
  1739.         var node$2 = this$1.startNodeAt(startPos, startLoc)
  1740.         node$2.callee = base
  1741.         node$2.arguments = this$1.parseExprList(tt.parenR, false)
  1742.         base = this$1.finishNode(node$2, "CallExpression")
  1743.       } else if (this$1.type === tt.backQuote) {
  1744.         var node$3 = this$1.startNodeAt(startPos, startLoc)
  1745.         node$3.tag = base
  1746.         node$3.quasi = this$1.parseTemplate()
  1747.         base = this$1.finishNode(node$3, "TaggedTemplateExpression")
  1748.       } else {
  1749.         return base
  1750.       }
  1751.     }
  1752.   }
  1753.  
  1754.   // Parse an atomic expression 鈥 either a single token that is an
  1755.   // expression, an expression started by a keyword like `function` or
  1756.   // `new`, or an expression wrapped in punctuation like `()`, `[]`,
  1757.   // or `{}`.
  1758.  
  1759.   pp$3.parseExprAtom = function(refDestructuringErrors) {
  1760.     var node, canBeArrow = this.potentialArrowAt == this.start
  1761.     switch (this.type) {
  1762.     case tt._super:
  1763.       if (!this.inFunction)
  1764.         this.raise(this.start, "'super' outside of function or class")
  1765.  
  1766.     case tt._this:
  1767.       var type = this.type === tt._this ? "ThisExpression" : "Super"
  1768.       node = this.startNode()
  1769.       this.next()
  1770.       return this.finishNode(node, type)
  1771.  
  1772.     case tt.name:
  1773.       var startPos = this.start, startLoc = this.startLoc
  1774.       var id = this.parseIdent(this.type !== tt.name)
  1775.       if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow))
  1776.         return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id])
  1777.       return id
  1778.  
  1779.     case tt.regexp:
  1780.       var value = this.value
  1781.       node = this.parseLiteral(value.value)
  1782.       node.regex = {pattern: value.pattern, flags: value.flags}
  1783.       return node
  1784.  
  1785.     case tt.num: case tt.string:
  1786.       return this.parseLiteral(this.value)
  1787.  
  1788.     case tt._null: case tt._true: case tt._false:
  1789.       node = this.startNode()
  1790.       node.value = this.type === tt._null ? null : this.type === tt._true
  1791.       node.raw = this.type.keyword
  1792.       this.next()
  1793.       return this.finishNode(node, "Literal")
  1794.  
  1795.     case tt.parenL:
  1796.       return this.parseParenAndDistinguishExpression(canBeArrow)
  1797.  
  1798.     case tt.bracketL:
  1799.       node = this.startNode()
  1800.       this.next()
  1801.       node.elements = this.parseExprList(tt.bracketR, true, true, refDestructuringErrors)
  1802.       return this.finishNode(node, "ArrayExpression")
  1803.  
  1804.     case tt.braceL:
  1805.       return this.parseObj(false, refDestructuringErrors)
  1806.  
  1807.     case tt._function:
  1808.       node = this.startNode()
  1809.       this.next()
  1810.       return this.parseFunction(node, false)
  1811.  
  1812.     case tt._class:
  1813.       return this.parseClass(this.startNode(), false)
  1814.  
  1815.     case tt._new:
  1816.       return this.parseNew()
  1817.  
  1818.     case tt.backQuote:
  1819.       return this.parseTemplate()
  1820.  
  1821.     default:
  1822.       this.unexpected()
  1823.     }
  1824.   }
  1825.  
  1826.   pp$3.parseLiteral = function(value) {
  1827.     var node = this.startNode()
  1828.     node.value = value
  1829.     node.raw = this.input.slice(this.start, this.end)
  1830.     this.next()
  1831.     return this.finishNode(node, "Literal")
  1832.   }
  1833.  
  1834.   pp$3.parseParenExpression = function() {
  1835.     this.expect(tt.parenL)
  1836.     var val = this.parseExpression()
  1837.     this.expect(tt.parenR)
  1838.     return val
  1839.   }
  1840.  
  1841.   pp$3.parseParenAndDistinguishExpression = function(canBeArrow) {
  1842.     var this$1 = this;
  1843.  
  1844.     var startPos = this.start, startLoc = this.startLoc, val
  1845.     if (this.options.ecmaVersion >= 6) {
  1846.       this.next()
  1847.  
  1848.       var innerStartPos = this.start, innerStartLoc = this.startLoc
  1849.       var exprList = [], first = true
  1850.       var refDestructuringErrors = new DestructuringErrors, spreadStart, innerParenStart
  1851.       while (this.type !== tt.parenR) {
  1852.         first ? first = false : this$1.expect(tt.comma)
  1853.         if (this$1.type === tt.ellipsis) {
  1854.           spreadStart = this$1.start
  1855.           exprList.push(this$1.parseParenItem(this$1.parseRest()))
  1856.           break
  1857.         } else {
  1858.           if (this$1.type === tt.parenL && !innerParenStart) {
  1859.             innerParenStart = this$1.start
  1860.           }
  1861.           exprList.push(this$1.parseMaybeAssign(false, refDestructuringErrors, this$1.parseParenItem))
  1862.         }
  1863.       }
  1864.       var innerEndPos = this.start, innerEndLoc = this.startLoc
  1865.       this.expect(tt.parenR)
  1866.  
  1867.       if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) {
  1868.         this.checkPatternErrors(refDestructuringErrors, true)
  1869.         if (innerParenStart) this.unexpected(innerParenStart)
  1870.         return this.parseParenArrowList(startPos, startLoc, exprList)
  1871.       }
  1872.  
  1873.       if (!exprList.length) this.unexpected(this.lastTokStart)
  1874.       if (spreadStart) this.unexpected(spreadStart)
  1875.       this.checkExpressionErrors(refDestructuringErrors, true)
  1876.  
  1877.       if (exprList.length > 1) {
  1878.         val = this.startNodeAt(innerStartPos, innerStartLoc)
  1879.         val.expressions = exprList
  1880.         this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc)
  1881.       } else {
  1882.         val = exprList[0]
  1883.       }
  1884.     } else {
  1885.       val = this.parseParenExpression()
  1886.     }
  1887.  
  1888.     if (this.options.preserveParens) {
  1889.       var par = this.startNodeAt(startPos, startLoc)
  1890.       par.expression = val
  1891.       return this.finishNode(par, "ParenthesizedExpression")
  1892.     } else {
  1893.       return val
  1894.     }
  1895.   }
  1896.  
  1897.   pp$3.parseParenItem = function(item) {
  1898.     return item
  1899.   }
  1900.  
  1901.   pp$3.parseParenArrowList = function(startPos, startLoc, exprList) {
  1902.     return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList)
  1903.   }
  1904.  
  1905.   // New's precedence is slightly tricky. It must allow its argument to
  1906.   // be a `[]` or dot subscript expression, but not a call 鈥 at least,
  1907.   // not without wrapping it in parentheses. Thus, it uses the noCalls
  1908.   // argument to parseSubscripts to prevent it from consuming the
  1909.   // argument list.
  1910.  
  1911.   var empty$1 = []
  1912.  
  1913.   pp$3.parseNew = function() {
  1914.     var node = this.startNode()
  1915.     var meta = this.parseIdent(true)
  1916.     if (this.options.ecmaVersion >= 6 && this.eat(tt.dot)) {
  1917.       node.meta = meta
  1918.       node.property = this.parseIdent(true)
  1919.       if (node.property.name !== "target")
  1920.         this.raiseRecoverable(node.property.start, "The only valid meta property for new is new.target")
  1921.       if (!this.inFunction)
  1922.         this.raiseRecoverable(node.start, "new.target can only be used in functions")
  1923.       return this.finishNode(node, "MetaProperty")
  1924.     }
  1925.     var startPos = this.start, startLoc = this.startLoc
  1926.     node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true)
  1927.     if (this.eat(tt.parenL)) node.arguments = this.parseExprList(tt.parenR, false)
  1928.     else node.arguments = empty$1
  1929.     return this.finishNode(node, "NewExpression")
  1930.   }
  1931.  
  1932.   // Parse template expression.
  1933.  
  1934.   pp$3.parseTemplateElement = function() {
  1935.     var elem = this.startNode()
  1936.     elem.value = {
  1937.       raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, '\n'),
  1938.       cooked: this.value
  1939.     }
  1940.     this.next()
  1941.     elem.tail = this.type === tt.backQuote
  1942.     return this.finishNode(elem, "TemplateElement")
  1943.   }
  1944.  
  1945.   pp$3.parseTemplate = function() {
  1946.     var this$1 = this;
  1947.  
  1948.     var node = this.startNode()
  1949.     this.next()
  1950.     node.expressions = []
  1951.     var curElt = this.parseTemplateElement()
  1952.     node.quasis = [curElt]
  1953.     while (!curElt.tail) {
  1954.       this$1.expect(tt.dollarBraceL)
  1955.       node.expressions.push(this$1.parseExpression())
  1956.       this$1.expect(tt.braceR)
  1957.       node.quasis.push(curElt = this$1.parseTemplateElement())
  1958.     }
  1959.     this.next()
  1960.     return this.finishNode(node, "TemplateLiteral")
  1961.   }
  1962.  
  1963.   // Parse an object literal or binding pattern.
  1964.  
  1965.   pp$3.parseObj = function(isPattern, refDestructuringErrors) {
  1966.     var this$1 = this;
  1967.  
  1968.     var node = this.startNode(), first = true, propHash = {}
  1969.     node.properties = []
  1970.     this.next()
  1971.     while (!this.eat(tt.braceR)) {
  1972.       if (!first) {
  1973.         this$1.expect(tt.comma)
  1974.         if (this$1.afterTrailingComma(tt.braceR)) break
  1975.       } else first = false
  1976.  
  1977.       var prop = this$1.startNode(), isGenerator, startPos, startLoc
  1978.       if (this$1.options.ecmaVersion >= 6) {
  1979.         prop.method = false
  1980.         prop.shorthand = false
  1981.         if (isPattern || refDestructuringErrors) {
  1982.           startPos = this$1.start
  1983.           startLoc = this$1.startLoc
  1984.         }
  1985.         if (!isPattern)
  1986.           isGenerator = this$1.eat(tt.star)
  1987.       }
  1988.       this$1.parsePropertyName(prop)
  1989.       this$1.parsePropertyValue(prop, isPattern, isGenerator, startPos, startLoc, refDestructuringErrors)
  1990.       this$1.checkPropClash(prop, propHash)
  1991.       node.properties.push(this$1.finishNode(prop, "Property"))
  1992.     }
  1993.     return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression")
  1994.   }
  1995.  
  1996.   pp$3.parsePropertyValue = function(prop, isPattern, isGenerator, startPos, startLoc, refDestructuringErrors) {
  1997.     if (this.eat(tt.colon)) {
  1998.       prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors)
  1999.       prop.kind = "init"
  2000.     } else if (this.options.ecmaVersion >= 6 && this.type === tt.parenL) {
  2001.       if (isPattern) this.unexpected()
  2002.       prop.kind = "init"
  2003.       prop.method = true
  2004.       prop.value = this.parseMethod(isGenerator)
  2005.     } else if (this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" &&
  2006.                (prop.key.name === "get" || prop.key.name === "set") &&
  2007.                (this.type != tt.comma && this.type != tt.braceR)) {
  2008.       if (isGenerator || isPattern) this.unexpected()
  2009.       prop.kind = prop.key.name
  2010.       this.parsePropertyName(prop)
  2011.       prop.value = this.parseMethod(false)
  2012.       var paramCount = prop.kind === "get" ? 0 : 1
  2013.       if (prop.value.params.length !== paramCount) {
  2014.         var start = prop.value.start
  2015.         if (prop.kind === "get")
  2016.           this.raiseRecoverable(start, "getter should have no params")
  2017.         else
  2018.           this.raiseRecoverable(start, "setter should have exactly one param")
  2019.       }
  2020.       if (prop.kind === "set" && prop.value.params[0].type === "RestElement")
  2021.         this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params")
  2022.     } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
  2023.       if (this.keywords.test(prop.key.name) ||
  2024.           (this.strict ? this.reservedWordsStrictBind : this.reservedWords).test(prop.key.name) ||
  2025.           (this.inGenerator && prop.key.name == "yield"))
  2026.         this.raiseRecoverable(prop.key.start, "'" + prop.key.name + "' can not be used as shorthand property")
  2027.       prop.kind = "init"
  2028.       if (isPattern) {
  2029.         prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key)
  2030.       } else if (this.type === tt.eq && refDestructuringErrors) {
  2031.         if (!refDestructuringErrors.shorthandAssign)
  2032.           refDestructuringErrors.shorthandAssign = this.start
  2033.         prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key)
  2034.       } else {
  2035.         prop.value = prop.key
  2036.       }
  2037.       prop.shorthand = true
  2038.     } else this.unexpected()
  2039.   }
  2040.  
  2041.   pp$3.parsePropertyName = function(prop) {
  2042.     if (this.options.ecmaVersion >= 6) {
  2043.       if (this.eat(tt.bracketL)) {
  2044.         prop.computed = true
  2045.         prop.key = this.parseMaybeAssign()
  2046.         this.expect(tt.bracketR)
  2047.         return prop.key
  2048.       } else {
  2049.         prop.computed = false
  2050.       }
  2051.     }
  2052.     return prop.key = this.type === tt.num || this.type === tt.string ? this.parseExprAtom() : this.parseIdent(true)
  2053.   }
  2054.  
  2055.   // Initialize empty function node.
  2056.  
  2057.   pp$3.initFunction = function(node) {
  2058.     node.id = null
  2059.     if (this.options.ecmaVersion >= 6) {
  2060.       node.generator = false
  2061.       node.expression = false
  2062.     }
  2063.   }
  2064.  
  2065.   // Parse object or class method.
  2066.  
  2067.   pp$3.parseMethod = function(isGenerator) {
  2068.     var node = this.startNode(), oldInGen = this.inGenerator
  2069.     this.inGenerator = isGenerator
  2070.     this.initFunction(node)
  2071.     this.expect(tt.parenL)
  2072.     node.params = this.parseBindingList(tt.parenR, false, false)
  2073.     if (this.options.ecmaVersion >= 6)
  2074.       node.generator = isGenerator
  2075.     this.parseFunctionBody(node, false)
  2076.     this.inGenerator = oldInGen
  2077.     return this.finishNode(node, "FunctionExpression")
  2078.   }
  2079.  
  2080.   // Parse arrow function expression with given parameters.
  2081.  
  2082.   pp$3.parseArrowExpression = function(node, params) {
  2083.     var oldInGen = this.inGenerator
  2084.     this.inGenerator = false
  2085.     this.initFunction(node)
  2086.     node.params = this.toAssignableList(params, true)
  2087.     this.parseFunctionBody(node, true)
  2088.     this.inGenerator = oldInGen
  2089.     return this.finishNode(node, "ArrowFunctionExpression")
  2090.   }
  2091.  
  2092.   // Parse function body and check parameters.
  2093.  
  2094.   pp$3.parseFunctionBody = function(node, isArrowFunction) {
  2095.     var isExpression = isArrowFunction && this.type !== tt.braceL
  2096.  
  2097.     if (isExpression) {
  2098.       node.body = this.parseMaybeAssign()
  2099.       node.expression = true
  2100.     } else {
  2101.       // Start a new scope with regard to labels and the `inFunction`
  2102.       // flag (restore them to their old value afterwards).
  2103.       var oldInFunc = this.inFunction, oldLabels = this.labels
  2104.       this.inFunction = true; this.labels = []
  2105.       node.body = this.parseBlock(true)
  2106.       node.expression = false
  2107.       this.inFunction = oldInFunc; this.labels = oldLabels
  2108.     }
  2109.  
  2110.     // If this is a strict mode function, verify that argument names
  2111.     // are not repeated, and it does not try to bind the words `eval`
  2112.     // or `arguments`.
  2113.     var useStrict = (!isExpression && node.body.body.length && this.isUseStrict(node.body.body[0])) ? node.body.body[0] : null;
  2114.     if (this.strict || useStrict) {
  2115.       var oldStrict = this.strict
  2116.       this.strict = true
  2117.       if (node.id)
  2118.         this.checkLVal(node.id, true)
  2119.       this.checkParams(node, useStrict)
  2120.       this.strict = oldStrict
  2121.     } else if (isArrowFunction) {
  2122.       this.checkParams(node, useStrict)
  2123.     }
  2124.   }
  2125.  
  2126.   // Checks function params for various disallowed patterns such as using "eval"
  2127.   // or "arguments" and duplicate parameters.
  2128.  
  2129.   pp$3.checkParams = function(node, useStrict) {
  2130.       var this$1 = this;
  2131.  
  2132.       var nameHash = {}
  2133.       for (var i = 0; i < node.params.length; i++) {
  2134.         if (useStrict && this$1.options.ecmaVersion >= 7 && node.params[i].type !== "Identifier")
  2135.           this$1.raiseRecoverable(useStrict.start, "Illegal 'use strict' directive in function with non-simple parameter list");
  2136.         this$1.checkLVal(node.params[i], true, nameHash)
  2137.       }
  2138.   }
  2139.  
  2140.   // Parses a comma-separated list of expressions, and returns them as
  2141.   // an array. `close` is the token type that ends the list, and
  2142.   // `allowEmpty` can be turned on to allow subsequent commas with
  2143.   // nothing in between them to be parsed as `null` (which is needed
  2144.   // for array literals).
  2145.  
  2146.   pp$3.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) {
  2147.     var this$1 = this;
  2148.  
  2149.     var elts = [], first = true
  2150.     while (!this.eat(close)) {
  2151.       if (!first) {
  2152.         this$1.expect(tt.comma)
  2153.         if (allowTrailingComma && this$1.afterTrailingComma(close)) break
  2154.       } else first = false
  2155.  
  2156.       var elt
  2157.       if (allowEmpty && this$1.type === tt.comma)
  2158.         elt = null
  2159.       else if (this$1.type === tt.ellipsis) {
  2160.         elt = this$1.parseSpread(refDestructuringErrors)
  2161.         if (this$1.type === tt.comma && refDestructuringErrors && !refDestructuringErrors.trailingComma) {
  2162.           refDestructuringErrors.trailingComma = this$1.lastTokStart
  2163.         }
  2164.       } else
  2165.         elt = this$1.parseMaybeAssign(false, refDestructuringErrors)
  2166.       elts.push(elt)
  2167.     }
  2168.     return elts
  2169.   }
  2170.  
  2171.   // Parse the next token as an identifier. If `liberal` is true (used
  2172.   // when parsing properties), it will also convert keywords into
  2173.   // identifiers.
  2174.  
  2175.   pp$3.parseIdent = function(liberal) {
  2176.     var node = this.startNode()
  2177.     if (liberal && this.options.allowReserved == "never") liberal = false
  2178.     if (this.type === tt.name) {
  2179.       if (!liberal && (this.strict ? this.reservedWordsStrict : this.reservedWords).test(this.value) &&
  2180.           (this.options.ecmaVersion >= 6 ||
  2181.            this.input.slice(this.start, this.end).indexOf("\\") == -1))
  2182.         this.raiseRecoverable(this.start, "The keyword '" + this.value + "' is reserved")
  2183.       if (!liberal && this.inGenerator && this.value === "yield")
  2184.         this.raiseRecoverable(this.start, "Can not use 'yield' as identifier inside a generator")
  2185.       node.name = this.value
  2186.     } else if (liberal && this.type.keyword) {
  2187.       node.name = this.type.keyword
  2188.     } else {
  2189.       this.unexpected()
  2190.     }
  2191.     this.next()
  2192.     return this.finishNode(node, "Identifier")
  2193.   }
  2194.  
  2195.   // Parses yield expression inside generator.
  2196.  
  2197.   pp$3.parseYield = function() {
  2198.     var node = this.startNode()
  2199.     this.next()
  2200.     if (this.type == tt.semi || this.canInsertSemicolon() || (this.type != tt.star && !this.type.startsExpr)) {
  2201.       node.delegate = false
  2202.       node.argument = null
  2203.     } else {
  2204.       node.delegate = this.eat(tt.star)
  2205.       node.argument = this.parseMaybeAssign()
  2206.     }
  2207.     return this.finishNode(node, "YieldExpression")
  2208.   }
  2209.  
  2210.   var pp$4 = Parser.prototype
  2211.  
  2212.   // This function is used to raise exceptions on parse errors. It
  2213.   // takes an offset integer (into the current `input`) to indicate
  2214.   // the location of the error, attaches the position to the end
  2215.   // of the error message, and then raises a `SyntaxError` with that
  2216.   // message.
  2217.  
  2218.   pp$4.raise = function(pos, message) {
  2219.     var loc = getLineInfo(this.input, pos)
  2220.     message += " (" + loc.line + ":" + loc.column + ")"
  2221.     var err = new SyntaxError(message)
  2222.     err.pos = pos; err.loc = loc; err.raisedAt = this.pos
  2223.     throw err
  2224.   }
  2225.  
  2226.   pp$4.raiseRecoverable = pp$4.raise
  2227.  
  2228.   pp$4.curPosition = function() {
  2229.     if (this.options.locations) {
  2230.       return new Position(this.curLine, this.pos - this.lineStart)
  2231.     }
  2232.   }
  2233.  
  2234.   var Node = function Node(parser, pos, loc) {
  2235.     this.type = ""
  2236.     this.start = pos
  2237.     this.end = 0
  2238.     if (parser.options.locations)
  2239.       this.loc = new SourceLocation(parser, loc)
  2240.     if (parser.options.directSourceFile)
  2241.       this.sourceFile = parser.options.directSourceFile
  2242.     if (parser.options.ranges)
  2243.       this.range = [pos, 0]
  2244.   };
  2245.  
  2246.   // Start an AST node, attaching a start offset.
  2247.  
  2248.   var pp$5 = Parser.prototype
  2249.  
  2250.   pp$5.startNode = function() {
  2251.     return new Node(this, this.start, this.startLoc)
  2252.   }