@runeditrun/rer 0.2.83 → 0.2.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/cli/authoring.mjs +1 -0
  2. package/cli/contract.mjs +1 -1
  3. package/cli/demo-host.mjs +5 -1
  4. package/cli/demo.mjs +6 -1
  5. package/cli/export.mjs +1 -1
  6. package/cli/parse.mjs +1 -1
  7. package/edition-authoring/base-copies.mjs +72 -25
  8. package/edition-authoring/copy-checkout.mjs +7 -120
  9. package/edition-authoring/edition-migrations.mjs +41 -0
  10. package/edition-authoring/files.mjs +67 -0
  11. package/edition-authoring/lock.mjs +2 -2
  12. package/edition-authoring/module-closure.mjs +232 -0
  13. package/edition-authoring/module-edges.mjs +100 -0
  14. package/edition-authoring/module-resolution.mjs +66 -0
  15. package/edition-authoring/module-syntax.mjs +57 -0
  16. package/edition-authoring/package-target.mjs +92 -0
  17. package/edition-authoring/runtime-dependencies.mjs +74 -97
  18. package/edition-authoring/vendor/babel-parser/LICENSE +22 -0
  19. package/edition-authoring/vendor/babel-parser/README.md +21 -0
  20. package/edition-authoring/vendor/babel-parser/babel-helper-string-parser/index.mjs +292 -0
  21. package/edition-authoring/vendor/babel-parser/babel-helper-validator-identifier/identifier.mjs +66 -0
  22. package/edition-authoring/vendor/babel-parser/babel-helper-validator-identifier/index.mjs +13 -0
  23. package/edition-authoring/vendor/babel-parser/babel-helper-validator-identifier/keyword.mjs +31 -0
  24. package/edition-authoring/vendor/babel-parser/babel-parser/index.mjs +99 -0
  25. package/edition-authoring/vendor/babel-parser/babel-parser/options.mjs +81 -0
  26. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/bind-operator-errors.mjs +8 -0
  27. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/module-errors.mjs +15 -0
  28. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/parse-expression-errors.mjs +10 -0
  29. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/pipeline-operator-errors.mjs +29 -0
  30. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/standard-errors.mjs +224 -0
  31. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/strict-mode-errors.mjs +17 -0
  32. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/to-node-description.mjs +31 -0
  33. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error.mjs +114 -0
  34. package/edition-authoring/vendor/babel-parser/babel-parser/parser/base.mjs +34 -0
  35. package/edition-authoring/vendor/babel-parser/babel-parser/parser/comments.mjs +199 -0
  36. package/edition-authoring/vendor/babel-parser/babel-parser/parser/expression.mjs +1794 -0
  37. package/edition-authoring/vendor/babel-parser/babel-parser/parser/index.mjs +76 -0
  38. package/edition-authoring/vendor/babel-parser/babel-parser/parser/lval.mjs +439 -0
  39. package/edition-authoring/vendor/babel-parser/babel-parser/parser/node.mjs +111 -0
  40. package/edition-authoring/vendor/babel-parser/babel-parser/parser/statement.mjs +1962 -0
  41. package/edition-authoring/vendor/babel-parser/babel-parser/parser/util.mjs +244 -0
  42. package/edition-authoring/vendor/babel-parser/babel-parser/plugin-utils.mjs +116 -0
  43. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/estree.mjs +417 -0
  44. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/flow/index.mjs +2412 -0
  45. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/flow/scope.mjs +37 -0
  46. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/jsx/index.mjs +420 -0
  47. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/jsx/xhtml.mjs +261 -0
  48. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/placeholders.mjs +205 -0
  49. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/typescript/index.mjs +2889 -0
  50. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/typescript/scope.mjs +115 -0
  51. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/v8intrinsic.mjs +26 -0
  52. package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/context.mjs +22 -0
  53. package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/index.mjs +1037 -0
  54. package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/state.mjs +178 -0
  55. package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/types.mjs +583 -0
  56. package/edition-authoring/vendor/babel-parser/babel-parser/types.mjs +1 -0
  57. package/edition-authoring/vendor/babel-parser/babel-parser/util/class-scope.mjs +82 -0
  58. package/edition-authoring/vendor/babel-parser/babel-parser/util/expression-scope.mjs +121 -0
  59. package/edition-authoring/vendor/babel-parser/babel-parser/util/identifier.mjs +23 -0
  60. package/edition-authoring/vendor/babel-parser/babel-parser/util/location.mjs +34 -0
  61. package/edition-authoring/vendor/babel-parser/babel-parser/util/production-parameter.mjs +40 -0
  62. package/edition-authoring/vendor/babel-parser/babel-parser/util/scope.mjs +173 -0
  63. package/edition-authoring/vendor/babel-parser/babel-parser/util/scopeflags.mjs +66 -0
  64. package/edition-authoring/vendor/babel-parser/babel-parser/util/whitespace.mjs +61 -0
  65. package/edition-authoring/vendor/yaml/LICENSE +13 -0
  66. package/edition-authoring/vendor/yaml/README.md +11 -0
  67. package/edition-authoring/vendor/yaml/compose/compose-collection.mjs +88 -0
  68. package/edition-authoring/vendor/yaml/compose/compose-doc.mjs +43 -0
  69. package/edition-authoring/vendor/yaml/compose/compose-node.mjs +110 -0
  70. package/edition-authoring/vendor/yaml/compose/compose-scalar.mjs +86 -0
  71. package/edition-authoring/vendor/yaml/compose/composer.mjs +218 -0
  72. package/edition-authoring/vendor/yaml/compose/resolve-block-map.mjs +115 -0
  73. package/edition-authoring/vendor/yaml/compose/resolve-block-scalar.mjs +198 -0
  74. package/edition-authoring/vendor/yaml/compose/resolve-block-seq.mjs +49 -0
  75. package/edition-authoring/vendor/yaml/compose/resolve-end.mjs +37 -0
  76. package/edition-authoring/vendor/yaml/compose/resolve-flow-collection.mjs +207 -0
  77. package/edition-authoring/vendor/yaml/compose/resolve-flow-scalar.mjs +228 -0
  78. package/edition-authoring/vendor/yaml/compose/resolve-props.mjs +148 -0
  79. package/edition-authoring/vendor/yaml/compose/util-contains-newline.mjs +34 -0
  80. package/edition-authoring/vendor/yaml/compose/util-empty-scalar-position.mjs +27 -0
  81. package/edition-authoring/vendor/yaml/compose/util-flow-indent-check.mjs +15 -0
  82. package/edition-authoring/vendor/yaml/compose/util-map-includes.mjs +13 -0
  83. package/edition-authoring/vendor/yaml/doc/Document.mjs +333 -0
  84. package/edition-authoring/vendor/yaml/doc/anchors.mjs +74 -0
  85. package/edition-authoring/vendor/yaml/doc/applyReviver.mjs +54 -0
  86. package/edition-authoring/vendor/yaml/doc/createNode.mjs +88 -0
  87. package/edition-authoring/vendor/yaml/doc/directives.mjs +176 -0
  88. package/edition-authoring/vendor/yaml/errors.mjs +57 -0
  89. package/edition-authoring/vendor/yaml/index.mjs +17 -0
  90. package/edition-authoring/vendor/yaml/log.mjs +11 -0
  91. package/edition-authoring/vendor/yaml/nodes/Alias.mjs +119 -0
  92. package/edition-authoring/vendor/yaml/nodes/Collection.mjs +147 -0
  93. package/edition-authoring/vendor/yaml/nodes/Node.mjs +38 -0
  94. package/edition-authoring/vendor/yaml/nodes/Pair.mjs +36 -0
  95. package/edition-authoring/vendor/yaml/nodes/Scalar.mjs +24 -0
  96. package/edition-authoring/vendor/yaml/nodes/YAMLMap.mjs +144 -0
  97. package/edition-authoring/vendor/yaml/nodes/YAMLSeq.mjs +113 -0
  98. package/edition-authoring/vendor/yaml/nodes/addPairToJSMap.mjs +62 -0
  99. package/edition-authoring/vendor/yaml/nodes/identity.mjs +36 -0
  100. package/edition-authoring/vendor/yaml/nodes/toJS.mjs +35 -0
  101. package/edition-authoring/vendor/yaml/parse/cst-scalar.mjs +214 -0
  102. package/edition-authoring/vendor/yaml/parse/cst-stringify.mjs +61 -0
  103. package/edition-authoring/vendor/yaml/parse/cst-visit.mjs +97 -0
  104. package/edition-authoring/vendor/yaml/parse/cst.mjs +98 -0
  105. package/edition-authoring/vendor/yaml/parse/lexer.mjs +722 -0
  106. package/edition-authoring/vendor/yaml/parse/line-counter.mjs +39 -0
  107. package/edition-authoring/vendor/yaml/parse/parser.mjs +975 -0
  108. package/edition-authoring/vendor/yaml/public-api.mjs +102 -0
  109. package/edition-authoring/vendor/yaml/schema/Schema.mjs +37 -0
  110. package/edition-authoring/vendor/yaml/schema/common/map.mjs +17 -0
  111. package/edition-authoring/vendor/yaml/schema/common/null.mjs +15 -0
  112. package/edition-authoring/vendor/yaml/schema/common/seq.mjs +17 -0
  113. package/edition-authoring/vendor/yaml/schema/common/string.mjs +14 -0
  114. package/edition-authoring/vendor/yaml/schema/core/bool.mjs +19 -0
  115. package/edition-authoring/vendor/yaml/schema/core/float.mjs +43 -0
  116. package/edition-authoring/vendor/yaml/schema/core/int.mjs +38 -0
  117. package/edition-authoring/vendor/yaml/schema/core/schema.mjs +23 -0
  118. package/edition-authoring/vendor/yaml/schema/json/schema.mjs +62 -0
  119. package/edition-authoring/vendor/yaml/schema/tags.mjs +96 -0
  120. package/edition-authoring/vendor/yaml/schema/yaml-1.1/binary.mjs +59 -0
  121. package/edition-authoring/vendor/yaml/schema/yaml-1.1/bool.mjs +26 -0
  122. package/edition-authoring/vendor/yaml/schema/yaml-1.1/float.mjs +46 -0
  123. package/edition-authoring/vendor/yaml/schema/yaml-1.1/int.mjs +71 -0
  124. package/edition-authoring/vendor/yaml/schema/yaml-1.1/merge.mjs +67 -0
  125. package/edition-authoring/vendor/yaml/schema/yaml-1.1/omap.mjs +74 -0
  126. package/edition-authoring/vendor/yaml/schema/yaml-1.1/pairs.mjs +78 -0
  127. package/edition-authoring/vendor/yaml/schema/yaml-1.1/schema.mjs +39 -0
  128. package/edition-authoring/vendor/yaml/schema/yaml-1.1/set.mjs +93 -0
  129. package/edition-authoring/vendor/yaml/schema/yaml-1.1/timestamp.mjs +101 -0
  130. package/edition-authoring/vendor/yaml/stringify/foldFlowLines.mjs +146 -0
  131. package/edition-authoring/vendor/yaml/stringify/stringify.mjs +130 -0
  132. package/edition-authoring/vendor/yaml/stringify/stringifyCollection.mjs +155 -0
  133. package/edition-authoring/vendor/yaml/stringify/stringifyComment.mjs +20 -0
  134. package/edition-authoring/vendor/yaml/stringify/stringifyDocument.mjs +85 -0
  135. package/edition-authoring/vendor/yaml/stringify/stringifyNumber.mjs +25 -0
  136. package/edition-authoring/vendor/yaml/stringify/stringifyPair.mjs +150 -0
  137. package/edition-authoring/vendor/yaml/stringify/stringifyString.mjs +338 -0
  138. package/edition-authoring/vendor/yaml/util.mjs +11 -0
  139. package/edition-authoring/vendor/yaml/visit.mjs +233 -0
  140. package/edition-authoring/workflow-copies.mjs +125 -0
  141. package/edition-authoring/workflow-scripts.mjs +112 -0
  142. package/foundation/runtime/contract-docs.mjs +753 -0
  143. package/global/CHANGELOG.md +22 -3
  144. package/modules/demo/declaration.mjs +1 -4
  145. package/modules/demo/vite.mjs +1 -1
  146. package/modules/deploy-kit/README.md +1 -1
  147. package/modules/deploy-kit/templates.mjs +3 -3
  148. package/onboarding/operator-installer.mjs +2 -2
  149. package/package.json +1 -1
  150. package/scripts/publish-check/README.md +6 -0
  151. package/scripts/publish-check/history_scan.py +5 -3
  152. package/scripts/publish-check/hygiene_config.py +2 -1
  153. package/scripts/publish-check/report.py +9 -3
  154. package/scripts/publish-check/third-party-notices.json +13 -0
  155. package/scripts/publish-check/third_party_notices.py +38 -0
  156. package/scripts/publish-check/tree_scan.py +6 -0
  157. package/scripts/publish-check.mjs +1 -1
