espree-umd

A UMD version of espree

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.greatest.deepsurf.us/scripts/480784/1286205/espree-umd.js

  1. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.espree = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  2. 'use strict';
  3.  
  4. const XHTMLEntities = require('./xhtml');
  5.  
  6. const hexNumber = /^[\da-fA-F]+$/;
  7. const decimalNumber = /^\d+$/;
  8.  
  9. // The map to `acorn-jsx` tokens from `acorn` namespace objects.
  10. const acornJsxMap = new WeakMap();
  11.  
  12. // Get the original tokens for the given `acorn` namespace object.
  13. function getJsxTokens(acorn) {
  14. acorn = acorn.Parser.acorn || acorn;
  15. let acornJsx = acornJsxMap.get(acorn);
  16. if (!acornJsx) {
  17. const tt = acorn.tokTypes;
  18. const TokContext = acorn.TokContext;
  19. const TokenType = acorn.TokenType;
  20. const tc_oTag = new TokContext('<tag', false);
  21. const tc_cTag = new TokContext('</tag', false);
  22. const tc_expr = new TokContext('<tag>...</tag>', true, true);
  23. const tokContexts = {
  24. tc_oTag: tc_oTag,
  25. tc_cTag: tc_cTag,
  26. tc_expr: tc_expr
  27. };
  28. const tokTypes = {
  29. jsxName: new TokenType('jsxName'),
  30. jsxText: new TokenType('jsxText', {beforeExpr: true}),
  31. jsxTagStart: new TokenType('jsxTagStart', {startsExpr: true}),
  32. jsxTagEnd: new TokenType('jsxTagEnd')
  33. };
  34.  
  35. tokTypes.jsxTagStart.updateContext = function() {
  36. this.context.push(tc_expr); // treat as beginning of JSX expression
  37. this.context.push(tc_oTag); // start opening tag context
  38. this.exprAllowed = false;
  39. };
  40. tokTypes.jsxTagEnd.updateContext = function(prevType) {
  41. let out = this.context.pop();
  42. if (out === tc_oTag && prevType === tt.slash || out === tc_cTag) {
  43. this.context.pop();
  44. this.exprAllowed = this.curContext() === tc_expr;
  45. } else {
  46. this.exprAllowed = true;
  47. }
  48. };
  49.  
  50. acornJsx = { tokContexts: tokContexts, tokTypes: tokTypes };
  51. acornJsxMap.set(acorn, acornJsx);
  52. }
  53.  
  54. return acornJsx;
  55. }
  56.  
  57. // Transforms JSX element name to string.
  58.  
  59. function getQualifiedJSXName(object) {
  60. if (!object)
  61. return object;
  62.  
  63. if (object.type === 'JSXIdentifier')
  64. return object.name;
  65.  
  66. if (object.type === 'JSXNamespacedName')
  67. return object.namespace.name + ':' + object.name.name;
  68.  
  69. if (object.type === 'JSXMemberExpression')
  70. return getQualifiedJSXName(object.object) + '.' +
  71. getQualifiedJSXName(object.property);
  72. }
  73.  
  74. module.exports = function(options) {
  75. options = options || {};
  76. return function(Parser) {
  77. return plugin({
  78. allowNamespaces: options.allowNamespaces !== false,
  79. allowNamespacedObjects: !!options.allowNamespacedObjects
  80. }, Parser);
  81. };
  82. };
  83.  
  84. // This is `tokTypes` of the peer dep.
  85. // This can be different instances from the actual `tokTypes` this plugin uses.
  86. Object.defineProperty(module.exports, "tokTypes", {
  87. get: function get_tokTypes() {
  88. return getJsxTokens(require("acorn")).tokTypes;
  89. },
  90. configurable: true,
  91. enumerable: true
  92. });
  93.  
  94. function plugin(options, Parser) {
  95. const acorn = Parser.acorn || require("acorn");
  96. const acornJsx = getJsxTokens(acorn);
  97. const tt = acorn.tokTypes;
  98. const tok = acornJsx.tokTypes;
  99. const tokContexts = acorn.tokContexts;
  100. const tc_oTag = acornJsx.tokContexts.tc_oTag;
  101. const tc_cTag = acornJsx.tokContexts.tc_cTag;
  102. const tc_expr = acornJsx.tokContexts.tc_expr;
  103. const isNewLine = acorn.isNewLine;
  104. const isIdentifierStart = acorn.isIdentifierStart;
  105. const isIdentifierChar = acorn.isIdentifierChar;
  106.  
  107. return class extends Parser {
  108. // Expose actual `tokTypes` and `tokContexts` to other plugins.
  109. static get acornJsx() {
  110. return acornJsx;
  111. }
  112.  
  113. // Reads inline JSX contents token.
  114. jsx_readToken() {
  115. let out = '', chunkStart = this.pos;
  116. for (;;) {
  117. if (this.pos >= this.input.length)
  118. this.raise(this.start, 'Unterminated JSX contents');
  119. let ch = this.input.charCodeAt(this.pos);
  120.  
  121. switch (ch) {
  122. case 60: // '<'
  123. case 123: // '{'
  124. if (this.pos === this.start) {
  125. if (ch === 60 && this.exprAllowed) {
  126. ++this.pos;
  127. return this.finishToken(tok.jsxTagStart);
  128. }
  129. return this.getTokenFromCode(ch);
  130. }
  131. out += this.input.slice(chunkStart, this.pos);
  132. return this.finishToken(tok.jsxText, out);
  133.  
  134. case 38: // '&'
  135. out += this.input.slice(chunkStart, this.pos);
  136. out += this.jsx_readEntity();
  137. chunkStart = this.pos;
  138. break;
  139.  
  140. case 62: // '>'
  141. case 125: // '}'
  142. this.raise(
  143. this.pos,
  144. "Unexpected token `" + this.input[this.pos] + "`. Did you mean `" +
  145. (ch === 62 ? "&gt;" : "&rbrace;") + "` or " + "`{\"" + this.input[this.pos] + "\"}" + "`?"
  146. );
  147.  
  148. default:
  149. if (isNewLine(ch)) {
  150. out += this.input.slice(chunkStart, this.pos);
  151. out += this.jsx_readNewLine(true);
  152. chunkStart = this.pos;
  153. } else {
  154. ++this.pos;
  155. }
  156. }
  157. }
  158. }
  159.  
  160. jsx_readNewLine(normalizeCRLF) {
  161. let ch = this.input.charCodeAt(this.pos);
  162. let out;
  163. ++this.pos;
  164. if (ch === 13 && this.input.charCodeAt(this.pos) === 10) {
  165. ++this.pos;
  166. out = normalizeCRLF ? '\n' : '\r\n';
  167. } else {
  168. out = String.fromCharCode(ch);
  169. }
  170. if (this.options.locations) {
  171. ++this.curLine;
  172. this.lineStart = this.pos;
  173. }
  174.  
  175. return out;
  176. }
  177.  
  178. jsx_readString(quote) {
  179. let out = '', chunkStart = ++this.pos;
  180. for (;;) {
  181. if (this.pos >= this.input.length)
  182. this.raise(this.start, 'Unterminated string constant');
  183. let ch = this.input.charCodeAt(this.pos);
  184. if (ch === quote) break;
  185. if (ch === 38) { // '&'
  186. out += this.input.slice(chunkStart, this.pos);
  187. out += this.jsx_readEntity();
  188. chunkStart = this.pos;
  189. } else if (isNewLine(ch)) {
  190. out += this.input.slice(chunkStart, this.pos);
  191. out += this.jsx_readNewLine(false);
  192. chunkStart = this.pos;
  193. } else {
  194. ++this.pos;
  195. }
  196. }
  197. out += this.input.slice(chunkStart, this.pos++);
  198. return this.finishToken(tt.string, out);
  199. }
  200.  
  201. jsx_readEntity() {
  202. let str = '', count = 0, entity;
  203. let ch = this.input[this.pos];
  204. if (ch !== '&')
  205. this.raise(this.pos, 'Entity must start with an ampersand');
  206. let startPos = ++this.pos;
  207. while (this.pos < this.input.length && count++ < 10) {
  208. ch = this.input[this.pos++];
  209. if (ch === ';') {
  210. if (str[0] === '#') {
  211. if (str[1] === 'x') {
  212. str = str.substr(2);
  213. if (hexNumber.test(str))
  214. entity = String.fromCharCode(parseInt(str, 16));
  215. } else {
  216. str = str.substr(1);
  217. if (decimalNumber.test(str))
  218. entity = String.fromCharCode(parseInt(str, 10));
  219. }
  220. } else {
  221. entity = XHTMLEntities[str];
  222. }
  223. break;
  224. }
  225. str += ch;
  226. }
  227. if (!entity) {
  228. this.pos = startPos;
  229. return '&';
  230. }
  231. return entity;
  232. }
  233.  
  234. // Read a JSX identifier (valid tag or attribute name).
  235. //
  236. // Optimized version since JSX identifiers can't contain
  237. // escape characters and so can be read as single slice.
  238. // Also assumes that first character was already checked
  239. // by isIdentifierStart in readToken.
  240.  
  241. jsx_readWord() {
  242. let ch, start = this.pos;
  243. do {
  244. ch = this.input.charCodeAt(++this.pos);
  245. } while (isIdentifierChar(ch) || ch === 45); // '-'
  246. return this.finishToken(tok.jsxName, this.input.slice(start, this.pos));
  247. }
  248.  
  249. // Parse next token as JSX identifier
  250.  
  251. jsx_parseIdentifier() {
  252. let node = this.startNode();
  253. if (this.type === tok.jsxName)
  254. node.name = this.value;
  255. else if (this.type.keyword)
  256. node.name = this.type.keyword;
  257. else
  258. this.unexpected();
  259. this.next();
  260. return this.finishNode(node, 'JSXIdentifier');
  261. }
  262.  
  263. // Parse namespaced identifier.
  264.  
  265. jsx_parseNamespacedName() {
  266. let startPos = this.start, startLoc = this.startLoc;
  267. let name = this.jsx_parseIdentifier();
  268. if (!options.allowNamespaces || !this.eat(tt.colon)) return name;
  269. var node = this.startNodeAt(startPos, startLoc);
  270. node.namespace = name;
  271. node.name = this.jsx_parseIdentifier();
  272. return this.finishNode(node, 'JSXNamespacedName');
  273. }
  274.  
  275. // Parses element name in any form - namespaced, member
  276. // or single identifier.
  277.  
  278. jsx_parseElementName() {
  279. if (this.type === tok.jsxTagEnd) return '';
  280. let startPos = this.start, startLoc = this.startLoc;
  281. let node = this.jsx_parseNamespacedName();
  282. if (this.type === tt.dot && node.type === 'JSXNamespacedName' && !options.allowNamespacedObjects) {
  283. this.unexpected();
  284. }
  285. while (this.eat(tt.dot)) {
  286. let newNode = this.startNodeAt(startPos, startLoc);
  287. newNode.object = node;
  288. newNode.property = this.jsx_parseIdentifier();
  289. node = this.finishNode(newNode, 'JSXMemberExpression');
  290. }
  291. return node;
  292. }
  293.  
  294. // Parses any type of JSX attribute value.
  295.  
  296. jsx_parseAttributeValue() {
  297. switch (this.type) {
  298. case tt.braceL:
  299. let node = this.jsx_parseExpressionContainer();
  300. if (node.expression.type === 'JSXEmptyExpression')
  301. this.raise(node.start, 'JSX attributes must only be assigned a non-empty expression');
  302. return node;
  303.  
  304. case tok.jsxTagStart:
  305. case tt.string:
  306. return this.parseExprAtom();
  307.  
  308. default:
  309. this.raise(this.start, 'JSX value should be either an expression or a quoted JSX text');
  310. }
  311. }
  312.  
  313. // JSXEmptyExpression is unique type since it doesn't actually parse anything,
  314. // and so it should start at the end of last read token (left brace) and finish
  315. // at the beginning of the next one (right brace).
  316.  
  317. jsx_parseEmptyExpression() {
  318. let node = this.startNodeAt(this.lastTokEnd, this.lastTokEndLoc);
  319. return this.finishNodeAt(node, 'JSXEmptyExpression', this.start, this.startLoc);
  320. }
  321.  
  322. // Parses JSX expression enclosed into curly brackets.
  323.  
  324. jsx_parseExpressionContainer() {
  325. let node = this.startNode();
  326. this.next();
  327. node.expression = this.type === tt.braceR
  328. ? this.jsx_parseEmptyExpression()
  329. : this.parseExpression();
  330. this.expect(tt.braceR);
  331. return this.finishNode(node, 'JSXExpressionContainer');
  332. }
  333.  
  334. // Parses following JSX attribute name-value pair.
  335.  
  336. jsx_parseAttribute() {
  337. let node = this.startNode();
  338. if (this.eat(tt.braceL)) {
  339. this.expect(tt.ellipsis);
  340. node.argument = this.parseMaybeAssign();
  341. this.expect(tt.braceR);
  342. return this.finishNode(node, 'JSXSpreadAttribute');
  343. }
  344. node.name = this.jsx_parseNamespacedName();
  345. node.value = this.eat(tt.eq) ? this.jsx_parseAttributeValue() : null;
  346. return this.finishNode(node, 'JSXAttribute');
  347. }
  348.  
  349. // Parses JSX opening tag starting after '<'.
  350.  
  351. jsx_parseOpeningElementAt(startPos, startLoc) {
  352. let node = this.startNodeAt(startPos, startLoc);
  353. node.attributes = [];
  354. let nodeName = this.jsx_parseElementName();
  355. if (nodeName) node.name = nodeName;
  356. while (this.type !== tt.slash && this.type !== tok.jsxTagEnd)
  357. node.attributes.push(this.jsx_parseAttribute());
  358. node.selfClosing = this.eat(tt.slash);
  359. this.expect(tok.jsxTagEnd);
  360. return this.finishNode(node, nodeName ? 'JSXOpeningElement' : 'JSXOpeningFragment');
  361. }
  362.  
  363. // Parses JSX closing tag starting after '</'.
  364.  
  365. jsx_parseClosingElementAt(startPos, startLoc) {
  366. let node = this.startNodeAt(startPos, startLoc);
  367. let nodeName = this.jsx_parseElementName();
  368. if (nodeName) node.name = nodeName;
  369. this.expect(tok.jsxTagEnd);
  370. return this.finishNode(node, nodeName ? 'JSXClosingElement' : 'JSXClosingFragment');
  371. }
  372.  
  373. // Parses entire JSX element, including it's opening tag
  374. // (starting after '<'), attributes, contents and closing tag.
  375.  
  376. jsx_parseElementAt(startPos, startLoc) {
  377. let node = this.startNodeAt(startPos, startLoc);
  378. let children = [];
  379. let openingElement = this.jsx_parseOpeningElementAt(startPos, startLoc);
  380. let closingElement = null;
  381.  
  382. if (!openingElement.selfClosing) {
  383. contents: for (;;) {
  384. switch (this.type) {
  385. case tok.jsxTagStart:
  386. startPos = this.start; startLoc = this.startLoc;
  387. this.next();
  388. if (this.eat(tt.slash)) {
  389. closingElement = this.jsx_parseClosingElementAt(startPos, startLoc);
  390. break contents;
  391. }
  392. children.push(this.jsx_parseElementAt(startPos, startLoc));
  393. break;
  394.  
  395. case tok.jsxText:
  396. children.push(this.parseExprAtom());
  397. break;
  398.  
  399. case tt.braceL:
  400. children.push(this.jsx_parseExpressionContainer());
  401. break;
  402.  
  403. default:
  404. this.unexpected();
  405. }
  406. }
  407. if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
  408. this.raise(
  409. closingElement.start,
  410. 'Expected corresponding JSX closing tag for <' + getQualifiedJSXName(openingElement.name) + '>');
  411. }
  412. }
  413. let fragmentOrElement = openingElement.name ? 'Element' : 'Fragment';
  414.  
  415. node['opening' + fragmentOrElement] = openingElement;
  416. node['closing' + fragmentOrElement] = closingElement;
  417. node.children = children;
  418. if (this.type === tt.relational && this.value === "<") {
  419. this.raise(this.start, "Adjacent JSX elements must be wrapped in an enclosing tag");
  420. }
  421. return this.finishNode(node, 'JSX' + fragmentOrElement);
  422. }
  423.  
  424. // Parse JSX text
  425.  
  426. jsx_parseText() {
  427. let node = this.parseLiteral(this.value);
  428. node.type = "JSXText";
  429. return node;
  430. }
  431.  
  432. // Parses entire JSX element from current position.
  433.  
  434. jsx_parseElement() {
  435. let startPos = this.start, startLoc = this.startLoc;
  436. this.next();
  437. return this.jsx_parseElementAt(startPos, startLoc);
  438. }
  439.  
  440. parseExprAtom(refShortHandDefaultPos) {
  441. if (this.type === tok.jsxText)
  442. return this.jsx_parseText();
  443. else if (this.type === tok.jsxTagStart)
  444. return this.jsx_parseElement();
  445. else
  446. return super.parseExprAtom(refShortHandDefaultPos);
  447. }
  448.  
  449. readToken(code) {
  450. let context = this.curContext();
  451.  
  452. if (context === tc_expr) return this.jsx_readToken();
  453.  
  454. if (context === tc_oTag || context === tc_cTag) {
  455. if (isIdentifierStart(code)) return this.jsx_readWord();
  456.  
  457. if (code == 62) {
  458. ++this.pos;
  459. return this.finishToken(tok.jsxTagEnd);
  460. }
  461.  
  462. if ((code === 34 || code === 39) && context == tc_oTag)
  463. return this.jsx_readString(code);
  464. }
  465.  
  466. if (code === 60 && this.exprAllowed && this.input.charCodeAt(this.pos + 1) !== 33) {
  467. ++this.pos;
  468. return this.finishToken(tok.jsxTagStart);
  469. }
  470. return super.readToken(code);
  471. }
  472.  
  473. updateContext(prevType) {
  474. if (this.type == tt.braceL) {
  475. var curContext = this.curContext();
  476. if (curContext == tc_oTag) this.context.push(tokContexts.b_expr);
  477. else if (curContext == tc_expr) this.context.push(tokContexts.b_tmpl);
  478. else super.updateContext(prevType);
  479. this.exprAllowed = true;
  480. } else if (this.type === tt.slash && prevType === tok.jsxTagStart) {
  481. this.context.length -= 2; // do not consider JSX expr -> JSX open tag -> ... anymore
  482. this.context.push(tc_cTag); // reconsider as closing tag context
  483. this.exprAllowed = false;
  484. } else {
  485. return super.updateContext(prevType);
  486. }
  487. }
  488. };
  489. }
  490.  
  491. },{"./xhtml":2,"acorn":3}],2:[function(require,module,exports){
  492. module.exports = {
  493. quot: '\u0022',
  494. amp: '&',
  495. apos: '\u0027',
  496. lt: '<',
  497. gt: '>',
  498. nbsp: '\u00A0',
  499. iexcl: '\u00A1',
  500. cent: '\u00A2',
  501. pound: '\u00A3',
  502. curren: '\u00A4',
  503. yen: '\u00A5',
  504. brvbar: '\u00A6',
  505. sect: '\u00A7',
  506. uml: '\u00A8',
  507. copy: '\u00A9',
  508. ordf: '\u00AA',
  509. laquo: '\u00AB',
  510. not: '\u00AC',
  511. shy: '\u00AD',
  512. reg: '\u00AE',
  513. macr: '\u00AF',
  514. deg: '\u00B0',
  515. plusmn: '\u00B1',
  516. sup2: '\u00B2',
  517. sup3: '\u00B3',
  518. acute: '\u00B4',
  519. micro: '\u00B5',
  520. para: '\u00B6',
  521. middot: '\u00B7',
  522. cedil: '\u00B8',
  523. sup1: '\u00B9',
  524. ordm: '\u00BA',
  525. raquo: '\u00BB',
  526. frac14: '\u00BC',
  527. frac12: '\u00BD',
  528. frac34: '\u00BE',
  529. iquest: '\u00BF',
  530. Agrave: '\u00C0',
  531. Aacute: '\u00C1',
  532. Acirc: '\u00C2',
  533. Atilde: '\u00C3',
  534. Auml: '\u00C4',
  535. Aring: '\u00C5',
  536. AElig: '\u00C6',
  537. Ccedil: '\u00C7',
  538. Egrave: '\u00C8',
  539. Eacute: '\u00C9',
  540. Ecirc: '\u00CA',
  541. Euml: '\u00CB',
  542. Igrave: '\u00CC',
  543. Iacute: '\u00CD',
  544. Icirc: '\u00CE',
  545. Iuml: '\u00CF',
  546. ETH: '\u00D0',
  547. Ntilde: '\u00D1',
  548. Ograve: '\u00D2',
  549. Oacute: '\u00D3',
  550. Ocirc: '\u00D4',
  551. Otilde: '\u00D5',
  552. Ouml: '\u00D6',
  553. times: '\u00D7',
  554. Oslash: '\u00D8',
  555. Ugrave: '\u00D9',
  556. Uacute: '\u00DA',
  557. Ucirc: '\u00DB',
  558. Uuml: '\u00DC',
  559. Yacute: '\u00DD',
  560. THORN: '\u00DE',
  561. szlig: '\u00DF',
  562. agrave: '\u00E0',
  563. aacute: '\u00E1',
  564. acirc: '\u00E2',
  565. atilde: '\u00E3',
  566. auml: '\u00E4',
  567. aring: '\u00E5',
  568. aelig: '\u00E6',
  569. ccedil: '\u00E7',
  570. egrave: '\u00E8',
  571. eacute: '\u00E9',
  572. ecirc: '\u00EA',
  573. euml: '\u00EB',
  574. igrave: '\u00EC',
  575. iacute: '\u00ED',
  576. icirc: '\u00EE',
  577. iuml: '\u00EF',
  578. eth: '\u00F0',
  579. ntilde: '\u00F1',
  580. ograve: '\u00F2',
  581. oacute: '\u00F3',
  582. ocirc: '\u00F4',
  583. otilde: '\u00F5',
  584. ouml: '\u00F6',
  585. divide: '\u00F7',
  586. oslash: '\u00F8',
  587. ugrave: '\u00F9',
  588. uacute: '\u00FA',
  589. ucirc: '\u00FB',
  590. uuml: '\u00FC',
  591. yacute: '\u00FD',
  592. thorn: '\u00FE',
  593. yuml: '\u00FF',
  594. OElig: '\u0152',
  595. oelig: '\u0153',
  596. Scaron: '\u0160',
  597. scaron: '\u0161',
  598. Yuml: '\u0178',
  599. fnof: '\u0192',
  600. circ: '\u02C6',
  601. tilde: '\u02DC',
  602. Alpha: '\u0391',
  603. Beta: '\u0392',
  604. Gamma: '\u0393',
  605. Delta: '\u0394',
  606. Epsilon: '\u0395',
  607. Zeta: '\u0396',
  608. Eta: '\u0397',
  609. Theta: '\u0398',
  610. Iota: '\u0399',
  611. Kappa: '\u039A',
  612. Lambda: '\u039B',
  613. Mu: '\u039C',
  614. Nu: '\u039D',
  615. Xi: '\u039E',
  616. Omicron: '\u039F',
  617. Pi: '\u03A0',
  618. Rho: '\u03A1',
  619. Sigma: '\u03A3',
  620. Tau: '\u03A4',
  621. Upsilon: '\u03A5',
  622. Phi: '\u03A6',
  623. Chi: '\u03A7',
  624. Psi: '\u03A8',
  625. Omega: '\u03A9',
  626. alpha: '\u03B1',
  627. beta: '\u03B2',
  628. gamma: '\u03B3',
  629. delta: '\u03B4',
  630. epsilon: '\u03B5',
  631. zeta: '\u03B6',
  632. eta: '\u03B7',
  633. theta: '\u03B8',
  634. iota: '\u03B9',
  635. kappa: '\u03BA',
  636. lambda: '\u03BB',
  637. mu: '\u03BC',
  638. nu: '\u03BD',
  639. xi: '\u03BE',
  640. omicron: '\u03BF',
  641. pi: '\u03C0',
  642. rho: '\u03C1',
  643. sigmaf: '\u03C2',
  644. sigma: '\u03C3',
  645. tau: '\u03C4',
  646. upsilon: '\u03C5',
  647. phi: '\u03C6',
  648. chi: '\u03C7',
  649. psi: '\u03C8',
  650. omega: '\u03C9',
  651. thetasym: '\u03D1',
  652. upsih: '\u03D2',
  653. piv: '\u03D6',
  654. ensp: '\u2002',
  655. emsp: '\u2003',
  656. thinsp: '\u2009',
  657. zwnj: '\u200C',
  658. zwj: '\u200D',
  659. lrm: '\u200E',
  660. rlm: '\u200F',
  661. ndash: '\u2013',
  662. mdash: '\u2014',
  663. lsquo: '\u2018',
  664. rsquo: '\u2019',
  665. sbquo: '\u201A',
  666. ldquo: '\u201C',
  667. rdquo: '\u201D',
  668. bdquo: '\u201E',
  669. dagger: '\u2020',
  670. Dagger: '\u2021',
  671. bull: '\u2022',
  672. hellip: '\u2026',
  673. permil: '\u2030',
  674. prime: '\u2032',
  675. Prime: '\u2033',
  676. lsaquo: '\u2039',
  677. rsaquo: '\u203A',
  678. oline: '\u203E',
  679. frasl: '\u2044',
  680. euro: '\u20AC',
  681. image: '\u2111',
  682. weierp: '\u2118',
  683. real: '\u211C',
  684. trade: '\u2122',
  685. alefsym: '\u2135',
  686. larr: '\u2190',
  687. uarr: '\u2191',
  688. rarr: '\u2192',
  689. darr: '\u2193',
  690. harr: '\u2194',
  691. crarr: '\u21B5',
  692. lArr: '\u21D0',
  693. uArr: '\u21D1',
  694. rArr: '\u21D2',
  695. dArr: '\u21D3',
  696. hArr: '\u21D4',
  697. forall: '\u2200',
  698. part: '\u2202',
  699. exist: '\u2203',
  700. empty: '\u2205',
  701. nabla: '\u2207',
  702. isin: '\u2208',
  703. notin: '\u2209',
  704. ni: '\u220B',
  705. prod: '\u220F',
  706. sum: '\u2211',
  707. minus: '\u2212',
  708. lowast: '\u2217',
  709. radic: '\u221A',
  710. prop: '\u221D',
  711. infin: '\u221E',
  712. ang: '\u2220',
  713. and: '\u2227',
  714. or: '\u2228',
  715. cap: '\u2229',
  716. cup: '\u222A',
  717. 'int': '\u222B',
  718. there4: '\u2234',
  719. sim: '\u223C',
  720. cong: '\u2245',
  721. asymp: '\u2248',
  722. ne: '\u2260',
  723. equiv: '\u2261',
  724. le: '\u2264',
  725. ge: '\u2265',
  726. sub: '\u2282',
  727. sup: '\u2283',
  728. nsub: '\u2284',
  729. sube: '\u2286',
  730. supe: '\u2287',
  731. oplus: '\u2295',
  732. otimes: '\u2297',
  733. perp: '\u22A5',
  734. sdot: '\u22C5',
  735. lceil: '\u2308',
  736. rceil: '\u2309',
  737. lfloor: '\u230A',
  738. rfloor: '\u230B',
  739. lang: '\u2329',
  740. rang: '\u232A',
  741. loz: '\u25CA',
  742. spades: '\u2660',
  743. clubs: '\u2663',
  744. hearts: '\u2665',
  745. diams: '\u2666'
  746. };
  747.  
  748. },{}],3:[function(require,module,exports){
  749. (function (global, factory) {
  750. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  751. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  752. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.acorn = {}));
  753. })(this, (function (exports) { 'use strict';
  754.  
  755. // This file was generated. Do not modify manually!
  756. var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 81, 2, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 9, 5351, 0, 7, 14, 13835, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 983, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
  757.  
  758. // This file was generated. Do not modify manually!
  759. var astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 68, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 4026, 582, 8634, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8936, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 757, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4153, 7, 221, 3, 5761, 15, 7472, 16, 621, 2467, 541, 1507, 4938, 6, 4191];
  760.  
  761. // This file was generated. Do not modify manually!
  762. var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0898-\u089f\u08ca-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3c\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0cf3\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ece\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\u1ace\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1dff\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\u30fb\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f\uff65";
  763.  
  764. // This file was generated. Do not modify manually!
  765. var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u0870-\u0887\u0889-\u088e\u08a0-\u08c9\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u1711\u171f-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4c\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ca\ua7d0\ua7d1\ua7d3\ua7d5-\ua7d9\ua7f2-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
  766.  
  767. // These are a run-length and offset encoded representation of the
  768. // >0xffff code points that are a valid part of identifiers. The
  769. // offset starts at 0x10000, and each pair of numbers represents an
  770. // offset to the next range, and then a size of the range.
  771.  
  772. // Reserved word lists for various dialects of the language
  773.  
  774. var reservedWords = {
  775. 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",
  776. 5: "class enum extends super const export import",
  777. 6: "enum",
  778. strict: "implements interface let package private protected public static yield",
  779. strictBind: "eval arguments"
  780. };
  781.  
  782. // And the keywords
  783.  
  784. 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";
  785.  
  786. var keywords$1 = {
  787. 5: ecma5AndLessKeywords,
  788. "5module": ecma5AndLessKeywords + " export import",
  789. 6: ecma5AndLessKeywords + " const class extends export import super"
  790. };
  791.  
  792. var keywordRelationalOperator = /^in(stanceof)?$/;
  793.  
  794. // ## Character categories
  795.  
  796. var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
  797. var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
  798.  
  799. // This has a complexity linear to the value of the code. The
  800. // assumption is that looking up astral identifier characters is
  801. // rare.
  802. function isInAstralSet(code, set) {
  803. var pos = 0x10000;
  804. for (var i = 0; i < set.length; i += 2) {
  805. pos += set[i];
  806. if (pos > code) { return false }
  807. pos += set[i + 1];
  808. if (pos >= code) { return true }
  809. }
  810. return false
  811. }
  812.  
  813. // Test whether a given character code starts an identifier.
  814.  
  815. function isIdentifierStart(code, astral) {
  816. if (code < 65) { return code === 36 }
  817. if (code < 91) { return true }
  818. if (code < 97) { return code === 95 }
  819. if (code < 123) { return true }
  820. if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)) }
  821. if (astral === false) { return false }
  822. return isInAstralSet(code, astralIdentifierStartCodes)
  823. }
  824.  
  825. // Test whether a given character is part of an identifier.
  826.  
  827. function isIdentifierChar(code, astral) {
  828. if (code < 48) { return code === 36 }
  829. if (code < 58) { return true }
  830. if (code < 65) { return false }
  831. if (code < 91) { return true }
  832. if (code < 97) { return code === 95 }
  833. if (code < 123) { return true }
  834. if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)) }
  835. if (astral === false) { return false }
  836. return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes)
  837. }
  838.  
  839. // ## Token types
  840.  
  841. // The assignment of fine-grained, information-carrying type objects
  842. // allows the tokenizer to store the information it has about a
  843. // token in a way that is very cheap for the parser to look up.
  844.  
  845. // All token type variables start with an underscore, to make them
  846. // easy to recognize.
  847.  
  848. // The `beforeExpr` property is used to disambiguate between regular
  849. // expressions and divisions. It is set on all token types that can
  850. // be followed by an expression (thus, a slash after them would be a
  851. // regular expression).
  852. //
  853. // The `startsExpr` property is used to check if the token ends a
  854. // `yield` expression. It is set on all token types that either can
  855. // directly start an expression (like a quotation mark) or can
  856. // continue an expression (like the body of a string).
  857. //
  858. // `isLoop` marks a keyword as starting a loop, which is important
  859. // to know when parsing a label, in order to allow or disallow
  860. // continue jumps to that label.
  861.  
  862. var TokenType = function TokenType(label, conf) {
  863. if ( conf === void 0 ) conf = {};
  864.  
  865. this.label = label;
  866. this.keyword = conf.keyword;
  867. this.beforeExpr = !!conf.beforeExpr;
  868. this.startsExpr = !!conf.startsExpr;
  869. this.isLoop = !!conf.isLoop;
  870. this.isAssign = !!conf.isAssign;
  871. this.prefix = !!conf.prefix;
  872. this.postfix = !!conf.postfix;
  873. this.binop = conf.binop || null;
  874. this.updateContext = null;
  875. };
  876.  
  877. function binop(name, prec) {
  878. return new TokenType(name, {beforeExpr: true, binop: prec})
  879. }
  880. var beforeExpr = {beforeExpr: true}, startsExpr = {startsExpr: true};
  881.  
  882. // Map keyword names to token types.
  883.  
  884. var keywords = {};
  885.  
  886. // Succinct definitions of keyword token types
  887. function kw(name, options) {
  888. if ( options === void 0 ) options = {};
  889.  
  890. options.keyword = name;
  891. return keywords[name] = new TokenType(name, options)
  892. }
  893.  
  894. var types$1 = {
  895. num: new TokenType("num", startsExpr),
  896. regexp: new TokenType("regexp", startsExpr),
  897. string: new TokenType("string", startsExpr),
  898. name: new TokenType("name", startsExpr),
  899. privateId: new TokenType("privateId", startsExpr),
  900. eof: new TokenType("eof"),
  901.  
  902. // Punctuation token types.
  903. bracketL: new TokenType("[", {beforeExpr: true, startsExpr: true}),
  904. bracketR: new TokenType("]"),
  905. braceL: new TokenType("{", {beforeExpr: true, startsExpr: true}),
  906. braceR: new TokenType("}"),
  907. parenL: new TokenType("(", {beforeExpr: true, startsExpr: true}),
  908. parenR: new TokenType(")"),
  909. comma: new TokenType(",", beforeExpr),
  910. semi: new TokenType(";", beforeExpr),
  911. colon: new TokenType(":", beforeExpr),
  912. dot: new TokenType("."),
  913. question: new TokenType("?", beforeExpr),
  914. questionDot: new TokenType("?."),
  915. arrow: new TokenType("=>", beforeExpr),
  916. template: new TokenType("template"),
  917. invalidTemplate: new TokenType("invalidTemplate"),
  918. ellipsis: new TokenType("...", beforeExpr),
  919. backQuote: new TokenType("`", startsExpr),
  920. dollarBraceL: new TokenType("${", {beforeExpr: true, startsExpr: true}),
  921.  
  922. // Operators. These carry several kinds of properties to help the
  923. // parser use them properly (the presence of these properties is
  924. // what categorizes them as operators).
  925. //
  926. // `binop`, when present, specifies that this operator is a binary
  927. // operator, and will refer to its precedence.
  928. //
  929. // `prefix` and `postfix` mark the operator as a prefix or postfix
  930. // unary operator.
  931. //
  932. // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as
  933. // binary operators with a very low precedence, that should result
  934. // in AssignmentExpression nodes.
  935.  
  936. eq: new TokenType("=", {beforeExpr: true, isAssign: true}),
  937. assign: new TokenType("_=", {beforeExpr: true, isAssign: true}),
  938. incDec: new TokenType("++/--", {prefix: true, postfix: true, startsExpr: true}),
  939. prefix: new TokenType("!/~", {beforeExpr: true, prefix: true, startsExpr: true}),
  940. logicalOR: binop("||", 1),
  941. logicalAND: binop("&&", 2),
  942. bitwiseOR: binop("|", 3),
  943. bitwiseXOR: binop("^", 4),
  944. bitwiseAND: binop("&", 5),
  945. equality: binop("==/!=/===/!==", 6),
  946. relational: binop("</>/<=/>=", 7),
  947. bitShift: binop("<</>>/>>>", 8),
  948. plusMin: new TokenType("+/-", {beforeExpr: true, binop: 9, prefix: true, startsExpr: true}),
  949. modulo: binop("%", 10),
  950. star: binop("*", 10),
  951. slash: binop("/", 10),
  952. starstar: new TokenType("**", {beforeExpr: true}),
  953. coalesce: binop("??", 1),
  954.  
  955. // Keyword token types.
  956. _break: kw("break"),
  957. _case: kw("case", beforeExpr),
  958. _catch: kw("catch"),
  959. _continue: kw("continue"),
  960. _debugger: kw("debugger"),
  961. _default: kw("default", beforeExpr),
  962. _do: kw("do", {isLoop: true, beforeExpr: true}),
  963. _else: kw("else", beforeExpr),
  964. _finally: kw("finally"),
  965. _for: kw("for", {isLoop: true}),
  966. _function: kw("function", startsExpr),
  967. _if: kw("if"),
  968. _return: kw("return", beforeExpr),
  969. _switch: kw("switch"),
  970. _throw: kw("throw", beforeExpr),
  971. _try: kw("try"),
  972. _var: kw("var"),
  973. _const: kw("const"),
  974. _while: kw("while", {isLoop: true}),
  975. _with: kw("with"),
  976. _new: kw("new", {beforeExpr: true, startsExpr: true}),
  977. _this: kw("this", startsExpr),
  978. _super: kw("super", startsExpr),
  979. _class: kw("class", startsExpr),
  980. _extends: kw("extends", beforeExpr),
  981. _export: kw("export"),
  982. _import: kw("import", startsExpr),
  983. _null: kw("null", startsExpr),
  984. _true: kw("true", startsExpr),
  985. _false: kw("false", startsExpr),
  986. _in: kw("in", {beforeExpr: true, binop: 7}),
  987. _instanceof: kw("instanceof", {beforeExpr: true, binop: 7}),
  988. _typeof: kw("typeof", {beforeExpr: true, prefix: true, startsExpr: true}),
  989. _void: kw("void", {beforeExpr: true, prefix: true, startsExpr: true}),
  990. _delete: kw("delete", {beforeExpr: true, prefix: true, startsExpr: true})
  991. };
  992.  
  993. // Matches a whole line break (where CRLF is considered a single
  994. // line break). Used to count lines.
  995.  
  996. var lineBreak = /\r\n?|\n|\u2028|\u2029/;
  997. var lineBreakG = new RegExp(lineBreak.source, "g");
  998.  
  999. function isNewLine(code) {
  1000. return code === 10 || code === 13 || code === 0x2028 || code === 0x2029
  1001. }
  1002.  
  1003. function nextLineBreak(code, from, end) {
  1004. if ( end === void 0 ) end = code.length;
  1005.  
  1006. for (var i = from; i < end; i++) {
  1007. var next = code.charCodeAt(i);
  1008. if (isNewLine(next))
  1009. { return i < end - 1 && next === 13 && code.charCodeAt(i + 1) === 10 ? i + 2 : i + 1 }
  1010. }
  1011. return -1
  1012. }
  1013.  
  1014. var nonASCIIwhitespace = /[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
  1015.  
  1016. var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
  1017.  
  1018. var ref = Object.prototype;
  1019. var hasOwnProperty = ref.hasOwnProperty;
  1020. var toString = ref.toString;
  1021.  
  1022. var hasOwn = Object.hasOwn || (function (obj, propName) { return (
  1023. hasOwnProperty.call(obj, propName)
  1024. ); });
  1025.  
  1026. var isArray = Array.isArray || (function (obj) { return (
  1027. toString.call(obj) === "[object Array]"
  1028. ); });
  1029.  
  1030. var regexpCache = Object.create(null);
  1031.  
  1032. function wordsRegexp(words) {
  1033. return regexpCache[words] || (regexpCache[words] = new RegExp("^(?:" + words.replace(/ /g, "|") + ")$"))
  1034. }
  1035.  
  1036. function codePointToString(code) {
  1037. // UTF-16 Decoding
  1038. if (code <= 0xFFFF) { return String.fromCharCode(code) }
  1039. code -= 0x10000;
  1040. return String.fromCharCode((code >> 10) + 0xD800, (code & 1023) + 0xDC00)
  1041. }
  1042.  
  1043. var loneSurrogate = /(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/;
  1044.  
  1045. // These are used when `options.locations` is on, for the
  1046. // `startLoc` and `endLoc` properties.
  1047.  
  1048. var Position = function Position(line, col) {
  1049. this.line = line;
  1050. this.column = col;
  1051. };
  1052.  
  1053. Position.prototype.offset = function offset (n) {
  1054. return new Position(this.line, this.column + n)
  1055. };
  1056.  
  1057. var SourceLocation = function SourceLocation(p, start, end) {
  1058. this.start = start;
  1059. this.end = end;
  1060. if (p.sourceFile !== null) { this.source = p.sourceFile; }
  1061. };
  1062.  
  1063. // The `getLineInfo` function is mostly useful when the
  1064. // `locations` option is off (for performance reasons) and you
  1065. // want to find the line/column position for a given character
  1066. // offset. `input` should be the code string that the offset refers
  1067. // into.
  1068.  
  1069. function getLineInfo(input, offset) {
  1070. for (var line = 1, cur = 0;;) {
  1071. var nextBreak = nextLineBreak(input, cur, offset);
  1072. if (nextBreak < 0) { return new Position(line, offset - cur) }
  1073. ++line;
  1074. cur = nextBreak;
  1075. }
  1076. }
  1077.  
  1078. // A second argument must be given to configure the parser process.
  1079. // These options are recognized (only `ecmaVersion` is required):
  1080.  
  1081. var defaultOptions = {
  1082. // `ecmaVersion` indicates the ECMAScript version to parse. Must be
  1083. // either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10
  1084. // (2019), 11 (2020), 12 (2021), 13 (2022), 14 (2023), or `"latest"`
  1085. // (the latest version the library supports). This influences
  1086. // support for strict mode, the set of reserved words, and support
  1087. // for new syntax features.
  1088. ecmaVersion: null,
  1089. // `sourceType` indicates the mode the code should be parsed in.
  1090. // Can be either `"script"` or `"module"`. This influences global
  1091. // strict mode and parsing of `import` and `export` declarations.
  1092. sourceType: "script",
  1093. // `onInsertedSemicolon` can be a callback that will be called when
  1094. // a semicolon is automatically inserted. It will be passed the
  1095. // position of the inserted semicolon as an offset, and if
  1096. // `locations` is enabled, it is given the location as a `{line,
  1097. // column}` object as second argument.
  1098. onInsertedSemicolon: null,
  1099. // `onTrailingComma` is similar to `onInsertedSemicolon`, but for
  1100. // trailing commas.
  1101. onTrailingComma: null,
  1102. // By default, reserved words are only enforced if ecmaVersion >= 5.
  1103. // Set `allowReserved` to a boolean value to explicitly turn this on
  1104. // an off. When this option has the value "never", reserved words
  1105. // and keywords can also not be used as property names.
  1106. allowReserved: null,
  1107. // When enabled, a return at the top level is not considered an
  1108. // error.
  1109. allowReturnOutsideFunction: false,
  1110. // When enabled, import/export statements are not constrained to
  1111. // appearing at the top of the program, and an import.meta expression
  1112. // in a script isn't considered an error.
  1113. allowImportExportEverywhere: false,
  1114. // By default, await identifiers are allowed to appear at the top-level scope only if ecmaVersion >= 2022.
  1115. // When enabled, await identifiers are allowed to appear at the top-level scope,
  1116. // but they are still not allowed in non-async functions.
  1117. allowAwaitOutsideFunction: null,
  1118. // When enabled, super identifiers are not constrained to
  1119. // appearing in methods and do not raise an error when they appear elsewhere.
  1120. allowSuperOutsideMethod: null,
  1121. // When enabled, hashbang directive in the beginning of file is
  1122. // allowed and treated as a line comment. Enabled by default when
  1123. // `ecmaVersion` >= 2023.
  1124. allowHashBang: false,
  1125. // By default, the parser will verify that private properties are
  1126. // only used in places where they are valid and have been declared.
  1127. // Set this to false to turn such checks off.
  1128. checkPrivateFields: true,
  1129. // When `locations` is on, `loc` properties holding objects with
  1130. // `start` and `end` properties in `{line, column}` form (with
  1131. // line being 1-based and column 0-based) will be attached to the
  1132. // nodes.
  1133. locations: false,
  1134. // A function can be passed as `onToken` option, which will
  1135. // cause Acorn to call that function with object in the same
  1136. // format as tokens returned from `tokenizer().getToken()`. Note
  1137. // that you are not allowed to call the parser from the
  1138. // callback—that will corrupt its internal state.
  1139. onToken: null,
  1140. // A function can be passed as `onComment` option, which will
  1141. // cause Acorn to call that function with `(block, text, start,
  1142. // end)` parameters whenever a comment is skipped. `block` is a
  1143. // boolean indicating whether this is a block (`/* */`) comment,
  1144. // `text` is the content of the comment, and `start` and `end` are
  1145. // character offsets that denote the start and end of the comment.
  1146. // When the `locations` option is on, two more parameters are
  1147. // passed, the full `{line, column}` locations of the start and
  1148. // end of the comments. Note that you are not allowed to call the
  1149. // parser from the callback—that will corrupt its internal state.
  1150. // When this option has an array as value, objects representing the
  1151. // comments are pushed to it.
  1152. onComment: null,
  1153. // Nodes have their start and end characters offsets recorded in
  1154. // `start` and `end` properties (directly on the node, rather than
  1155. // the `loc` object, which holds line/column data. To also add a
  1156. // [semi-standardized][range] `range` property holding a `[start,
  1157. // end]` array with the same numbers, set the `ranges` option to
  1158. // `true`.
  1159. //
  1160. // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678
  1161. ranges: false,
  1162. // It is possible to parse multiple files into a single AST by
  1163. // passing the tree produced by parsing the first file as
  1164. // `program` option in subsequent parses. This will add the
  1165. // toplevel forms of the parsed file to the `Program` (top) node
  1166. // of an existing parse tree.
  1167. program: null,
  1168. // When `locations` is on, you can pass this to record the source
  1169. // file in every node's `loc` object.
  1170. sourceFile: null,
  1171. // This value, if given, is stored in every node, whether
  1172. // `locations` is on or off.
  1173. directSourceFile: null,
  1174. // When enabled, parenthesized expressions are represented by
  1175. // (non-standard) ParenthesizedExpression nodes
  1176. preserveParens: false
  1177. };
  1178.  
  1179. // Interpret and default an options object
  1180.  
  1181. var warnedAboutEcmaVersion = false;
  1182.  
  1183. function getOptions(opts) {
  1184. var options = {};
  1185.  
  1186. for (var opt in defaultOptions)
  1187. { options[opt] = opts && hasOwn(opts, opt) ? opts[opt] : defaultOptions[opt]; }
  1188.  
  1189. if (options.ecmaVersion === "latest") {
  1190. options.ecmaVersion = 1e8;
  1191. } else if (options.ecmaVersion == null) {
  1192. if (!warnedAboutEcmaVersion && typeof console === "object" && console.warn) {
  1193. warnedAboutEcmaVersion = true;
  1194. console.warn("Since Acorn 8.0.0, options.ecmaVersion is required.\nDefaulting to 2020, but this will stop working in the future.");
  1195. }
  1196. options.ecmaVersion = 11;
  1197. } else if (options.ecmaVersion >= 2015) {
  1198. options.ecmaVersion -= 2009;
  1199. }
  1200.  
  1201. if (options.allowReserved == null)
  1202. { options.allowReserved = options.ecmaVersion < 5; }
  1203.  
  1204. if (!opts || opts.allowHashBang == null)
  1205. { options.allowHashBang = options.ecmaVersion >= 14; }
  1206.  
  1207. if (isArray(options.onToken)) {
  1208. var tokens = options.onToken;
  1209. options.onToken = function (token) { return tokens.push(token); };
  1210. }
  1211. if (isArray(options.onComment))
  1212. { options.onComment = pushComment(options, options.onComment); }
  1213.  
  1214. return options
  1215. }
  1216.  
  1217. function pushComment(options, array) {
  1218. return function(block, text, start, end, startLoc, endLoc) {
  1219. var comment = {
  1220. type: block ? "Block" : "Line",
  1221. value: text,
  1222. start: start,
  1223. end: end
  1224. };
  1225. if (options.locations)
  1226. { comment.loc = new SourceLocation(this, startLoc, endLoc); }
  1227. if (options.ranges)
  1228. { comment.range = [start, end]; }
  1229. array.push(comment);
  1230. }
  1231. }
  1232.  
  1233. // Each scope gets a bitset that may contain these flags
  1234. var
  1235. SCOPE_TOP = 1,
  1236. SCOPE_FUNCTION = 2,
  1237. SCOPE_ASYNC = 4,
  1238. SCOPE_GENERATOR = 8,
  1239. SCOPE_ARROW = 16,
  1240. SCOPE_SIMPLE_CATCH = 32,
  1241. SCOPE_SUPER = 64,
  1242. SCOPE_DIRECT_SUPER = 128,
  1243. SCOPE_CLASS_STATIC_BLOCK = 256,
  1244. SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK;
  1245.  
  1246. function functionFlags(async, generator) {
  1247. return SCOPE_FUNCTION | (async ? SCOPE_ASYNC : 0) | (generator ? SCOPE_GENERATOR : 0)
  1248. }
  1249.  
  1250. // Used in checkLVal* and declareName to determine the type of a binding
  1251. var
  1252. BIND_NONE = 0, // Not a binding
  1253. BIND_VAR = 1, // Var-style binding
  1254. BIND_LEXICAL = 2, // Let- or const-style binding
  1255. BIND_FUNCTION = 3, // Function declaration
  1256. BIND_SIMPLE_CATCH = 4, // Simple (identifier pattern) catch binding
  1257. BIND_OUTSIDE = 5; // Special case for function names as bound inside the function
  1258.  
  1259. var Parser = function Parser(options, input, startPos) {
  1260. this.options = options = getOptions(options);
  1261. this.sourceFile = options.sourceFile;
  1262. this.keywords = wordsRegexp(keywords$1[options.ecmaVersion >= 6 ? 6 : options.sourceType === "module" ? "5module" : 5]);
  1263. var reserved = "";
  1264. if (options.allowReserved !== true) {
  1265. reserved = reservedWords[options.ecmaVersion >= 6 ? 6 : options.ecmaVersion === 5 ? 5 : 3];
  1266. if (options.sourceType === "module") { reserved += " await"; }
  1267. }
  1268. this.reservedWords = wordsRegexp(reserved);
  1269. var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict;
  1270. this.reservedWordsStrict = wordsRegexp(reservedStrict);
  1271. this.reservedWordsStrictBind = wordsRegexp(reservedStrict + " " + reservedWords.strictBind);
  1272. this.input = String(input);
  1273.  
  1274. // Used to signal to callers of `readWord1` whether the word
  1275. // contained any escape sequences. This is needed because words with
  1276. // escape sequences must not be interpreted as keywords.
  1277. this.containsEsc = false;
  1278.  
  1279. // Set up token state
  1280.  
  1281. // The current position of the tokenizer in the input.
  1282. if (startPos) {
  1283. this.pos = startPos;
  1284. this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1;
  1285. this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;
  1286. } else {
  1287. this.pos = this.lineStart = 0;
  1288. this.curLine = 1;
  1289. }
  1290.  
  1291. // Properties of the current token:
  1292. // Its type
  1293. this.type = types$1.eof;
  1294. // For tokens that include more information than their type, the value
  1295. this.value = null;
  1296. // Its start and end offset
  1297. this.start = this.end = this.pos;
  1298. // And, if locations are used, the {line, column} object
  1299. // corresponding to those offsets
  1300. this.startLoc = this.endLoc = this.curPosition();
  1301.  
  1302. // Position information for the previous token
  1303. this.lastTokEndLoc = this.lastTokStartLoc = null;
  1304. this.lastTokStart = this.lastTokEnd = this.pos;
  1305.  
  1306. // The context stack is used to superficially track syntactic
  1307. // context to predict whether a regular expression is allowed in a
  1308. // given position.
  1309. this.context = this.initialContext();
  1310. this.exprAllowed = true;
  1311.  
  1312. // Figure out if it's a module code.
  1313. this.inModule = options.sourceType === "module";
  1314. this.strict = this.inModule || this.strictDirective(this.pos);
  1315.  
  1316. // Used to signify the start of a potential arrow function
  1317. this.potentialArrowAt = -1;
  1318. this.potentialArrowInForAwait = false;
  1319.  
  1320. // Positions to delayed-check that yield/await does not exist in default parameters.
  1321. this.yieldPos = this.awaitPos = this.awaitIdentPos = 0;
  1322. // Labels in scope.
  1323. this.labels = [];
  1324. // Thus-far undefined exports.
  1325. this.undefinedExports = Object.create(null);
  1326.  
  1327. // If enabled, skip leading hashbang line.
  1328. if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === "#!")
  1329. { this.skipLineComment(2); }
  1330.  
  1331. // Scope tracking for duplicate variable names (see scope.js)
  1332. this.scopeStack = [];
  1333. this.enterScope(SCOPE_TOP);
  1334.  
  1335. // For RegExp validation
  1336. this.regexpState = null;
  1337.  
  1338. // The stack of private names.
  1339. // Each element has two properties: 'declared' and 'used'.
  1340. // When it exited from the outermost class definition, all used private names must be declared.
  1341. this.privateNameStack = [];
  1342. };
  1343.  
  1344. var prototypeAccessors = { inFunction: { configurable: true },inGenerator: { configurable: true },inAsync: { configurable: true },canAwait: { configurable: true },allowSuper: { configurable: true },allowDirectSuper: { configurable: true },treatFunctionsAsVar: { configurable: true },allowNewDotTarget: { configurable: true },inClassStaticBlock: { configurable: true } };
  1345.  
  1346. Parser.prototype.parse = function parse () {
  1347. var node = this.options.program || this.startNode();
  1348. this.nextToken();
  1349. return this.parseTopLevel(node)
  1350. };
  1351.  
  1352. prototypeAccessors.inFunction.get = function () { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 };
  1353.  
  1354. prototypeAccessors.inGenerator.get = function () { return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 && !this.currentVarScope().inClassFieldInit };
  1355.  
  1356. prototypeAccessors.inAsync.get = function () { return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 && !this.currentVarScope().inClassFieldInit };
  1357.  
  1358. prototypeAccessors.canAwait.get = function () {
  1359. for (var i = this.scopeStack.length - 1; i >= 0; i--) {
  1360. var scope = this.scopeStack[i];
  1361. if (scope.inClassFieldInit || scope.flags & SCOPE_CLASS_STATIC_BLOCK) { return false }
  1362. if (scope.flags & SCOPE_FUNCTION) { return (scope.flags & SCOPE_ASYNC) > 0 }
  1363. }
  1364. return (this.inModule && this.options.ecmaVersion >= 13) || this.options.allowAwaitOutsideFunction
  1365. };
  1366.  
  1367. prototypeAccessors.allowSuper.get = function () {
  1368. var ref = this.currentThisScope();
  1369. var flags = ref.flags;
  1370. var inClassFieldInit = ref.inClassFieldInit;
  1371. return (flags & SCOPE_SUPER) > 0 || inClassFieldInit || this.options.allowSuperOutsideMethod
  1372. };
  1373.  
  1374. prototypeAccessors.allowDirectSuper.get = function () { return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0 };
  1375.  
  1376. prototypeAccessors.treatFunctionsAsVar.get = function () { return this.treatFunctionsAsVarInScope(this.currentScope()) };
  1377.  
  1378. prototypeAccessors.allowNewDotTarget.get = function () {
  1379. var ref = this.currentThisScope();
  1380. var flags = ref.flags;
  1381. var inClassFieldInit = ref.inClassFieldInit;
  1382. return (flags & (SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK)) > 0 || inClassFieldInit
  1383. };
  1384.  
  1385. prototypeAccessors.inClassStaticBlock.get = function () {
  1386. return (this.currentVarScope().flags & SCOPE_CLASS_STATIC_BLOCK) > 0
  1387. };
  1388.  
  1389. Parser.extend = function extend () {
  1390. var plugins = [], len = arguments.length;
  1391. while ( len-- ) plugins[ len ] = arguments[ len ];
  1392.  
  1393. var cls = this;
  1394. for (var i = 0; i < plugins.length; i++) { cls = plugins[i](cls); }
  1395. return cls
  1396. };
  1397.  
  1398. Parser.parse = function parse (input, options) {
  1399. return new this(options, input).parse()
  1400. };
  1401.  
  1402. Parser.parseExpressionAt = function parseExpressionAt (input, pos, options) {
  1403. var parser = new this(options, input, pos);
  1404. parser.nextToken();
  1405. return parser.parseExpression()
  1406. };
  1407.  
  1408. Parser.tokenizer = function tokenizer (input, options) {
  1409. return new this(options, input)
  1410. };
  1411.  
  1412. Object.defineProperties( Parser.prototype, prototypeAccessors );
  1413.  
  1414. var pp$9 = Parser.prototype;
  1415.  
  1416. // ## Parser utilities
  1417.  
  1418. var literal = /^(?:'((?:\\.|[^'\\])*?)'|"((?:\\.|[^"\\])*?)")/;
  1419. pp$9.strictDirective = function(start) {
  1420. if (this.options.ecmaVersion < 5) { return false }
  1421. for (;;) {
  1422. // Try to find string literal.
  1423. skipWhiteSpace.lastIndex = start;
  1424. start += skipWhiteSpace.exec(this.input)[0].length;
  1425. var match = literal.exec(this.input.slice(start));
  1426. if (!match) { return false }
  1427. if ((match[1] || match[2]) === "use strict") {
  1428. skipWhiteSpace.lastIndex = start + match[0].length;
  1429. var spaceAfter = skipWhiteSpace.exec(this.input), end = spaceAfter.index + spaceAfter[0].length;
  1430. var next = this.input.charAt(end);
  1431. return next === ";" || next === "}" ||
  1432. (lineBreak.test(spaceAfter[0]) &&
  1433. !(/[(`.[+\-/*%<>=,?^&]/.test(next) || next === "!" && this.input.charAt(end + 1) === "="))
  1434. }
  1435. start += match[0].length;
  1436.  
  1437. // Skip semicolon, if any.
  1438. skipWhiteSpace.lastIndex = start;
  1439. start += skipWhiteSpace.exec(this.input)[0].length;
  1440. if (this.input[start] === ";")
  1441. { start++; }
  1442. }
  1443. };
  1444.  
  1445. // Predicate that tests whether the next token is of the given
  1446. // type, and if yes, consumes it as a side effect.
  1447.  
  1448. pp$9.eat = function(type) {
  1449. if (this.type === type) {
  1450. this.next();
  1451. return true
  1452. } else {
  1453. return false
  1454. }
  1455. };
  1456.  
  1457. // Tests whether parsed token is a contextual keyword.
  1458.  
  1459. pp$9.isContextual = function(name) {
  1460. return this.type === types$1.name && this.value === name && !this.containsEsc
  1461. };
  1462.  
  1463. // Consumes contextual keyword if possible.
  1464.  
  1465. pp$9.eatContextual = function(name) {
  1466. if (!this.isContextual(name)) { return false }
  1467. this.next();
  1468. return true
  1469. };
  1470.  
  1471. // Asserts that following token is given contextual keyword.
  1472.  
  1473. pp$9.expectContextual = function(name) {
  1474. if (!this.eatContextual(name)) { this.unexpected(); }
  1475. };
  1476.  
  1477. // Test whether a semicolon can be inserted at the current position.
  1478.  
  1479. pp$9.canInsertSemicolon = function() {
  1480. return this.type === types$1.eof ||
  1481. this.type === types$1.braceR ||
  1482. lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
  1483. };
  1484.  
  1485. pp$9.insertSemicolon = function() {
  1486. if (this.canInsertSemicolon()) {
  1487. if (this.options.onInsertedSemicolon)
  1488. { this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc); }
  1489. return true
  1490. }
  1491. };
  1492.  
  1493. // Consume a semicolon, or, failing that, see if we are allowed to
  1494. // pretend that there is a semicolon at this position.
  1495.  
  1496. pp$9.semicolon = function() {
  1497. if (!this.eat(types$1.semi) && !this.insertSemicolon()) { this.unexpected(); }
  1498. };
  1499.  
  1500. pp$9.afterTrailingComma = function(tokType, notNext) {
  1501. if (this.type === tokType) {
  1502. if (this.options.onTrailingComma)
  1503. { this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc); }
  1504. if (!notNext)
  1505. { this.next(); }
  1506. return true
  1507. }
  1508. };
  1509.  
  1510. // Expect a token of a given type. If found, consume it, otherwise,
  1511. // raise an unexpected token error.
  1512.  
  1513. pp$9.expect = function(type) {
  1514. this.eat(type) || this.unexpected();
  1515. };
  1516.  
  1517. // Raise an unexpected token error.
  1518.  
  1519. pp$9.unexpected = function(pos) {
  1520. this.raise(pos != null ? pos : this.start, "Unexpected token");
  1521. };
  1522.  
  1523. var DestructuringErrors = function DestructuringErrors() {
  1524. this.shorthandAssign =
  1525. this.trailingComma =
  1526. this.parenthesizedAssign =
  1527. this.parenthesizedBind =
  1528. this.doubleProto =
  1529. -1;
  1530. };
  1531.  
  1532. pp$9.checkPatternErrors = function(refDestructuringErrors, isAssign) {
  1533. if (!refDestructuringErrors) { return }
  1534. if (refDestructuringErrors.trailingComma > -1)
  1535. { this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element"); }
  1536. var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind;
  1537. if (parens > -1) { this.raiseRecoverable(parens, isAssign ? "Assigning to rvalue" : "Parenthesized pattern"); }
  1538. };
  1539.  
  1540. pp$9.checkExpressionErrors = function(refDestructuringErrors, andThrow) {
  1541. if (!refDestructuringErrors) { return false }
  1542. var shorthandAssign = refDestructuringErrors.shorthandAssign;
  1543. var doubleProto = refDestructuringErrors.doubleProto;
  1544. if (!andThrow) { return shorthandAssign >= 0 || doubleProto >= 0 }
  1545. if (shorthandAssign >= 0)
  1546. { this.raise(shorthandAssign, "Shorthand property assignments are valid only in destructuring patterns"); }
  1547. if (doubleProto >= 0)
  1548. { this.raiseRecoverable(doubleProto, "Redefinition of __proto__ property"); }
  1549. };
  1550.  
  1551. pp$9.checkYieldAwaitInDefaultParams = function() {
  1552. if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos))
  1553. { this.raise(this.yieldPos, "Yield expression cannot be a default value"); }
  1554. if (this.awaitPos)
  1555. { this.raise(this.awaitPos, "Await expression cannot be a default value"); }
  1556. };
  1557.  
  1558. pp$9.isSimpleAssignTarget = function(expr) {
  1559. if (expr.type === "ParenthesizedExpression")
  1560. { return this.isSimpleAssignTarget(expr.expression) }
  1561. return expr.type === "Identifier" || expr.type === "MemberExpression"
  1562. };
  1563.  
  1564. var pp$8 = Parser.prototype;
  1565.  
  1566. // ### Statement parsing
  1567.  
  1568. // Parse a program. Initializes the parser, reads any number of
  1569. // statements, and wraps them in a Program node. Optionally takes a
  1570. // `program` argument. If present, the statements will be appended
  1571. // to its body instead of creating a new node.
  1572.  
  1573. pp$8.parseTopLevel = function(node) {
  1574. var exports = Object.create(null);
  1575. if (!node.body) { node.body = []; }
  1576. while (this.type !== types$1.eof) {
  1577. var stmt = this.parseStatement(null, true, exports);
  1578. node.body.push(stmt);
  1579. }
  1580. if (this.inModule)
  1581. { for (var i = 0, list = Object.keys(this.undefinedExports); i < list.length; i += 1)
  1582. {
  1583. var name = list[i];
  1584.  
  1585. this.raiseRecoverable(this.undefinedExports[name].start, ("Export '" + name + "' is not defined"));
  1586. } }
  1587. this.adaptDirectivePrologue(node.body);
  1588. this.next();
  1589. node.sourceType = this.options.sourceType;
  1590. return this.finishNode(node, "Program")
  1591. };
  1592.  
  1593. var loopLabel = {kind: "loop"}, switchLabel = {kind: "switch"};
  1594.  
  1595. pp$8.isLet = function(context) {
  1596. if (this.options.ecmaVersion < 6 || !this.isContextual("let")) { return false }
  1597. skipWhiteSpace.lastIndex = this.pos;
  1598. var skip = skipWhiteSpace.exec(this.input);
  1599. var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
  1600. // For ambiguous cases, determine if a LexicalDeclaration (or only a
  1601. // Statement) is allowed here. If context is not empty then only a Statement
  1602. // is allowed. However, `let [` is an explicit negative lookahead for
  1603. // ExpressionStatement, so special-case it first.
  1604. if (nextCh === 91 || nextCh === 92) { return true } // '[', '/'
  1605. if (context) { return false }
  1606.  
  1607. if (nextCh === 123 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true } // '{', astral
  1608. if (isIdentifierStart(nextCh, true)) {
  1609. var pos = next + 1;
  1610. while (isIdentifierChar(nextCh = this.input.charCodeAt(pos), true)) { ++pos; }
  1611. if (nextCh === 92 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true }
  1612. var ident = this.input.slice(next, pos);
  1613. if (!keywordRelationalOperator.test(ident)) { return true }
  1614. }
  1615. return false
  1616. };
  1617.  
  1618. // check 'async [no LineTerminator here] function'
  1619. // - 'async /*foo*/ function' is OK.
  1620. // - 'async /*\n*/ function' is invalid.
  1621. pp$8.isAsyncFunction = function() {
  1622. if (this.options.ecmaVersion < 8 || !this.isContextual("async"))
  1623. { return false }
  1624.  
  1625. skipWhiteSpace.lastIndex = this.pos;
  1626. var skip = skipWhiteSpace.exec(this.input);
  1627. var next = this.pos + skip[0].length, after;
  1628. return !lineBreak.test(this.input.slice(this.pos, next)) &&
  1629. this.input.slice(next, next + 8) === "function" &&
  1630. (next + 8 === this.input.length ||
  1631. !(isIdentifierChar(after = this.input.charCodeAt(next + 8)) || after > 0xd7ff && after < 0xdc00))
  1632. };
  1633.  
  1634. // Parse a single statement.
  1635. //
  1636. // If expecting a statement and finding a slash operator, parse a
  1637. // regular expression literal. This is to handle cases like
  1638. // `if (foo) /blah/.exec(foo)`, where looking at the previous token
  1639. // does not help.
  1640.  
  1641. pp$8.parseStatement = function(context, topLevel, exports) {
  1642. var starttype = this.type, node = this.startNode(), kind;
  1643.  
  1644. if (this.isLet(context)) {
  1645. starttype = types$1._var;
  1646. kind = "let";
  1647. }
  1648.  
  1649. // Most types of statements are recognized by the keyword they
  1650. // start with. Many are trivial to parse, some require a bit of
  1651. // complexity.
  1652.  
  1653. switch (starttype) {
  1654. case types$1._break: case types$1._continue: return this.parseBreakContinueStatement(node, starttype.keyword)
  1655. case types$1._debugger: return this.parseDebuggerStatement(node)
  1656. case types$1._do: return this.parseDoStatement(node)
  1657. case types$1._for: return this.parseForStatement(node)
  1658. case types$1._function:
  1659. // Function as sole body of either an if statement or a labeled statement
  1660. // works, but not when it is part of a labeled statement that is the sole
  1661. // body of an if statement.
  1662. if ((context && (this.strict || context !== "if" && context !== "label")) && this.options.ecmaVersion >= 6) { this.unexpected(); }
  1663. return this.parseFunctionStatement(node, false, !context)
  1664. case types$1._class:
  1665. if (context) { this.unexpected(); }
  1666. return this.parseClass(node, true)
  1667. case types$1._if: return this.parseIfStatement(node)
  1668. case types$1._return: return this.parseReturnStatement(node)
  1669. case types$1._switch: return this.parseSwitchStatement(node)
  1670. case types$1._throw: return this.parseThrowStatement(node)
  1671. case types$1._try: return this.parseTryStatement(node)
  1672. case types$1._const: case types$1._var:
  1673. kind = kind || this.value;
  1674. if (context && kind !== "var") { this.unexpected(); }
  1675. return this.parseVarStatement(node, kind)
  1676. case types$1._while: return this.parseWhileStatement(node)
  1677. case types$1._with: return this.parseWithStatement(node)
  1678. case types$1.braceL: return this.parseBlock(true, node)
  1679. case types$1.semi: return this.parseEmptyStatement(node)
  1680. case types$1._export:
  1681. case types$1._import:
  1682. if (this.options.ecmaVersion > 10 && starttype === types$1._import) {
  1683. skipWhiteSpace.lastIndex = this.pos;
  1684. var skip = skipWhiteSpace.exec(this.input);
  1685. var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
  1686. if (nextCh === 40 || nextCh === 46) // '(' or '.'
  1687. { return this.parseExpressionStatement(node, this.parseExpression()) }
  1688. }
  1689.  
  1690. if (!this.options.allowImportExportEverywhere) {
  1691. if (!topLevel)
  1692. { this.raise(this.start, "'import' and 'export' may only appear at the top level"); }
  1693. if (!this.inModule)
  1694. { this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'"); }
  1695. }
  1696. return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports)
  1697.  
  1698. // If the statement does not start with a statement keyword or a
  1699. // brace, it's an ExpressionStatement or LabeledStatement. We
  1700. // simply start parsing an expression, and afterwards, if the
  1701. // next token is a colon and the expression was a simple
  1702. // Identifier node, we switch to interpreting it as a label.
  1703. default:
  1704. if (this.isAsyncFunction()) {
  1705. if (context) { this.unexpected(); }
  1706. this.next();
  1707. return this.parseFunctionStatement(node, true, !context)
  1708. }
  1709.  
  1710. var maybeName = this.value, expr = this.parseExpression();
  1711. if (starttype === types$1.name && expr.type === "Identifier" && this.eat(types$1.colon))
  1712. { return this.parseLabeledStatement(node, maybeName, expr, context) }
  1713. else { return this.parseExpressionStatement(node, expr) }
  1714. }
  1715. };
  1716.  
  1717. pp$8.parseBreakContinueStatement = function(node, keyword) {
  1718. var isBreak = keyword === "break";
  1719. this.next();
  1720. if (this.eat(types$1.semi) || this.insertSemicolon()) { node.label = null; }
  1721. else if (this.type !== types$1.name) { this.unexpected(); }
  1722. else {
  1723. node.label = this.parseIdent();
  1724. this.semicolon();
  1725. }
  1726.  
  1727. // Verify that there is an actual destination to break or
  1728. // continue to.
  1729. var i = 0;
  1730. for (; i < this.labels.length; ++i) {
  1731. var lab = this.labels[i];
  1732. if (node.label == null || lab.name === node.label.name) {
  1733. if (lab.kind != null && (isBreak || lab.kind === "loop")) { break }
  1734. if (node.label && isBreak) { break }
  1735. }
  1736. }
  1737. if (i === this.labels.length) { this.raise(node.start, "Unsyntactic " + keyword); }
  1738. return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement")
  1739. };
  1740.  
  1741. pp$8.parseDebuggerStatement = function(node) {
  1742. this.next();
  1743. this.semicolon();
  1744. return this.finishNode(node, "DebuggerStatement")
  1745. };
  1746.  
  1747. pp$8.parseDoStatement = function(node) {
  1748. this.next();
  1749. this.labels.push(loopLabel);
  1750. node.body = this.parseStatement("do");
  1751. this.labels.pop();
  1752. this.expect(types$1._while);
  1753. node.test = this.parseParenExpression();
  1754. if (this.options.ecmaVersion >= 6)
  1755. { this.eat(types$1.semi); }
  1756. else
  1757. { this.semicolon(); }
  1758. return this.finishNode(node, "DoWhileStatement")
  1759. };
  1760.  
  1761. // Disambiguating between a `for` and a `for`/`in` or `for`/`of`
  1762. // loop is non-trivial. Basically, we have to parse the init `var`
  1763. // statement or expression, disallowing the `in` operator (see
  1764. // the second parameter to `parseExpression`), and then check
  1765. // whether the next token is `in` or `of`. When there is no init
  1766. // part (semicolon immediately after the opening parenthesis), it
  1767. // is a regular `for` loop.
  1768.  
  1769. pp$8.parseForStatement = function(node) {
  1770. this.next();
  1771. var awaitAt = (this.options.ecmaVersion >= 9 && this.canAwait && this.eatContextual("await")) ? this.lastTokStart : -1;
  1772. this.labels.push(loopLabel);
  1773. this.enterScope(0);
  1774. this.expect(types$1.parenL);
  1775. if (this.type === types$1.semi) {
  1776. if (awaitAt > -1) { this.unexpected(awaitAt); }
  1777. return this.parseFor(node, null)
  1778. }
  1779. var isLet = this.isLet();
  1780. if (this.type === types$1._var || this.type === types$1._const || isLet) {
  1781. var init$1 = this.startNode(), kind = isLet ? "let" : this.value;
  1782. this.next();
  1783. this.parseVar(init$1, true, kind);
  1784. this.finishNode(init$1, "VariableDeclaration");
  1785. if ((this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1) {
  1786. if (this.options.ecmaVersion >= 9) {
  1787. if (this.type === types$1._in) {
  1788. if (awaitAt > -1) { this.unexpected(awaitAt); }
  1789. } else { node.await = awaitAt > -1; }
  1790. }
  1791. return this.parseForIn(node, init$1)
  1792. }
  1793. if (awaitAt > -1) { this.unexpected(awaitAt); }
  1794. return this.parseFor(node, init$1)
  1795. }
  1796. var startsWithLet = this.isContextual("let"), isForOf = false;
  1797. var refDestructuringErrors = new DestructuringErrors;
  1798. var init = this.parseExpression(awaitAt > -1 ? "await" : true, refDestructuringErrors);
  1799. if (this.type === types$1._in || (isForOf = this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
  1800. if (this.options.ecmaVersion >= 9) {
  1801. if (this.type === types$1._in) {
  1802. if (awaitAt > -1) { this.unexpected(awaitAt); }
  1803. } else { node.await = awaitAt > -1; }
  1804. }
  1805. if (startsWithLet && isForOf) { this.raise(init.start, "The left-hand side of a for-of loop may not start with 'let'."); }
  1806. this.toAssignable(init, false, refDestructuringErrors);
  1807. this.checkLValPattern(init);
  1808. return this.parseForIn(node, init)
  1809. } else {
  1810. this.checkExpressionErrors(refDestructuringErrors, true);
  1811. }
  1812. if (awaitAt > -1) { this.unexpected(awaitAt); }
  1813. return this.parseFor(node, init)
  1814. };
  1815.  
  1816. pp$8.parseFunctionStatement = function(node, isAsync, declarationPosition) {
  1817. this.next();
  1818. return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync)
  1819. };
  1820.  
  1821. pp$8.parseIfStatement = function(node) {
  1822. this.next();
  1823. node.test = this.parseParenExpression();
  1824. // allow function declarations in branches, but only in non-strict mode
  1825. node.consequent = this.parseStatement("if");
  1826. node.alternate = this.eat(types$1._else) ? this.parseStatement("if") : null;
  1827. return this.finishNode(node, "IfStatement")
  1828. };
  1829.  
  1830. pp$8.parseReturnStatement = function(node) {
  1831. if (!this.inFunction && !this.options.allowReturnOutsideFunction)
  1832. { this.raise(this.start, "'return' outside of function"); }
  1833. this.next();
  1834.  
  1835. // In `return` (and `break`/`continue`), the keywords with
  1836. // optional arguments, we eagerly look for a semicolon or the
  1837. // possibility to insert one.
  1838.  
  1839. if (this.eat(types$1.semi) || this.insertSemicolon()) { node.argument = null; }
  1840. else { node.argument = this.parseExpression(); this.semicolon(); }
  1841. return this.finishNode(node, "ReturnStatement")
  1842. };
  1843.  
  1844. pp$8.parseSwitchStatement = function(node) {
  1845. this.next();
  1846. node.discriminant = this.parseParenExpression();
  1847. node.cases = [];
  1848. this.expect(types$1.braceL);
  1849. this.labels.push(switchLabel);
  1850. this.enterScope(0);
  1851.  
  1852. // Statements under must be grouped (by label) in SwitchCase
  1853. // nodes. `cur` is used to keep the node that we are currently
  1854. // adding statements to.
  1855.  
  1856. var cur;
  1857. for (var sawDefault = false; this.type !== types$1.braceR;) {
  1858. if (this.type === types$1._case || this.type === types$1._default) {
  1859. var isCase = this.type === types$1._case;
  1860. if (cur) { this.finishNode(cur, "SwitchCase"); }
  1861. node.cases.push(cur = this.startNode());
  1862. cur.consequent = [];
  1863. this.next();
  1864. if (isCase) {
  1865. cur.test = this.parseExpression();
  1866. } else {
  1867. if (sawDefault) { this.raiseRecoverable(this.lastTokStart, "Multiple default clauses"); }
  1868. sawDefault = true;
  1869. cur.test = null;
  1870. }
  1871. this.expect(types$1.colon);
  1872. } else {
  1873. if (!cur) { this.unexpected(); }
  1874. cur.consequent.push(this.parseStatement(null));
  1875. }
  1876. }
  1877. this.exitScope();
  1878. if (cur) { this.finishNode(cur, "SwitchCase"); }
  1879. this.next(); // Closing brace
  1880. this.labels.pop();
  1881. return this.finishNode(node, "SwitchStatement")
  1882. };
  1883.  
  1884. pp$8.parseThrowStatement = function(node) {
  1885. this.next();
  1886. if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start)))
  1887. { this.raise(this.lastTokEnd, "Illegal newline after throw"); }
  1888. node.argument = this.parseExpression();
  1889. this.semicolon();
  1890. return this.finishNode(node, "ThrowStatement")
  1891. };
  1892.  
  1893. // Reused empty array added for node fields that are always empty.
  1894.  
  1895. var empty$1 = [];
  1896.  
  1897. pp$8.parseCatchClauseParam = function() {
  1898. var param = this.parseBindingAtom();
  1899. var simple = param.type === "Identifier";
  1900. this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0);
  1901. this.checkLValPattern(param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL);
  1902. this.expect(types$1.parenR);
  1903.  
  1904. return param
  1905. };
  1906.  
  1907. pp$8.parseTryStatement = function(node) {
  1908. this.next();
  1909. node.block = this.parseBlock();
  1910. node.handler = null;
  1911. if (this.type === types$1._catch) {
  1912. var clause = this.startNode();
  1913. this.next();
  1914. if (this.eat(types$1.parenL)) {
  1915. clause.param = this.parseCatchClauseParam();
  1916. } else {
  1917. if (this.options.ecmaVersion < 10) { this.unexpected(); }
  1918. clause.param = null;
  1919. this.enterScope(0);
  1920. }
  1921. clause.body = this.parseBlock(false);
  1922. this.exitScope();
  1923. node.handler = this.finishNode(clause, "CatchClause");
  1924. }
  1925. node.finalizer = this.eat(types$1._finally) ? this.parseBlock() : null;
  1926. if (!node.handler && !node.finalizer)
  1927. { this.raise(node.start, "Missing catch or finally clause"); }
  1928. return this.finishNode(node, "TryStatement")
  1929. };
  1930.  
  1931. pp$8.parseVarStatement = function(node, kind, allowMissingInitializer) {
  1932. this.next();
  1933. this.parseVar(node, false, kind, allowMissingInitializer);
  1934. this.semicolon();
  1935. return this.finishNode(node, "VariableDeclaration")
  1936. };
  1937.  
  1938. pp$8.parseWhileStatement = function(node) {
  1939. this.next();
  1940. node.test = this.parseParenExpression();
  1941. this.labels.push(loopLabel);
  1942. node.body = this.parseStatement("while");
  1943. this.labels.pop();
  1944. return this.finishNode(node, "WhileStatement")
  1945. };
  1946.  
  1947. pp$8.parseWithStatement = function(node) {
  1948. if (this.strict) { this.raise(this.start, "'with' in strict mode"); }
  1949. this.next();
  1950. node.object = this.parseParenExpression();
  1951. node.body = this.parseStatement("with");
  1952. return this.finishNode(node, "WithStatement")
  1953. };
  1954.  
  1955. pp$8.parseEmptyStatement = function(node) {
  1956. this.next();
  1957. return this.finishNode(node, "EmptyStatement")
  1958. };
  1959.  
  1960. pp$8.parseLabeledStatement = function(node, maybeName, expr, context) {
  1961. for (var i$1 = 0, list = this.labels; i$1 < list.length; i$1 += 1)
  1962. {
  1963. var label = list[i$1];
  1964.  
  1965. if (label.name === maybeName)
  1966. { this.raise(expr.start, "Label '" + maybeName + "' is already declared");
  1967. } }
  1968. var kind = this.type.isLoop ? "loop" : this.type === types$1._switch ? "switch" : null;
  1969. for (var i = this.labels.length - 1; i >= 0; i--) {
  1970. var label$1 = this.labels[i];
  1971. if (label$1.statementStart === node.start) {
  1972. // Update information about previous labels on this node
  1973. label$1.statementStart = this.start;
  1974. label$1.kind = kind;
  1975. } else { break }
  1976. }
  1977. this.labels.push({name: maybeName, kind: kind, statementStart: this.start});
  1978. node.body = this.parseStatement(context ? context.indexOf("label") === -1 ? context + "label" : context : "label");
  1979. this.labels.pop();
  1980. node.label = expr;
  1981. return this.finishNode(node, "LabeledStatement")
  1982. };
  1983.  
  1984. pp$8.parseExpressionStatement = function(node, expr) {
  1985. node.expression = expr;
  1986. this.semicolon();
  1987. return this.finishNode(node, "ExpressionStatement")
  1988. };
  1989.  
  1990. // Parse a semicolon-enclosed block of statements, handling `"use
  1991. // strict"` declarations when `allowStrict` is true (used for
  1992. // function bodies).
  1993.  
  1994. pp$8.parseBlock = function(createNewLexicalScope, node, exitStrict) {
  1995. if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true;
  1996. if ( node === void 0 ) node = this.startNode();
  1997.  
  1998. node.body = [];
  1999. this.expect(types$1.braceL);
  2000. if (createNewLexicalScope) { this.enterScope(0); }
  2001. while (this.type !== types$1.braceR) {
  2002. var stmt = this.parseStatement(null);
  2003. node.body.push(stmt);
  2004. }
  2005. if (exitStrict) { this.strict = false; }
  2006. this.next();
  2007. if (createNewLexicalScope) { this.exitScope(); }
  2008. return this.finishNode(node, "BlockStatement")
  2009. };
  2010.  
  2011. // Parse a regular `for` loop. The disambiguation code in
  2012. // `parseStatement` will already have parsed the init statement or
  2013. // expression.
  2014.  
  2015. pp$8.parseFor = function(node, init) {
  2016. node.init = init;
  2017. this.expect(types$1.semi);
  2018. node.test = this.type === types$1.semi ? null : this.parseExpression();
  2019. this.expect(types$1.semi);
  2020. node.update = this.type === types$1.parenR ? null : this.parseExpression();
  2021. this.expect(types$1.parenR);
  2022. node.body = this.parseStatement("for");
  2023. this.exitScope();
  2024. this.labels.pop();
  2025. return this.finishNode(node, "ForStatement")
  2026. };
  2027.  
  2028. // Parse a `for`/`in` and `for`/`of` loop, which are almost
  2029. // same from parser's perspective.
  2030.  
  2031. pp$8.parseForIn = function(node, init) {
  2032. var isForIn = this.type === types$1._in;
  2033. this.next();
  2034.  
  2035. if (
  2036. init.type === "VariableDeclaration" &&
  2037. init.declarations[0].init != null &&
  2038. (
  2039. !isForIn ||
  2040. this.options.ecmaVersion < 8 ||
  2041. this.strict ||
  2042. init.kind !== "var" ||
  2043. init.declarations[0].id.type !== "Identifier"
  2044. )
  2045. ) {
  2046. this.raise(
  2047. init.start,
  2048. ((isForIn ? "for-in" : "for-of") + " loop variable declaration may not have an initializer")
  2049. );
  2050. }
  2051. node.left = init;
  2052. node.right = isForIn ? this.parseExpression() : this.parseMaybeAssign();
  2053. this.expect(types$1.parenR);
  2054. node.body = this.parseStatement("for");
  2055. this.exitScope();
  2056. this.labels.pop();
  2057. return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement")
  2058. };
  2059.  
  2060. // Parse a list of variable declarations.
  2061.  
  2062. pp$8.parseVar = function(node, isFor, kind, allowMissingInitializer) {
  2063. node.declarations = [];
  2064. node.kind = kind;
  2065. for (;;) {
  2066. var decl = this.startNode();
  2067. this.parseVarId(decl, kind);
  2068. if (this.eat(types$1.eq)) {
  2069. decl.init = this.parseMaybeAssign(isFor);
  2070. } else if (!allowMissingInitializer && kind === "const" && !(this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of")))) {
  2071. this.unexpected();
  2072. } else if (!allowMissingInitializer && decl.id.type !== "Identifier" && !(isFor && (this.type === types$1._in || this.isContextual("of")))) {
  2073. this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");
  2074. } else {
  2075. decl.init = null;
  2076. }
  2077. node.declarations.push(this.finishNode(decl, "VariableDeclarator"));
  2078. if (!this.eat(types$1.comma)) { break }
  2079. }
  2080. return node
  2081. };
  2082.  
  2083. pp$8.parseVarId = function(decl, kind) {
  2084. decl.id = this.parseBindingAtom();
  2085. this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false);
  2086. };
  2087.  
  2088. var FUNC_STATEMENT = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID = 4;
  2089.  
  2090. // Parse a function declaration or literal (depending on the
  2091. // `statement & FUNC_STATEMENT`).
  2092.  
  2093. // Remove `allowExpressionBody` for 7.0.0, as it is only called with false
  2094. pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, forInit) {
  2095. this.initFunction(node);
  2096. if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) {
  2097. if (this.type === types$1.star && (statement & FUNC_HANGING_STATEMENT))
  2098. { this.unexpected(); }
  2099. node.generator = this.eat(types$1.star);
  2100. }
  2101. if (this.options.ecmaVersion >= 8)
  2102. { node.async = !!isAsync; }
  2103.  
  2104. if (statement & FUNC_STATEMENT) {
  2105. node.id = (statement & FUNC_NULLABLE_ID) && this.type !== types$1.name ? null : this.parseIdent();
  2106. if (node.id && !(statement & FUNC_HANGING_STATEMENT))
  2107. // If it is a regular function declaration in sloppy mode, then it is
  2108. // subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding
  2109. // mode depends on properties of the current scope (see
  2110. // treatFunctionsAsVar).
  2111. { this.checkLValSimple(node.id, (this.strict || node.generator || node.async) ? this.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION); }
  2112. }
  2113.  
  2114. var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
  2115. this.yieldPos = 0;
  2116. this.awaitPos = 0;
  2117. this.awaitIdentPos = 0;
  2118. this.enterScope(functionFlags(node.async, node.generator));
  2119.  
  2120. if (!(statement & FUNC_STATEMENT))
  2121. { node.id = this.type === types$1.name ? this.parseIdent() : null; }
  2122.  
  2123. this.parseFunctionParams(node);
  2124. this.parseFunctionBody(node, allowExpressionBody, false, forInit);
  2125.  
  2126. this.yieldPos = oldYieldPos;
  2127. this.awaitPos = oldAwaitPos;
  2128. this.awaitIdentPos = oldAwaitIdentPos;
  2129. return this.finishNode(node, (statement & FUNC_STATEMENT) ? "FunctionDeclaration" : "FunctionExpression")
  2130. };
  2131.  
  2132. pp$8.parseFunctionParams = function(node) {
  2133. this.expect(types$1.parenL);
  2134. node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8);
  2135. this.checkYieldAwaitInDefaultParams();
  2136. };
  2137.  
  2138. // Parse a class declaration or literal (depending on the
  2139. // `isStatement` parameter).
  2140.  
  2141. pp$8.parseClass = function(node, isStatement) {
  2142. this.next();
  2143.  
  2144. // ecma-262 14.6 Class Definitions
  2145. // A class definition is always strict mode code.
  2146. var oldStrict = this.strict;
  2147. this.strict = true;
  2148.  
  2149. this.parseClassId(node, isStatement);
  2150. this.parseClassSuper(node);
  2151. var privateNameMap = this.enterClassBody();
  2152. var classBody = this.startNode();
  2153. var hadConstructor = false;
  2154. classBody.body = [];
  2155. this.expect(types$1.braceL);
  2156. while (this.type !== types$1.braceR) {
  2157. var element = this.parseClassElement(node.superClass !== null);
  2158. if (element) {
  2159. classBody.body.push(element);
  2160. if (element.type === "MethodDefinition" && element.kind === "constructor") {
  2161. if (hadConstructor) { this.raiseRecoverable(element.start, "Duplicate constructor in the same class"); }
  2162. hadConstructor = true;
  2163. } else if (element.key && element.key.type === "PrivateIdentifier" && isPrivateNameConflicted(privateNameMap, element)) {
  2164. this.raiseRecoverable(element.key.start, ("Identifier '#" + (element.key.name) + "' has already been declared"));
  2165. }
  2166. }
  2167. }
  2168. this.strict = oldStrict;
  2169. this.next();
  2170. node.body = this.finishNode(classBody, "ClassBody");
  2171. this.exitClassBody();
  2172. return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression")
  2173. };
  2174.  
  2175. pp$8.parseClassElement = function(constructorAllowsSuper) {
  2176. if (this.eat(types$1.semi)) { return null }
  2177.  
  2178. var ecmaVersion = this.options.ecmaVersion;
  2179. var node = this.startNode();
  2180. var keyName = "";
  2181. var isGenerator = false;
  2182. var isAsync = false;
  2183. var kind = "method";
  2184. var isStatic = false;
  2185.  
  2186. if (this.eatContextual("static")) {
  2187. // Parse static init block
  2188. if (ecmaVersion >= 13 && this.eat(types$1.braceL)) {
  2189. this.parseClassStaticBlock(node);
  2190. return node
  2191. }
  2192. if (this.isClassElementNameStart() || this.type === types$1.star) {
  2193. isStatic = true;
  2194. } else {
  2195. keyName = "static";
  2196. }
  2197. }
  2198. node.static = isStatic;
  2199. if (!keyName && ecmaVersion >= 8 && this.eatContextual("async")) {
  2200. if ((this.isClassElementNameStart() || this.type === types$1.star) && !this.canInsertSemicolon()) {
  2201. isAsync = true;
  2202. } else {
  2203. keyName = "async";
  2204. }
  2205. }
  2206. if (!keyName && (ecmaVersion >= 9 || !isAsync) && this.eat(types$1.star)) {
  2207. isGenerator = true;
  2208. }
  2209. if (!keyName && !isAsync && !isGenerator) {
  2210. var lastValue = this.value;
  2211. if (this.eatContextual("get") || this.eatContextual("set")) {
  2212. if (this.isClassElementNameStart()) {
  2213. kind = lastValue;
  2214. } else {
  2215. keyName = lastValue;
  2216. }
  2217. }
  2218. }
  2219.  
  2220. // Parse element name
  2221. if (keyName) {
  2222. // 'async', 'get', 'set', or 'static' were not a keyword contextually.
  2223. // The last token is any of those. Make it the element name.
  2224. node.computed = false;
  2225. node.key = this.startNodeAt(this.lastTokStart, this.lastTokStartLoc);
  2226. node.key.name = keyName;
  2227. this.finishNode(node.key, "Identifier");
  2228. } else {
  2229. this.parseClassElementName(node);
  2230. }
  2231.  
  2232. // Parse element value
  2233. if (ecmaVersion < 13 || this.type === types$1.parenL || kind !== "method" || isGenerator || isAsync) {
  2234. var isConstructor = !node.static && checkKeyName(node, "constructor");
  2235. var allowsDirectSuper = isConstructor && constructorAllowsSuper;
  2236. // Couldn't move this check into the 'parseClassMethod' method for backward compatibility.
  2237. if (isConstructor && kind !== "method") { this.raise(node.key.start, "Constructor can't have get/set modifier"); }
  2238. node.kind = isConstructor ? "constructor" : kind;
  2239. this.parseClassMethod(node, isGenerator, isAsync, allowsDirectSuper);
  2240. } else {
  2241. this.parseClassField(node);
  2242. }
  2243.  
  2244. return node
  2245. };
  2246.  
  2247. pp$8.isClassElementNameStart = function() {
  2248. return (
  2249. this.type === types$1.name ||
  2250. this.type === types$1.privateId ||
  2251. this.type === types$1.num ||
  2252. this.type === types$1.string ||
  2253. this.type === types$1.bracketL ||
  2254. this.type.keyword
  2255. )
  2256. };
  2257.  
  2258. pp$8.parseClassElementName = function(element) {
  2259. if (this.type === types$1.privateId) {
  2260. if (this.value === "constructor") {
  2261. this.raise(this.start, "Classes can't have an element named '#constructor'");
  2262. }
  2263. element.computed = false;
  2264. element.key = this.parsePrivateIdent();
  2265. } else {
  2266. this.parsePropertyName(element);
  2267. }
  2268. };
  2269.  
  2270. pp$8.parseClassMethod = function(method, isGenerator, isAsync, allowsDirectSuper) {
  2271. // Check key and flags
  2272. var key = method.key;
  2273. if (method.kind === "constructor") {
  2274. if (isGenerator) { this.raise(key.start, "Constructor can't be a generator"); }
  2275. if (isAsync) { this.raise(key.start, "Constructor can't be an async method"); }
  2276. } else if (method.static && checkKeyName(method, "prototype")) {
  2277. this.raise(key.start, "Classes may not have a static property named prototype");
  2278. }
  2279.  
  2280. // Parse value
  2281. var value = method.value = this.parseMethod(isGenerator, isAsync, allowsDirectSuper);
  2282.  
  2283. // Check value
  2284. if (method.kind === "get" && value.params.length !== 0)
  2285. { this.raiseRecoverable(value.start, "getter should have no params"); }
  2286. if (method.kind === "set" && value.params.length !== 1)
  2287. { this.raiseRecoverable(value.start, "setter should have exactly one param"); }
  2288. if (method.kind === "set" && value.params[0].type === "RestElement")
  2289. { this.raiseRecoverable(value.params[0].start, "Setter cannot use rest params"); }
  2290.  
  2291. return this.finishNode(method, "MethodDefinition")
  2292. };
  2293.  
  2294. pp$8.parseClassField = function(field) {
  2295. if (checkKeyName(field, "constructor")) {
  2296. this.raise(field.key.start, "Classes can't have a field named 'constructor'");
  2297. } else if (field.static && checkKeyName(field, "prototype")) {
  2298. this.raise(field.key.start, "Classes can't have a static field named 'prototype'");
  2299. }
  2300.  
  2301. if (this.eat(types$1.eq)) {
  2302. // To raise SyntaxError if 'arguments' exists in the initializer.
  2303. var scope = this.currentThisScope();
  2304. var inClassFieldInit = scope.inClassFieldInit;
  2305. scope.inClassFieldInit = true;
  2306. field.value = this.parseMaybeAssign();
  2307. scope.inClassFieldInit = inClassFieldInit;
  2308. } else {
  2309. field.value = null;
  2310. }
  2311. this.semicolon();
  2312.  
  2313. return this.finishNode(field, "PropertyDefinition")
  2314. };
  2315.  
  2316. pp$8.parseClassStaticBlock = function(node) {
  2317. node.body = [];
  2318.  
  2319. var oldLabels = this.labels;
  2320. this.labels = [];
  2321. this.enterScope(SCOPE_CLASS_STATIC_BLOCK | SCOPE_SUPER);
  2322. while (this.type !== types$1.braceR) {
  2323. var stmt = this.parseStatement(null);
  2324. node.body.push(stmt);
  2325. }
  2326. this.next();
  2327. this.exitScope();
  2328. this.labels = oldLabels;
  2329.  
  2330. return this.finishNode(node, "StaticBlock")
  2331. };
  2332.  
  2333. pp$8.parseClassId = function(node, isStatement) {
  2334. if (this.type === types$1.name) {
  2335. node.id = this.parseIdent();
  2336. if (isStatement)
  2337. { this.checkLValSimple(node.id, BIND_LEXICAL, false); }
  2338. } else {
  2339. if (isStatement === true)
  2340. { this.unexpected(); }
  2341. node.id = null;
  2342. }
  2343. };
  2344.  
  2345. pp$8.parseClassSuper = function(node) {
  2346. node.superClass = this.eat(types$1._extends) ? this.parseExprSubscripts(null, false) : null;
  2347. };
  2348.  
  2349. pp$8.enterClassBody = function() {
  2350. var element = {declared: Object.create(null), used: []};
  2351. this.privateNameStack.push(element);
  2352. return element.declared
  2353. };
  2354.  
  2355. pp$8.exitClassBody = function() {
  2356. var ref = this.privateNameStack.pop();
  2357. var declared = ref.declared;
  2358. var used = ref.used;
  2359. if (!this.options.checkPrivateFields) { return }
  2360. var len = this.privateNameStack.length;
  2361. var parent = len === 0 ? null : this.privateNameStack[len - 1];
  2362. for (var i = 0; i < used.length; ++i) {
  2363. var id = used[i];
  2364. if (!hasOwn(declared, id.name)) {
  2365. if (parent) {
  2366. parent.used.push(id);
  2367. } else {
  2368. this.raiseRecoverable(id.start, ("Private field '#" + (id.name) + "' must be declared in an enclosing class"));
  2369. }
  2370. }
  2371. }
  2372. };
  2373.  
  2374. function isPrivateNameConflicted(privateNameMap, element) {
  2375. var name = element.key.name;
  2376. var curr = privateNameMap[name];
  2377.  
  2378. var next = "true";
  2379. if (element.type === "MethodDefinition" && (element.kind === "get" || element.kind === "set")) {
  2380. next = (element.static ? "s" : "i") + element.kind;
  2381. }
  2382.  
  2383. // `class { get #a(){}; static set #a(_){} }` is also conflict.
  2384. if (
  2385. curr === "iget" && next === "iset" ||
  2386. curr === "iset" && next === "iget" ||
  2387. curr === "sget" && next === "sset" ||
  2388. curr === "sset" && next === "sget"
  2389. ) {
  2390. privateNameMap[name] = "true";
  2391. return false
  2392. } else if (!curr) {
  2393. privateNameMap[name] = next;
  2394. return false
  2395. } else {
  2396. return true
  2397. }
  2398. }
  2399.  
  2400. function checkKeyName(node, name) {
  2401. var computed = node.computed;
  2402. var key = node.key;
  2403. return !computed && (
  2404. key.type === "Identifier" && key.name === name ||
  2405. key.type === "Literal" && key.value === name
  2406. )
  2407. }
  2408.  
  2409. // Parses module export declaration.
  2410.  
  2411. pp$8.parseExportAllDeclaration = function(node, exports) {
  2412. if (this.options.ecmaVersion >= 11) {
  2413. if (this.eatContextual("as")) {
  2414. node.exported = this.parseModuleExportName();
  2415. this.checkExport(exports, node.exported, this.lastTokStart);
  2416. } else {
  2417. node.exported = null;
  2418. }
  2419. }
  2420. this.expectContextual("from");
  2421. if (this.type !== types$1.string) { this.unexpected(); }
  2422. node.source = this.parseExprAtom();
  2423. this.semicolon();
  2424. return this.finishNode(node, "ExportAllDeclaration")
  2425. };
  2426.  
  2427. pp$8.parseExport = function(node, exports) {
  2428. this.next();
  2429. // export * from '...'
  2430. if (this.eat(types$1.star)) {
  2431. return this.parseExportAllDeclaration(node, exports)
  2432. }
  2433. if (this.eat(types$1._default)) { // export default ...
  2434. this.checkExport(exports, "default", this.lastTokStart);
  2435. node.declaration = this.parseExportDefaultDeclaration();
  2436. return this.finishNode(node, "ExportDefaultDeclaration")
  2437. }
  2438. // export var|const|let|function|class ...
  2439. if (this.shouldParseExportStatement()) {
  2440. node.declaration = this.parseExportDeclaration(node);
  2441. if (node.declaration.type === "VariableDeclaration")
  2442. { this.checkVariableExport(exports, node.declaration.declarations); }
  2443. else
  2444. { this.checkExport(exports, node.declaration.id, node.declaration.id.start); }
  2445. node.specifiers = [];
  2446. node.source = null;
  2447. } else { // export { x, y as z } [from '...']
  2448. node.declaration = null;
  2449. node.specifiers = this.parseExportSpecifiers(exports);
  2450. if (this.eatContextual("from")) {
  2451. if (this.type !== types$1.string) { this.unexpected(); }
  2452. node.source = this.parseExprAtom();
  2453. } else {
  2454. for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
  2455. // check for keywords used as local names
  2456. var spec = list[i];
  2457.  
  2458. this.checkUnreserved(spec.local);
  2459. // check if export is defined
  2460. this.checkLocalExport(spec.local);
  2461.  
  2462. if (spec.local.type === "Literal") {
  2463. this.raise(spec.local.start, "A string literal cannot be used as an exported binding without `from`.");
  2464. }
  2465. }
  2466.  
  2467. node.source = null;
  2468. }
  2469. this.semicolon();
  2470. }
  2471. return this.finishNode(node, "ExportNamedDeclaration")
  2472. };
  2473.  
  2474. pp$8.parseExportDeclaration = function(node) {
  2475. return this.parseStatement(null)
  2476. };
  2477.  
  2478. pp$8.parseExportDefaultDeclaration = function() {
  2479. var isAsync;
  2480. if (this.type === types$1._function || (isAsync = this.isAsyncFunction())) {
  2481. var fNode = this.startNode();
  2482. this.next();
  2483. if (isAsync) { this.next(); }
  2484. return this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync)
  2485. } else if (this.type === types$1._class) {
  2486. var cNode = this.startNode();
  2487. return this.parseClass(cNode, "nullableID")
  2488. } else {
  2489. var declaration = this.parseMaybeAssign();
  2490. this.semicolon();
  2491. return declaration
  2492. }
  2493. };
  2494.  
  2495. pp$8.checkExport = function(exports, name, pos) {
  2496. if (!exports) { return }
  2497. if (typeof name !== "string")
  2498. { name = name.type === "Identifier" ? name.name : name.value; }
  2499. if (hasOwn(exports, name))
  2500. { this.raiseRecoverable(pos, "Duplicate export '" + name + "'"); }
  2501. exports[name] = true;
  2502. };
  2503.  
  2504. pp$8.checkPatternExport = function(exports, pat) {
  2505. var type = pat.type;
  2506. if (type === "Identifier")
  2507. { this.checkExport(exports, pat, pat.start); }
  2508. else if (type === "ObjectPattern")
  2509. { for (var i = 0, list = pat.properties; i < list.length; i += 1)
  2510. {
  2511. var prop = list[i];
  2512.  
  2513. this.checkPatternExport(exports, prop);
  2514. } }
  2515. else if (type === "ArrayPattern")
  2516. { for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
  2517. var elt = list$1[i$1];
  2518.  
  2519. if (elt) { this.checkPatternExport(exports, elt); }
  2520. } }
  2521. else if (type === "Property")
  2522. { this.checkPatternExport(exports, pat.value); }
  2523. else if (type === "AssignmentPattern")
  2524. { this.checkPatternExport(exports, pat.left); }
  2525. else if (type === "RestElement")
  2526. { this.checkPatternExport(exports, pat.argument); }
  2527. };
  2528.  
  2529. pp$8.checkVariableExport = function(exports, decls) {
  2530. if (!exports) { return }
  2531. for (var i = 0, list = decls; i < list.length; i += 1)
  2532. {
  2533. var decl = list[i];
  2534.  
  2535. this.checkPatternExport(exports, decl.id);
  2536. }
  2537. };
  2538.  
  2539. pp$8.shouldParseExportStatement = function() {
  2540. return this.type.keyword === "var" ||
  2541. this.type.keyword === "const" ||
  2542. this.type.keyword === "class" ||
  2543. this.type.keyword === "function" ||
  2544. this.isLet() ||
  2545. this.isAsyncFunction()
  2546. };
  2547.  
  2548. // Parses a comma-separated list of module exports.
  2549.  
  2550. pp$8.parseExportSpecifier = function(exports) {
  2551. var node = this.startNode();
  2552. node.local = this.parseModuleExportName();
  2553.  
  2554. node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local;
  2555. this.checkExport(
  2556. exports,
  2557. node.exported,
  2558. node.exported.start
  2559. );
  2560.  
  2561. return this.finishNode(node, "ExportSpecifier")
  2562. };
  2563.  
  2564. pp$8.parseExportSpecifiers = function(exports) {
  2565. var nodes = [], first = true;
  2566. // export { x, y as z } [from '...']
  2567. this.expect(types$1.braceL);
  2568. while (!this.eat(types$1.braceR)) {
  2569. if (!first) {
  2570. this.expect(types$1.comma);
  2571. if (this.afterTrailingComma(types$1.braceR)) { break }
  2572. } else { first = false; }
  2573.  
  2574. nodes.push(this.parseExportSpecifier(exports));
  2575. }
  2576. return nodes
  2577. };
  2578.  
  2579. // Parses import declaration.
  2580.  
  2581. pp$8.parseImport = function(node) {
  2582. this.next();
  2583.  
  2584. // import '...'
  2585. if (this.type === types$1.string) {
  2586. node.specifiers = empty$1;
  2587. node.source = this.parseExprAtom();
  2588. } else {
  2589. node.specifiers = this.parseImportSpecifiers();
  2590. this.expectContextual("from");
  2591. node.source = this.type === types$1.string ? this.parseExprAtom() : this.unexpected();
  2592. }
  2593. this.semicolon();
  2594. return this.finishNode(node, "ImportDeclaration")
  2595. };
  2596.  
  2597. // Parses a comma-separated list of module imports.
  2598.  
  2599. pp$8.parseImportSpecifier = function() {
  2600. var node = this.startNode();
  2601. node.imported = this.parseModuleExportName();
  2602.  
  2603. if (this.eatContextual("as")) {
  2604. node.local = this.parseIdent();
  2605. } else {
  2606. this.checkUnreserved(node.imported);
  2607. node.local = node.imported;
  2608. }
  2609. this.checkLValSimple(node.local, BIND_LEXICAL);
  2610.  
  2611. return this.finishNode(node, "ImportSpecifier")
  2612. };
  2613.  
  2614. pp$8.parseImportDefaultSpecifier = function() {
  2615. // import defaultObj, { x, y as z } from '...'
  2616. var node = this.startNode();
  2617. node.local = this.parseIdent();
  2618. this.checkLValSimple(node.local, BIND_LEXICAL);
  2619. return this.finishNode(node, "ImportDefaultSpecifier")
  2620. };
  2621.  
  2622. pp$8.parseImportNamespaceSpecifier = function() {
  2623. var node = this.startNode();
  2624. this.next();
  2625. this.expectContextual("as");
  2626. node.local = this.parseIdent();
  2627. this.checkLValSimple(node.local, BIND_LEXICAL);
  2628. return this.finishNode(node, "ImportNamespaceSpecifier")
  2629. };
  2630.  
  2631. pp$8.parseImportSpecifiers = function() {
  2632. var nodes = [], first = true;
  2633. if (this.type === types$1.name) {
  2634. nodes.push(this.parseImportDefaultSpecifier());
  2635. if (!this.eat(types$1.comma)) { return nodes }
  2636. }
  2637. if (this.type === types$1.star) {
  2638. nodes.push(this.parseImportNamespaceSpecifier());
  2639. return nodes
  2640. }
  2641. this.expect(types$1.braceL);
  2642. while (!this.eat(types$1.braceR)) {
  2643. if (!first) {
  2644. this.expect(types$1.comma);
  2645. if (this.afterTrailingComma(types$1.braceR)) { break }
  2646. } else { first = false; }
  2647.  
  2648. nodes.push(this.parseImportSpecifier());
  2649. }
  2650. return nodes
  2651. };
  2652.  
  2653. pp$8.parseModuleExportName = function() {
  2654. if (this.options.ecmaVersion >= 13 && this.type === types$1.string) {
  2655. var stringLiteral = this.parseLiteral(this.value);
  2656. if (loneSurrogate.test(stringLiteral.value)) {
  2657. this.raise(stringLiteral.start, "An export name cannot include a lone surrogate.");
  2658. }
  2659. return stringLiteral
  2660. }
  2661. return this.parseIdent(true)
  2662. };
  2663.  
  2664. // Set `ExpressionStatement#directive` property for directive prologues.
  2665. pp$8.adaptDirectivePrologue = function(statements) {
  2666. for (var i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i) {
  2667. statements[i].directive = statements[i].expression.raw.slice(1, -1);
  2668. }
  2669. };
  2670. pp$8.isDirectiveCandidate = function(statement) {
  2671. return (
  2672. this.options.ecmaVersion >= 5 &&
  2673. statement.type === "ExpressionStatement" &&
  2674. statement.expression.type === "Literal" &&
  2675. typeof statement.expression.value === "string" &&
  2676. // Reject parenthesized strings.
  2677. (this.input[statement.start] === "\"" || this.input[statement.start] === "'")
  2678. )
  2679. };
  2680.  
  2681. var pp$7 = Parser.prototype;
  2682.  
  2683. // Convert existing expression atom to assignable pattern
  2684. // if possible.
  2685.  
  2686. pp$7.toAssignable = function(node, isBinding, refDestructuringErrors) {
  2687. if (this.options.ecmaVersion >= 6 && node) {
  2688. switch (node.type) {
  2689. case "Identifier":
  2690. if (this.inAsync && node.name === "await")
  2691. { this.raise(node.start, "Cannot use 'await' as identifier inside an async function"); }
  2692. break
  2693.  
  2694. case "ObjectPattern":
  2695. case "ArrayPattern":
  2696. case "AssignmentPattern":
  2697. case "RestElement":
  2698. break
  2699.  
  2700. case "ObjectExpression":
  2701. node.type = "ObjectPattern";
  2702. if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
  2703. for (var i = 0, list = node.properties; i < list.length; i += 1) {
  2704. var prop = list[i];
  2705.  
  2706. this.toAssignable(prop, isBinding);
  2707. // Early error:
  2708. // AssignmentRestProperty[Yield, Await] :
  2709. // `...` DestructuringAssignmentTarget[Yield, Await]
  2710. //
  2711. // It is a Syntax Error if |DestructuringAssignmentTarget| is an |ArrayLiteral| or an |ObjectLiteral|.
  2712. if (
  2713. prop.type === "RestElement" &&
  2714. (prop.argument.type === "ArrayPattern" || prop.argument.type === "ObjectPattern")
  2715. ) {
  2716. this.raise(prop.argument.start, "Unexpected token");
  2717. }
  2718. }
  2719. break
  2720.  
  2721. case "Property":
  2722. // AssignmentProperty has type === "Property"
  2723. if (node.kind !== "init") { this.raise(node.key.start, "Object pattern can't contain getter or setter"); }
  2724. this.toAssignable(node.value, isBinding);
  2725. break
  2726.  
  2727. case "ArrayExpression":
  2728. node.type = "ArrayPattern";
  2729. if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
  2730. this.toAssignableList(node.elements, isBinding);
  2731. break
  2732.  
  2733. case "SpreadElement":
  2734. node.type = "RestElement";
  2735. this.toAssignable(node.argument, isBinding);
  2736. if (node.argument.type === "AssignmentPattern")
  2737. { this.raise(node.argument.start, "Rest elements cannot have a default value"); }
  2738. break
  2739.  
  2740. case "AssignmentExpression":
  2741. if (node.operator !== "=") { this.raise(node.left.end, "Only '=' operator can be used for specifying default value."); }
  2742. node.type = "AssignmentPattern";
  2743. delete node.operator;
  2744. this.toAssignable(node.left, isBinding);
  2745. break
  2746.  
  2747. case "ParenthesizedExpression":
  2748. this.toAssignable(node.expression, isBinding, refDestructuringErrors);
  2749. break
  2750.  
  2751. case "ChainExpression":
  2752. this.raiseRecoverable(node.start, "Optional chaining cannot appear in left-hand side");
  2753. break
  2754.  
  2755. case "MemberExpression":
  2756. if (!isBinding) { break }
  2757.  
  2758. default:
  2759. this.raise(node.start, "Assigning to rvalue");
  2760. }
  2761. } else if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
  2762. return node
  2763. };
  2764.  
  2765. // Convert list of expression atoms to binding list.
  2766.  
  2767. pp$7.toAssignableList = function(exprList, isBinding) {
  2768. var end = exprList.length;
  2769. for (var i = 0; i < end; i++) {
  2770. var elt = exprList[i];
  2771. if (elt) { this.toAssignable(elt, isBinding); }
  2772. }
  2773. if (end) {
  2774. var last = exprList[end - 1];
  2775. if (this.options.ecmaVersion === 6 && isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier")
  2776. { this.unexpected(last.argument.start); }
  2777. }
  2778. return exprList
  2779. };
  2780.  
  2781. // Parses spread element.
  2782.  
  2783. pp$7.parseSpread = function(refDestructuringErrors) {
  2784. var node = this.startNode();
  2785. this.next();
  2786. node.argument = this.parseMaybeAssign(false, refDestructuringErrors);
  2787. return this.finishNode(node, "SpreadElement")
  2788. };
  2789.  
  2790. pp$7.parseRestBinding = function() {
  2791. var node = this.startNode();
  2792. this.next();
  2793.  
  2794. // RestElement inside of a function parameter must be an identifier
  2795. if (this.options.ecmaVersion === 6 && this.type !== types$1.name)
  2796. { this.unexpected(); }
  2797.  
  2798. node.argument = this.parseBindingAtom();
  2799.  
  2800. return this.finishNode(node, "RestElement")
  2801. };
  2802.  
  2803. // Parses lvalue (assignable) atom.
  2804.  
  2805. pp$7.parseBindingAtom = function() {
  2806. if (this.options.ecmaVersion >= 6) {
  2807. switch (this.type) {
  2808. case types$1.bracketL:
  2809. var node = this.startNode();
  2810. this.next();
  2811. node.elements = this.parseBindingList(types$1.bracketR, true, true);
  2812. return this.finishNode(node, "ArrayPattern")
  2813.  
  2814. case types$1.braceL:
  2815. return this.parseObj(true)
  2816. }
  2817. }
  2818. return this.parseIdent()
  2819. };
  2820.  
  2821. pp$7.parseBindingList = function(close, allowEmpty, allowTrailingComma, allowModifiers) {
  2822. var elts = [], first = true;
  2823. while (!this.eat(close)) {
  2824. if (first) { first = false; }
  2825. else { this.expect(types$1.comma); }
  2826. if (allowEmpty && this.type === types$1.comma) {
  2827. elts.push(null);
  2828. } else if (allowTrailingComma && this.afterTrailingComma(close)) {
  2829. break
  2830. } else if (this.type === types$1.ellipsis) {
  2831. var rest = this.parseRestBinding();
  2832. this.parseBindingListItem(rest);
  2833. elts.push(rest);
  2834. if (this.type === types$1.comma) { this.raiseRecoverable(this.start, "Comma is not permitted after the rest element"); }
  2835. this.expect(close);
  2836. break
  2837. } else {
  2838. elts.push(this.parseAssignableListItem(allowModifiers));
  2839. }
  2840. }
  2841. return elts
  2842. };
  2843.  
  2844. pp$7.parseAssignableListItem = function(allowModifiers) {
  2845. var elem = this.parseMaybeDefault(this.start, this.startLoc);
  2846. this.parseBindingListItem(elem);
  2847. return elem
  2848. };
  2849.  
  2850. pp$7.parseBindingListItem = function(param) {
  2851. return param
  2852. };
  2853.  
  2854. // Parses assignment pattern around given atom if possible.
  2855.  
  2856. pp$7.parseMaybeDefault = function(startPos, startLoc, left) {
  2857. left = left || this.parseBindingAtom();
  2858. if (this.options.ecmaVersion < 6 || !this.eat(types$1.eq)) { return left }
  2859. var node = this.startNodeAt(startPos, startLoc);
  2860. node.left = left;
  2861. node.right = this.parseMaybeAssign();
  2862. return this.finishNode(node, "AssignmentPattern")
  2863. };
  2864.  
  2865. // The following three functions all verify that a node is an lvalue —
  2866. // something that can be bound, or assigned to. In order to do so, they perform
  2867. // a variety of checks:
  2868. //
  2869. // - Check that none of the bound/assigned-to identifiers are reserved words.
  2870. // - Record name declarations for bindings in the appropriate scope.
  2871. // - Check duplicate argument names, if checkClashes is set.
  2872. //
  2873. // If a complex binding pattern is encountered (e.g., object and array
  2874. // destructuring), the entire pattern is recursively checked.
  2875. //
  2876. // There are three versions of checkLVal*() appropriate for different
  2877. // circumstances:
  2878. //
  2879. // - checkLValSimple() shall be used if the syntactic construct supports
  2880. // nothing other than identifiers and member expressions. Parenthesized
  2881. // expressions are also correctly handled. This is generally appropriate for
  2882. // constructs for which the spec says
  2883. //
  2884. // > It is a Syntax Error if AssignmentTargetType of [the production] is not
  2885. // > simple.
  2886. //
  2887. // It is also appropriate for checking if an identifier is valid and not
  2888. // defined elsewhere, like import declarations or function/class identifiers.
  2889. //
  2890. // Examples where this is used include:
  2891. // a += …;
  2892. // import a from '…';
  2893. // where a is the node to be checked.
  2894. //
  2895. // - checkLValPattern() shall be used if the syntactic construct supports
  2896. // anything checkLValSimple() supports, as well as object and array
  2897. // destructuring patterns. This is generally appropriate for constructs for
  2898. // which the spec says
  2899. //
  2900. // > It is a Syntax Error if [the production] is neither an ObjectLiteral nor
  2901. // > an ArrayLiteral and AssignmentTargetType of [the production] is not
  2902. // > simple.
  2903. //
  2904. // Examples where this is used include:
  2905. // (a = …);
  2906. // const a = …;
  2907. // try { … } catch (a) { … }
  2908. // where a is the node to be checked.
  2909. //
  2910. // - checkLValInnerPattern() shall be used if the syntactic construct supports
  2911. // anything checkLValPattern() supports, as well as default assignment
  2912. // patterns, rest elements, and other constructs that may appear within an
  2913. // object or array destructuring pattern.
  2914. //
  2915. // As a special case, function parameters also use checkLValInnerPattern(),
  2916. // as they also support defaults and rest constructs.
  2917. //
  2918. // These functions deliberately support both assignment and binding constructs,
  2919. // as the logic for both is exceedingly similar. If the node is the target of
  2920. // an assignment, then bindingType should be set to BIND_NONE. Otherwise, it
  2921. // should be set to the appropriate BIND_* constant, like BIND_VAR or
  2922. // BIND_LEXICAL.
  2923. //
  2924. // If the function is called with a non-BIND_NONE bindingType, then
  2925. // additionally a checkClashes object may be specified to allow checking for
  2926. // duplicate argument names. checkClashes is ignored if the provided construct
  2927. // is an assignment (i.e., bindingType is BIND_NONE).
  2928.  
  2929. pp$7.checkLValSimple = function(expr, bindingType, checkClashes) {
  2930. if ( bindingType === void 0 ) bindingType = BIND_NONE;
  2931.  
  2932. var isBind = bindingType !== BIND_NONE;
  2933.  
  2934. switch (expr.type) {
  2935. case "Identifier":
  2936. if (this.strict && this.reservedWordsStrictBind.test(expr.name))
  2937. { this.raiseRecoverable(expr.start, (isBind ? "Binding " : "Assigning to ") + expr.name + " in strict mode"); }
  2938. if (isBind) {
  2939. if (bindingType === BIND_LEXICAL && expr.name === "let")
  2940. { this.raiseRecoverable(expr.start, "let is disallowed as a lexically bound name"); }
  2941. if (checkClashes) {
  2942. if (hasOwn(checkClashes, expr.name))
  2943. { this.raiseRecoverable(expr.start, "Argument name clash"); }
  2944. checkClashes[expr.name] = true;
  2945. }
  2946. if (bindingType !== BIND_OUTSIDE) { this.declareName(expr.name, bindingType, expr.start); }
  2947. }
  2948. break
  2949.  
  2950. case "ChainExpression":
  2951. this.raiseRecoverable(expr.start, "Optional chaining cannot appear in left-hand side");
  2952. break
  2953.  
  2954. case "MemberExpression":
  2955. if (isBind) { this.raiseRecoverable(expr.start, "Binding member expression"); }
  2956. break
  2957.  
  2958. case "ParenthesizedExpression":
  2959. if (isBind) { this.raiseRecoverable(expr.start, "Binding parenthesized expression"); }
  2960. return this.checkLValSimple(expr.expression, bindingType, checkClashes)
  2961.  
  2962. default:
  2963. this.raise(expr.start, (isBind ? "Binding" : "Assigning to") + " rvalue");
  2964. }
  2965. };
  2966.  
  2967. pp$7.checkLValPattern = function(expr, bindingType, checkClashes) {
  2968. if ( bindingType === void 0 ) bindingType = BIND_NONE;
  2969.  
  2970. switch (expr.type) {
  2971. case "ObjectPattern":
  2972. for (var i = 0, list = expr.properties; i < list.length; i += 1) {
  2973. var prop = list[i];
  2974.  
  2975. this.checkLValInnerPattern(prop, bindingType, checkClashes);
  2976. }
  2977. break
  2978.  
  2979. case "ArrayPattern":
  2980. for (var i$1 = 0, list$1 = expr.elements; i$1 < list$1.length; i$1 += 1) {
  2981. var elem = list$1[i$1];
  2982.  
  2983. if (elem) { this.checkLValInnerPattern(elem, bindingType, checkClashes); }
  2984. }
  2985. break
  2986.  
  2987. default:
  2988. this.checkLValSimple(expr, bindingType, checkClashes);
  2989. }
  2990. };
  2991.  
  2992. pp$7.checkLValInnerPattern = function(expr, bindingType, checkClashes) {
  2993. if ( bindingType === void 0 ) bindingType = BIND_NONE;
  2994.  
  2995. switch (expr.type) {
  2996. case "Property":
  2997. // AssignmentProperty has type === "Property"
  2998. this.checkLValInnerPattern(expr.value, bindingType, checkClashes);
  2999. break
  3000.  
  3001. case "AssignmentPattern":
  3002. this.checkLValPattern(expr.left, bindingType, checkClashes);
  3003. break
  3004.  
  3005. case "RestElement":
  3006. this.checkLValPattern(expr.argument, bindingType, checkClashes);
  3007. break
  3008.  
  3009. default:
  3010. this.checkLValPattern(expr, bindingType, checkClashes);
  3011. }
  3012. };
  3013.  
  3014. // The algorithm used to determine whether a regexp can appear at a
  3015. // given point in the program is loosely based on sweet.js' approach.
  3016. // See https://github.com/mozilla/sweet.js/wiki/design
  3017.  
  3018.  
  3019. var TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) {
  3020. this.token = token;
  3021. this.isExpr = !!isExpr;
  3022. this.preserveSpace = !!preserveSpace;
  3023. this.override = override;
  3024. this.generator = !!generator;
  3025. };
  3026.  
  3027. var types = {
  3028. b_stat: new TokContext("{", false),
  3029. b_expr: new TokContext("{", true),
  3030. b_tmpl: new TokContext("${", false),
  3031. p_stat: new TokContext("(", false),
  3032. p_expr: new TokContext("(", true),
  3033. q_tmpl: new TokContext("`", true, true, function (p) { return p.tryReadTemplateToken(); }),
  3034. f_stat: new TokContext("function", false),
  3035. f_expr: new TokContext("function", true),
  3036. f_expr_gen: new TokContext("function", true, false, null, true),
  3037. f_gen: new TokContext("function", false, false, null, true)
  3038. };
  3039.  
  3040. var pp$6 = Parser.prototype;
  3041.  
  3042. pp$6.initialContext = function() {
  3043. return [types.b_stat]
  3044. };
  3045.  
  3046. pp$6.curContext = function() {
  3047. return this.context[this.context.length - 1]
  3048. };
  3049.  
  3050. pp$6.braceIsBlock = function(prevType) {
  3051. var parent = this.curContext();
  3052. if (parent === types.f_expr || parent === types.f_stat)
  3053. { return true }
  3054. if (prevType === types$1.colon && (parent === types.b_stat || parent === types.b_expr))
  3055. { return !parent.isExpr }
  3056.  
  3057. // The check for `tt.name && exprAllowed` detects whether we are
  3058. // after a `yield` or `of` construct. See the `updateContext` for
  3059. // `tt.name`.
  3060. if (prevType === types$1._return || prevType === types$1.name && this.exprAllowed)
  3061. { return lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) }
  3062. if (prevType === types$1._else || prevType === types$1.semi || prevType === types$1.eof || prevType === types$1.parenR || prevType === types$1.arrow)
  3063. { return true }
  3064. if (prevType === types$1.braceL)
  3065. { return parent === types.b_stat }
  3066. if (prevType === types$1._var || prevType === types$1._const || prevType === types$1.name)
  3067. { return false }
  3068. return !this.exprAllowed
  3069. };
  3070.  
  3071. pp$6.inGeneratorContext = function() {
  3072. for (var i = this.context.length - 1; i >= 1; i--) {
  3073. var context = this.context[i];
  3074. if (context.token === "function")
  3075. { return context.generator }
  3076. }
  3077. return false
  3078. };
  3079.  
  3080. pp$6.updateContext = function(prevType) {
  3081. var update, type = this.type;
  3082. if (type.keyword && prevType === types$1.dot)
  3083. { this.exprAllowed = false; }
  3084. else if (update = type.updateContext)
  3085. { update.call(this, prevType); }
  3086. else
  3087. { this.exprAllowed = type.beforeExpr; }
  3088. };
  3089.  
  3090. // Used to handle edge cases when token context could not be inferred correctly during tokenization phase
  3091.  
  3092. pp$6.overrideContext = function(tokenCtx) {
  3093. if (this.curContext() !== tokenCtx) {
  3094. this.context[this.context.length - 1] = tokenCtx;
  3095. }
  3096. };
  3097.  
  3098. // Token-specific context update code
  3099.  
  3100. types$1.parenR.updateContext = types$1.braceR.updateContext = function() {
  3101. if (this.context.length === 1) {
  3102. this.exprAllowed = true;
  3103. return
  3104. }
  3105. var out = this.context.pop();
  3106. if (out === types.b_stat && this.curContext().token === "function") {
  3107. out = this.context.pop();
  3108. }
  3109. this.exprAllowed = !out.isExpr;
  3110. };
  3111.  
  3112. types$1.braceL.updateContext = function(prevType) {
  3113. this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr);
  3114. this.exprAllowed = true;
  3115. };
  3116.  
  3117. types$1.dollarBraceL.updateContext = function() {
  3118. this.context.push(types.b_tmpl);
  3119. this.exprAllowed = true;
  3120. };
  3121.  
  3122. types$1.parenL.updateContext = function(prevType) {
  3123. var statementParens = prevType === types$1._if || prevType === types$1._for || prevType === types$1._with || prevType === types$1._while;
  3124. this.context.push(statementParens ? types.p_stat : types.p_expr);
  3125. this.exprAllowed = true;
  3126. };
  3127.  
  3128. types$1.incDec.updateContext = function() {
  3129. // tokExprAllowed stays unchanged
  3130. };
  3131.  
  3132. types$1._function.updateContext = types$1._class.updateContext = function(prevType) {
  3133. if (prevType.beforeExpr && prevType !== types$1._else &&
  3134. !(prevType === types$1.semi && this.curContext() !== types.p_stat) &&
  3135. !(prevType === types$1._return && lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) &&
  3136. !((prevType === types$1.colon || prevType === types$1.braceL) && this.curContext() === types.b_stat))
  3137. { this.context.push(types.f_expr); }
  3138. else
  3139. { this.context.push(types.f_stat); }
  3140. this.exprAllowed = false;
  3141. };
  3142.  
  3143. types$1.colon.updateContext = function() {
  3144. if (this.curContext().token === "function") { this.context.pop(); }
  3145. this.exprAllowed = true;
  3146. };
  3147.  
  3148. types$1.backQuote.updateContext = function() {
  3149. if (this.curContext() === types.q_tmpl)
  3150. { this.context.pop(); }
  3151. else
  3152. { this.context.push(types.q_tmpl); }
  3153. this.exprAllowed = false;
  3154. };
  3155.  
  3156. types$1.star.updateContext = function(prevType) {
  3157. if (prevType === types$1._function) {
  3158. var index = this.context.length - 1;
  3159. if (this.context[index] === types.f_expr)
  3160. { this.context[index] = types.f_expr_gen; }
  3161. else
  3162. { this.context[index] = types.f_gen; }
  3163. }
  3164. this.exprAllowed = true;
  3165. };
  3166.  
  3167. types$1.name.updateContext = function(prevType) {
  3168. var allowed = false;
  3169. if (this.options.ecmaVersion >= 6 && prevType !== types$1.dot) {
  3170. if (this.value === "of" && !this.exprAllowed ||
  3171. this.value === "yield" && this.inGeneratorContext())
  3172. { allowed = true; }
  3173. }
  3174. this.exprAllowed = allowed;
  3175. };
  3176.  
  3177. // A recursive descent parser operates by defining functions for all
  3178. // syntactic elements, and recursively calling those, each function
  3179. // advancing the input stream and returning an AST node. Precedence
  3180. // of constructs (for example, the fact that `!x[1]` means `!(x[1])`
  3181. // instead of `(!x)[1]` is handled by the fact that the parser
  3182. // function that parses unary prefix operators is called first, and
  3183. // in turn calls the function that parses `[]` subscripts — that
  3184. // way, it'll receive the node for `x[1]` already parsed, and wraps
  3185. // *that* in the unary operator node.
  3186. //
  3187. // Acorn uses an [operator precedence parser][opp] to handle binary
  3188. // operator precedence, because it is much more compact than using
  3189. // the technique outlined above, which uses different, nesting
  3190. // functions to specify precedence, for all of the ten binary
  3191. // precedence levels that JavaScript defines.
  3192. //
  3193. // [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser
  3194.  
  3195.  
  3196. var pp$5 = Parser.prototype;
  3197.  
  3198. // Check if property name clashes with already added.
  3199. // Object/class getters and setters are not allowed to clash —
  3200. // either with each other or with an init property — and in
  3201. // strict mode, init properties are also not allowed to be repeated.
  3202.  
  3203. pp$5.checkPropClash = function(prop, propHash, refDestructuringErrors) {
  3204. if (this.options.ecmaVersion >= 9 && prop.type === "SpreadElement")
  3205. { return }
  3206. if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand))
  3207. { return }
  3208. var key = prop.key;
  3209. var name;
  3210. switch (key.type) {
  3211. case "Identifier": name = key.name; break
  3212. case "Literal": name = String(key.value); break
  3213. default: return
  3214. }
  3215. var kind = prop.kind;
  3216. if (this.options.ecmaVersion >= 6) {
  3217. if (name === "__proto__" && kind === "init") {
  3218. if (propHash.proto) {
  3219. if (refDestructuringErrors) {
  3220. if (refDestructuringErrors.doubleProto < 0) {
  3221. refDestructuringErrors.doubleProto = key.start;
  3222. }
  3223. } else {
  3224. this.raiseRecoverable(key.start, "Redefinition of __proto__ property");
  3225. }
  3226. }
  3227. propHash.proto = true;
  3228. }
  3229. return
  3230. }
  3231. name = "$" + name;
  3232. var other = propHash[name];
  3233. if (other) {
  3234. var redefinition;
  3235. if (kind === "init") {
  3236. redefinition = this.strict && other.init || other.get || other.set;
  3237. } else {
  3238. redefinition = other.init || other[kind];
  3239. }
  3240. if (redefinition)
  3241. { this.raiseRecoverable(key.start, "Redefinition of property"); }
  3242. } else {
  3243. other = propHash[name] = {
  3244. init: false,
  3245. get: false,
  3246. set: false
  3247. };
  3248. }
  3249. other[kind] = true;
  3250. };
  3251.  
  3252. // ### Expression parsing
  3253.  
  3254. // These nest, from the most general expression type at the top to
  3255. // 'atomic', nondivisible expression types at the bottom. Most of
  3256. // the functions will simply let the function(s) below them parse,
  3257. // and, *if* the syntactic construct they handle is present, wrap
  3258. // the AST node that the inner parser gave them in another node.
  3259.  
  3260. // Parse a full expression. The optional arguments are used to
  3261. // forbid the `in` operator (in for loops initalization expressions)
  3262. // and provide reference for storing '=' operator inside shorthand
  3263. // property assignment in contexts where both object expression
  3264. // and object pattern might appear (so it's possible to raise
  3265. // delayed syntax error at correct position).
  3266.  
  3267. pp$5.parseExpression = function(forInit, refDestructuringErrors) {
  3268. var startPos = this.start, startLoc = this.startLoc;
  3269. var expr = this.parseMaybeAssign(forInit, refDestructuringErrors);
  3270. if (this.type === types$1.comma) {
  3271. var node = this.startNodeAt(startPos, startLoc);
  3272. node.expressions = [expr];
  3273. while (this.eat(types$1.comma)) { node.expressions.push(this.parseMaybeAssign(forInit, refDestructuringErrors)); }
  3274. return this.finishNode(node, "SequenceExpression")
  3275. }
  3276. return expr
  3277. };
  3278.  
  3279. // Parse an assignment expression. This includes applications of
  3280. // operators like `+=`.
  3281.  
  3282. pp$5.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse) {
  3283. if (this.isContextual("yield")) {
  3284. if (this.inGenerator) { return this.parseYield(forInit) }
  3285. // The tokenizer will assume an expression is allowed after
  3286. // `yield`, but this isn't that kind of yield
  3287. else { this.exprAllowed = false; }
  3288. }
  3289.  
  3290. var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1, oldDoubleProto = -1;
  3291. if (refDestructuringErrors) {
  3292. oldParenAssign = refDestructuringErrors.parenthesizedAssign;
  3293. oldTrailingComma = refDestructuringErrors.trailingComma;
  3294. oldDoubleProto = refDestructuringErrors.doubleProto;
  3295. refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1;
  3296. } else {
  3297. refDestructuringErrors = new DestructuringErrors;
  3298. ownDestructuringErrors = true;
  3299. }
  3300.  
  3301. var startPos = this.start, startLoc = this.startLoc;
  3302. if (this.type === types$1.parenL || this.type === types$1.name) {
  3303. this.potentialArrowAt = this.start;
  3304. this.potentialArrowInForAwait = forInit === "await";
  3305. }
  3306. var left = this.parseMaybeConditional(forInit, refDestructuringErrors);
  3307. if (afterLeftParse) { left = afterLeftParse.call(this, left, startPos, startLoc); }
  3308. if (this.type.isAssign) {
  3309. var node = this.startNodeAt(startPos, startLoc);
  3310. node.operator = this.value;
  3311. if (this.type === types$1.eq)
  3312. { left = this.toAssignable(left, false, refDestructuringErrors); }
  3313. if (!ownDestructuringErrors) {
  3314. refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.doubleProto = -1;
  3315. }
  3316. if (refDestructuringErrors.shorthandAssign >= left.start)
  3317. { refDestructuringErrors.shorthandAssign = -1; } // reset because shorthand default was used correctly
  3318. if (this.type === types$1.eq)
  3319. { this.checkLValPattern(left); }
  3320. else
  3321. { this.checkLValSimple(left); }
  3322. node.left = left;
  3323. this.next();
  3324. node.right = this.parseMaybeAssign(forInit);
  3325. if (oldDoubleProto > -1) { refDestructuringErrors.doubleProto = oldDoubleProto; }
  3326. return this.finishNode(node, "AssignmentExpression")
  3327. } else {
  3328. if (ownDestructuringErrors) { this.checkExpressionErrors(refDestructuringErrors, true); }
  3329. }
  3330. if (oldParenAssign > -1) { refDestructuringErrors.parenthesizedAssign = oldParenAssign; }
  3331. if (oldTrailingComma > -1) { refDestructuringErrors.trailingComma = oldTrailingComma; }
  3332. return left
  3333. };
  3334.  
  3335. // Parse a ternary conditional (`?:`) operator.
  3336.  
  3337. pp$5.parseMaybeConditional = function(forInit, refDestructuringErrors) {
  3338. var startPos = this.start, startLoc = this.startLoc;
  3339. var expr = this.parseExprOps(forInit, refDestructuringErrors);
  3340. if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
  3341. if (this.eat(types$1.question)) {
  3342. var node = this.startNodeAt(startPos, startLoc);
  3343. node.test = expr;
  3344. node.consequent = this.parseMaybeAssign();
  3345. this.expect(types$1.colon);
  3346. node.alternate = this.parseMaybeAssign(forInit);
  3347. return this.finishNode(node, "ConditionalExpression")
  3348. }
  3349. return expr
  3350. };
  3351.  
  3352. // Start the precedence parser.
  3353.  
  3354. pp$5.parseExprOps = function(forInit, refDestructuringErrors) {
  3355. var startPos = this.start, startLoc = this.startLoc;
  3356. var expr = this.parseMaybeUnary(refDestructuringErrors, false, false, forInit);
  3357. if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
  3358. return expr.start === startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, forInit)
  3359. };
  3360.  
  3361. // Parse binary operators with the operator precedence parsing
  3362. // algorithm. `left` is the left-hand side of the operator.
  3363. // `minPrec` provides context that allows the function to stop and
  3364. // defer further parser to one of its callers when it encounters an
  3365. // operator that has a lower precedence than the set it is parsing.
  3366.  
  3367. pp$5.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, forInit) {
  3368. var prec = this.type.binop;
  3369. if (prec != null && (!forInit || this.type !== types$1._in)) {
  3370. if (prec > minPrec) {
  3371. var logical = this.type === types$1.logicalOR || this.type === types$1.logicalAND;
  3372. var coalesce = this.type === types$1.coalesce;
  3373. if (coalesce) {
  3374. // Handle the precedence of `tt.coalesce` as equal to the range of logical expressions.
  3375. // In other words, `node.right` shouldn't contain logical expressions in order to check the mixed error.
  3376. prec = types$1.logicalAND.binop;
  3377. }
  3378. var op = this.value;
  3379. this.next();
  3380. var startPos = this.start, startLoc = this.startLoc;
  3381. var right = this.parseExprOp(this.parseMaybeUnary(null, false, false, forInit), startPos, startLoc, prec, forInit);
  3382. var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical || coalesce);
  3383. if ((logical && this.type === types$1.coalesce) || (coalesce && (this.type === types$1.logicalOR || this.type === types$1.logicalAND))) {
  3384. this.raiseRecoverable(this.start, "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses");
  3385. }
  3386. return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, forInit)
  3387. }
  3388. }
  3389. return left
  3390. };
  3391.  
  3392. pp$5.buildBinary = function(startPos, startLoc, left, right, op, logical) {
  3393. if (right.type === "PrivateIdentifier") { this.raise(right.start, "Private identifier can only be left side of binary expression"); }
  3394. var node = this.startNodeAt(startPos, startLoc);
  3395. node.left = left;
  3396. node.operator = op;
  3397. node.right = right;
  3398. return this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression")
  3399. };
  3400.  
  3401. // Parse unary operators, both prefix and postfix.
  3402.  
  3403. pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forInit) {
  3404. var startPos = this.start, startLoc = this.startLoc, expr;
  3405. if (this.isContextual("await") && this.canAwait) {
  3406. expr = this.parseAwait(forInit);
  3407. sawUnary = true;
  3408. } else if (this.type.prefix) {
  3409. var node = this.startNode(), update = this.type === types$1.incDec;
  3410. node.operator = this.value;
  3411. node.prefix = true;
  3412. this.next();
  3413. node.argument = this.parseMaybeUnary(null, true, update, forInit);
  3414. this.checkExpressionErrors(refDestructuringErrors, true);
  3415. if (update) { this.checkLValSimple(node.argument); }
  3416. else if (this.strict && node.operator === "delete" &&
  3417. node.argument.type === "Identifier")
  3418. { this.raiseRecoverable(node.start, "Deleting local variable in strict mode"); }
  3419. else if (node.operator === "delete" && isPrivateFieldAccess(node.argument))
  3420. { this.raiseRecoverable(node.start, "Private fields can not be deleted"); }
  3421. else { sawUnary = true; }
  3422. expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
  3423. } else if (!sawUnary && this.type === types$1.privateId) {
  3424. if ((forInit || this.privateNameStack.length === 0) && this.options.checkPrivateFields) { this.unexpected(); }
  3425. expr = this.parsePrivateIdent();
  3426. // only could be private fields in 'in', such as #x in obj
  3427. if (this.type !== types$1._in) { this.unexpected(); }
  3428. } else {
  3429. expr = this.parseExprSubscripts(refDestructuringErrors, forInit);
  3430. if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
  3431. while (this.type.postfix && !this.canInsertSemicolon()) {
  3432. var node$1 = this.startNodeAt(startPos, startLoc);
  3433. node$1.operator = this.value;
  3434. node$1.prefix = false;
  3435. node$1.argument = expr;
  3436. this.checkLValSimple(expr);
  3437. this.next();
  3438. expr = this.finishNode(node$1, "UpdateExpression");
  3439. }
  3440. }
  3441.  
  3442. if (!incDec && this.eat(types$1.starstar)) {
  3443. if (sawUnary)
  3444. { this.unexpected(this.lastTokStart); }
  3445. else
  3446. { return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false, false, forInit), "**", false) }
  3447. } else {
  3448. return expr
  3449. }
  3450. };
  3451.  
  3452. function isPrivateFieldAccess(node) {
  3453. return (
  3454. node.type === "MemberExpression" && node.property.type === "PrivateIdentifier" ||
  3455. node.type === "ChainExpression" && isPrivateFieldAccess(node.expression)
  3456. )
  3457. }
  3458.  
  3459. // Parse call, dot, and `[]`-subscript expressions.
  3460.  
  3461. pp$5.parseExprSubscripts = function(refDestructuringErrors, forInit) {
  3462. var startPos = this.start, startLoc = this.startLoc;
  3463. var expr = this.parseExprAtom(refDestructuringErrors, forInit);
  3464. if (expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")")
  3465. { return expr }
  3466. var result = this.parseSubscripts(expr, startPos, startLoc, false, forInit);
  3467. if (refDestructuringErrors && result.type === "MemberExpression") {
  3468. if (refDestructuringErrors.parenthesizedAssign >= result.start) { refDestructuringErrors.parenthesizedAssign = -1; }
  3469. if (refDestructuringErrors.parenthesizedBind >= result.start) { refDestructuringErrors.parenthesizedBind = -1; }
  3470. if (refDestructuringErrors.trailingComma >= result.start) { refDestructuringErrors.trailingComma = -1; }
  3471. }
  3472. return result
  3473. };
  3474.  
  3475. pp$5.parseSubscripts = function(base, startPos, startLoc, noCalls, forInit) {
  3476. var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" &&
  3477. this.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 &&
  3478. this.potentialArrowAt === base.start;
  3479. var optionalChained = false;
  3480.  
  3481. while (true) {
  3482. var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit);
  3483.  
  3484. if (element.optional) { optionalChained = true; }
  3485. if (element === base || element.type === "ArrowFunctionExpression") {
  3486. if (optionalChained) {
  3487. var chainNode = this.startNodeAt(startPos, startLoc);
  3488. chainNode.expression = element;
  3489. element = this.finishNode(chainNode, "ChainExpression");
  3490. }
  3491. return element
  3492. }
  3493.  
  3494. base = element;
  3495. }
  3496. };
  3497.  
  3498. pp$5.shouldParseAsyncArrow = function() {
  3499. return !this.canInsertSemicolon() && this.eat(types$1.arrow)
  3500. };
  3501.  
  3502. pp$5.parseSubscriptAsyncArrow = function(startPos, startLoc, exprList, forInit) {
  3503. return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true, forInit)
  3504. };
  3505.  
  3506. pp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit) {
  3507. var optionalSupported = this.options.ecmaVersion >= 11;
  3508. var optional = optionalSupported && this.eat(types$1.questionDot);
  3509. if (noCalls && optional) { this.raise(this.lastTokStart, "Optional chaining cannot appear in the callee of new expressions"); }
  3510.  
  3511. var computed = this.eat(types$1.bracketL);
  3512. if (computed || (optional && this.type !== types$1.parenL && this.type !== types$1.backQuote) || this.eat(types$1.dot)) {
  3513. var node = this.startNodeAt(startPos, startLoc);
  3514. node.object = base;
  3515. if (computed) {
  3516. node.property = this.parseExpression();
  3517. this.expect(types$1.bracketR);
  3518. } else if (this.type === types$1.privateId && base.type !== "Super") {
  3519. node.property = this.parsePrivateIdent();
  3520. } else {
  3521. node.property = this.parseIdent(this.options.allowReserved !== "never");
  3522. }
  3523. node.computed = !!computed;
  3524. if (optionalSupported) {
  3525. node.optional = optional;
  3526. }
  3527. base = this.finishNode(node, "MemberExpression");
  3528. } else if (!noCalls && this.eat(types$1.parenL)) {
  3529. var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
  3530. this.yieldPos = 0;
  3531. this.awaitPos = 0;
  3532. this.awaitIdentPos = 0;
  3533. var exprList = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors);
  3534. if (maybeAsyncArrow && !optional && this.shouldParseAsyncArrow()) {
  3535. this.checkPatternErrors(refDestructuringErrors, false);
  3536. this.checkYieldAwaitInDefaultParams();
  3537. if (this.awaitIdentPos > 0)
  3538. { this.raise(this.awaitIdentPos, "Cannot use 'await' as identifier inside an async function"); }
  3539. this.yieldPos = oldYieldPos;
  3540. this.awaitPos = oldAwaitPos;
  3541. this.awaitIdentPos = oldAwaitIdentPos;
  3542. return this.parseSubscriptAsyncArrow(startPos, startLoc, exprList, forInit)
  3543. }
  3544. this.checkExpressionErrors(refDestructuringErrors, true);
  3545. this.yieldPos = oldYieldPos || this.yieldPos;
  3546. this.awaitPos = oldAwaitPos || this.awaitPos;
  3547. this.awaitIdentPos = oldAwaitIdentPos || this.awaitIdentPos;
  3548. var node$1 = this.startNodeAt(startPos, startLoc);
  3549. node$1.callee = base;
  3550. node$1.arguments = exprList;
  3551. if (optionalSupported) {
  3552. node$1.optional = optional;
  3553. }
  3554. base = this.finishNode(node$1, "CallExpression");
  3555. } else if (this.type === types$1.backQuote) {
  3556. if (optional || optionalChained) {
  3557. this.raise(this.start, "Optional chaining cannot appear in the tag of tagged template expressions");
  3558. }
  3559. var node$2 = this.startNodeAt(startPos, startLoc);
  3560. node$2.tag = base;
  3561. node$2.quasi = this.parseTemplate({isTagged: true});
  3562. base = this.finishNode(node$2, "TaggedTemplateExpression");
  3563. }
  3564. return base
  3565. };
  3566.  
  3567. // Parse an atomic expression — either a single token that is an
  3568. // expression, an expression started by a keyword like `function` or
  3569. // `new`, or an expression wrapped in punctuation like `()`, `[]`,
  3570. // or `{}`.
  3571.  
  3572. pp$5.parseExprAtom = function(refDestructuringErrors, forInit, forNew) {
  3573. // If a division operator appears in an expression position, the
  3574. // tokenizer got confused, and we force it to read a regexp instead.
  3575. if (this.type === types$1.slash) { this.readRegexp(); }
  3576.  
  3577. var node, canBeArrow = this.potentialArrowAt === this.start;
  3578. switch (this.type) {
  3579. case types$1._super:
  3580. if (!this.allowSuper)
  3581. { this.raise(this.start, "'super' keyword outside a method"); }
  3582. node = this.startNode();
  3583. this.next();
  3584. if (this.type === types$1.parenL && !this.allowDirectSuper)
  3585. { this.raise(node.start, "super() call outside constructor of a subclass"); }
  3586. // The `super` keyword can appear at below:
  3587. // SuperProperty:
  3588. // super [ Expression ]
  3589. // super . IdentifierName
  3590. // SuperCall:
  3591. // super ( Arguments )
  3592. if (this.type !== types$1.dot && this.type !== types$1.bracketL && this.type !== types$1.parenL)
  3593. { this.unexpected(); }
  3594. return this.finishNode(node, "Super")
  3595.  
  3596. case types$1._this:
  3597. node = this.startNode();
  3598. this.next();
  3599. return this.finishNode(node, "ThisExpression")
  3600.  
  3601. case types$1.name:
  3602. var startPos = this.start, startLoc = this.startLoc, containsEsc = this.containsEsc;
  3603. var id = this.parseIdent(false);
  3604. if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === "async" && !this.canInsertSemicolon() && this.eat(types$1._function)) {
  3605. this.overrideContext(types.f_expr);
  3606. return this.parseFunction(this.startNodeAt(startPos, startLoc), 0, false, true, forInit)
  3607. }
  3608. if (canBeArrow && !this.canInsertSemicolon()) {
  3609. if (this.eat(types$1.arrow))
  3610. { return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false, forInit) }
  3611. if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === types$1.name && !containsEsc &&
  3612. (!this.potentialArrowInForAwait || this.value !== "of" || this.containsEsc)) {
  3613. id = this.parseIdent(false);
  3614. if (this.canInsertSemicolon() || !this.eat(types$1.arrow))
  3615. { this.unexpected(); }
  3616. return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true, forInit)
  3617. }
  3618. }
  3619. return id
  3620.  
  3621. case types$1.regexp:
  3622. var value = this.value;
  3623. node = this.parseLiteral(value.value);
  3624. node.regex = {pattern: value.pattern, flags: value.flags};
  3625. return node
  3626.  
  3627. case types$1.num: case types$1.string:
  3628. return this.parseLiteral(this.value)
  3629.  
  3630. case types$1._null: case types$1._true: case types$1._false:
  3631. node = this.startNode();
  3632. node.value = this.type === types$1._null ? null : this.type === types$1._true;
  3633. node.raw = this.type.keyword;
  3634. this.next();
  3635. return this.finishNode(node, "Literal")
  3636.  
  3637. case types$1.parenL:
  3638. var start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow, forInit);
  3639. if (refDestructuringErrors) {
  3640. if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr))
  3641. { refDestructuringErrors.parenthesizedAssign = start; }
  3642. if (refDestructuringErrors.parenthesizedBind < 0)
  3643. { refDestructuringErrors.parenthesizedBind = start; }
  3644. }
  3645. return expr
  3646.  
  3647. case types$1.bracketL:
  3648. node = this.startNode();
  3649. this.next();
  3650. node.elements = this.parseExprList(types$1.bracketR, true, true, refDestructuringErrors);
  3651. return this.finishNode(node, "ArrayExpression")
  3652.  
  3653. case types$1.braceL:
  3654. this.overrideContext(types.b_expr);
  3655. return this.parseObj(false, refDestructuringErrors)
  3656.  
  3657. case types$1._function:
  3658. node = this.startNode();
  3659. this.next();
  3660. return this.parseFunction(node, 0)
  3661.  
  3662. case types$1._class:
  3663. return this.parseClass(this.startNode(), false)
  3664.  
  3665. case types$1._new:
  3666. return this.parseNew()
  3667.  
  3668. case types$1.backQuote:
  3669. return this.parseTemplate()
  3670.  
  3671. case types$1._import:
  3672. if (this.options.ecmaVersion >= 11) {
  3673. return this.parseExprImport(forNew)
  3674. } else {
  3675. return this.unexpected()
  3676. }
  3677.  
  3678. default:
  3679. return this.parseExprAtomDefault()
  3680. }
  3681. };
  3682.  
  3683. pp$5.parseExprAtomDefault = function() {
  3684. this.unexpected();
  3685. };
  3686.  
  3687. pp$5.parseExprImport = function(forNew) {
  3688. var node = this.startNode();
  3689.  
  3690. // Consume `import` as an identifier for `import.meta`.
  3691. // Because `this.parseIdent(true)` doesn't check escape sequences, it needs the check of `this.containsEsc`.
  3692. if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword import"); }
  3693. var meta = this.parseIdent(true);
  3694.  
  3695. if (this.type === types$1.parenL && !forNew) {
  3696. return this.parseDynamicImport(node)
  3697. } else if (this.type === types$1.dot) {
  3698. node.meta = meta;
  3699. return this.parseImportMeta(node)
  3700. } else {
  3701. this.unexpected();
  3702. }
  3703. };
  3704.  
  3705. pp$5.parseDynamicImport = function(node) {
  3706. this.next(); // skip `(`
  3707.  
  3708. // Parse node.source.
  3709. node.source = this.parseMaybeAssign();
  3710.  
  3711. // Verify ending.
  3712. if (!this.eat(types$1.parenR)) {
  3713. var errorPos = this.start;
  3714. if (this.eat(types$1.comma) && this.eat(types$1.parenR)) {
  3715. this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()");
  3716. } else {
  3717. this.unexpected(errorPos);
  3718. }
  3719. }
  3720.  
  3721. return this.finishNode(node, "ImportExpression")
  3722. };
  3723.  
  3724. pp$5.parseImportMeta = function(node) {
  3725. this.next(); // skip `.`
  3726.  
  3727. var containsEsc = this.containsEsc;
  3728. node.property = this.parseIdent(true);
  3729.  
  3730. if (node.property.name !== "meta")
  3731. { this.raiseRecoverable(node.property.start, "The only valid meta property for import is 'import.meta'"); }
  3732. if (containsEsc)
  3733. { this.raiseRecoverable(node.start, "'import.meta' must not contain escaped characters"); }
  3734. if (this.options.sourceType !== "module" && !this.options.allowImportExportEverywhere)
  3735. { this.raiseRecoverable(node.start, "Cannot use 'import.meta' outside a module"); }
  3736.  
  3737. return this.finishNode(node, "MetaProperty")
  3738. };
  3739.  
  3740. pp$5.parseLiteral = function(value) {
  3741. var node = this.startNode();
  3742. node.value = value;
  3743. node.raw = this.input.slice(this.start, this.end);
  3744. if (node.raw.charCodeAt(node.raw.length - 1) === 110) { node.bigint = node.raw.slice(0, -1).replace(/_/g, ""); }
  3745. this.next();
  3746. return this.finishNode(node, "Literal")
  3747. };
  3748.  
  3749. pp$5.parseParenExpression = function() {
  3750. this.expect(types$1.parenL);
  3751. var val = this.parseExpression();
  3752. this.expect(types$1.parenR);
  3753. return val
  3754. };
  3755.  
  3756. pp$5.shouldParseArrow = function(exprList) {
  3757. return !this.canInsertSemicolon()
  3758. };
  3759.  
  3760. pp$5.parseParenAndDistinguishExpression = function(canBeArrow, forInit) {
  3761. var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8;
  3762. if (this.options.ecmaVersion >= 6) {
  3763. this.next();
  3764.  
  3765. var innerStartPos = this.start, innerStartLoc = this.startLoc;
  3766. var exprList = [], first = true, lastIsComma = false;
  3767. var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart;
  3768. this.yieldPos = 0;
  3769. this.awaitPos = 0;
  3770. // Do not save awaitIdentPos to allow checking awaits nested in parameters
  3771. while (this.type !== types$1.parenR) {
  3772. first ? first = false : this.expect(types$1.comma);
  3773. if (allowTrailingComma && this.afterTrailingComma(types$1.parenR, true)) {
  3774. lastIsComma = true;
  3775. break
  3776. } else if (this.type === types$1.ellipsis) {
  3777. spreadStart = this.start;
  3778. exprList.push(this.parseParenItem(this.parseRestBinding()));
  3779. if (this.type === types$1.comma) {
  3780. this.raiseRecoverable(
  3781. this.start,
  3782. "Comma is not permitted after the rest element"
  3783. );
  3784. }
  3785. break
  3786. } else {
  3787. exprList.push(this.parseMaybeAssign(false, refDestructuringErrors, this.parseParenItem));
  3788. }
  3789. }
  3790. var innerEndPos = this.lastTokEnd, innerEndLoc = this.lastTokEndLoc;
  3791. this.expect(types$1.parenR);
  3792.  
  3793. if (canBeArrow && this.shouldParseArrow(exprList) && this.eat(types$1.arrow)) {
  3794. this.checkPatternErrors(refDestructuringErrors, false);
  3795. this.checkYieldAwaitInDefaultParams();
  3796. this.yieldPos = oldYieldPos;
  3797. this.awaitPos = oldAwaitPos;
  3798. return this.parseParenArrowList(startPos, startLoc, exprList, forInit)
  3799. }
  3800.  
  3801. if (!exprList.length || lastIsComma) { this.unexpected(this.lastTokStart); }
  3802. if (spreadStart) { this.unexpected(spreadStart); }
  3803. this.checkExpressionErrors(refDestructuringErrors, true);
  3804. this.yieldPos = oldYieldPos || this.yieldPos;
  3805. this.awaitPos = oldAwaitPos || this.awaitPos;
  3806.  
  3807. if (exprList.length > 1) {
  3808. val = this.startNodeAt(innerStartPos, innerStartLoc);
  3809. val.expressions = exprList;
  3810. this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc);
  3811. } else {
  3812. val = exprList[0];
  3813. }
  3814. } else {
  3815. val = this.parseParenExpression();
  3816. }
  3817.  
  3818. if (this.options.preserveParens) {
  3819. var par = this.startNodeAt(startPos, startLoc);
  3820. par.expression = val;
  3821. return this.finishNode(par, "ParenthesizedExpression")
  3822. } else {
  3823. return val
  3824. }
  3825. };
  3826.  
  3827. pp$5.parseParenItem = function(item) {
  3828. return item
  3829. };
  3830.  
  3831. pp$5.parseParenArrowList = function(startPos, startLoc, exprList, forInit) {
  3832. return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, false, forInit)
  3833. };
  3834.  
  3835. // New's precedence is slightly tricky. It must allow its argument to
  3836. // be a `[]` or dot subscript expression, but not a call — at least,
  3837. // not without wrapping it in parentheses. Thus, it uses the noCalls
  3838. // argument to parseSubscripts to prevent it from consuming the
  3839. // argument list.
  3840.  
  3841. var empty = [];
  3842.  
  3843. pp$5.parseNew = function() {
  3844. if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword new"); }
  3845. var node = this.startNode();
  3846. this.next();
  3847. if (this.options.ecmaVersion >= 6 && this.type === types$1.dot) {
  3848. var meta = this.startNodeAt(node.start, node.startLoc);
  3849. meta.name = "new";
  3850. node.meta = this.finishNode(meta, "Identifier");
  3851. this.next();
  3852. var containsEsc = this.containsEsc;
  3853. node.property = this.parseIdent(true);
  3854. if (node.property.name !== "target")
  3855. { this.raiseRecoverable(node.property.start, "The only valid meta property for new is 'new.target'"); }
  3856. if (containsEsc)
  3857. { this.raiseRecoverable(node.start, "'new.target' must not contain escaped characters"); }
  3858. if (!this.allowNewDotTarget)
  3859. { this.raiseRecoverable(node.start, "'new.target' can only be used in functions and class static block"); }
  3860. return this.finishNode(node, "MetaProperty")
  3861. }
  3862. var startPos = this.start, startLoc = this.startLoc;
  3863. node.callee = this.parseSubscripts(this.parseExprAtom(null, false, true), startPos, startLoc, true, false);
  3864. if (this.eat(types$1.parenL)) { node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false); }
  3865. else { node.arguments = empty; }
  3866. return this.finishNode(node, "NewExpression")
  3867. };
  3868.  
  3869. // Parse template expression.
  3870.  
  3871. pp$5.parseTemplateElement = function(ref) {
  3872. var isTagged = ref.isTagged;
  3873.  
  3874. var elem = this.startNode();
  3875. if (this.type === types$1.invalidTemplate) {
  3876. if (!isTagged) {
  3877. this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal");
  3878. }
  3879. elem.value = {
  3880. raw: this.value,
  3881. cooked: null
  3882. };
  3883. } else {
  3884. elem.value = {
  3885. raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, "\n"),
  3886. cooked: this.value
  3887. };
  3888. }
  3889. this.next();
  3890. elem.tail = this.type === types$1.backQuote;
  3891. return this.finishNode(elem, "TemplateElement")
  3892. };
  3893.  
  3894. pp$5.parseTemplate = function(ref) {
  3895. if ( ref === void 0 ) ref = {};
  3896. var isTagged = ref.isTagged; if ( isTagged === void 0 ) isTagged = false;
  3897.  
  3898. var node = this.startNode();
  3899. this.next();
  3900. node.expressions = [];
  3901. var curElt = this.parseTemplateElement({isTagged: isTagged});
  3902. node.quasis = [curElt];
  3903. while (!curElt.tail) {
  3904. if (this.type === types$1.eof) { this.raise(this.pos, "Unterminated template literal"); }
  3905. this.expect(types$1.dollarBraceL);
  3906. node.expressions.push(this.parseExpression());
  3907. this.expect(types$1.braceR);
  3908. node.quasis.push(curElt = this.parseTemplateElement({isTagged: isTagged}));
  3909. }
  3910. this.next();
  3911. return this.finishNode(node, "TemplateLiteral")
  3912. };
  3913.  
  3914. pp$5.isAsyncProp = function(prop) {
  3915. return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" &&
  3916. (this.type === types$1.name || this.type === types$1.num || this.type === types$1.string || this.type === types$1.bracketL || this.type.keyword || (this.options.ecmaVersion >= 9 && this.type === types$1.star)) &&
  3917. !lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
  3918. };
  3919.  
  3920. // Parse an object literal or binding pattern.
  3921.  
  3922. pp$5.parseObj = function(isPattern, refDestructuringErrors) {
  3923. var node = this.startNode(), first = true, propHash = {};
  3924. node.properties = [];
  3925. this.next();
  3926. while (!this.eat(types$1.braceR)) {
  3927. if (!first) {
  3928. this.expect(types$1.comma);
  3929. if (this.options.ecmaVersion >= 5 && this.afterTrailingComma(types$1.braceR)) { break }
  3930. } else { first = false; }
  3931.  
  3932. var prop = this.parseProperty(isPattern, refDestructuringErrors);
  3933. if (!isPattern) { this.checkPropClash(prop, propHash, refDestructuringErrors); }
  3934. node.properties.push(prop);
  3935. }
  3936. return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression")
  3937. };
  3938.  
  3939. pp$5.parseProperty = function(isPattern, refDestructuringErrors) {
  3940. var prop = this.startNode(), isGenerator, isAsync, startPos, startLoc;
  3941. if (this.options.ecmaVersion >= 9 && this.eat(types$1.ellipsis)) {
  3942. if (isPattern) {
  3943. prop.argument = this.parseIdent(false);
  3944. if (this.type === types$1.comma) {
  3945. this.raiseRecoverable(this.start, "Comma is not permitted after the rest element");
  3946. }
  3947. return this.finishNode(prop, "RestElement")
  3948. }
  3949. // Parse argument.
  3950. prop.argument = this.parseMaybeAssign(false, refDestructuringErrors);
  3951. // To disallow trailing comma via `this.toAssignable()`.
  3952. if (this.type === types$1.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0) {
  3953. refDestructuringErrors.trailingComma = this.start;
  3954. }
  3955. // Finish
  3956. return this.finishNode(prop, "SpreadElement")
  3957. }
  3958. if (this.options.ecmaVersion >= 6) {
  3959. prop.method = false;
  3960. prop.shorthand = false;
  3961. if (isPattern || refDestructuringErrors) {
  3962. startPos = this.start;
  3963. startLoc = this.startLoc;
  3964. }
  3965. if (!isPattern)
  3966. { isGenerator = this.eat(types$1.star); }
  3967. }
  3968. var containsEsc = this.containsEsc;
  3969. this.parsePropertyName(prop);
  3970. if (!isPattern && !containsEsc && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) {
  3971. isAsync = true;
  3972. isGenerator = this.options.ecmaVersion >= 9 && this.eat(types$1.star);
  3973. this.parsePropertyName(prop);
  3974. } else {
  3975. isAsync = false;
  3976. }
  3977. this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc);
  3978. return this.finishNode(prop, "Property")
  3979. };
  3980.  
  3981. pp$5.parseGetterSetter = function(prop) {
  3982. prop.kind = prop.key.name;
  3983. this.parsePropertyName(prop);
  3984. prop.value = this.parseMethod(false);
  3985. var paramCount = prop.kind === "get" ? 0 : 1;
  3986. if (prop.value.params.length !== paramCount) {
  3987. var start = prop.value.start;
  3988. if (prop.kind === "get")
  3989. { this.raiseRecoverable(start, "getter should have no params"); }
  3990. else
  3991. { this.raiseRecoverable(start, "setter should have exactly one param"); }
  3992. } else {
  3993. if (prop.kind === "set" && prop.value.params[0].type === "RestElement")
  3994. { this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params"); }
  3995. }
  3996. };
  3997.  
  3998. pp$5.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) {
  3999. if ((isGenerator || isAsync) && this.type === types$1.colon)
  4000. { this.unexpected(); }
  4001.  
  4002. if (this.eat(types$1.colon)) {
  4003. prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors);
  4004. prop.kind = "init";
  4005. } else if (this.options.ecmaVersion >= 6 && this.type === types$1.parenL) {
  4006. if (isPattern) { this.unexpected(); }
  4007. prop.kind = "init";
  4008. prop.method = true;
  4009. prop.value = this.parseMethod(isGenerator, isAsync);
  4010. } else if (!isPattern && !containsEsc &&
  4011. this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" &&
  4012. (prop.key.name === "get" || prop.key.name === "set") &&
  4013. (this.type !== types$1.comma && this.type !== types$1.braceR && this.type !== types$1.eq)) {
  4014. if (isGenerator || isAsync) { this.unexpected(); }
  4015. this.parseGetterSetter(prop);
  4016. } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
  4017. if (isGenerator || isAsync) { this.unexpected(); }
  4018. this.checkUnreserved(prop.key);
  4019. if (prop.key.name === "await" && !this.awaitIdentPos)
  4020. { this.awaitIdentPos = startPos; }
  4021. prop.kind = "init";
  4022. if (isPattern) {
  4023. prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key));
  4024. } else if (this.type === types$1.eq && refDestructuringErrors) {
  4025. if (refDestructuringErrors.shorthandAssign < 0)
  4026. { refDestructuringErrors.shorthandAssign = this.start; }
  4027. prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key));
  4028. } else {
  4029. prop.value = this.copyNode(prop.key);
  4030. }
  4031. prop.shorthand = true;
  4032. } else { this.unexpected(); }
  4033. };
  4034.  
  4035. pp$5.parsePropertyName = function(prop) {
  4036. if (this.options.ecmaVersion >= 6) {
  4037. if (this.eat(types$1.bracketL)) {
  4038. prop.computed = true;
  4039. prop.key = this.parseMaybeAssign();
  4040. this.expect(types$1.bracketR);
  4041. return prop.key
  4042. } else {
  4043. prop.computed = false;
  4044. }
  4045. }
  4046. return prop.key = this.type === types$1.num || this.type === types$1.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never")
  4047. };
  4048.  
  4049. // Initialize empty function node.
  4050.  
  4051. pp$5.initFunction = function(node) {
  4052. node.id = null;
  4053. if (this.options.ecmaVersion >= 6) { node.generator = node.expression = false; }
  4054. if (this.options.ecmaVersion >= 8) { node.async = false; }
  4055. };
  4056.  
  4057. // Parse object or class method.
  4058.  
  4059. pp$5.parseMethod = function(isGenerator, isAsync, allowDirectSuper) {
  4060. var node = this.startNode(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
  4061.  
  4062. this.initFunction(node);
  4063. if (this.options.ecmaVersion >= 6)
  4064. { node.generator = isGenerator; }
  4065. if (this.options.ecmaVersion >= 8)
  4066. { node.async = !!isAsync; }
  4067.  
  4068. this.yieldPos = 0;
  4069. this.awaitPos = 0;
  4070. this.awaitIdentPos = 0;
  4071. this.enterScope(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0));
  4072.  
  4073. this.expect(types$1.parenL);
  4074. node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8);
  4075. this.checkYieldAwaitInDefaultParams();
  4076. this.parseFunctionBody(node, false, true, false);
  4077.  
  4078. this.yieldPos = oldYieldPos;
  4079. this.awaitPos = oldAwaitPos;
  4080. this.awaitIdentPos = oldAwaitIdentPos;
  4081. return this.finishNode(node, "FunctionExpression")
  4082. };
  4083.  
  4084. // Parse arrow function expression with given parameters.
  4085.  
  4086. pp$5.parseArrowExpression = function(node, params, isAsync, forInit) {
  4087. var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
  4088.  
  4089. this.enterScope(functionFlags(isAsync, false) | SCOPE_ARROW);
  4090. this.initFunction(node);
  4091. if (this.options.ecmaVersion >= 8) { node.async = !!isAsync; }
  4092.  
  4093. this.yieldPos = 0;
  4094. this.awaitPos = 0;
  4095. this.awaitIdentPos = 0;
  4096.  
  4097. node.params = this.toAssignableList(params, true);
  4098. this.parseFunctionBody(node, true, false, forInit);
  4099.  
  4100. this.yieldPos = oldYieldPos;
  4101. this.awaitPos = oldAwaitPos;
  4102. this.awaitIdentPos = oldAwaitIdentPos;
  4103. return this.finishNode(node, "ArrowFunctionExpression")
  4104. };
  4105.  
  4106. // Parse function body and check parameters.
  4107.  
  4108. pp$5.parseFunctionBody = function(node, isArrowFunction, isMethod, forInit) {
  4109. var isExpression = isArrowFunction && this.type !== types$1.braceL;
  4110. var oldStrict = this.strict, useStrict = false;
  4111.  
  4112. if (isExpression) {
  4113. node.body = this.parseMaybeAssign(forInit);
  4114. node.expression = true;
  4115. this.checkParams(node, false);
  4116. } else {
  4117. var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params);
  4118. if (!oldStrict || nonSimple) {
  4119. useStrict = this.strictDirective(this.end);
  4120. // If this is a strict mode function, verify that argument names
  4121. // are not repeated, and it does not try to bind the words `eval`
  4122. // or `arguments`.
  4123. if (useStrict && nonSimple)
  4124. { this.raiseRecoverable(node.start, "Illegal 'use strict' directive in function with non-simple parameter list"); }
  4125. }
  4126. // Start a new scope with regard to labels and the `inFunction`
  4127. // flag (restore them to their old value afterwards).
  4128. var oldLabels = this.labels;
  4129. this.labels = [];
  4130. if (useStrict) { this.strict = true; }
  4131.  
  4132. // Add the params to varDeclaredNames to ensure that an error is thrown
  4133. // if a let/const declaration in the function clashes with one of the params.
  4134. this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params));
  4135. // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval'
  4136. if (this.strict && node.id) { this.checkLValSimple(node.id, BIND_OUTSIDE); }
  4137. node.body = this.parseBlock(false, undefined, useStrict && !oldStrict);
  4138. node.expression = false;
  4139. this.adaptDirectivePrologue(node.body.body);
  4140. this.labels = oldLabels;
  4141. }
  4142. this.exitScope();
  4143. };
  4144.  
  4145. pp$5.isSimpleParamList = function(params) {
  4146. for (var i = 0, list = params; i < list.length; i += 1)
  4147. {
  4148. var param = list[i];
  4149.  
  4150. if (param.type !== "Identifier") { return false
  4151. } }
  4152. return true
  4153. };
  4154.  
  4155. // Checks function params for various disallowed patterns such as using "eval"
  4156. // or "arguments" and duplicate parameters.
  4157.  
  4158. pp$5.checkParams = function(node, allowDuplicates) {
  4159. var nameHash = Object.create(null);
  4160. for (var i = 0, list = node.params; i < list.length; i += 1)
  4161. {
  4162. var param = list[i];
  4163.  
  4164. this.checkLValInnerPattern(param, BIND_VAR, allowDuplicates ? null : nameHash);
  4165. }
  4166. };
  4167.  
  4168. // Parses a comma-separated list of expressions, and returns them as
  4169. // an array. `close` is the token type that ends the list, and
  4170. // `allowEmpty` can be turned on to allow subsequent commas with
  4171. // nothing in between them to be parsed as `null` (which is needed
  4172. // for array literals).
  4173.  
  4174. pp$5.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) {
  4175. var elts = [], first = true;
  4176. while (!this.eat(close)) {
  4177. if (!first) {
  4178. this.expect(types$1.comma);
  4179. if (allowTrailingComma && this.afterTrailingComma(close)) { break }
  4180. } else { first = false; }
  4181.  
  4182. var elt = (void 0);
  4183. if (allowEmpty && this.type === types$1.comma)
  4184. { elt = null; }
  4185. else if (this.type === types$1.ellipsis) {
  4186. elt = this.parseSpread(refDestructuringErrors);
  4187. if (refDestructuringErrors && this.type === types$1.comma && refDestructuringErrors.trailingComma < 0)
  4188. { refDestructuringErrors.trailingComma = this.start; }
  4189. } else {
  4190. elt = this.parseMaybeAssign(false, refDestructuringErrors);
  4191. }
  4192. elts.push(elt);
  4193. }
  4194. return elts
  4195. };
  4196.  
  4197. pp$5.checkUnreserved = function(ref) {
  4198. var start = ref.start;
  4199. var end = ref.end;
  4200. var name = ref.name;
  4201.  
  4202. if (this.inGenerator && name === "yield")
  4203. { this.raiseRecoverable(start, "Cannot use 'yield' as identifier inside a generator"); }
  4204. if (this.inAsync && name === "await")
  4205. { this.raiseRecoverable(start, "Cannot use 'await' as identifier inside an async function"); }
  4206. if (this.currentThisScope().inClassFieldInit && name === "arguments")
  4207. { this.raiseRecoverable(start, "Cannot use 'arguments' in class field initializer"); }
  4208. if (this.inClassStaticBlock && (name === "arguments" || name === "await"))
  4209. { this.raise(start, ("Cannot use " + name + " in class static initialization block")); }
  4210. if (this.keywords.test(name))
  4211. { this.raise(start, ("Unexpected keyword '" + name + "'")); }
  4212. if (this.options.ecmaVersion < 6 &&
  4213. this.input.slice(start, end).indexOf("\\") !== -1) { return }
  4214. var re = this.strict ? this.reservedWordsStrict : this.reservedWords;
  4215. if (re.test(name)) {
  4216. if (!this.inAsync && name === "await")
  4217. { this.raiseRecoverable(start, "Cannot use keyword 'await' outside an async function"); }
  4218. this.raiseRecoverable(start, ("The keyword '" + name + "' is reserved"));
  4219. }
  4220. };
  4221.  
  4222. // Parse the next token as an identifier. If `liberal` is true (used
  4223. // when parsing properties), it will also convert keywords into
  4224. // identifiers.
  4225.  
  4226. pp$5.parseIdent = function(liberal) {
  4227. var node = this.parseIdentNode();
  4228. this.next(!!liberal);
  4229. this.finishNode(node, "Identifier");
  4230. if (!liberal) {
  4231. this.checkUnreserved(node);
  4232. if (node.name === "await" && !this.awaitIdentPos)
  4233. { this.awaitIdentPos = node.start; }
  4234. }
  4235. return node
  4236. };
  4237.  
  4238. pp$5.parseIdentNode = function() {
  4239. var node = this.startNode();
  4240. if (this.type === types$1.name) {
  4241. node.name = this.value;
  4242. } else if (this.type.keyword) {
  4243. node.name = this.type.keyword;
  4244.  
  4245. // To fix https://github.com/acornjs/acorn/issues/575
  4246. // `class` and `function` keywords push new context into this.context.
  4247. // But there is no chance to pop the context if the keyword is consumed as an identifier such as a property name.
  4248. // If the previous token is a dot, this does not apply because the context-managing code already ignored the keyword
  4249. if ((node.name === "class" || node.name === "function") &&
  4250. (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) {
  4251. this.context.pop();
  4252. }
  4253. this.type = types$1.name;
  4254. } else {
  4255. this.unexpected();
  4256. }
  4257. return node
  4258. };
  4259.  
  4260. pp$5.parsePrivateIdent = function() {
  4261. var node = this.startNode();
  4262. if (this.type === types$1.privateId) {
  4263. node.name = this.value;
  4264. } else {
  4265. this.unexpected();
  4266. }
  4267. this.next();
  4268. this.finishNode(node, "PrivateIdentifier");
  4269.  
  4270. // For validating existence
  4271. if (this.options.checkPrivateFields) {
  4272. if (this.privateNameStack.length === 0) {
  4273. this.raise(node.start, ("Private field '#" + (node.name) + "' must be declared in an enclosing class"));
  4274. } else {
  4275. this.privateNameStack[this.privateNameStack.length - 1].used.push(node);
  4276. }
  4277. }
  4278.  
  4279. return node
  4280. };
  4281.  
  4282. // Parses yield expression inside generator.
  4283.  
  4284. pp$5.parseYield = function(forInit) {
  4285. if (!this.yieldPos) { this.yieldPos = this.start; }
  4286.  
  4287. var node = this.startNode();
  4288. this.next();
  4289. if (this.type === types$1.semi || this.canInsertSemicolon() || (this.type !== types$1.star && !this.type.startsExpr)) {
  4290. node.delegate = false;
  4291. node.argument = null;
  4292. } else {
  4293. node.delegate = this.eat(types$1.star);
  4294. node.argument = this.parseMaybeAssign(forInit);
  4295. }
  4296. return this.finishNode(node, "YieldExpression")
  4297. };
  4298.  
  4299. pp$5.parseAwait = function(forInit) {
  4300. if (!this.awaitPos) { this.awaitPos = this.start; }
  4301.  
  4302. var node = this.startNode();
  4303. this.next();
  4304. node.argument = this.parseMaybeUnary(null, true, false, forInit);
  4305. return this.finishNode(node, "AwaitExpression")
  4306. };
  4307.  
  4308. var pp$4 = Parser.prototype;
  4309.  
  4310. // This function is used to raise exceptions on parse errors. It
  4311. // takes an offset integer (into the current `input`) to indicate
  4312. // the location of the error, attaches the position to the end
  4313. // of the error message, and then raises a `SyntaxError` with that
  4314. // message.
  4315.  
  4316. pp$4.raise = function(pos, message) {
  4317. var loc = getLineInfo(this.input, pos);
  4318. message += " (" + loc.line + ":" + loc.column + ")";
  4319. var err = new SyntaxError(message);
  4320. err.pos = pos; err.loc = loc; err.raisedAt = this.pos;
  4321. throw err
  4322. };
  4323.  
  4324. pp$4.raiseRecoverable = pp$4.raise;
  4325.  
  4326. pp$4.curPosition = function() {
  4327. if (this.options.locations) {
  4328. return new Position(this.curLine, this.pos - this.lineStart)
  4329. }
  4330. };
  4331.  
  4332. var pp$3 = Parser.prototype;
  4333.  
  4334. var Scope = function Scope(flags) {
  4335. this.flags = flags;
  4336. // A list of var-declared names in the current lexical scope
  4337. this.var = [];
  4338. // A list of lexically-declared names in the current lexical scope
  4339. this.lexical = [];
  4340. // A list of lexically-declared FunctionDeclaration names in the current lexical scope
  4341. this.functions = [];
  4342. // A switch to disallow the identifier reference 'arguments'
  4343. this.inClassFieldInit = false;
  4344. };
  4345.  
  4346. // The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names.
  4347.  
  4348. pp$3.enterScope = function(flags) {
  4349. this.scopeStack.push(new Scope(flags));
  4350. };
  4351.  
  4352. pp$3.exitScope = function() {
  4353. this.scopeStack.pop();
  4354. };
  4355.  
  4356. // The spec says:
  4357. // > At the top level of a function, or script, function declarations are
  4358. // > treated like var declarations rather than like lexical declarations.
  4359. pp$3.treatFunctionsAsVarInScope = function(scope) {
  4360. return (scope.flags & SCOPE_FUNCTION) || !this.inModule && (scope.flags & SCOPE_TOP)
  4361. };
  4362.  
  4363. pp$3.declareName = function(name, bindingType, pos) {
  4364. var redeclared = false;
  4365. if (bindingType === BIND_LEXICAL) {
  4366. var scope = this.currentScope();
  4367. redeclared = scope.lexical.indexOf(name) > -1 || scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1;
  4368. scope.lexical.push(name);
  4369. if (this.inModule && (scope.flags & SCOPE_TOP))
  4370. { delete this.undefinedExports[name]; }
  4371. } else if (bindingType === BIND_SIMPLE_CATCH) {
  4372. var scope$1 = this.currentScope();
  4373. scope$1.lexical.push(name);
  4374. } else if (bindingType === BIND_FUNCTION) {
  4375. var scope$2 = this.currentScope();
  4376. if (this.treatFunctionsAsVar)
  4377. { redeclared = scope$2.lexical.indexOf(name) > -1; }
  4378. else
  4379. { redeclared = scope$2.lexical.indexOf(name) > -1 || scope$2.var.indexOf(name) > -1; }
  4380. scope$2.functions.push(name);
  4381. } else {
  4382. for (var i = this.scopeStack.length - 1; i >= 0; --i) {
  4383. var scope$3 = this.scopeStack[i];
  4384. if (scope$3.lexical.indexOf(name) > -1 && !((scope$3.flags & SCOPE_SIMPLE_CATCH) && scope$3.lexical[0] === name) ||
  4385. !this.treatFunctionsAsVarInScope(scope$3) && scope$3.functions.indexOf(name) > -1) {
  4386. redeclared = true;
  4387. break
  4388. }
  4389. scope$3.var.push(name);
  4390. if (this.inModule && (scope$3.flags & SCOPE_TOP))
  4391. { delete this.undefinedExports[name]; }
  4392. if (scope$3.flags & SCOPE_VAR) { break }
  4393. }
  4394. }
  4395. if (redeclared) { this.raiseRecoverable(pos, ("Identifier '" + name + "' has already been declared")); }
  4396. };
  4397.  
  4398. pp$3.checkLocalExport = function(id) {
  4399. // scope.functions must be empty as Module code is always strict.
  4400. if (this.scopeStack[0].lexical.indexOf(id.name) === -1 &&
  4401. this.scopeStack[0].var.indexOf(id.name) === -1) {
  4402. this.undefinedExports[id.name] = id;
  4403. }
  4404. };
  4405.  
  4406. pp$3.currentScope = function() {
  4407. return this.scopeStack[this.scopeStack.length - 1]
  4408. };
  4409.  
  4410. pp$3.currentVarScope = function() {
  4411. for (var i = this.scopeStack.length - 1;; i--) {
  4412. var scope = this.scopeStack[i];
  4413. if (scope.flags & SCOPE_VAR) { return scope }
  4414. }
  4415. };
  4416.  
  4417. // Could be useful for `this`, `new.target`, `super()`, `super.property`, and `super[property]`.
  4418. pp$3.currentThisScope = function() {
  4419. for (var i = this.scopeStack.length - 1;; i--) {
  4420. var scope = this.scopeStack[i];
  4421. if (scope.flags & SCOPE_VAR && !(scope.flags & SCOPE_ARROW)) { return scope }
  4422. }
  4423. };
  4424.  
  4425. var Node = function Node(parser, pos, loc) {
  4426. this.type = "";
  4427. this.start = pos;
  4428. this.end = 0;
  4429. if (parser.options.locations)
  4430. { this.loc = new SourceLocation(parser, loc); }
  4431. if (parser.options.directSourceFile)
  4432. { this.sourceFile = parser.options.directSourceFile; }
  4433. if (parser.options.ranges)
  4434. { this.range = [pos, 0]; }
  4435. };
  4436.  
  4437. // Start an AST node, attaching a start offset.
  4438.  
  4439. var pp$2 = Parser.prototype;
  4440.  
  4441. pp$2.startNode = function() {
  4442. return new Node(this, this.start, this.startLoc)
  4443. };
  4444.  
  4445. pp$2.startNodeAt = function(pos, loc) {
  4446. return new Node(this, pos, loc)
  4447. };
  4448.  
  4449. // Finish an AST node, adding `type` and `end` properties.
  4450.  
  4451. function finishNodeAt(node, type, pos, loc) {
  4452. node.type = type;
  4453. node.end = pos;
  4454. if (this.options.locations)
  4455. { node.loc.end = loc; }
  4456. if (this.options.ranges)
  4457. { node.range[1] = pos; }
  4458. return node
  4459. }
  4460.  
  4461. pp$2.finishNode = function(node, type) {
  4462. return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc)
  4463. };
  4464.  
  4465. // Finish node at given position
  4466.  
  4467. pp$2.finishNodeAt = function(node, type, pos, loc) {
  4468. return finishNodeAt.call(this, node, type, pos, loc)
  4469. };
  4470.  
  4471. pp$2.copyNode = function(node) {
  4472. var newNode = new Node(this, node.start, this.startLoc);
  4473. for (var prop in node) { newNode[prop] = node[prop]; }
  4474. return newNode
  4475. };
  4476.  
  4477. // This file contains Unicode properties extracted from the ECMAScript specification.
  4478. // The lists are extracted like so:
  4479. // $$('#table-binary-unicode-properties > figure > table > tbody > tr > td:nth-child(1) code').map(el => el.innerText)
  4480.  
  4481. // #table-binary-unicode-properties
  4482. var ecma9BinaryProperties = "ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS";
  4483. var ecma10BinaryProperties = ecma9BinaryProperties + " Extended_Pictographic";
  4484. var ecma11BinaryProperties = ecma10BinaryProperties;
  4485. var ecma12BinaryProperties = ecma11BinaryProperties + " EBase EComp EMod EPres ExtPict";
  4486. var ecma13BinaryProperties = ecma12BinaryProperties;
  4487. var ecma14BinaryProperties = ecma13BinaryProperties;
  4488.  
  4489. var unicodeBinaryProperties = {
  4490. 9: ecma9BinaryProperties,
  4491. 10: ecma10BinaryProperties,
  4492. 11: ecma11BinaryProperties,
  4493. 12: ecma12BinaryProperties,
  4494. 13: ecma13BinaryProperties,
  4495. 14: ecma14BinaryProperties
  4496. };
  4497.  
  4498. // #table-binary-unicode-properties-of-strings
  4499. var ecma14BinaryPropertiesOfStrings = "Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji";
  4500.  
  4501. var unicodeBinaryPropertiesOfStrings = {
  4502. 9: "",
  4503. 10: "",
  4504. 11: "",
  4505. 12: "",
  4506. 13: "",
  4507. 14: ecma14BinaryPropertiesOfStrings
  4508. };
  4509.  
  4510. // #table-unicode-general-category-values
  4511. var unicodeGeneralCategoryValues = "Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu";
  4512.  
  4513. // #table-unicode-script-values
  4514. var ecma9ScriptValues = "Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb";
  4515. var ecma10ScriptValues = ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd";
  4516. var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho";
  4517. var ecma12ScriptValues = ecma11ScriptValues + " Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi";
  4518. var ecma13ScriptValues = ecma12ScriptValues + " Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith";
  4519. var ecma14ScriptValues = ecma13ScriptValues + " Hrkt Katakana_Or_Hiragana Kawi Nag_Mundari Nagm Unknown Zzzz";
  4520.  
  4521. var unicodeScriptValues = {
  4522. 9: ecma9ScriptValues,
  4523. 10: ecma10ScriptValues,
  4524. 11: ecma11ScriptValues,
  4525. 12: ecma12ScriptValues,
  4526. 13: ecma13ScriptValues,
  4527. 14: ecma14ScriptValues
  4528. };
  4529.  
  4530. var data = {};
  4531. function buildUnicodeData(ecmaVersion) {
  4532. var d = data[ecmaVersion] = {
  4533. binary: wordsRegexp(unicodeBinaryProperties[ecmaVersion] + " " + unicodeGeneralCategoryValues),
  4534. binaryOfStrings: wordsRegexp(unicodeBinaryPropertiesOfStrings[ecmaVersion]),
  4535. nonBinary: {
  4536. General_Category: wordsRegexp(unicodeGeneralCategoryValues),
  4537. Script: wordsRegexp(unicodeScriptValues[ecmaVersion])
  4538. }
  4539. };
  4540. d.nonBinary.Script_Extensions = d.nonBinary.Script;
  4541.  
  4542. d.nonBinary.gc = d.nonBinary.General_Category;
  4543. d.nonBinary.sc = d.nonBinary.Script;
  4544. d.nonBinary.scx = d.nonBinary.Script_Extensions;
  4545. }
  4546.  
  4547. for (var i = 0, list = [9, 10, 11, 12, 13, 14]; i < list.length; i += 1) {
  4548. var ecmaVersion = list[i];
  4549.  
  4550. buildUnicodeData(ecmaVersion);
  4551. }
  4552.  
  4553. var pp$1 = Parser.prototype;
  4554.  
  4555. var RegExpValidationState = function RegExpValidationState(parser) {
  4556. this.parser = parser;
  4557. this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "") + (parser.options.ecmaVersion >= 15 ? "v" : "");
  4558. this.unicodeProperties = data[parser.options.ecmaVersion >= 14 ? 14 : parser.options.ecmaVersion];
  4559. this.source = "";
  4560. this.flags = "";
  4561. this.start = 0;
  4562. this.switchU = false;
  4563. this.switchV = false;
  4564. this.switchN = false;
  4565. this.pos = 0;
  4566. this.lastIntValue = 0;
  4567. this.lastStringValue = "";
  4568. this.lastAssertionIsQuantifiable = false;
  4569. this.numCapturingParens = 0;
  4570. this.maxBackReference = 0;
  4571. this.groupNames = [];
  4572. this.backReferenceNames = [];
  4573. };
  4574.  
  4575. RegExpValidationState.prototype.reset = function reset (start, pattern, flags) {
  4576. var unicodeSets = flags.indexOf("v") !== -1;
  4577. var unicode = flags.indexOf("u") !== -1;
  4578. this.start = start | 0;
  4579. this.source = pattern + "";
  4580. this.flags = flags;
  4581. if (unicodeSets && this.parser.options.ecmaVersion >= 15) {
  4582. this.switchU = true;
  4583. this.switchV = true;
  4584. this.switchN = true;
  4585. } else {
  4586. this.switchU = unicode && this.parser.options.ecmaVersion >= 6;
  4587. this.switchV = false;
  4588. this.switchN = unicode && this.parser.options.ecmaVersion >= 9;
  4589. }
  4590. };
  4591.  
  4592. RegExpValidationState.prototype.raise = function raise (message) {
  4593. this.parser.raiseRecoverable(this.start, ("Invalid regular expression: /" + (this.source) + "/: " + message));
  4594. };
  4595.  
  4596. // If u flag is given, this returns the code point at the index (it combines a surrogate pair).
  4597. // Otherwise, this returns the code unit of the index (can be a part of a surrogate pair).
  4598. RegExpValidationState.prototype.at = function at (i, forceU) {
  4599. if ( forceU === void 0 ) forceU = false;
  4600.  
  4601. var s = this.source;
  4602. var l = s.length;
  4603. if (i >= l) {
  4604. return -1
  4605. }
  4606. var c = s.charCodeAt(i);
  4607. if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) {
  4608. return c
  4609. }
  4610. var next = s.charCodeAt(i + 1);
  4611. return next >= 0xDC00 && next <= 0xDFFF ? (c << 10) + next - 0x35FDC00 : c
  4612. };
  4613.  
  4614. RegExpValidationState.prototype.nextIndex = function nextIndex (i, forceU) {
  4615. if ( forceU === void 0 ) forceU = false;
  4616.  
  4617. var s = this.source;
  4618. var l = s.length;
  4619. if (i >= l) {
  4620. return l
  4621. }
  4622. var c = s.charCodeAt(i), next;
  4623. if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l ||
  4624. (next = s.charCodeAt(i + 1)) < 0xDC00 || next > 0xDFFF) {
  4625. return i + 1
  4626. }
  4627. return i + 2
  4628. };
  4629.  
  4630. RegExpValidationState.prototype.current = function current (forceU) {
  4631. if ( forceU === void 0 ) forceU = false;
  4632.  
  4633. return this.at(this.pos, forceU)
  4634. };
  4635.  
  4636. RegExpValidationState.prototype.lookahead = function lookahead (forceU) {
  4637. if ( forceU === void 0 ) forceU = false;
  4638.  
  4639. return this.at(this.nextIndex(this.pos, forceU), forceU)
  4640. };
  4641.  
  4642. RegExpValidationState.prototype.advance = function advance (forceU) {
  4643. if ( forceU === void 0 ) forceU = false;
  4644.  
  4645. this.pos = this.nextIndex(this.pos, forceU);
  4646. };
  4647.  
  4648. RegExpValidationState.prototype.eat = function eat (ch, forceU) {
  4649. if ( forceU === void 0 ) forceU = false;
  4650.  
  4651. if (this.current(forceU) === ch) {
  4652. this.advance(forceU);
  4653. return true
  4654. }
  4655. return false
  4656. };
  4657.  
  4658. RegExpValidationState.prototype.eatChars = function eatChars (chs, forceU) {
  4659. if ( forceU === void 0 ) forceU = false;
  4660.  
  4661. var pos = this.pos;
  4662. for (var i = 0, list = chs; i < list.length; i += 1) {
  4663. var ch = list[i];
  4664.  
  4665. var current = this.at(pos, forceU);
  4666. if (current === -1 || current !== ch) {
  4667. return false
  4668. }
  4669. pos = this.nextIndex(pos, forceU);
  4670. }
  4671. this.pos = pos;
  4672. return true
  4673. };
  4674.  
  4675. /**
  4676. * Validate the flags part of a given RegExpLiteral.
  4677. *
  4678. * @param {RegExpValidationState} state The state to validate RegExp.
  4679. * @returns {void}
  4680. */
  4681. pp$1.validateRegExpFlags = function(state) {
  4682. var validFlags = state.validFlags;
  4683. var flags = state.flags;
  4684.  
  4685. var u = false;
  4686. var v = false;
  4687.  
  4688. for (var i = 0; i < flags.length; i++) {
  4689. var flag = flags.charAt(i);
  4690. if (validFlags.indexOf(flag) === -1) {
  4691. this.raise(state.start, "Invalid regular expression flag");
  4692. }
  4693. if (flags.indexOf(flag, i + 1) > -1) {
  4694. this.raise(state.start, "Duplicate regular expression flag");
  4695. }
  4696. if (flag === "u") { u = true; }
  4697. if (flag === "v") { v = true; }
  4698. }
  4699. if (this.options.ecmaVersion >= 15 && u && v) {
  4700. this.raise(state.start, "Invalid regular expression flag");
  4701. }
  4702. };
  4703.  
  4704. /**
  4705. * Validate the pattern part of a given RegExpLiteral.
  4706. *
  4707. * @param {RegExpValidationState} state The state to validate RegExp.
  4708. * @returns {void}
  4709. */
  4710. pp$1.validateRegExpPattern = function(state) {
  4711. this.regexp_pattern(state);
  4712.  
  4713. // The goal symbol for the parse is |Pattern[~U, ~N]|. If the result of
  4714. // parsing contains a |GroupName|, reparse with the goal symbol
  4715. // |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError*
  4716. // exception if _P_ did not conform to the grammar, if any elements of _P_
  4717. // were not matched by the parse, or if any Early Error conditions exist.
  4718. if (!state.switchN && this.options.ecmaVersion >= 9 && state.groupNames.length > 0) {
  4719. state.switchN = true;
  4720. this.regexp_pattern(state);
  4721. }
  4722. };
  4723.  
  4724. // https://www.ecma-international.org/ecma-262/8.0/#prod-Pattern
  4725. pp$1.regexp_pattern = function(state) {
  4726. state.pos = 0;
  4727. state.lastIntValue = 0;
  4728. state.lastStringValue = "";
  4729. state.lastAssertionIsQuantifiable = false;
  4730. state.numCapturingParens = 0;
  4731. state.maxBackReference = 0;
  4732. state.groupNames.length = 0;
  4733. state.backReferenceNames.length = 0;
  4734.  
  4735. this.regexp_disjunction(state);
  4736.  
  4737. if (state.pos !== state.source.length) {
  4738. // Make the same messages as V8.
  4739. if (state.eat(0x29 /* ) */)) {
  4740. state.raise("Unmatched ')'");
  4741. }
  4742. if (state.eat(0x5D /* ] */) || state.eat(0x7D /* } */)) {
  4743. state.raise("Lone quantifier brackets");
  4744. }
  4745. }
  4746. if (state.maxBackReference > state.numCapturingParens) {
  4747. state.raise("Invalid escape");
  4748. }
  4749. for (var i = 0, list = state.backReferenceNames; i < list.length; i += 1) {
  4750. var name = list[i];
  4751.  
  4752. if (state.groupNames.indexOf(name) === -1) {
  4753. state.raise("Invalid named capture referenced");
  4754. }
  4755. }
  4756. };
  4757.  
  4758. // https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction
  4759. pp$1.regexp_disjunction = function(state) {
  4760. this.regexp_alternative(state);
  4761. while (state.eat(0x7C /* | */)) {
  4762. this.regexp_alternative(state);
  4763. }
  4764.  
  4765. // Make the same message as V8.
  4766. if (this.regexp_eatQuantifier(state, true)) {
  4767. state.raise("Nothing to repeat");
  4768. }
  4769. if (state.eat(0x7B /* { */)) {
  4770. state.raise("Lone quantifier brackets");
  4771. }
  4772. };
  4773.  
  4774. // https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative
  4775. pp$1.regexp_alternative = function(state) {
  4776. while (state.pos < state.source.length && this.regexp_eatTerm(state))
  4777. { }
  4778. };
  4779.  
  4780. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term
  4781. pp$1.regexp_eatTerm = function(state) {
  4782. if (this.regexp_eatAssertion(state)) {
  4783. // Handle `QuantifiableAssertion Quantifier` alternative.
  4784. // `state.lastAssertionIsQuantifiable` is true if the last eaten Assertion
  4785. // is a QuantifiableAssertion.
  4786. if (state.lastAssertionIsQuantifiable && this.regexp_eatQuantifier(state)) {
  4787. // Make the same message as V8.
  4788. if (state.switchU) {
  4789. state.raise("Invalid quantifier");
  4790. }
  4791. }
  4792. return true
  4793. }
  4794.  
  4795. if (state.switchU ? this.regexp_eatAtom(state) : this.regexp_eatExtendedAtom(state)) {
  4796. this.regexp_eatQuantifier(state);
  4797. return true
  4798. }
  4799.  
  4800. return false
  4801. };
  4802.  
  4803. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Assertion
  4804. pp$1.regexp_eatAssertion = function(state) {
  4805. var start = state.pos;
  4806. state.lastAssertionIsQuantifiable = false;
  4807.  
  4808. // ^, $
  4809. if (state.eat(0x5E /* ^ */) || state.eat(0x24 /* $ */)) {
  4810. return true
  4811. }
  4812.  
  4813. // \b \B
  4814. if (state.eat(0x5C /* \ */)) {
  4815. if (state.eat(0x42 /* B */) || state.eat(0x62 /* b */)) {
  4816. return true
  4817. }
  4818. state.pos = start;
  4819. }
  4820.  
  4821. // Lookahead / Lookbehind
  4822. if (state.eat(0x28 /* ( */) && state.eat(0x3F /* ? */)) {
  4823. var lookbehind = false;
  4824. if (this.options.ecmaVersion >= 9) {
  4825. lookbehind = state.eat(0x3C /* < */);
  4826. }
  4827. if (state.eat(0x3D /* = */) || state.eat(0x21 /* ! */)) {
  4828. this.regexp_disjunction(state);
  4829. if (!state.eat(0x29 /* ) */)) {
  4830. state.raise("Unterminated group");
  4831. }
  4832. state.lastAssertionIsQuantifiable = !lookbehind;
  4833. return true
  4834. }
  4835. }
  4836.  
  4837. state.pos = start;
  4838. return false
  4839. };
  4840.  
  4841. // https://www.ecma-international.org/ecma-262/8.0/#prod-Quantifier
  4842. pp$1.regexp_eatQuantifier = function(state, noError) {
  4843. if ( noError === void 0 ) noError = false;
  4844.  
  4845. if (this.regexp_eatQuantifierPrefix(state, noError)) {
  4846. state.eat(0x3F /* ? */);
  4847. return true
  4848. }
  4849. return false
  4850. };
  4851.  
  4852. // https://www.ecma-international.org/ecma-262/8.0/#prod-QuantifierPrefix
  4853. pp$1.regexp_eatQuantifierPrefix = function(state, noError) {
  4854. return (
  4855. state.eat(0x2A /* * */) ||
  4856. state.eat(0x2B /* + */) ||
  4857. state.eat(0x3F /* ? */) ||
  4858. this.regexp_eatBracedQuantifier(state, noError)
  4859. )
  4860. };
  4861. pp$1.regexp_eatBracedQuantifier = function(state, noError) {
  4862. var start = state.pos;
  4863. if (state.eat(0x7B /* { */)) {
  4864. var min = 0, max = -1;
  4865. if (this.regexp_eatDecimalDigits(state)) {
  4866. min = state.lastIntValue;
  4867. if (state.eat(0x2C /* , */) && this.regexp_eatDecimalDigits(state)) {
  4868. max = state.lastIntValue;
  4869. }
  4870. if (state.eat(0x7D /* } */)) {
  4871. // SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-term
  4872. if (max !== -1 && max < min && !noError) {
  4873. state.raise("numbers out of order in {} quantifier");
  4874. }
  4875. return true
  4876. }
  4877. }
  4878. if (state.switchU && !noError) {
  4879. state.raise("Incomplete quantifier");
  4880. }
  4881. state.pos = start;
  4882. }
  4883. return false
  4884. };
  4885.  
  4886. // https://www.ecma-international.org/ecma-262/8.0/#prod-Atom
  4887. pp$1.regexp_eatAtom = function(state) {
  4888. return (
  4889. this.regexp_eatPatternCharacters(state) ||
  4890. state.eat(0x2E /* . */) ||
  4891. this.regexp_eatReverseSolidusAtomEscape(state) ||
  4892. this.regexp_eatCharacterClass(state) ||
  4893. this.regexp_eatUncapturingGroup(state) ||
  4894. this.regexp_eatCapturingGroup(state)
  4895. )
  4896. };
  4897. pp$1.regexp_eatReverseSolidusAtomEscape = function(state) {
  4898. var start = state.pos;
  4899. if (state.eat(0x5C /* \ */)) {
  4900. if (this.regexp_eatAtomEscape(state)) {
  4901. return true
  4902. }
  4903. state.pos = start;
  4904. }
  4905. return false
  4906. };
  4907. pp$1.regexp_eatUncapturingGroup = function(state) {
  4908. var start = state.pos;
  4909. if (state.eat(0x28 /* ( */)) {
  4910. if (state.eat(0x3F /* ? */) && state.eat(0x3A /* : */)) {
  4911. this.regexp_disjunction(state);
  4912. if (state.eat(0x29 /* ) */)) {
  4913. return true
  4914. }
  4915. state.raise("Unterminated group");
  4916. }
  4917. state.pos = start;
  4918. }
  4919. return false
  4920. };
  4921. pp$1.regexp_eatCapturingGroup = function(state) {
  4922. if (state.eat(0x28 /* ( */)) {
  4923. if (this.options.ecmaVersion >= 9) {
  4924. this.regexp_groupSpecifier(state);
  4925. } else if (state.current() === 0x3F /* ? */) {
  4926. state.raise("Invalid group");
  4927. }
  4928. this.regexp_disjunction(state);
  4929. if (state.eat(0x29 /* ) */)) {
  4930. state.numCapturingParens += 1;
  4931. return true
  4932. }
  4933. state.raise("Unterminated group");
  4934. }
  4935. return false
  4936. };
  4937.  
  4938. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom
  4939. pp$1.regexp_eatExtendedAtom = function(state) {
  4940. return (
  4941. state.eat(0x2E /* . */) ||
  4942. this.regexp_eatReverseSolidusAtomEscape(state) ||
  4943. this.regexp_eatCharacterClass(state) ||
  4944. this.regexp_eatUncapturingGroup(state) ||
  4945. this.regexp_eatCapturingGroup(state) ||
  4946. this.regexp_eatInvalidBracedQuantifier(state) ||
  4947. this.regexp_eatExtendedPatternCharacter(state)
  4948. )
  4949. };
  4950.  
  4951. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-InvalidBracedQuantifier
  4952. pp$1.regexp_eatInvalidBracedQuantifier = function(state) {
  4953. if (this.regexp_eatBracedQuantifier(state, true)) {
  4954. state.raise("Nothing to repeat");
  4955. }
  4956. return false
  4957. };
  4958.  
  4959. // https://www.ecma-international.org/ecma-262/8.0/#prod-SyntaxCharacter
  4960. pp$1.regexp_eatSyntaxCharacter = function(state) {
  4961. var ch = state.current();
  4962. if (isSyntaxCharacter(ch)) {
  4963. state.lastIntValue = ch;
  4964. state.advance();
  4965. return true
  4966. }
  4967. return false
  4968. };
  4969. function isSyntaxCharacter(ch) {
  4970. return (
  4971. ch === 0x24 /* $ */ ||
  4972. ch >= 0x28 /* ( */ && ch <= 0x2B /* + */ ||
  4973. ch === 0x2E /* . */ ||
  4974. ch === 0x3F /* ? */ ||
  4975. ch >= 0x5B /* [ */ && ch <= 0x5E /* ^ */ ||
  4976. ch >= 0x7B /* { */ && ch <= 0x7D /* } */
  4977. )
  4978. }
  4979.  
  4980. // https://www.ecma-international.org/ecma-262/8.0/#prod-PatternCharacter
  4981. // But eat eager.
  4982. pp$1.regexp_eatPatternCharacters = function(state) {
  4983. var start = state.pos;
  4984. var ch = 0;
  4985. while ((ch = state.current()) !== -1 && !isSyntaxCharacter(ch)) {
  4986. state.advance();
  4987. }
  4988. return state.pos !== start
  4989. };
  4990.  
  4991. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedPatternCharacter
  4992. pp$1.regexp_eatExtendedPatternCharacter = function(state) {
  4993. var ch = state.current();
  4994. if (
  4995. ch !== -1 &&
  4996. ch !== 0x24 /* $ */ &&
  4997. !(ch >= 0x28 /* ( */ && ch <= 0x2B /* + */) &&
  4998. ch !== 0x2E /* . */ &&
  4999. ch !== 0x3F /* ? */ &&
  5000. ch !== 0x5B /* [ */ &&
  5001. ch !== 0x5E /* ^ */ &&
  5002. ch !== 0x7C /* | */
  5003. ) {
  5004. state.advance();
  5005. return true
  5006. }
  5007. return false
  5008. };
  5009.  
  5010. // GroupSpecifier ::
  5011. // [empty]
  5012. // `?` GroupName
  5013. pp$1.regexp_groupSpecifier = function(state) {
  5014. if (state.eat(0x3F /* ? */)) {
  5015. if (this.regexp_eatGroupName(state)) {
  5016. if (state.groupNames.indexOf(state.lastStringValue) !== -1) {
  5017. state.raise("Duplicate capture group name");
  5018. }
  5019. state.groupNames.push(state.lastStringValue);
  5020. return
  5021. }
  5022. state.raise("Invalid group");
  5023. }
  5024. };
  5025.  
  5026. // GroupName ::
  5027. // `<` RegExpIdentifierName `>`
  5028. // Note: this updates `state.lastStringValue` property with the eaten name.
  5029. pp$1.regexp_eatGroupName = function(state) {
  5030. state.lastStringValue = "";
  5031. if (state.eat(0x3C /* < */)) {
  5032. if (this.regexp_eatRegExpIdentifierName(state) && state.eat(0x3E /* > */)) {
  5033. return true
  5034. }
  5035. state.raise("Invalid capture group name");
  5036. }
  5037. return false
  5038. };
  5039.  
  5040. // RegExpIdentifierName ::
  5041. // RegExpIdentifierStart
  5042. // RegExpIdentifierName RegExpIdentifierPart
  5043. // Note: this updates `state.lastStringValue` property with the eaten name.
  5044. pp$1.regexp_eatRegExpIdentifierName = function(state) {
  5045. state.lastStringValue = "";
  5046. if (this.regexp_eatRegExpIdentifierStart(state)) {
  5047. state.lastStringValue += codePointToString(state.lastIntValue);
  5048. while (this.regexp_eatRegExpIdentifierPart(state)) {
  5049. state.lastStringValue += codePointToString(state.lastIntValue);
  5050. }
  5051. return true
  5052. }
  5053. return false
  5054. };
  5055.  
  5056. // RegExpIdentifierStart ::
  5057. // UnicodeIDStart
  5058. // `$`
  5059. // `_`
  5060. // `\` RegExpUnicodeEscapeSequence[+U]
  5061. pp$1.regexp_eatRegExpIdentifierStart = function(state) {
  5062. var start = state.pos;
  5063. var forceU = this.options.ecmaVersion >= 11;
  5064. var ch = state.current(forceU);
  5065. state.advance(forceU);
  5066.  
  5067. if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
  5068. ch = state.lastIntValue;
  5069. }
  5070. if (isRegExpIdentifierStart(ch)) {
  5071. state.lastIntValue = ch;
  5072. return true
  5073. }
  5074.  
  5075. state.pos = start;
  5076. return false
  5077. };
  5078. function isRegExpIdentifierStart(ch) {
  5079. return isIdentifierStart(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */
  5080. }
  5081.  
  5082. // RegExpIdentifierPart ::
  5083. // UnicodeIDContinue
  5084. // `$`
  5085. // `_`
  5086. // `\` RegExpUnicodeEscapeSequence[+U]
  5087. // <ZWNJ>
  5088. // <ZWJ>
  5089. pp$1.regexp_eatRegExpIdentifierPart = function(state) {
  5090. var start = state.pos;
  5091. var forceU = this.options.ecmaVersion >= 11;
  5092. var ch = state.current(forceU);
  5093. state.advance(forceU);
  5094.  
  5095. if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
  5096. ch = state.lastIntValue;
  5097. }
  5098. if (isRegExpIdentifierPart(ch)) {
  5099. state.lastIntValue = ch;
  5100. return true
  5101. }
  5102.  
  5103. state.pos = start;
  5104. return false
  5105. };
  5106. function isRegExpIdentifierPart(ch) {
  5107. return isIdentifierChar(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */ || ch === 0x200C /* <ZWNJ> */ || ch === 0x200D /* <ZWJ> */
  5108. }
  5109.  
  5110. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-AtomEscape
  5111. pp$1.regexp_eatAtomEscape = function(state) {
  5112. if (
  5113. this.regexp_eatBackReference(state) ||
  5114. this.regexp_eatCharacterClassEscape(state) ||
  5115. this.regexp_eatCharacterEscape(state) ||
  5116. (state.switchN && this.regexp_eatKGroupName(state))
  5117. ) {
  5118. return true
  5119. }
  5120. if (state.switchU) {
  5121. // Make the same message as V8.
  5122. if (state.current() === 0x63 /* c */) {
  5123. state.raise("Invalid unicode escape");
  5124. }
  5125. state.raise("Invalid escape");
  5126. }
  5127. return false
  5128. };
  5129. pp$1.regexp_eatBackReference = function(state) {
  5130. var start = state.pos;
  5131. if (this.regexp_eatDecimalEscape(state)) {
  5132. var n = state.lastIntValue;
  5133. if (state.switchU) {
  5134. // For SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-atomescape
  5135. if (n > state.maxBackReference) {
  5136. state.maxBackReference = n;
  5137. }
  5138. return true
  5139. }
  5140. if (n <= state.numCapturingParens) {
  5141. return true
  5142. }
  5143. state.pos = start;
  5144. }
  5145. return false
  5146. };
  5147. pp$1.regexp_eatKGroupName = function(state) {
  5148. if (state.eat(0x6B /* k */)) {
  5149. if (this.regexp_eatGroupName(state)) {
  5150. state.backReferenceNames.push(state.lastStringValue);
  5151. return true
  5152. }
  5153. state.raise("Invalid named reference");
  5154. }
  5155. return false
  5156. };
  5157.  
  5158. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-CharacterEscape
  5159. pp$1.regexp_eatCharacterEscape = function(state) {
  5160. return (
  5161. this.regexp_eatControlEscape(state) ||
  5162. this.regexp_eatCControlLetter(state) ||
  5163. this.regexp_eatZero(state) ||
  5164. this.regexp_eatHexEscapeSequence(state) ||
  5165. this.regexp_eatRegExpUnicodeEscapeSequence(state, false) ||
  5166. (!state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state)) ||
  5167. this.regexp_eatIdentityEscape(state)
  5168. )
  5169. };
  5170. pp$1.regexp_eatCControlLetter = function(state) {
  5171. var start = state.pos;
  5172. if (state.eat(0x63 /* c */)) {
  5173. if (this.regexp_eatControlLetter(state)) {
  5174. return true
  5175. }
  5176. state.pos = start;
  5177. }
  5178. return false
  5179. };
  5180. pp$1.regexp_eatZero = function(state) {
  5181. if (state.current() === 0x30 /* 0 */ && !isDecimalDigit(state.lookahead())) {
  5182. state.lastIntValue = 0;
  5183. state.advance();
  5184. return true
  5185. }
  5186. return false
  5187. };
  5188.  
  5189. // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlEscape
  5190. pp$1.regexp_eatControlEscape = function(state) {
  5191. var ch = state.current();
  5192. if (ch === 0x74 /* t */) {
  5193. state.lastIntValue = 0x09; /* \t */
  5194. state.advance();
  5195. return true
  5196. }
  5197. if (ch === 0x6E /* n */) {
  5198. state.lastIntValue = 0x0A; /* \n */
  5199. state.advance();
  5200. return true
  5201. }
  5202. if (ch === 0x76 /* v */) {
  5203. state.lastIntValue = 0x0B; /* \v */
  5204. state.advance();
  5205. return true
  5206. }
  5207. if (ch === 0x66 /* f */) {
  5208. state.lastIntValue = 0x0C; /* \f */
  5209. state.advance();
  5210. return true
  5211. }
  5212. if (ch === 0x72 /* r */) {
  5213. state.lastIntValue = 0x0D; /* \r */
  5214. state.advance();
  5215. return true
  5216. }
  5217. return false
  5218. };
  5219.  
  5220. // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlLetter
  5221. pp$1.regexp_eatControlLetter = function(state) {
  5222. var ch = state.current();
  5223. if (isControlLetter(ch)) {
  5224. state.lastIntValue = ch % 0x20;
  5225. state.advance();
  5226. return true
  5227. }
  5228. return false
  5229. };
  5230. function isControlLetter(ch) {
  5231. return (
  5232. (ch >= 0x41 /* A */ && ch <= 0x5A /* Z */) ||
  5233. (ch >= 0x61 /* a */ && ch <= 0x7A /* z */)
  5234. )
  5235. }
  5236.  
  5237. // https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence
  5238. pp$1.regexp_eatRegExpUnicodeEscapeSequence = function(state, forceU) {
  5239. if ( forceU === void 0 ) forceU = false;
  5240.  
  5241. var start = state.pos;
  5242. var switchU = forceU || state.switchU;
  5243.  
  5244. if (state.eat(0x75 /* u */)) {
  5245. if (this.regexp_eatFixedHexDigits(state, 4)) {
  5246. var lead = state.lastIntValue;
  5247. if (switchU && lead >= 0xD800 && lead <= 0xDBFF) {
  5248. var leadSurrogateEnd = state.pos;
  5249. if (state.eat(0x5C /* \ */) && state.eat(0x75 /* u */) && this.regexp_eatFixedHexDigits(state, 4)) {
  5250. var trail = state.lastIntValue;
  5251. if (trail >= 0xDC00 && trail <= 0xDFFF) {
  5252. state.lastIntValue = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
  5253. return true
  5254. }
  5255. }
  5256. state.pos = leadSurrogateEnd;
  5257. state.lastIntValue = lead;
  5258. }
  5259. return true
  5260. }
  5261. if (
  5262. switchU &&
  5263. state.eat(0x7B /* { */) &&
  5264. this.regexp_eatHexDigits(state) &&
  5265. state.eat(0x7D /* } */) &&
  5266. isValidUnicode(state.lastIntValue)
  5267. ) {
  5268. return true
  5269. }
  5270. if (switchU) {
  5271. state.raise("Invalid unicode escape");
  5272. }
  5273. state.pos = start;
  5274. }
  5275.  
  5276. return false
  5277. };
  5278. function isValidUnicode(ch) {
  5279. return ch >= 0 && ch <= 0x10FFFF
  5280. }
  5281.  
  5282. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-IdentityEscape
  5283. pp$1.regexp_eatIdentityEscape = function(state) {
  5284. if (state.switchU) {
  5285. if (this.regexp_eatSyntaxCharacter(state)) {
  5286. return true
  5287. }
  5288. if (state.eat(0x2F /* / */)) {
  5289. state.lastIntValue = 0x2F; /* / */
  5290. return true
  5291. }
  5292. return false
  5293. }
  5294.  
  5295. var ch = state.current();
  5296. if (ch !== 0x63 /* c */ && (!state.switchN || ch !== 0x6B /* k */)) {
  5297. state.lastIntValue = ch;
  5298. state.advance();
  5299. return true
  5300. }
  5301.  
  5302. return false
  5303. };
  5304.  
  5305. // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalEscape
  5306. pp$1.regexp_eatDecimalEscape = function(state) {
  5307. state.lastIntValue = 0;
  5308. var ch = state.current();
  5309. if (ch >= 0x31 /* 1 */ && ch <= 0x39 /* 9 */) {
  5310. do {
  5311. state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */);
  5312. state.advance();
  5313. } while ((ch = state.current()) >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */)
  5314. return true
  5315. }
  5316. return false
  5317. };
  5318.  
  5319. // Return values used by character set parsing methods, needed to
  5320. // forbid negation of sets that can match strings.
  5321. var CharSetNone = 0; // Nothing parsed
  5322. var CharSetOk = 1; // Construct parsed, cannot contain strings
  5323. var CharSetString = 2; // Construct parsed, can contain strings
  5324.  
  5325. // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClassEscape
  5326. pp$1.regexp_eatCharacterClassEscape = function(state) {
  5327. var ch = state.current();
  5328.  
  5329. if (isCharacterClassEscape(ch)) {
  5330. state.lastIntValue = -1;
  5331. state.advance();
  5332. return CharSetOk
  5333. }
  5334.  
  5335. var negate = false;
  5336. if (
  5337. state.switchU &&
  5338. this.options.ecmaVersion >= 9 &&
  5339. ((negate = ch === 0x50 /* P */) || ch === 0x70 /* p */)
  5340. ) {
  5341. state.lastIntValue = -1;
  5342. state.advance();
  5343. var result;
  5344. if (
  5345. state.eat(0x7B /* { */) &&
  5346. (result = this.regexp_eatUnicodePropertyValueExpression(state)) &&
  5347. state.eat(0x7D /* } */)
  5348. ) {
  5349. if (negate && result === CharSetString) { state.raise("Invalid property name"); }
  5350. return result
  5351. }
  5352. state.raise("Invalid property name");
  5353. }
  5354.  
  5355. return CharSetNone
  5356. };
  5357.  
  5358. function isCharacterClassEscape(ch) {
  5359. return (
  5360. ch === 0x64 /* d */ ||
  5361. ch === 0x44 /* D */ ||
  5362. ch === 0x73 /* s */ ||
  5363. ch === 0x53 /* S */ ||
  5364. ch === 0x77 /* w */ ||
  5365. ch === 0x57 /* W */
  5366. )
  5367. }
  5368.  
  5369. // UnicodePropertyValueExpression ::
  5370. // UnicodePropertyName `=` UnicodePropertyValue
  5371. // LoneUnicodePropertyNameOrValue
  5372. pp$1.regexp_eatUnicodePropertyValueExpression = function(state) {
  5373. var start = state.pos;
  5374.  
  5375. // UnicodePropertyName `=` UnicodePropertyValue
  5376. if (this.regexp_eatUnicodePropertyName(state) && state.eat(0x3D /* = */)) {
  5377. var name = state.lastStringValue;
  5378. if (this.regexp_eatUnicodePropertyValue(state)) {
  5379. var value = state.lastStringValue;
  5380. this.regexp_validateUnicodePropertyNameAndValue(state, name, value);
  5381. return CharSetOk
  5382. }
  5383. }
  5384. state.pos = start;
  5385.  
  5386. // LoneUnicodePropertyNameOrValue
  5387. if (this.regexp_eatLoneUnicodePropertyNameOrValue(state)) {
  5388. var nameOrValue = state.lastStringValue;
  5389. return this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue)
  5390. }
  5391. return CharSetNone
  5392. };
  5393.  
  5394. pp$1.regexp_validateUnicodePropertyNameAndValue = function(state, name, value) {
  5395. if (!hasOwn(state.unicodeProperties.nonBinary, name))
  5396. { state.raise("Invalid property name"); }
  5397. if (!state.unicodeProperties.nonBinary[name].test(value))
  5398. { state.raise("Invalid property value"); }
  5399. };
  5400.  
  5401. pp$1.regexp_validateUnicodePropertyNameOrValue = function(state, nameOrValue) {
  5402. if (state.unicodeProperties.binary.test(nameOrValue)) { return CharSetOk }
  5403. if (state.switchV && state.unicodeProperties.binaryOfStrings.test(nameOrValue)) { return CharSetString }
  5404. state.raise("Invalid property name");
  5405. };
  5406.  
  5407. // UnicodePropertyName ::
  5408. // UnicodePropertyNameCharacters
  5409. pp$1.regexp_eatUnicodePropertyName = function(state) {
  5410. var ch = 0;
  5411. state.lastStringValue = "";
  5412. while (isUnicodePropertyNameCharacter(ch = state.current())) {
  5413. state.lastStringValue += codePointToString(ch);
  5414. state.advance();
  5415. }
  5416. return state.lastStringValue !== ""
  5417. };
  5418.  
  5419. function isUnicodePropertyNameCharacter(ch) {
  5420. return isControlLetter(ch) || ch === 0x5F /* _ */
  5421. }
  5422.  
  5423. // UnicodePropertyValue ::
  5424. // UnicodePropertyValueCharacters
  5425. pp$1.regexp_eatUnicodePropertyValue = function(state) {
  5426. var ch = 0;
  5427. state.lastStringValue = "";
  5428. while (isUnicodePropertyValueCharacter(ch = state.current())) {
  5429. state.lastStringValue += codePointToString(ch);
  5430. state.advance();
  5431. }
  5432. return state.lastStringValue !== ""
  5433. };
  5434. function isUnicodePropertyValueCharacter(ch) {
  5435. return isUnicodePropertyNameCharacter(ch) || isDecimalDigit(ch)
  5436. }
  5437.  
  5438. // LoneUnicodePropertyNameOrValue ::
  5439. // UnicodePropertyValueCharacters
  5440. pp$1.regexp_eatLoneUnicodePropertyNameOrValue = function(state) {
  5441. return this.regexp_eatUnicodePropertyValue(state)
  5442. };
  5443.  
  5444. // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClass
  5445. pp$1.regexp_eatCharacterClass = function(state) {
  5446. if (state.eat(0x5B /* [ */)) {
  5447. var negate = state.eat(0x5E /* ^ */);
  5448. var result = this.regexp_classContents(state);
  5449. if (!state.eat(0x5D /* ] */))
  5450. { state.raise("Unterminated character class"); }
  5451. if (negate && result === CharSetString)
  5452. { state.raise("Negated character class may contain strings"); }
  5453. return true
  5454. }
  5455. return false
  5456. };
  5457.  
  5458. // https://tc39.es/ecma262/#prod-ClassContents
  5459. // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassRanges
  5460. pp$1.regexp_classContents = function(state) {
  5461. if (state.current() === 0x5D /* ] */) { return CharSetOk }
  5462. if (state.switchV) { return this.regexp_classSetExpression(state) }
  5463. this.regexp_nonEmptyClassRanges(state);
  5464. return CharSetOk
  5465. };
  5466.  
  5467. // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRanges
  5468. // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRangesNoDash
  5469. pp$1.regexp_nonEmptyClassRanges = function(state) {
  5470. while (this.regexp_eatClassAtom(state)) {
  5471. var left = state.lastIntValue;
  5472. if (state.eat(0x2D /* - */) && this.regexp_eatClassAtom(state)) {
  5473. var right = state.lastIntValue;
  5474. if (state.switchU && (left === -1 || right === -1)) {
  5475. state.raise("Invalid character class");
  5476. }
  5477. if (left !== -1 && right !== -1 && left > right) {
  5478. state.raise("Range out of order in character class");
  5479. }
  5480. }
  5481. }
  5482. };
  5483.  
  5484. // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtom
  5485. // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtomNoDash
  5486. pp$1.regexp_eatClassAtom = function(state) {
  5487. var start = state.pos;
  5488.  
  5489. if (state.eat(0x5C /* \ */)) {
  5490. if (this.regexp_eatClassEscape(state)) {
  5491. return true
  5492. }
  5493. if (state.switchU) {
  5494. // Make the same message as V8.
  5495. var ch$1 = state.current();
  5496. if (ch$1 === 0x63 /* c */ || isOctalDigit(ch$1)) {
  5497. state.raise("Invalid class escape");
  5498. }
  5499. state.raise("Invalid escape");
  5500. }
  5501. state.pos = start;
  5502. }
  5503.  
  5504. var ch = state.current();
  5505. if (ch !== 0x5D /* ] */) {
  5506. state.lastIntValue = ch;
  5507. state.advance();
  5508. return true
  5509. }
  5510.  
  5511. return false
  5512. };
  5513.  
  5514. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassEscape
  5515. pp$1.regexp_eatClassEscape = function(state) {
  5516. var start = state.pos;
  5517.  
  5518. if (state.eat(0x62 /* b */)) {
  5519. state.lastIntValue = 0x08; /* <BS> */
  5520. return true
  5521. }
  5522.  
  5523. if (state.switchU && state.eat(0x2D /* - */)) {
  5524. state.lastIntValue = 0x2D; /* - */
  5525. return true
  5526. }
  5527.  
  5528. if (!state.switchU && state.eat(0x63 /* c */)) {
  5529. if (this.regexp_eatClassControlLetter(state)) {
  5530. return true
  5531. }
  5532. state.pos = start;
  5533. }
  5534.  
  5535. return (
  5536. this.regexp_eatCharacterClassEscape(state) ||
  5537. this.regexp_eatCharacterEscape(state)
  5538. )
  5539. };
  5540.  
  5541. // https://tc39.es/ecma262/#prod-ClassSetExpression
  5542. // https://tc39.es/ecma262/#prod-ClassUnion
  5543. // https://tc39.es/ecma262/#prod-ClassIntersection
  5544. // https://tc39.es/ecma262/#prod-ClassSubtraction
  5545. pp$1.regexp_classSetExpression = function(state) {
  5546. var result = CharSetOk, subResult;
  5547. if (this.regexp_eatClassSetRange(state)) ; else if (subResult = this.regexp_eatClassSetOperand(state)) {
  5548. if (subResult === CharSetString) { result = CharSetString; }
  5549. // https://tc39.es/ecma262/#prod-ClassIntersection
  5550. var start = state.pos;
  5551. while (state.eatChars([0x26, 0x26] /* && */)) {
  5552. if (
  5553. state.current() !== 0x26 /* & */ &&
  5554. (subResult = this.regexp_eatClassSetOperand(state))
  5555. ) {
  5556. if (subResult !== CharSetString) { result = CharSetOk; }
  5557. continue
  5558. }
  5559. state.raise("Invalid character in character class");
  5560. }
  5561. if (start !== state.pos) { return result }
  5562. // https://tc39.es/ecma262/#prod-ClassSubtraction
  5563. while (state.eatChars([0x2D, 0x2D] /* -- */)) {
  5564. if (this.regexp_eatClassSetOperand(state)) { continue }
  5565. state.raise("Invalid character in character class");
  5566. }
  5567. if (start !== state.pos) { return result }
  5568. } else {
  5569. state.raise("Invalid character in character class");
  5570. }
  5571. // https://tc39.es/ecma262/#prod-ClassUnion
  5572. for (;;) {
  5573. if (this.regexp_eatClassSetRange(state)) { continue }
  5574. subResult = this.regexp_eatClassSetOperand(state);
  5575. if (!subResult) { return result }
  5576. if (subResult === CharSetString) { result = CharSetString; }
  5577. }
  5578. };
  5579.  
  5580. // https://tc39.es/ecma262/#prod-ClassSetRange
  5581. pp$1.regexp_eatClassSetRange = function(state) {
  5582. var start = state.pos;
  5583. if (this.regexp_eatClassSetCharacter(state)) {
  5584. var left = state.lastIntValue;
  5585. if (state.eat(0x2D /* - */) && this.regexp_eatClassSetCharacter(state)) {
  5586. var right = state.lastIntValue;
  5587. if (left !== -1 && right !== -1 && left > right) {
  5588. state.raise("Range out of order in character class");
  5589. }
  5590. return true
  5591. }
  5592. state.pos = start;
  5593. }
  5594. return false
  5595. };
  5596.  
  5597. // https://tc39.es/ecma262/#prod-ClassSetOperand
  5598. pp$1.regexp_eatClassSetOperand = function(state) {
  5599. if (this.regexp_eatClassSetCharacter(state)) { return CharSetOk }
  5600. return this.regexp_eatClassStringDisjunction(state) || this.regexp_eatNestedClass(state)
  5601. };
  5602.  
  5603. // https://tc39.es/ecma262/#prod-NestedClass
  5604. pp$1.regexp_eatNestedClass = function(state) {
  5605. var start = state.pos;
  5606. if (state.eat(0x5B /* [ */)) {
  5607. var negate = state.eat(0x5E /* ^ */);
  5608. var result = this.regexp_classContents(state);
  5609. if (state.eat(0x5D /* ] */)) {
  5610. if (negate && result === CharSetString) {
  5611. state.raise("Negated character class may contain strings");
  5612. }
  5613. return result
  5614. }
  5615. state.pos = start;
  5616. }
  5617. if (state.eat(0x5C /* \ */)) {
  5618. var result$1 = this.regexp_eatCharacterClassEscape(state);
  5619. if (result$1) {
  5620. return result$1
  5621. }
  5622. state.pos = start;
  5623. }
  5624. return null
  5625. };
  5626.  
  5627. // https://tc39.es/ecma262/#prod-ClassStringDisjunction
  5628. pp$1.regexp_eatClassStringDisjunction = function(state) {
  5629. var start = state.pos;
  5630. if (state.eatChars([0x5C, 0x71] /* \q */)) {
  5631. if (state.eat(0x7B /* { */)) {
  5632. var result = this.regexp_classStringDisjunctionContents(state);
  5633. if (state.eat(0x7D /* } */)) {
  5634. return result
  5635. }
  5636. } else {
  5637. // Make the same message as V8.
  5638. state.raise("Invalid escape");
  5639. }
  5640. state.pos = start;
  5641. }
  5642. return null
  5643. };
  5644.  
  5645. // https://tc39.es/ecma262/#prod-ClassStringDisjunctionContents
  5646. pp$1.regexp_classStringDisjunctionContents = function(state) {
  5647. var result = this.regexp_classString(state);
  5648. while (state.eat(0x7C /* | */)) {
  5649. if (this.regexp_classString(state) === CharSetString) { result = CharSetString; }
  5650. }
  5651. return result
  5652. };
  5653.  
  5654. // https://tc39.es/ecma262/#prod-ClassString
  5655. // https://tc39.es/ecma262/#prod-NonEmptyClassString
  5656. pp$1.regexp_classString = function(state) {
  5657. var count = 0;
  5658. while (this.regexp_eatClassSetCharacter(state)) { count++; }
  5659. return count === 1 ? CharSetOk : CharSetString
  5660. };
  5661.  
  5662. // https://tc39.es/ecma262/#prod-ClassSetCharacter
  5663. pp$1.regexp_eatClassSetCharacter = function(state) {
  5664. var start = state.pos;
  5665. if (state.eat(0x5C /* \ */)) {
  5666. if (
  5667. this.regexp_eatCharacterEscape(state) ||
  5668. this.regexp_eatClassSetReservedPunctuator(state)
  5669. ) {
  5670. return true
  5671. }
  5672. if (state.eat(0x62 /* b */)) {
  5673. state.lastIntValue = 0x08; /* <BS> */
  5674. return true
  5675. }
  5676. state.pos = start;
  5677. return false
  5678. }
  5679. var ch = state.current();
  5680. if (ch < 0 || ch === state.lookahead() && isClassSetReservedDoublePunctuatorCharacter(ch)) { return false }
  5681. if (isClassSetSyntaxCharacter(ch)) { return false }
  5682. state.advance();
  5683. state.lastIntValue = ch;
  5684. return true
  5685. };
  5686.  
  5687. // https://tc39.es/ecma262/#prod-ClassSetReservedDoublePunctuator
  5688. function isClassSetReservedDoublePunctuatorCharacter(ch) {
  5689. return (
  5690. ch === 0x21 /* ! */ ||
  5691. ch >= 0x23 /* # */ && ch <= 0x26 /* & */ ||
  5692. ch >= 0x2A /* * */ && ch <= 0x2C /* , */ ||
  5693. ch === 0x2E /* . */ ||
  5694. ch >= 0x3A /* : */ && ch <= 0x40 /* @ */ ||
  5695. ch === 0x5E /* ^ */ ||
  5696. ch === 0x60 /* ` */ ||
  5697. ch === 0x7E /* ~ */
  5698. )
  5699. }
  5700.  
  5701. // https://tc39.es/ecma262/#prod-ClassSetSyntaxCharacter
  5702. function isClassSetSyntaxCharacter(ch) {
  5703. return (
  5704. ch === 0x28 /* ( */ ||
  5705. ch === 0x29 /* ) */ ||
  5706. ch === 0x2D /* - */ ||
  5707. ch === 0x2F /* / */ ||
  5708. ch >= 0x5B /* [ */ && ch <= 0x5D /* ] */ ||
  5709. ch >= 0x7B /* { */ && ch <= 0x7D /* } */
  5710. )
  5711. }
  5712.  
  5713. // https://tc39.es/ecma262/#prod-ClassSetReservedPunctuator
  5714. pp$1.regexp_eatClassSetReservedPunctuator = function(state) {
  5715. var ch = state.current();
  5716. if (isClassSetReservedPunctuator(ch)) {
  5717. state.lastIntValue = ch;
  5718. state.advance();
  5719. return true
  5720. }
  5721. return false
  5722. };
  5723.  
  5724. // https://tc39.es/ecma262/#prod-ClassSetReservedPunctuator
  5725. function isClassSetReservedPunctuator(ch) {
  5726. return (
  5727. ch === 0x21 /* ! */ ||
  5728. ch === 0x23 /* # */ ||
  5729. ch === 0x25 /* % */ ||
  5730. ch === 0x26 /* & */ ||
  5731. ch === 0x2C /* , */ ||
  5732. ch === 0x2D /* - */ ||
  5733. ch >= 0x3A /* : */ && ch <= 0x3E /* > */ ||
  5734. ch === 0x40 /* @ */ ||
  5735. ch === 0x60 /* ` */ ||
  5736. ch === 0x7E /* ~ */
  5737. )
  5738. }
  5739.  
  5740. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassControlLetter
  5741. pp$1.regexp_eatClassControlLetter = function(state) {
  5742. var ch = state.current();
  5743. if (isDecimalDigit(ch) || ch === 0x5F /* _ */) {
  5744. state.lastIntValue = ch % 0x20;
  5745. state.advance();
  5746. return true
  5747. }
  5748. return false
  5749. };
  5750.  
  5751. // https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
  5752. pp$1.regexp_eatHexEscapeSequence = function(state) {
  5753. var start = state.pos;
  5754. if (state.eat(0x78 /* x */)) {
  5755. if (this.regexp_eatFixedHexDigits(state, 2)) {
  5756. return true
  5757. }
  5758. if (state.switchU) {
  5759. state.raise("Invalid escape");
  5760. }
  5761. state.pos = start;
  5762. }
  5763. return false
  5764. };
  5765.  
  5766. // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalDigits
  5767. pp$1.regexp_eatDecimalDigits = function(state) {
  5768. var start = state.pos;
  5769. var ch = 0;
  5770. state.lastIntValue = 0;
  5771. while (isDecimalDigit(ch = state.current())) {
  5772. state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */);
  5773. state.advance();
  5774. }
  5775. return state.pos !== start
  5776. };
  5777. function isDecimalDigit(ch) {
  5778. return ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */
  5779. }
  5780.  
  5781. // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigits
  5782. pp$1.regexp_eatHexDigits = function(state) {
  5783. var start = state.pos;
  5784. var ch = 0;
  5785. state.lastIntValue = 0;
  5786. while (isHexDigit(ch = state.current())) {
  5787. state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
  5788. state.advance();
  5789. }
  5790. return state.pos !== start
  5791. };
  5792. function isHexDigit(ch) {
  5793. return (
  5794. (ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */) ||
  5795. (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) ||
  5796. (ch >= 0x61 /* a */ && ch <= 0x66 /* f */)
  5797. )
  5798. }
  5799. function hexToInt(ch) {
  5800. if (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) {
  5801. return 10 + (ch - 0x41 /* A */)
  5802. }
  5803. if (ch >= 0x61 /* a */ && ch <= 0x66 /* f */) {
  5804. return 10 + (ch - 0x61 /* a */)
  5805. }
  5806. return ch - 0x30 /* 0 */
  5807. }
  5808.  
  5809. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-LegacyOctalEscapeSequence
  5810. // Allows only 0-377(octal) i.e. 0-255(decimal).
  5811. pp$1.regexp_eatLegacyOctalEscapeSequence = function(state) {
  5812. if (this.regexp_eatOctalDigit(state)) {
  5813. var n1 = state.lastIntValue;
  5814. if (this.regexp_eatOctalDigit(state)) {
  5815. var n2 = state.lastIntValue;
  5816. if (n1 <= 3 && this.regexp_eatOctalDigit(state)) {
  5817. state.lastIntValue = n1 * 64 + n2 * 8 + state.lastIntValue;
  5818. } else {
  5819. state.lastIntValue = n1 * 8 + n2;
  5820. }
  5821. } else {
  5822. state.lastIntValue = n1;
  5823. }
  5824. return true
  5825. }
  5826. return false
  5827. };
  5828.  
  5829. // https://www.ecma-international.org/ecma-262/8.0/#prod-OctalDigit
  5830. pp$1.regexp_eatOctalDigit = function(state) {
  5831. var ch = state.current();
  5832. if (isOctalDigit(ch)) {
  5833. state.lastIntValue = ch - 0x30; /* 0 */
  5834. state.advance();
  5835. return true
  5836. }
  5837. state.lastIntValue = 0;
  5838. return false
  5839. };
  5840. function isOctalDigit(ch) {
  5841. return ch >= 0x30 /* 0 */ && ch <= 0x37 /* 7 */
  5842. }
  5843.  
  5844. // https://www.ecma-international.org/ecma-262/8.0/#prod-Hex4Digits
  5845. // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigit
  5846. // And HexDigit HexDigit in https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
  5847. pp$1.regexp_eatFixedHexDigits = function(state, length) {
  5848. var start = state.pos;
  5849. state.lastIntValue = 0;
  5850. for (var i = 0; i < length; ++i) {
  5851. var ch = state.current();
  5852. if (!isHexDigit(ch)) {
  5853. state.pos = start;
  5854. return false
  5855. }
  5856. state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
  5857. state.advance();
  5858. }
  5859. return true
  5860. };
  5861.  
  5862. // Object type used to represent tokens. Note that normally, tokens
  5863. // simply exist as properties on the parser object. This is only
  5864. // used for the onToken callback and the external tokenizer.
  5865.  
  5866. var Token = function Token(p) {
  5867. this.type = p.type;
  5868. this.value = p.value;
  5869. this.start = p.start;
  5870. this.end = p.end;
  5871. if (p.options.locations)
  5872. { this.loc = new SourceLocation(p, p.startLoc, p.endLoc); }
  5873. if (p.options.ranges)
  5874. { this.range = [p.start, p.end]; }
  5875. };
  5876.  
  5877. // ## Tokenizer
  5878.  
  5879. var pp = Parser.prototype;
  5880.  
  5881. // Move to the next token
  5882.  
  5883. pp.next = function(ignoreEscapeSequenceInKeyword) {
  5884. if (!ignoreEscapeSequenceInKeyword && this.type.keyword && this.containsEsc)
  5885. { this.raiseRecoverable(this.start, "Escape sequence in keyword " + this.type.keyword); }
  5886. if (this.options.onToken)
  5887. { this.options.onToken(new Token(this)); }
  5888.  
  5889. this.lastTokEnd = this.end;
  5890. this.lastTokStart = this.start;
  5891. this.lastTokEndLoc = this.endLoc;
  5892. this.lastTokStartLoc = this.startLoc;
  5893. this.nextToken();
  5894. };
  5895.  
  5896. pp.getToken = function() {
  5897. this.next();
  5898. return new Token(this)
  5899. };
  5900.  
  5901. // If we're in an ES6 environment, make parsers iterable
  5902. if (typeof Symbol !== "undefined")
  5903. { pp[Symbol.iterator] = function() {
  5904. var this$1$1 = this;
  5905.  
  5906. return {
  5907. next: function () {
  5908. var token = this$1$1.getToken();
  5909. return {
  5910. done: token.type === types$1.eof,
  5911. value: token
  5912. }
  5913. }
  5914. }
  5915. }; }
  5916.  
  5917. // Toggle strict mode. Re-reads the next number or string to please
  5918. // pedantic tests (`"use strict"; 010;` should fail).
  5919.  
  5920. // Read a single token, updating the parser object's token-related
  5921. // properties.
  5922.  
  5923. pp.nextToken = function() {
  5924. var curContext = this.curContext();
  5925. if (!curContext || !curContext.preserveSpace) { this.skipSpace(); }
  5926.  
  5927. this.start = this.pos;
  5928. if (this.options.locations) { this.startLoc = this.curPosition(); }
  5929. if (this.pos >= this.input.length) { return this.finishToken(types$1.eof) }
  5930.  
  5931. if (curContext.override) { return curContext.override(this) }
  5932. else { this.readToken(this.fullCharCodeAtPos()); }
  5933. };
  5934.  
  5935. pp.readToken = function(code) {
  5936. // Identifier or keyword. '\uXXXX' sequences are allowed in
  5937. // identifiers, so '\' also dispatches to that.
  5938. if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */)
  5939. { return this.readWord() }
  5940.  
  5941. return this.getTokenFromCode(code)
  5942. };
  5943.  
  5944. pp.fullCharCodeAtPos = function() {
  5945. var code = this.input.charCodeAt(this.pos);
  5946. if (code <= 0xd7ff || code >= 0xdc00) { return code }
  5947. var next = this.input.charCodeAt(this.pos + 1);
  5948. return next <= 0xdbff || next >= 0xe000 ? code : (code << 10) + next - 0x35fdc00
  5949. };
  5950.  
  5951. pp.skipBlockComment = function() {
  5952. var startLoc = this.options.onComment && this.curPosition();
  5953. var start = this.pos, end = this.input.indexOf("*/", this.pos += 2);
  5954. if (end === -1) { this.raise(this.pos - 2, "Unterminated comment"); }
  5955. this.pos = end + 2;
  5956. if (this.options.locations) {
  5957. for (var nextBreak = (void 0), pos = start; (nextBreak = nextLineBreak(this.input, pos, this.pos)) > -1;) {
  5958. ++this.curLine;
  5959. pos = this.lineStart = nextBreak;
  5960. }
  5961. }
  5962. if (this.options.onComment)
  5963. { this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos,
  5964. startLoc, this.curPosition()); }
  5965. };
  5966.  
  5967. pp.skipLineComment = function(startSkip) {
  5968. var start = this.pos;
  5969. var startLoc = this.options.onComment && this.curPosition();
  5970. var ch = this.input.charCodeAt(this.pos += startSkip);
  5971. while (this.pos < this.input.length && !isNewLine(ch)) {
  5972. ch = this.input.charCodeAt(++this.pos);
  5973. }
  5974. if (this.options.onComment)
  5975. { this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos,
  5976. startLoc, this.curPosition()); }
  5977. };
  5978.  
  5979. // Called at the start of the parse and after every token. Skips
  5980. // whitespace and comments, and.
  5981.  
  5982. pp.skipSpace = function() {
  5983. loop: while (this.pos < this.input.length) {
  5984. var ch = this.input.charCodeAt(this.pos);
  5985. switch (ch) {
  5986. case 32: case 160: // ' '
  5987. ++this.pos;
  5988. break
  5989. case 13:
  5990. if (this.input.charCodeAt(this.pos + 1) === 10) {
  5991. ++this.pos;
  5992. }
  5993. case 10: case 8232: case 8233:
  5994. ++this.pos;
  5995. if (this.options.locations) {
  5996. ++this.curLine;
  5997. this.lineStart = this.pos;
  5998. }
  5999. break
  6000. case 47: // '/'
  6001. switch (this.input.charCodeAt(this.pos + 1)) {
  6002. case 42: // '*'
  6003. this.skipBlockComment();
  6004. break
  6005. case 47:
  6006. this.skipLineComment(2);
  6007. break
  6008. default:
  6009. break loop
  6010. }
  6011. break
  6012. default:
  6013. if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {
  6014. ++this.pos;
  6015. } else {
  6016. break loop
  6017. }
  6018. }
  6019. }
  6020. };
  6021.  
  6022. // Called at the end of every token. Sets `end`, `val`, and
  6023. // maintains `context` and `exprAllowed`, and skips the space after
  6024. // the token, so that the next one's `start` will point at the
  6025. // right position.
  6026.  
  6027. pp.finishToken = function(type, val) {
  6028. this.end = this.pos;
  6029. if (this.options.locations) { this.endLoc = this.curPosition(); }
  6030. var prevType = this.type;
  6031. this.type = type;
  6032. this.value = val;
  6033.  
  6034. this.updateContext(prevType);
  6035. };
  6036.  
  6037. // ### Token reading
  6038.  
  6039. // This is the function that is called to fetch the next token. It
  6040. // is somewhat obscure, because it works in character codes rather
  6041. // than characters, and because operator parsing has been inlined
  6042. // into it.
  6043. //
  6044. // All in the name of speed.
  6045. //
  6046. pp.readToken_dot = function() {
  6047. var next = this.input.charCodeAt(this.pos + 1);
  6048. if (next >= 48 && next <= 57) { return this.readNumber(true) }
  6049. var next2 = this.input.charCodeAt(this.pos + 2);
  6050. if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.'
  6051. this.pos += 3;
  6052. return this.finishToken(types$1.ellipsis)
  6053. } else {
  6054. ++this.pos;
  6055. return this.finishToken(types$1.dot)
  6056. }
  6057. };
  6058.  
  6059. pp.readToken_slash = function() { // '/'
  6060. var next = this.input.charCodeAt(this.pos + 1);
  6061. if (this.exprAllowed) { ++this.pos; return this.readRegexp() }
  6062. if (next === 61) { return this.finishOp(types$1.assign, 2) }
  6063. return this.finishOp(types$1.slash, 1)
  6064. };
  6065.  
  6066. pp.readToken_mult_modulo_exp = function(code) { // '%*'
  6067. var next = this.input.charCodeAt(this.pos + 1);
  6068. var size = 1;
  6069. var tokentype = code === 42 ? types$1.star : types$1.modulo;
  6070.  
  6071. // exponentiation operator ** and **=
  6072. if (this.options.ecmaVersion >= 7 && code === 42 && next === 42) {
  6073. ++size;
  6074. tokentype = types$1.starstar;
  6075. next = this.input.charCodeAt(this.pos + 2);
  6076. }
  6077.  
  6078. if (next === 61) { return this.finishOp(types$1.assign, size + 1) }
  6079. return this.finishOp(tokentype, size)
  6080. };
  6081.  
  6082. pp.readToken_pipe_amp = function(code) { // '|&'
  6083. var next = this.input.charCodeAt(this.pos + 1);
  6084. if (next === code) {
  6085. if (this.options.ecmaVersion >= 12) {
  6086. var next2 = this.input.charCodeAt(this.pos + 2);
  6087. if (next2 === 61) { return this.finishOp(types$1.assign, 3) }
  6088. }
  6089. return this.finishOp(code === 124 ? types$1.logicalOR : types$1.logicalAND, 2)
  6090. }
  6091. if (next === 61) { return this.finishOp(types$1.assign, 2) }
  6092. return this.finishOp(code === 124 ? types$1.bitwiseOR : types$1.bitwiseAND, 1)
  6093. };
  6094.  
  6095. pp.readToken_caret = function() { // '^'
  6096. var next = this.input.charCodeAt(this.pos + 1);
  6097. if (next === 61) { return this.finishOp(types$1.assign, 2) }
  6098. return this.finishOp(types$1.bitwiseXOR, 1)
  6099. };
  6100.  
  6101. pp.readToken_plus_min = function(code) { // '+-'
  6102. var next = this.input.charCodeAt(this.pos + 1);
  6103. if (next === code) {
  6104. if (next === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 &&
  6105. (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) {
  6106. // A `-->` line comment
  6107. this.skipLineComment(3);
  6108. this.skipSpace();
  6109. return this.nextToken()
  6110. }
  6111. return this.finishOp(types$1.incDec, 2)
  6112. }
  6113. if (next === 61) { return this.finishOp(types$1.assign, 2) }
  6114. return this.finishOp(types$1.plusMin, 1)
  6115. };
  6116.  
  6117. pp.readToken_lt_gt = function(code) { // '<>'
  6118. var next = this.input.charCodeAt(this.pos + 1);
  6119. var size = 1;
  6120. if (next === code) {
  6121. size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;
  6122. if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types$1.assign, size + 1) }
  6123. return this.finishOp(types$1.bitShift, size)
  6124. }
  6125. if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 &&
  6126. this.input.charCodeAt(this.pos + 3) === 45) {
  6127. // `<!--`, an XML-style comment that should be interpreted as a line comment
  6128. this.skipLineComment(4);
  6129. this.skipSpace();
  6130. return this.nextToken()
  6131. }
  6132. if (next === 61) { size = 2; }
  6133. return this.finishOp(types$1.relational, size)
  6134. };
  6135.  
  6136. pp.readToken_eq_excl = function(code) { // '=!'
  6137. var next = this.input.charCodeAt(this.pos + 1);
  6138. if (next === 61) { return this.finishOp(types$1.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2) }
  6139. if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) { // '=>'
  6140. this.pos += 2;
  6141. return this.finishToken(types$1.arrow)
  6142. }
  6143. return this.finishOp(code === 61 ? types$1.eq : types$1.prefix, 1)
  6144. };
  6145.  
  6146. pp.readToken_question = function() { // '?'
  6147. var ecmaVersion = this.options.ecmaVersion;
  6148. if (ecmaVersion >= 11) {
  6149. var next = this.input.charCodeAt(this.pos + 1);
  6150. if (next === 46) {
  6151. var next2 = this.input.charCodeAt(this.pos + 2);
  6152. if (next2 < 48 || next2 > 57) { return this.finishOp(types$1.questionDot, 2) }
  6153. }
  6154. if (next === 63) {
  6155. if (ecmaVersion >= 12) {
  6156. var next2$1 = this.input.charCodeAt(this.pos + 2);
  6157. if (next2$1 === 61) { return this.finishOp(types$1.assign, 3) }
  6158. }
  6159. return this.finishOp(types$1.coalesce, 2)
  6160. }
  6161. }
  6162. return this.finishOp(types$1.question, 1)
  6163. };
  6164.  
  6165. pp.readToken_numberSign = function() { // '#'
  6166. var ecmaVersion = this.options.ecmaVersion;
  6167. var code = 35; // '#'
  6168. if (ecmaVersion >= 13) {
  6169. ++this.pos;
  6170. code = this.fullCharCodeAtPos();
  6171. if (isIdentifierStart(code, true) || code === 92 /* '\' */) {
  6172. return this.finishToken(types$1.privateId, this.readWord1())
  6173. }
  6174. }
  6175.  
  6176. this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
  6177. };
  6178.  
  6179. pp.getTokenFromCode = function(code) {
  6180. switch (code) {
  6181. // The interpretation of a dot depends on whether it is followed
  6182. // by a digit or another two dots.
  6183. case 46: // '.'
  6184. return this.readToken_dot()
  6185.  
  6186. // Punctuation tokens.
  6187. case 40: ++this.pos; return this.finishToken(types$1.parenL)
  6188. case 41: ++this.pos; return this.finishToken(types$1.parenR)
  6189. case 59: ++this.pos; return this.finishToken(types$1.semi)
  6190. case 44: ++this.pos; return this.finishToken(types$1.comma)
  6191. case 91: ++this.pos; return this.finishToken(types$1.bracketL)
  6192. case 93: ++this.pos; return this.finishToken(types$1.bracketR)
  6193. case 123: ++this.pos; return this.finishToken(types$1.braceL)
  6194. case 125: ++this.pos; return this.finishToken(types$1.braceR)
  6195. case 58: ++this.pos; return this.finishToken(types$1.colon)
  6196.  
  6197. case 96: // '`'
  6198. if (this.options.ecmaVersion < 6) { break }
  6199. ++this.pos;
  6200. return this.finishToken(types$1.backQuote)
  6201.  
  6202. case 48: // '0'
  6203. var next = this.input.charCodeAt(this.pos + 1);
  6204. if (next === 120 || next === 88) { return this.readRadixNumber(16) } // '0x', '0X' - hex number
  6205. if (this.options.ecmaVersion >= 6) {
  6206. if (next === 111 || next === 79) { return this.readRadixNumber(8) } // '0o', '0O' - octal number
  6207. if (next === 98 || next === 66) { return this.readRadixNumber(2) } // '0b', '0B' - binary number
  6208. }
  6209.  
  6210. // Anything else beginning with a digit is an integer, octal
  6211. // number, or float.
  6212. case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: // 1-9
  6213. return this.readNumber(false)
  6214.  
  6215. // Quotes produce strings.
  6216. case 34: case 39: // '"', "'"
  6217. return this.readString(code)
  6218.  
  6219. // Operators are parsed inline in tiny state machines. '=' (61) is
  6220. // often referred to. `finishOp` simply skips the amount of
  6221. // characters it is given as second argument, and returns a token
  6222. // of the type given by its first argument.
  6223. case 47: // '/'
  6224. return this.readToken_slash()
  6225.  
  6226. case 37: case 42: // '%*'
  6227. return this.readToken_mult_modulo_exp(code)
  6228.  
  6229. case 124: case 38: // '|&'
  6230. return this.readToken_pipe_amp(code)
  6231.  
  6232. case 94: // '^'
  6233. return this.readToken_caret()
  6234.  
  6235. case 43: case 45: // '+-'
  6236. return this.readToken_plus_min(code)
  6237.  
  6238. case 60: case 62: // '<>'
  6239. return this.readToken_lt_gt(code)
  6240.  
  6241. case 61: case 33: // '=!'
  6242. return this.readToken_eq_excl(code)
  6243.  
  6244. case 63: // '?'
  6245. return this.readToken_question()
  6246.  
  6247. case 126: // '~'
  6248. return this.finishOp(types$1.prefix, 1)
  6249.  
  6250. case 35: // '#'
  6251. return this.readToken_numberSign()
  6252. }
  6253.  
  6254. this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
  6255. };
  6256.  
  6257. pp.finishOp = function(type, size) {
  6258. var str = this.input.slice(this.pos, this.pos + size);
  6259. this.pos += size;
  6260. return this.finishToken(type, str)
  6261. };
  6262.  
  6263. pp.readRegexp = function() {
  6264. var escaped, inClass, start = this.pos;
  6265. for (;;) {
  6266. if (this.pos >= this.input.length) { this.raise(start, "Unterminated regular expression"); }
  6267. var ch = this.input.charAt(this.pos);
  6268. if (lineBreak.test(ch)) { this.raise(start, "Unterminated regular expression"); }
  6269. if (!escaped) {
  6270. if (ch === "[") { inClass = true; }
  6271. else if (ch === "]" && inClass) { inClass = false; }
  6272. else if (ch === "/" && !inClass) { break }
  6273. escaped = ch === "\\";
  6274. } else { escaped = false; }
  6275. ++this.pos;
  6276. }
  6277. var pattern = this.input.slice(start, this.pos);
  6278. ++this.pos;
  6279. var flagsStart = this.pos;
  6280. var flags = this.readWord1();
  6281. if (this.containsEsc) { this.unexpected(flagsStart); }
  6282.  
  6283. // Validate pattern
  6284. var state = this.regexpState || (this.regexpState = new RegExpValidationState(this));
  6285. state.reset(start, pattern, flags);
  6286. this.validateRegExpFlags(state);
  6287. this.validateRegExpPattern(state);
  6288.  
  6289. // Create Literal#value property value.
  6290. var value = null;
  6291. try {
  6292. value = new RegExp(pattern, flags);
  6293. } catch (e) {
  6294. // ESTree requires null if it failed to instantiate RegExp object.
  6295. // https://github.com/estree/estree/blob/a27003adf4fd7bfad44de9cef372a2eacd527b1c/es5.md#regexpliteral
  6296. }
  6297.  
  6298. return this.finishToken(types$1.regexp, {pattern: pattern, flags: flags, value: value})
  6299. };
  6300.  
  6301. // Read an integer in the given radix. Return null if zero digits
  6302. // were read, the integer value otherwise. When `len` is given, this
  6303. // will return `null` unless the integer has exactly `len` digits.
  6304.  
  6305. pp.readInt = function(radix, len, maybeLegacyOctalNumericLiteral) {
  6306. // `len` is used for character escape sequences. In that case, disallow separators.
  6307. var allowSeparators = this.options.ecmaVersion >= 12 && len === undefined;
  6308.  
  6309. // `maybeLegacyOctalNumericLiteral` is true if it doesn't have prefix (0x,0o,0b)
  6310. // and isn't fraction part nor exponent part. In that case, if the first digit
  6311. // is zero then disallow separators.
  6312. var isLegacyOctalNumericLiteral = maybeLegacyOctalNumericLiteral && this.input.charCodeAt(this.pos) === 48;
  6313.  
  6314. var start = this.pos, total = 0, lastCode = 0;
  6315. for (var i = 0, e = len == null ? Infinity : len; i < e; ++i, ++this.pos) {
  6316. var code = this.input.charCodeAt(this.pos), val = (void 0);
  6317.  
  6318. if (allowSeparators && code === 95) {
  6319. if (isLegacyOctalNumericLiteral) { this.raiseRecoverable(this.pos, "Numeric separator is not allowed in legacy octal numeric literals"); }
  6320. if (lastCode === 95) { this.raiseRecoverable(this.pos, "Numeric separator must be exactly one underscore"); }
  6321. if (i === 0) { this.raiseRecoverable(this.pos, "Numeric separator is not allowed at the first of digits"); }
  6322. lastCode = code;
  6323. continue
  6324. }
  6325.  
  6326. if (code >= 97) { val = code - 97 + 10; } // a
  6327. else if (code >= 65) { val = code - 65 + 10; } // A
  6328. else if (code >= 48 && code <= 57) { val = code - 48; } // 0-9
  6329. else { val = Infinity; }
  6330. if (val >= radix) { break }
  6331. lastCode = code;
  6332. total = total * radix + val;
  6333. }
  6334.  
  6335. if (allowSeparators && lastCode === 95) { this.raiseRecoverable(this.pos - 1, "Numeric separator is not allowed at the last of digits"); }
  6336. if (this.pos === start || len != null && this.pos - start !== len) { return null }
  6337.  
  6338. return total
  6339. };
  6340.  
  6341. function stringToNumber(str, isLegacyOctalNumericLiteral) {
  6342. if (isLegacyOctalNumericLiteral) {
  6343. return parseInt(str, 8)
  6344. }
  6345.  
  6346. // `parseFloat(value)` stops parsing at the first numeric separator then returns a wrong value.
  6347. return parseFloat(str.replace(/_/g, ""))
  6348. }
  6349.  
  6350. function stringToBigInt(str) {
  6351. if (typeof BigInt !== "function") {
  6352. return null
  6353. }
  6354.  
  6355. // `BigInt(value)` throws syntax error if the string contains numeric separators.
  6356. return BigInt(str.replace(/_/g, ""))
  6357. }
  6358.  
  6359. pp.readRadixNumber = function(radix) {
  6360. var start = this.pos;
  6361. this.pos += 2; // 0x
  6362. var val = this.readInt(radix);
  6363. if (val == null) { this.raise(this.start + 2, "Expected number in radix " + radix); }
  6364. if (this.options.ecmaVersion >= 11 && this.input.charCodeAt(this.pos) === 110) {
  6365. val = stringToBigInt(this.input.slice(start, this.pos));
  6366. ++this.pos;
  6367. } else if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
  6368. return this.finishToken(types$1.num, val)
  6369. };
  6370.  
  6371. // Read an integer, octal integer, or floating-point number.
  6372.  
  6373. pp.readNumber = function(startsWithDot) {
  6374. var start = this.pos;
  6375. if (!startsWithDot && this.readInt(10, undefined, true) === null) { this.raise(start, "Invalid number"); }
  6376. var octal = this.pos - start >= 2 && this.input.charCodeAt(start) === 48;
  6377. if (octal && this.strict) { this.raise(start, "Invalid number"); }
  6378. var next = this.input.charCodeAt(this.pos);
  6379. if (!octal && !startsWithDot && this.options.ecmaVersion >= 11 && next === 110) {
  6380. var val$1 = stringToBigInt(this.input.slice(start, this.pos));
  6381. ++this.pos;
  6382. if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
  6383. return this.finishToken(types$1.num, val$1)
  6384. }
  6385. if (octal && /[89]/.test(this.input.slice(start, this.pos))) { octal = false; }
  6386. if (next === 46 && !octal) { // '.'
  6387. ++this.pos;
  6388. this.readInt(10);
  6389. next = this.input.charCodeAt(this.pos);
  6390. }
  6391. if ((next === 69 || next === 101) && !octal) { // 'eE'
  6392. next = this.input.charCodeAt(++this.pos);
  6393. if (next === 43 || next === 45) { ++this.pos; } // '+-'
  6394. if (this.readInt(10) === null) { this.raise(start, "Invalid number"); }
  6395. }
  6396. if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
  6397.  
  6398. var val = stringToNumber(this.input.slice(start, this.pos), octal);
  6399. return this.finishToken(types$1.num, val)
  6400. };
  6401.  
  6402. // Read a string value, interpreting backslash-escapes.
  6403.  
  6404. pp.readCodePoint = function() {
  6405. var ch = this.input.charCodeAt(this.pos), code;
  6406.  
  6407. if (ch === 123) { // '{'
  6408. if (this.options.ecmaVersion < 6) { this.unexpected(); }
  6409. var codePos = ++this.pos;
  6410. code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);
  6411. ++this.pos;
  6412. if (code > 0x10FFFF) { this.invalidStringToken(codePos, "Code point out of bounds"); }
  6413. } else {
  6414. code = this.readHexChar(4);
  6415. }
  6416. return code
  6417. };
  6418.  
  6419. pp.readString = function(quote) {
  6420. var out = "", chunkStart = ++this.pos;
  6421. for (;;) {
  6422. if (this.pos >= this.input.length) { this.raise(this.start, "Unterminated string constant"); }
  6423. var ch = this.input.charCodeAt(this.pos);
  6424. if (ch === quote) { break }
  6425. if (ch === 92) { // '\'
  6426. out += this.input.slice(chunkStart, this.pos);
  6427. out += this.readEscapedChar(false);
  6428. chunkStart = this.pos;
  6429. } else if (ch === 0x2028 || ch === 0x2029) {
  6430. if (this.options.ecmaVersion < 10) { this.raise(this.start, "Unterminated string constant"); }
  6431. ++this.pos;
  6432. if (this.options.locations) {
  6433. this.curLine++;
  6434. this.lineStart = this.pos;
  6435. }
  6436. } else {
  6437. if (isNewLine(ch)) { this.raise(this.start, "Unterminated string constant"); }
  6438. ++this.pos;
  6439. }
  6440. }
  6441. out += this.input.slice(chunkStart, this.pos++);
  6442. return this.finishToken(types$1.string, out)
  6443. };
  6444.  
  6445. // Reads template string tokens.
  6446.  
  6447. var INVALID_TEMPLATE_ESCAPE_ERROR = {};
  6448.  
  6449. pp.tryReadTemplateToken = function() {
  6450. this.inTemplateElement = true;
  6451. try {
  6452. this.readTmplToken();
  6453. } catch (err) {
  6454. if (err === INVALID_TEMPLATE_ESCAPE_ERROR) {
  6455. this.readInvalidTemplateToken();
  6456. } else {
  6457. throw err
  6458. }
  6459. }
  6460.  
  6461. this.inTemplateElement = false;
  6462. };
  6463.  
  6464. pp.invalidStringToken = function(position, message) {
  6465. if (this.inTemplateElement && this.options.ecmaVersion >= 9) {
  6466. throw INVALID_TEMPLATE_ESCAPE_ERROR
  6467. } else {
  6468. this.raise(position, message);
  6469. }
  6470. };
  6471.  
  6472. pp.readTmplToken = function() {
  6473. var out = "", chunkStart = this.pos;
  6474. for (;;) {
  6475. if (this.pos >= this.input.length) { this.raise(this.start, "Unterminated template"); }
  6476. var ch = this.input.charCodeAt(this.pos);
  6477. if (ch === 96 || ch === 36 && this.input.charCodeAt(this.pos + 1) === 123) { // '`', '${'
  6478. if (this.pos === this.start && (this.type === types$1.template || this.type === types$1.invalidTemplate)) {
  6479. if (ch === 36) {
  6480. this.pos += 2;
  6481. return this.finishToken(types$1.dollarBraceL)
  6482. } else {
  6483. ++this.pos;
  6484. return this.finishToken(types$1.backQuote)
  6485. }
  6486. }
  6487. out += this.input.slice(chunkStart, this.pos);
  6488. return this.finishToken(types$1.template, out)
  6489. }
  6490. if (ch === 92) { // '\'
  6491. out += this.input.slice(chunkStart, this.pos);
  6492. out += this.readEscapedChar(true);
  6493. chunkStart = this.pos;
  6494. } else if (isNewLine(ch)) {
  6495. out += this.input.slice(chunkStart, this.pos);
  6496. ++this.pos;
  6497. switch (ch) {
  6498. case 13:
  6499. if (this.input.charCodeAt(this.pos) === 10) { ++this.pos; }
  6500. case 10:
  6501. out += "\n";
  6502. break
  6503. default:
  6504. out += String.fromCharCode(ch);
  6505. break
  6506. }
  6507. if (this.options.locations) {
  6508. ++this.curLine;
  6509. this.lineStart = this.pos;
  6510. }
  6511. chunkStart = this.pos;
  6512. } else {
  6513. ++this.pos;
  6514. }
  6515. }
  6516. };
  6517.  
  6518. // Reads a template token to search for the end, without validating any escape sequences
  6519. pp.readInvalidTemplateToken = function() {
  6520. for (; this.pos < this.input.length; this.pos++) {
  6521. switch (this.input[this.pos]) {
  6522. case "\\":
  6523. ++this.pos;
  6524. break
  6525.  
  6526. case "$":
  6527. if (this.input[this.pos + 1] !== "{") {
  6528. break
  6529. }
  6530.  
  6531. // falls through
  6532. case "`":
  6533. return this.finishToken(types$1.invalidTemplate, this.input.slice(this.start, this.pos))
  6534.  
  6535. // no default
  6536. }
  6537. }
  6538. this.raise(this.start, "Unterminated template");
  6539. };
  6540.  
  6541. // Used to read escaped characters
  6542.  
  6543. pp.readEscapedChar = function(inTemplate) {
  6544. var ch = this.input.charCodeAt(++this.pos);
  6545. ++this.pos;
  6546. switch (ch) {
  6547. case 110: return "\n" // 'n' -> '\n'
  6548. case 114: return "\r" // 'r' -> '\r'
  6549. case 120: return String.fromCharCode(this.readHexChar(2)) // 'x'
  6550. case 117: return codePointToString(this.readCodePoint()) // 'u'
  6551. case 116: return "\t" // 't' -> '\t'
  6552. case 98: return "\b" // 'b' -> '\b'
  6553. case 118: return "\u000b" // 'v' -> '\u000b'
  6554. case 102: return "\f" // 'f' -> '\f'
  6555. case 13: if (this.input.charCodeAt(this.pos) === 10) { ++this.pos; } // '\r\n'
  6556. case 10: // ' \n'
  6557. if (this.options.locations) { this.lineStart = this.pos; ++this.curLine; }
  6558. return ""
  6559. case 56:
  6560. case 57:
  6561. if (this.strict) {
  6562. this.invalidStringToken(
  6563. this.pos - 1,
  6564. "Invalid escape sequence"
  6565. );
  6566. }
  6567. if (inTemplate) {
  6568. var codePos = this.pos - 1;
  6569.  
  6570. this.invalidStringToken(
  6571. codePos,
  6572. "Invalid escape sequence in template string"
  6573. );
  6574. }
  6575. default:
  6576. if (ch >= 48 && ch <= 55) {
  6577. var octalStr = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0];
  6578. var octal = parseInt(octalStr, 8);
  6579. if (octal > 255) {
  6580. octalStr = octalStr.slice(0, -1);
  6581. octal = parseInt(octalStr, 8);
  6582. }
  6583. this.pos += octalStr.length - 1;
  6584. ch = this.input.charCodeAt(this.pos);
  6585. if ((octalStr !== "0" || ch === 56 || ch === 57) && (this.strict || inTemplate)) {
  6586. this.invalidStringToken(
  6587. this.pos - 1 - octalStr.length,
  6588. inTemplate
  6589. ? "Octal literal in template string"
  6590. : "Octal literal in strict mode"
  6591. );
  6592. }
  6593. return String.fromCharCode(octal)
  6594. }
  6595. if (isNewLine(ch)) {
  6596. // Unicode new line characters after \ get removed from output in both
  6597. // template literals and strings
  6598. return ""
  6599. }
  6600. return String.fromCharCode(ch)
  6601. }
  6602. };
  6603.  
  6604. // Used to read character escape sequences ('\x', '\u', '\U').
  6605.  
  6606. pp.readHexChar = function(len) {
  6607. var codePos = this.pos;
  6608. var n = this.readInt(16, len);
  6609. if (n === null) { this.invalidStringToken(codePos, "Bad character escape sequence"); }
  6610. return n
  6611. };
  6612.  
  6613. // Read an identifier, and return it as a string. Sets `this.containsEsc`
  6614. // to whether the word contained a '\u' escape.
  6615. //
  6616. // Incrementally adds only escaped chars, adding other chunks as-is
  6617. // as a micro-optimization.
  6618.  
  6619. pp.readWord1 = function() {
  6620. this.containsEsc = false;
  6621. var word = "", first = true, chunkStart = this.pos;
  6622. var astral = this.options.ecmaVersion >= 6;
  6623. while (this.pos < this.input.length) {
  6624. var ch = this.fullCharCodeAtPos();
  6625. if (isIdentifierChar(ch, astral)) {
  6626. this.pos += ch <= 0xffff ? 1 : 2;
  6627. } else if (ch === 92) { // "\"
  6628. this.containsEsc = true;
  6629. word += this.input.slice(chunkStart, this.pos);
  6630. var escStart = this.pos;
  6631. if (this.input.charCodeAt(++this.pos) !== 117) // "u"
  6632. { this.invalidStringToken(this.pos, "Expecting Unicode escape sequence \\uXXXX"); }
  6633. ++this.pos;
  6634. var esc = this.readCodePoint();
  6635. if (!(first ? isIdentifierStart : isIdentifierChar)(esc, astral))
  6636. { this.invalidStringToken(escStart, "Invalid Unicode escape"); }
  6637. word += codePointToString(esc);
  6638. chunkStart = this.pos;
  6639. } else {
  6640. break
  6641. }
  6642. first = false;
  6643. }
  6644. return word + this.input.slice(chunkStart, this.pos)
  6645. };
  6646.  
  6647. // Read an identifier or keyword token. Will check for reserved
  6648. // words when necessary.
  6649.  
  6650. pp.readWord = function() {
  6651. var word = this.readWord1();
  6652. var type = types$1.name;
  6653. if (this.keywords.test(word)) {
  6654. type = keywords[word];
  6655. }
  6656. return this.finishToken(type, word)
  6657. };
  6658.  
  6659. // Acorn is a tiny, fast JavaScript parser written in JavaScript.
  6660. //
  6661. // Acorn was written by Marijn Haverbeke, Ingvar Stepanyan, and
  6662. // various contributors and released under an MIT license.
  6663. //
  6664. // Git repositories for Acorn are available at
  6665. //
  6666. // http://marijnhaverbeke.nl/git/acorn
  6667. // https://github.com/acornjs/acorn.git
  6668. //
  6669. // Please use the [github bug tracker][ghbt] to report issues.
  6670. //
  6671. // [ghbt]: https://github.com/acornjs/acorn/issues
  6672. //
  6673. // [walk]: util/walk.js
  6674.  
  6675.  
  6676. var version = "8.11.2";
  6677.  
  6678. Parser.acorn = {
  6679. Parser: Parser,
  6680. version: version,
  6681. defaultOptions: defaultOptions,
  6682. Position: Position,
  6683. SourceLocation: SourceLocation,
  6684. getLineInfo: getLineInfo,
  6685. Node: Node,
  6686. TokenType: TokenType,
  6687. tokTypes: types$1,
  6688. keywordTypes: keywords,
  6689. TokContext: TokContext,
  6690. tokContexts: types,
  6691. isIdentifierChar: isIdentifierChar,
  6692. isIdentifierStart: isIdentifierStart,
  6693. Token: Token,
  6694. isNewLine: isNewLine,
  6695. lineBreak: lineBreak,
  6696. lineBreakG: lineBreakG,
  6697. nonASCIIwhitespace: nonASCIIwhitespace
  6698. };
  6699.  
  6700. // The main exported interface (under `self.acorn` when in the
  6701. // browser) is a `parse` function that takes a code string and
  6702. // returns an abstract syntax tree as specified by [Mozilla parser
  6703. // API][api].
  6704. //
  6705. // [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
  6706.  
  6707. function parse(input, options) {
  6708. return Parser.parse(input, options)
  6709. }
  6710.  
  6711. // This function tries to parse a single expression at a given
  6712. // offset in a string. Useful for parsing mixed-language formats
  6713. // that embed JavaScript expressions.
  6714.  
  6715. function parseExpressionAt(input, pos, options) {
  6716. return Parser.parseExpressionAt(input, pos, options)
  6717. }
  6718.  
  6719. // Acorn is organized as a tokenizer and a recursive-descent parser.
  6720. // The `tokenizer` export provides an interface to the tokenizer.
  6721.  
  6722. function tokenizer(input, options) {
  6723. return Parser.tokenizer(input, options)
  6724. }
  6725.  
  6726. exports.Node = Node;
  6727. exports.Parser = Parser;
  6728. exports.Position = Position;
  6729. exports.SourceLocation = SourceLocation;
  6730. exports.TokContext = TokContext;
  6731. exports.Token = Token;
  6732. exports.TokenType = TokenType;
  6733. exports.defaultOptions = defaultOptions;
  6734. exports.getLineInfo = getLineInfo;
  6735. exports.isIdentifierChar = isIdentifierChar;
  6736. exports.isIdentifierStart = isIdentifierStart;
  6737. exports.isNewLine = isNewLine;
  6738. exports.keywordTypes = keywords;
  6739. exports.lineBreak = lineBreak;
  6740. exports.lineBreakG = lineBreakG;
  6741. exports.nonASCIIwhitespace = nonASCIIwhitespace;
  6742. exports.parse = parse;
  6743. exports.parseExpressionAt = parseExpressionAt;
  6744. exports.tokContexts = types;
  6745. exports.tokTypes = types$1;
  6746. exports.tokenizer = tokenizer;
  6747. exports.version = version;
  6748.  
  6749. }));
  6750.  
  6751. },{}],4:[function(require,module,exports){
  6752. 'use strict';
  6753.  
  6754. Object.defineProperty(exports, '__esModule', { value: true });
  6755.  
  6756. /**
  6757. * @typedef {{ readonly [type: string]: ReadonlyArray<string> }} VisitorKeys
  6758. */
  6759.  
  6760. /**
  6761. * @type {VisitorKeys}
  6762. */
  6763. const KEYS = {
  6764. ArrayExpression: [
  6765. "elements"
  6766. ],
  6767. ArrayPattern: [
  6768. "elements"
  6769. ],
  6770. ArrowFunctionExpression: [
  6771. "params",
  6772. "body"
  6773. ],
  6774. AssignmentExpression: [
  6775. "left",
  6776. "right"
  6777. ],
  6778. AssignmentPattern: [
  6779. "left",
  6780. "right"
  6781. ],
  6782. AwaitExpression: [
  6783. "argument"
  6784. ],
  6785. BinaryExpression: [
  6786. "left",
  6787. "right"
  6788. ],
  6789. BlockStatement: [
  6790. "body"
  6791. ],
  6792. BreakStatement: [
  6793. "label"
  6794. ],
  6795. CallExpression: [
  6796. "callee",
  6797. "arguments"
  6798. ],
  6799. CatchClause: [
  6800. "param",
  6801. "body"
  6802. ],
  6803. ChainExpression: [
  6804. "expression"
  6805. ],
  6806. ClassBody: [
  6807. "body"
  6808. ],
  6809. ClassDeclaration: [
  6810. "id",
  6811. "superClass",
  6812. "body"
  6813. ],
  6814. ClassExpression: [
  6815. "id",
  6816. "superClass",
  6817. "body"
  6818. ],
  6819. ConditionalExpression: [
  6820. "test",
  6821. "consequent",
  6822. "alternate"
  6823. ],
  6824. ContinueStatement: [
  6825. "label"
  6826. ],
  6827. DebuggerStatement: [],
  6828. DoWhileStatement: [
  6829. "body",
  6830. "test"
  6831. ],
  6832. EmptyStatement: [],
  6833. ExperimentalRestProperty: [
  6834. "argument"
  6835. ],
  6836. ExperimentalSpreadProperty: [
  6837. "argument"
  6838. ],
  6839. ExportAllDeclaration: [
  6840. "exported",
  6841. "source"
  6842. ],
  6843. ExportDefaultDeclaration: [
  6844. "declaration"
  6845. ],
  6846. ExportNamedDeclaration: [
  6847. "declaration",
  6848. "specifiers",
  6849. "source"
  6850. ],
  6851. ExportSpecifier: [
  6852. "exported",
  6853. "local"
  6854. ],
  6855. ExpressionStatement: [
  6856. "expression"
  6857. ],
  6858. ForInStatement: [
  6859. "left",
  6860. "right",
  6861. "body"
  6862. ],
  6863. ForOfStatement: [
  6864. "left",
  6865. "right",
  6866. "body"
  6867. ],
  6868. ForStatement: [
  6869. "init",
  6870. "test",
  6871. "update",
  6872. "body"
  6873. ],
  6874. FunctionDeclaration: [
  6875. "id",
  6876. "params",
  6877. "body"
  6878. ],
  6879. FunctionExpression: [
  6880. "id",
  6881. "params",
  6882. "body"
  6883. ],
  6884. Identifier: [],
  6885. IfStatement: [
  6886. "test",
  6887. "consequent",
  6888. "alternate"
  6889. ],
  6890. ImportDeclaration: [
  6891. "specifiers",
  6892. "source"
  6893. ],
  6894. ImportDefaultSpecifier: [
  6895. "local"
  6896. ],
  6897. ImportExpression: [
  6898. "source"
  6899. ],
  6900. ImportNamespaceSpecifier: [
  6901. "local"
  6902. ],
  6903. ImportSpecifier: [
  6904. "imported",
  6905. "local"
  6906. ],
  6907. JSXAttribute: [
  6908. "name",
  6909. "value"
  6910. ],
  6911. JSXClosingElement: [
  6912. "name"
  6913. ],
  6914. JSXClosingFragment: [],
  6915. JSXElement: [
  6916. "openingElement",
  6917. "children",
  6918. "closingElement"
  6919. ],
  6920. JSXEmptyExpression: [],
  6921. JSXExpressionContainer: [
  6922. "expression"
  6923. ],
  6924. JSXFragment: [
  6925. "openingFragment",
  6926. "children",
  6927. "closingFragment"
  6928. ],
  6929. JSXIdentifier: [],
  6930. JSXMemberExpression: [
  6931. "object",
  6932. "property"
  6933. ],
  6934. JSXNamespacedName: [
  6935. "namespace",
  6936. "name"
  6937. ],
  6938. JSXOpeningElement: [
  6939. "name",
  6940. "attributes"
  6941. ],
  6942. JSXOpeningFragment: [],
  6943. JSXSpreadAttribute: [
  6944. "argument"
  6945. ],
  6946. JSXSpreadChild: [
  6947. "expression"
  6948. ],
  6949. JSXText: [],
  6950. LabeledStatement: [
  6951. "label",
  6952. "body"
  6953. ],
  6954. Literal: [],
  6955. LogicalExpression: [
  6956. "left",
  6957. "right"
  6958. ],
  6959. MemberExpression: [
  6960. "object",
  6961. "property"
  6962. ],
  6963. MetaProperty: [
  6964. "meta",
  6965. "property"
  6966. ],
  6967. MethodDefinition: [
  6968. "key",
  6969. "value"
  6970. ],
  6971. NewExpression: [
  6972. "callee",
  6973. "arguments"
  6974. ],
  6975. ObjectExpression: [
  6976. "properties"
  6977. ],
  6978. ObjectPattern: [
  6979. "properties"
  6980. ],
  6981. PrivateIdentifier: [],
  6982. Program: [
  6983. "body"
  6984. ],
  6985. Property: [
  6986. "key",
  6987. "value"
  6988. ],
  6989. PropertyDefinition: [
  6990. "key",
  6991. "value"
  6992. ],
  6993. RestElement: [
  6994. "argument"
  6995. ],
  6996. ReturnStatement: [
  6997. "argument"
  6998. ],
  6999. SequenceExpression: [
  7000. "expressions"
  7001. ],
  7002. SpreadElement: [
  7003. "argument"
  7004. ],
  7005. StaticBlock: [
  7006. "body"
  7007. ],
  7008. Super: [],
  7009. SwitchCase: [
  7010. "test",
  7011. "consequent"
  7012. ],
  7013. SwitchStatement: [
  7014. "discriminant",
  7015. "cases"
  7016. ],
  7017. TaggedTemplateExpression: [
  7018. "tag",
  7019. "quasi"
  7020. ],
  7021. TemplateElement: [],
  7022. TemplateLiteral: [
  7023. "quasis",
  7024. "expressions"
  7025. ],
  7026. ThisExpression: [],
  7027. ThrowStatement: [
  7028. "argument"
  7029. ],
  7030. TryStatement: [
  7031. "block",
  7032. "handler",
  7033. "finalizer"
  7034. ],
  7035. UnaryExpression: [
  7036. "argument"
  7037. ],
  7038. UpdateExpression: [
  7039. "argument"
  7040. ],
  7041. VariableDeclaration: [
  7042. "declarations"
  7043. ],
  7044. VariableDeclarator: [
  7045. "id",
  7046. "init"
  7047. ],
  7048. WhileStatement: [
  7049. "test",
  7050. "body"
  7051. ],
  7052. WithStatement: [
  7053. "object",
  7054. "body"
  7055. ],
  7056. YieldExpression: [
  7057. "argument"
  7058. ]
  7059. };
  7060.  
  7061. // Types.
  7062. const NODE_TYPES = Object.keys(KEYS);
  7063.  
  7064. // Freeze the keys.
  7065. for (const type of NODE_TYPES) {
  7066. Object.freeze(KEYS[type]);
  7067. }
  7068. Object.freeze(KEYS);
  7069.  
  7070. /**
  7071. * @author Toru Nagashima <https://github.com/mysticatea>
  7072. * See LICENSE file in root directory for full license.
  7073. */
  7074.  
  7075. /**
  7076. * @typedef {import('./visitor-keys.js').VisitorKeys} VisitorKeys
  7077. */
  7078.  
  7079. // List to ignore keys.
  7080. const KEY_BLACKLIST = new Set([
  7081. "parent",
  7082. "leadingComments",
  7083. "trailingComments"
  7084. ]);
  7085.  
  7086. /**
  7087. * Check whether a given key should be used or not.
  7088. * @param {string} key The key to check.
  7089. * @returns {boolean} `true` if the key should be used.
  7090. */
  7091. function filterKey(key) {
  7092. return !KEY_BLACKLIST.has(key) && key[0] !== "_";
  7093. }
  7094.  
  7095. /**
  7096. * Get visitor keys of a given node.
  7097. * @param {object} node The AST node to get keys.
  7098. * @returns {readonly string[]} Visitor keys of the node.
  7099. */
  7100. function getKeys(node) {
  7101. return Object.keys(node).filter(filterKey);
  7102. }
  7103.  
  7104. // Disable valid-jsdoc rule because it reports syntax error on the type of @returns.
  7105. // eslint-disable-next-line valid-jsdoc
  7106. /**
  7107. * Make the union set with `KEYS` and given keys.
  7108. * @param {VisitorKeys} additionalKeys The additional keys.
  7109. * @returns {VisitorKeys} The union set.
  7110. */
  7111. function unionWith(additionalKeys) {
  7112. const retv = /** @type {{
  7113. [type: string]: ReadonlyArray<string>
  7114. }} */ (Object.assign({}, KEYS));
  7115.  
  7116. for (const type of Object.keys(additionalKeys)) {
  7117. if (Object.prototype.hasOwnProperty.call(retv, type)) {
  7118. const keys = new Set(additionalKeys[type]);
  7119.  
  7120. for (const key of retv[type]) {
  7121. keys.add(key);
  7122. }
  7123.  
  7124. retv[type] = Object.freeze(Array.from(keys));
  7125. } else {
  7126. retv[type] = Object.freeze(Array.from(additionalKeys[type]));
  7127. }
  7128. }
  7129.  
  7130. return Object.freeze(retv);
  7131. }
  7132.  
  7133. exports.KEYS = KEYS;
  7134. exports.getKeys = getKeys;
  7135. exports.unionWith = unionWith;
  7136.  
  7137. },{}],"espree":[function(require,module,exports){
  7138. 'use strict';
  7139.  
  7140. Object.defineProperty(exports, '__esModule', { value: true });
  7141.  
  7142. var acorn = require('acorn');
  7143. var jsx = require('acorn-jsx');
  7144. var visitorKeys = require('eslint-visitor-keys');
  7145.  
  7146. function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
  7147.  
  7148. function _interopNamespace(e) {
  7149. if (e && e.__esModule) return e;
  7150. var n = Object.create(null);
  7151. if (e) {
  7152. Object.keys(e).forEach(function (k) {
  7153. if (k !== 'default') {
  7154. var d = Object.getOwnPropertyDescriptor(e, k);
  7155. Object.defineProperty(n, k, d.get ? d : {
  7156. enumerable: true,
  7157. get: function () { return e[k]; }
  7158. });
  7159. }
  7160. });
  7161. }
  7162. n["default"] = e;
  7163. return Object.freeze(n);
  7164. }
  7165.  
  7166. var acorn__namespace = /*#__PURE__*/_interopNamespace(acorn);
  7167. var jsx__default = /*#__PURE__*/_interopDefaultLegacy(jsx);
  7168. var visitorKeys__namespace = /*#__PURE__*/_interopNamespace(visitorKeys);
  7169.  
  7170. /**
  7171. * @fileoverview Translates tokens between Acorn format and Esprima format.
  7172. * @author Nicholas C. Zakas
  7173. */
  7174.  
  7175. //------------------------------------------------------------------------------
  7176. // Requirements
  7177. //------------------------------------------------------------------------------
  7178.  
  7179. // none!
  7180.  
  7181. //------------------------------------------------------------------------------
  7182. // Private
  7183. //------------------------------------------------------------------------------
  7184.  
  7185.  
  7186. // Esprima Token Types
  7187. const Token = {
  7188. Boolean: "Boolean",
  7189. EOF: "<end>",
  7190. Identifier: "Identifier",
  7191. PrivateIdentifier: "PrivateIdentifier",
  7192. Keyword: "Keyword",
  7193. Null: "Null",
  7194. Numeric: "Numeric",
  7195. Punctuator: "Punctuator",
  7196. String: "String",
  7197. RegularExpression: "RegularExpression",
  7198. Template: "Template",
  7199. JSXIdentifier: "JSXIdentifier",
  7200. JSXText: "JSXText"
  7201. };
  7202.  
  7203. /**
  7204. * Converts part of a template into an Esprima token.
  7205. * @param {AcornToken[]} tokens The Acorn tokens representing the template.
  7206. * @param {string} code The source code.
  7207. * @returns {EsprimaToken} The Esprima equivalent of the template token.
  7208. * @private
  7209. */
  7210. function convertTemplatePart(tokens, code) {
  7211. const firstToken = tokens[0],
  7212. lastTemplateToken = tokens[tokens.length - 1];
  7213.  
  7214. const token = {
  7215. type: Token.Template,
  7216. value: code.slice(firstToken.start, lastTemplateToken.end)
  7217. };
  7218.  
  7219. if (firstToken.loc) {
  7220. token.loc = {
  7221. start: firstToken.loc.start,
  7222. end: lastTemplateToken.loc.end
  7223. };
  7224. }
  7225.  
  7226. if (firstToken.range) {
  7227. token.start = firstToken.range[0];
  7228. token.end = lastTemplateToken.range[1];
  7229. token.range = [token.start, token.end];
  7230. }
  7231.  
  7232. return token;
  7233. }
  7234.  
  7235. /**
  7236. * Contains logic to translate Acorn tokens into Esprima tokens.
  7237. * @param {Object} acornTokTypes The Acorn token types.
  7238. * @param {string} code The source code Acorn is parsing. This is necessary
  7239. * to correct the "value" property of some tokens.
  7240. * @constructor
  7241. */
  7242. function TokenTranslator(acornTokTypes, code) {
  7243.  
  7244. // token types
  7245. this._acornTokTypes = acornTokTypes;
  7246.  
  7247. // token buffer for templates
  7248. this._tokens = [];
  7249.  
  7250. // track the last curly brace
  7251. this._curlyBrace = null;
  7252.  
  7253. // the source code
  7254. this._code = code;
  7255.  
  7256. }
  7257.  
  7258. TokenTranslator.prototype = {
  7259. constructor: TokenTranslator,
  7260.  
  7261. /**
  7262. * Translates a single Esprima token to a single Acorn token. This may be
  7263. * inaccurate due to how templates are handled differently in Esprima and
  7264. * Acorn, but should be accurate for all other tokens.
  7265. * @param {AcornToken} token The Acorn token to translate.
  7266. * @param {Object} extra Espree extra object.
  7267. * @returns {EsprimaToken} The Esprima version of the token.
  7268. */
  7269. translate(token, extra) {
  7270.  
  7271. const type = token.type,
  7272. tt = this._acornTokTypes;
  7273.  
  7274. if (type === tt.name) {
  7275. token.type = Token.Identifier;
  7276.  
  7277. // TODO: See if this is an Acorn bug
  7278. if (token.value === "static") {
  7279. token.type = Token.Keyword;
  7280. }
  7281.  
  7282. if (extra.ecmaVersion > 5 && (token.value === "yield" || token.value === "let")) {
  7283. token.type = Token.Keyword;
  7284. }
  7285.  
  7286. } else if (type === tt.privateId) {
  7287. token.type = Token.PrivateIdentifier;
  7288.  
  7289. } else if (type === tt.semi || type === tt.comma ||
  7290. type === tt.parenL || type === tt.parenR ||
  7291. type === tt.braceL || type === tt.braceR ||
  7292. type === tt.dot || type === tt.bracketL ||
  7293. type === tt.colon || type === tt.question ||
  7294. type === tt.bracketR || type === tt.ellipsis ||
  7295. type === tt.arrow || type === tt.jsxTagStart ||
  7296. type === tt.incDec || type === tt.starstar ||
  7297. type === tt.jsxTagEnd || type === tt.prefix ||
  7298. type === tt.questionDot ||
  7299. (type.binop && !type.keyword) ||
  7300. type.isAssign) {
  7301.  
  7302. token.type = Token.Punctuator;
  7303. token.value = this._code.slice(token.start, token.end);
  7304. } else if (type === tt.jsxName) {
  7305. token.type = Token.JSXIdentifier;
  7306. } else if (type.label === "jsxText" || type === tt.jsxAttrValueToken) {
  7307. token.type = Token.JSXText;
  7308. } else if (type.keyword) {
  7309. if (type.keyword === "true" || type.keyword === "false") {
  7310. token.type = Token.Boolean;
  7311. } else if (type.keyword === "null") {
  7312. token.type = Token.Null;
  7313. } else {
  7314. token.type = Token.Keyword;
  7315. }
  7316. } else if (type === tt.num) {
  7317. token.type = Token.Numeric;
  7318. token.value = this._code.slice(token.start, token.end);
  7319. } else if (type === tt.string) {
  7320.  
  7321. if (extra.jsxAttrValueToken) {
  7322. extra.jsxAttrValueToken = false;
  7323. token.type = Token.JSXText;
  7324. } else {
  7325. token.type = Token.String;
  7326. }
  7327.  
  7328. token.value = this._code.slice(token.start, token.end);
  7329. } else if (type === tt.regexp) {
  7330. token.type = Token.RegularExpression;
  7331. const value = token.value;
  7332.  
  7333. token.regex = {
  7334. flags: value.flags,
  7335. pattern: value.pattern
  7336. };
  7337. token.value = `/${value.pattern}/${value.flags}`;
  7338. }
  7339.  
  7340. return token;
  7341. },
  7342.  
  7343. /**
  7344. * Function to call during Acorn's onToken handler.
  7345. * @param {AcornToken} token The Acorn token.
  7346. * @param {Object} extra The Espree extra object.
  7347. * @returns {void}
  7348. */
  7349. onToken(token, extra) {
  7350.  
  7351. const tt = this._acornTokTypes,
  7352. tokens = extra.tokens,
  7353. templateTokens = this._tokens;
  7354.  
  7355. /**
  7356. * Flushes the buffered template tokens and resets the template
  7357. * tracking.
  7358. * @returns {void}
  7359. * @private
  7360. */
  7361. const translateTemplateTokens = () => {
  7362. tokens.push(convertTemplatePart(this._tokens, this._code));
  7363. this._tokens = [];
  7364. };
  7365.  
  7366. if (token.type === tt.eof) {
  7367.  
  7368. // might be one last curlyBrace
  7369. if (this._curlyBrace) {
  7370. tokens.push(this.translate(this._curlyBrace, extra));
  7371. }
  7372.  
  7373. return;
  7374. }
  7375.  
  7376. if (token.type === tt.backQuote) {
  7377.  
  7378. // if there's already a curly, it's not part of the template
  7379. if (this._curlyBrace) {
  7380. tokens.push(this.translate(this._curlyBrace, extra));
  7381. this._curlyBrace = null;
  7382. }
  7383.  
  7384. templateTokens.push(token);
  7385.  
  7386. // it's the end
  7387. if (templateTokens.length > 1) {
  7388. translateTemplateTokens();
  7389. }
  7390.  
  7391. return;
  7392. }
  7393. if (token.type === tt.dollarBraceL) {
  7394. templateTokens.push(token);
  7395. translateTemplateTokens();
  7396. return;
  7397. }
  7398. if (token.type === tt.braceR) {
  7399.  
  7400. // if there's already a curly, it's not part of the template
  7401. if (this._curlyBrace) {
  7402. tokens.push(this.translate(this._curlyBrace, extra));
  7403. }
  7404.  
  7405. // store new curly for later
  7406. this._curlyBrace = token;
  7407. return;
  7408. }
  7409. if (token.type === tt.template || token.type === tt.invalidTemplate) {
  7410. if (this._curlyBrace) {
  7411. templateTokens.push(this._curlyBrace);
  7412. this._curlyBrace = null;
  7413. }
  7414.  
  7415. templateTokens.push(token);
  7416. return;
  7417. }
  7418.  
  7419. if (this._curlyBrace) {
  7420. tokens.push(this.translate(this._curlyBrace, extra));
  7421. this._curlyBrace = null;
  7422. }
  7423.  
  7424. tokens.push(this.translate(token, extra));
  7425. }
  7426. };
  7427.  
  7428. /**
  7429. * @fileoverview A collection of methods for processing Espree's options.
  7430. * @author Kai Cataldo
  7431. */
  7432.  
  7433. //------------------------------------------------------------------------------
  7434. // Helpers
  7435. //------------------------------------------------------------------------------
  7436.  
  7437. const SUPPORTED_VERSIONS = [
  7438. 3,
  7439. 5,
  7440. 6, // 2015
  7441. 7, // 2016
  7442. 8, // 2017
  7443. 9, // 2018
  7444. 10, // 2019
  7445. 11, // 2020
  7446. 12, // 2021
  7447. 13, // 2022
  7448. 14, // 2023
  7449. 15 // 2024
  7450. ];
  7451.  
  7452. /**
  7453. * Get the latest ECMAScript version supported by Espree.
  7454. * @returns {number} The latest ECMAScript version.
  7455. */
  7456. function getLatestEcmaVersion() {
  7457. return SUPPORTED_VERSIONS[SUPPORTED_VERSIONS.length - 1];
  7458. }
  7459.  
  7460. /**
  7461. * Get the list of ECMAScript versions supported by Espree.
  7462. * @returns {number[]} An array containing the supported ECMAScript versions.
  7463. */
  7464. function getSupportedEcmaVersions() {
  7465. return [...SUPPORTED_VERSIONS];
  7466. }
  7467.  
  7468. /**
  7469. * Normalize ECMAScript version from the initial config
  7470. * @param {(number|"latest")} ecmaVersion ECMAScript version from the initial config
  7471. * @throws {Error} throws an error if the ecmaVersion is invalid.
  7472. * @returns {number} normalized ECMAScript version
  7473. */
  7474. function normalizeEcmaVersion(ecmaVersion = 5) {
  7475.  
  7476. let version = ecmaVersion === "latest" ? getLatestEcmaVersion() : ecmaVersion;
  7477.  
  7478. if (typeof version !== "number") {
  7479. throw new Error(`ecmaVersion must be a number or "latest". Received value of type ${typeof ecmaVersion} instead.`);
  7480. }
  7481.  
  7482. // Calculate ECMAScript edition number from official year version starting with
  7483. // ES2015, which corresponds with ES6 (or a difference of 2009).
  7484. if (version >= 2015) {
  7485. version -= 2009;
  7486. }
  7487.  
  7488. if (!SUPPORTED_VERSIONS.includes(version)) {
  7489. throw new Error("Invalid ecmaVersion.");
  7490. }
  7491.  
  7492. return version;
  7493. }
  7494.  
  7495. /**
  7496. * Normalize sourceType from the initial config
  7497. * @param {string} sourceType to normalize
  7498. * @throws {Error} throw an error if sourceType is invalid
  7499. * @returns {string} normalized sourceType
  7500. */
  7501. function normalizeSourceType(sourceType = "script") {
  7502. if (sourceType === "script" || sourceType === "module") {
  7503. return sourceType;
  7504. }
  7505.  
  7506. if (sourceType === "commonjs") {
  7507. return "script";
  7508. }
  7509.  
  7510. throw new Error("Invalid sourceType.");
  7511. }
  7512.  
  7513. /**
  7514. * Normalize parserOptions
  7515. * @param {Object} options the parser options to normalize
  7516. * @throws {Error} throw an error if found invalid option.
  7517. * @returns {Object} normalized options
  7518. */
  7519. function normalizeOptions(options) {
  7520. const ecmaVersion = normalizeEcmaVersion(options.ecmaVersion);
  7521. const sourceType = normalizeSourceType(options.sourceType);
  7522. const ranges = options.range === true;
  7523. const locations = options.loc === true;
  7524.  
  7525. if (ecmaVersion !== 3 && options.allowReserved) {
  7526.  
  7527. // a value of `false` is intentionally allowed here, so a shared config can overwrite it when needed
  7528. throw new Error("`allowReserved` is only supported when ecmaVersion is 3");
  7529. }
  7530. if (typeof options.allowReserved !== "undefined" && typeof options.allowReserved !== "boolean") {
  7531. throw new Error("`allowReserved`, when present, must be `true` or `false`");
  7532. }
  7533. const allowReserved = ecmaVersion === 3 ? (options.allowReserved || "never") : false;
  7534. const ecmaFeatures = options.ecmaFeatures || {};
  7535. const allowReturnOutsideFunction = options.sourceType === "commonjs" ||
  7536. Boolean(ecmaFeatures.globalReturn);
  7537.  
  7538. if (sourceType === "module" && ecmaVersion < 6) {
  7539. throw new Error("sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options.");
  7540. }
  7541.  
  7542. return Object.assign({}, options, {
  7543. ecmaVersion,
  7544. sourceType,
  7545. ranges,
  7546. locations,
  7547. allowReserved,
  7548. allowReturnOutsideFunction
  7549. });
  7550. }
  7551.  
  7552. /* eslint no-param-reassign: 0 -- stylistic choice */
  7553.  
  7554.  
  7555. const STATE = Symbol("espree's internal state");
  7556. const ESPRIMA_FINISH_NODE = Symbol("espree's esprimaFinishNode");
  7557.  
  7558.  
  7559. /**
  7560. * Converts an Acorn comment to a Esprima comment.
  7561. * @param {boolean} block True if it's a block comment, false if not.
  7562. * @param {string} text The text of the comment.
  7563. * @param {int} start The index at which the comment starts.
  7564. * @param {int} end The index at which the comment ends.
  7565. * @param {Location} startLoc The location at which the comment starts.
  7566. * @param {Location} endLoc The location at which the comment ends.
  7567. * @param {string} code The source code being parsed.
  7568. * @returns {Object} The comment object.
  7569. * @private
  7570. */
  7571. function convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc, code) {
  7572. let type;
  7573.  
  7574. if (block) {
  7575. type = "Block";
  7576. } else if (code.slice(start, start + 2) === "#!") {
  7577. type = "Hashbang";
  7578. } else {
  7579. type = "Line";
  7580. }
  7581.  
  7582. const comment = {
  7583. type,
  7584. value: text
  7585. };
  7586.  
  7587. if (typeof start === "number") {
  7588. comment.start = start;
  7589. comment.end = end;
  7590. comment.range = [start, end];
  7591. }
  7592.  
  7593. if (typeof startLoc === "object") {
  7594. comment.loc = {
  7595. start: startLoc,
  7596. end: endLoc
  7597. };
  7598. }
  7599.  
  7600. return comment;
  7601. }
  7602.  
  7603. var espree = () => Parser => {
  7604. const tokTypes = Object.assign({}, Parser.acorn.tokTypes);
  7605.  
  7606. if (Parser.acornJsx) {
  7607. Object.assign(tokTypes, Parser.acornJsx.tokTypes);
  7608. }
  7609.  
  7610. return class Espree extends Parser {
  7611. constructor(opts, code) {
  7612. if (typeof opts !== "object" || opts === null) {
  7613. opts = {};
  7614. }
  7615. if (typeof code !== "string" && !(code instanceof String)) {
  7616. code = String(code);
  7617. }
  7618.  
  7619. // save original source type in case of commonjs
  7620. const originalSourceType = opts.sourceType;
  7621. const options = normalizeOptions(opts);
  7622. const ecmaFeatures = options.ecmaFeatures || {};
  7623. const tokenTranslator =
  7624. options.tokens === true
  7625. ? new TokenTranslator(tokTypes, code)
  7626. : null;
  7627.  
  7628. /*
  7629. * Data that is unique to Espree and is not represented internally
  7630. * in Acorn.
  7631. *
  7632. * For ES2023 hashbangs, Espree will call `onComment()` during the
  7633. * constructor, so we must define state before having access to
  7634. * `this`.
  7635. */
  7636. const state = {
  7637. originalSourceType: originalSourceType || options.sourceType,
  7638. tokens: tokenTranslator ? [] : null,
  7639. comments: options.comment === true ? [] : null,
  7640. impliedStrict: ecmaFeatures.impliedStrict === true && options.ecmaVersion >= 5,
  7641. ecmaVersion: options.ecmaVersion,
  7642. jsxAttrValueToken: false,
  7643. lastToken: null,
  7644. templateElements: []
  7645. };
  7646.  
  7647. // Initialize acorn parser.
  7648. super({
  7649.  
  7650. // do not use spread, because we don't want to pass any unknown options to acorn
  7651. ecmaVersion: options.ecmaVersion,
  7652. sourceType: options.sourceType,
  7653. ranges: options.ranges,
  7654. locations: options.locations,
  7655. allowReserved: options.allowReserved,
  7656.  
  7657. // Truthy value is true for backward compatibility.
  7658. allowReturnOutsideFunction: options.allowReturnOutsideFunction,
  7659.  
  7660. // Collect tokens
  7661. onToken(token) {
  7662. if (tokenTranslator) {
  7663.  
  7664. // Use `tokens`, `ecmaVersion`, and `jsxAttrValueToken` in the state.
  7665. tokenTranslator.onToken(token, state);
  7666. }
  7667. if (token.type !== tokTypes.eof) {
  7668. state.lastToken = token;
  7669. }
  7670. },
  7671.  
  7672. // Collect comments
  7673. onComment(block, text, start, end, startLoc, endLoc) {
  7674. if (state.comments) {
  7675. const comment = convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc, code);
  7676.  
  7677. state.comments.push(comment);
  7678. }
  7679. }
  7680. }, code);
  7681.  
  7682. /*
  7683. * We put all of this data into a symbol property as a way to avoid
  7684. * potential naming conflicts with future versions of Acorn.
  7685. */
  7686. this[STATE] = state;
  7687. }
  7688.  
  7689. tokenize() {
  7690. do {
  7691. this.next();
  7692. } while (this.type !== tokTypes.eof);
  7693.  
  7694. // Consume the final eof token
  7695. this.next();
  7696.  
  7697. const extra = this[STATE];
  7698. const tokens = extra.tokens;
  7699.  
  7700. if (extra.comments) {
  7701. tokens.comments = extra.comments;
  7702. }
  7703.  
  7704. return tokens;
  7705. }
  7706.  
  7707. finishNode(...args) {
  7708. const result = super.finishNode(...args);
  7709.  
  7710. return this[ESPRIMA_FINISH_NODE](result);
  7711. }
  7712.  
  7713. finishNodeAt(...args) {
  7714. const result = super.finishNodeAt(...args);
  7715.  
  7716. return this[ESPRIMA_FINISH_NODE](result);
  7717. }
  7718.  
  7719. parse() {
  7720. const extra = this[STATE];
  7721. const program = super.parse();
  7722.  
  7723. program.sourceType = extra.originalSourceType;
  7724.  
  7725. if (extra.comments) {
  7726. program.comments = extra.comments;
  7727. }
  7728. if (extra.tokens) {
  7729. program.tokens = extra.tokens;
  7730. }
  7731.  
  7732. /*
  7733. * Adjust opening and closing position of program to match Esprima.
  7734. * Acorn always starts programs at range 0 whereas Esprima starts at the
  7735. * first AST node's start (the only real difference is when there's leading
  7736. * whitespace or leading comments). Acorn also counts trailing whitespace
  7737. * as part of the program whereas Esprima only counts up to the last token.
  7738. */
  7739. if (program.body.length) {
  7740. const [firstNode] = program.body;
  7741.  
  7742. if (program.range) {
  7743. program.range[0] = firstNode.range[0];
  7744. }
  7745. if (program.loc) {
  7746. program.loc.start = firstNode.loc.start;
  7747. }
  7748. program.start = firstNode.start;
  7749. }
  7750. if (extra.lastToken) {
  7751. if (program.range) {
  7752. program.range[1] = extra.lastToken.range[1];
  7753. }
  7754. if (program.loc) {
  7755. program.loc.end = extra.lastToken.loc.end;
  7756. }
  7757. program.end = extra.lastToken.end;
  7758. }
  7759.  
  7760.  
  7761. /*
  7762. * https://github.com/eslint/espree/issues/349
  7763. * Ensure that template elements have correct range information.
  7764. * This is one location where Acorn produces a different value
  7765. * for its start and end properties vs. the values present in the
  7766. * range property. In order to avoid confusion, we set the start
  7767. * and end properties to the values that are present in range.
  7768. * This is done here, instead of in finishNode(), because Acorn
  7769. * uses the values of start and end internally while parsing, making
  7770. * it dangerous to change those values while parsing is ongoing.
  7771. * By waiting until the end of parsing, we can safely change these
  7772. * values without affect any other part of the process.
  7773. */
  7774. this[STATE].templateElements.forEach(templateElement => {
  7775. const startOffset = -1;
  7776. const endOffset = templateElement.tail ? 1 : 2;
  7777.  
  7778. templateElement.start += startOffset;
  7779. templateElement.end += endOffset;
  7780.  
  7781. if (templateElement.range) {
  7782. templateElement.range[0] += startOffset;
  7783. templateElement.range[1] += endOffset;
  7784. }
  7785.  
  7786. if (templateElement.loc) {
  7787. templateElement.loc.start.column += startOffset;
  7788. templateElement.loc.end.column += endOffset;
  7789. }
  7790. });
  7791.  
  7792. return program;
  7793. }
  7794.  
  7795. parseTopLevel(node) {
  7796. if (this[STATE].impliedStrict) {
  7797. this.strict = true;
  7798. }
  7799. return super.parseTopLevel(node);
  7800. }
  7801.  
  7802. /**
  7803. * Overwrites the default raise method to throw Esprima-style errors.
  7804. * @param {int} pos The position of the error.
  7805. * @param {string} message The error message.
  7806. * @throws {SyntaxError} A syntax error.
  7807. * @returns {void}
  7808. */
  7809. raise(pos, message) {
  7810. const loc = Parser.acorn.getLineInfo(this.input, pos);
  7811. const err = new SyntaxError(message);
  7812.  
  7813. err.index = pos;
  7814. err.lineNumber = loc.line;
  7815. err.column = loc.column + 1; // acorn uses 0-based columns
  7816. throw err;
  7817. }
  7818.  
  7819. /**
  7820. * Overwrites the default raise method to throw Esprima-style errors.
  7821. * @param {int} pos The position of the error.
  7822. * @param {string} message The error message.
  7823. * @throws {SyntaxError} A syntax error.
  7824. * @returns {void}
  7825. */
  7826. raiseRecoverable(pos, message) {
  7827. this.raise(pos, message);
  7828. }
  7829.  
  7830. /**
  7831. * Overwrites the default unexpected method to throw Esprima-style errors.
  7832. * @param {int} pos The position of the error.
  7833. * @throws {SyntaxError} A syntax error.
  7834. * @returns {void}
  7835. */
  7836. unexpected(pos) {
  7837. let message = "Unexpected token";
  7838.  
  7839. if (pos !== null && pos !== void 0) {
  7840. this.pos = pos;
  7841.  
  7842. if (this.options.locations) {
  7843. while (this.pos < this.lineStart) {
  7844. this.lineStart = this.input.lastIndexOf("\n", this.lineStart - 2) + 1;
  7845. --this.curLine;
  7846. }
  7847. }
  7848.  
  7849. this.nextToken();
  7850. }
  7851.  
  7852. if (this.end > this.start) {
  7853. message += ` ${this.input.slice(this.start, this.end)}`;
  7854. }
  7855.  
  7856. this.raise(this.start, message);
  7857. }
  7858.  
  7859. /*
  7860. * Esprima-FB represents JSX strings as tokens called "JSXText", but Acorn-JSX
  7861. * uses regular tt.string without any distinction between this and regular JS
  7862. * strings. As such, we intercept an attempt to read a JSX string and set a flag
  7863. * on extra so that when tokens are converted, the next token will be switched
  7864. * to JSXText via onToken.
  7865. */
  7866. jsx_readString(quote) { // eslint-disable-line camelcase -- required by API
  7867. const result = super.jsx_readString(quote);
  7868.  
  7869. if (this.type === tokTypes.string) {
  7870. this[STATE].jsxAttrValueToken = true;
  7871. }
  7872. return result;
  7873. }
  7874.  
  7875. /**
  7876. * Performs last-minute Esprima-specific compatibility checks and fixes.
  7877. * @param {ASTNode} result The node to check.
  7878. * @returns {ASTNode} The finished node.
  7879. */
  7880. [ESPRIMA_FINISH_NODE](result) {
  7881.  
  7882. // Acorn doesn't count the opening and closing backticks as part of templates
  7883. // so we have to adjust ranges/locations appropriately.
  7884. if (result.type === "TemplateElement") {
  7885.  
  7886. // save template element references to fix start/end later
  7887. this[STATE].templateElements.push(result);
  7888. }
  7889.  
  7890. if (result.type.includes("Function") && !result.generator) {
  7891. result.generator = false;
  7892. }
  7893.  
  7894. return result;
  7895. }
  7896. };
  7897. };
  7898.  
  7899. const version$1 = "9.6.1";
  7900.  
  7901. /* eslint-disable jsdoc/no-multi-asterisks -- needed to preserve original formatting of licences */
  7902.  
  7903.  
  7904. // To initialize lazily.
  7905. const parsers = {
  7906. _regular: null,
  7907. _jsx: null,
  7908.  
  7909. get regular() {
  7910. if (this._regular === null) {
  7911. this._regular = acorn__namespace.Parser.extend(espree());
  7912. }
  7913. return this._regular;
  7914. },
  7915.  
  7916. get jsx() {
  7917. if (this._jsx === null) {
  7918. this._jsx = acorn__namespace.Parser.extend(jsx__default["default"](), espree());
  7919. }
  7920. return this._jsx;
  7921. },
  7922.  
  7923. get(options) {
  7924. const useJsx = Boolean(
  7925. options &&
  7926. options.ecmaFeatures &&
  7927. options.ecmaFeatures.jsx
  7928. );
  7929.  
  7930. return useJsx ? this.jsx : this.regular;
  7931. }
  7932. };
  7933.  
  7934. //------------------------------------------------------------------------------
  7935. // Tokenizer
  7936. //------------------------------------------------------------------------------
  7937.  
  7938. /**
  7939. * Tokenizes the given code.
  7940. * @param {string} code The code to tokenize.
  7941. * @param {Object} options Options defining how to tokenize.
  7942. * @returns {Token[]} An array of tokens.
  7943. * @throws {SyntaxError} If the input code is invalid.
  7944. * @private
  7945. */
  7946. function tokenize(code, options) {
  7947. const Parser = parsers.get(options);
  7948.  
  7949. // Ensure to collect tokens.
  7950. if (!options || options.tokens !== true) {
  7951. options = Object.assign({}, options, { tokens: true }); // eslint-disable-line no-param-reassign -- stylistic choice
  7952. }
  7953.  
  7954. return new Parser(options, code).tokenize();
  7955. }
  7956.  
  7957. //------------------------------------------------------------------------------
  7958. // Parser
  7959. //------------------------------------------------------------------------------
  7960.  
  7961. /**
  7962. * Parses the given code.
  7963. * @param {string} code The code to tokenize.
  7964. * @param {Object} options Options defining how to tokenize.
  7965. * @returns {ASTNode} The "Program" AST node.
  7966. * @throws {SyntaxError} If the input code is invalid.
  7967. */
  7968. function parse(code, options) {
  7969. const Parser = parsers.get(options);
  7970.  
  7971. return new Parser(options, code).parse();
  7972. }
  7973.  
  7974. //------------------------------------------------------------------------------
  7975. // Public
  7976. //------------------------------------------------------------------------------
  7977.  
  7978. const version = version$1;
  7979. const name = "espree";
  7980.  
  7981. /* istanbul ignore next */
  7982. const VisitorKeys = (function() {
  7983. return visitorKeys__namespace.KEYS;
  7984. }());
  7985.  
  7986. // Derive node types from VisitorKeys
  7987. /* istanbul ignore next */
  7988. const Syntax = (function() {
  7989. let key,
  7990. types = {};
  7991.  
  7992. if (typeof Object.create === "function") {
  7993. types = Object.create(null);
  7994. }
  7995.  
  7996. for (key in VisitorKeys) {
  7997. if (Object.hasOwnProperty.call(VisitorKeys, key)) {
  7998. types[key] = key;
  7999. }
  8000. }
  8001.  
  8002. if (typeof Object.freeze === "function") {
  8003. Object.freeze(types);
  8004. }
  8005.  
  8006. return types;
  8007. }());
  8008.  
  8009. const latestEcmaVersion = getLatestEcmaVersion();
  8010.  
  8011. const supportedEcmaVersions = getSupportedEcmaVersions();
  8012.  
  8013. exports.Syntax = Syntax;
  8014. exports.VisitorKeys = VisitorKeys;
  8015. exports.latestEcmaVersion = latestEcmaVersion;
  8016. exports.name = name;
  8017. exports.parse = parse;
  8018. exports.supportedEcmaVersions = supportedEcmaVersions;
  8019. exports.tokenize = tokenize;
  8020. exports.version = version;
  8021.  
  8022. },{"acorn":3,"acorn-jsx":1,"eslint-visitor-keys":4}]},{},[])("espree")
  8023. });