@@ -0,0 +1,1794 @@
1
+ // Generated from Babel v7.29.8 (MIT); see README.md.
2
+ import { tokenCanStartExpression, tokenIsAssignment, tokenIsIdentifier, tokenIsKeywordOrIdentifier, tokenIsOperator, tokenIsPostfix, tokenIsPrefix, tokenIsRightAssociative, tokenIsTemplate, tokenKeywordOrIdentifierIsKeyword, tokenLabelName, tokenOperatorPrecedence, tt } from "../tokenizer/types.mjs";
3
+ import LValParser from "./lval.mjs";
4
+ import { isKeyword, isReservedWord, isStrictReservedWord, isStrictBindReservedWord, isIdentifierStart, canBeReservedWord } from "../util/identifier.mjs";
5
+ import { createPositionWithColumnOffset } from "../util/location.mjs";
6
+ import { ScopeFlag, BindingFlag } from "../util/scopeflags.mjs";
7
+ import { ExpressionErrors } from "./util.mjs";
8
+ import { ParamKind, functionFlags } from "../util/production-parameter.mjs";
9
+ import { newArrowHeadScope, newAsyncArrowScope, newExpressionScope } from "../util/expression-scope.mjs";
10
+ import { Errors } from "../parse-error.mjs";
11
+ import { UnparenthesizedPipeBodyDescriptions } from "../parse-error/pipeline-operator-errors.mjs";
12
+ import { setInnerComments } from "./comments.mjs";
13
+ import { OptionFlags } from "../options.mjs";
14
+ class ExpressionParser extends LValParser {
15
+ checkProto(prop, isRecord, sawProto, refExpressionErrors) {
16
+ if (prop.type === "SpreadElement" || this.isObjectMethod(prop) || prop.computed || prop.shorthand) {
17
+ return sawProto;
18
+ }
19
+ const key = prop.key;
20
+ const name = key.type === "Identifier" ? key.name : key.value;
21
+ if (name === "__proto__") {
22
+ if (isRecord) {
23
+ this.raise(Errors.RecordNoProto, key);
24
+ return true;
25
+ }
26
+ if (sawProto) {
27
+ if (refExpressionErrors) {
28
+ if (refExpressionErrors.doubleProtoLoc === null) {
29
+ refExpressionErrors.doubleProtoLoc = key.loc.start;
30
+ }
31
+ } else {
32
+ this.raise(Errors.DuplicateProto, key);
33
+ }
34
+ }
35
+ return true;
36
+ }
37
+ return sawProto;
38
+ }
39
+ shouldExitDescending(expr, potentialArrowAt) {
40
+ return expr.type === "ArrowFunctionExpression" && this.offsetToSourcePos(expr.start) === potentialArrowAt;
41
+ }
42
+ getExpression() {
43
+ this.enterInitialScopes();
44
+ this.nextToken();
45
+ if (this.match(tt.eof)) {
46
+ throw this.raise(Errors.ParseExpressionEmptyInput, this.state.startLoc);
47
+ }
48
+ const expr = this.parseExpression();
49
+ if (!this.match(tt.eof)) {
50
+ throw this.raise(Errors.ParseExpressionExpectsEOF, this.state.startLoc, {
51
+ unexpected: this.input.codePointAt(this.state.start)
52
+ });
53
+ }
54
+ this.finalizeRemainingComments();
55
+ expr.comments = this.comments;
56
+ expr.errors = this.state.errors;
57
+ if (this.optionFlags & OptionFlags.Tokens) {
58
+ expr.tokens = this.tokens;
59
+ }
60
+ return expr;
61
+ }
62
+ parseExpression(disallowIn, refExpressionErrors) {
63
+ if (disallowIn) {
64
+ return this.disallowInAnd(() => this.parseExpressionBase(refExpressionErrors));
65
+ }
66
+ return this.allowInAnd(() => this.parseExpressionBase(refExpressionErrors));
67
+ }
68
+ parseExpressionBase(refExpressionErrors) {
69
+ const startLoc = this.state.startLoc;
70
+ const expr = this.parseMaybeAssign(refExpressionErrors);
71
+ if (this.match(tt.comma)) {
72
+ const node = this.startNodeAt(startLoc);
73
+ node.expressions = [expr];
74
+ while (this.eat(tt.comma)) {
75
+ node.expressions.push(this.parseMaybeAssign(refExpressionErrors));
76
+ }
77
+ this.toReferencedList(node.expressions);
78
+ return this.finishNode(node, "SequenceExpression");
79
+ }
80
+ return expr;
81
+ }
82
+ parseMaybeAssignDisallowIn(refExpressionErrors, afterLeftParse) {
83
+ return this.disallowInAnd(() => this.parseMaybeAssign(refExpressionErrors, afterLeftParse));
84
+ }
85
+ parseMaybeAssignAllowIn(refExpressionErrors, afterLeftParse) {
86
+ return this.allowInAnd(() => this.parseMaybeAssign(refExpressionErrors, afterLeftParse));
87
+ }
88
+ setOptionalParametersError(refExpressionErrors) {
89
+ refExpressionErrors.optionalParametersLoc = this.state.startLoc;
90
+ }
91
+ parseMaybeAssign(refExpressionErrors, afterLeftParse) {
92
+ const startLoc = this.state.startLoc;
93
+ const isYield = this.isContextual(tt._yield);
94
+ if (isYield) {
95
+ if (this.prodParam.hasYield) {
96
+ this.next();
97
+ let left2 = this.parseYield(startLoc);
98
+ if (afterLeftParse) {
99
+ left2 = afterLeftParse.call(this, left2, startLoc);
100
+ }
101
+ return left2;
102
+ }
103
+ }
104
+ let ownExpressionErrors;
105
+ if (refExpressionErrors) {
106
+ ownExpressionErrors = false;
107
+ } else {
108
+ refExpressionErrors = new ExpressionErrors();
109
+ ownExpressionErrors = true;
110
+ }
111
+ const {
112
+ type
113
+ } = this.state;
114
+ if (type === tt.parenL || tokenIsIdentifier(type)) {
115
+ this.state.potentialArrowAt = this.state.start;
116
+ }
117
+ let left = this.parseMaybeConditional(refExpressionErrors);
118
+ if (afterLeftParse) {
119
+ left = afterLeftParse.call(this, left, startLoc);
120
+ }
121
+ if (tokenIsAssignment(this.state.type)) {
122
+ const node = this.startNodeAt(startLoc);
123
+ const operator = this.state.value;
124
+ node.operator = operator;
125
+ if (this.match(tt.eq)) {
126
+ this.toAssignable(left, true);
127
+ node.left = left;
128
+ const startIndex = startLoc.index;
129
+ if (refExpressionErrors.doubleProtoLoc != null && refExpressionErrors.doubleProtoLoc.index >= startIndex) {
130
+ refExpressionErrors.doubleProtoLoc = null;
131
+ }
132
+ if (refExpressionErrors.shorthandAssignLoc != null && refExpressionErrors.shorthandAssignLoc.index >= startIndex) {
133
+ refExpressionErrors.shorthandAssignLoc = null;
134
+ }
135
+ if (refExpressionErrors.privateKeyLoc != null && refExpressionErrors.privateKeyLoc.index >= startIndex) {
136
+ this.checkDestructuringPrivate(refExpressionErrors);
137
+ refExpressionErrors.privateKeyLoc = null;
138
+ }
139
+ if (refExpressionErrors.voidPatternLoc != null && refExpressionErrors.voidPatternLoc.index >= startIndex) {
140
+ refExpressionErrors.voidPatternLoc = null;
141
+ }
142
+ } else {
143
+ node.left = left;
144
+ }
145
+ this.next();
146
+ node.right = this.parseMaybeAssign();
147
+ this.checkLVal(left, this.finishNode(node, "AssignmentExpression"), void 0, void 0, void 0, void 0, operator === "||=" || operator === "&&=" || operator === "??=");
148
+ return node;
149
+ } else if (ownExpressionErrors) {
150
+ this.checkExpressionErrors(refExpressionErrors, true);
151
+ }
152
+ if (isYield) {
153
+ const {
154
+ type: type2
155
+ } = this.state;
156
+ const startsExpr = this.hasPlugin("v8intrinsic") ? tokenCanStartExpression(type2) : tokenCanStartExpression(type2) && !this.match(tt.modulo);
157
+ if (startsExpr && !this.isAmbiguousPrefixOrIdentifier()) {
158
+ this.raiseOverwrite(Errors.YieldNotInGeneratorFunction, startLoc);
159
+ return this.parseYield(startLoc);
160
+ }
161
+ }
162
+ return left;
163
+ }
164
+ parseMaybeConditional(refExpressionErrors) {
165
+ const startLoc = this.state.startLoc;
166
+ const potentialArrowAt = this.state.potentialArrowAt;
167
+ const expr = this.parseExprOps(refExpressionErrors);
168
+ if (this.shouldExitDescending(expr, potentialArrowAt)) {
169
+ return expr;
170
+ }
171
+ return this.parseConditional(expr, startLoc, refExpressionErrors);
172
+ }
173
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- Retain the upstream parser interface and bindings.
174
+ parseConditional(expr, startLoc, refExpressionErrors) {
175
+ if (this.eat(tt.question)) {
176
+ const node = this.startNodeAt(startLoc);
177
+ node.test = expr;
178
+ node.consequent = this.parseMaybeAssignAllowIn();
179
+ this.expect(tt.colon);
180
+ node.alternate = this.parseMaybeAssign();
181
+ return this.finishNode(node, "ConditionalExpression");
182
+ }
183
+ return expr;
184
+ }
185
+ parseMaybeUnaryOrPrivate(refExpressionErrors) {
186
+ return this.match(tt.privateName) ? this.parsePrivateName() : this.parseMaybeUnary(refExpressionErrors);
187
+ }
188
+ parseExprOps(refExpressionErrors) {
189
+ const startLoc = this.state.startLoc;
190
+ const potentialArrowAt = this.state.potentialArrowAt;
191
+ const expr = this.parseMaybeUnaryOrPrivate(refExpressionErrors);
192
+ if (this.shouldExitDescending(expr, potentialArrowAt)) {
193
+ return expr;
194
+ }
195
+ return this.parseExprOp(expr, startLoc, -1);
196
+ }
197
+ parseExprOp(left, leftStartLoc, minPrec) {
198
+ if (this.isPrivateName(left)) {
199
+ const value = this.getPrivateNameSV(left);
200
+ if (minPrec >= tokenOperatorPrecedence(tt._in) || !this.prodParam.hasIn || !this.match(tt._in)) {
201
+ this.raise(Errors.PrivateInExpectedIn, left, {
202
+ identifierName: value
203
+ });
204
+ }
205
+ this.classScope.usePrivateName(value, left.loc.start);
206
+ }
207
+ const op = this.state.type;
208
+ if (tokenIsOperator(op) && (this.prodParam.hasIn || !this.match(tt._in))) {
209
+ let prec = tokenOperatorPrecedence(op);
210
+ if (prec > minPrec) {
211
+ if (op === tt.pipeline) {
212
+ this.expectPlugin("pipelineOperator");
213
+ if (this.state.inFSharpPipelineDirectBody) {
214
+ return left;
215
+ }
216
+ this.checkPipelineAtInfixOperator(left, leftStartLoc);
217
+ }
218
+ const node = this.startNodeAt(leftStartLoc);
219
+ node.left = left;
220
+ node.operator = this.state.value;
221
+ const logical = op === tt.logicalOR || op === tt.logicalAND;
222
+ const coalesce = op === tt.nullishCoalescing;
223
+ if (coalesce) {
224
+ prec = tokenOperatorPrecedence(tt.logicalAND);
225
+ }
226
+ this.next();
227
+ if (op === tt.pipeline && this.hasPlugin(["pipelineOperator", {
228
+ proposal: "minimal"
229
+ }])) {
230
+ if (this.state.type === tt._await && this.prodParam.hasAwait) {
231
+ throw this.raise(Errors.UnexpectedAwaitAfterPipelineBody, this.state.startLoc);
232
+ }
233
+ }
234
+ node.right = this.parseExprOpRightExpr(op, prec);
235
+ const finishedNode = this.finishNode(node, logical || coalesce ? "LogicalExpression" : "BinaryExpression");
236
+ const nextOp = this.state.type;
237
+ if (coalesce && (nextOp === tt.logicalOR || nextOp === tt.logicalAND) || logical && nextOp === tt.nullishCoalescing) {
238
+ throw this.raise(Errors.MixingCoalesceWithLogical, this.state.startLoc);
239
+ }
240
+ return this.parseExprOp(finishedNode, leftStartLoc, minPrec);
241
+ }
242
+ }
243
+ return left;
244
+ }
245
+ parseExprOpRightExpr(op, prec) {
246
+ const startLoc = this.state.startLoc;
247
+ switch (op) {
248
+ case tt.pipeline:
249
+ switch (this.getPluginOption("pipelineOperator", "proposal")) {
250
+ case "hack":
251
+ return this.withTopicBindingContext(() => {
252
+ return this.parseHackPipeBody();
253
+ });
254
+ case "fsharp":
255
+ return this.withSoloAwaitPermittingContext(() => {
256
+ return this.parseFSharpPipelineBody(prec);
257
+ });
258
+ }
259
+ if (this.getPluginOption("pipelineOperator", "proposal") === "smart") {
260
+ return this.withTopicBindingContext(() => {
261
+ if (this.prodParam.hasYield && this.isContextual(tt._yield)) {
262
+ throw this.raise(Errors.PipeBodyIsTighter, this.state.startLoc);
263
+ }
264
+ return this.parseSmartPipelineBodyInStyle(this.parseExprOpBaseRightExpr(op, prec), startLoc);
265
+ });
266
+ }
267
+ // falls through (upstream parser grammar)
268
+ default:
269
+ return this.parseExprOpBaseRightExpr(op, prec);
270
+ }
271
+ }
272
+ parseExprOpBaseRightExpr(op, prec) {
273
+ const startLoc = this.state.startLoc;
274
+ return this.parseExprOp(this.parseMaybeUnaryOrPrivate(), startLoc, tokenIsRightAssociative(op) ? prec - 1 : prec);
275
+ }
276
+ parseHackPipeBody() {
277
+ const {
278
+ startLoc
279
+ } = this.state;
280
+ const body = this.parseMaybeAssign();
281
+ const requiredParentheses = UnparenthesizedPipeBodyDescriptions.has(body.type);
282
+ if (requiredParentheses && !body.extra?.parenthesized) {
283
+ this.raise(Errors.PipeUnparenthesizedBody, startLoc, {
284
+ type: body.type
285
+ });
286
+ }
287
+ if (!this.topicReferenceWasUsedInCurrentContext()) {
288
+ this.raise(Errors.PipeTopicUnused, startLoc);
289
+ }
290
+ return body;
291
+ }
292
+ checkExponentialAfterUnary(node) {
293
+ if (this.match(tt.exponent)) {
294
+ this.raise(Errors.UnexpectedTokenUnaryExponentiation, node.argument);
295
+ }
296
+ }
297
+ parseMaybeUnary(refExpressionErrors, sawUnary) {
298
+ const startLoc = this.state.startLoc;
299
+ const isAwait = this.isContextual(tt._await);
300
+ if (isAwait && this.recordAwaitIfAllowed()) {
301
+ this.next();
302
+ const expr2 = this.parseAwait(startLoc);
303
+ if (!sawUnary) this.checkExponentialAfterUnary(expr2);
304
+ return expr2;
305
+ }
306
+ const update = this.match(tt.incDec);
307
+ const node = this.startNode();
308
+ if (tokenIsPrefix(this.state.type)) {
309
+ node.operator = this.state.value;
310
+ node.prefix = true;
311
+ if (this.match(tt._throw)) {
312
+ this.expectPlugin("throwExpressions");
313
+ }
314
+ const isDelete = this.match(tt._delete);
315
+ this.next();
316
+ node.argument = this.parseMaybeUnary(null, true);
317
+ this.checkExpressionErrors(refExpressionErrors, true);
318
+ if (this.state.strict && isDelete) {
319
+ const arg = node.argument;
320
+ if (arg.type === "Identifier") {
321
+ this.raise(Errors.StrictDelete, node);
322
+ } else if (this.hasPropertyAsPrivateName(arg)) {
323
+ this.raise(Errors.DeletePrivateField, node);
324
+ }
325
+ }
326
+ if (!update) {
327
+ if (!sawUnary) {
328
+ this.checkExponentialAfterUnary(node);
329
+ }
330
+ return this.finishNode(node, "UnaryExpression");
331
+ }
332
+ }
333
+ const expr = this.parseUpdate(node, update, refExpressionErrors);
334
+ if (isAwait) {
335
+ const {
336
+ type
337
+ } = this.state;
338
+ const startsExpr = this.hasPlugin("v8intrinsic") ? tokenCanStartExpression(type) : tokenCanStartExpression(type) && !this.match(tt.modulo);
339
+ if (startsExpr && !this.isAmbiguousPrefixOrIdentifier()) {
340
+ this.raiseOverwrite(Errors.AwaitNotInAsyncContext, startLoc);
341
+ return this.parseAwait(startLoc);
342
+ }
343
+ }
344
+ return expr;
345
+ }
346
+ parseUpdate(node, update, refExpressionErrors) {
347
+ if (update) {
348
+ const updateExpressionNode = node;
349
+ this.checkLVal(updateExpressionNode.argument, this.finishNode(updateExpressionNode, "UpdateExpression"));
350
+ return node;
351
+ }
352
+ const startLoc = this.state.startLoc;
353
+ let expr = this.parseExprSubscripts(refExpressionErrors);
354
+ if (this.checkExpressionErrors(refExpressionErrors, false)) return expr;
355
+ while (tokenIsPostfix(this.state.type) && !this.canInsertSemicolon()) {
356
+ const node2 = this.startNodeAt(startLoc);
357
+ node2.operator = this.state.value;
358
+ node2.prefix = false;
359
+ node2.argument = expr;
360
+ this.next();
361
+ this.checkLVal(expr, expr = this.finishNode(node2, "UpdateExpression"));
362
+ }
363
+ return expr;
364
+ }
365
+ parseExprSubscripts(refExpressionErrors) {
366
+ const startLoc = this.state.startLoc;
367
+ const potentialArrowAt = this.state.potentialArrowAt;
368
+ const expr = this.parseExprAtom(refExpressionErrors);
369
+ if (this.shouldExitDescending(expr, potentialArrowAt)) {
370
+ return expr;
371
+ }
372
+ return this.parseSubscripts(expr, startLoc);
373
+ }
374
+ parseSubscripts(base, startLoc, noCalls) {
375
+ const state = {
376
+ optionalChainMember: false,
377
+ maybeAsyncArrow: this.atPossibleAsyncArrow(base),
378
+ stop: false
379
+ };
380
+ do {
381
+ base = this.parseSubscript(base, startLoc, noCalls, state);
382
+ state.maybeAsyncArrow = false;
383
+ } while (!state.stop);
384
+ return base;
385
+ }
386
+ parseSubscript(base, startLoc, noCalls, state) {
387
+ const {
388
+ type
389
+ } = this.state;
390
+ if (!noCalls && type === tt.doubleColon) {
391
+ return this.parseBind(base, startLoc, state);
392
+ } else if (tokenIsTemplate(type)) {
393
+ return this.parseTaggedTemplateExpression(base, startLoc, state);
394
+ }
395
+ let optional = false;
396
+ if (type === tt.questionDot) {
397
+ if (noCalls) {
398
+ this.raise(Errors.OptionalChainingNoNew, this.state.startLoc);
399
+ if (this.lookaheadCharCode() === 40) {
400
+ return this.stopParseSubscript(base, state);
401
+ }
402
+ }
403
+ state.optionalChainMember = optional = true;
404
+ this.next();
405
+ }
406
+ if (!noCalls && this.match(tt.parenL)) {
407
+ return this.parseCoverCallAndAsyncArrowHead(base, startLoc, state, optional);
408
+ } else {
409
+ const computed = this.eat(tt.bracketL);
410
+ if (computed || optional || this.eat(tt.dot)) {
411
+ return this.parseMember(base, startLoc, state, computed, optional);
412
+ } else {
413
+ return this.stopParseSubscript(base, state);
414
+ }
415
+ }
416
+ }
417
+ stopParseSubscript(base, state) {
418
+ state.stop = true;
419
+ return base;
420
+ }
421
+ parseMember(base, startLoc, state, computed, optional) {
422
+ const node = this.startNodeAt(startLoc);
423
+ node.object = base;
424
+ node.computed = computed;
425
+ if (computed) {
426
+ node.property = this.parseExpression();
427
+ this.expect(tt.bracketR);
428
+ } else if (this.match(tt.privateName)) {
429
+ if (base.type === "Super") {
430
+ this.raise(Errors.SuperPrivateField, startLoc);
431
+ }
432
+ this.classScope.usePrivateName(this.state.value, this.state.startLoc);
433
+ node.property = this.parsePrivateName();
434
+ } else {
435
+ node.property = this.parseIdentifier(true);
436
+ }
437
+ if (state.optionalChainMember) {
438
+ node.optional = optional;
439
+ return this.finishNode(node, "OptionalMemberExpression");
440
+ } else {
441
+ return this.finishNode(node, "MemberExpression");
442
+ }
443
+ }
444
+ parseBind(base, startLoc, state) {
445
+ const node = this.startNodeAt(startLoc);
446
+ node.object = base;
447
+ this.next();
448
+ const isImport = this.match(tt._import);
449
+ const callee = this.parseNoCallExpr();
450
+ if (callee.type === "Super" || isImport && callee.type === "ImportExpression" || callee.type === "Import") {
451
+ throw this.raise(Errors.UnsupportedBindRHS, callee);
452
+ }
453
+ node.callee = callee;
454
+ state.stop = true;
455
+ return this.parseSubscripts(this.finishNode(node, "BindExpression"), startLoc, false);
456
+ }
457
+ parseCoverCallAndAsyncArrowHead(base, startLoc, state, optional) {
458
+ const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
459
+ let refExpressionErrors = null;
460
+ this.state.maybeInArrowParameters = true;
461
+ this.next();
462
+ const node = this.startNodeAt(startLoc);
463
+ node.callee = base;
464
+ const {
465
+ maybeAsyncArrow,
466
+ optionalChainMember
467
+ } = state;
468
+ if (maybeAsyncArrow) {
469
+ this.expressionScope.enter(newAsyncArrowScope());
470
+ refExpressionErrors = new ExpressionErrors();
471
+ }
472
+ if (optionalChainMember) {
473
+ node.optional = optional;
474
+ }
475
+ if (optional) {
476
+ node.arguments = this.parseCallExpressionArguments();
477
+ } else {
478
+ node.arguments = this.parseCallExpressionArguments(base.type !== "Super", node, refExpressionErrors);
479
+ }
480
+ let finishedNode = this.finishCallExpression(node, optionalChainMember);
481
+ if (maybeAsyncArrow && this.shouldParseAsyncArrow() && !optional) {
482
+ state.stop = true;
483
+ this.checkDestructuringPrivate(refExpressionErrors);
484
+ this.expressionScope.validateAsPattern();
485
+ this.expressionScope.exit();
486
+ finishedNode = this.parseAsyncArrowFromCallExpression(this.startNodeAt(startLoc), finishedNode);
487
+ } else {
488
+ if (maybeAsyncArrow) {
489
+ this.checkExpressionErrors(refExpressionErrors, true);
490
+ this.expressionScope.exit();
491
+ }
492
+ this.toReferencedArguments(finishedNode);
493
+ }
494
+ this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
495
+ return finishedNode;
496
+ }
497
+ toReferencedArguments(node, isParenthesizedExpr) {
498
+ this.toReferencedListDeep(node.arguments, isParenthesizedExpr);
499
+ }
500
+ parseTaggedTemplateExpression(base, startLoc, state) {
501
+ const node = this.startNodeAt(startLoc);
502
+ node.tag = base;
503
+ node.quasi = this.parseTemplate(true);
504
+ if (state.optionalChainMember) {
505
+ this.raise(Errors.OptionalChainingNoTemplate, startLoc);
506
+ }
507
+ return this.finishNode(node, "TaggedTemplateExpression");
508
+ }
509
+ atPossibleAsyncArrow(base) {
510
+ return base.type === "Identifier" && base.name === "async" && this.state.lastTokEndLoc.index === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 && this.offsetToSourcePos(base.start) === this.state.potentialArrowAt;
511
+ }
512
+ finishCallExpression(node, optional) {
513
+ if (node.callee.type === "Import") {
514
+ if (node.arguments.length === 0 || node.arguments.length > 2) {
515
+ this.raise(Errors.ImportCallArity, node);
516
+ } else {
517
+ for (const arg of node.arguments) {
518
+ if (arg.type === "SpreadElement") {
519
+ this.raise(Errors.ImportCallSpreadArgument, arg);
520
+ }
521
+ }
522
+ }
523
+ }
524
+ return this.finishNode(node, optional ? "OptionalCallExpression" : "CallExpression");
525
+ }
526
+ parseCallExpressionArguments(allowPlaceholder, nodeForExtra, refExpressionErrors) {
527
+ const elts = [];
528
+ let first = true;
529
+ const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
530
+ this.state.inFSharpPipelineDirectBody = false;
531
+ while (!this.eat(tt.parenR)) {
532
+ if (first) {
533
+ first = false;
534
+ } else {
535
+ this.expect(tt.comma);
536
+ if (this.match(tt.parenR)) {
537
+ if (nodeForExtra) {
538
+ this.addTrailingCommaExtraToNode(nodeForExtra);
539
+ }
540
+ this.next();
541
+ break;
542
+ }
543
+ }
544
+ elts.push(this.parseExprListItem(tt.parenR, false, refExpressionErrors, allowPlaceholder));
545
+ }
546
+ this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
547
+ return elts;
548
+ }
549
+ shouldParseAsyncArrow() {
550
+ return this.match(tt.arrow) && !this.canInsertSemicolon();
551
+ }
552
+ parseAsyncArrowFromCallExpression(node, call) {
553
+ this.resetPreviousNodeTrailingComments(call);
554
+ this.expect(tt.arrow);
555
+ this.parseArrowExpression(node, call.arguments, true, call.extra?.trailingCommaLoc);
556
+ if (call.innerComments) {
557
+ setInnerComments(node, call.innerComments);
558
+ }
559
+ if (call.callee.trailingComments) {
560
+ setInnerComments(node, call.callee.trailingComments);
561
+ }
562
+ return node;
563
+ }
564
+ parseNoCallExpr() {
565
+ const startLoc = this.state.startLoc;
566
+ return this.parseSubscripts(this.parseExprAtom(), startLoc, true);
567
+ }
568
+ parseExprAtom(refExpressionErrors) {
569
+ let node;
570
+ let decorators = null;
571
+ const {
572
+ type
573
+ } = this.state;
574
+ switch (type) {
575
+ case tt._super:
576
+ return this.parseSuper();
577
+ case tt._import:
578
+ node = this.startNode();
579
+ this.next();
580
+ if (this.match(tt.dot)) {
581
+ return this.parseImportMetaPropertyOrPhaseCall(node);
582
+ }
583
+ if (this.match(tt.parenL)) {
584
+ if (this.optionFlags & OptionFlags.CreateImportExpressions) {
585
+ return this.parseImportCall(node);
586
+ } else {
587
+ return this.finishNode(node, "Import");
588
+ }
589
+ } else {
590
+ this.raise(Errors.UnsupportedImport, this.state.lastTokStartLoc);
591
+ return this.finishNode(node, "Import");
592
+ }
593
+ case tt._this:
594
+ node = this.startNode();
595
+ this.next();
596
+ return this.finishNode(node, "ThisExpression");
597
+ case tt._do: {
598
+ return this.parseDo(this.startNode(), false);
599
+ }
600
+ case tt.slash:
601
+ case tt.slashAssign: {
602
+ this.readRegexp();
603
+ return this.parseRegExpLiteral(this.state.value);
604
+ }
605
+ case tt.num:
606
+ return this.parseNumericLiteral(this.state.value);
607
+ case tt.bigint:
608
+ return this.parseBigIntLiteral(this.state.value);
609
+ case tt.string:
610
+ return this.parseStringLiteral(this.state.value);
611
+ case tt._null:
612
+ return this.parseNullLiteral();
613
+ case tt._true:
614
+ return this.parseBooleanLiteral(true);
615
+ case tt._false:
616
+ return this.parseBooleanLiteral(false);
617
+ case tt.parenL: {
618
+ const canBeArrow = this.state.potentialArrowAt === this.state.start;
619
+ return this.parseParenAndDistinguishExpression(canBeArrow);
620
+ }
621
+ case tt.bracketL: {
622
+ return this.parseArrayLike(tt.bracketR, false, refExpressionErrors);
623
+ }
624
+ case tt.braceL: {
625
+ return this.parseObjectLike(tt.braceR, false, false, refExpressionErrors);
626
+ }
627
+ case tt._function:
628
+ return this.parseFunctionOrFunctionSent();
629
+ case tt.at:
630
+ decorators = this.parseDecorators();
631
+ // falls through (upstream parser grammar)
632
+ case tt._class:
633
+ return this.parseClass(this.maybeTakeDecorators(decorators, this.startNode()), false);
634
+ case tt._new:
635
+ return this.parseNewOrNewTarget();
636
+ case tt.templateNonTail:
637
+ case tt.templateTail:
638
+ return this.parseTemplate(false);
639
+ case tt.doubleColon: {
640
+ node = this.startNode();
641
+ this.next();
642
+ node.object = null;
643
+ const callee = node.callee = this.parseNoCallExpr();
644
+ if (callee.type === "MemberExpression") {
645
+ return this.finishNode(node, "BindExpression");
646
+ } else {
647
+ throw this.raise(Errors.UnsupportedBind, callee);
648
+ }
649
+ }
650
+ case tt.privateName: {
651
+ this.raise(Errors.PrivateInExpectedIn, this.state.startLoc, {
652
+ identifierName: this.state.value
653
+ });
654
+ return this.parsePrivateName();
655
+ }
656
+ case tt.moduloAssign: {
657
+ return this.parseTopicReferenceThenEqualsSign(tt.modulo, "%");
658
+ }
659
+ case tt.xorAssign: {
660
+ return this.parseTopicReferenceThenEqualsSign(tt.bitwiseXOR, "^");
661
+ }
662
+ case tt.doubleCaret:
663
+ case tt.doubleAt: {
664
+ return this.parseTopicReference("hack");
665
+ }
666
+ case tt.bitwiseXOR:
667
+ case tt.modulo:
668
+ case tt.hash: {
669
+ const pipeProposal = this.getPluginOption("pipelineOperator", "proposal");
670
+ if (pipeProposal) {
671
+ return this.parseTopicReference(pipeProposal);
672
+ }
673
+ throw this.unexpected();
674
+ }
675
+ case tt.lt: {
676
+ const lookaheadCh = this.input.codePointAt(this.nextTokenStart());
677
+ if (isIdentifierStart(lookaheadCh) || lookaheadCh === 62) {
678
+ throw this.expectOnePlugin(["jsx", "flow", "typescript"]);
679
+ }
680
+ throw this.unexpected();
681
+ }
682
+ default:
683
+ {
684
+ if (type === tt.decimal) {
685
+ return this.parseDecimalLiteral(this.state.value);
686
+ } else if (type === tt.bracketBarL || type === tt.bracketHashL) {
687
+ return this.parseArrayLike(this.state.type === tt.bracketBarL ? tt.bracketBarR : tt.bracketR, true);
688
+ } else if (type === tt.braceBarL || type === tt.braceHashL) {
689
+ return this.parseObjectLike(this.state.type === tt.braceBarL ? tt.braceBarR : tt.braceR, false, true);
690
+ }
691
+ }
692
+ if (tokenIsIdentifier(type)) {
693
+ if (this.isContextual(tt._module) && this.lookaheadInLineCharCode() === 123) {
694
+ return this.parseModuleExpression();
695
+ }
696
+ const canBeArrow = this.state.potentialArrowAt === this.state.start;
697
+ const containsEsc = this.state.containsEsc;
698
+ const id = this.parseIdentifier();
699
+ if (!containsEsc && id.name === "async" && !this.canInsertSemicolon()) {
700
+ const {
701
+ type: type2
702
+ } = this.state;
703
+ if (type2 === tt._function) {
704
+ this.resetPreviousNodeTrailingComments(id);
705
+ this.next();
706
+ return this.parseAsyncFunctionExpression(this.startNodeAtNode(id));
707
+ } else if (tokenIsIdentifier(type2)) {
708
+ if (canBeArrow && this.lookaheadCharCode() === 61) {
709
+ return this.parseAsyncArrowUnaryFunction(this.startNodeAtNode(id));
710
+ } else {
711
+ return id;
712
+ }
713
+ } else if (type2 === tt._do) {
714
+ this.resetPreviousNodeTrailingComments(id);
715
+ return this.parseDo(this.startNodeAtNode(id), true);
716
+ }
717
+ }
718
+ if (canBeArrow && this.match(tt.arrow) && !this.canInsertSemicolon()) {
719
+ this.next();
720
+ return this.parseArrowExpression(this.startNodeAtNode(id), [id], false);
721
+ }
722
+ return id;
723
+ } else {
724
+ throw this.unexpected();
725
+ }
726
+ }
727
+ }
728
+ parseTopicReferenceThenEqualsSign(topicTokenType, topicTokenValue) {
729
+ const pipeProposal = this.getPluginOption("pipelineOperator", "proposal");
730
+ if (pipeProposal) {
731
+ this.state.type = topicTokenType;
732
+ this.state.value = topicTokenValue;
733
+ this.state.pos--;
734
+ this.state.end--;
735
+ this.state.endLoc = createPositionWithColumnOffset(this.state.endLoc, -1);
736
+ return this.parseTopicReference(pipeProposal);
737
+ }
738
+ throw this.unexpected();
739
+ }
740
+ parseTopicReference(pipeProposal) {
741
+ const node = this.startNode();
742
+ const startLoc = this.state.startLoc;
743
+ const tokenType = this.state.type;
744
+ this.next();
745
+ return this.finishTopicReference(node, startLoc, pipeProposal, tokenType);
746
+ }
747
+ finishTopicReference(node, startLoc, pipeProposal, tokenType) {
748
+ if (this.testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType)) {
749
+ if (pipeProposal === "hack") {
750
+ if (!this.topicReferenceIsAllowedInCurrentContext()) {
751
+ this.raise(Errors.PipeTopicUnbound, startLoc);
752
+ }
753
+ this.registerTopicReference();
754
+ return this.finishNode(node, "TopicReference");
755
+ } else {
756
+ if (!this.topicReferenceIsAllowedInCurrentContext()) {
757
+ this.raise(Errors.PrimaryTopicNotAllowed, startLoc);
758
+ }
759
+ this.registerTopicReference();
760
+ return this.finishNode(node, "PipelinePrimaryTopicReference");
761
+ }
762
+ } else {
763
+ throw this.raise(Errors.PipeTopicUnconfiguredToken, startLoc, {
764
+ token: tokenLabelName(tokenType)
765
+ });
766
+ }
767
+ }
768
+ testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType) {
769
+ switch (pipeProposal) {
770
+ case "hack": {
771
+ return this.hasPlugin(["pipelineOperator", {
772
+ topicToken: tokenLabelName(tokenType)
773
+ }]);
774
+ }
775
+ case "smart":
776
+ return tokenType === tt.hash;
777
+ default:
778
+ throw this.raise(Errors.PipeTopicRequiresHackPipes, startLoc);
779
+ }
780
+ }
781
+ parseAsyncArrowUnaryFunction(node) {
782
+ this.prodParam.enter(functionFlags(true, this.prodParam.hasYield));
783
+ const params = [this.parseIdentifier()];
784
+ this.prodParam.exit();
785
+ if (this.hasPrecedingLineBreak()) {
786
+ this.raise(Errors.LineTerminatorBeforeArrow, this.state.curPosition());
787
+ }
788
+ this.expect(tt.arrow);
789
+ return this.parseArrowExpression(node, params, true);
790
+ }
791
+ parseDo(node, isAsync) {
792
+ this.expectPlugin("doExpressions");
793
+ if (isAsync) {
794
+ this.expectPlugin("asyncDoExpressions");
795
+ }
796
+ node.async = isAsync;
797
+ this.next();
798
+ const oldLabels = this.state.labels;
799
+ this.state.labels = [];
800
+ if (isAsync) {
801
+ this.prodParam.enter(ParamKind.PARAM_AWAIT);
802
+ node.body = this.parseBlock();
803
+ this.prodParam.exit();
804
+ } else {
805
+ node.body = this.parseBlock();
806
+ }
807
+ this.state.labels = oldLabels;
808
+ return this.finishNode(node, "DoExpression");
809
+ }
810
+ parseSuper() {
811
+ const node = this.startNode();
812
+ this.next();
813
+ if (this.match(tt.parenL) && !this.scope.allowDirectSuper) {
814
+ {
815
+ if (!(this.optionFlags & OptionFlags.AllowSuperOutsideMethod)) {
816
+ this.raise(Errors.SuperNotAllowed, node);
817
+ }
818
+ }
819
+ } else if (!this.scope.allowSuper) {
820
+ {
821
+ if (!(this.optionFlags & OptionFlags.AllowSuperOutsideMethod)) {
822
+ this.raise(Errors.UnexpectedSuper, node);
823
+ }
824
+ }
825
+ }
826
+ if (!this.match(tt.parenL) && !this.match(tt.bracketL) && !this.match(tt.dot)) {
827
+ this.raise(Errors.UnsupportedSuper, node);
828
+ }
829
+ return this.finishNode(node, "Super");
830
+ }
831
+ parsePrivateName() {
832
+ const node = this.startNode();
833
+ const id = this.startNodeAt(createPositionWithColumnOffset(this.state.startLoc, 1));
834
+ const name = this.state.value;
835
+ this.next();
836
+ node.id = this.createIdentifier(id, name);
837
+ return this.finishNode(node, "PrivateName");
838
+ }
839
+ parseFunctionOrFunctionSent() {
840
+ const node = this.startNode();
841
+ this.next();
842
+ if (this.prodParam.hasYield && this.match(tt.dot)) {
843
+ const meta = this.createIdentifier(this.startNodeAtNode(node), "function");
844
+ this.next();
845
+ if (this.match(tt._sent)) {
846
+ this.expectPlugin("functionSent");
847
+ } else if (!this.hasPlugin("functionSent")) {
848
+ this.unexpected();
849
+ }
850
+ return this.parseMetaProperty(node, meta, "sent");
851
+ }
852
+ return this.parseFunction(node);
853
+ }
854
+ parseMetaProperty(node, meta, propertyName) {
855
+ node.meta = meta;
856
+ const containsEsc = this.state.containsEsc;
857
+ node.property = this.parseIdentifier(true);
858
+ if (node.property.name !== propertyName || containsEsc) {
859
+ this.raise(Errors.UnsupportedMetaProperty, node.property, {
860
+ target: meta.name,
861
+ onlyValidPropertyName: propertyName
862
+ });
863
+ }
864
+ return this.finishNode(node, "MetaProperty");
865
+ }
866
+ parseImportMetaPropertyOrPhaseCall(node) {
867
+ this.next();
868
+ if (this.isContextual(tt._source) || this.isContextual(tt._defer)) {
869
+ const isSource = this.isContextual(tt._source);
870
+ this.expectPlugin(isSource ? "sourcePhaseImports" : "deferredImportEvaluation");
871
+ this.next();
872
+ node.phase = isSource ? "source" : "defer";
873
+ return this.parseImportCall(node);
874
+ } else {
875
+ const id = this.createIdentifierAt(this.startNodeAtNode(node), "import", this.state.lastTokStartLoc);
876
+ if (this.isContextual(tt._meta)) {
877
+ if (!this.inModule) {
878
+ this.raise(Errors.ImportMetaOutsideModule, id);
879
+ }
880
+ this.sawUnambiguousESM = true;
881
+ }
882
+ return this.parseMetaProperty(node, id, "meta");
883
+ }
884
+ }
885
+ parseLiteralAtNode(value, type, node) {
886
+ this.addExtra(node, "rawValue", value);
887
+ this.addExtra(node, "raw", this.input.slice(this.offsetToSourcePos(node.start), this.state.end));
888
+ node.value = value;
889
+ this.next();
890
+ return this.finishNode(node, type);
891
+ }
892
+ parseLiteral(value, type) {
893
+ const node = this.startNode();
894
+ return this.parseLiteralAtNode(value, type, node);
895
+ }
896
+ parseStringLiteral(value) {
897
+ return this.parseLiteral(value, "StringLiteral");
898
+ }
899
+ parseNumericLiteral(value) {
900
+ return this.parseLiteral(value, "NumericLiteral");
901
+ }
902
+ parseBigIntLiteral(value) {
903
+ {
904
+ return this.parseLiteral(value, "BigIntLiteral");
905
+ }
906
+ }
907
+ parseDecimalLiteral(value) {
908
+ return this.parseLiteral(value, "DecimalLiteral");
909
+ }
910
+ parseRegExpLiteral(value) {
911
+ const node = this.startNode();
912
+ this.addExtra(node, "raw", this.input.slice(this.offsetToSourcePos(node.start), this.state.end));
913
+ node.pattern = value.pattern;
914
+ node.flags = value.flags;
915
+ this.next();
916
+ return this.finishNode(node, "RegExpLiteral");
917
+ }
918
+ parseBooleanLiteral(value) {
919
+ const node = this.startNode();
920
+ node.value = value;
921
+ this.next();
922
+ return this.finishNode(node, "BooleanLiteral");
923
+ }
924
+ parseNullLiteral() {
925
+ const node = this.startNode();
926
+ this.next();
927
+ return this.finishNode(node, "NullLiteral");
928
+ }
929
+ parseParenAndDistinguishExpression(canBeArrow) {
930
+ const startLoc = this.state.startLoc;
931
+ let val;
932
+ this.next();
933
+ this.expressionScope.enter(newArrowHeadScope());
934
+ const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
935
+ const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
936
+ this.state.maybeInArrowParameters = true;
937
+ this.state.inFSharpPipelineDirectBody = false;
938
+ const innerStartLoc = this.state.startLoc;
939
+ const exprList = [];
940
+ const refExpressionErrors = new ExpressionErrors();
941
+ let first = true;
942
+ let spreadStartLoc;
943
+ let optionalCommaStartLoc;
944
+ while (!this.match(tt.parenR)) {
945
+ if (first) {
946
+ first = false;
947
+ } else {
948
+ this.expect(tt.comma, refExpressionErrors.optionalParametersLoc === null ? null : refExpressionErrors.optionalParametersLoc);
949
+ if (this.match(tt.parenR)) {
950
+ optionalCommaStartLoc = this.state.startLoc;
951
+ break;
952
+ }
953
+ }
954
+ if (this.match(tt.ellipsis)) {
955
+ const spreadNodeStartLoc = this.state.startLoc;
956
+ spreadStartLoc = this.state.startLoc;
957
+ exprList.push(this.parseParenItem(this.parseRestBinding(), spreadNodeStartLoc));
958
+ if (!this.checkCommaAfterRest(41)) {
959
+ break;
960
+ }
961
+ } else {
962
+ exprList.push(this.parseMaybeAssignAllowInOrVoidPattern(tt.parenR, refExpressionErrors, this.parseParenItem));
963
+ }
964
+ }
965
+ const innerEndLoc = this.state.lastTokEndLoc;
966
+ this.expect(tt.parenR);
967
+ this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
968
+ this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
969
+ let arrowNode = this.startNodeAt(startLoc);
970
+ if (canBeArrow && this.shouldParseArrow(exprList) && (arrowNode = this.parseArrow(arrowNode))) {
971
+ this.checkDestructuringPrivate(refExpressionErrors);
972
+ this.expressionScope.validateAsPattern();
973
+ this.expressionScope.exit();
974
+ this.parseArrowExpression(arrowNode, exprList, false);
975
+ return arrowNode;
976
+ }
977
+ this.expressionScope.exit();
978
+ if (!exprList.length) {
979
+ this.unexpected(this.state.lastTokStartLoc);
980
+ }
981
+ if (optionalCommaStartLoc) this.unexpected(optionalCommaStartLoc);
982
+ if (spreadStartLoc) this.unexpected(spreadStartLoc);
983
+ this.checkExpressionErrors(refExpressionErrors, true);
984
+ this.toReferencedListDeep(exprList, true);
985
+ if (exprList.length > 1) {
986
+ val = this.startNodeAt(innerStartLoc);
987
+ val.expressions = exprList;
988
+ this.finishNode(val, "SequenceExpression");
989
+ this.resetEndLocation(val, innerEndLoc);
990
+ } else {
991
+ val = exprList[0];
992
+ }
993
+ return this.wrapParenthesis(startLoc, val);
994
+ }
995
+ wrapParenthesis(startLoc, expression) {
996
+ if (!(this.optionFlags & OptionFlags.CreateParenthesizedExpressions)) {
997
+ this.addExtra(expression, "parenthesized", true);
998
+ this.addExtra(expression, "parenStart", startLoc.index);
999
+ this.takeSurroundingComments(expression, startLoc.index, this.state.lastTokEndLoc.index);
1000
+ return expression;
1001
+ }
1002
+ const parenExpression = this.startNodeAt(startLoc);
1003
+ parenExpression.expression = expression;
1004
+ return this.finishNode(parenExpression, "ParenthesizedExpression");
1005
+ }
1006
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- Retain the upstream parser interface and bindings.
1007
+ shouldParseArrow(params) {
1008
+ return !this.canInsertSemicolon();
1009
+ }
1010
+ parseArrow(node) {
1011
+ if (this.eat(tt.arrow)) {
1012
+ return node;
1013
+ }
1014
+ }
1015
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- Retain the upstream parser interface and bindings.
1016
+ parseParenItem(node, startLoc) {
1017
+ return node;
1018
+ }
1019
+ parseNewOrNewTarget() {
1020
+ const node = this.startNode();
1021
+ this.next();
1022
+ if (this.match(tt.dot)) {
1023
+ const meta = this.createIdentifier(this.startNodeAtNode(node), "new");
1024
+ this.next();
1025
+ const metaProp = this.parseMetaProperty(node, meta, "target");
1026
+ if (!this.scope.allowNewTarget) {
1027
+ this.raise(Errors.UnexpectedNewTarget, metaProp);
1028
+ }
1029
+ return metaProp;
1030
+ }
1031
+ return this.parseNew(node);
1032
+ }
1033
+ parseNew(node) {
1034
+ this.parseNewCallee(node);
1035
+ if (this.eat(tt.parenL)) {
1036
+ const args = this.parseExprList(tt.parenR);
1037
+ this.toReferencedList(args);
1038
+ node.arguments = args;
1039
+ } else {
1040
+ node.arguments = [];
1041
+ }
1042
+ return this.finishNode(node, "NewExpression");
1043
+ }
1044
+ parseNewCallee(node) {
1045
+ const isImport = this.match(tt._import);
1046
+ const callee = this.parseNoCallExpr();
1047
+ node.callee = callee;
1048
+ if (isImport && callee.type === "ImportExpression" || callee.type === "Import") {
1049
+ this.raise(Errors.ImportCallNotNewExpression, callee);
1050
+ }
1051
+ if (callee.type === "Super") {
1052
+ this.raise(Errors.SuperCallNotNewExpression, callee);
1053
+ }
1054
+ }
1055
+ parseTemplateElement(isTagged) {
1056
+ const {
1057
+ start,
1058
+ startLoc,
1059
+ end,
1060
+ value
1061
+ } = this.state;
1062
+ const elemStart = start + 1;
1063
+ const elem = this.startNodeAt(createPositionWithColumnOffset(startLoc, 1));
1064
+ if (value === null) {
1065
+ if (!isTagged) {
1066
+ this.raise(Errors.InvalidEscapeSequenceTemplate, createPositionWithColumnOffset(this.state.firstInvalidTemplateEscapePos, 1));
1067
+ }
1068
+ }
1069
+ const isTail = this.match(tt.templateTail);
1070
+ const endOffset = isTail ? -1 : -2;
1071
+ const elemEnd = end + endOffset;
1072
+ elem.value = {
1073
+ raw: this.input.slice(elemStart, elemEnd).replace(/\r\n?/g, "\n"),
1074
+ cooked: value === null ? null : value.slice(1, endOffset)
1075
+ };
1076
+ elem.tail = isTail;
1077
+ this.next();
1078
+ const finishedNode = this.finishNode(elem, "TemplateElement");
1079
+ this.resetEndLocation(finishedNode, createPositionWithColumnOffset(this.state.lastTokEndLoc, endOffset));
1080
+ return finishedNode;
1081
+ }
1082
+ parseTemplate(isTagged) {
1083
+ const node = this.startNode();
1084
+ let curElt = this.parseTemplateElement(isTagged);
1085
+ const quasis = [curElt];
1086
+ const substitutions = [];
1087
+ while (!curElt.tail) {
1088
+ substitutions.push(this.parseTemplateSubstitution());
1089
+ this.readTemplateContinuation();
1090
+ quasis.push(curElt = this.parseTemplateElement(isTagged));
1091
+ }
1092
+ node.expressions = substitutions;
1093
+ node.quasis = quasis;
1094
+ return this.finishNode(node, "TemplateLiteral");
1095
+ }
1096
+ parseTemplateSubstitution() {
1097
+ return this.parseExpression();
1098
+ }
1099
+ parseObjectLike(close, isPattern, isRecord, refExpressionErrors) {
1100
+ if (isRecord) {
1101
+ this.expectPlugin("recordAndTuple");
1102
+ }
1103
+ const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
1104
+ this.state.inFSharpPipelineDirectBody = false;
1105
+ let sawProto = false;
1106
+ let first = true;
1107
+ const node = this.startNode();
1108
+ node.properties = [];
1109
+ this.next();
1110
+ while (!this.match(close)) {
1111
+ if (first) {
1112
+ first = false;
1113
+ } else {
1114
+ this.expect(tt.comma);
1115
+ if (this.match(close)) {
1116
+ this.addTrailingCommaExtraToNode(node);
1117
+ break;
1118
+ }
1119
+ }
1120
+ let prop;
1121
+ if (isPattern) {
1122
+ prop = this.parseBindingProperty();
1123
+ } else {
1124
+ prop = this.parsePropertyDefinition(refExpressionErrors);
1125
+ sawProto = this.checkProto(prop, isRecord, sawProto, refExpressionErrors);
1126
+ }
1127
+ if (isRecord && !this.isObjectProperty(prop) && prop.type !== "SpreadElement") {
1128
+ this.raise(Errors.InvalidRecordProperty, prop);
1129
+ }
1130
+ {
1131
+ if (prop.shorthand) {
1132
+ this.addExtra(prop, "shorthand", true);
1133
+ }
1134
+ }
1135
+ node.properties.push(prop);
1136
+ }
1137
+ this.next();
1138
+ this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
1139
+ let type = "ObjectExpression";
1140
+ if (isPattern) {
1141
+ type = "ObjectPattern";
1142
+ } else if (isRecord) {
1143
+ type = "RecordExpression";
1144
+ }
1145
+ return this.finishNode(node, type);
1146
+ }
1147
+ addTrailingCommaExtraToNode(node) {
1148
+ this.addExtra(node, "trailingComma", this.state.lastTokStartLoc.index);
1149
+ this.addExtra(node, "trailingCommaLoc", this.state.lastTokStartLoc, false);
1150
+ }
1151
+ maybeAsyncOrAccessorProp(prop) {
1152
+ return !prop.computed && prop.key.type === "Identifier" && (this.isLiteralPropertyName() || this.match(tt.bracketL) || this.match(tt.star));
1153
+ }
1154
+ parsePropertyDefinition(refExpressionErrors) {
1155
+ let decorators = [];
1156
+ if (this.match(tt.at)) {
1157
+ if (this.hasPlugin("decorators")) {
1158
+ this.raise(Errors.UnsupportedPropertyDecorator, this.state.startLoc);
1159
+ }
1160
+ while (this.match(tt.at)) {
1161
+ decorators.push(this.parseDecorator());
1162
+ }
1163
+ }
1164
+ const prop = this.startNode();
1165
+ let isAsync = false;
1166
+ let isAccessor = false;
1167
+ let startLoc;
1168
+ if (this.match(tt.ellipsis)) {
1169
+ if (decorators.length) this.unexpected();
1170
+ return this.parseSpread();
1171
+ }
1172
+ if (decorators.length) {
1173
+ prop.decorators = decorators;
1174
+ decorators = [];
1175
+ }
1176
+ prop.method = false;
1177
+ if (refExpressionErrors) {
1178
+ startLoc = this.state.startLoc;
1179
+ }
1180
+ let isGenerator = this.eat(tt.star);
1181
+ this.parsePropertyNamePrefixOperator(prop);
1182
+ const containsEsc = this.state.containsEsc;
1183
+ this.parsePropertyName(prop, refExpressionErrors);
1184
+ if (!isGenerator && !containsEsc && this.maybeAsyncOrAccessorProp(prop)) {
1185
+ const {
1186
+ key
1187
+ } = prop;
1188
+ const keyName = key.name;
1189
+ if (keyName === "async" && !this.hasPrecedingLineBreak()) {
1190
+ isAsync = true;
1191
+ this.resetPreviousNodeTrailingComments(key);
1192
+ isGenerator = this.eat(tt.star);
1193
+ this.parsePropertyName(prop);
1194
+ }
1195
+ if (keyName === "get" || keyName === "set") {
1196
+ isAccessor = true;
1197
+ this.resetPreviousNodeTrailingComments(key);
1198
+ prop.kind = keyName;
1199
+ if (this.match(tt.star)) {
1200
+ isGenerator = true;
1201
+ this.raise(Errors.AccessorIsGenerator, this.state.curPosition(), {
1202
+ kind: keyName
1203
+ });
1204
+ this.next();
1205
+ }
1206
+ this.parsePropertyName(prop);
1207
+ }
1208
+ }
1209
+ return this.parseObjPropValue(prop, startLoc, isGenerator, isAsync, false, isAccessor, refExpressionErrors);
1210
+ }
1211
+ getGetterSetterExpectedParamCount(method) {
1212
+ return method.kind === "get" ? 0 : 1;
1213
+ }
1214
+ getObjectOrClassMethodParams(method) {
1215
+ return method.params;
1216
+ }
1217
+ checkGetterSetterParams(method) {
1218
+ const paramCount = this.getGetterSetterExpectedParamCount(method);
1219
+ const params = this.getObjectOrClassMethodParams(method);
1220
+ if (params.length !== paramCount) {
1221
+ this.raise(method.kind === "get" ? Errors.BadGetterArity : Errors.BadSetterArity, method);
1222
+ }
1223
+ if (method.kind === "set" && params[params.length - 1]?.type === "RestElement") {
1224
+ this.raise(Errors.BadSetterRestParameter, method);
1225
+ }
1226
+ }
1227
+ parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) {
1228
+ if (isAccessor) {
1229
+ const finishedProp = this.parseMethod(prop, isGenerator, false, false, false, "ObjectMethod");
1230
+ this.checkGetterSetterParams(finishedProp);
1231
+ return finishedProp;
1232
+ }
1233
+ if (isAsync || isGenerator || this.match(tt.parenL)) {
1234
+ if (isPattern) this.unexpected();
1235
+ prop.kind = "method";
1236
+ prop.method = true;
1237
+ return this.parseMethod(prop, isGenerator, isAsync, false, false, "ObjectMethod");
1238
+ }
1239
+ }
1240
+ parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors) {
1241
+ prop.shorthand = false;
1242
+ if (this.eat(tt.colon)) {
1243
+ prop.value = isPattern ? this.parseMaybeDefault(this.state.startLoc) : this.parseMaybeAssignAllowInOrVoidPattern(tt.braceR, refExpressionErrors);
1244
+ return this.finishObjectProperty(prop);
1245
+ }
1246
+ if (!prop.computed && prop.key.type === "Identifier") {
1247
+ this.checkReservedWord(prop.key.name, prop.key.loc.start, true, false);
1248
+ if (isPattern) {
1249
+ prop.value = this.parseMaybeDefault(startLoc, this.cloneIdentifier(prop.key));
1250
+ } else if (this.match(tt.eq)) {
1251
+ const shorthandAssignLoc = this.state.startLoc;
1252
+ if (refExpressionErrors != null) {
1253
+ if (refExpressionErrors.shorthandAssignLoc === null) {
1254
+ refExpressionErrors.shorthandAssignLoc = shorthandAssignLoc;
1255
+ }
1256
+ } else {
1257
+ this.raise(Errors.InvalidCoverInitializedName, shorthandAssignLoc);
1258
+ }
1259
+ prop.value = this.parseMaybeDefault(startLoc, this.cloneIdentifier(prop.key));
1260
+ } else {
1261
+ prop.value = this.cloneIdentifier(prop.key);
1262
+ }
1263
+ prop.shorthand = true;
1264
+ return this.finishObjectProperty(prop);
1265
+ }
1266
+ }
1267
+ finishObjectProperty(node) {
1268
+ return this.finishNode(node, "ObjectProperty");
1269
+ }
1270
+ parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
1271
+ const node = this.parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) || this.parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors);
1272
+ if (!node) this.unexpected();
1273
+ return node;
1274
+ }
1275
+ parsePropertyName(prop, refExpressionErrors) {
1276
+ if (this.eat(tt.bracketL)) {
1277
+ prop.computed = true;
1278
+ prop.key = this.parseMaybeAssignAllowIn();
1279
+ this.expect(tt.bracketR);
1280
+ } else {
1281
+ const {
1282
+ type,
1283
+ value
1284
+ } = this.state;
1285
+ let key;
1286
+ if (tokenIsKeywordOrIdentifier(type)) {
1287
+ key = this.parseIdentifier(true);
1288
+ } else {
1289
+ switch (type) {
1290
+ case tt.num:
1291
+ key = this.parseNumericLiteral(value);
1292
+ break;
1293
+ case tt.string:
1294
+ key = this.parseStringLiteral(value);
1295
+ break;
1296
+ case tt.bigint:
1297
+ key = this.parseBigIntLiteral(value);
1298
+ break;
1299
+ case tt.privateName: {
1300
+ const privateKeyLoc = this.state.startLoc;
1301
+ if (refExpressionErrors != null) {
1302
+ if (refExpressionErrors.privateKeyLoc === null) {
1303
+ refExpressionErrors.privateKeyLoc = privateKeyLoc;
1304
+ }
1305
+ } else {
1306
+ this.raise(Errors.UnexpectedPrivateField, privateKeyLoc);
1307
+ }
1308
+ key = this.parsePrivateName();
1309
+ break;
1310
+ }
1311
+ default:
1312
+ if (type === tt.decimal) {
1313
+ key = this.parseDecimalLiteral(value);
1314
+ break;
1315
+ }
1316
+ this.unexpected();
1317
+ }
1318
+ }
1319
+ prop.key = key;
1320
+ if (type !== tt.privateName) {
1321
+ prop.computed = false;
1322
+ }
1323
+ }
1324
+ }
1325
+ initFunction(node, isAsync) {
1326
+ node.id = null;
1327
+ node.generator = false;
1328
+ node.async = isAsync;
1329
+ }
1330
+ parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) {
1331
+ this.initFunction(node, isAsync);
1332
+ node.generator = isGenerator;
1333
+ this.scope.enter(ScopeFlag.FUNCTION | ScopeFlag.SUPER | (inClassScope ? ScopeFlag.CLASS : 0) | (allowDirectSuper ? ScopeFlag.DIRECT_SUPER : 0));
1334
+ this.prodParam.enter(functionFlags(isAsync, node.generator));
1335
+ this.parseFunctionParams(node, isConstructor);
1336
+ const finishedNode = this.parseFunctionBodyAndFinish(node, type, true);
1337
+ this.prodParam.exit();
1338
+ this.scope.exit();
1339
+ return finishedNode;
1340
+ }
1341
+ parseArrayLike(close, isTuple, refExpressionErrors) {
1342
+ if (isTuple) {
1343
+ this.expectPlugin("recordAndTuple");
1344
+ }
1345
+ const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
1346
+ this.state.inFSharpPipelineDirectBody = false;
1347
+ const node = this.startNode();
1348
+ this.next();
1349
+ node.elements = this.parseExprList(close, !isTuple, refExpressionErrors, node);
1350
+ this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
1351
+ return this.finishNode(node, isTuple ? "TupleExpression" : "ArrayExpression");
1352
+ }
1353
+ parseArrowExpression(node, params, isAsync, trailingCommaLoc) {
1354
+ this.scope.enter(ScopeFlag.FUNCTION | ScopeFlag.ARROW);
1355
+ let flags = functionFlags(isAsync, false);
1356
+ if (!this.match(tt.braceL) && this.prodParam.hasIn) {
1357
+ flags |= ParamKind.PARAM_IN;
1358
+ }
1359
+ this.prodParam.enter(flags);
1360
+ this.initFunction(node, isAsync);
1361
+ const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
1362
+ if (params) {
1363
+ this.state.maybeInArrowParameters = true;
1364
+ this.setArrowFunctionParameters(node, params, trailingCommaLoc);
1365
+ }
1366
+ this.state.maybeInArrowParameters = false;
1367
+ this.parseFunctionBody(node, true);
1368
+ this.prodParam.exit();
1369
+ this.scope.exit();
1370
+ this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
1371
+ return this.finishNode(node, "ArrowFunctionExpression");
1372
+ }
1373
+ setArrowFunctionParameters(node, params, trailingCommaLoc) {
1374
+ this.toAssignableList(params, trailingCommaLoc, false);
1375
+ node.params = params;
1376
+ }
1377
+ parseFunctionBodyAndFinish(node, type, isMethod = false) {
1378
+ this.parseFunctionBody(node, false, isMethod);
1379
+ return this.finishNode(node, type);
1380
+ }
1381
+ parseFunctionBody(node, allowExpression, isMethod = false) {
1382
+ const isExpression = allowExpression && !this.match(tt.braceL);
1383
+ this.expressionScope.enter(newExpressionScope());
1384
+ if (isExpression) {
1385
+ node.body = this.parseMaybeAssign();
1386
+ this.checkParams(node, false, allowExpression, false);
1387
+ } else {
1388
+ const oldStrict = this.state.strict;
1389
+ const oldLabels = this.state.labels;
1390
+ this.state.labels = [];
1391
+ this.prodParam.enter(this.prodParam.currentFlags() | ParamKind.PARAM_RETURN);
1392
+ node.body = this.parseBlock(true, false, (hasStrictModeDirective) => {
1393
+ const nonSimple = !this.isSimpleParamList(node.params);
1394
+ if (hasStrictModeDirective && nonSimple) {
1395
+ this.raise(Errors.IllegalLanguageModeDirective, (node.kind === "method" || node.kind === "constructor") && !!node.key ? node.key.loc.end : node);
1396
+ }
1397
+ const strictModeChanged = !oldStrict && this.state.strict;
1398
+ this.checkParams(node, !this.state.strict && !allowExpression && !isMethod && !nonSimple, allowExpression, strictModeChanged);
1399
+ if (this.state.strict && node.id) {
1400
+ this.checkIdentifier(node.id, BindingFlag.TYPE_OUTSIDE, strictModeChanged);
1401
+ }
1402
+ });
1403
+ this.prodParam.exit();
1404
+ this.state.labels = oldLabels;
1405
+ }
1406
+ this.expressionScope.exit();
1407
+ }
1408
+ isSimpleParameter(node) {
1409
+ return node.type === "Identifier";
1410
+ }
1411
+ isSimpleParamList(params) {
1412
+ for (let i = 0, len = params.length; i < len; i++) {
1413
+ if (!this.isSimpleParameter(params[i])) return false;
1414
+ }
1415
+ return true;
1416
+ }
1417
+ checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) {
1418
+ const checkClashes = !allowDuplicates && /* @__PURE__ */ new Set();
1419
+ const formalParameters = {
1420
+ type: "FormalParameters"
1421
+ };
1422
+ for (const param of node.params) {
1423
+ this.checkLVal(param, formalParameters, BindingFlag.TYPE_VAR, checkClashes, strictModeChanged);
1424
+ }
1425
+ }
1426
+ parseExprList(close, allowEmpty, refExpressionErrors, nodeForExtra) {
1427
+ const elts = [];
1428
+ let first = true;
1429
+ while (!this.eat(close)) {
1430
+ if (first) {
1431
+ first = false;
1432
+ } else {
1433
+ this.expect(tt.comma);
1434
+ if (this.match(close)) {
1435
+ if (nodeForExtra) {
1436
+ this.addTrailingCommaExtraToNode(nodeForExtra);
1437
+ }
1438
+ this.next();
1439
+ break;
1440
+ }
1441
+ }
1442
+ elts.push(this.parseExprListItem(close, allowEmpty, refExpressionErrors));
1443
+ }
1444
+ return elts;
1445
+ }
1446
+ parseExprListItem(close, allowEmpty, refExpressionErrors, allowPlaceholder) {
1447
+ let elt;
1448
+ if (this.match(tt.comma)) {
1449
+ if (!allowEmpty) {
1450
+ this.raise(Errors.UnexpectedToken, this.state.curPosition(), {
1451
+ unexpected: ","
1452
+ });
1453
+ }
1454
+ elt = null;
1455
+ } else if (this.match(tt.ellipsis)) {
1456
+ const spreadNodeStartLoc = this.state.startLoc;
1457
+ elt = this.parseParenItem(this.parseSpread(refExpressionErrors), spreadNodeStartLoc);
1458
+ } else if (this.match(tt.question)) {
1459
+ this.expectPlugin("partialApplication");
1460
+ if (!allowPlaceholder) {
1461
+ this.raise(Errors.UnexpectedArgumentPlaceholder, this.state.startLoc);
1462
+ }
1463
+ const node = this.startNode();
1464
+ this.next();
1465
+ elt = this.finishNode(node, "ArgumentPlaceholder");
1466
+ } else {
1467
+ elt = this.parseMaybeAssignAllowInOrVoidPattern(close, refExpressionErrors, this.parseParenItem);
1468
+ }
1469
+ return elt;
1470
+ }
1471
+ parseIdentifier(liberal) {
1472
+ const node = this.startNode();
1473
+ const name = this.parseIdentifierName(liberal);
1474
+ return this.createIdentifier(node, name);
1475
+ }
1476
+ createIdentifier(node, name) {
1477
+ node.name = name;
1478
+ node.loc.identifierName = name;
1479
+ return this.finishNode(node, "Identifier");
1480
+ }
1481
+ createIdentifierAt(node, name, endLoc) {
1482
+ node.name = name;
1483
+ node.loc.identifierName = name;
1484
+ return this.finishNodeAt(node, "Identifier", endLoc);
1485
+ }
1486
+ parseIdentifierName(liberal) {
1487
+ let name;
1488
+ const {
1489
+ startLoc,
1490
+ type
1491
+ } = this.state;
1492
+ if (tokenIsKeywordOrIdentifier(type)) {
1493
+ name = this.state.value;
1494
+ } else {
1495
+ this.unexpected();
1496
+ }
1497
+ const tokenIsKeyword = tokenKeywordOrIdentifierIsKeyword(type);
1498
+ if (liberal) {
1499
+ if (tokenIsKeyword) {
1500
+ this.replaceToken(tt.name);
1501
+ }
1502
+ } else {
1503
+ this.checkReservedWord(name, startLoc, tokenIsKeyword, false);
1504
+ }
1505
+ this.next();
1506
+ return name;
1507
+ }
1508
+ checkReservedWord(word, startLoc, checkKeywords, isBinding) {
1509
+ if (word.length > 10) {
1510
+ return;
1511
+ }
1512
+ if (!canBeReservedWord(word)) {
1513
+ return;
1514
+ }
1515
+ if (checkKeywords && isKeyword(word)) {
1516
+ this.raise(Errors.UnexpectedKeyword, startLoc, {
1517
+ keyword: word
1518
+ });
1519
+ return;
1520
+ }
1521
+ const reservedTest = !this.state.strict ? isReservedWord : isBinding ? isStrictBindReservedWord : isStrictReservedWord;
1522
+ if (reservedTest(word, this.inModule)) {
1523
+ this.raise(Errors.UnexpectedReservedWord, startLoc, {
1524
+ reservedWord: word
1525
+ });
1526
+ return;
1527
+ } else if (word === "yield") {
1528
+ if (this.prodParam.hasYield) {
1529
+ this.raise(Errors.YieldBindingIdentifier, startLoc);
1530
+ return;
1531
+ }
1532
+ } else if (word === "await") {
1533
+ if (this.prodParam.hasAwait) {
1534
+ this.raise(Errors.AwaitBindingIdentifier, startLoc);
1535
+ return;
1536
+ }
1537
+ if (this.scope.inStaticBlock) {
1538
+ this.raise(Errors.AwaitBindingIdentifierInStaticBlock, startLoc);
1539
+ return;
1540
+ }
1541
+ this.expressionScope.recordAsyncArrowParametersError(startLoc);
1542
+ } else if (word === "arguments") {
1543
+ if (this.scope.inClassAndNotInNonArrowFunction) {
1544
+ this.raise(Errors.ArgumentsInClass, startLoc);
1545
+ return;
1546
+ }
1547
+ }
1548
+ }
1549
+ recordAwaitIfAllowed() {
1550
+ const isAwaitAllowed = this.prodParam.hasAwait;
1551
+ if (isAwaitAllowed && !this.scope.inFunction) {
1552
+ this.state.hasTopLevelAwait = true;
1553
+ }
1554
+ return isAwaitAllowed;
1555
+ }
1556
+ parseAwait(startLoc) {
1557
+ const node = this.startNodeAt(startLoc);
1558
+ this.expressionScope.recordParameterInitializerError(Errors.AwaitExpressionFormalParameter, node);
1559
+ if (this.eat(tt.star)) {
1560
+ this.raise(Errors.ObsoleteAwaitStar, node);
1561
+ }
1562
+ if (!this.scope.inFunction && !(this.optionFlags & OptionFlags.AllowAwaitOutsideFunction)) {
1563
+ if (this.isAmbiguousPrefixOrIdentifier()) {
1564
+ this.ambiguousScriptDifferentAst = true;
1565
+ } else {
1566
+ this.sawUnambiguousESM = true;
1567
+ }
1568
+ }
1569
+ if (!this.state.soloAwait) {
1570
+ node.argument = this.parseMaybeUnary(null, true);
1571
+ }
1572
+ return this.finishNode(node, "AwaitExpression");
1573
+ }
1574
+ isAmbiguousPrefixOrIdentifier() {
1575
+ if (this.hasPrecedingLineBreak()) return true;
1576
+ const {
1577
+ type
1578
+ } = this.state;
1579
+ return type === tt.plusMin || type === tt.parenL || type === tt.bracketL || tokenIsTemplate(type) || type === tt._of && !this.state.containsEsc || type === tt.regexp || type === tt.slash || this.hasPlugin("v8intrinsic") && type === tt.modulo;
1580
+ }
1581
+ parseYield(startLoc) {
1582
+ const node = this.startNodeAt(startLoc);
1583
+ this.expressionScope.recordParameterInitializerError(Errors.YieldInParameter, node);
1584
+ let delegating = false;
1585
+ let argument = null;
1586
+ if (!this.hasPrecedingLineBreak()) {
1587
+ delegating = this.eat(tt.star);
1588
+ switch (this.state.type) {
1589
+ case tt.semi:
1590
+ case tt.eof:
1591
+ case tt.braceR:
1592
+ case tt.parenR:
1593
+ case tt.bracketR:
1594
+ case tt.braceBarR:
1595
+ case tt.colon:
1596
+ case tt.comma:
1597
+ if (!delegating) break;
1598
+ // falls through (upstream parser grammar)
1599
+ default:
1600
+ argument = this.parseMaybeAssign();
1601
+ }
1602
+ }
1603
+ node.delegate = delegating;
1604
+ node.argument = argument;
1605
+ return this.finishNode(node, "YieldExpression");
1606
+ }
1607
+ parseImportCall(node) {
1608
+ this.next();
1609
+ node.source = this.parseMaybeAssignAllowIn();
1610
+ node.options = null;
1611
+ if (this.eat(tt.comma)) {
1612
+ if (!this.match(tt.parenR)) {
1613
+ node.options = this.parseMaybeAssignAllowIn();
1614
+ if (this.eat(tt.comma)) {
1615
+ this.addTrailingCommaExtraToNode(node.options);
1616
+ if (!this.match(tt.parenR)) {
1617
+ do {
1618
+ this.parseMaybeAssignAllowIn();
1619
+ } while (this.eat(tt.comma) && !this.match(tt.parenR));
1620
+ this.raise(Errors.ImportCallArity, node);
1621
+ }
1622
+ }
1623
+ } else {
1624
+ this.addTrailingCommaExtraToNode(node.source);
1625
+ }
1626
+ }
1627
+ this.expect(tt.parenR);
1628
+ return this.finishNode(node, "ImportExpression");
1629
+ }
1630
+ checkPipelineAtInfixOperator(left, leftStartLoc) {
1631
+ if (this.hasPlugin(["pipelineOperator", {
1632
+ proposal: "smart"
1633
+ }])) {
1634
+ if (left.type === "SequenceExpression") {
1635
+ this.raise(Errors.PipelineHeadSequenceExpression, leftStartLoc);
1636
+ }
1637
+ }
1638
+ }
1639
+ parseSmartPipelineBodyInStyle(childExpr, startLoc) {
1640
+ if (this.isSimpleReference(childExpr)) {
1641
+ const bodyNode = this.startNodeAt(startLoc);
1642
+ bodyNode.callee = childExpr;
1643
+ return this.finishNode(bodyNode, "PipelineBareFunction");
1644
+ } else {
1645
+ const bodyNode = this.startNodeAt(startLoc);
1646
+ this.checkSmartPipeTopicBodyEarlyErrors(startLoc);
1647
+ bodyNode.expression = childExpr;
1648
+ return this.finishNode(bodyNode, "PipelineTopicExpression");
1649
+ }
1650
+ }
1651
+ isSimpleReference(expression) {
1652
+ switch (expression.type) {
1653
+ case "MemberExpression":
1654
+ return !expression.computed && this.isSimpleReference(expression.object);
1655
+ case "Identifier":
1656
+ return true;
1657
+ default:
1658
+ return false;
1659
+ }
1660
+ }
1661
+ checkSmartPipeTopicBodyEarlyErrors(startLoc) {
1662
+ if (this.match(tt.arrow)) {
1663
+ throw this.raise(Errors.PipelineBodyNoArrow, this.state.startLoc);
1664
+ }
1665
+ if (!this.topicReferenceWasUsedInCurrentContext()) {
1666
+ this.raise(Errors.PipelineTopicUnused, startLoc);
1667
+ }
1668
+ }
1669
+ withTopicBindingContext(callback) {
1670
+ const outerContextTopicState = this.state.topicContext;
1671
+ this.state.topicContext = {
1672
+ maxNumOfResolvableTopics: 1,
1673
+ maxTopicIndex: null
1674
+ };
1675
+ try {
1676
+ return callback();
1677
+ } finally {
1678
+ this.state.topicContext = outerContextTopicState;
1679
+ }
1680
+ }
1681
+ withSmartMixTopicForbiddingContext(callback) {
1682
+ if (this.hasPlugin(["pipelineOperator", {
1683
+ proposal: "smart"
1684
+ }])) {
1685
+ const outerContextTopicState = this.state.topicContext;
1686
+ this.state.topicContext = {
1687
+ maxNumOfResolvableTopics: 0,
1688
+ maxTopicIndex: null
1689
+ };
1690
+ try {
1691
+ return callback();
1692
+ } finally {
1693
+ this.state.topicContext = outerContextTopicState;
1694
+ }
1695
+ } else {
1696
+ return callback();
1697
+ }
1698
+ }
1699
+ withSoloAwaitPermittingContext(callback) {
1700
+ const outerContextSoloAwaitState = this.state.soloAwait;
1701
+ this.state.soloAwait = true;
1702
+ try {
1703
+ return callback();
1704
+ } finally {
1705
+ this.state.soloAwait = outerContextSoloAwaitState;
1706
+ }
1707
+ }
1708
+ allowInAnd(callback) {
1709
+ const flags = this.prodParam.currentFlags();
1710
+ const prodParamToSet = ParamKind.PARAM_IN & ~flags;
1711
+ if (prodParamToSet) {
1712
+ this.prodParam.enter(flags | ParamKind.PARAM_IN);
1713
+ try {
1714
+ return callback();
1715
+ } finally {
1716
+ this.prodParam.exit();
1717
+ }
1718
+ }
1719
+ return callback();
1720
+ }
1721
+ disallowInAnd(callback) {
1722
+ const flags = this.prodParam.currentFlags();
1723
+ const prodParamToClear = ParamKind.PARAM_IN & flags;
1724
+ if (prodParamToClear) {
1725
+ this.prodParam.enter(flags & ~ParamKind.PARAM_IN);
1726
+ try {
1727
+ return callback();
1728
+ } finally {
1729
+ this.prodParam.exit();
1730
+ }
1731
+ }
1732
+ return callback();
1733
+ }
1734
+ registerTopicReference() {
1735
+ this.state.topicContext.maxTopicIndex = 0;
1736
+ }
1737
+ topicReferenceIsAllowedInCurrentContext() {
1738
+ return this.state.topicContext.maxNumOfResolvableTopics >= 1;
1739
+ }
1740
+ topicReferenceWasUsedInCurrentContext() {
1741
+ return this.state.topicContext.maxTopicIndex != null && this.state.topicContext.maxTopicIndex >= 0;
1742
+ }
1743
+ parseFSharpPipelineBody(prec) {
1744
+ const startLoc = this.state.startLoc;
1745
+ this.state.potentialArrowAt = this.state.start;
1746
+ const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
1747
+ this.state.inFSharpPipelineDirectBody = true;
1748
+ const ret = this.parseExprOp(this.parseMaybeUnaryOrPrivate(), startLoc, prec);
1749
+ this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
1750
+ return ret;
1751
+ }
1752
+ parseModuleExpression() {
1753
+ this.expectPlugin("moduleBlocks");
1754
+ const node = this.startNode();
1755
+ this.next();
1756
+ if (!this.match(tt.braceL)) {
1757
+ this.unexpected(null, tt.braceL);
1758
+ }
1759
+ const program = this.startNodeAt(this.state.endLoc);
1760
+ this.next();
1761
+ const revertScopes = this.initializeScopes(true);
1762
+ this.enterInitialScopes();
1763
+ try {
1764
+ node.body = this.parseProgram(program, tt.braceR, "module");
1765
+ } finally {
1766
+ revertScopes();
1767
+ }
1768
+ return this.finishNode(node, "ModuleExpression");
1769
+ }
1770
+ parseVoidPattern(refExpressionErrors) {
1771
+ this.expectPlugin("discardBinding");
1772
+ const node = this.startNode();
1773
+ if (refExpressionErrors != null) {
1774
+ refExpressionErrors.voidPatternLoc = this.state.startLoc;
1775
+ }
1776
+ this.next();
1777
+ return this.finishNode(node, "VoidPattern");
1778
+ }
1779
+ parseMaybeAssignAllowInOrVoidPattern(close, refExpressionErrors, afterLeftParse) {
1780
+ if (refExpressionErrors != null && this.match(tt._void)) {
1781
+ const nextCode = this.lookaheadCharCode();
1782
+ if (nextCode === 44 || nextCode === (close === tt.bracketR ? 93 : close === tt.braceR ? 125 : 41) || nextCode === 61) {
1783
+ return this.parseMaybeDefault(this.state.startLoc, this.parseVoidPattern(refExpressionErrors));
1784
+ }
1785
+ }
1786
+ return this.parseMaybeAssignAllowIn(refExpressionErrors, afterLeftParse);
1787
+ }
1788
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- Retain the upstream parser interface and bindings.
1789
+ parsePropertyNamePrefixOperator(prop) {
1790
+ }
1791
+ }
1792
+ export {
1793
+ ExpressionParser as default
1794
+ };