driftjs-compiler 0.0.0
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.
- package/dist/index-es.js +4804 -0
- package/package.json +28 -0
- package/src/generator.ts +1029 -0
- package/src/index.ts +36 -0
- package/src/lexer.ts +954 -0
- package/src/parser.ts +533 -0
- package/src/transformer.ts +288 -0
- package/tests/generator.test.ts +149 -0
- package/tests/if_conditionals.test.ts +371 -0
- package/tests/lexer.test.ts +221 -0
- package/tests/parser.test.ts +302 -0
- package/tests/transformer.test.ts +110 -0
- package/tsconfig.json +8 -0
- package/types/ast.ts +88 -0
- package/types/error.ts +29 -0
- package/types/index.ts +6 -0
- package/types/lexer-state.ts +118 -0
- package/types/opcodes.ts +66 -0
- package/types/token.ts +61 -0
- package/vite.config.ts +20 -0
package/dist/index-es.js
ADDED
|
@@ -0,0 +1,4804 @@
|
|
|
1
|
+
//#region types/token.ts
|
|
2
|
+
var e = {
|
|
3
|
+
TagOpen: "TagOpen",
|
|
4
|
+
TagOpenSlash: "TagOpenSlash",
|
|
5
|
+
TagClose: "TagClose",
|
|
6
|
+
TagSelfClose: "TagSelfClose",
|
|
7
|
+
Equals: "Equals",
|
|
8
|
+
Identifier: "Identifier",
|
|
9
|
+
StringLiteral: "StringLiteral",
|
|
10
|
+
Text: "Text",
|
|
11
|
+
Interpolation: "Interpolation",
|
|
12
|
+
Comment: "Comment",
|
|
13
|
+
DirectiveIf: "DirectiveIf",
|
|
14
|
+
DirectiveElseIf: "DirectiveElseIf",
|
|
15
|
+
DirectiveElse: "DirectiveElse",
|
|
16
|
+
DirectiveFor: "DirectiveFor",
|
|
17
|
+
DirectiveSwitch: "DirectiveSwitch",
|
|
18
|
+
DirectiveCase: "DirectiveCase",
|
|
19
|
+
DirectiveDefault: "DirectiveDefault",
|
|
20
|
+
BlockOpen: "BlockOpen",
|
|
21
|
+
BlockClose: "BlockClose",
|
|
22
|
+
EOF: "EOF"
|
|
23
|
+
}, t = {
|
|
24
|
+
Data: "Data",
|
|
25
|
+
TagOpen: "TagOpen",
|
|
26
|
+
EndTagOpen: "EndTagOpen",
|
|
27
|
+
BeforeAttributeName: "BeforeAttributeName",
|
|
28
|
+
AttributeName: "AttributeName",
|
|
29
|
+
AfterAttributeName: "AfterAttributeName",
|
|
30
|
+
BeforeAttributeValue: "BeforeAttributeValue",
|
|
31
|
+
AttributeValueQuoted: "AttributeValueQuoted",
|
|
32
|
+
AttributeValueInterpolation: "AttributeValueInterpolation",
|
|
33
|
+
Comment: "Comment",
|
|
34
|
+
Interpolation: "Interpolation",
|
|
35
|
+
RawText: "RawText",
|
|
36
|
+
EOF: "EOF"
|
|
37
|
+
}, n = {
|
|
38
|
+
Program: "Program",
|
|
39
|
+
Element: "Element",
|
|
40
|
+
Text: "Text",
|
|
41
|
+
Interpolation: "Interpolation",
|
|
42
|
+
Attribute: "Attribute",
|
|
43
|
+
Comment: "Comment",
|
|
44
|
+
If: "If",
|
|
45
|
+
For: "For",
|
|
46
|
+
Switch: "Switch"
|
|
47
|
+
}, r = class extends Error {
|
|
48
|
+
line;
|
|
49
|
+
column;
|
|
50
|
+
offset;
|
|
51
|
+
constructor(e, t, n, r) {
|
|
52
|
+
super(`LexerError [${t}:${n}]: ${e}`), this.line = t, this.column = n, this.offset = r, this.name = "DriftLexerError";
|
|
53
|
+
}
|
|
54
|
+
}, i = class extends Error {
|
|
55
|
+
line;
|
|
56
|
+
column;
|
|
57
|
+
offset;
|
|
58
|
+
constructor(e, t, n, r) {
|
|
59
|
+
super(`ParserError [${t}:${n}]: ${e}`), this.line = t, this.column = n, this.offset = r, this.name = "DriftParserError";
|
|
60
|
+
}
|
|
61
|
+
}, a = /* @__PURE__ */ function(e) {
|
|
62
|
+
return e[e.RETURN = 0] = "RETURN", e[e.CREATE_ELEMENT = 1] = "CREATE_ELEMENT", e[e.CREATE_TEXT = 2] = "CREATE_TEXT", e[e.CREATE_COMMENT = 3] = "CREATE_COMMENT", e[e.APPEND_CHILD = 4] = "APPEND_CHILD", e[e.SET_ATTR = 5] = "SET_ATTR", e[e.CREATE_FRAGMENT = 6] = "CREATE_FRAGMENT", e[e.INTERPOLATE_TEXT = 7] = "INTERPOLATE_TEXT", e[e.JUMP = 8] = "JUMP", e[e.JUMP_IF_FALSE = 9] = "JUMP_IF_FALSE", e[e.EVAL_EXPR = 10] = "EVAL_EXPR", e[e.LOOP_ITER = 11] = "LOOP_ITER", e[e.EXEC_SCRIPT = 12] = "EXEC_SCRIPT", e[e.REACTIVE_IF = 13] = "REACTIVE_IF", e[e.REACTIVE_FOR = 14] = "REACTIVE_FOR", e;
|
|
63
|
+
}({}), o = {
|
|
64
|
+
[t.Data]: [
|
|
65
|
+
{
|
|
66
|
+
to: t.Comment,
|
|
67
|
+
when: "The next characters are <!--",
|
|
68
|
+
emits: "Comment"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
to: t.EndTagOpen,
|
|
72
|
+
when: "The next characters are </",
|
|
73
|
+
emits: "TagOpenSlash"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
to: t.TagOpen,
|
|
77
|
+
when: "The next character is '<' for a start tag",
|
|
78
|
+
emits: "TagOpen"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
to: t.Interpolation,
|
|
82
|
+
when: "The next character is '{' in element content",
|
|
83
|
+
emits: "Interpolation"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
to: t.Data,
|
|
87
|
+
when: "Plain content is consumed up to the next control delimiter",
|
|
88
|
+
emits: "Text"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
to: t.EOF,
|
|
92
|
+
when: "The source has been fully consumed",
|
|
93
|
+
emits: "EOF"
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
[t.TagOpen]: [{
|
|
97
|
+
to: t.BeforeAttributeName,
|
|
98
|
+
when: "A valid opening tag name is consumed",
|
|
99
|
+
emits: "Identifier"
|
|
100
|
+
}],
|
|
101
|
+
[t.EndTagOpen]: [{
|
|
102
|
+
to: t.BeforeAttributeName,
|
|
103
|
+
when: "A valid closing tag name is consumed",
|
|
104
|
+
emits: "Identifier"
|
|
105
|
+
}],
|
|
106
|
+
[t.BeforeAttributeName]: [
|
|
107
|
+
{
|
|
108
|
+
to: t.AttributeName,
|
|
109
|
+
when: "An attribute name begins in an opening tag",
|
|
110
|
+
emits: "Identifier"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
to: t.Data,
|
|
114
|
+
when: "A tag is closed with '>' and raw-text mode does not apply",
|
|
115
|
+
emits: "TagClose"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
to: t.RawText,
|
|
119
|
+
when: "A script/style start tag is closed with '>'",
|
|
120
|
+
emits: "TagClose"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
to: t.Data,
|
|
124
|
+
when: "A tag is self-closed with '/>'",
|
|
125
|
+
emits: "TagSelfClose"
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
[t.AttributeName]: [{
|
|
129
|
+
to: t.AfterAttributeName,
|
|
130
|
+
when: "The attribute identifier has been fully consumed",
|
|
131
|
+
emits: "Identifier"
|
|
132
|
+
}],
|
|
133
|
+
[t.AfterAttributeName]: [{
|
|
134
|
+
to: t.BeforeAttributeValue,
|
|
135
|
+
when: "The next character is '='",
|
|
136
|
+
emits: "Equals"
|
|
137
|
+
}, {
|
|
138
|
+
to: t.BeforeAttributeName,
|
|
139
|
+
when: "The attribute is boolean and the lexer moves to the next attribute or tag boundary",
|
|
140
|
+
emits: "No token"
|
|
141
|
+
}],
|
|
142
|
+
[t.BeforeAttributeValue]: [{
|
|
143
|
+
to: t.AttributeValueQuoted,
|
|
144
|
+
when: "The attribute value starts with a quote",
|
|
145
|
+
emits: "StringLiteral"
|
|
146
|
+
}, {
|
|
147
|
+
to: t.AttributeValueInterpolation,
|
|
148
|
+
when: "The attribute value starts with '{'",
|
|
149
|
+
emits: "Interpolation"
|
|
150
|
+
}],
|
|
151
|
+
[t.AttributeValueQuoted]: [{
|
|
152
|
+
to: t.BeforeAttributeName,
|
|
153
|
+
when: "The closing quote is consumed",
|
|
154
|
+
emits: "StringLiteral"
|
|
155
|
+
}],
|
|
156
|
+
[t.AttributeValueInterpolation]: [{
|
|
157
|
+
to: t.BeforeAttributeName,
|
|
158
|
+
when: "The interpolation closes and the attribute value is complete",
|
|
159
|
+
emits: "Interpolation"
|
|
160
|
+
}],
|
|
161
|
+
[t.Comment]: [{
|
|
162
|
+
to: t.Data,
|
|
163
|
+
when: "The terminating --> delimiter is consumed",
|
|
164
|
+
emits: "Comment"
|
|
165
|
+
}],
|
|
166
|
+
[t.Interpolation]: [{
|
|
167
|
+
to: t.Data,
|
|
168
|
+
when: "A content interpolation closes with a matching brace",
|
|
169
|
+
emits: "Interpolation"
|
|
170
|
+
}, {
|
|
171
|
+
to: t.BeforeAttributeName,
|
|
172
|
+
when: "An attribute interpolation closes with a matching brace",
|
|
173
|
+
emits: "Interpolation"
|
|
174
|
+
}],
|
|
175
|
+
[t.RawText]: [
|
|
176
|
+
{
|
|
177
|
+
to: t.RawText,
|
|
178
|
+
when: "Plain raw-text content is consumed before the matching closing tag",
|
|
179
|
+
emits: "Text"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
to: t.EndTagOpen,
|
|
183
|
+
when: "The matching raw-text closing tag begins with </",
|
|
184
|
+
emits: "TagOpenSlash"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
to: t.EOF,
|
|
188
|
+
when: "The raw-text block reaches end of input before a closing tag appears",
|
|
189
|
+
emits: "EOF"
|
|
190
|
+
}
|
|
191
|
+
],
|
|
192
|
+
[t.EOF]: [{
|
|
193
|
+
to: t.EOF,
|
|
194
|
+
when: "Additional parser requests are made after end of input",
|
|
195
|
+
emits: "EOF"
|
|
196
|
+
}]
|
|
197
|
+
};
|
|
198
|
+
function s(e) {
|
|
199
|
+
return e === "script" || e === "style";
|
|
200
|
+
}
|
|
201
|
+
var c = /* @__PURE__ */ new Set([
|
|
202
|
+
"if",
|
|
203
|
+
"else",
|
|
204
|
+
"for",
|
|
205
|
+
"switch",
|
|
206
|
+
"case",
|
|
207
|
+
"default"
|
|
208
|
+
]), l = class {
|
|
209
|
+
source;
|
|
210
|
+
offset = 0;
|
|
211
|
+
line = 1;
|
|
212
|
+
column = 1;
|
|
213
|
+
emittedTokenCount = 0;
|
|
214
|
+
eofToken = null;
|
|
215
|
+
state = { kind: t.Data };
|
|
216
|
+
blockDepth = 0;
|
|
217
|
+
constructor(e) {
|
|
218
|
+
this.source = e;
|
|
219
|
+
}
|
|
220
|
+
nextToken() {
|
|
221
|
+
let e = this.readNextToken();
|
|
222
|
+
return this.emittedTokenCount++, e;
|
|
223
|
+
}
|
|
224
|
+
getCurrentState() {
|
|
225
|
+
return this.state;
|
|
226
|
+
}
|
|
227
|
+
getEmittedTokenCount() {
|
|
228
|
+
return this.emittedTokenCount;
|
|
229
|
+
}
|
|
230
|
+
readNextToken() {
|
|
231
|
+
switch (this.state.kind) {
|
|
232
|
+
case t.Data: return this.readDataToken();
|
|
233
|
+
case t.TagOpen: return this.readTagNameToken(!1);
|
|
234
|
+
case t.EndTagOpen: return this.readTagNameToken(!0);
|
|
235
|
+
case t.BeforeAttributeName: return this.readBeforeAttributeNameToken();
|
|
236
|
+
case t.AttributeName: return this.readAttributeNameToken();
|
|
237
|
+
case t.AfterAttributeName: return this.readAfterAttributeNameToken();
|
|
238
|
+
case t.BeforeAttributeValue: return this.readBeforeAttributeValueToken();
|
|
239
|
+
case t.Comment:
|
|
240
|
+
case t.Interpolation:
|
|
241
|
+
case t.AttributeValueQuoted:
|
|
242
|
+
case t.AttributeValueInterpolation: throw Error(`Lexer entered transient state '${this.state.kind}' unexpectedly.`);
|
|
243
|
+
case t.RawText: return this.readRawTextToken();
|
|
244
|
+
case t.EOF: return this.getOrCreateEOFToken();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
readDataToken() {
|
|
248
|
+
let n = this.getLocation();
|
|
249
|
+
return this.isAtEnd() ? (this.transitionTo({ kind: t.EOF }), this.getOrCreateEOFToken(n)) : this.startsWith("<!--") ? (this.consumePattern("<!--"), this.transitionTo({ kind: t.Comment }), this.readCommentToken(n)) : this.startsWith("</") ? (this.consumePattern("</"), this.transitionTo({ kind: t.EndTagOpen }), this.createToken(e.TagOpenSlash, "</", n)) : this.peek() === "<" ? (this.advance(), this.transitionTo({ kind: t.TagOpen }), this.createToken(e.TagOpen, "<", n)) : this.peek() === "{" ? (this.advance(), this.transitionTo({
|
|
250
|
+
kind: t.Interpolation,
|
|
251
|
+
context: "content",
|
|
252
|
+
tagName: null
|
|
253
|
+
}), this.readInterpolationToken(n, "content", null)) : this.peek() === "}" && this.blockDepth > 0 ? (this.advance(), this.blockDepth--, this.createToken(e.BlockClose, "}", n)) : this.peek() === "@" ? this.readDirectiveToken(n) : this.readTextToken();
|
|
254
|
+
}
|
|
255
|
+
readDirectiveToken(t) {
|
|
256
|
+
this.advance();
|
|
257
|
+
let n = "";
|
|
258
|
+
for (; !this.isAtEnd() && /[a-zA-Z]/.test(this.peek());) n += this.advance();
|
|
259
|
+
if (!c.has(n)) throw new r(`Unknown directive '@${n}'`, t.line, t.column, t.offset);
|
|
260
|
+
if (n === "if") return this.readDirectiveHeader(t, e.DirectiveIf);
|
|
261
|
+
if (n === "else") {
|
|
262
|
+
if (this.skipWhitespace(), this.startsWith("if") && !/[a-zA-Z0-9_]/.test(this.peek(2))) return this.consumePattern("if"), this.readDirectiveHeader(t, e.DirectiveElseIf);
|
|
263
|
+
if (this.skipWhitespace(), this.peek() === "{") return this.advance(), this.blockDepth++, this.createToken(e.DirectiveElse, "", t);
|
|
264
|
+
throw new r("Expected '{' after @else directive", t.line, t.column, t.offset);
|
|
265
|
+
} else if (n === "for") return this.readDirectiveHeader(t, e.DirectiveFor);
|
|
266
|
+
else if (n === "switch") return this.readDirectiveHeader(t, e.DirectiveSwitch);
|
|
267
|
+
else if (n === "case") return this.readDirectiveHeader(t, e.DirectiveCase);
|
|
268
|
+
else return this.skipWhitespace(), this.peek() === "{" && (this.advance(), this.blockDepth++), this.createToken(e.DirectiveDefault, "", t);
|
|
269
|
+
}
|
|
270
|
+
readDirectiveHeader(e, t) {
|
|
271
|
+
this.skipWhitespace();
|
|
272
|
+
let n = "", i = 0, a = null, o = !1, s = !1, c = !1, l = !1, u = !1;
|
|
273
|
+
for (; !this.isAtEnd();) {
|
|
274
|
+
let r = this.advance();
|
|
275
|
+
if (s) {
|
|
276
|
+
n += r, r === "\n" && (s = !1);
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
if (c) {
|
|
280
|
+
n += r, r === "/" && n.endsWith("*/") && (c = !1);
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
if (l) {
|
|
284
|
+
n += r, o ? o = !1 : r === "\\" ? o = !0 : r === "[" ? u = !0 : r === "]" && u ? u = !1 : r === "/" && !u && (l = !1);
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
if (a !== null) {
|
|
288
|
+
n += r, o ? o = !1 : r === "\\" ? o = !0 : r === a && (a = null);
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
if (r === "/" && !o) {
|
|
292
|
+
let e = this.peek();
|
|
293
|
+
if (e === "/") {
|
|
294
|
+
s = !0, n += r;
|
|
295
|
+
continue;
|
|
296
|
+
} else if (e === "*") {
|
|
297
|
+
c = !0, n += r;
|
|
298
|
+
continue;
|
|
299
|
+
} else if (this.isRegexStart(n)) {
|
|
300
|
+
l = !0, u = !1, n += r;
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if (r === "\"" || r === "'" || r === "`") {
|
|
305
|
+
a = r, n += r;
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
if (r === "(") {
|
|
309
|
+
i++, n += r;
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
if (r === ")") {
|
|
313
|
+
i > 0 && i--, n += r;
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
if (r === "{" && i === 0) return this.blockDepth++, this.createToken(t, n.trim(), e);
|
|
317
|
+
n += r;
|
|
318
|
+
}
|
|
319
|
+
throw new r("Unterminated directive header, expected '{'", e.line, e.column, e.offset);
|
|
320
|
+
}
|
|
321
|
+
readTagNameToken(n) {
|
|
322
|
+
if (this.isAtEnd()) throw this.createUnexpectedEOFError(n ? "after closing tag opener" : "after opening tag opener");
|
|
323
|
+
let i = this.getLocation(), a = this.peek();
|
|
324
|
+
if (!this.isIdentifierStart(a)) throw new r(`Expected tag name but found '${a || "EOF"}'`, i.line, i.column, i.offset);
|
|
325
|
+
let o = this.readIdentifierValue(), c = !n && s(o);
|
|
326
|
+
return this.transitionTo({
|
|
327
|
+
kind: t.BeforeAttributeName,
|
|
328
|
+
tagName: o,
|
|
329
|
+
isClosingTag: n,
|
|
330
|
+
entersRawText: c
|
|
331
|
+
}), this.createToken(e.Identifier, o, i);
|
|
332
|
+
}
|
|
333
|
+
readBeforeAttributeNameToken() {
|
|
334
|
+
let n = this.state;
|
|
335
|
+
if (n.kind !== t.BeforeAttributeName) throw Error(`Expected BeforeAttributeName state but found '${n.kind}'.`);
|
|
336
|
+
if (this.skipWhitespace(), this.isAtEnd()) throw this.createUnexpectedEOFError(`inside tag <${n.tagName}>`);
|
|
337
|
+
let i = this.getLocation();
|
|
338
|
+
if (n.isClosingTag) {
|
|
339
|
+
if (this.peek() !== ">") throw new r(`Unexpected character '${this.peek()}' inside closing tag </${n.tagName}>`, i.line, i.column, i.offset);
|
|
340
|
+
return this.advance(), this.transitionTo({ kind: t.Data }), this.createToken(e.TagClose, ">", i);
|
|
341
|
+
}
|
|
342
|
+
if (this.peek() === ">") return this.advance(), n.entersRawText && s(n.tagName) ? this.transitionTo({
|
|
343
|
+
kind: t.RawText,
|
|
344
|
+
tagName: n.tagName
|
|
345
|
+
}) : this.transitionTo({ kind: t.Data }), this.createToken(e.TagClose, ">", i);
|
|
346
|
+
if (this.peek() === "/" && this.peek(1) === ">") return this.advance(), this.advance(), this.transitionTo({ kind: t.Data }), this.createToken(e.TagSelfClose, "/>", i);
|
|
347
|
+
if (!this.isIdentifierStart(this.peek())) throw new r(`Unexpected character '${this.peek()}' inside tag <${n.tagName}>`, i.line, i.column, i.offset);
|
|
348
|
+
return this.transitionTo({
|
|
349
|
+
kind: t.AttributeName,
|
|
350
|
+
tagName: n.tagName,
|
|
351
|
+
attributeName: null
|
|
352
|
+
}), this.readAttributeNameToken();
|
|
353
|
+
}
|
|
354
|
+
readAttributeNameToken() {
|
|
355
|
+
let n = this.state;
|
|
356
|
+
if (n.kind !== t.AttributeName) throw Error(`Expected AttributeName state but found '${n.kind}'.`);
|
|
357
|
+
let i = this.getLocation();
|
|
358
|
+
if (!this.isIdentifierStart(this.peek())) throw new r(`Expected attribute name but found '${this.peek() || "EOF"}'`, i.line, i.column, i.offset);
|
|
359
|
+
let a = this.readIdentifierValue(), o = n.tagName;
|
|
360
|
+
return this.transitionTo({
|
|
361
|
+
kind: t.AfterAttributeName,
|
|
362
|
+
tagName: o,
|
|
363
|
+
attributeName: a
|
|
364
|
+
}), this.createToken(e.Identifier, a, i);
|
|
365
|
+
}
|
|
366
|
+
readAfterAttributeNameToken() {
|
|
367
|
+
let n = this.state;
|
|
368
|
+
if (n.kind !== t.AfterAttributeName) throw Error(`Expected AfterAttributeName state but found '${n.kind}'.`);
|
|
369
|
+
let r = n.tagName, i = n.attributeName;
|
|
370
|
+
if (this.skipWhitespace(), this.isAtEnd()) throw this.createUnexpectedEOFError(`after attribute '${i}' in <${r}>`);
|
|
371
|
+
if (this.peek() === "=") {
|
|
372
|
+
let n = this.getLocation();
|
|
373
|
+
return this.advance(), this.transitionTo({
|
|
374
|
+
kind: t.BeforeAttributeValue,
|
|
375
|
+
tagName: r,
|
|
376
|
+
attributeName: i
|
|
377
|
+
}), this.createToken(e.Equals, "=", n);
|
|
378
|
+
}
|
|
379
|
+
return this.transitionTo({
|
|
380
|
+
kind: t.BeforeAttributeName,
|
|
381
|
+
tagName: r,
|
|
382
|
+
isClosingTag: !1,
|
|
383
|
+
entersRawText: s(r)
|
|
384
|
+
}), this.readBeforeAttributeNameToken();
|
|
385
|
+
}
|
|
386
|
+
readBeforeAttributeValueToken() {
|
|
387
|
+
let e = this.state;
|
|
388
|
+
if (e.kind !== t.BeforeAttributeValue) throw Error(`Expected BeforeAttributeValue state but found '${e.kind}'.`);
|
|
389
|
+
let n = e.tagName, i = e.attributeName;
|
|
390
|
+
if (this.skipWhitespace(), this.isAtEnd()) throw this.createUnexpectedEOFError(`before value for attribute '${i}' in <${n}>`);
|
|
391
|
+
let a = this.getLocation(), o = this.peek();
|
|
392
|
+
if (o === "\"" || o === "'") return this.advance(), this.transitionTo({
|
|
393
|
+
kind: t.AttributeValueQuoted,
|
|
394
|
+
tagName: n,
|
|
395
|
+
attributeName: i,
|
|
396
|
+
quote: o
|
|
397
|
+
}), this.readQuotedStringToken(a, o, n);
|
|
398
|
+
if (o === "{") return this.advance(), this.transitionTo({
|
|
399
|
+
kind: t.AttributeValueInterpolation,
|
|
400
|
+
tagName: n,
|
|
401
|
+
attributeName: i
|
|
402
|
+
}), this.readInterpolationToken(a, "attribute", n);
|
|
403
|
+
throw new r(`Expected quoted string or interpolation for attribute '${i}' in <${n}>`, a.line, a.column, a.offset);
|
|
404
|
+
}
|
|
405
|
+
readCommentToken(n) {
|
|
406
|
+
let i = "";
|
|
407
|
+
for (; !this.isAtEnd();) {
|
|
408
|
+
if (this.startsWith("-->")) return this.consumePattern("-->"), this.transitionTo({ kind: t.Data }), this.createToken(e.Comment, i, n);
|
|
409
|
+
i += this.advance();
|
|
410
|
+
}
|
|
411
|
+
throw new r("Unterminated XML comment", n.line, n.column, n.offset);
|
|
412
|
+
}
|
|
413
|
+
isRegexStart(e) {
|
|
414
|
+
let t = e.trimEnd();
|
|
415
|
+
if (t.length === 0) return !0;
|
|
416
|
+
let n = t[t.length - 1];
|
|
417
|
+
if ("=(,:;!&|?[{}+-*%<>~^".includes(n)) return !0;
|
|
418
|
+
let r = t.split(/\s+/).pop();
|
|
419
|
+
return !!(r && [
|
|
420
|
+
"return",
|
|
421
|
+
"yield",
|
|
422
|
+
"await",
|
|
423
|
+
"case",
|
|
424
|
+
"typeof",
|
|
425
|
+
"void",
|
|
426
|
+
"delete",
|
|
427
|
+
"instanceof",
|
|
428
|
+
"in",
|
|
429
|
+
"do"
|
|
430
|
+
].includes(r));
|
|
431
|
+
}
|
|
432
|
+
readInterpolationToken(n, i, a) {
|
|
433
|
+
let o = 1, c = null, l = !1, u = !1, d = !1, f = !1, p = !1, m = [], h = "";
|
|
434
|
+
for (; !this.isAtEnd();) {
|
|
435
|
+
let r = this.advance();
|
|
436
|
+
if (u) {
|
|
437
|
+
h += r, r === "\n" && (u = !1);
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
if (d) {
|
|
441
|
+
h += r, r === "/" && h.endsWith("*/") && (d = !1);
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
if (f) {
|
|
445
|
+
h += r, l ? l = !1 : r === "\\" ? l = !0 : r === "[" ? p = !0 : r === "]" && p ? p = !1 : r === "/" && !p && (f = !1);
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
if (c !== null) {
|
|
449
|
+
h += r, l ? l = !1 : r === "\\" ? l = !0 : r === c ? c = null : c === "`" && r === "{" && h.endsWith("${") && (m.push(o), c = null, o++);
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
if (r === "/" && !l) {
|
|
453
|
+
let e = this.peek();
|
|
454
|
+
if (e === "/") {
|
|
455
|
+
u = !0, h += r;
|
|
456
|
+
continue;
|
|
457
|
+
} else if (e === "*") {
|
|
458
|
+
d = !0, h += r;
|
|
459
|
+
continue;
|
|
460
|
+
} else if (this.isRegexStart(h)) {
|
|
461
|
+
f = !0, p = !1, h += r;
|
|
462
|
+
continue;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
if (r === "\"" || r === "'" || r === "`") {
|
|
466
|
+
c = r, h += r;
|
|
467
|
+
continue;
|
|
468
|
+
}
|
|
469
|
+
if (r === "{") {
|
|
470
|
+
o++, h += r;
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
if (r === "}") {
|
|
474
|
+
if (o--, m.length > 0 && o === m[m.length - 1] && (m.pop(), c = "`"), o === 0) return i === "attribute" && a !== null ? this.transitionTo({
|
|
475
|
+
kind: t.BeforeAttributeName,
|
|
476
|
+
tagName: a,
|
|
477
|
+
isClosingTag: !1,
|
|
478
|
+
entersRawText: s(a)
|
|
479
|
+
}) : this.transitionTo({ kind: t.Data }), this.createToken(e.Interpolation, h, n);
|
|
480
|
+
h += r;
|
|
481
|
+
continue;
|
|
482
|
+
}
|
|
483
|
+
h += r;
|
|
484
|
+
}
|
|
485
|
+
throw new r("Unterminated interpolation expression, expected closing brace '}'", n.line, n.column, n.offset);
|
|
486
|
+
}
|
|
487
|
+
readRawTextToken() {
|
|
488
|
+
let n = this.state;
|
|
489
|
+
if (n.kind !== t.RawText) throw Error(`Expected RawText state but found '${n.kind}'.`);
|
|
490
|
+
let r = this.getLocation(), i = `</${n.tagName}`;
|
|
491
|
+
if (this.isAtEnd()) return this.transitionTo({ kind: t.EOF }), this.getOrCreateEOFToken(r);
|
|
492
|
+
if (this.isRawTextClosingTagAhead(i)) return this.consumePattern("</"), this.transitionTo({ kind: t.EndTagOpen }), this.createToken(e.TagOpenSlash, "</", r);
|
|
493
|
+
let a = "";
|
|
494
|
+
for (; !this.isAtEnd() && !this.isRawTextClosingTagAhead(i);) a += this.advance();
|
|
495
|
+
return a.length > 0 ? this.createToken(e.Text, a, r) : (this.transitionTo({ kind: t.EOF }), this.getOrCreateEOFToken(r));
|
|
496
|
+
}
|
|
497
|
+
readTextToken() {
|
|
498
|
+
let t = this.getLocation(), n = "";
|
|
499
|
+
for (; !this.isAtEnd();) {
|
|
500
|
+
let e = this.peek();
|
|
501
|
+
if (e === "<" || e === "{" || e === "@" || e === "}" && this.blockDepth > 0) break;
|
|
502
|
+
n += this.advance();
|
|
503
|
+
}
|
|
504
|
+
return this.createToken(e.Text, n, t);
|
|
505
|
+
}
|
|
506
|
+
readQuotedStringToken(n, i, a) {
|
|
507
|
+
let o = "";
|
|
508
|
+
for (; !this.isAtEnd();) {
|
|
509
|
+
if (this.peek() === i) return this.advance(), this.transitionTo({
|
|
510
|
+
kind: t.BeforeAttributeName,
|
|
511
|
+
tagName: a,
|
|
512
|
+
isClosingTag: !1,
|
|
513
|
+
entersRawText: s(a)
|
|
514
|
+
}), this.createToken(e.StringLiteral, o, n);
|
|
515
|
+
o += this.advance();
|
|
516
|
+
}
|
|
517
|
+
throw new r(`Unterminated string literal, expected closing quote ${i}`, n.line, n.column, n.offset);
|
|
518
|
+
}
|
|
519
|
+
readIdentifierValue() {
|
|
520
|
+
let e = "";
|
|
521
|
+
for (; !this.isAtEnd() && this.isIdentifierChar(this.peek());) e += this.advance();
|
|
522
|
+
return e;
|
|
523
|
+
}
|
|
524
|
+
getOrCreateEOFToken(t = this.getLocation()) {
|
|
525
|
+
return this.eofToken === null && (this.eofToken = {
|
|
526
|
+
type: e.EOF,
|
|
527
|
+
value: "",
|
|
528
|
+
loc: {
|
|
529
|
+
start: t,
|
|
530
|
+
end: t
|
|
531
|
+
}
|
|
532
|
+
}), this.eofToken;
|
|
533
|
+
}
|
|
534
|
+
createToken(e, t, n) {
|
|
535
|
+
return {
|
|
536
|
+
type: e,
|
|
537
|
+
value: t,
|
|
538
|
+
loc: {
|
|
539
|
+
start: n,
|
|
540
|
+
end: this.getLocation()
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
createUnexpectedEOFError(e) {
|
|
545
|
+
let t = this.getLocation();
|
|
546
|
+
return new r(`Unexpected end of input ${e}`, t.line, t.column, t.offset);
|
|
547
|
+
}
|
|
548
|
+
transitionTo(e) {
|
|
549
|
+
if (!o[this.state.kind].some((t) => t.to === e.kind)) throw Error(`Invalid lexer transition from '${this.state.kind}' to '${e.kind}'.`);
|
|
550
|
+
this.state = e;
|
|
551
|
+
}
|
|
552
|
+
getLocation() {
|
|
553
|
+
return {
|
|
554
|
+
line: this.line,
|
|
555
|
+
column: this.column,
|
|
556
|
+
offset: this.offset
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
isAtEnd() {
|
|
560
|
+
return this.offset >= this.source.length;
|
|
561
|
+
}
|
|
562
|
+
peek(e = 0) {
|
|
563
|
+
let t = this.offset + e;
|
|
564
|
+
return t >= this.source.length ? "" : this.source[t] ?? "";
|
|
565
|
+
}
|
|
566
|
+
advance() {
|
|
567
|
+
let e = this.source[this.offset] ?? "";
|
|
568
|
+
return this.offset++, e === "\n" ? (this.line++, this.column = 1) : this.column++, e;
|
|
569
|
+
}
|
|
570
|
+
startsWith(e) {
|
|
571
|
+
return this.source.startsWith(e, this.offset);
|
|
572
|
+
}
|
|
573
|
+
consumePattern(e) {
|
|
574
|
+
for (let t = 0; t < e.length; t++) this.advance();
|
|
575
|
+
}
|
|
576
|
+
skipWhitespace() {
|
|
577
|
+
for (; !this.isAtEnd();) {
|
|
578
|
+
let e = this.peek();
|
|
579
|
+
if (e === " " || e === " " || e === "\r" || e === "\n") this.advance();
|
|
580
|
+
else break;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
isIdentifierStart(e) {
|
|
584
|
+
if (e.length === 0) return !1;
|
|
585
|
+
let t = e.charCodeAt(0);
|
|
586
|
+
return t >= 65 && t <= 90 || t >= 97 && t <= 122;
|
|
587
|
+
}
|
|
588
|
+
isIdentifierChar(e) {
|
|
589
|
+
if (e.length === 0) return !1;
|
|
590
|
+
let t = e.charCodeAt(0);
|
|
591
|
+
return t >= 65 && t <= 90 || t >= 97 && t <= 122 || t >= 48 && t <= 57 || t === 95 || t === 45;
|
|
592
|
+
}
|
|
593
|
+
isRawTextClosingTagAhead(e) {
|
|
594
|
+
if (!this.startsWith(e)) return !1;
|
|
595
|
+
let t = this.peek(e.length);
|
|
596
|
+
return t === "" || t === ">" || t === " " || t === " " || t === "\r" || t === "\n";
|
|
597
|
+
}
|
|
598
|
+
}, u = /* @__PURE__ */ new Set([
|
|
599
|
+
"area",
|
|
600
|
+
"base",
|
|
601
|
+
"br",
|
|
602
|
+
"col",
|
|
603
|
+
"embed",
|
|
604
|
+
"hr",
|
|
605
|
+
"img",
|
|
606
|
+
"input",
|
|
607
|
+
"link",
|
|
608
|
+
"meta",
|
|
609
|
+
"param",
|
|
610
|
+
"source",
|
|
611
|
+
"track",
|
|
612
|
+
"wbr"
|
|
613
|
+
]), d = class {
|
|
614
|
+
tokens;
|
|
615
|
+
current = 0;
|
|
616
|
+
constructor(e) {
|
|
617
|
+
this.tokens = e;
|
|
618
|
+
}
|
|
619
|
+
nextToken() {
|
|
620
|
+
if (this.current >= this.tokens.length) return this.tokens[this.tokens.length - 1];
|
|
621
|
+
let e = this.tokens[this.current];
|
|
622
|
+
return this.current++, e;
|
|
623
|
+
}
|
|
624
|
+
}, f = class {
|
|
625
|
+
tokenSource;
|
|
626
|
+
lookahead = [];
|
|
627
|
+
constructor(e) {
|
|
628
|
+
this.tokenSource = Array.isArray(e) ? new d(e) : e;
|
|
629
|
+
}
|
|
630
|
+
parse() {
|
|
631
|
+
return this.lookahead.length = 0, this.parseProgram();
|
|
632
|
+
}
|
|
633
|
+
parseProgram() {
|
|
634
|
+
let e = this.peek().loc.start, t = [];
|
|
635
|
+
for (; !this.isAtEnd();) t.push(this.parseChild());
|
|
636
|
+
let r = this.peek().loc.end;
|
|
637
|
+
return {
|
|
638
|
+
type: n.Program,
|
|
639
|
+
body: t,
|
|
640
|
+
loc: {
|
|
641
|
+
start: e,
|
|
642
|
+
end: r
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
parseChild() {
|
|
647
|
+
let t = this.peek();
|
|
648
|
+
if (t.type === e.Comment) return this.advance(), {
|
|
649
|
+
type: n.Comment,
|
|
650
|
+
content: t.value,
|
|
651
|
+
loc: t.loc
|
|
652
|
+
};
|
|
653
|
+
if (t.type === e.Interpolation) return this.advance(), {
|
|
654
|
+
type: n.Interpolation,
|
|
655
|
+
expression: t.value,
|
|
656
|
+
loc: t.loc
|
|
657
|
+
};
|
|
658
|
+
if (t.type === e.TagOpen) return this.parseElement();
|
|
659
|
+
if (t.type === e.DirectiveIf) return this.parseIfDirective();
|
|
660
|
+
if (t.type === e.DirectiveFor) return this.parseForDirective();
|
|
661
|
+
if (t.type === e.DirectiveSwitch) return this.parseSwitchDirective();
|
|
662
|
+
if (t.type === e.Text) return this.advance(), {
|
|
663
|
+
type: n.Text,
|
|
664
|
+
content: t.value,
|
|
665
|
+
loc: t.loc
|
|
666
|
+
};
|
|
667
|
+
throw t.type === e.TagOpenSlash ? new i(`Unexpected closing tag '</${this.peek(1).value}>' without opening tag`, t.loc.start.line, t.loc.start.column, t.loc.start.offset) : new i(`Unexpected token '${t.value}' of type '${t.type}'`, t.loc.start.line, t.loc.start.column, t.loc.start.offset);
|
|
668
|
+
}
|
|
669
|
+
parseElement() {
|
|
670
|
+
let t = this.consume(e.TagOpen, "Expected opening tag bracket").loc.start, r = this.consume(e.Identifier, "Expected tag name after opening bracket").value, a = [];
|
|
671
|
+
for (; !this.check(e.TagClose) && !this.check(e.TagSelfClose) && !this.isAtEnd();) a.push(this.parseAttribute());
|
|
672
|
+
if (this.check(e.TagSelfClose)) {
|
|
673
|
+
let e = this.advance();
|
|
674
|
+
return {
|
|
675
|
+
type: n.Element,
|
|
676
|
+
tagName: r,
|
|
677
|
+
attributes: a,
|
|
678
|
+
children: [],
|
|
679
|
+
isSelfClosing: !0,
|
|
680
|
+
loc: {
|
|
681
|
+
start: t,
|
|
682
|
+
end: e.loc.end
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
let o = this.consume(e.TagClose, "Expected closing bracket after attributes");
|
|
687
|
+
if (u.has(r.toLowerCase())) return {
|
|
688
|
+
type: n.Element,
|
|
689
|
+
tagName: r,
|
|
690
|
+
attributes: a,
|
|
691
|
+
children: [],
|
|
692
|
+
isSelfClosing: !0,
|
|
693
|
+
loc: {
|
|
694
|
+
start: t,
|
|
695
|
+
end: o.loc.end
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
let s = [];
|
|
699
|
+
for (; !this.check(e.TagOpenSlash) && !this.isAtEnd();) s.push(this.parseChild());
|
|
700
|
+
if (this.isAtEnd()) throw new i(`Unclosed element '<${r}>', expected closing tag '</${r}>'`, t.line, t.column, t.offset);
|
|
701
|
+
this.consume(e.TagOpenSlash, `Expected closing tag '</${r}>'`);
|
|
702
|
+
let c = this.consume(e.Identifier, "Expected closing tag name");
|
|
703
|
+
if (c.value !== r) throw new i(`Mismatched closing tag. Expected '</${r}>' but got '</${c.value}>'`, c.loc.start.line, c.loc.start.column, c.loc.start.offset);
|
|
704
|
+
let l = this.consume(e.TagClose, "Expected '>' after closing tag name");
|
|
705
|
+
return {
|
|
706
|
+
type: n.Element,
|
|
707
|
+
tagName: r,
|
|
708
|
+
attributes: a,
|
|
709
|
+
children: s,
|
|
710
|
+
isSelfClosing: !1,
|
|
711
|
+
loc: {
|
|
712
|
+
start: t,
|
|
713
|
+
end: l.loc.end
|
|
714
|
+
}
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
parseAttribute() {
|
|
718
|
+
let t = this.consume(e.Identifier, "Expected attribute name"), r = t.loc.start, a = t.value;
|
|
719
|
+
if (this.matchToken(e.Equals)) {
|
|
720
|
+
let t = this.peek();
|
|
721
|
+
if (t.type === e.StringLiteral) return this.advance(), {
|
|
722
|
+
type: n.Attribute,
|
|
723
|
+
name: a,
|
|
724
|
+
value: t.value,
|
|
725
|
+
loc: {
|
|
726
|
+
start: r,
|
|
727
|
+
end: t.loc.end
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
if (t.type === e.Interpolation) {
|
|
731
|
+
this.advance();
|
|
732
|
+
let e = {
|
|
733
|
+
type: n.Interpolation,
|
|
734
|
+
expression: t.value,
|
|
735
|
+
loc: t.loc
|
|
736
|
+
};
|
|
737
|
+
return {
|
|
738
|
+
type: n.Attribute,
|
|
739
|
+
name: a,
|
|
740
|
+
value: e,
|
|
741
|
+
loc: {
|
|
742
|
+
start: r,
|
|
743
|
+
end: t.loc.end
|
|
744
|
+
}
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
throw new i(`Expected string literal or interpolation after '=' for attribute '${a}'`, t.loc.start.line, t.loc.start.column, t.loc.start.offset);
|
|
748
|
+
}
|
|
749
|
+
return {
|
|
750
|
+
type: n.Attribute,
|
|
751
|
+
name: a,
|
|
752
|
+
value: null,
|
|
753
|
+
loc: {
|
|
754
|
+
start: r,
|
|
755
|
+
end: t.loc.end
|
|
756
|
+
}
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
parseIfDirective() {
|
|
760
|
+
let t = this.consume(e.DirectiveIf, "Expected @if directive"), r = t.loc.start, i = t.value, a = [];
|
|
761
|
+
for (; !this.check(e.BlockClose) && !this.isAtEnd();) a.push(this.parseChild());
|
|
762
|
+
let o = this.consume(e.BlockClose, "Expected closing brace } for @if block"), s = null, c = o.loc.end;
|
|
763
|
+
if (this.skipWhitespaceTokens(), this.check(e.DirectiveElseIf)) s = this.parseElseIfChain(), c = s.loc.end;
|
|
764
|
+
else if (this.check(e.DirectiveElse)) {
|
|
765
|
+
this.advance();
|
|
766
|
+
let t = [];
|
|
767
|
+
for (; !this.check(e.BlockClose) && !this.isAtEnd();) t.push(this.parseChild());
|
|
768
|
+
let n = this.consume(e.BlockClose, "Expected closing brace } for @else block");
|
|
769
|
+
s = t, c = n.loc.end;
|
|
770
|
+
}
|
|
771
|
+
return {
|
|
772
|
+
type: n.If,
|
|
773
|
+
test: i,
|
|
774
|
+
consequent: a,
|
|
775
|
+
alternate: s,
|
|
776
|
+
loc: {
|
|
777
|
+
start: r,
|
|
778
|
+
end: c
|
|
779
|
+
}
|
|
780
|
+
};
|
|
781
|
+
}
|
|
782
|
+
parseElseIfChain() {
|
|
783
|
+
let t = this.consume(e.DirectiveElseIf, "Expected @else if directive"), r = t.loc.start, i = t.value, a = [];
|
|
784
|
+
for (; !this.check(e.BlockClose) && !this.isAtEnd();) a.push(this.parseChild());
|
|
785
|
+
let o = this.consume(e.BlockClose, "Expected closing brace } for @else if block"), s = null, c = o.loc.end;
|
|
786
|
+
if (this.skipWhitespaceTokens(), this.check(e.DirectiveElseIf)) s = this.parseElseIfChain(), c = s.loc.end;
|
|
787
|
+
else if (this.check(e.DirectiveElse)) {
|
|
788
|
+
this.advance();
|
|
789
|
+
let t = [];
|
|
790
|
+
for (; !this.check(e.BlockClose) && !this.isAtEnd();) t.push(this.parseChild());
|
|
791
|
+
let n = this.consume(e.BlockClose, "Expected closing brace } for @else block");
|
|
792
|
+
s = t, c = n.loc.end;
|
|
793
|
+
}
|
|
794
|
+
return {
|
|
795
|
+
type: n.If,
|
|
796
|
+
test: i,
|
|
797
|
+
consequent: a,
|
|
798
|
+
alternate: s,
|
|
799
|
+
loc: {
|
|
800
|
+
start: r,
|
|
801
|
+
end: c
|
|
802
|
+
}
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
parseForDirective() {
|
|
806
|
+
let t = this.consume(e.DirectiveFor, "Expected @for directive"), r = t.loc.start, a = t.value, o = (() => {
|
|
807
|
+
let e = 0;
|
|
808
|
+
for (let t = 0; t <= a.length - 4; t++) {
|
|
809
|
+
let n = a[t];
|
|
810
|
+
if (n === "(") e++;
|
|
811
|
+
else if (n === ")") e--;
|
|
812
|
+
else if (e === 0 && a.slice(t, t + 4) === " in ") return t;
|
|
813
|
+
}
|
|
814
|
+
return -1;
|
|
815
|
+
})();
|
|
816
|
+
if (o === -1) throw new i(`Invalid @for header syntax '${a}'. Expected format: 'item in list' or '(item, index) in list'`, t.loc.start.line, t.loc.start.column, t.loc.start.offset);
|
|
817
|
+
let s = a.slice(0, o).trim(), c = a.slice(o + 4).trim(), l = null, u = c.match(/\s+key\s+(.+)$/);
|
|
818
|
+
u && (l = u[1].trim(), c = c.slice(0, u.index).trim());
|
|
819
|
+
let d = c, f = s, p = null;
|
|
820
|
+
if (s.startsWith("(") && s.endsWith(")")) {
|
|
821
|
+
let e = s.slice(1, -1).split(",").map((e) => e.trim());
|
|
822
|
+
f = e[0] || "", p = e[1] || null;
|
|
823
|
+
}
|
|
824
|
+
let m = [];
|
|
825
|
+
for (; !this.check(e.BlockClose) && !this.isAtEnd();) m.push(this.parseChild());
|
|
826
|
+
let h = this.consume(e.BlockClose, "Expected closing brace } for @for block");
|
|
827
|
+
return {
|
|
828
|
+
type: n.For,
|
|
829
|
+
item: f,
|
|
830
|
+
index: p,
|
|
831
|
+
iterable: d,
|
|
832
|
+
key: l,
|
|
833
|
+
body: m,
|
|
834
|
+
loc: {
|
|
835
|
+
start: r,
|
|
836
|
+
end: h.loc.end
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
parseSwitchDirective() {
|
|
841
|
+
let t = this.consume(e.DirectiveSwitch, "Expected @switch directive"), r = t.loc.start, a = t.value, o = [];
|
|
842
|
+
for (this.skipWhitespaceTokens(); !this.check(e.BlockClose) && !this.isAtEnd();) {
|
|
843
|
+
if (this.check(e.DirectiveCase)) {
|
|
844
|
+
let t = this.advance(), n = [];
|
|
845
|
+
for (; !this.check(e.BlockClose) && !this.isAtEnd();) n.push(this.parseChild());
|
|
846
|
+
let r = this.consume(e.BlockClose, "Expected closing brace } for @case block");
|
|
847
|
+
o.push({
|
|
848
|
+
expression: t.value,
|
|
849
|
+
body: n,
|
|
850
|
+
loc: {
|
|
851
|
+
start: t.loc.start,
|
|
852
|
+
end: r.loc.end
|
|
853
|
+
}
|
|
854
|
+
});
|
|
855
|
+
} else if (this.check(e.DirectiveDefault)) {
|
|
856
|
+
let t = this.advance(), n = [];
|
|
857
|
+
for (; !this.check(e.BlockClose) && !this.isAtEnd();) n.push(this.parseChild());
|
|
858
|
+
let r = this.consume(e.BlockClose, "Expected closing brace } for @default block");
|
|
859
|
+
o.push({
|
|
860
|
+
expression: null,
|
|
861
|
+
body: n,
|
|
862
|
+
loc: {
|
|
863
|
+
start: t.loc.start,
|
|
864
|
+
end: r.loc.end
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
} else throw new i(`Unexpected token '${this.peek().value}' inside @switch block. Expected @case or @default.`, this.peek().loc.start.line, this.peek().loc.start.column, this.peek().loc.start.offset);
|
|
868
|
+
this.skipWhitespaceTokens();
|
|
869
|
+
}
|
|
870
|
+
let s = this.consume(e.BlockClose, "Expected closing brace } for @switch block");
|
|
871
|
+
return {
|
|
872
|
+
type: n.Switch,
|
|
873
|
+
discriminant: a,
|
|
874
|
+
cases: o,
|
|
875
|
+
loc: {
|
|
876
|
+
start: r,
|
|
877
|
+
end: s.loc.end
|
|
878
|
+
}
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
skipWhitespaceTokens() {
|
|
882
|
+
for (; this.check(e.Text) && this.peek().value.trim().length === 0;) this.advance();
|
|
883
|
+
}
|
|
884
|
+
isAtEnd() {
|
|
885
|
+
return this.peek().type === e.EOF;
|
|
886
|
+
}
|
|
887
|
+
peek(e = 0) {
|
|
888
|
+
return this.ensureLookahead(e), this.lookahead[Math.min(e, this.lookahead.length - 1)];
|
|
889
|
+
}
|
|
890
|
+
advance() {
|
|
891
|
+
let t = this.peek();
|
|
892
|
+
return t.type !== e.EOF && this.lookahead.shift(), t;
|
|
893
|
+
}
|
|
894
|
+
check(e) {
|
|
895
|
+
return this.peek().type === e;
|
|
896
|
+
}
|
|
897
|
+
matchToken(e) {
|
|
898
|
+
return this.check(e) ? (this.advance(), !0) : !1;
|
|
899
|
+
}
|
|
900
|
+
consume(e, t) {
|
|
901
|
+
if (this.check(e)) return this.advance();
|
|
902
|
+
let n = this.peek();
|
|
903
|
+
throw new i(t, n.loc.start.line, n.loc.start.column, n.loc.start.offset);
|
|
904
|
+
}
|
|
905
|
+
ensureLookahead(t) {
|
|
906
|
+
for (; this.lookahead.length <= t;) {
|
|
907
|
+
let t = this.tokenSource.nextToken();
|
|
908
|
+
if (this.lookahead.push(t), t.type === e.EOF) break;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
}, p = [
|
|
912
|
+
509,
|
|
913
|
+
0,
|
|
914
|
+
227,
|
|
915
|
+
0,
|
|
916
|
+
150,
|
|
917
|
+
4,
|
|
918
|
+
294,
|
|
919
|
+
9,
|
|
920
|
+
1368,
|
|
921
|
+
2,
|
|
922
|
+
2,
|
|
923
|
+
1,
|
|
924
|
+
6,
|
|
925
|
+
3,
|
|
926
|
+
41,
|
|
927
|
+
2,
|
|
928
|
+
5,
|
|
929
|
+
0,
|
|
930
|
+
166,
|
|
931
|
+
1,
|
|
932
|
+
574,
|
|
933
|
+
3,
|
|
934
|
+
9,
|
|
935
|
+
9,
|
|
936
|
+
7,
|
|
937
|
+
9,
|
|
938
|
+
32,
|
|
939
|
+
4,
|
|
940
|
+
318,
|
|
941
|
+
1,
|
|
942
|
+
78,
|
|
943
|
+
5,
|
|
944
|
+
71,
|
|
945
|
+
10,
|
|
946
|
+
50,
|
|
947
|
+
3,
|
|
948
|
+
123,
|
|
949
|
+
2,
|
|
950
|
+
54,
|
|
951
|
+
14,
|
|
952
|
+
32,
|
|
953
|
+
10,
|
|
954
|
+
3,
|
|
955
|
+
1,
|
|
956
|
+
11,
|
|
957
|
+
3,
|
|
958
|
+
46,
|
|
959
|
+
10,
|
|
960
|
+
8,
|
|
961
|
+
0,
|
|
962
|
+
46,
|
|
963
|
+
9,
|
|
964
|
+
7,
|
|
965
|
+
2,
|
|
966
|
+
37,
|
|
967
|
+
13,
|
|
968
|
+
2,
|
|
969
|
+
9,
|
|
970
|
+
6,
|
|
971
|
+
1,
|
|
972
|
+
45,
|
|
973
|
+
0,
|
|
974
|
+
13,
|
|
975
|
+
2,
|
|
976
|
+
49,
|
|
977
|
+
13,
|
|
978
|
+
9,
|
|
979
|
+
3,
|
|
980
|
+
2,
|
|
981
|
+
11,
|
|
982
|
+
83,
|
|
983
|
+
11,
|
|
984
|
+
7,
|
|
985
|
+
0,
|
|
986
|
+
3,
|
|
987
|
+
0,
|
|
988
|
+
158,
|
|
989
|
+
11,
|
|
990
|
+
6,
|
|
991
|
+
9,
|
|
992
|
+
7,
|
|
993
|
+
3,
|
|
994
|
+
56,
|
|
995
|
+
1,
|
|
996
|
+
2,
|
|
997
|
+
6,
|
|
998
|
+
3,
|
|
999
|
+
1,
|
|
1000
|
+
3,
|
|
1001
|
+
2,
|
|
1002
|
+
10,
|
|
1003
|
+
0,
|
|
1004
|
+
11,
|
|
1005
|
+
1,
|
|
1006
|
+
3,
|
|
1007
|
+
6,
|
|
1008
|
+
4,
|
|
1009
|
+
4,
|
|
1010
|
+
68,
|
|
1011
|
+
8,
|
|
1012
|
+
2,
|
|
1013
|
+
0,
|
|
1014
|
+
3,
|
|
1015
|
+
0,
|
|
1016
|
+
2,
|
|
1017
|
+
3,
|
|
1018
|
+
2,
|
|
1019
|
+
4,
|
|
1020
|
+
2,
|
|
1021
|
+
0,
|
|
1022
|
+
15,
|
|
1023
|
+
1,
|
|
1024
|
+
83,
|
|
1025
|
+
17,
|
|
1026
|
+
10,
|
|
1027
|
+
9,
|
|
1028
|
+
5,
|
|
1029
|
+
0,
|
|
1030
|
+
82,
|
|
1031
|
+
19,
|
|
1032
|
+
13,
|
|
1033
|
+
9,
|
|
1034
|
+
214,
|
|
1035
|
+
6,
|
|
1036
|
+
3,
|
|
1037
|
+
8,
|
|
1038
|
+
28,
|
|
1039
|
+
1,
|
|
1040
|
+
83,
|
|
1041
|
+
16,
|
|
1042
|
+
16,
|
|
1043
|
+
9,
|
|
1044
|
+
82,
|
|
1045
|
+
12,
|
|
1046
|
+
9,
|
|
1047
|
+
9,
|
|
1048
|
+
7,
|
|
1049
|
+
19,
|
|
1050
|
+
58,
|
|
1051
|
+
14,
|
|
1052
|
+
5,
|
|
1053
|
+
9,
|
|
1054
|
+
243,
|
|
1055
|
+
14,
|
|
1056
|
+
166,
|
|
1057
|
+
9,
|
|
1058
|
+
71,
|
|
1059
|
+
5,
|
|
1060
|
+
2,
|
|
1061
|
+
1,
|
|
1062
|
+
3,
|
|
1063
|
+
3,
|
|
1064
|
+
2,
|
|
1065
|
+
0,
|
|
1066
|
+
2,
|
|
1067
|
+
1,
|
|
1068
|
+
13,
|
|
1069
|
+
9,
|
|
1070
|
+
120,
|
|
1071
|
+
6,
|
|
1072
|
+
3,
|
|
1073
|
+
6,
|
|
1074
|
+
4,
|
|
1075
|
+
0,
|
|
1076
|
+
29,
|
|
1077
|
+
9,
|
|
1078
|
+
41,
|
|
1079
|
+
6,
|
|
1080
|
+
2,
|
|
1081
|
+
3,
|
|
1082
|
+
9,
|
|
1083
|
+
0,
|
|
1084
|
+
10,
|
|
1085
|
+
10,
|
|
1086
|
+
47,
|
|
1087
|
+
15,
|
|
1088
|
+
199,
|
|
1089
|
+
7,
|
|
1090
|
+
137,
|
|
1091
|
+
9,
|
|
1092
|
+
54,
|
|
1093
|
+
7,
|
|
1094
|
+
2,
|
|
1095
|
+
7,
|
|
1096
|
+
17,
|
|
1097
|
+
9,
|
|
1098
|
+
57,
|
|
1099
|
+
21,
|
|
1100
|
+
2,
|
|
1101
|
+
13,
|
|
1102
|
+
123,
|
|
1103
|
+
5,
|
|
1104
|
+
4,
|
|
1105
|
+
0,
|
|
1106
|
+
2,
|
|
1107
|
+
1,
|
|
1108
|
+
2,
|
|
1109
|
+
6,
|
|
1110
|
+
2,
|
|
1111
|
+
0,
|
|
1112
|
+
9,
|
|
1113
|
+
9,
|
|
1114
|
+
49,
|
|
1115
|
+
4,
|
|
1116
|
+
2,
|
|
1117
|
+
1,
|
|
1118
|
+
2,
|
|
1119
|
+
4,
|
|
1120
|
+
9,
|
|
1121
|
+
9,
|
|
1122
|
+
55,
|
|
1123
|
+
9,
|
|
1124
|
+
266,
|
|
1125
|
+
3,
|
|
1126
|
+
10,
|
|
1127
|
+
1,
|
|
1128
|
+
2,
|
|
1129
|
+
0,
|
|
1130
|
+
49,
|
|
1131
|
+
6,
|
|
1132
|
+
4,
|
|
1133
|
+
4,
|
|
1134
|
+
14,
|
|
1135
|
+
10,
|
|
1136
|
+
5350,
|
|
1137
|
+
0,
|
|
1138
|
+
7,
|
|
1139
|
+
14,
|
|
1140
|
+
11465,
|
|
1141
|
+
27,
|
|
1142
|
+
2343,
|
|
1143
|
+
9,
|
|
1144
|
+
87,
|
|
1145
|
+
9,
|
|
1146
|
+
39,
|
|
1147
|
+
4,
|
|
1148
|
+
60,
|
|
1149
|
+
6,
|
|
1150
|
+
26,
|
|
1151
|
+
9,
|
|
1152
|
+
535,
|
|
1153
|
+
9,
|
|
1154
|
+
470,
|
|
1155
|
+
0,
|
|
1156
|
+
2,
|
|
1157
|
+
54,
|
|
1158
|
+
8,
|
|
1159
|
+
3,
|
|
1160
|
+
82,
|
|
1161
|
+
0,
|
|
1162
|
+
12,
|
|
1163
|
+
1,
|
|
1164
|
+
19628,
|
|
1165
|
+
1,
|
|
1166
|
+
4178,
|
|
1167
|
+
9,
|
|
1168
|
+
519,
|
|
1169
|
+
45,
|
|
1170
|
+
3,
|
|
1171
|
+
22,
|
|
1172
|
+
543,
|
|
1173
|
+
4,
|
|
1174
|
+
4,
|
|
1175
|
+
5,
|
|
1176
|
+
9,
|
|
1177
|
+
7,
|
|
1178
|
+
3,
|
|
1179
|
+
6,
|
|
1180
|
+
31,
|
|
1181
|
+
3,
|
|
1182
|
+
149,
|
|
1183
|
+
2,
|
|
1184
|
+
1418,
|
|
1185
|
+
49,
|
|
1186
|
+
513,
|
|
1187
|
+
54,
|
|
1188
|
+
5,
|
|
1189
|
+
49,
|
|
1190
|
+
9,
|
|
1191
|
+
0,
|
|
1192
|
+
15,
|
|
1193
|
+
0,
|
|
1194
|
+
23,
|
|
1195
|
+
4,
|
|
1196
|
+
2,
|
|
1197
|
+
14,
|
|
1198
|
+
1361,
|
|
1199
|
+
6,
|
|
1200
|
+
2,
|
|
1201
|
+
16,
|
|
1202
|
+
3,
|
|
1203
|
+
6,
|
|
1204
|
+
2,
|
|
1205
|
+
1,
|
|
1206
|
+
2,
|
|
1207
|
+
4,
|
|
1208
|
+
101,
|
|
1209
|
+
0,
|
|
1210
|
+
161,
|
|
1211
|
+
6,
|
|
1212
|
+
10,
|
|
1213
|
+
9,
|
|
1214
|
+
357,
|
|
1215
|
+
0,
|
|
1216
|
+
62,
|
|
1217
|
+
13,
|
|
1218
|
+
499,
|
|
1219
|
+
13,
|
|
1220
|
+
245,
|
|
1221
|
+
1,
|
|
1222
|
+
2,
|
|
1223
|
+
9,
|
|
1224
|
+
233,
|
|
1225
|
+
0,
|
|
1226
|
+
3,
|
|
1227
|
+
0,
|
|
1228
|
+
8,
|
|
1229
|
+
1,
|
|
1230
|
+
6,
|
|
1231
|
+
0,
|
|
1232
|
+
475,
|
|
1233
|
+
6,
|
|
1234
|
+
110,
|
|
1235
|
+
6,
|
|
1236
|
+
6,
|
|
1237
|
+
9,
|
|
1238
|
+
4759,
|
|
1239
|
+
9,
|
|
1240
|
+
787719,
|
|
1241
|
+
239
|
|
1242
|
+
], m = [
|
|
1243
|
+
0,
|
|
1244
|
+
11,
|
|
1245
|
+
2,
|
|
1246
|
+
25,
|
|
1247
|
+
2,
|
|
1248
|
+
18,
|
|
1249
|
+
2,
|
|
1250
|
+
1,
|
|
1251
|
+
2,
|
|
1252
|
+
14,
|
|
1253
|
+
3,
|
|
1254
|
+
13,
|
|
1255
|
+
35,
|
|
1256
|
+
122,
|
|
1257
|
+
70,
|
|
1258
|
+
52,
|
|
1259
|
+
268,
|
|
1260
|
+
28,
|
|
1261
|
+
4,
|
|
1262
|
+
48,
|
|
1263
|
+
48,
|
|
1264
|
+
31,
|
|
1265
|
+
14,
|
|
1266
|
+
29,
|
|
1267
|
+
6,
|
|
1268
|
+
37,
|
|
1269
|
+
11,
|
|
1270
|
+
29,
|
|
1271
|
+
3,
|
|
1272
|
+
35,
|
|
1273
|
+
5,
|
|
1274
|
+
7,
|
|
1275
|
+
2,
|
|
1276
|
+
4,
|
|
1277
|
+
43,
|
|
1278
|
+
157,
|
|
1279
|
+
19,
|
|
1280
|
+
35,
|
|
1281
|
+
5,
|
|
1282
|
+
35,
|
|
1283
|
+
5,
|
|
1284
|
+
39,
|
|
1285
|
+
9,
|
|
1286
|
+
51,
|
|
1287
|
+
13,
|
|
1288
|
+
10,
|
|
1289
|
+
2,
|
|
1290
|
+
14,
|
|
1291
|
+
2,
|
|
1292
|
+
6,
|
|
1293
|
+
2,
|
|
1294
|
+
1,
|
|
1295
|
+
2,
|
|
1296
|
+
10,
|
|
1297
|
+
2,
|
|
1298
|
+
14,
|
|
1299
|
+
2,
|
|
1300
|
+
6,
|
|
1301
|
+
2,
|
|
1302
|
+
1,
|
|
1303
|
+
4,
|
|
1304
|
+
51,
|
|
1305
|
+
13,
|
|
1306
|
+
310,
|
|
1307
|
+
10,
|
|
1308
|
+
21,
|
|
1309
|
+
11,
|
|
1310
|
+
7,
|
|
1311
|
+
25,
|
|
1312
|
+
5,
|
|
1313
|
+
2,
|
|
1314
|
+
41,
|
|
1315
|
+
2,
|
|
1316
|
+
8,
|
|
1317
|
+
70,
|
|
1318
|
+
5,
|
|
1319
|
+
3,
|
|
1320
|
+
0,
|
|
1321
|
+
2,
|
|
1322
|
+
43,
|
|
1323
|
+
2,
|
|
1324
|
+
1,
|
|
1325
|
+
4,
|
|
1326
|
+
0,
|
|
1327
|
+
3,
|
|
1328
|
+
22,
|
|
1329
|
+
11,
|
|
1330
|
+
22,
|
|
1331
|
+
10,
|
|
1332
|
+
30,
|
|
1333
|
+
66,
|
|
1334
|
+
18,
|
|
1335
|
+
2,
|
|
1336
|
+
1,
|
|
1337
|
+
11,
|
|
1338
|
+
21,
|
|
1339
|
+
11,
|
|
1340
|
+
25,
|
|
1341
|
+
7,
|
|
1342
|
+
25,
|
|
1343
|
+
39,
|
|
1344
|
+
55,
|
|
1345
|
+
7,
|
|
1346
|
+
1,
|
|
1347
|
+
65,
|
|
1348
|
+
0,
|
|
1349
|
+
16,
|
|
1350
|
+
3,
|
|
1351
|
+
2,
|
|
1352
|
+
2,
|
|
1353
|
+
2,
|
|
1354
|
+
28,
|
|
1355
|
+
43,
|
|
1356
|
+
28,
|
|
1357
|
+
4,
|
|
1358
|
+
28,
|
|
1359
|
+
36,
|
|
1360
|
+
7,
|
|
1361
|
+
2,
|
|
1362
|
+
27,
|
|
1363
|
+
28,
|
|
1364
|
+
53,
|
|
1365
|
+
11,
|
|
1366
|
+
21,
|
|
1367
|
+
11,
|
|
1368
|
+
18,
|
|
1369
|
+
14,
|
|
1370
|
+
17,
|
|
1371
|
+
111,
|
|
1372
|
+
72,
|
|
1373
|
+
56,
|
|
1374
|
+
50,
|
|
1375
|
+
14,
|
|
1376
|
+
50,
|
|
1377
|
+
14,
|
|
1378
|
+
35,
|
|
1379
|
+
39,
|
|
1380
|
+
27,
|
|
1381
|
+
10,
|
|
1382
|
+
22,
|
|
1383
|
+
251,
|
|
1384
|
+
41,
|
|
1385
|
+
7,
|
|
1386
|
+
1,
|
|
1387
|
+
17,
|
|
1388
|
+
5,
|
|
1389
|
+
57,
|
|
1390
|
+
28,
|
|
1391
|
+
11,
|
|
1392
|
+
0,
|
|
1393
|
+
9,
|
|
1394
|
+
21,
|
|
1395
|
+
43,
|
|
1396
|
+
17,
|
|
1397
|
+
47,
|
|
1398
|
+
20,
|
|
1399
|
+
28,
|
|
1400
|
+
22,
|
|
1401
|
+
13,
|
|
1402
|
+
52,
|
|
1403
|
+
58,
|
|
1404
|
+
1,
|
|
1405
|
+
3,
|
|
1406
|
+
0,
|
|
1407
|
+
14,
|
|
1408
|
+
44,
|
|
1409
|
+
33,
|
|
1410
|
+
24,
|
|
1411
|
+
27,
|
|
1412
|
+
35,
|
|
1413
|
+
30,
|
|
1414
|
+
0,
|
|
1415
|
+
3,
|
|
1416
|
+
0,
|
|
1417
|
+
9,
|
|
1418
|
+
34,
|
|
1419
|
+
4,
|
|
1420
|
+
0,
|
|
1421
|
+
13,
|
|
1422
|
+
47,
|
|
1423
|
+
15,
|
|
1424
|
+
3,
|
|
1425
|
+
22,
|
|
1426
|
+
0,
|
|
1427
|
+
2,
|
|
1428
|
+
0,
|
|
1429
|
+
36,
|
|
1430
|
+
17,
|
|
1431
|
+
2,
|
|
1432
|
+
24,
|
|
1433
|
+
20,
|
|
1434
|
+
1,
|
|
1435
|
+
64,
|
|
1436
|
+
6,
|
|
1437
|
+
2,
|
|
1438
|
+
0,
|
|
1439
|
+
2,
|
|
1440
|
+
3,
|
|
1441
|
+
2,
|
|
1442
|
+
14,
|
|
1443
|
+
2,
|
|
1444
|
+
9,
|
|
1445
|
+
8,
|
|
1446
|
+
46,
|
|
1447
|
+
39,
|
|
1448
|
+
7,
|
|
1449
|
+
3,
|
|
1450
|
+
1,
|
|
1451
|
+
3,
|
|
1452
|
+
21,
|
|
1453
|
+
2,
|
|
1454
|
+
6,
|
|
1455
|
+
2,
|
|
1456
|
+
1,
|
|
1457
|
+
2,
|
|
1458
|
+
4,
|
|
1459
|
+
4,
|
|
1460
|
+
0,
|
|
1461
|
+
19,
|
|
1462
|
+
0,
|
|
1463
|
+
13,
|
|
1464
|
+
4,
|
|
1465
|
+
31,
|
|
1466
|
+
9,
|
|
1467
|
+
2,
|
|
1468
|
+
0,
|
|
1469
|
+
3,
|
|
1470
|
+
0,
|
|
1471
|
+
2,
|
|
1472
|
+
37,
|
|
1473
|
+
2,
|
|
1474
|
+
0,
|
|
1475
|
+
26,
|
|
1476
|
+
0,
|
|
1477
|
+
2,
|
|
1478
|
+
0,
|
|
1479
|
+
45,
|
|
1480
|
+
52,
|
|
1481
|
+
19,
|
|
1482
|
+
3,
|
|
1483
|
+
21,
|
|
1484
|
+
2,
|
|
1485
|
+
31,
|
|
1486
|
+
47,
|
|
1487
|
+
21,
|
|
1488
|
+
1,
|
|
1489
|
+
2,
|
|
1490
|
+
0,
|
|
1491
|
+
185,
|
|
1492
|
+
46,
|
|
1493
|
+
42,
|
|
1494
|
+
3,
|
|
1495
|
+
37,
|
|
1496
|
+
47,
|
|
1497
|
+
21,
|
|
1498
|
+
0,
|
|
1499
|
+
60,
|
|
1500
|
+
42,
|
|
1501
|
+
14,
|
|
1502
|
+
0,
|
|
1503
|
+
72,
|
|
1504
|
+
26,
|
|
1505
|
+
38,
|
|
1506
|
+
6,
|
|
1507
|
+
186,
|
|
1508
|
+
43,
|
|
1509
|
+
117,
|
|
1510
|
+
63,
|
|
1511
|
+
32,
|
|
1512
|
+
7,
|
|
1513
|
+
3,
|
|
1514
|
+
0,
|
|
1515
|
+
3,
|
|
1516
|
+
7,
|
|
1517
|
+
2,
|
|
1518
|
+
1,
|
|
1519
|
+
2,
|
|
1520
|
+
23,
|
|
1521
|
+
16,
|
|
1522
|
+
0,
|
|
1523
|
+
2,
|
|
1524
|
+
0,
|
|
1525
|
+
95,
|
|
1526
|
+
7,
|
|
1527
|
+
3,
|
|
1528
|
+
38,
|
|
1529
|
+
17,
|
|
1530
|
+
0,
|
|
1531
|
+
2,
|
|
1532
|
+
0,
|
|
1533
|
+
29,
|
|
1534
|
+
0,
|
|
1535
|
+
11,
|
|
1536
|
+
39,
|
|
1537
|
+
8,
|
|
1538
|
+
0,
|
|
1539
|
+
22,
|
|
1540
|
+
0,
|
|
1541
|
+
12,
|
|
1542
|
+
45,
|
|
1543
|
+
20,
|
|
1544
|
+
0,
|
|
1545
|
+
19,
|
|
1546
|
+
72,
|
|
1547
|
+
200,
|
|
1548
|
+
32,
|
|
1549
|
+
32,
|
|
1550
|
+
8,
|
|
1551
|
+
2,
|
|
1552
|
+
36,
|
|
1553
|
+
18,
|
|
1554
|
+
0,
|
|
1555
|
+
50,
|
|
1556
|
+
29,
|
|
1557
|
+
113,
|
|
1558
|
+
6,
|
|
1559
|
+
2,
|
|
1560
|
+
1,
|
|
1561
|
+
2,
|
|
1562
|
+
37,
|
|
1563
|
+
22,
|
|
1564
|
+
0,
|
|
1565
|
+
26,
|
|
1566
|
+
5,
|
|
1567
|
+
2,
|
|
1568
|
+
1,
|
|
1569
|
+
2,
|
|
1570
|
+
31,
|
|
1571
|
+
15,
|
|
1572
|
+
0,
|
|
1573
|
+
24,
|
|
1574
|
+
43,
|
|
1575
|
+
261,
|
|
1576
|
+
18,
|
|
1577
|
+
16,
|
|
1578
|
+
0,
|
|
1579
|
+
2,
|
|
1580
|
+
12,
|
|
1581
|
+
2,
|
|
1582
|
+
33,
|
|
1583
|
+
125,
|
|
1584
|
+
0,
|
|
1585
|
+
80,
|
|
1586
|
+
921,
|
|
1587
|
+
103,
|
|
1588
|
+
110,
|
|
1589
|
+
18,
|
|
1590
|
+
195,
|
|
1591
|
+
2637,
|
|
1592
|
+
96,
|
|
1593
|
+
16,
|
|
1594
|
+
1071,
|
|
1595
|
+
18,
|
|
1596
|
+
5,
|
|
1597
|
+
26,
|
|
1598
|
+
3994,
|
|
1599
|
+
6,
|
|
1600
|
+
582,
|
|
1601
|
+
6842,
|
|
1602
|
+
29,
|
|
1603
|
+
1763,
|
|
1604
|
+
568,
|
|
1605
|
+
8,
|
|
1606
|
+
30,
|
|
1607
|
+
18,
|
|
1608
|
+
78,
|
|
1609
|
+
18,
|
|
1610
|
+
29,
|
|
1611
|
+
19,
|
|
1612
|
+
47,
|
|
1613
|
+
17,
|
|
1614
|
+
3,
|
|
1615
|
+
32,
|
|
1616
|
+
20,
|
|
1617
|
+
6,
|
|
1618
|
+
18,
|
|
1619
|
+
433,
|
|
1620
|
+
44,
|
|
1621
|
+
212,
|
|
1622
|
+
63,
|
|
1623
|
+
33,
|
|
1624
|
+
24,
|
|
1625
|
+
3,
|
|
1626
|
+
24,
|
|
1627
|
+
45,
|
|
1628
|
+
74,
|
|
1629
|
+
6,
|
|
1630
|
+
0,
|
|
1631
|
+
67,
|
|
1632
|
+
12,
|
|
1633
|
+
65,
|
|
1634
|
+
1,
|
|
1635
|
+
2,
|
|
1636
|
+
0,
|
|
1637
|
+
15,
|
|
1638
|
+
4,
|
|
1639
|
+
10,
|
|
1640
|
+
7381,
|
|
1641
|
+
42,
|
|
1642
|
+
31,
|
|
1643
|
+
98,
|
|
1644
|
+
114,
|
|
1645
|
+
8702,
|
|
1646
|
+
3,
|
|
1647
|
+
2,
|
|
1648
|
+
6,
|
|
1649
|
+
2,
|
|
1650
|
+
1,
|
|
1651
|
+
2,
|
|
1652
|
+
290,
|
|
1653
|
+
16,
|
|
1654
|
+
0,
|
|
1655
|
+
30,
|
|
1656
|
+
2,
|
|
1657
|
+
3,
|
|
1658
|
+
0,
|
|
1659
|
+
15,
|
|
1660
|
+
3,
|
|
1661
|
+
9,
|
|
1662
|
+
395,
|
|
1663
|
+
2309,
|
|
1664
|
+
106,
|
|
1665
|
+
6,
|
|
1666
|
+
12,
|
|
1667
|
+
4,
|
|
1668
|
+
8,
|
|
1669
|
+
8,
|
|
1670
|
+
9,
|
|
1671
|
+
5991,
|
|
1672
|
+
84,
|
|
1673
|
+
2,
|
|
1674
|
+
70,
|
|
1675
|
+
2,
|
|
1676
|
+
1,
|
|
1677
|
+
3,
|
|
1678
|
+
0,
|
|
1679
|
+
3,
|
|
1680
|
+
1,
|
|
1681
|
+
3,
|
|
1682
|
+
3,
|
|
1683
|
+
2,
|
|
1684
|
+
11,
|
|
1685
|
+
2,
|
|
1686
|
+
0,
|
|
1687
|
+
2,
|
|
1688
|
+
6,
|
|
1689
|
+
2,
|
|
1690
|
+
64,
|
|
1691
|
+
2,
|
|
1692
|
+
3,
|
|
1693
|
+
3,
|
|
1694
|
+
7,
|
|
1695
|
+
2,
|
|
1696
|
+
6,
|
|
1697
|
+
2,
|
|
1698
|
+
27,
|
|
1699
|
+
2,
|
|
1700
|
+
3,
|
|
1701
|
+
2,
|
|
1702
|
+
4,
|
|
1703
|
+
2,
|
|
1704
|
+
0,
|
|
1705
|
+
4,
|
|
1706
|
+
6,
|
|
1707
|
+
2,
|
|
1708
|
+
339,
|
|
1709
|
+
3,
|
|
1710
|
+
24,
|
|
1711
|
+
2,
|
|
1712
|
+
24,
|
|
1713
|
+
2,
|
|
1714
|
+
30,
|
|
1715
|
+
2,
|
|
1716
|
+
24,
|
|
1717
|
+
2,
|
|
1718
|
+
30,
|
|
1719
|
+
2,
|
|
1720
|
+
24,
|
|
1721
|
+
2,
|
|
1722
|
+
30,
|
|
1723
|
+
2,
|
|
1724
|
+
24,
|
|
1725
|
+
2,
|
|
1726
|
+
30,
|
|
1727
|
+
2,
|
|
1728
|
+
24,
|
|
1729
|
+
2,
|
|
1730
|
+
7,
|
|
1731
|
+
1845,
|
|
1732
|
+
30,
|
|
1733
|
+
7,
|
|
1734
|
+
5,
|
|
1735
|
+
262,
|
|
1736
|
+
61,
|
|
1737
|
+
147,
|
|
1738
|
+
44,
|
|
1739
|
+
11,
|
|
1740
|
+
6,
|
|
1741
|
+
17,
|
|
1742
|
+
0,
|
|
1743
|
+
322,
|
|
1744
|
+
29,
|
|
1745
|
+
19,
|
|
1746
|
+
43,
|
|
1747
|
+
485,
|
|
1748
|
+
27,
|
|
1749
|
+
229,
|
|
1750
|
+
29,
|
|
1751
|
+
3,
|
|
1752
|
+
0,
|
|
1753
|
+
208,
|
|
1754
|
+
30,
|
|
1755
|
+
2,
|
|
1756
|
+
2,
|
|
1757
|
+
2,
|
|
1758
|
+
1,
|
|
1759
|
+
2,
|
|
1760
|
+
6,
|
|
1761
|
+
3,
|
|
1762
|
+
4,
|
|
1763
|
+
10,
|
|
1764
|
+
1,
|
|
1765
|
+
225,
|
|
1766
|
+
6,
|
|
1767
|
+
2,
|
|
1768
|
+
3,
|
|
1769
|
+
2,
|
|
1770
|
+
1,
|
|
1771
|
+
2,
|
|
1772
|
+
14,
|
|
1773
|
+
2,
|
|
1774
|
+
196,
|
|
1775
|
+
60,
|
|
1776
|
+
67,
|
|
1777
|
+
8,
|
|
1778
|
+
0,
|
|
1779
|
+
1205,
|
|
1780
|
+
3,
|
|
1781
|
+
2,
|
|
1782
|
+
26,
|
|
1783
|
+
2,
|
|
1784
|
+
1,
|
|
1785
|
+
2,
|
|
1786
|
+
0,
|
|
1787
|
+
3,
|
|
1788
|
+
0,
|
|
1789
|
+
2,
|
|
1790
|
+
9,
|
|
1791
|
+
2,
|
|
1792
|
+
3,
|
|
1793
|
+
2,
|
|
1794
|
+
0,
|
|
1795
|
+
2,
|
|
1796
|
+
0,
|
|
1797
|
+
7,
|
|
1798
|
+
0,
|
|
1799
|
+
5,
|
|
1800
|
+
0,
|
|
1801
|
+
2,
|
|
1802
|
+
0,
|
|
1803
|
+
2,
|
|
1804
|
+
0,
|
|
1805
|
+
2,
|
|
1806
|
+
2,
|
|
1807
|
+
2,
|
|
1808
|
+
1,
|
|
1809
|
+
2,
|
|
1810
|
+
0,
|
|
1811
|
+
3,
|
|
1812
|
+
0,
|
|
1813
|
+
2,
|
|
1814
|
+
0,
|
|
1815
|
+
2,
|
|
1816
|
+
0,
|
|
1817
|
+
2,
|
|
1818
|
+
0,
|
|
1819
|
+
2,
|
|
1820
|
+
0,
|
|
1821
|
+
2,
|
|
1822
|
+
1,
|
|
1823
|
+
2,
|
|
1824
|
+
0,
|
|
1825
|
+
3,
|
|
1826
|
+
3,
|
|
1827
|
+
2,
|
|
1828
|
+
6,
|
|
1829
|
+
2,
|
|
1830
|
+
3,
|
|
1831
|
+
2,
|
|
1832
|
+
3,
|
|
1833
|
+
2,
|
|
1834
|
+
0,
|
|
1835
|
+
2,
|
|
1836
|
+
9,
|
|
1837
|
+
2,
|
|
1838
|
+
16,
|
|
1839
|
+
6,
|
|
1840
|
+
2,
|
|
1841
|
+
2,
|
|
1842
|
+
4,
|
|
1843
|
+
2,
|
|
1844
|
+
16,
|
|
1845
|
+
4421,
|
|
1846
|
+
42719,
|
|
1847
|
+
33,
|
|
1848
|
+
4381,
|
|
1849
|
+
3,
|
|
1850
|
+
5773,
|
|
1851
|
+
3,
|
|
1852
|
+
7472,
|
|
1853
|
+
16,
|
|
1854
|
+
621,
|
|
1855
|
+
2467,
|
|
1856
|
+
541,
|
|
1857
|
+
1507,
|
|
1858
|
+
4938,
|
|
1859
|
+
6,
|
|
1860
|
+
8489
|
|
1861
|
+
], h = "·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ--ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・", g = "ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ--ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ", _ = {
|
|
1862
|
+
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",
|
|
1863
|
+
5: "class enum extends super const export import",
|
|
1864
|
+
6: "enum",
|
|
1865
|
+
strict: "implements interface let package private protected public static yield",
|
|
1866
|
+
strictBind: "eval arguments"
|
|
1867
|
+
}, ee = "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", te = {
|
|
1868
|
+
5: ee,
|
|
1869
|
+
"5module": ee + " export import",
|
|
1870
|
+
6: ee + " const class extends export import super"
|
|
1871
|
+
}, ne = /^in(stanceof)?$/, re = RegExp("[" + g + "]"), ie = RegExp("[" + g + h + "]");
|
|
1872
|
+
function ae(e, t) {
|
|
1873
|
+
for (var n = 65536, r = 0; r < t.length; r += 2) {
|
|
1874
|
+
if (n += t[r], n > e) return !1;
|
|
1875
|
+
if (n += t[r + 1], n >= e) return !0;
|
|
1876
|
+
}
|
|
1877
|
+
return !1;
|
|
1878
|
+
}
|
|
1879
|
+
function v(e, t) {
|
|
1880
|
+
return e < 65 ? e === 36 : e < 91 ? !0 : e < 97 ? e === 95 : e < 123 ? !0 : e <= 65535 ? e >= 170 && re.test(String.fromCharCode(e)) : t !== !1 && ae(e, m);
|
|
1881
|
+
}
|
|
1882
|
+
function y(e, t) {
|
|
1883
|
+
return e < 48 ? e === 36 : e < 58 ? !0 : e < 65 ? !1 : e < 91 ? !0 : e < 97 ? e === 95 : e < 123 ? !0 : e <= 65535 ? e >= 170 && ie.test(String.fromCharCode(e)) : t === !1 ? !1 : ae(e, m) || ae(e, p);
|
|
1884
|
+
}
|
|
1885
|
+
var b = function(e, t) {
|
|
1886
|
+
t === void 0 && (t = {}), this.label = e, this.keyword = t.keyword, this.beforeExpr = !!t.beforeExpr, this.startsExpr = !!t.startsExpr, this.isLoop = !!t.isLoop, this.isAssign = !!t.isAssign, this.prefix = !!t.prefix, this.postfix = !!t.postfix, this.binop = t.binop || null, this.updateContext = null;
|
|
1887
|
+
};
|
|
1888
|
+
function x(e, t) {
|
|
1889
|
+
return new b(e, {
|
|
1890
|
+
beforeExpr: !0,
|
|
1891
|
+
binop: t
|
|
1892
|
+
});
|
|
1893
|
+
}
|
|
1894
|
+
var S = { beforeExpr: !0 }, C = { startsExpr: !0 }, oe = {};
|
|
1895
|
+
function w(e, t) {
|
|
1896
|
+
return t === void 0 && (t = {}), t.keyword = e, oe[e] = new b(e, t);
|
|
1897
|
+
}
|
|
1898
|
+
var T = {
|
|
1899
|
+
num: new b("num", C),
|
|
1900
|
+
regexp: new b("regexp", C),
|
|
1901
|
+
string: new b("string", C),
|
|
1902
|
+
name: new b("name", C),
|
|
1903
|
+
privateId: new b("privateId", C),
|
|
1904
|
+
eof: new b("eof"),
|
|
1905
|
+
bracketL: new b("[", {
|
|
1906
|
+
beforeExpr: !0,
|
|
1907
|
+
startsExpr: !0
|
|
1908
|
+
}),
|
|
1909
|
+
bracketR: new b("]"),
|
|
1910
|
+
braceL: new b("{", {
|
|
1911
|
+
beforeExpr: !0,
|
|
1912
|
+
startsExpr: !0
|
|
1913
|
+
}),
|
|
1914
|
+
braceR: new b("}"),
|
|
1915
|
+
parenL: new b("(", {
|
|
1916
|
+
beforeExpr: !0,
|
|
1917
|
+
startsExpr: !0
|
|
1918
|
+
}),
|
|
1919
|
+
parenR: new b(")"),
|
|
1920
|
+
comma: new b(",", S),
|
|
1921
|
+
semi: new b(";", S),
|
|
1922
|
+
colon: new b(":", S),
|
|
1923
|
+
dot: new b("."),
|
|
1924
|
+
question: new b("?", S),
|
|
1925
|
+
questionDot: new b("?."),
|
|
1926
|
+
arrow: new b("=>", S),
|
|
1927
|
+
template: new b("template"),
|
|
1928
|
+
invalidTemplate: new b("invalidTemplate"),
|
|
1929
|
+
ellipsis: new b("...", S),
|
|
1930
|
+
backQuote: new b("`", C),
|
|
1931
|
+
dollarBraceL: new b("${", {
|
|
1932
|
+
beforeExpr: !0,
|
|
1933
|
+
startsExpr: !0
|
|
1934
|
+
}),
|
|
1935
|
+
eq: new b("=", {
|
|
1936
|
+
beforeExpr: !0,
|
|
1937
|
+
isAssign: !0
|
|
1938
|
+
}),
|
|
1939
|
+
assign: new b("_=", {
|
|
1940
|
+
beforeExpr: !0,
|
|
1941
|
+
isAssign: !0
|
|
1942
|
+
}),
|
|
1943
|
+
incDec: new b("++/--", {
|
|
1944
|
+
prefix: !0,
|
|
1945
|
+
postfix: !0,
|
|
1946
|
+
startsExpr: !0
|
|
1947
|
+
}),
|
|
1948
|
+
prefix: new b("!/~", {
|
|
1949
|
+
beforeExpr: !0,
|
|
1950
|
+
prefix: !0,
|
|
1951
|
+
startsExpr: !0
|
|
1952
|
+
}),
|
|
1953
|
+
logicalOR: x("||", 1),
|
|
1954
|
+
logicalAND: x("&&", 2),
|
|
1955
|
+
bitwiseOR: x("|", 3),
|
|
1956
|
+
bitwiseXOR: x("^", 4),
|
|
1957
|
+
bitwiseAND: x("&", 5),
|
|
1958
|
+
equality: x("==/!=/===/!==", 6),
|
|
1959
|
+
relational: x("</>/<=/>=", 7),
|
|
1960
|
+
bitShift: x("<</>>/>>>", 8),
|
|
1961
|
+
plusMin: new b("+/-", {
|
|
1962
|
+
beforeExpr: !0,
|
|
1963
|
+
binop: 9,
|
|
1964
|
+
prefix: !0,
|
|
1965
|
+
startsExpr: !0
|
|
1966
|
+
}),
|
|
1967
|
+
modulo: x("%", 10),
|
|
1968
|
+
star: x("*", 10),
|
|
1969
|
+
slash: x("/", 10),
|
|
1970
|
+
starstar: new b("**", { beforeExpr: !0 }),
|
|
1971
|
+
coalesce: x("??", 1),
|
|
1972
|
+
_break: w("break"),
|
|
1973
|
+
_case: w("case", S),
|
|
1974
|
+
_catch: w("catch"),
|
|
1975
|
+
_continue: w("continue"),
|
|
1976
|
+
_debugger: w("debugger"),
|
|
1977
|
+
_default: w("default", S),
|
|
1978
|
+
_do: w("do", {
|
|
1979
|
+
isLoop: !0,
|
|
1980
|
+
beforeExpr: !0
|
|
1981
|
+
}),
|
|
1982
|
+
_else: w("else", S),
|
|
1983
|
+
_finally: w("finally"),
|
|
1984
|
+
_for: w("for", { isLoop: !0 }),
|
|
1985
|
+
_function: w("function", C),
|
|
1986
|
+
_if: w("if"),
|
|
1987
|
+
_return: w("return", S),
|
|
1988
|
+
_switch: w("switch"),
|
|
1989
|
+
_throw: w("throw", S),
|
|
1990
|
+
_try: w("try"),
|
|
1991
|
+
_var: w("var"),
|
|
1992
|
+
_const: w("const"),
|
|
1993
|
+
_while: w("while", { isLoop: !0 }),
|
|
1994
|
+
_with: w("with"),
|
|
1995
|
+
_new: w("new", {
|
|
1996
|
+
beforeExpr: !0,
|
|
1997
|
+
startsExpr: !0
|
|
1998
|
+
}),
|
|
1999
|
+
_this: w("this", C),
|
|
2000
|
+
_super: w("super", C),
|
|
2001
|
+
_class: w("class", C),
|
|
2002
|
+
_extends: w("extends", S),
|
|
2003
|
+
_export: w("export"),
|
|
2004
|
+
_import: w("import", C),
|
|
2005
|
+
_null: w("null", C),
|
|
2006
|
+
_true: w("true", C),
|
|
2007
|
+
_false: w("false", C),
|
|
2008
|
+
_in: w("in", {
|
|
2009
|
+
beforeExpr: !0,
|
|
2010
|
+
binop: 7
|
|
2011
|
+
}),
|
|
2012
|
+
_instanceof: w("instanceof", {
|
|
2013
|
+
beforeExpr: !0,
|
|
2014
|
+
binop: 7
|
|
2015
|
+
}),
|
|
2016
|
+
_typeof: w("typeof", {
|
|
2017
|
+
beforeExpr: !0,
|
|
2018
|
+
prefix: !0,
|
|
2019
|
+
startsExpr: !0
|
|
2020
|
+
}),
|
|
2021
|
+
_void: w("void", {
|
|
2022
|
+
beforeExpr: !0,
|
|
2023
|
+
prefix: !0,
|
|
2024
|
+
startsExpr: !0
|
|
2025
|
+
}),
|
|
2026
|
+
_delete: w("delete", {
|
|
2027
|
+
beforeExpr: !0,
|
|
2028
|
+
prefix: !0,
|
|
2029
|
+
startsExpr: !0
|
|
2030
|
+
})
|
|
2031
|
+
}, E = /\r\n?|\n|\u2028|\u2029/, se = new RegExp(E.source, "g");
|
|
2032
|
+
function D(e) {
|
|
2033
|
+
return e === 10 || e === 13 || e === 8232 || e === 8233;
|
|
2034
|
+
}
|
|
2035
|
+
function ce(e, t, n) {
|
|
2036
|
+
n === void 0 && (n = e.length);
|
|
2037
|
+
for (var r = t; r < n; r++) {
|
|
2038
|
+
var i = e.charCodeAt(r);
|
|
2039
|
+
if (D(i)) return r < n - 1 && i === 13 && e.charCodeAt(r + 1) === 10 ? r + 2 : r + 1;
|
|
2040
|
+
}
|
|
2041
|
+
return -1;
|
|
2042
|
+
}
|
|
2043
|
+
var le = /[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/, O = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g, ue = Object.prototype, de = ue.hasOwnProperty, fe = ue.toString, k = Object.hasOwn || (function(e, t) {
|
|
2044
|
+
return de.call(e, t);
|
|
2045
|
+
}), pe = Array.isArray || (function(e) {
|
|
2046
|
+
return fe.call(e) === "[object Array]";
|
|
2047
|
+
}), me = Object.create(null);
|
|
2048
|
+
function A(e) {
|
|
2049
|
+
return me[e] || (me[e] = RegExp("^(?:" + e.replace(/ /g, "|") + ")$"));
|
|
2050
|
+
}
|
|
2051
|
+
function j(e) {
|
|
2052
|
+
return e <= 65535 ? String.fromCharCode(e) : (e -= 65536, String.fromCharCode((e >> 10) + 55296, (e & 1023) + 56320));
|
|
2053
|
+
}
|
|
2054
|
+
var he = /(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/, M = function(e, t) {
|
|
2055
|
+
this.line = e, this.column = t;
|
|
2056
|
+
};
|
|
2057
|
+
M.prototype.offset = function(e) {
|
|
2058
|
+
return new M(this.line, this.column + e);
|
|
2059
|
+
};
|
|
2060
|
+
var ge = function(e, t, n) {
|
|
2061
|
+
this.start = t, this.end = n, e.sourceFile !== null && (this.source = e.sourceFile);
|
|
2062
|
+
};
|
|
2063
|
+
function _e(e, t) {
|
|
2064
|
+
for (var n = 1, r = 0;;) {
|
|
2065
|
+
var i = ce(e, r, t);
|
|
2066
|
+
if (i < 0) return new M(n, t - r);
|
|
2067
|
+
++n, r = i;
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
var ve = {
|
|
2071
|
+
ecmaVersion: null,
|
|
2072
|
+
sourceType: "script",
|
|
2073
|
+
strict: !1,
|
|
2074
|
+
onInsertedSemicolon: null,
|
|
2075
|
+
onTrailingComma: null,
|
|
2076
|
+
allowReserved: null,
|
|
2077
|
+
allowReturnOutsideFunction: !1,
|
|
2078
|
+
allowImportExportEverywhere: !1,
|
|
2079
|
+
allowAwaitOutsideFunction: null,
|
|
2080
|
+
allowSuperOutsideMethod: null,
|
|
2081
|
+
allowHashBang: !1,
|
|
2082
|
+
checkPrivateFields: !0,
|
|
2083
|
+
locations: !1,
|
|
2084
|
+
onToken: null,
|
|
2085
|
+
onComment: null,
|
|
2086
|
+
ranges: !1,
|
|
2087
|
+
program: null,
|
|
2088
|
+
sourceFile: null,
|
|
2089
|
+
directSourceFile: null,
|
|
2090
|
+
preserveParens: !1
|
|
2091
|
+
}, ye = !1;
|
|
2092
|
+
function be(e) {
|
|
2093
|
+
var t = {};
|
|
2094
|
+
for (var n in ve) t[n] = e && k(e, n) ? e[n] : ve[n];
|
|
2095
|
+
if (t.ecmaVersion === "latest" ? t.ecmaVersion = 1e8 : t.ecmaVersion == null ? (!ye && typeof console == "object" && console.warn && (ye = !0, console.warn("Since Acorn 8.0.0, options.ecmaVersion is required.\nDefaulting to 2020, but this will stop working in the future.")), t.ecmaVersion = 11) : t.ecmaVersion >= 2015 && (t.ecmaVersion -= 2009), t.allowReserved ??= t.ecmaVersion < 5, (!e || e.allowHashBang == null) && (t.allowHashBang = t.ecmaVersion >= 14), pe(t.onToken)) {
|
|
2096
|
+
var r = t.onToken;
|
|
2097
|
+
t.onToken = function(e) {
|
|
2098
|
+
return r.push(e);
|
|
2099
|
+
};
|
|
2100
|
+
}
|
|
2101
|
+
if (pe(t.onComment) && (t.onComment = xe(t, t.onComment)), t.sourceType === "commonjs" && t.allowAwaitOutsideFunction) throw Error("Cannot use allowAwaitOutsideFunction with sourceType: commonjs");
|
|
2102
|
+
return t;
|
|
2103
|
+
}
|
|
2104
|
+
function xe(e, t) {
|
|
2105
|
+
return function(n, r, i, a, o, s) {
|
|
2106
|
+
var c = {
|
|
2107
|
+
type: n ? "Block" : "Line",
|
|
2108
|
+
value: r,
|
|
2109
|
+
start: i,
|
|
2110
|
+
end: a
|
|
2111
|
+
};
|
|
2112
|
+
e.locations && (c.loc = new ge(this, o, s)), e.ranges && (c.range = [i, a]), t.push(c);
|
|
2113
|
+
};
|
|
2114
|
+
}
|
|
2115
|
+
var N = 1, P = 2, Se = 4, Ce = 8, we = 16, Te = 32, Ee = 64, De = 128, F = 256, Oe = 512, ke = 1024, Ae = N | P | F;
|
|
2116
|
+
function je(e, t) {
|
|
2117
|
+
return P | (e ? Se : 0) | (t ? Ce : 0);
|
|
2118
|
+
}
|
|
2119
|
+
var Me = 0, Ne = 1, I = 2, Pe = 3, Fe = 4, Ie = 5, L = function(e, t, n) {
|
|
2120
|
+
this.options = e = be(e), this.sourceFile = e.sourceFile, this.keywords = A(te[e.ecmaVersion >= 6 ? 6 : e.sourceType === "module" ? "5module" : 5]);
|
|
2121
|
+
var r = "";
|
|
2122
|
+
e.allowReserved !== !0 && (r = _[e.ecmaVersion >= 6 ? 6 : e.ecmaVersion === 5 ? 5 : 3], e.sourceType === "module" && (r += " await")), this.reservedWords = A(r);
|
|
2123
|
+
var i = (r ? r + " " : "") + _.strict;
|
|
2124
|
+
this.reservedWordsStrict = A(i), this.reservedWordsStrictBind = A(i + " " + _.strictBind), this.input = String(t), this.containsEsc = !1, n ? (this.pos = n, this.lineStart = this.input.lastIndexOf("\n", n - 1) + 1, this.curLine = this.input.slice(0, this.lineStart).split(E).length) : (this.pos = this.lineStart = 0, this.curLine = 1), this.type = T.eof, this.value = null, this.start = this.end = this.pos, this.startLoc = this.endLoc = this.curPosition(), this.lastTokEndLoc = this.lastTokStartLoc = null, this.lastTokStart = this.lastTokEnd = this.pos, this.context = this.initialContext(), this.exprAllowed = !0, this.inModule = e.sourceType === "module", this.strict = this.inModule || e.strict === !0 || this.strictDirective(this.pos), this.potentialArrowAt = -1, this.potentialArrowInForAwait = !1, this.yieldPos = this.awaitPos = this.awaitIdentPos = 0, this.labels = [], this.undefinedExports = Object.create(null), this.pos === 0 && e.allowHashBang && this.input.slice(0, 2) === "#!" && this.skipLineComment(2), this.scopeStack = [], this.enterScope(this.options.sourceType === "commonjs" ? P : N), this.regexpState = null, this.privateNameStack = [];
|
|
2125
|
+
}, R = {
|
|
2126
|
+
inFunction: { configurable: !0 },
|
|
2127
|
+
inGenerator: { configurable: !0 },
|
|
2128
|
+
inAsync: { configurable: !0 },
|
|
2129
|
+
canAwait: { configurable: !0 },
|
|
2130
|
+
allowReturn: { configurable: !0 },
|
|
2131
|
+
allowSuper: { configurable: !0 },
|
|
2132
|
+
allowDirectSuper: { configurable: !0 },
|
|
2133
|
+
treatFunctionsAsVar: { configurable: !0 },
|
|
2134
|
+
allowNewDotTarget: { configurable: !0 },
|
|
2135
|
+
allowUsing: { configurable: !0 },
|
|
2136
|
+
inClassStaticBlock: { configurable: !0 }
|
|
2137
|
+
};
|
|
2138
|
+
L.prototype.parse = function() {
|
|
2139
|
+
var e = this, t = this.options.program || this.startNode();
|
|
2140
|
+
return this.nextToken(), this.catchStackOverflow(function() {
|
|
2141
|
+
return e.parseTopLevel(t);
|
|
2142
|
+
});
|
|
2143
|
+
}, R.inFunction.get = function() {
|
|
2144
|
+
return (this.currentVarScope().flags & P) > 0;
|
|
2145
|
+
}, R.inGenerator.get = function() {
|
|
2146
|
+
return (this.currentVarScope().flags & Ce) > 0;
|
|
2147
|
+
}, R.inAsync.get = function() {
|
|
2148
|
+
return (this.currentVarScope().flags & Se) > 0;
|
|
2149
|
+
}, R.canAwait.get = function() {
|
|
2150
|
+
for (var e = this.scopeStack.length - 1; e >= 0; e--) {
|
|
2151
|
+
var t = this.scopeStack[e].flags;
|
|
2152
|
+
if (t & (F | Oe)) return !1;
|
|
2153
|
+
if (t & P) return (t & Se) > 0;
|
|
2154
|
+
}
|
|
2155
|
+
return this.inModule && this.options.ecmaVersion >= 13 || this.options.allowAwaitOutsideFunction;
|
|
2156
|
+
}, R.allowReturn.get = function() {
|
|
2157
|
+
return !!(this.inFunction || this.options.allowReturnOutsideFunction && this.currentVarScope().flags & N);
|
|
2158
|
+
}, R.allowSuper.get = function() {
|
|
2159
|
+
return (this.currentThisScope().flags & Ee) > 0 || this.options.allowSuperOutsideMethod;
|
|
2160
|
+
}, R.allowDirectSuper.get = function() {
|
|
2161
|
+
return (this.currentThisScope().flags & De) > 0;
|
|
2162
|
+
}, R.treatFunctionsAsVar.get = function() {
|
|
2163
|
+
return this.treatFunctionsAsVarInScope(this.currentScope());
|
|
2164
|
+
}, R.allowNewDotTarget.get = function() {
|
|
2165
|
+
for (var e = this.scopeStack.length - 1; e >= 0; e--) {
|
|
2166
|
+
var t = this.scopeStack[e].flags;
|
|
2167
|
+
if (t & (F | Oe) || t & P && !(t & we)) return !0;
|
|
2168
|
+
}
|
|
2169
|
+
return !1;
|
|
2170
|
+
}, R.allowUsing.get = function() {
|
|
2171
|
+
var e = this.currentScope().flags;
|
|
2172
|
+
return !(e & ke || !this.inModule && e & N);
|
|
2173
|
+
}, R.inClassStaticBlock.get = function() {
|
|
2174
|
+
return (this.currentVarScope().flags & F) > 0;
|
|
2175
|
+
}, L.extend = function() {
|
|
2176
|
+
for (var e = [], t = arguments.length; t--;) e[t] = arguments[t];
|
|
2177
|
+
for (var n = this, r = 0; r < e.length; r++) n = e[r](n);
|
|
2178
|
+
return n;
|
|
2179
|
+
}, L.parse = function(e, t) {
|
|
2180
|
+
return new this(t, e).parse();
|
|
2181
|
+
}, L.parseExpressionAt = function(e, t, n) {
|
|
2182
|
+
var r = new this(n, e, t);
|
|
2183
|
+
return r.nextToken(), r.parseExpression();
|
|
2184
|
+
}, L.tokenizer = function(e, t) {
|
|
2185
|
+
return new this(t, e);
|
|
2186
|
+
}, Object.defineProperties(L.prototype, R);
|
|
2187
|
+
var z = L.prototype, Le = /^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;
|
|
2188
|
+
z.strictDirective = function(e) {
|
|
2189
|
+
if (this.options.ecmaVersion < 5) return !1;
|
|
2190
|
+
for (;;) {
|
|
2191
|
+
O.lastIndex = e, e += O.exec(this.input)[0].length;
|
|
2192
|
+
var t = Le.exec(this.input.slice(e));
|
|
2193
|
+
if (!t) return !1;
|
|
2194
|
+
if ((t[1] || t[2]) === "use strict") {
|
|
2195
|
+
O.lastIndex = e + t[0].length;
|
|
2196
|
+
var n = O.exec(this.input), r = n.index + n[0].length, i = this.input.charAt(r);
|
|
2197
|
+
return i === ";" || i === "}" || E.test(n[0]) && !(/[(`.[+\-/*%<>=,?^&]/.test(i) || i === "!" && this.input.charAt(r + 1) === "=");
|
|
2198
|
+
}
|
|
2199
|
+
e += t[0].length, O.lastIndex = e, e += O.exec(this.input)[0].length, this.input[e] === ";" && e++;
|
|
2200
|
+
}
|
|
2201
|
+
}, z.eat = function(e) {
|
|
2202
|
+
return this.type === e ? (this.next(), !0) : !1;
|
|
2203
|
+
}, z.isContextual = function(e) {
|
|
2204
|
+
return this.type === T.name && this.value === e && !this.containsEsc;
|
|
2205
|
+
}, z.eatContextual = function(e) {
|
|
2206
|
+
return this.isContextual(e) ? (this.next(), !0) : !1;
|
|
2207
|
+
}, z.catchStackOverflow = function(e) {
|
|
2208
|
+
try {
|
|
2209
|
+
return e();
|
|
2210
|
+
} catch (e) {
|
|
2211
|
+
if (e instanceof Error && (/\bstack\b.*\b(exceeded|overflow)\b/i.test(e.message) || /\btoo much recursion\b/i.test(e.message))) this.raise(this.start, "Not enough stack space to parse input");
|
|
2212
|
+
else throw e;
|
|
2213
|
+
}
|
|
2214
|
+
}, z.expectContextual = function(e) {
|
|
2215
|
+
this.eatContextual(e) || this.unexpected();
|
|
2216
|
+
}, z.canInsertSemicolon = function() {
|
|
2217
|
+
return this.type === T.eof || this.type === T.braceR || E.test(this.input.slice(this.lastTokEnd, this.start));
|
|
2218
|
+
}, z.insertSemicolon = function() {
|
|
2219
|
+
if (this.canInsertSemicolon()) return this.options.onInsertedSemicolon && this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc), !0;
|
|
2220
|
+
}, z.semicolon = function() {
|
|
2221
|
+
!this.eat(T.semi) && !this.insertSemicolon() && this.unexpected();
|
|
2222
|
+
}, z.afterTrailingComma = function(e, t) {
|
|
2223
|
+
if (this.type === e) return this.options.onTrailingComma && this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc), t || this.next(), !0;
|
|
2224
|
+
}, z.expect = function(e) {
|
|
2225
|
+
this.eat(e) || this.unexpected();
|
|
2226
|
+
}, z.unexpected = function(e) {
|
|
2227
|
+
this.raise(e ?? this.start, "Unexpected token");
|
|
2228
|
+
};
|
|
2229
|
+
var Re = function() {
|
|
2230
|
+
this.shorthandAssign = this.trailingComma = this.parenthesizedAssign = this.parenthesizedBind = this.doubleProto = -1;
|
|
2231
|
+
};
|
|
2232
|
+
z.checkPatternErrors = function(e, t) {
|
|
2233
|
+
if (e) {
|
|
2234
|
+
e.trailingComma > -1 && this.raiseRecoverable(e.trailingComma, "Comma is not permitted after the rest element");
|
|
2235
|
+
var n = t ? e.parenthesizedAssign : e.parenthesizedBind;
|
|
2236
|
+
n > -1 && this.raiseRecoverable(n, t ? "Assigning to rvalue" : "Parenthesized pattern");
|
|
2237
|
+
}
|
|
2238
|
+
}, z.checkExpressionErrors = function(e, t) {
|
|
2239
|
+
if (!e) return !1;
|
|
2240
|
+
var n = e.shorthandAssign, r = e.doubleProto;
|
|
2241
|
+
if (!t) return n >= 0 || r >= 0;
|
|
2242
|
+
n >= 0 && this.raise(n, "Shorthand property assignments are valid only in destructuring patterns"), r >= 0 && this.raiseRecoverable(r, "Redefinition of __proto__ property");
|
|
2243
|
+
}, z.checkYieldAwaitInDefaultParams = function() {
|
|
2244
|
+
this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos) && this.raise(this.yieldPos, "Yield expression cannot be a default value"), this.awaitPos && this.raise(this.awaitPos, "Await expression cannot be a default value");
|
|
2245
|
+
}, z.isSimpleAssignTarget = function(e) {
|
|
2246
|
+
return e.type === "ParenthesizedExpression" ? this.isSimpleAssignTarget(e.expression) : e.type === "Identifier" || e.type === "MemberExpression";
|
|
2247
|
+
};
|
|
2248
|
+
var B = L.prototype;
|
|
2249
|
+
B.parseTopLevel = function(e) {
|
|
2250
|
+
var t = Object.create(null);
|
|
2251
|
+
for (e.body ||= []; this.type !== T.eof;) {
|
|
2252
|
+
var n = this.parseStatement(null, !0, t);
|
|
2253
|
+
e.body.push(n);
|
|
2254
|
+
}
|
|
2255
|
+
if (this.inModule) for (var r = 0, i = Object.keys(this.undefinedExports); r < i.length; r += 1) {
|
|
2256
|
+
var a = i[r];
|
|
2257
|
+
this.raiseRecoverable(this.undefinedExports[a].start, "Export '" + a + "' is not defined");
|
|
2258
|
+
}
|
|
2259
|
+
return this.adaptDirectivePrologue(e.body), this.next(), e.sourceType = this.options.sourceType === "commonjs" ? "script" : this.options.sourceType, this.finishNode(e, "Program");
|
|
2260
|
+
};
|
|
2261
|
+
var ze = { kind: "loop" }, Be = { kind: "switch" };
|
|
2262
|
+
B.isLet = function(e) {
|
|
2263
|
+
if (this.options.ecmaVersion < 6 || !this.isContextual("let")) return !1;
|
|
2264
|
+
O.lastIndex = this.pos;
|
|
2265
|
+
var t = O.exec(this.input), n = this.pos + t[0].length, r = this.fullCharCodeAt(n);
|
|
2266
|
+
if (r === 91 || r === 92) return !0;
|
|
2267
|
+
if (e) return !1;
|
|
2268
|
+
if (r === 123) return !0;
|
|
2269
|
+
if (v(r)) {
|
|
2270
|
+
var i = n;
|
|
2271
|
+
do
|
|
2272
|
+
n += r <= 65535 ? 1 : 2;
|
|
2273
|
+
while (y(r = this.fullCharCodeAt(n)));
|
|
2274
|
+
if (r === 92) return !0;
|
|
2275
|
+
var a = this.input.slice(i, n);
|
|
2276
|
+
if (!ne.test(a)) return !0;
|
|
2277
|
+
}
|
|
2278
|
+
return !1;
|
|
2279
|
+
}, B.isAsyncFunction = function() {
|
|
2280
|
+
if (this.options.ecmaVersion < 8 || !this.isContextual("async")) return !1;
|
|
2281
|
+
O.lastIndex = this.pos;
|
|
2282
|
+
var e = O.exec(this.input), t = this.pos + e[0].length, n;
|
|
2283
|
+
return !E.test(this.input.slice(this.pos, t)) && this.input.slice(t, t + 8) === "function" && (t + 8 === this.input.length || !(y(n = this.fullCharCodeAt(t + 8)) || n === 92));
|
|
2284
|
+
}, B.isUsingKeyword = function(e, t) {
|
|
2285
|
+
if (this.options.ecmaVersion < 17 || !this.isContextual(e ? "await" : "using")) return !1;
|
|
2286
|
+
O.lastIndex = this.pos;
|
|
2287
|
+
var n = O.exec(this.input), r = this.pos + n[0].length;
|
|
2288
|
+
if (E.test(this.input.slice(this.pos, r))) return !1;
|
|
2289
|
+
if (e) {
|
|
2290
|
+
var i = r + 5, a;
|
|
2291
|
+
if (this.input.slice(r, i) !== "using" || i === this.input.length || y(a = this.fullCharCodeAt(i)) || a === 92) return !1;
|
|
2292
|
+
O.lastIndex = i;
|
|
2293
|
+
var o = O.exec(this.input);
|
|
2294
|
+
if (r = i + o[0].length, o && E.test(this.input.slice(i, r))) return !1;
|
|
2295
|
+
}
|
|
2296
|
+
var s = this.fullCharCodeAt(r);
|
|
2297
|
+
if (!v(s) && s !== 92) return !1;
|
|
2298
|
+
var c = r;
|
|
2299
|
+
do
|
|
2300
|
+
r += s <= 65535 ? 1 : 2;
|
|
2301
|
+
while (y(s = this.fullCharCodeAt(r)));
|
|
2302
|
+
if (s === 92) return !0;
|
|
2303
|
+
var l = this.input.slice(c, r);
|
|
2304
|
+
if (ne.test(l)) return !1;
|
|
2305
|
+
if (t && !e && l === "of") {
|
|
2306
|
+
O.lastIndex = r;
|
|
2307
|
+
var u = O.exec(this.input);
|
|
2308
|
+
if (r += u[0].length, this.input.charCodeAt(r) !== 61 || (s = this.input.charCodeAt(r + 1)) === 61 || s === 62) return !1;
|
|
2309
|
+
}
|
|
2310
|
+
return !0;
|
|
2311
|
+
}, B.isAwaitUsing = function(e) {
|
|
2312
|
+
return this.isUsingKeyword(!0, e);
|
|
2313
|
+
}, B.isUsing = function(e) {
|
|
2314
|
+
return this.isUsingKeyword(!1, e);
|
|
2315
|
+
}, B.parseStatement = function(e, t, n) {
|
|
2316
|
+
var r = this.type, i = this.startNode(), a;
|
|
2317
|
+
switch (this.isLet(e) && (r = T._var, a = "let"), r) {
|
|
2318
|
+
case T._break:
|
|
2319
|
+
case T._continue: return this.parseBreakContinueStatement(i, r.keyword);
|
|
2320
|
+
case T._debugger: return this.parseDebuggerStatement(i);
|
|
2321
|
+
case T._do: return this.parseDoStatement(i);
|
|
2322
|
+
case T._for: return this.parseForStatement(i);
|
|
2323
|
+
case T._function: return e && (this.strict || e !== "if" && e !== "label") && this.options.ecmaVersion >= 6 && this.unexpected(), this.parseFunctionStatement(i, !1, !e);
|
|
2324
|
+
case T._class: return e && this.unexpected(), this.parseClass(i, !0);
|
|
2325
|
+
case T._if: return this.parseIfStatement(i);
|
|
2326
|
+
case T._return: return this.parseReturnStatement(i);
|
|
2327
|
+
case T._switch: return this.parseSwitchStatement(i);
|
|
2328
|
+
case T._throw: return this.parseThrowStatement(i);
|
|
2329
|
+
case T._try: return this.parseTryStatement(i);
|
|
2330
|
+
case T._const:
|
|
2331
|
+
case T._var: return a ||= this.value, e && a !== "var" && this.unexpected(), this.parseVarStatement(i, a);
|
|
2332
|
+
case T._while: return this.parseWhileStatement(i);
|
|
2333
|
+
case T._with: return this.parseWithStatement(i);
|
|
2334
|
+
case T.braceL: return this.parseBlock(!0, i);
|
|
2335
|
+
case T.semi: return this.parseEmptyStatement(i);
|
|
2336
|
+
case T._export:
|
|
2337
|
+
case T._import:
|
|
2338
|
+
if (this.options.ecmaVersion > 10 && r === T._import) {
|
|
2339
|
+
O.lastIndex = this.pos;
|
|
2340
|
+
var o = O.exec(this.input), s = this.pos + o[0].length, c = this.input.charCodeAt(s);
|
|
2341
|
+
if (c === 40 || c === 46) return this.parseExpressionStatement(i, this.parseExpression());
|
|
2342
|
+
}
|
|
2343
|
+
return this.options.allowImportExportEverywhere || (t || this.raise(this.start, "'import' and 'export' may only appear at the top level"), this.inModule || this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'")), r === T._import ? this.parseImport(i) : this.parseExport(i, n);
|
|
2344
|
+
default:
|
|
2345
|
+
if (this.isAsyncFunction()) return e && this.unexpected(), this.next(), this.parseFunctionStatement(i, !0, !e);
|
|
2346
|
+
var l = this.isAwaitUsing(!1) ? "await using" : this.isUsing(!1) ? "using" : null;
|
|
2347
|
+
if (l) return this.allowUsing || this.raise(this.start, "Using declaration cannot appear in the top level when source type is `script` or in the bare case statement"), e && this.raise(this.start, "Using declaration is not allowed in single-statement positions"), l === "await using" && (this.canAwait || this.raise(this.start, "Await using cannot appear outside of async function"), this.next()), this.next(), this.parseVar(i, !1, l), this.semicolon(), this.finishNode(i, "VariableDeclaration");
|
|
2348
|
+
var u = this.value, d = this.parseExpression();
|
|
2349
|
+
return r === T.name && d.type === "Identifier" && this.eat(T.colon) ? this.parseLabeledStatement(i, u, d, e) : this.parseExpressionStatement(i, d);
|
|
2350
|
+
}
|
|
2351
|
+
}, B.parseBreakContinueStatement = function(e, t) {
|
|
2352
|
+
var n = t === "break";
|
|
2353
|
+
this.next(), this.eat(T.semi) || this.insertSemicolon() ? e.label = null : this.type === T.name ? (e.label = this.parseIdent(), this.semicolon()) : this.unexpected();
|
|
2354
|
+
for (var r = 0; r < this.labels.length; ++r) {
|
|
2355
|
+
var i = this.labels[r];
|
|
2356
|
+
if ((e.label == null || i.name === e.label.name) && (i.kind != null && (n || i.kind === "loop") || e.label && n)) break;
|
|
2357
|
+
}
|
|
2358
|
+
return r === this.labels.length && this.raise(e.start, "Unsyntactic " + t), this.finishNode(e, n ? "BreakStatement" : "ContinueStatement");
|
|
2359
|
+
}, B.parseDebuggerStatement = function(e) {
|
|
2360
|
+
return this.next(), this.semicolon(), this.finishNode(e, "DebuggerStatement");
|
|
2361
|
+
}, B.parseDoStatement = function(e) {
|
|
2362
|
+
return this.next(), this.labels.push(ze), e.body = this.parseStatement("do"), this.labels.pop(), this.expect(T._while), e.test = this.parseParenExpression(), this.options.ecmaVersion >= 6 ? this.eat(T.semi) : this.semicolon(), this.finishNode(e, "DoWhileStatement");
|
|
2363
|
+
}, B.parseForStatement = function(e) {
|
|
2364
|
+
this.next();
|
|
2365
|
+
var t = this.options.ecmaVersion >= 9 && this.canAwait && this.eatContextual("await") ? this.lastTokStart : -1;
|
|
2366
|
+
if (this.labels.push(ze), this.enterScope(0), this.expect(T.parenL), this.type === T.semi) return t > -1 && this.unexpected(t), this.parseFor(e, null);
|
|
2367
|
+
var n = this.isLet();
|
|
2368
|
+
if (this.type === T._var || this.type === T._const || n) {
|
|
2369
|
+
var r = this.startNode(), i = n ? "let" : this.value;
|
|
2370
|
+
return this.next(), this.parseVar(r, !0, i), this.finishNode(r, "VariableDeclaration"), this.parseForAfterInit(e, r, t);
|
|
2371
|
+
}
|
|
2372
|
+
var a = this.isContextual("let"), o = !1, s = this.isUsing(!0) ? "using" : this.isAwaitUsing(!0) ? "await using" : null;
|
|
2373
|
+
if (s) {
|
|
2374
|
+
var c = this.startNode();
|
|
2375
|
+
return this.next(), s === "await using" && (this.canAwait || this.raise(this.start, "Await using cannot appear outside of async function"), this.next()), this.parseVar(c, !0, s), this.finishNode(c, "VariableDeclaration"), this.parseForAfterInit(e, c, t);
|
|
2376
|
+
}
|
|
2377
|
+
var l = this.containsEsc, u = new Re(), d = this.start, f = t > -1 ? this.parseExprSubscripts(u, "await") : this.parseExpression(!0, u);
|
|
2378
|
+
return this.type === T._in || (o = this.options.ecmaVersion >= 6 && this.isContextual("of")) ? (t > -1 ? (this.type === T._in && this.unexpected(t), e.await = !0) : o && this.options.ecmaVersion >= 8 && (f.start === d && !l && f.type === "Identifier" && f.name === "async" ? this.unexpected() : this.options.ecmaVersion >= 9 && (e.await = !1)), a && o && this.raise(f.start, "The left-hand side of a for-of loop may not start with 'let'."), this.toAssignable(f, !1, u), this.checkLValPattern(f), this.parseForIn(e, f)) : (this.checkExpressionErrors(u, !0), t > -1 && this.unexpected(t), this.parseFor(e, f));
|
|
2379
|
+
}, B.parseForAfterInit = function(e, t, n) {
|
|
2380
|
+
return (this.type === T._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) && t.declarations.length === 1 ? (this.type === T._in ? ((t.kind === "using" || t.kind === "await using") && !t.declarations[0].init && this.raise(this.start, "Using declaration is not allowed in for-in loops"), this.options.ecmaVersion >= 9 && n > -1 && this.unexpected(n)) : this.options.ecmaVersion >= 9 && (e.await = n > -1), this.parseForIn(e, t)) : (n > -1 && this.unexpected(n), this.parseFor(e, t));
|
|
2381
|
+
}, B.parseFunctionStatement = function(e, t, n) {
|
|
2382
|
+
return this.next(), this.parseFunction(e, He | (n ? 0 : Ue), !1, t);
|
|
2383
|
+
}, B.parseIfStatement = function(e) {
|
|
2384
|
+
return this.next(), e.test = this.parseParenExpression(), e.consequent = this.parseStatement("if"), e.alternate = this.eat(T._else) ? this.parseStatement("if") : null, this.finishNode(e, "IfStatement");
|
|
2385
|
+
}, B.parseReturnStatement = function(e) {
|
|
2386
|
+
return this.allowReturn || this.raise(this.start, "'return' outside of function"), this.next(), this.eat(T.semi) || this.insertSemicolon() ? e.argument = null : (e.argument = this.parseExpression(), this.semicolon()), this.finishNode(e, "ReturnStatement");
|
|
2387
|
+
}, B.parseSwitchStatement = function(e) {
|
|
2388
|
+
this.next(), e.discriminant = this.parseParenExpression(), e.cases = [], this.expect(T.braceL), this.labels.push(Be), this.enterScope(ke);
|
|
2389
|
+
for (var t, n = !1; this.type !== T.braceR;) if (this.type === T._case || this.type === T._default) {
|
|
2390
|
+
var r = this.type === T._case;
|
|
2391
|
+
t && this.finishNode(t, "SwitchCase"), e.cases.push(t = this.startNode()), t.consequent = [], this.next(), r ? t.test = this.parseExpression() : (n && this.raiseRecoverable(this.lastTokStart, "Multiple default clauses"), n = !0, t.test = null), this.expect(T.colon);
|
|
2392
|
+
} else t || this.unexpected(), t.consequent.push(this.parseStatement(null));
|
|
2393
|
+
return this.exitScope(), t && this.finishNode(t, "SwitchCase"), this.next(), this.labels.pop(), this.finishNode(e, "SwitchStatement");
|
|
2394
|
+
}, B.parseThrowStatement = function(e) {
|
|
2395
|
+
return this.next(), E.test(this.input.slice(this.lastTokEnd, this.start)) && this.raise(this.lastTokEnd, "Illegal newline after throw"), e.argument = this.parseExpression(), this.semicolon(), this.finishNode(e, "ThrowStatement");
|
|
2396
|
+
};
|
|
2397
|
+
var Ve = [];
|
|
2398
|
+
B.parseCatchClauseParam = function() {
|
|
2399
|
+
var e = this.parseBindingAtom(), t = e.type === "Identifier";
|
|
2400
|
+
return this.enterScope(t ? Te : 0), this.checkLValPattern(e, t ? Fe : I), this.expect(T.parenR), e;
|
|
2401
|
+
}, B.parseTryStatement = function(e) {
|
|
2402
|
+
if (this.next(), e.block = this.parseBlock(), e.handler = null, this.type === T._catch) {
|
|
2403
|
+
var t = this.startNode();
|
|
2404
|
+
this.next(), this.eat(T.parenL) ? t.param = this.parseCatchClauseParam() : (this.options.ecmaVersion < 10 && this.unexpected(), t.param = null, this.enterScope(0)), t.body = this.parseBlock(!1), this.exitScope(), e.handler = this.finishNode(t, "CatchClause");
|
|
2405
|
+
}
|
|
2406
|
+
return e.finalizer = this.eat(T._finally) ? this.parseBlock() : null, !e.handler && !e.finalizer && this.raise(e.start, "Missing catch or finally clause"), this.finishNode(e, "TryStatement");
|
|
2407
|
+
}, B.parseVarStatement = function(e, t, n) {
|
|
2408
|
+
return this.next(), this.parseVar(e, !1, t, n), this.semicolon(), this.finishNode(e, "VariableDeclaration");
|
|
2409
|
+
}, B.parseWhileStatement = function(e) {
|
|
2410
|
+
return this.next(), e.test = this.parseParenExpression(), this.labels.push(ze), e.body = this.parseStatement("while"), this.labels.pop(), this.finishNode(e, "WhileStatement");
|
|
2411
|
+
}, B.parseWithStatement = function(e) {
|
|
2412
|
+
return this.strict && this.raise(this.start, "'with' in strict mode"), this.next(), e.object = this.parseParenExpression(), e.body = this.parseStatement("with"), this.finishNode(e, "WithStatement");
|
|
2413
|
+
}, B.parseEmptyStatement = function(e) {
|
|
2414
|
+
return this.next(), this.finishNode(e, "EmptyStatement");
|
|
2415
|
+
}, B.parseLabeledStatement = function(e, t, n, r) {
|
|
2416
|
+
for (var i = 0, a = this.labels; i < a.length; i += 1) a[i].name === t && this.raise(n.start, "Label '" + t + "' is already declared");
|
|
2417
|
+
for (var o = this.type.isLoop ? "loop" : this.type === T._switch ? "switch" : null, s = this.labels.length - 1; s >= 0; s--) {
|
|
2418
|
+
var c = this.labels[s];
|
|
2419
|
+
if (c.statementStart === e.start) c.statementStart = this.start, c.kind = o;
|
|
2420
|
+
else break;
|
|
2421
|
+
}
|
|
2422
|
+
return this.labels.push({
|
|
2423
|
+
name: t,
|
|
2424
|
+
kind: o,
|
|
2425
|
+
statementStart: this.start
|
|
2426
|
+
}), e.body = this.parseStatement(r ? r.indexOf("label") === -1 ? r + "label" : r : "label"), this.labels.pop(), e.label = n, this.finishNode(e, "LabeledStatement");
|
|
2427
|
+
}, B.parseExpressionStatement = function(e, t) {
|
|
2428
|
+
return e.expression = t, this.semicolon(), this.finishNode(e, "ExpressionStatement");
|
|
2429
|
+
}, B.parseBlock = function(e, t, n) {
|
|
2430
|
+
for (e === void 0 && (e = !0), t === void 0 && (t = this.startNode()), t.body = [], this.expect(T.braceL), e && this.enterScope(0); this.type !== T.braceR;) {
|
|
2431
|
+
var r = this.parseStatement(null);
|
|
2432
|
+
t.body.push(r);
|
|
2433
|
+
}
|
|
2434
|
+
return n && (this.strict = !1), this.next(), e && this.exitScope(), this.finishNode(t, "BlockStatement");
|
|
2435
|
+
}, B.parseFor = function(e, t) {
|
|
2436
|
+
return e.init = t, this.expect(T.semi), e.test = this.type === T.semi ? null : this.parseExpression(), this.expect(T.semi), e.update = this.type === T.parenR ? null : this.parseExpression(), this.expect(T.parenR), e.body = this.parseStatement("for"), this.exitScope(), this.labels.pop(), this.finishNode(e, "ForStatement");
|
|
2437
|
+
}, B.parseForIn = function(e, t) {
|
|
2438
|
+
var n = this.type === T._in;
|
|
2439
|
+
return this.next(), t.type === "VariableDeclaration" && t.declarations[0].init != null && (!n || this.options.ecmaVersion < 8 || this.strict || t.kind !== "var" || t.declarations[0].id.type !== "Identifier") && this.raise(t.start, (n ? "for-in" : "for-of") + " loop variable declaration may not have an initializer"), e.left = t, e.right = n ? this.parseExpression() : this.parseMaybeAssign(), this.expect(T.parenR), e.body = this.parseStatement("for"), this.exitScope(), this.labels.pop(), this.finishNode(e, n ? "ForInStatement" : "ForOfStatement");
|
|
2440
|
+
}, B.parseVar = function(e, t, n, r) {
|
|
2441
|
+
for (e.declarations = [], e.kind = n;;) {
|
|
2442
|
+
var i = this.startNode();
|
|
2443
|
+
if (this.parseVarId(i, n), this.eat(T.eq) ? i.init = this.parseMaybeAssign(t) : !r && n === "const" && !(this.type === T._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) ? this.unexpected() : !r && (n === "using" || n === "await using") && this.options.ecmaVersion >= 17 && this.type !== T._in && !this.isContextual("of") ? this.raise(this.lastTokEnd, "Missing initializer in " + n + " declaration") : !r && i.id.type !== "Identifier" && !(t && (this.type === T._in || this.isContextual("of"))) ? this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value") : i.init = null, e.declarations.push(this.finishNode(i, "VariableDeclarator")), !this.eat(T.comma)) break;
|
|
2444
|
+
}
|
|
2445
|
+
return e;
|
|
2446
|
+
}, B.parseVarId = function(e, t) {
|
|
2447
|
+
e.id = t === "using" || t === "await using" ? this.parseIdent() : this.parseBindingAtom(), this.checkLValPattern(e.id, t === "var" ? Ne : I, !1);
|
|
2448
|
+
};
|
|
2449
|
+
var He = 1, Ue = 2, We = 4;
|
|
2450
|
+
B.parseFunction = function(e, t, n, r, i) {
|
|
2451
|
+
this.initFunction(e), (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !r) && (this.type === T.star && t & Ue && this.unexpected(), e.generator = this.eat(T.star)), this.options.ecmaVersion >= 8 && (e.async = !!r), t & He && (e.id = t & We && this.type !== T.name ? null : this.parseIdent(), e.id && !(t & Ue) && this.checkLValSimple(e.id, this.strict || e.generator || e.async ? this.treatFunctionsAsVar ? Ne : I : Pe));
|
|
2452
|
+
var a = this.yieldPos, o = this.awaitPos, s = this.awaitIdentPos;
|
|
2453
|
+
return this.yieldPos = 0, this.awaitPos = 0, this.awaitIdentPos = 0, this.enterScope(je(e.async, e.generator)), t & He || (e.id = this.type === T.name ? this.parseIdent() : null), this.parseFunctionParams(e), this.parseFunctionBody(e, n, !1, i), this.yieldPos = a, this.awaitPos = o, this.awaitIdentPos = s, this.finishNode(e, t & He ? "FunctionDeclaration" : "FunctionExpression");
|
|
2454
|
+
}, B.parseFunctionParams = function(e) {
|
|
2455
|
+
this.expect(T.parenL), e.params = this.parseBindingList(T.parenR, !1, this.options.ecmaVersion >= 8), this.checkYieldAwaitInDefaultParams();
|
|
2456
|
+
}, B.parseClass = function(e, t) {
|
|
2457
|
+
this.next();
|
|
2458
|
+
var n = this.strict;
|
|
2459
|
+
this.strict = !0, this.parseClassId(e, t), this.parseClassSuper(e);
|
|
2460
|
+
var r = this.enterClassBody(), i = this.startNode(), a = !1;
|
|
2461
|
+
for (i.body = [], this.expect(T.braceL); this.type !== T.braceR;) {
|
|
2462
|
+
var o = this.parseClassElement(e.superClass !== null);
|
|
2463
|
+
o && (i.body.push(o), o.type === "MethodDefinition" && o.kind === "constructor" ? (a && this.raiseRecoverable(o.start, "Duplicate constructor in the same class"), a = !0) : o.key && o.key.type === "PrivateIdentifier" && Ge(r, o) && this.raiseRecoverable(o.key.start, "Identifier '#" + o.key.name + "' has already been declared"));
|
|
2464
|
+
}
|
|
2465
|
+
return this.strict = n, this.next(), e.body = this.finishNode(i, "ClassBody"), this.exitClassBody(), this.finishNode(e, t ? "ClassDeclaration" : "ClassExpression");
|
|
2466
|
+
}, B.parseClassElement = function(e) {
|
|
2467
|
+
if (this.eat(T.semi)) return null;
|
|
2468
|
+
var t = this.options.ecmaVersion, n = this.startNode(), r = "", i = !1, a = !1, o = "method", s = !1;
|
|
2469
|
+
if (this.eatContextual("static")) {
|
|
2470
|
+
if (t >= 13 && this.eat(T.braceL)) return this.parseClassStaticBlock(n), n;
|
|
2471
|
+
this.isClassElementNameStart() || this.type === T.star ? s = !0 : r = "static";
|
|
2472
|
+
}
|
|
2473
|
+
if (n.static = s, !r && t >= 8 && this.eatContextual("async") && ((this.isClassElementNameStart() || this.type === T.star) && !this.canInsertSemicolon() ? a = !0 : r = "async"), !r && (t >= 9 || !a) && this.eat(T.star) && (i = !0), !r && !a && !i) {
|
|
2474
|
+
var c = this.value;
|
|
2475
|
+
(this.eatContextual("get") || this.eatContextual("set")) && (this.isClassElementNameStart() ? o = c : r = c);
|
|
2476
|
+
}
|
|
2477
|
+
if (r ? (n.computed = !1, n.key = this.startNodeAt(this.lastTokStart, this.lastTokStartLoc), n.key.name = r, this.finishNode(n.key, "Identifier")) : this.parseClassElementName(n), t < 13 || this.type === T.parenL || o !== "method" || i || a) {
|
|
2478
|
+
var l = !n.static && Ke(n, "constructor"), u = l && e;
|
|
2479
|
+
l && o !== "method" && this.raise(n.key.start, "Constructor can't have get/set modifier"), n.kind = l ? "constructor" : o, this.parseClassMethod(n, i, a, u);
|
|
2480
|
+
} else this.parseClassField(n);
|
|
2481
|
+
return n;
|
|
2482
|
+
}, B.isClassElementNameStart = function() {
|
|
2483
|
+
return this.type === T.name || this.type === T.privateId || this.type === T.num || this.type === T.string || this.type === T.bracketL || this.type.keyword;
|
|
2484
|
+
}, B.parseClassElementName = function(e) {
|
|
2485
|
+
this.type === T.privateId ? (this.value === "constructor" && this.raise(this.start, "Classes can't have an element named '#constructor'"), e.computed = !1, e.key = this.parsePrivateIdent()) : this.parsePropertyName(e);
|
|
2486
|
+
}, B.parseClassMethod = function(e, t, n, r) {
|
|
2487
|
+
var i = e.key;
|
|
2488
|
+
e.kind === "constructor" ? (t && this.raise(i.start, "Constructor can't be a generator"), n && this.raise(i.start, "Constructor can't be an async method")) : e.static && Ke(e, "prototype") && this.raise(i.start, "Classes may not have a static property named prototype");
|
|
2489
|
+
var a = e.value = this.parseMethod(t, n, r);
|
|
2490
|
+
return e.kind === "get" && a.params.length !== 0 && this.raiseRecoverable(a.start, "getter should have no params"), e.kind === "set" && a.params.length !== 1 && this.raiseRecoverable(a.start, "setter should have exactly one param"), e.kind === "set" && a.params[0].type === "RestElement" && this.raiseRecoverable(a.params[0].start, "Setter cannot use rest params"), this.finishNode(e, "MethodDefinition");
|
|
2491
|
+
}, B.parseClassField = function(e) {
|
|
2492
|
+
return Ke(e, "constructor") ? this.raise(e.key.start, "Classes can't have a field named 'constructor'") : e.static && Ke(e, "prototype") && this.raise(e.key.start, "Classes can't have a static field named 'prototype'"), this.eat(T.eq) ? (this.enterScope(Oe | Ee), e.value = this.parseMaybeAssign(), this.exitScope()) : e.value = null, this.semicolon(), this.finishNode(e, "PropertyDefinition");
|
|
2493
|
+
}, B.parseClassStaticBlock = function(e) {
|
|
2494
|
+
e.body = [];
|
|
2495
|
+
var t = this.labels;
|
|
2496
|
+
for (this.labels = [], this.enterScope(F | Ee); this.type !== T.braceR;) {
|
|
2497
|
+
var n = this.parseStatement(null);
|
|
2498
|
+
e.body.push(n);
|
|
2499
|
+
}
|
|
2500
|
+
return this.next(), this.exitScope(), this.labels = t, this.finishNode(e, "StaticBlock");
|
|
2501
|
+
}, B.parseClassId = function(e, t) {
|
|
2502
|
+
this.type === T.name ? (e.id = this.parseIdent(), t && this.checkLValSimple(e.id, I, !1)) : (t === !0 && this.unexpected(), e.id = null);
|
|
2503
|
+
}, B.parseClassSuper = function(e) {
|
|
2504
|
+
e.superClass = this.eat(T._extends) ? this.parseExprSubscripts(null, !1) : null;
|
|
2505
|
+
}, B.enterClassBody = function() {
|
|
2506
|
+
var e = {
|
|
2507
|
+
declared: Object.create(null),
|
|
2508
|
+
used: []
|
|
2509
|
+
};
|
|
2510
|
+
return this.privateNameStack.push(e), e.declared;
|
|
2511
|
+
}, B.exitClassBody = function() {
|
|
2512
|
+
var e = this.privateNameStack.pop(), t = e.declared, n = e.used;
|
|
2513
|
+
if (this.options.checkPrivateFields) for (var r = this.privateNameStack.length, i = r === 0 ? null : this.privateNameStack[r - 1], a = 0; a < n.length; ++a) {
|
|
2514
|
+
var o = n[a];
|
|
2515
|
+
k(t, o.name) || (i ? i.used.push(o) : this.raiseRecoverable(o.start, "Private field '#" + o.name + "' must be declared in an enclosing class"));
|
|
2516
|
+
}
|
|
2517
|
+
};
|
|
2518
|
+
function Ge(e, t) {
|
|
2519
|
+
var n = t.key.name, r = e[n], i = "true";
|
|
2520
|
+
return t.type === "MethodDefinition" && (t.kind === "get" || t.kind === "set") && (i = (t.static ? "s" : "i") + t.kind), r === "iget" && i === "iset" || r === "iset" && i === "iget" || r === "sget" && i === "sset" || r === "sset" && i === "sget" ? (e[n] = "true", !1) : r ? !0 : (e[n] = i, !1);
|
|
2521
|
+
}
|
|
2522
|
+
function Ke(e, t) {
|
|
2523
|
+
var n = e.computed, r = e.key;
|
|
2524
|
+
return !n && (r.type === "Identifier" && r.name === t || r.type === "Literal" && r.value === t);
|
|
2525
|
+
}
|
|
2526
|
+
B.parseExportAllDeclaration = function(e, t) {
|
|
2527
|
+
return this.options.ecmaVersion >= 11 && (this.eatContextual("as") ? (e.exported = this.parseModuleExportName(), this.checkExport(t, e.exported, this.lastTokStart)) : e.exported = null), this.expectContextual("from"), this.type !== T.string && this.unexpected(), e.source = this.parseExprAtom(), this.options.ecmaVersion >= 16 && (e.attributes = this.parseWithClause()), this.semicolon(), this.finishNode(e, "ExportAllDeclaration");
|
|
2528
|
+
}, B.parseExport = function(e, t) {
|
|
2529
|
+
if (this.next(), this.eat(T.star)) return this.parseExportAllDeclaration(e, t);
|
|
2530
|
+
if (this.eat(T._default)) return this.checkExport(t, "default", this.lastTokStart), e.declaration = this.parseExportDefaultDeclaration(), this.finishNode(e, "ExportDefaultDeclaration");
|
|
2531
|
+
if (this.shouldParseExportStatement()) e.declaration = this.parseExportDeclaration(e), e.declaration.type === "VariableDeclaration" ? this.checkVariableExport(t, e.declaration.declarations) : this.checkExport(t, e.declaration.id, e.declaration.id.start), e.specifiers = [], e.source = null, this.options.ecmaVersion >= 16 && (e.attributes = []);
|
|
2532
|
+
else {
|
|
2533
|
+
if (e.declaration = null, e.specifiers = this.parseExportSpecifiers(t), this.eatContextual("from")) this.type !== T.string && this.unexpected(), e.source = this.parseExprAtom(), this.options.ecmaVersion >= 16 && (e.attributes = this.parseWithClause());
|
|
2534
|
+
else {
|
|
2535
|
+
for (var n = 0, r = e.specifiers; n < r.length; n += 1) {
|
|
2536
|
+
var i = r[n];
|
|
2537
|
+
this.checkUnreserved(i.local), this.checkLocalExport(i.local), i.local.type === "Literal" && this.raise(i.local.start, "A string literal cannot be used as an exported binding without `from`.");
|
|
2538
|
+
}
|
|
2539
|
+
e.source = null, this.options.ecmaVersion >= 16 && (e.attributes = []);
|
|
2540
|
+
}
|
|
2541
|
+
this.semicolon();
|
|
2542
|
+
}
|
|
2543
|
+
return this.finishNode(e, "ExportNamedDeclaration");
|
|
2544
|
+
}, B.parseExportDeclaration = function(e) {
|
|
2545
|
+
return this.parseStatement(null);
|
|
2546
|
+
}, B.parseExportDefaultDeclaration = function() {
|
|
2547
|
+
var e;
|
|
2548
|
+
if (this.type === T._function || (e = this.isAsyncFunction())) {
|
|
2549
|
+
var t = this.startNode();
|
|
2550
|
+
return this.next(), e && this.next(), this.parseFunction(t, He | We, !1, e);
|
|
2551
|
+
} else if (this.type === T._class) {
|
|
2552
|
+
var n = this.startNode();
|
|
2553
|
+
return this.parseClass(n, "nullableID");
|
|
2554
|
+
} else {
|
|
2555
|
+
var r = this.parseMaybeAssign();
|
|
2556
|
+
return this.semicolon(), r;
|
|
2557
|
+
}
|
|
2558
|
+
}, B.checkExport = function(e, t, n) {
|
|
2559
|
+
e && (typeof t != "string" && (t = t.type === "Identifier" ? t.name : t.value), k(e, t) && this.raiseRecoverable(n, "Duplicate export '" + t + "'"), e[t] = !0);
|
|
2560
|
+
}, B.checkPatternExport = function(e, t) {
|
|
2561
|
+
var n = t.type;
|
|
2562
|
+
if (n === "Identifier") this.checkExport(e, t, t.start);
|
|
2563
|
+
else if (n === "ObjectPattern") for (var r = 0, i = t.properties; r < i.length; r += 1) {
|
|
2564
|
+
var a = i[r];
|
|
2565
|
+
this.checkPatternExport(e, a);
|
|
2566
|
+
}
|
|
2567
|
+
else if (n === "ArrayPattern") for (var o = 0, s = t.elements; o < s.length; o += 1) {
|
|
2568
|
+
var c = s[o];
|
|
2569
|
+
c && this.checkPatternExport(e, c);
|
|
2570
|
+
}
|
|
2571
|
+
else n === "Property" ? this.checkPatternExport(e, t.value) : n === "AssignmentPattern" ? this.checkPatternExport(e, t.left) : n === "RestElement" && this.checkPatternExport(e, t.argument);
|
|
2572
|
+
}, B.checkVariableExport = function(e, t) {
|
|
2573
|
+
if (e) for (var n = 0, r = t; n < r.length; n += 1) {
|
|
2574
|
+
var i = r[n];
|
|
2575
|
+
this.checkPatternExport(e, i.id);
|
|
2576
|
+
}
|
|
2577
|
+
}, B.shouldParseExportStatement = function() {
|
|
2578
|
+
return this.type.keyword === "var" || this.type.keyword === "const" || this.type.keyword === "class" || this.type.keyword === "function" || this.isLet() || this.isAsyncFunction();
|
|
2579
|
+
}, B.parseExportSpecifier = function(e) {
|
|
2580
|
+
var t = this.startNode();
|
|
2581
|
+
return t.local = this.parseModuleExportName(), t.exported = this.eatContextual("as") ? this.parseModuleExportName() : t.local, this.checkExport(e, t.exported, t.exported.start), this.finishNode(t, "ExportSpecifier");
|
|
2582
|
+
}, B.parseExportSpecifiers = function(e) {
|
|
2583
|
+
var t = [], n = !0;
|
|
2584
|
+
for (this.expect(T.braceL); !this.eat(T.braceR);) {
|
|
2585
|
+
if (n) n = !1;
|
|
2586
|
+
else if (this.expect(T.comma), this.afterTrailingComma(T.braceR)) break;
|
|
2587
|
+
t.push(this.parseExportSpecifier(e));
|
|
2588
|
+
}
|
|
2589
|
+
return t;
|
|
2590
|
+
}, B.parseImport = function(e) {
|
|
2591
|
+
return this.next(), this.type === T.string ? (e.specifiers = Ve, e.source = this.parseExprAtom()) : (e.specifiers = this.parseImportSpecifiers(), this.expectContextual("from"), e.source = this.type === T.string ? this.parseExprAtom() : this.unexpected()), this.options.ecmaVersion >= 16 && (e.attributes = this.parseWithClause()), this.semicolon(), this.finishNode(e, "ImportDeclaration");
|
|
2592
|
+
}, B.parseImportSpecifier = function() {
|
|
2593
|
+
var e = this.startNode();
|
|
2594
|
+
return e.imported = this.parseModuleExportName(), this.eatContextual("as") ? e.local = this.parseIdent() : (this.checkUnreserved(e.imported), e.local = e.imported), this.checkLValSimple(e.local, I), this.finishNode(e, "ImportSpecifier");
|
|
2595
|
+
}, B.parseImportDefaultSpecifier = function() {
|
|
2596
|
+
var e = this.startNode();
|
|
2597
|
+
return e.local = this.parseIdent(), this.checkLValSimple(e.local, I), this.finishNode(e, "ImportDefaultSpecifier");
|
|
2598
|
+
}, B.parseImportNamespaceSpecifier = function() {
|
|
2599
|
+
var e = this.startNode();
|
|
2600
|
+
return this.next(), this.expectContextual("as"), e.local = this.parseIdent(), this.checkLValSimple(e.local, I), this.finishNode(e, "ImportNamespaceSpecifier");
|
|
2601
|
+
}, B.parseImportSpecifiers = function() {
|
|
2602
|
+
var e = [], t = !0;
|
|
2603
|
+
if (this.type === T.name && (e.push(this.parseImportDefaultSpecifier()), !this.eat(T.comma))) return e;
|
|
2604
|
+
if (this.type === T.star) return e.push(this.parseImportNamespaceSpecifier()), e;
|
|
2605
|
+
for (this.expect(T.braceL); !this.eat(T.braceR);) {
|
|
2606
|
+
if (t) t = !1;
|
|
2607
|
+
else if (this.expect(T.comma), this.afterTrailingComma(T.braceR)) break;
|
|
2608
|
+
e.push(this.parseImportSpecifier());
|
|
2609
|
+
}
|
|
2610
|
+
return e;
|
|
2611
|
+
}, B.parseWithClause = function() {
|
|
2612
|
+
var e = [];
|
|
2613
|
+
if (!this.eat(T._with)) return e;
|
|
2614
|
+
this.expect(T.braceL);
|
|
2615
|
+
for (var t = {}, n = !0; !this.eat(T.braceR);) {
|
|
2616
|
+
if (n) n = !1;
|
|
2617
|
+
else if (this.expect(T.comma), this.afterTrailingComma(T.braceR)) break;
|
|
2618
|
+
var r = this.parseImportAttribute(), i = r.key.type === "Identifier" ? r.key.name : r.key.value;
|
|
2619
|
+
k(t, i) && this.raiseRecoverable(r.key.start, "Duplicate attribute key '" + i + "'"), t[i] = !0, e.push(r);
|
|
2620
|
+
}
|
|
2621
|
+
return e;
|
|
2622
|
+
}, B.parseImportAttribute = function() {
|
|
2623
|
+
var e = this.startNode();
|
|
2624
|
+
return e.key = this.type === T.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never"), this.expect(T.colon), this.type !== T.string && this.unexpected(), e.value = this.parseExprAtom(), this.finishNode(e, "ImportAttribute");
|
|
2625
|
+
}, B.parseModuleExportName = function() {
|
|
2626
|
+
if (this.options.ecmaVersion >= 13 && this.type === T.string) {
|
|
2627
|
+
var e = this.parseLiteral(this.value);
|
|
2628
|
+
return he.test(e.value) && this.raise(e.start, "An export name cannot include a lone surrogate."), e;
|
|
2629
|
+
}
|
|
2630
|
+
return this.parseIdent(!0);
|
|
2631
|
+
}, B.adaptDirectivePrologue = function(e) {
|
|
2632
|
+
for (var t = 0; t < e.length && this.isDirectiveCandidate(e[t]); ++t) e[t].directive = e[t].expression.raw.slice(1, -1);
|
|
2633
|
+
}, B.isDirectiveCandidate = function(e) {
|
|
2634
|
+
return this.options.ecmaVersion >= 5 && e.type === "ExpressionStatement" && e.expression.type === "Literal" && typeof e.expression.value == "string" && (this.input[e.start] === "\"" || this.input[e.start] === "'");
|
|
2635
|
+
};
|
|
2636
|
+
var V = L.prototype;
|
|
2637
|
+
V.toAssignable = function(e, t, n) {
|
|
2638
|
+
if (this.options.ecmaVersion >= 6 && e) switch (e.type) {
|
|
2639
|
+
case "Identifier":
|
|
2640
|
+
this.inAsync && e.name === "await" && this.raise(e.start, "Cannot use 'await' as identifier inside an async function");
|
|
2641
|
+
break;
|
|
2642
|
+
case "ObjectPattern":
|
|
2643
|
+
case "ArrayPattern":
|
|
2644
|
+
case "AssignmentPattern":
|
|
2645
|
+
case "RestElement": break;
|
|
2646
|
+
case "ObjectExpression":
|
|
2647
|
+
e.type = "ObjectPattern", n && this.checkPatternErrors(n, !0);
|
|
2648
|
+
for (var r = 0, i = e.properties; r < i.length; r += 1) {
|
|
2649
|
+
var a = i[r];
|
|
2650
|
+
this.toAssignable(a, t), a.type === "RestElement" && (a.argument.type === "ArrayPattern" || a.argument.type === "ObjectPattern") && this.raise(a.argument.start, "Unexpected token");
|
|
2651
|
+
}
|
|
2652
|
+
break;
|
|
2653
|
+
case "Property":
|
|
2654
|
+
e.kind !== "init" && this.raise(e.key.start, "Object pattern can't contain getter or setter"), this.toAssignable(e.value, t);
|
|
2655
|
+
break;
|
|
2656
|
+
case "ArrayExpression":
|
|
2657
|
+
e.type = "ArrayPattern", n && this.checkPatternErrors(n, !0), this.toAssignableList(e.elements, t);
|
|
2658
|
+
break;
|
|
2659
|
+
case "SpreadElement":
|
|
2660
|
+
e.type = "RestElement", this.toAssignable(e.argument, t), e.argument.type === "AssignmentPattern" && this.raise(e.argument.start, "Rest elements cannot have a default value");
|
|
2661
|
+
break;
|
|
2662
|
+
case "AssignmentExpression":
|
|
2663
|
+
e.operator !== "=" && this.raise(e.left.end, "Only '=' operator can be used for specifying default value."), e.type = "AssignmentPattern", delete e.operator, this.toAssignable(e.left, t);
|
|
2664
|
+
break;
|
|
2665
|
+
case "ParenthesizedExpression":
|
|
2666
|
+
this.toAssignable(e.expression, t, n);
|
|
2667
|
+
break;
|
|
2668
|
+
case "ChainExpression":
|
|
2669
|
+
this.raiseRecoverable(e.start, "Optional chaining cannot appear in left-hand side");
|
|
2670
|
+
break;
|
|
2671
|
+
case "MemberExpression": if (!t) break;
|
|
2672
|
+
default: this.raise(e.start, "Assigning to rvalue");
|
|
2673
|
+
}
|
|
2674
|
+
else n && this.checkPatternErrors(n, !0);
|
|
2675
|
+
return e;
|
|
2676
|
+
}, V.toAssignableList = function(e, t) {
|
|
2677
|
+
for (var n = e.length, r = 0; r < n; r++) {
|
|
2678
|
+
var i = e[r];
|
|
2679
|
+
i && this.toAssignable(i, t);
|
|
2680
|
+
}
|
|
2681
|
+
if (n) {
|
|
2682
|
+
var a = e[n - 1];
|
|
2683
|
+
this.options.ecmaVersion === 6 && t && a && a.type === "RestElement" && a.argument.type !== "Identifier" && this.unexpected(a.argument.start);
|
|
2684
|
+
}
|
|
2685
|
+
return e;
|
|
2686
|
+
}, V.parseSpread = function(e) {
|
|
2687
|
+
var t = this.startNode();
|
|
2688
|
+
return this.next(), t.argument = this.parseMaybeAssign(!1, e), this.finishNode(t, "SpreadElement");
|
|
2689
|
+
}, V.parseRestBinding = function() {
|
|
2690
|
+
var e = this.startNode();
|
|
2691
|
+
return this.next(), this.options.ecmaVersion === 6 && this.type !== T.name && this.unexpected(), e.argument = this.parseBindingAtom(), this.finishNode(e, "RestElement");
|
|
2692
|
+
}, V.parseBindingAtom = function() {
|
|
2693
|
+
if (this.options.ecmaVersion >= 6) switch (this.type) {
|
|
2694
|
+
case T.bracketL:
|
|
2695
|
+
var e = this.startNode();
|
|
2696
|
+
return this.next(), e.elements = this.parseBindingList(T.bracketR, !0, !0), this.finishNode(e, "ArrayPattern");
|
|
2697
|
+
case T.braceL: return this.parseObj(!0);
|
|
2698
|
+
}
|
|
2699
|
+
return this.parseIdent();
|
|
2700
|
+
}, V.parseBindingList = function(e, t, n, r) {
|
|
2701
|
+
for (var i = [], a = !0; !this.eat(e);) if (a ? a = !1 : this.expect(T.comma), t && this.type === T.comma) i.push(null);
|
|
2702
|
+
else if (n && this.afterTrailingComma(e)) break;
|
|
2703
|
+
else if (this.type === T.ellipsis) {
|
|
2704
|
+
var o = this.parseRestBinding();
|
|
2705
|
+
this.parseBindingListItem(o), i.push(o), this.type === T.comma && this.raiseRecoverable(this.start, "Comma is not permitted after the rest element"), this.expect(e);
|
|
2706
|
+
break;
|
|
2707
|
+
} else i.push(this.parseAssignableListItem(r));
|
|
2708
|
+
return i;
|
|
2709
|
+
}, V.parseAssignableListItem = function(e) {
|
|
2710
|
+
var t = this.parseMaybeDefault(this.start, this.startLoc);
|
|
2711
|
+
return this.parseBindingListItem(t), t;
|
|
2712
|
+
}, V.parseBindingListItem = function(e) {
|
|
2713
|
+
return e;
|
|
2714
|
+
}, V.parseMaybeDefault = function(e, t, n) {
|
|
2715
|
+
if (n ||= this.parseBindingAtom(), this.options.ecmaVersion < 6 || !this.eat(T.eq)) return n;
|
|
2716
|
+
var r = this.startNodeAt(e, t);
|
|
2717
|
+
return r.left = n, r.right = this.parseMaybeAssign(), this.finishNode(r, "AssignmentPattern");
|
|
2718
|
+
}, V.checkLValSimple = function(e, t, n) {
|
|
2719
|
+
t === void 0 && (t = Me);
|
|
2720
|
+
var r = t !== Me;
|
|
2721
|
+
switch (e.type) {
|
|
2722
|
+
case "Identifier":
|
|
2723
|
+
this.strict && this.reservedWordsStrictBind.test(e.name) && this.raiseRecoverable(e.start, (r ? "Binding " : "Assigning to ") + e.name + " in strict mode"), r && (t === I && e.name === "let" && this.raiseRecoverable(e.start, "let is disallowed as a lexically bound name"), n && (k(n, e.name) && this.raiseRecoverable(e.start, "Argument name clash"), n[e.name] = !0), t !== Ie && this.declareName(e.name, t, e.start));
|
|
2724
|
+
break;
|
|
2725
|
+
case "ChainExpression":
|
|
2726
|
+
this.raiseRecoverable(e.start, "Optional chaining cannot appear in left-hand side");
|
|
2727
|
+
break;
|
|
2728
|
+
case "MemberExpression":
|
|
2729
|
+
r && this.raiseRecoverable(e.start, "Binding member expression");
|
|
2730
|
+
break;
|
|
2731
|
+
case "ParenthesizedExpression": return r && this.raiseRecoverable(e.start, "Binding parenthesized expression"), this.checkLValSimple(e.expression, t, n);
|
|
2732
|
+
default: this.raise(e.start, (r ? "Binding" : "Assigning to") + " rvalue");
|
|
2733
|
+
}
|
|
2734
|
+
}, V.checkLValPattern = function(e, t, n) {
|
|
2735
|
+
switch (t === void 0 && (t = Me), e.type) {
|
|
2736
|
+
case "ObjectPattern":
|
|
2737
|
+
for (var r = 0, i = e.properties; r < i.length; r += 1) {
|
|
2738
|
+
var a = i[r];
|
|
2739
|
+
this.checkLValInnerPattern(a, t, n);
|
|
2740
|
+
}
|
|
2741
|
+
break;
|
|
2742
|
+
case "ArrayPattern":
|
|
2743
|
+
for (var o = 0, s = e.elements; o < s.length; o += 1) {
|
|
2744
|
+
var c = s[o];
|
|
2745
|
+
c && this.checkLValInnerPattern(c, t, n);
|
|
2746
|
+
}
|
|
2747
|
+
break;
|
|
2748
|
+
default: this.checkLValSimple(e, t, n);
|
|
2749
|
+
}
|
|
2750
|
+
}, V.checkLValInnerPattern = function(e, t, n) {
|
|
2751
|
+
switch (t === void 0 && (t = Me), e.type) {
|
|
2752
|
+
case "Property":
|
|
2753
|
+
this.checkLValInnerPattern(e.value, t, n);
|
|
2754
|
+
break;
|
|
2755
|
+
case "AssignmentPattern":
|
|
2756
|
+
this.checkLValPattern(e.left, t, n);
|
|
2757
|
+
break;
|
|
2758
|
+
case "RestElement":
|
|
2759
|
+
this.checkLValPattern(e.argument, t, n);
|
|
2760
|
+
break;
|
|
2761
|
+
default: this.checkLValPattern(e, t, n);
|
|
2762
|
+
}
|
|
2763
|
+
};
|
|
2764
|
+
var H = function(e, t, n, r, i) {
|
|
2765
|
+
this.token = e, this.isExpr = !!t, this.preserveSpace = !!n, this.override = r, this.generator = !!i;
|
|
2766
|
+
}, U = {
|
|
2767
|
+
b_stat: new H("{", !1),
|
|
2768
|
+
b_expr: new H("{", !0),
|
|
2769
|
+
b_tmpl: new H("${", !1),
|
|
2770
|
+
p_stat: new H("(", !1),
|
|
2771
|
+
p_expr: new H("(", !0),
|
|
2772
|
+
q_tmpl: new H("`", !0, !0, function(e) {
|
|
2773
|
+
return e.tryReadTemplateToken();
|
|
2774
|
+
}),
|
|
2775
|
+
f_stat: new H("function", !1),
|
|
2776
|
+
f_expr: new H("function", !0),
|
|
2777
|
+
f_expr_gen: new H("function", !0, !1, null, !0),
|
|
2778
|
+
f_gen: new H("function", !1, !1, null, !0)
|
|
2779
|
+
}, W = L.prototype;
|
|
2780
|
+
W.initialContext = function() {
|
|
2781
|
+
return [U.b_stat];
|
|
2782
|
+
}, W.curContext = function() {
|
|
2783
|
+
return this.context[this.context.length - 1];
|
|
2784
|
+
}, W.braceIsBlock = function(e) {
|
|
2785
|
+
var t = this.curContext();
|
|
2786
|
+
return t === U.f_expr || t === U.f_stat ? !0 : e === T.colon && (t === U.b_stat || t === U.b_expr) ? !t.isExpr : e === T._return || e === T.name && this.exprAllowed ? E.test(this.input.slice(this.lastTokEnd, this.start)) : e === T._else || e === T.semi || e === T.eof || e === T.parenR || e === T.arrow ? !0 : e === T.braceL ? t === U.b_stat : e === T._var || e === T._const || e === T.name ? !1 : !this.exprAllowed;
|
|
2787
|
+
}, W.inGeneratorContext = function() {
|
|
2788
|
+
for (var e = this.context.length - 1; e >= 1; e--) {
|
|
2789
|
+
var t = this.context[e];
|
|
2790
|
+
if (t.token === "function") return t.generator;
|
|
2791
|
+
}
|
|
2792
|
+
return !1;
|
|
2793
|
+
}, W.updateContext = function(e) {
|
|
2794
|
+
var t, n = this.type;
|
|
2795
|
+
n.keyword && e === T.dot ? this.exprAllowed = !1 : (t = n.updateContext) ? t.call(this, e) : this.exprAllowed = n.beforeExpr;
|
|
2796
|
+
}, W.overrideContext = function(e) {
|
|
2797
|
+
this.curContext() !== e && (this.context[this.context.length - 1] = e);
|
|
2798
|
+
}, T.parenR.updateContext = T.braceR.updateContext = function() {
|
|
2799
|
+
if (this.context.length === 1) {
|
|
2800
|
+
this.exprAllowed = !0;
|
|
2801
|
+
return;
|
|
2802
|
+
}
|
|
2803
|
+
var e = this.context.pop();
|
|
2804
|
+
e === U.b_stat && this.curContext().token === "function" && (e = this.context.pop()), this.exprAllowed = !e.isExpr;
|
|
2805
|
+
}, T.braceL.updateContext = function(e) {
|
|
2806
|
+
this.context.push(this.braceIsBlock(e) ? U.b_stat : U.b_expr), this.exprAllowed = !0;
|
|
2807
|
+
}, T.dollarBraceL.updateContext = function() {
|
|
2808
|
+
this.context.push(U.b_tmpl), this.exprAllowed = !0;
|
|
2809
|
+
}, T.parenL.updateContext = function(e) {
|
|
2810
|
+
var t = e === T._if || e === T._for || e === T._with || e === T._while;
|
|
2811
|
+
this.context.push(t ? U.p_stat : U.p_expr), this.exprAllowed = !0;
|
|
2812
|
+
}, T.incDec.updateContext = function() {}, T._function.updateContext = T._class.updateContext = function(e) {
|
|
2813
|
+
e.beforeExpr && e !== T._else && !(e === T.semi && this.curContext() !== U.p_stat) && !(e === T._return && E.test(this.input.slice(this.lastTokEnd, this.start))) && !((e === T.colon || e === T.braceL) && this.curContext() === U.b_stat) ? this.context.push(U.f_expr) : this.context.push(U.f_stat), this.exprAllowed = !1;
|
|
2814
|
+
}, T.colon.updateContext = function() {
|
|
2815
|
+
this.curContext().token === "function" && this.context.pop(), this.exprAllowed = !0;
|
|
2816
|
+
}, T.backQuote.updateContext = function() {
|
|
2817
|
+
this.curContext() === U.q_tmpl ? this.context.pop() : this.context.push(U.q_tmpl), this.exprAllowed = !1;
|
|
2818
|
+
}, T.star.updateContext = function(e) {
|
|
2819
|
+
if (e === T._function) {
|
|
2820
|
+
var t = this.context.length - 1;
|
|
2821
|
+
this.context[t] === U.f_expr ? this.context[t] = U.f_expr_gen : this.context[t] = U.f_gen;
|
|
2822
|
+
}
|
|
2823
|
+
this.exprAllowed = !0;
|
|
2824
|
+
}, T.name.updateContext = function(e) {
|
|
2825
|
+
var t = !1;
|
|
2826
|
+
this.options.ecmaVersion >= 6 && e !== T.dot && (this.value === "of" && !this.exprAllowed || this.value === "yield" && this.inGeneratorContext()) && (t = !0), this.exprAllowed = t;
|
|
2827
|
+
};
|
|
2828
|
+
var G = L.prototype;
|
|
2829
|
+
G.checkPropClash = function(e, t, n) {
|
|
2830
|
+
if (!(this.options.ecmaVersion >= 9 && e.type === "SpreadElement") && !(this.options.ecmaVersion >= 6 && (e.computed || e.method || e.shorthand))) {
|
|
2831
|
+
var r = e.key, i;
|
|
2832
|
+
switch (r.type) {
|
|
2833
|
+
case "Identifier":
|
|
2834
|
+
i = r.name;
|
|
2835
|
+
break;
|
|
2836
|
+
case "Literal":
|
|
2837
|
+
i = String(r.value);
|
|
2838
|
+
break;
|
|
2839
|
+
default: return;
|
|
2840
|
+
}
|
|
2841
|
+
var a = e.kind;
|
|
2842
|
+
if (this.options.ecmaVersion >= 6) {
|
|
2843
|
+
i === "__proto__" && a === "init" && (t.proto && (n ? n.doubleProto < 0 && (n.doubleProto = r.start) : this.raiseRecoverable(r.start, "Redefinition of __proto__ property")), t.proto = !0);
|
|
2844
|
+
return;
|
|
2845
|
+
}
|
|
2846
|
+
i = "$" + i;
|
|
2847
|
+
var o = t[i];
|
|
2848
|
+
o ? (a === "init" ? this.strict && o.init || o.get || o.set : o.init || o[a]) && this.raiseRecoverable(r.start, "Redefinition of property") : o = t[i] = {
|
|
2849
|
+
init: !1,
|
|
2850
|
+
get: !1,
|
|
2851
|
+
set: !1
|
|
2852
|
+
}, o[a] = !0;
|
|
2853
|
+
}
|
|
2854
|
+
}, G.parseExpression = function(e, t) {
|
|
2855
|
+
var n = this;
|
|
2856
|
+
return this.catchStackOverflow(function() {
|
|
2857
|
+
var r = n.start, i = n.startLoc, a = n.parseMaybeAssign(e, t);
|
|
2858
|
+
if (n.type === T.comma) {
|
|
2859
|
+
var o = n.startNodeAt(r, i);
|
|
2860
|
+
for (o.expressions = [a]; n.eat(T.comma);) o.expressions.push(n.parseMaybeAssign(e, t));
|
|
2861
|
+
return n.finishNode(o, "SequenceExpression");
|
|
2862
|
+
}
|
|
2863
|
+
return a;
|
|
2864
|
+
});
|
|
2865
|
+
}, G.parseMaybeAssign = function(e, t, n) {
|
|
2866
|
+
if (this.isContextual("yield")) {
|
|
2867
|
+
if (this.inGenerator) return this.parseYield(e);
|
|
2868
|
+
this.exprAllowed = !1;
|
|
2869
|
+
}
|
|
2870
|
+
var r = !1, i = -1, a = -1, o = -1;
|
|
2871
|
+
t ? (i = t.parenthesizedAssign, a = t.trailingComma, o = t.doubleProto, t.parenthesizedAssign = t.trailingComma = -1) : (t = new Re(), r = !0);
|
|
2872
|
+
var s = this.start, c = this.startLoc;
|
|
2873
|
+
(this.type === T.parenL || this.type === T.name) && (this.potentialArrowAt = this.start, this.potentialArrowInForAwait = e === "await");
|
|
2874
|
+
var l = this.parseMaybeConditional(e, t);
|
|
2875
|
+
if (n && (l = n.call(this, l, s, c)), this.type.isAssign) {
|
|
2876
|
+
var u = this.startNodeAt(s, c);
|
|
2877
|
+
return u.operator = this.value, this.type === T.eq && (l = this.toAssignable(l, !1, t)), r || (t.parenthesizedAssign = t.trailingComma = t.doubleProto = -1), t.shorthandAssign >= l.start && (t.shorthandAssign = -1), this.type === T.eq ? this.checkLValPattern(l) : this.checkLValSimple(l), u.left = l, this.next(), u.right = this.parseMaybeAssign(e), o > -1 && (t.doubleProto = o), this.finishNode(u, "AssignmentExpression");
|
|
2878
|
+
} else r && this.checkExpressionErrors(t, !0);
|
|
2879
|
+
return i > -1 && (t.parenthesizedAssign = i), a > -1 && (t.trailingComma = a), l;
|
|
2880
|
+
}, G.parseMaybeConditional = function(e, t) {
|
|
2881
|
+
var n = this.start, r = this.startLoc, i = this.parseExprOps(e, t);
|
|
2882
|
+
if (this.checkExpressionErrors(t)) return i;
|
|
2883
|
+
if (!(i.type === "ArrowFunctionExpression" && i.start === n) && this.eat(T.question)) {
|
|
2884
|
+
var a = this.startNodeAt(n, r);
|
|
2885
|
+
return a.test = i, a.consequent = this.parseMaybeAssign(), this.expect(T.colon), a.alternate = this.parseMaybeAssign(e), this.finishNode(a, "ConditionalExpression");
|
|
2886
|
+
}
|
|
2887
|
+
return i;
|
|
2888
|
+
}, G.parseExprOps = function(e, t) {
|
|
2889
|
+
var n = this.start, r = this.startLoc, i = this.parseMaybeUnary(t, !1, !1, e);
|
|
2890
|
+
return this.checkExpressionErrors(t) || i.start === n && i.type === "ArrowFunctionExpression" ? i : this.parseExprOp(i, n, r, -1, e);
|
|
2891
|
+
}, G.parseExprOp = function(e, t, n, r, i) {
|
|
2892
|
+
var a = this.type.binop;
|
|
2893
|
+
if (a != null && (!i || this.type !== T._in) && a > r) {
|
|
2894
|
+
var o = this.type === T.logicalOR || this.type === T.logicalAND, s = this.type === T.coalesce;
|
|
2895
|
+
s && (a = T.logicalAND.binop);
|
|
2896
|
+
var c = this.value;
|
|
2897
|
+
this.next();
|
|
2898
|
+
var l = this.start, u = this.startLoc, d = this.parseExprOp(this.parseMaybeUnary(null, !1, !1, i), l, u, a, i), f = this.buildBinary(t, n, e, d, c, o || s);
|
|
2899
|
+
return (o && this.type === T.coalesce || s && (this.type === T.logicalOR || this.type === T.logicalAND)) && this.raiseRecoverable(this.start, "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"), this.parseExprOp(f, t, n, r, i);
|
|
2900
|
+
}
|
|
2901
|
+
return e;
|
|
2902
|
+
}, G.buildBinary = function(e, t, n, r, i, a) {
|
|
2903
|
+
r.type === "PrivateIdentifier" && this.raise(r.start, "Private identifier can only be left side of binary expression");
|
|
2904
|
+
var o = this.startNodeAt(e, t);
|
|
2905
|
+
return o.left = n, o.operator = i, o.right = r, this.finishNode(o, a ? "LogicalExpression" : "BinaryExpression");
|
|
2906
|
+
}, G.parseMaybeUnary = function(e, t, n, r) {
|
|
2907
|
+
var i = this.start, a = this.startLoc, o;
|
|
2908
|
+
if (this.isContextual("await") && this.canAwait) o = this.parseAwait(r), t = !0;
|
|
2909
|
+
else if (this.type.prefix) {
|
|
2910
|
+
var s = this.startNode(), c = this.type === T.incDec;
|
|
2911
|
+
s.operator = this.value, s.prefix = !0, this.next(), s.argument = this.parseMaybeUnary(null, !0, c, r), this.checkExpressionErrors(e, !0), c ? this.checkLValSimple(s.argument) : this.strict && s.operator === "delete" && qe(s.argument) ? this.raiseRecoverable(s.start, "Deleting local variable in strict mode") : s.operator === "delete" && Je(s.argument) ? this.raiseRecoverable(s.start, "Private fields can not be deleted") : t = !0, o = this.finishNode(s, c ? "UpdateExpression" : "UnaryExpression");
|
|
2912
|
+
} else if (!t && this.type === T.privateId) (r || this.privateNameStack.length === 0) && this.options.checkPrivateFields && this.unexpected(), o = this.parsePrivateIdent(), this.type !== T._in && this.unexpected();
|
|
2913
|
+
else {
|
|
2914
|
+
if (o = this.parseExprSubscripts(e, r), this.checkExpressionErrors(e)) return o;
|
|
2915
|
+
for (; this.type.postfix && !this.canInsertSemicolon();) {
|
|
2916
|
+
var l = this.startNodeAt(i, a);
|
|
2917
|
+
l.operator = this.value, l.prefix = !1, l.argument = o, this.checkLValSimple(o), this.next(), o = this.finishNode(l, "UpdateExpression");
|
|
2918
|
+
}
|
|
2919
|
+
}
|
|
2920
|
+
if (!n && this.eat(T.starstar)) if (t) this.unexpected(this.lastTokStart);
|
|
2921
|
+
else return this.buildBinary(i, a, o, this.parseMaybeUnary(null, !1, !1, r), "**", !1);
|
|
2922
|
+
else return o;
|
|
2923
|
+
};
|
|
2924
|
+
function qe(e) {
|
|
2925
|
+
return e.type === "Identifier" || e.type === "ParenthesizedExpression" && qe(e.expression);
|
|
2926
|
+
}
|
|
2927
|
+
function Je(e) {
|
|
2928
|
+
return e.type === "MemberExpression" && e.property.type === "PrivateIdentifier" || e.type === "ChainExpression" && Je(e.expression) || e.type === "ParenthesizedExpression" && Je(e.expression);
|
|
2929
|
+
}
|
|
2930
|
+
G.parseExprSubscripts = function(e, t) {
|
|
2931
|
+
var n = this.start, r = this.startLoc, i = this.parseExprAtom(e, t);
|
|
2932
|
+
if (i.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")") return i;
|
|
2933
|
+
var a = this.parseSubscripts(i, n, r, !1, t);
|
|
2934
|
+
return e && a.type === "MemberExpression" && (e.parenthesizedAssign >= a.start && (e.parenthesizedAssign = -1), e.parenthesizedBind >= a.start && (e.parenthesizedBind = -1), e.trailingComma >= a.start && (e.trailingComma = -1)), a;
|
|
2935
|
+
}, G.parseSubscripts = function(e, t, n, r, i) {
|
|
2936
|
+
for (var a = this.options.ecmaVersion >= 8 && e.type === "Identifier" && e.name === "async" && this.lastTokEnd === e.end && !this.canInsertSemicolon() && e.end - e.start === 5 && this.potentialArrowAt === e.start, o = !1;;) {
|
|
2937
|
+
var s = this.parseSubscript(e, t, n, r, a, o, i);
|
|
2938
|
+
if (s.optional && (o = !0), s === e || s.type === "ArrowFunctionExpression") {
|
|
2939
|
+
if (o) {
|
|
2940
|
+
var c = this.startNodeAt(t, n);
|
|
2941
|
+
c.expression = s, s = this.finishNode(c, "ChainExpression");
|
|
2942
|
+
}
|
|
2943
|
+
return s;
|
|
2944
|
+
}
|
|
2945
|
+
e = s;
|
|
2946
|
+
}
|
|
2947
|
+
}, G.shouldParseAsyncArrow = function() {
|
|
2948
|
+
return !this.canInsertSemicolon() && this.eat(T.arrow);
|
|
2949
|
+
}, G.parseSubscriptAsyncArrow = function(e, t, n, r) {
|
|
2950
|
+
return this.parseArrowExpression(this.startNodeAt(e, t), n, !0, r);
|
|
2951
|
+
}, G.parseSubscript = function(e, t, n, r, i, a, o) {
|
|
2952
|
+
var s = this.options.ecmaVersion >= 11, c = s && this.eat(T.questionDot);
|
|
2953
|
+
r && c && this.raise(this.lastTokStart, "Optional chaining cannot appear in the callee of new expressions");
|
|
2954
|
+
var l = this.eat(T.bracketL);
|
|
2955
|
+
if (l || c && this.type !== T.parenL && this.type !== T.backQuote || this.eat(T.dot)) {
|
|
2956
|
+
var u = this.startNodeAt(t, n);
|
|
2957
|
+
u.object = e, l ? (u.property = this.parseExpression(), this.expect(T.bracketR)) : this.type === T.privateId && e.type !== "Super" ? u.property = this.parsePrivateIdent() : u.property = this.parseIdent(this.options.allowReserved !== "never"), u.computed = !!l, s && (u.optional = c), e = this.finishNode(u, "MemberExpression");
|
|
2958
|
+
} else if (!r && this.eat(T.parenL)) {
|
|
2959
|
+
var d = new Re(), f = this.yieldPos, p = this.awaitPos, m = this.awaitIdentPos;
|
|
2960
|
+
this.yieldPos = 0, this.awaitPos = 0, this.awaitIdentPos = 0;
|
|
2961
|
+
var h = this.parseExprList(T.parenR, this.options.ecmaVersion >= 8, !1, d);
|
|
2962
|
+
if (i && !c && this.shouldParseAsyncArrow()) return this.checkPatternErrors(d, !1), this.checkYieldAwaitInDefaultParams(), this.awaitIdentPos > 0 && this.raise(this.awaitIdentPos, "Cannot use 'await' as identifier inside an async function"), this.yieldPos = f, this.awaitPos = p, this.awaitIdentPos = m, this.parseSubscriptAsyncArrow(t, n, h, o);
|
|
2963
|
+
this.checkExpressionErrors(d, !0), this.yieldPos = f || this.yieldPos, this.awaitPos = p || this.awaitPos, this.awaitIdentPos = m || this.awaitIdentPos;
|
|
2964
|
+
var g = this.startNodeAt(t, n);
|
|
2965
|
+
g.callee = e, g.arguments = h, s && (g.optional = c), e = this.finishNode(g, "CallExpression");
|
|
2966
|
+
} else if (this.type === T.backQuote) {
|
|
2967
|
+
(c || a) && this.raise(this.start, "Optional chaining cannot appear in the tag of tagged template expressions");
|
|
2968
|
+
var _ = this.startNodeAt(t, n);
|
|
2969
|
+
_.tag = e, _.quasi = this.parseTemplate({ isTagged: !0 }), e = this.finishNode(_, "TaggedTemplateExpression");
|
|
2970
|
+
}
|
|
2971
|
+
return e;
|
|
2972
|
+
}, G.parseExprAtom = function(e, t, n) {
|
|
2973
|
+
this.type === T.slash && this.readRegexp();
|
|
2974
|
+
var r, i = this.potentialArrowAt === this.start;
|
|
2975
|
+
switch (this.type) {
|
|
2976
|
+
case T._super: return this.allowSuper || this.raise(this.start, "'super' keyword outside a method"), r = this.startNode(), this.next(), this.type === T.parenL && !this.allowDirectSuper && this.raise(r.start, "super() call outside constructor of a subclass"), this.type !== T.dot && this.type !== T.bracketL && this.type !== T.parenL && this.unexpected(), this.finishNode(r, "Super");
|
|
2977
|
+
case T._this: return r = this.startNode(), this.next(), this.finishNode(r, "ThisExpression");
|
|
2978
|
+
case T.name:
|
|
2979
|
+
var a = this.start, o = this.startLoc, s = this.containsEsc, c = this.parseIdent(!1);
|
|
2980
|
+
if (this.options.ecmaVersion >= 8 && !s && c.name === "async" && !this.canInsertSemicolon() && this.eat(T._function)) return this.overrideContext(U.f_expr), this.parseFunction(this.startNodeAt(a, o), 0, !1, !0, t);
|
|
2981
|
+
if (i && !this.canInsertSemicolon()) {
|
|
2982
|
+
if (this.eat(T.arrow)) return this.parseArrowExpression(this.startNodeAt(a, o), [c], !1, t);
|
|
2983
|
+
if (this.options.ecmaVersion >= 8 && c.name === "async" && this.type === T.name && !s && (!this.potentialArrowInForAwait || this.value !== "of" || this.containsEsc)) return c = this.parseIdent(!1), (this.canInsertSemicolon() || !this.eat(T.arrow)) && this.unexpected(), this.parseArrowExpression(this.startNodeAt(a, o), [c], !0, t);
|
|
2984
|
+
}
|
|
2985
|
+
return c;
|
|
2986
|
+
case T.regexp:
|
|
2987
|
+
var l = this.value;
|
|
2988
|
+
return r = this.parseLiteral(l.value), r.regex = {
|
|
2989
|
+
pattern: l.pattern,
|
|
2990
|
+
flags: l.flags
|
|
2991
|
+
}, r;
|
|
2992
|
+
case T.num:
|
|
2993
|
+
case T.string: return this.parseLiteral(this.value);
|
|
2994
|
+
case T._null:
|
|
2995
|
+
case T._true:
|
|
2996
|
+
case T._false: return r = this.startNode(), r.value = this.type === T._null ? null : this.type === T._true, r.raw = this.type.keyword, this.next(), this.finishNode(r, "Literal");
|
|
2997
|
+
case T.parenL:
|
|
2998
|
+
var u = this.start, d = this.parseParenAndDistinguishExpression(i, t);
|
|
2999
|
+
return e && (e.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(d) && (e.parenthesizedAssign = u), e.parenthesizedBind < 0 && (e.parenthesizedBind = u)), d;
|
|
3000
|
+
case T.bracketL: return r = this.startNode(), this.next(), r.elements = this.parseExprList(T.bracketR, !0, !0, e), this.finishNode(r, "ArrayExpression");
|
|
3001
|
+
case T.braceL: return this.overrideContext(U.b_expr), this.parseObj(!1, e);
|
|
3002
|
+
case T._function: return r = this.startNode(), this.next(), this.parseFunction(r, 0);
|
|
3003
|
+
case T._class: return this.parseClass(this.startNode(), !1);
|
|
3004
|
+
case T._new: return this.parseNew();
|
|
3005
|
+
case T.backQuote: return this.parseTemplate();
|
|
3006
|
+
case T._import: return this.options.ecmaVersion >= 11 ? this.parseExprImport(n) : this.unexpected();
|
|
3007
|
+
default: return this.parseExprAtomDefault();
|
|
3008
|
+
}
|
|
3009
|
+
}, G.parseExprAtomDefault = function() {
|
|
3010
|
+
this.unexpected();
|
|
3011
|
+
}, G.parseExprImport = function(e) {
|
|
3012
|
+
var t = this.startNode();
|
|
3013
|
+
if (this.containsEsc && this.raiseRecoverable(this.start, "Escape sequence in keyword import"), this.next(), this.type === T.parenL && !e) return this.parseDynamicImport(t);
|
|
3014
|
+
if (this.type === T.dot) {
|
|
3015
|
+
var n = this.startNodeAt(t.start, t.loc && t.loc.start);
|
|
3016
|
+
return n.name = "import", t.meta = this.finishNode(n, "Identifier"), this.parseImportMeta(t);
|
|
3017
|
+
} else this.unexpected();
|
|
3018
|
+
}, G.parseDynamicImport = function(e) {
|
|
3019
|
+
if (this.next(), e.source = this.parseMaybeAssign(), this.options.ecmaVersion >= 16) this.eat(T.parenR) ? e.options = null : (this.expect(T.comma), this.afterTrailingComma(T.parenR) ? e.options = null : (e.options = this.parseMaybeAssign(), this.eat(T.parenR) || (this.expect(T.comma), this.afterTrailingComma(T.parenR) || this.unexpected())));
|
|
3020
|
+
else if (!this.eat(T.parenR)) {
|
|
3021
|
+
var t = this.start;
|
|
3022
|
+
this.eat(T.comma) && this.eat(T.parenR) ? this.raiseRecoverable(t, "Trailing comma is not allowed in import()") : this.unexpected(t);
|
|
3023
|
+
}
|
|
3024
|
+
return this.finishNode(e, "ImportExpression");
|
|
3025
|
+
}, G.parseImportMeta = function(e) {
|
|
3026
|
+
this.next();
|
|
3027
|
+
var t = this.containsEsc;
|
|
3028
|
+
return e.property = this.parseIdent(!0), e.property.name !== "meta" && this.raiseRecoverable(e.property.start, "The only valid meta property for import is 'import.meta'"), t && this.raiseRecoverable(e.start, "'import.meta' must not contain escaped characters"), this.options.sourceType !== "module" && !this.options.allowImportExportEverywhere && this.raiseRecoverable(e.start, "Cannot use 'import.meta' outside a module"), this.finishNode(e, "MetaProperty");
|
|
3029
|
+
}, G.parseLiteral = function(e) {
|
|
3030
|
+
var t = this.startNode();
|
|
3031
|
+
return t.value = e, t.raw = this.input.slice(this.start, this.end), t.raw.charCodeAt(t.raw.length - 1) === 110 && (t.bigint = t.value == null ? t.raw.slice(0, -1).replace(/_/g, "") : t.value.toString()), this.next(), this.finishNode(t, "Literal");
|
|
3032
|
+
}, G.parseParenExpression = function() {
|
|
3033
|
+
this.expect(T.parenL);
|
|
3034
|
+
var e = this.parseExpression();
|
|
3035
|
+
return this.expect(T.parenR), e;
|
|
3036
|
+
}, G.shouldParseArrow = function(e) {
|
|
3037
|
+
return !this.canInsertSemicolon();
|
|
3038
|
+
}, G.parseParenAndDistinguishExpression = function(e, t) {
|
|
3039
|
+
var n = this.start, r = this.startLoc, i, a = this.options.ecmaVersion >= 8;
|
|
3040
|
+
if (this.options.ecmaVersion >= 6) {
|
|
3041
|
+
this.next();
|
|
3042
|
+
var o = this.start, s = this.startLoc, c = [], l = !0, u = !1, d = new Re(), f = this.yieldPos, p = this.awaitPos, m;
|
|
3043
|
+
for (this.yieldPos = 0, this.awaitPos = 0; this.type !== T.parenR;) if (l ? l = !1 : this.expect(T.comma), a && this.afterTrailingComma(T.parenR, !0)) {
|
|
3044
|
+
u = !0;
|
|
3045
|
+
break;
|
|
3046
|
+
} else if (this.type === T.ellipsis) {
|
|
3047
|
+
m = this.start, c.push(this.parseParenItem(this.parseRestBinding())), this.type === T.comma && this.raiseRecoverable(this.start, "Comma is not permitted after the rest element");
|
|
3048
|
+
break;
|
|
3049
|
+
} else c.push(this.parseMaybeAssign(!1, d, this.parseParenItem));
|
|
3050
|
+
var h = this.lastTokEnd, g = this.lastTokEndLoc;
|
|
3051
|
+
if (this.expect(T.parenR), e && this.shouldParseArrow(c) && this.eat(T.arrow)) return this.checkPatternErrors(d, !1), this.checkYieldAwaitInDefaultParams(), this.yieldPos = f, this.awaitPos = p, this.parseParenArrowList(n, r, c, t);
|
|
3052
|
+
(!c.length || u) && this.unexpected(this.lastTokStart), m && this.unexpected(m), this.checkExpressionErrors(d, !0), this.yieldPos = f || this.yieldPos, this.awaitPos = p || this.awaitPos, c.length > 1 ? (i = this.startNodeAt(o, s), i.expressions = c, this.finishNodeAt(i, "SequenceExpression", h, g)) : i = c[0];
|
|
3053
|
+
} else i = this.parseParenExpression();
|
|
3054
|
+
if (this.options.preserveParens) {
|
|
3055
|
+
var _ = this.startNodeAt(n, r);
|
|
3056
|
+
return _.expression = i, this.finishNode(_, "ParenthesizedExpression");
|
|
3057
|
+
} else return i;
|
|
3058
|
+
}, G.parseParenItem = function(e) {
|
|
3059
|
+
return e;
|
|
3060
|
+
}, G.parseParenArrowList = function(e, t, n, r) {
|
|
3061
|
+
return this.parseArrowExpression(this.startNodeAt(e, t), n, !1, r);
|
|
3062
|
+
};
|
|
3063
|
+
var Ye = [];
|
|
3064
|
+
G.parseNew = function() {
|
|
3065
|
+
this.containsEsc && this.raiseRecoverable(this.start, "Escape sequence in keyword new");
|
|
3066
|
+
var e = this.startNode();
|
|
3067
|
+
if (this.next(), this.options.ecmaVersion >= 6 && this.type === T.dot) {
|
|
3068
|
+
var t = this.startNodeAt(e.start, e.loc && e.loc.start);
|
|
3069
|
+
t.name = "new", e.meta = this.finishNode(t, "Identifier"), this.next();
|
|
3070
|
+
var n = this.containsEsc;
|
|
3071
|
+
return e.property = this.parseIdent(!0), e.property.name !== "target" && this.raiseRecoverable(e.property.start, "The only valid meta property for new is 'new.target'"), n && this.raiseRecoverable(e.start, "'new.target' must not contain escaped characters"), this.allowNewDotTarget || this.raiseRecoverable(e.start, "'new.target' can only be used in functions and class static block"), this.finishNode(e, "MetaProperty");
|
|
3072
|
+
}
|
|
3073
|
+
var r = this.start, i = this.startLoc;
|
|
3074
|
+
return e.callee = this.parseSubscripts(this.parseExprAtom(null, !1, !0), r, i, !0, !1), e.callee.type === "Super" && this.raiseRecoverable(r, "Invalid use of 'super'"), this.eat(T.parenL) ? e.arguments = this.parseExprList(T.parenR, this.options.ecmaVersion >= 8, !1) : e.arguments = Ye, this.finishNode(e, "NewExpression");
|
|
3075
|
+
}, G.parseTemplateElement = function(e) {
|
|
3076
|
+
var t = e.isTagged, n = this.startNode();
|
|
3077
|
+
return this.type === T.invalidTemplate ? (t || this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal"), n.value = {
|
|
3078
|
+
raw: this.value.replace(/\r\n?/g, "\n"),
|
|
3079
|
+
cooked: null
|
|
3080
|
+
}) : n.value = {
|
|
3081
|
+
raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, "\n"),
|
|
3082
|
+
cooked: this.value
|
|
3083
|
+
}, this.next(), n.tail = this.type === T.backQuote, this.finishNode(n, "TemplateElement");
|
|
3084
|
+
}, G.parseTemplate = function(e) {
|
|
3085
|
+
e === void 0 && (e = {});
|
|
3086
|
+
var t = e.isTagged;
|
|
3087
|
+
t === void 0 && (t = !1);
|
|
3088
|
+
var n = this.startNode();
|
|
3089
|
+
this.next(), n.expressions = [];
|
|
3090
|
+
var r = this.parseTemplateElement({ isTagged: t });
|
|
3091
|
+
for (n.quasis = [r]; !r.tail;) this.type === T.eof && this.raise(this.pos, "Unterminated template literal"), this.expect(T.dollarBraceL), n.expressions.push(this.parseExpression()), this.expect(T.braceR), n.quasis.push(r = this.parseTemplateElement({ isTagged: t }));
|
|
3092
|
+
return this.next(), this.finishNode(n, "TemplateLiteral");
|
|
3093
|
+
}, G.isAsyncProp = function(e) {
|
|
3094
|
+
return !e.computed && e.key.type === "Identifier" && e.key.name === "async" && (this.type === T.name || this.type === T.num || this.type === T.string || this.type === T.bracketL || this.type.keyword || this.options.ecmaVersion >= 9 && this.type === T.star) && !E.test(this.input.slice(this.lastTokEnd, this.start));
|
|
3095
|
+
}, G.parseObj = function(e, t) {
|
|
3096
|
+
var n = this.startNode(), r = !0, i = {};
|
|
3097
|
+
for (n.properties = [], this.next(); !this.eat(T.braceR);) {
|
|
3098
|
+
if (r) r = !1;
|
|
3099
|
+
else if (this.expect(T.comma), this.options.ecmaVersion >= 5 && this.afterTrailingComma(T.braceR)) break;
|
|
3100
|
+
var a = this.parseProperty(e, t);
|
|
3101
|
+
e || this.checkPropClash(a, i, t), n.properties.push(a);
|
|
3102
|
+
}
|
|
3103
|
+
return this.finishNode(n, e ? "ObjectPattern" : "ObjectExpression");
|
|
3104
|
+
}, G.parseProperty = function(e, t) {
|
|
3105
|
+
var n = this.startNode(), r, i, a, o;
|
|
3106
|
+
if (this.options.ecmaVersion >= 9 && this.eat(T.ellipsis)) return e ? (n.argument = this.parseIdent(!1), this.type === T.comma && this.raiseRecoverable(this.start, "Comma is not permitted after the rest element"), this.finishNode(n, "RestElement")) : (n.argument = this.parseMaybeAssign(!1, t), this.type === T.comma && t && t.trailingComma < 0 && (t.trailingComma = this.start), this.finishNode(n, "SpreadElement"));
|
|
3107
|
+
this.options.ecmaVersion >= 6 && (n.method = !1, n.shorthand = !1, (e || t) && (a = this.start, o = this.startLoc), e || (r = this.eat(T.star)));
|
|
3108
|
+
var s = this.containsEsc;
|
|
3109
|
+
return this.parsePropertyName(n), !e && !s && this.options.ecmaVersion >= 8 && !r && this.isAsyncProp(n) ? (i = !0, r = this.options.ecmaVersion >= 9 && this.eat(T.star), this.parsePropertyName(n)) : i = !1, this.parsePropertyValue(n, e, r, i, a, o, t, s), this.finishNode(n, "Property");
|
|
3110
|
+
}, G.parseGetterSetter = function(e) {
|
|
3111
|
+
var t = e.key.name;
|
|
3112
|
+
this.parsePropertyName(e), e.value = this.parseMethod(!1), e.kind = t;
|
|
3113
|
+
var n = e.kind === "get" ? 0 : 1;
|
|
3114
|
+
if (e.value.params.length !== n) {
|
|
3115
|
+
var r = e.value.start;
|
|
3116
|
+
e.kind === "get" ? this.raiseRecoverable(r, "getter should have no params") : this.raiseRecoverable(r, "setter should have exactly one param");
|
|
3117
|
+
} else e.kind === "set" && e.value.params[0].type === "RestElement" && this.raiseRecoverable(e.value.params[0].start, "Setter cannot use rest params");
|
|
3118
|
+
}, G.parsePropertyValue = function(e, t, n, r, i, a, o, s) {
|
|
3119
|
+
(n || r) && this.type === T.colon && this.unexpected(), this.eat(T.colon) ? (e.value = t ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(!1, o), e.kind = "init") : this.options.ecmaVersion >= 6 && this.type === T.parenL ? (t && this.unexpected(), e.method = !0, e.value = this.parseMethod(n, r), e.kind = "init") : !t && !s && this.options.ecmaVersion >= 5 && !e.computed && e.key.type === "Identifier" && (e.key.name === "get" || e.key.name === "set") && this.type !== T.comma && this.type !== T.braceR && this.type !== T.eq ? ((n || r) && this.unexpected(), this.parseGetterSetter(e)) : this.options.ecmaVersion >= 6 && !e.computed && e.key.type === "Identifier" ? ((n || r) && this.unexpected(), this.checkUnreserved(e.key), e.key.name === "await" && !this.awaitIdentPos && (this.awaitIdentPos = i), t ? e.value = this.parseMaybeDefault(i, a, this.copyNode(e.key)) : this.type === T.eq && o ? (o.shorthandAssign < 0 && (o.shorthandAssign = this.start), e.value = this.parseMaybeDefault(i, a, this.copyNode(e.key))) : e.value = this.copyNode(e.key), e.kind = "init", e.shorthand = !0) : this.unexpected();
|
|
3120
|
+
}, G.parsePropertyName = function(e) {
|
|
3121
|
+
if (this.options.ecmaVersion >= 6) {
|
|
3122
|
+
if (this.eat(T.bracketL)) return e.computed = !0, e.key = this.parseMaybeAssign(), this.expect(T.bracketR), e.key;
|
|
3123
|
+
e.computed = !1;
|
|
3124
|
+
}
|
|
3125
|
+
return e.key = this.type === T.num || this.type === T.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never");
|
|
3126
|
+
}, G.initFunction = function(e) {
|
|
3127
|
+
e.id = null, this.options.ecmaVersion >= 6 && (e.generator = e.expression = !1), this.options.ecmaVersion >= 8 && (e.async = !1);
|
|
3128
|
+
}, G.parseMethod = function(e, t, n) {
|
|
3129
|
+
var r = this.startNode(), i = this.yieldPos, a = this.awaitPos, o = this.awaitIdentPos;
|
|
3130
|
+
return this.initFunction(r), this.options.ecmaVersion >= 6 && (r.generator = e), this.options.ecmaVersion >= 8 && (r.async = !!t), this.yieldPos = 0, this.awaitPos = 0, this.awaitIdentPos = 0, this.enterScope(je(t, r.generator) | Ee | (n ? De : 0)), this.expect(T.parenL), r.params = this.parseBindingList(T.parenR, !1, this.options.ecmaVersion >= 8), this.checkYieldAwaitInDefaultParams(), this.parseFunctionBody(r, !1, !0, !1), this.yieldPos = i, this.awaitPos = a, this.awaitIdentPos = o, this.finishNode(r, "FunctionExpression");
|
|
3131
|
+
}, G.parseArrowExpression = function(e, t, n, r) {
|
|
3132
|
+
var i = this.yieldPos, a = this.awaitPos, o = this.awaitIdentPos;
|
|
3133
|
+
return this.enterScope(je(n, !1) | we), this.initFunction(e), this.options.ecmaVersion >= 8 && (e.async = !!n), this.yieldPos = 0, this.awaitPos = 0, this.awaitIdentPos = 0, e.params = this.toAssignableList(t, !0), this.parseFunctionBody(e, !0, !1, r), this.yieldPos = i, this.awaitPos = a, this.awaitIdentPos = o, this.finishNode(e, "ArrowFunctionExpression");
|
|
3134
|
+
}, G.parseFunctionBody = function(e, t, n, r) {
|
|
3135
|
+
var i = t && this.type !== T.braceL, a = this.strict, o = !1;
|
|
3136
|
+
if (i) e.body = this.parseMaybeAssign(r), e.expression = !0, this.checkParams(e, !1);
|
|
3137
|
+
else {
|
|
3138
|
+
var s = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(e.params);
|
|
3139
|
+
(!a || s) && (o = this.strictDirective(this.end), o && s && this.raiseRecoverable(e.start, "Illegal 'use strict' directive in function with non-simple parameter list"));
|
|
3140
|
+
var c = this.labels;
|
|
3141
|
+
this.labels = [], o && (this.strict = !0), this.checkParams(e, !a && !o && !t && !n && this.isSimpleParamList(e.params)), this.strict && e.id && this.checkLValSimple(e.id, Ie), e.body = this.parseBlock(!1, void 0, o && !a), e.expression = !1, this.adaptDirectivePrologue(e.body.body), this.labels = c;
|
|
3142
|
+
}
|
|
3143
|
+
this.exitScope();
|
|
3144
|
+
}, G.isSimpleParamList = function(e) {
|
|
3145
|
+
for (var t = 0, n = e; t < n.length; t += 1) if (n[t].type !== "Identifier") return !1;
|
|
3146
|
+
return !0;
|
|
3147
|
+
}, G.checkParams = function(e, t) {
|
|
3148
|
+
for (var n = Object.create(null), r = 0, i = e.params; r < i.length; r += 1) {
|
|
3149
|
+
var a = i[r];
|
|
3150
|
+
this.checkLValInnerPattern(a, Ne, t ? null : n);
|
|
3151
|
+
}
|
|
3152
|
+
}, G.parseExprList = function(e, t, n, r) {
|
|
3153
|
+
for (var i = [], a = !0; !this.eat(e);) {
|
|
3154
|
+
if (a) a = !1;
|
|
3155
|
+
else if (this.expect(T.comma), t && this.afterTrailingComma(e)) break;
|
|
3156
|
+
var o = void 0;
|
|
3157
|
+
n && this.type === T.comma ? o = null : this.type === T.ellipsis ? (o = this.parseSpread(r), r && this.type === T.comma && r.trailingComma < 0 && (r.trailingComma = this.start)) : o = this.parseMaybeAssign(!1, r), i.push(o);
|
|
3158
|
+
}
|
|
3159
|
+
return i;
|
|
3160
|
+
}, G.checkUnreserved = function(e) {
|
|
3161
|
+
var t = e.start, n = e.end, r = e.name;
|
|
3162
|
+
this.inGenerator && r === "yield" && this.raiseRecoverable(t, "Cannot use 'yield' as identifier inside a generator"), this.inAsync && r === "await" && this.raiseRecoverable(t, "Cannot use 'await' as identifier inside an async function"), !(this.currentThisScope().flags & Ae) && r === "arguments" && this.raiseRecoverable(t, "Cannot use 'arguments' in class field initializer"), this.inClassStaticBlock && (r === "arguments" || r === "await") && this.raise(t, "Cannot use " + r + " in class static initialization block"), this.keywords.test(r) && this.raise(t, "Unexpected keyword '" + r + "'"), !(this.options.ecmaVersion < 6 && this.input.slice(t, n).indexOf("\\") !== -1) && (this.strict ? this.reservedWordsStrict : this.reservedWords).test(r) && (!this.inAsync && r === "await" && this.raiseRecoverable(t, "Cannot use keyword 'await' outside an async function"), this.raiseRecoverable(t, "The keyword '" + r + "' is reserved"));
|
|
3163
|
+
}, G.parseIdent = function(e) {
|
|
3164
|
+
var t = this.parseIdentNode();
|
|
3165
|
+
return this.next(!!e), this.finishNode(t, "Identifier"), e || (this.checkUnreserved(t), t.name === "await" && !this.awaitIdentPos && (this.awaitIdentPos = t.start)), t;
|
|
3166
|
+
}, G.parseIdentNode = function() {
|
|
3167
|
+
var e = this.startNode();
|
|
3168
|
+
return this.type === T.name ? e.name = this.value : this.type.keyword ? (e.name = this.type.keyword, (e.name === "class" || e.name === "function") && (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46) && this.context.pop(), this.type = T.name) : this.unexpected(), e;
|
|
3169
|
+
}, G.parsePrivateIdent = function() {
|
|
3170
|
+
var e = this.startNode();
|
|
3171
|
+
return this.type === T.privateId ? e.name = this.value : this.unexpected(), this.next(), this.finishNode(e, "PrivateIdentifier"), this.options.checkPrivateFields && (this.privateNameStack.length === 0 ? this.raise(e.start, "Private field '#" + e.name + "' must be declared in an enclosing class") : this.privateNameStack[this.privateNameStack.length - 1].used.push(e)), e;
|
|
3172
|
+
}, G.parseYield = function(e) {
|
|
3173
|
+
this.yieldPos ||= this.start;
|
|
3174
|
+
var t = this.startNode();
|
|
3175
|
+
return this.next(), this.type === T.semi || this.canInsertSemicolon() || this.type !== T.star && !this.type.startsExpr ? (t.delegate = !1, t.argument = null) : (t.delegate = this.eat(T.star), t.argument = this.parseMaybeAssign(e)), this.finishNode(t, "YieldExpression");
|
|
3176
|
+
}, G.parseAwait = function(e) {
|
|
3177
|
+
this.awaitPos ||= this.start;
|
|
3178
|
+
var t = this.startNode();
|
|
3179
|
+
return this.next(), t.argument = this.parseMaybeUnary(null, !0, !1, e), this.finishNode(t, "AwaitExpression");
|
|
3180
|
+
};
|
|
3181
|
+
var Xe = L.prototype;
|
|
3182
|
+
Xe.raise = function(e, t) {
|
|
3183
|
+
var n = _e(this.input, e);
|
|
3184
|
+
t += " (" + n.line + ":" + n.column + ")", this.sourceFile && (t += " in " + this.sourceFile);
|
|
3185
|
+
var r = SyntaxError(t);
|
|
3186
|
+
throw r.pos = e, r.loc = n, r.raisedAt = this.pos, r;
|
|
3187
|
+
}, Xe.raiseRecoverable = Xe.raise, Xe.curPosition = function() {
|
|
3188
|
+
if (this.options.locations) return new M(this.curLine, this.pos - this.lineStart);
|
|
3189
|
+
};
|
|
3190
|
+
var K = L.prototype, Ze = function(e) {
|
|
3191
|
+
this.flags = e, this.var = [], this.lexical = [], this.functions = [];
|
|
3192
|
+
};
|
|
3193
|
+
K.enterScope = function(e) {
|
|
3194
|
+
this.scopeStack.push(new Ze(e));
|
|
3195
|
+
}, K.exitScope = function() {
|
|
3196
|
+
this.scopeStack.pop();
|
|
3197
|
+
}, K.treatFunctionsAsVarInScope = function(e) {
|
|
3198
|
+
return e.flags & P || !this.inModule && e.flags & N;
|
|
3199
|
+
}, K.declareName = function(e, t, n) {
|
|
3200
|
+
var r = !1;
|
|
3201
|
+
if (t === I) {
|
|
3202
|
+
var i = this.currentScope();
|
|
3203
|
+
r = i.lexical.indexOf(e) > -1 || i.functions.indexOf(e) > -1 || i.var.indexOf(e) > -1, i.lexical.push(e), this.inModule && i.flags & N && delete this.undefinedExports[e];
|
|
3204
|
+
} else if (t === Fe) this.currentScope().lexical.push(e);
|
|
3205
|
+
else if (t === Pe) {
|
|
3206
|
+
var a = this.currentScope();
|
|
3207
|
+
r = this.treatFunctionsAsVar ? a.lexical.indexOf(e) > -1 : a.lexical.indexOf(e) > -1 || a.var.indexOf(e) > -1, a.functions.push(e);
|
|
3208
|
+
} else for (var o = this.scopeStack.length - 1; o >= 0; --o) {
|
|
3209
|
+
var s = this.scopeStack[o];
|
|
3210
|
+
if (s.lexical.indexOf(e) > -1 && !(s.flags & Te && s.lexical[0] === e) || !this.treatFunctionsAsVarInScope(s) && s.functions.indexOf(e) > -1) {
|
|
3211
|
+
r = !0;
|
|
3212
|
+
break;
|
|
3213
|
+
}
|
|
3214
|
+
if (s.var.push(e), this.inModule && s.flags & N && delete this.undefinedExports[e], s.flags & Ae) break;
|
|
3215
|
+
}
|
|
3216
|
+
r && this.raiseRecoverable(n, "Identifier '" + e + "' has already been declared");
|
|
3217
|
+
}, K.checkLocalExport = function(e) {
|
|
3218
|
+
this.scopeStack[0].lexical.indexOf(e.name) === -1 && this.scopeStack[0].var.indexOf(e.name) === -1 && (this.undefinedExports[e.name] = e);
|
|
3219
|
+
}, K.currentScope = function() {
|
|
3220
|
+
return this.scopeStack[this.scopeStack.length - 1];
|
|
3221
|
+
}, K.currentVarScope = function() {
|
|
3222
|
+
for (var e = this.scopeStack.length - 1;; e--) {
|
|
3223
|
+
var t = this.scopeStack[e];
|
|
3224
|
+
if (t.flags & (Ae | Oe | F)) return t;
|
|
3225
|
+
}
|
|
3226
|
+
}, K.currentThisScope = function() {
|
|
3227
|
+
for (var e = this.scopeStack.length - 1;; e--) {
|
|
3228
|
+
var t = this.scopeStack[e];
|
|
3229
|
+
if (t.flags & (Ae | Oe | F) && !(t.flags & we)) return t;
|
|
3230
|
+
}
|
|
3231
|
+
};
|
|
3232
|
+
var Qe = function(e, t, n) {
|
|
3233
|
+
this.type = "", this.start = t, this.end = 0, e.options.locations && (this.loc = new ge(e, n)), e.options.directSourceFile && (this.sourceFile = e.options.directSourceFile), e.options.ranges && (this.range = [t, 0]);
|
|
3234
|
+
}, $e = L.prototype;
|
|
3235
|
+
$e.startNode = function() {
|
|
3236
|
+
return new Qe(this, this.start, this.startLoc);
|
|
3237
|
+
}, $e.startNodeAt = function(e, t) {
|
|
3238
|
+
return new Qe(this, e, t);
|
|
3239
|
+
};
|
|
3240
|
+
function et(e, t, n, r) {
|
|
3241
|
+
return e.type = t, e.end = n, this.options.locations && (e.loc.end = r), this.options.ranges && (e.range[1] = n), e;
|
|
3242
|
+
}
|
|
3243
|
+
$e.finishNode = function(e, t) {
|
|
3244
|
+
return et.call(this, e, t, this.lastTokEnd, this.lastTokEndLoc);
|
|
3245
|
+
}, $e.finishNodeAt = function(e, t, n, r) {
|
|
3246
|
+
return et.call(this, e, t, n, r);
|
|
3247
|
+
}, $e.copyNode = function(e) {
|
|
3248
|
+
var t = new Qe(this, e.start, this.startLoc);
|
|
3249
|
+
for (var n in e) t[n] = e[n];
|
|
3250
|
+
return t;
|
|
3251
|
+
};
|
|
3252
|
+
var tt = "Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz", nt = "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", rt = nt + " Extended_Pictographic", it = rt, at = it + " EBase EComp EMod EPres ExtPict", ot = at, st = {
|
|
3253
|
+
9: nt,
|
|
3254
|
+
10: rt,
|
|
3255
|
+
11: it,
|
|
3256
|
+
12: at,
|
|
3257
|
+
13: ot,
|
|
3258
|
+
14: ot
|
|
3259
|
+
}, ct = {
|
|
3260
|
+
9: "",
|
|
3261
|
+
10: "",
|
|
3262
|
+
11: "",
|
|
3263
|
+
12: "",
|
|
3264
|
+
13: "",
|
|
3265
|
+
14: "Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji"
|
|
3266
|
+
}, lt = "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", ut = "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", dt = ut + " Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd", ft = dt + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho", pt = ft + " Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi", mt = pt + " Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith", ht = {
|
|
3267
|
+
9: ut,
|
|
3268
|
+
10: dt,
|
|
3269
|
+
11: ft,
|
|
3270
|
+
12: pt,
|
|
3271
|
+
13: mt,
|
|
3272
|
+
14: mt + " " + tt
|
|
3273
|
+
}, gt = {};
|
|
3274
|
+
function _t(e) {
|
|
3275
|
+
var t = gt[e] = {
|
|
3276
|
+
binary: A(st[e] + " " + lt),
|
|
3277
|
+
binaryOfStrings: A(ct[e]),
|
|
3278
|
+
nonBinary: {
|
|
3279
|
+
General_Category: A(lt),
|
|
3280
|
+
Script: A(ht[e])
|
|
3281
|
+
}
|
|
3282
|
+
};
|
|
3283
|
+
t.nonBinary.Script_Extensions = t.nonBinary.Script, t.nonBinary.gc = t.nonBinary.General_Category, t.nonBinary.sc = t.nonBinary.Script, t.nonBinary.scx = t.nonBinary.Script_Extensions;
|
|
3284
|
+
}
|
|
3285
|
+
for (var vt = 0, yt = [
|
|
3286
|
+
9,
|
|
3287
|
+
10,
|
|
3288
|
+
11,
|
|
3289
|
+
12,
|
|
3290
|
+
13,
|
|
3291
|
+
14
|
|
3292
|
+
]; vt < yt.length; vt += 1) {
|
|
3293
|
+
var bt = yt[vt];
|
|
3294
|
+
_t(bt);
|
|
3295
|
+
}
|
|
3296
|
+
var q = L.prototype, xt = function(e, t) {
|
|
3297
|
+
this.parent = e, this.base = t || this;
|
|
3298
|
+
};
|
|
3299
|
+
xt.prototype.separatedFrom = function(e) {
|
|
3300
|
+
for (var t = this; t; t = t.parent) for (var n = e; n; n = n.parent) if (t.base === n.base && t !== n) return !0;
|
|
3301
|
+
return !1;
|
|
3302
|
+
}, xt.prototype.sibling = function() {
|
|
3303
|
+
return new xt(this.parent, this.base);
|
|
3304
|
+
};
|
|
3305
|
+
var J = function(e) {
|
|
3306
|
+
this.parser = e, this.validFlags = "gim" + (e.options.ecmaVersion >= 6 ? "uy" : "") + (e.options.ecmaVersion >= 9 ? "s" : "") + (e.options.ecmaVersion >= 13 ? "d" : "") + (e.options.ecmaVersion >= 15 ? "v" : ""), this.unicodeProperties = gt[e.options.ecmaVersion >= 14 ? 14 : e.options.ecmaVersion], this.source = "", this.flags = "", this.start = 0, this.switchU = !1, this.switchV = !1, this.switchN = !1, this.pos = 0, this.lastIntValue = 0, this.lastStringValue = "", this.lastAssertionIsQuantifiable = !1, this.numCapturingParens = 0, this.maxBackReference = 0, this.groupNames = Object.create(null), this.backReferenceNames = [], this.branchID = null;
|
|
3307
|
+
};
|
|
3308
|
+
J.prototype.reset = function(e, t, n) {
|
|
3309
|
+
var r = n.indexOf("v") !== -1, i = n.indexOf("u") !== -1;
|
|
3310
|
+
this.start = e | 0, this.source = t + "", this.flags = n, r && this.parser.options.ecmaVersion >= 15 ? (this.switchU = !0, this.switchV = !0, this.switchN = !0) : (this.switchU = i && this.parser.options.ecmaVersion >= 6, this.switchV = !1, this.switchN = i && this.parser.options.ecmaVersion >= 9);
|
|
3311
|
+
}, J.prototype.raise = function(e) {
|
|
3312
|
+
this.parser.raiseRecoverable(this.start, "Invalid regular expression: /" + this.source + "/: " + e);
|
|
3313
|
+
}, J.prototype.at = function(e, t) {
|
|
3314
|
+
t === void 0 && (t = !1);
|
|
3315
|
+
var n = this.source, r = n.length;
|
|
3316
|
+
if (e >= r) return -1;
|
|
3317
|
+
var i = n.charCodeAt(e);
|
|
3318
|
+
if (!(t || this.switchU) || i <= 55295 || i >= 57344 || e + 1 >= r) return i;
|
|
3319
|
+
var a = n.charCodeAt(e + 1);
|
|
3320
|
+
return a >= 56320 && a <= 57343 ? (i << 10) + a - 56613888 : i;
|
|
3321
|
+
}, J.prototype.nextIndex = function(e, t) {
|
|
3322
|
+
t === void 0 && (t = !1);
|
|
3323
|
+
var n = this.source, r = n.length;
|
|
3324
|
+
if (e >= r) return r;
|
|
3325
|
+
var i = n.charCodeAt(e), a;
|
|
3326
|
+
return !(t || this.switchU) || i <= 55295 || i >= 57344 || e + 1 >= r || (a = n.charCodeAt(e + 1)) < 56320 || a > 57343 ? e + 1 : e + 2;
|
|
3327
|
+
}, J.prototype.current = function(e) {
|
|
3328
|
+
return e === void 0 && (e = !1), this.at(this.pos, e);
|
|
3329
|
+
}, J.prototype.lookahead = function(e) {
|
|
3330
|
+
return e === void 0 && (e = !1), this.at(this.nextIndex(this.pos, e), e);
|
|
3331
|
+
}, J.prototype.advance = function(e) {
|
|
3332
|
+
e === void 0 && (e = !1), this.pos = this.nextIndex(this.pos, e);
|
|
3333
|
+
}, J.prototype.eat = function(e, t) {
|
|
3334
|
+
return t === void 0 && (t = !1), this.current(t) === e ? (this.advance(t), !0) : !1;
|
|
3335
|
+
}, J.prototype.eatChars = function(e, t) {
|
|
3336
|
+
t === void 0 && (t = !1);
|
|
3337
|
+
for (var n = this.pos, r = 0, i = e; r < i.length; r += 1) {
|
|
3338
|
+
var a = i[r], o = this.at(n, t);
|
|
3339
|
+
if (o === -1 || o !== a) return !1;
|
|
3340
|
+
n = this.nextIndex(n, t);
|
|
3341
|
+
}
|
|
3342
|
+
return this.pos = n, !0;
|
|
3343
|
+
}, q.validateRegExpFlags = function(e) {
|
|
3344
|
+
for (var t = e.validFlags, n = e.flags, r = !1, i = !1, a = 0; a < n.length; a++) {
|
|
3345
|
+
var o = n.charAt(a);
|
|
3346
|
+
t.indexOf(o) === -1 && this.raise(e.start, "Invalid regular expression flag"), n.indexOf(o, a + 1) > -1 && this.raise(e.start, "Duplicate regular expression flag"), o === "u" && (r = !0), o === "v" && (i = !0);
|
|
3347
|
+
}
|
|
3348
|
+
this.options.ecmaVersion >= 15 && r && i && this.raise(e.start, "Invalid regular expression flag");
|
|
3349
|
+
};
|
|
3350
|
+
function St(e) {
|
|
3351
|
+
for (var t in e) return !0;
|
|
3352
|
+
return !1;
|
|
3353
|
+
}
|
|
3354
|
+
q.validateRegExpPattern = function(e) {
|
|
3355
|
+
this.regexp_pattern(e), !e.switchN && this.options.ecmaVersion >= 9 && St(e.groupNames) && (e.switchN = !0, this.regexp_pattern(e));
|
|
3356
|
+
}, q.regexp_pattern = function(e) {
|
|
3357
|
+
e.pos = 0, e.lastIntValue = 0, e.lastStringValue = "", e.lastAssertionIsQuantifiable = !1, e.numCapturingParens = 0, e.maxBackReference = 0, e.groupNames = Object.create(null), e.backReferenceNames.length = 0, e.branchID = null, this.regexp_disjunction(e), e.pos !== e.source.length && (e.eat(41) && e.raise("Unmatched ')'"), (e.eat(93) || e.eat(125)) && e.raise("Lone quantifier brackets")), e.maxBackReference > e.numCapturingParens && e.raise("Invalid escape");
|
|
3358
|
+
for (var t = 0, n = e.backReferenceNames; t < n.length; t += 1) {
|
|
3359
|
+
var r = n[t];
|
|
3360
|
+
e.groupNames[r] || e.raise("Invalid named capture referenced");
|
|
3361
|
+
}
|
|
3362
|
+
}, q.regexp_disjunction = function(e) {
|
|
3363
|
+
var t = this.options.ecmaVersion >= 16;
|
|
3364
|
+
for (t && (e.branchID = new xt(e.branchID, null)), this.regexp_alternative(e); e.eat(124);) t && (e.branchID = e.branchID.sibling()), this.regexp_alternative(e);
|
|
3365
|
+
t && (e.branchID = e.branchID.parent), this.regexp_eatQuantifier(e, !0) && e.raise("Nothing to repeat"), e.eat(123) && e.raise("Lone quantifier brackets");
|
|
3366
|
+
}, q.regexp_alternative = function(e) {
|
|
3367
|
+
for (; e.pos < e.source.length && this.regexp_eatTerm(e););
|
|
3368
|
+
}, q.regexp_eatTerm = function(e) {
|
|
3369
|
+
return this.regexp_eatAssertion(e) ? (e.lastAssertionIsQuantifiable && this.regexp_eatQuantifier(e) && e.switchU && e.raise("Invalid quantifier"), !0) : (e.switchU ? this.regexp_eatAtom(e) : this.regexp_eatExtendedAtom(e)) ? (this.regexp_eatQuantifier(e), !0) : !1;
|
|
3370
|
+
}, q.regexp_eatAssertion = function(e) {
|
|
3371
|
+
var t = e.pos;
|
|
3372
|
+
if (e.lastAssertionIsQuantifiable = !1, e.eat(94) || e.eat(36)) return !0;
|
|
3373
|
+
if (e.eat(92)) {
|
|
3374
|
+
if (e.eat(66) || e.eat(98)) return !0;
|
|
3375
|
+
e.pos = t;
|
|
3376
|
+
}
|
|
3377
|
+
if (e.eat(40) && e.eat(63)) {
|
|
3378
|
+
var n = !1;
|
|
3379
|
+
if (this.options.ecmaVersion >= 9 && (n = e.eat(60)), e.eat(61) || e.eat(33)) return this.regexp_disjunction(e), e.eat(41) || e.raise("Unterminated group"), e.lastAssertionIsQuantifiable = !n, !0;
|
|
3380
|
+
}
|
|
3381
|
+
return e.pos = t, !1;
|
|
3382
|
+
}, q.regexp_eatQuantifier = function(e, t) {
|
|
3383
|
+
return t === void 0 && (t = !1), this.regexp_eatQuantifierPrefix(e, t) ? (e.eat(63), !0) : !1;
|
|
3384
|
+
}, q.regexp_eatQuantifierPrefix = function(e, t) {
|
|
3385
|
+
return e.eat(42) || e.eat(43) || e.eat(63) || this.regexp_eatBracedQuantifier(e, t);
|
|
3386
|
+
}, q.regexp_eatBracedQuantifier = function(e, t) {
|
|
3387
|
+
var n = e.pos;
|
|
3388
|
+
if (e.eat(123)) {
|
|
3389
|
+
var r = 0, i = -1;
|
|
3390
|
+
if (this.regexp_eatDecimalDigits(e) && (r = e.lastIntValue, e.eat(44) && this.regexp_eatDecimalDigits(e) && (i = e.lastIntValue), e.eat(125))) return i !== -1 && i < r && !t && e.raise("numbers out of order in {} quantifier"), !0;
|
|
3391
|
+
e.switchU && !t && e.raise("Incomplete quantifier"), e.pos = n;
|
|
3392
|
+
}
|
|
3393
|
+
return !1;
|
|
3394
|
+
}, q.regexp_eatAtom = function(e) {
|
|
3395
|
+
return this.regexp_eatPatternCharacters(e) || e.eat(46) || this.regexp_eatReverseSolidusAtomEscape(e) || this.regexp_eatCharacterClass(e) || this.regexp_eatUncapturingGroup(e) || this.regexp_eatCapturingGroup(e);
|
|
3396
|
+
}, q.regexp_eatReverseSolidusAtomEscape = function(e) {
|
|
3397
|
+
var t = e.pos;
|
|
3398
|
+
if (e.eat(92)) {
|
|
3399
|
+
if (this.regexp_eatAtomEscape(e)) return !0;
|
|
3400
|
+
e.pos = t;
|
|
3401
|
+
}
|
|
3402
|
+
return !1;
|
|
3403
|
+
}, q.regexp_eatUncapturingGroup = function(e) {
|
|
3404
|
+
var t = e.pos;
|
|
3405
|
+
if (e.eat(40)) {
|
|
3406
|
+
if (e.eat(63)) {
|
|
3407
|
+
if (this.options.ecmaVersion >= 16) {
|
|
3408
|
+
var n = this.regexp_eatModifiers(e), r = e.eat(45);
|
|
3409
|
+
if (n || r) {
|
|
3410
|
+
for (var i = 0; i < n.length; i++) {
|
|
3411
|
+
var a = n.charAt(i);
|
|
3412
|
+
n.indexOf(a, i + 1) > -1 && e.raise("Duplicate regular expression modifiers");
|
|
3413
|
+
}
|
|
3414
|
+
if (r) {
|
|
3415
|
+
var o = this.regexp_eatModifiers(e);
|
|
3416
|
+
!n && !o && e.current() === 58 && e.raise("Invalid regular expression modifiers");
|
|
3417
|
+
for (var s = 0; s < o.length; s++) {
|
|
3418
|
+
var c = o.charAt(s);
|
|
3419
|
+
(o.indexOf(c, s + 1) > -1 || n.indexOf(c) > -1) && e.raise("Duplicate regular expression modifiers");
|
|
3420
|
+
}
|
|
3421
|
+
}
|
|
3422
|
+
}
|
|
3423
|
+
}
|
|
3424
|
+
if (e.eat(58)) {
|
|
3425
|
+
if (this.regexp_disjunction(e), e.eat(41)) return !0;
|
|
3426
|
+
e.raise("Unterminated group");
|
|
3427
|
+
}
|
|
3428
|
+
}
|
|
3429
|
+
e.pos = t;
|
|
3430
|
+
}
|
|
3431
|
+
return !1;
|
|
3432
|
+
}, q.regexp_eatCapturingGroup = function(e) {
|
|
3433
|
+
if (e.eat(40)) {
|
|
3434
|
+
if (this.options.ecmaVersion >= 9 ? this.regexp_groupSpecifier(e) : e.current() === 63 && e.raise("Invalid group"), this.regexp_disjunction(e), e.eat(41)) return e.numCapturingParens += 1, !0;
|
|
3435
|
+
e.raise("Unterminated group");
|
|
3436
|
+
}
|
|
3437
|
+
return !1;
|
|
3438
|
+
}, q.regexp_eatModifiers = function(e) {
|
|
3439
|
+
for (var t = "", n = 0; (n = e.current()) !== -1 && Ct(n);) t += j(n), e.advance();
|
|
3440
|
+
return t;
|
|
3441
|
+
};
|
|
3442
|
+
function Ct(e) {
|
|
3443
|
+
return e === 105 || e === 109 || e === 115;
|
|
3444
|
+
}
|
|
3445
|
+
q.regexp_eatExtendedAtom = function(e) {
|
|
3446
|
+
return e.eat(46) || this.regexp_eatReverseSolidusAtomEscape(e) || this.regexp_eatCharacterClass(e) || this.regexp_eatUncapturingGroup(e) || this.regexp_eatCapturingGroup(e) || this.regexp_eatInvalidBracedQuantifier(e) || this.regexp_eatExtendedPatternCharacter(e);
|
|
3447
|
+
}, q.regexp_eatInvalidBracedQuantifier = function(e) {
|
|
3448
|
+
return this.regexp_eatBracedQuantifier(e, !0) && e.raise("Nothing to repeat"), !1;
|
|
3449
|
+
}, q.regexp_eatSyntaxCharacter = function(e) {
|
|
3450
|
+
var t = e.current();
|
|
3451
|
+
return wt(t) ? (e.lastIntValue = t, e.advance(), !0) : !1;
|
|
3452
|
+
};
|
|
3453
|
+
function wt(e) {
|
|
3454
|
+
return e === 36 || e >= 40 && e <= 43 || e === 46 || e === 63 || e >= 91 && e <= 94 || e >= 123 && e <= 125;
|
|
3455
|
+
}
|
|
3456
|
+
q.regexp_eatPatternCharacters = function(e) {
|
|
3457
|
+
for (var t = e.pos, n = 0; (n = e.current()) !== -1 && !wt(n);) e.advance();
|
|
3458
|
+
return e.pos !== t;
|
|
3459
|
+
}, q.regexp_eatExtendedPatternCharacter = function(e) {
|
|
3460
|
+
var t = e.current();
|
|
3461
|
+
return t !== -1 && t !== 36 && !(t >= 40 && t <= 43) && t !== 46 && t !== 63 && t !== 91 && t !== 94 && t !== 124 ? (e.advance(), !0) : !1;
|
|
3462
|
+
}, q.regexp_groupSpecifier = function(e) {
|
|
3463
|
+
if (e.eat(63)) {
|
|
3464
|
+
this.regexp_eatGroupName(e) || e.raise("Invalid group");
|
|
3465
|
+
var t = this.options.ecmaVersion >= 16, n = e.groupNames[e.lastStringValue];
|
|
3466
|
+
if (n) if (t) for (var r = 0, i = n; r < i.length; r += 1) i[r].separatedFrom(e.branchID) || e.raise("Duplicate capture group name");
|
|
3467
|
+
else e.raise("Duplicate capture group name");
|
|
3468
|
+
t ? (n || (e.groupNames[e.lastStringValue] = [])).push(e.branchID) : e.groupNames[e.lastStringValue] = !0;
|
|
3469
|
+
}
|
|
3470
|
+
}, q.regexp_eatGroupName = function(e) {
|
|
3471
|
+
if (e.lastStringValue = "", e.eat(60)) {
|
|
3472
|
+
if (this.regexp_eatRegExpIdentifierName(e) && e.eat(62)) return !0;
|
|
3473
|
+
e.raise("Invalid capture group name");
|
|
3474
|
+
}
|
|
3475
|
+
return !1;
|
|
3476
|
+
}, q.regexp_eatRegExpIdentifierName = function(e) {
|
|
3477
|
+
if (e.lastStringValue = "", this.regexp_eatRegExpIdentifierStart(e)) {
|
|
3478
|
+
for (e.lastStringValue += j(e.lastIntValue); this.regexp_eatRegExpIdentifierPart(e);) e.lastStringValue += j(e.lastIntValue);
|
|
3479
|
+
return !0;
|
|
3480
|
+
}
|
|
3481
|
+
return !1;
|
|
3482
|
+
}, q.regexp_eatRegExpIdentifierStart = function(e) {
|
|
3483
|
+
var t = e.pos, n = this.options.ecmaVersion >= 11, r = e.current(n);
|
|
3484
|
+
return e.advance(n), r === 92 && this.regexp_eatRegExpUnicodeEscapeSequence(e, n) && (r = e.lastIntValue), Tt(r) ? (e.lastIntValue = r, !0) : (e.pos = t, !1);
|
|
3485
|
+
};
|
|
3486
|
+
function Tt(e) {
|
|
3487
|
+
return v(e, !0) || e === 36 || e === 95;
|
|
3488
|
+
}
|
|
3489
|
+
q.regexp_eatRegExpIdentifierPart = function(e) {
|
|
3490
|
+
var t = e.pos, n = this.options.ecmaVersion >= 11, r = e.current(n);
|
|
3491
|
+
return e.advance(n), r === 92 && this.regexp_eatRegExpUnicodeEscapeSequence(e, n) && (r = e.lastIntValue), Et(r) ? (e.lastIntValue = r, !0) : (e.pos = t, !1);
|
|
3492
|
+
};
|
|
3493
|
+
function Et(e) {
|
|
3494
|
+
return y(e, !0) || e === 36 || e === 95 || e === 8204 || e === 8205;
|
|
3495
|
+
}
|
|
3496
|
+
q.regexp_eatAtomEscape = function(e) {
|
|
3497
|
+
return this.regexp_eatBackReference(e) || this.regexp_eatCharacterClassEscape(e) || this.regexp_eatCharacterEscape(e) || e.switchN && this.regexp_eatKGroupName(e) ? !0 : (e.switchU && (e.current() === 99 && e.raise("Invalid unicode escape"), e.raise("Invalid escape")), !1);
|
|
3498
|
+
}, q.regexp_eatBackReference = function(e) {
|
|
3499
|
+
var t = e.pos;
|
|
3500
|
+
if (this.regexp_eatDecimalEscape(e)) {
|
|
3501
|
+
var n = e.lastIntValue;
|
|
3502
|
+
if (e.switchU) return n > e.maxBackReference && (e.maxBackReference = n), !0;
|
|
3503
|
+
if (n <= e.numCapturingParens) return !0;
|
|
3504
|
+
e.pos = t;
|
|
3505
|
+
}
|
|
3506
|
+
return !1;
|
|
3507
|
+
}, q.regexp_eatKGroupName = function(e) {
|
|
3508
|
+
if (e.eat(107)) {
|
|
3509
|
+
if (this.regexp_eatGroupName(e)) return e.backReferenceNames.push(e.lastStringValue), !0;
|
|
3510
|
+
e.raise("Invalid named reference");
|
|
3511
|
+
}
|
|
3512
|
+
return !1;
|
|
3513
|
+
}, q.regexp_eatCharacterEscape = function(e) {
|
|
3514
|
+
return this.regexp_eatControlEscape(e) || this.regexp_eatCControlLetter(e) || this.regexp_eatZero(e) || this.regexp_eatHexEscapeSequence(e) || this.regexp_eatRegExpUnicodeEscapeSequence(e, !1) || !e.switchU && this.regexp_eatLegacyOctalEscapeSequence(e) || this.regexp_eatIdentityEscape(e);
|
|
3515
|
+
}, q.regexp_eatCControlLetter = function(e) {
|
|
3516
|
+
var t = e.pos;
|
|
3517
|
+
if (e.eat(99)) {
|
|
3518
|
+
if (this.regexp_eatControlLetter(e)) return !0;
|
|
3519
|
+
e.pos = t;
|
|
3520
|
+
}
|
|
3521
|
+
return !1;
|
|
3522
|
+
}, q.regexp_eatZero = function(e) {
|
|
3523
|
+
return e.current() === 48 && !It(e.lookahead()) ? (e.lastIntValue = 0, e.advance(), !0) : !1;
|
|
3524
|
+
}, q.regexp_eatControlEscape = function(e) {
|
|
3525
|
+
var t = e.current();
|
|
3526
|
+
return t === 116 ? (e.lastIntValue = 9, e.advance(), !0) : t === 110 ? (e.lastIntValue = 10, e.advance(), !0) : t === 118 ? (e.lastIntValue = 11, e.advance(), !0) : t === 102 ? (e.lastIntValue = 12, e.advance(), !0) : t === 114 ? (e.lastIntValue = 13, e.advance(), !0) : !1;
|
|
3527
|
+
}, q.regexp_eatControlLetter = function(e) {
|
|
3528
|
+
var t = e.current();
|
|
3529
|
+
return Dt(t) ? (e.lastIntValue = t % 32, e.advance(), !0) : !1;
|
|
3530
|
+
};
|
|
3531
|
+
function Dt(e) {
|
|
3532
|
+
return e >= 65 && e <= 90 || e >= 97 && e <= 122;
|
|
3533
|
+
}
|
|
3534
|
+
q.regexp_eatRegExpUnicodeEscapeSequence = function(e, t) {
|
|
3535
|
+
t === void 0 && (t = !1);
|
|
3536
|
+
var n = e.pos, r = t || e.switchU;
|
|
3537
|
+
if (e.eat(117)) {
|
|
3538
|
+
if (this.regexp_eatFixedHexDigits(e, 4)) {
|
|
3539
|
+
var i = e.lastIntValue;
|
|
3540
|
+
if (r && i >= 55296 && i <= 56319) {
|
|
3541
|
+
var a = e.pos;
|
|
3542
|
+
if (e.eat(92) && e.eat(117) && this.regexp_eatFixedHexDigits(e, 4)) {
|
|
3543
|
+
var o = e.lastIntValue;
|
|
3544
|
+
if (o >= 56320 && o <= 57343) return e.lastIntValue = (i - 55296) * 1024 + (o - 56320) + 65536, !0;
|
|
3545
|
+
}
|
|
3546
|
+
e.pos = a, e.lastIntValue = i;
|
|
3547
|
+
}
|
|
3548
|
+
return !0;
|
|
3549
|
+
}
|
|
3550
|
+
if (r && e.eat(123) && this.regexp_eatHexDigits(e) && e.eat(125) && Ot(e.lastIntValue)) return !0;
|
|
3551
|
+
r && e.raise("Invalid unicode escape"), e.pos = n;
|
|
3552
|
+
}
|
|
3553
|
+
return !1;
|
|
3554
|
+
};
|
|
3555
|
+
function Ot(e) {
|
|
3556
|
+
return e >= 0 && e <= 1114111;
|
|
3557
|
+
}
|
|
3558
|
+
q.regexp_eatIdentityEscape = function(e) {
|
|
3559
|
+
if (e.switchU) return this.regexp_eatSyntaxCharacter(e) ? !0 : e.eat(47) ? (e.lastIntValue = 47, !0) : !1;
|
|
3560
|
+
var t = e.current();
|
|
3561
|
+
return t !== 99 && (!e.switchN || t !== 107) ? (e.lastIntValue = t, e.advance(), !0) : !1;
|
|
3562
|
+
}, q.regexp_eatDecimalEscape = function(e) {
|
|
3563
|
+
e.lastIntValue = 0;
|
|
3564
|
+
var t = e.current();
|
|
3565
|
+
if (t >= 49 && t <= 57) {
|
|
3566
|
+
do
|
|
3567
|
+
e.lastIntValue = 10 * e.lastIntValue + (t - 48), e.advance();
|
|
3568
|
+
while ((t = e.current()) >= 48 && t <= 57);
|
|
3569
|
+
return !0;
|
|
3570
|
+
}
|
|
3571
|
+
return !1;
|
|
3572
|
+
};
|
|
3573
|
+
var kt = 0, Y = 1, X = 2;
|
|
3574
|
+
q.regexp_eatCharacterClassEscape = function(e) {
|
|
3575
|
+
var t = e.current();
|
|
3576
|
+
if (At(t)) return e.lastIntValue = -1, e.advance(), Y;
|
|
3577
|
+
var n = !1;
|
|
3578
|
+
if (e.switchU && this.options.ecmaVersion >= 9 && ((n = t === 80) || t === 112)) {
|
|
3579
|
+
e.lastIntValue = -1, e.advance();
|
|
3580
|
+
var r;
|
|
3581
|
+
if (e.eat(123) && (r = this.regexp_eatUnicodePropertyValueExpression(e)) && e.eat(125)) return n && r === X && e.raise("Invalid property name"), r;
|
|
3582
|
+
e.raise("Invalid property name");
|
|
3583
|
+
}
|
|
3584
|
+
return kt;
|
|
3585
|
+
};
|
|
3586
|
+
function At(e) {
|
|
3587
|
+
return e === 100 || e === 68 || e === 115 || e === 83 || e === 119 || e === 87;
|
|
3588
|
+
}
|
|
3589
|
+
q.regexp_eatUnicodePropertyValueExpression = function(e) {
|
|
3590
|
+
var t = e.pos;
|
|
3591
|
+
if (this.regexp_eatUnicodePropertyName(e) && e.eat(61)) {
|
|
3592
|
+
var n = e.lastStringValue;
|
|
3593
|
+
if (this.regexp_eatUnicodePropertyValue(e)) {
|
|
3594
|
+
var r = e.lastStringValue;
|
|
3595
|
+
return this.regexp_validateUnicodePropertyNameAndValue(e, n, r), Y;
|
|
3596
|
+
}
|
|
3597
|
+
}
|
|
3598
|
+
if (e.pos = t, this.regexp_eatLoneUnicodePropertyNameOrValue(e)) {
|
|
3599
|
+
var i = e.lastStringValue;
|
|
3600
|
+
return this.regexp_validateUnicodePropertyNameOrValue(e, i);
|
|
3601
|
+
}
|
|
3602
|
+
return kt;
|
|
3603
|
+
}, q.regexp_validateUnicodePropertyNameAndValue = function(e, t, n) {
|
|
3604
|
+
k(e.unicodeProperties.nonBinary, t) || e.raise("Invalid property name"), e.unicodeProperties.nonBinary[t].test(n) || e.raise("Invalid property value");
|
|
3605
|
+
}, q.regexp_validateUnicodePropertyNameOrValue = function(e, t) {
|
|
3606
|
+
if (e.unicodeProperties.binary.test(t)) return Y;
|
|
3607
|
+
if (e.switchV && e.unicodeProperties.binaryOfStrings.test(t)) return X;
|
|
3608
|
+
e.raise("Invalid property name");
|
|
3609
|
+
}, q.regexp_eatUnicodePropertyName = function(e) {
|
|
3610
|
+
var t = 0;
|
|
3611
|
+
for (e.lastStringValue = ""; jt(t = e.current());) e.lastStringValue += j(t), e.advance();
|
|
3612
|
+
return e.lastStringValue !== "";
|
|
3613
|
+
};
|
|
3614
|
+
function jt(e) {
|
|
3615
|
+
return Dt(e) || e === 95;
|
|
3616
|
+
}
|
|
3617
|
+
q.regexp_eatUnicodePropertyValue = function(e) {
|
|
3618
|
+
var t = 0;
|
|
3619
|
+
for (e.lastStringValue = ""; Mt(t = e.current());) e.lastStringValue += j(t), e.advance();
|
|
3620
|
+
return e.lastStringValue !== "";
|
|
3621
|
+
};
|
|
3622
|
+
function Mt(e) {
|
|
3623
|
+
return jt(e) || It(e);
|
|
3624
|
+
}
|
|
3625
|
+
q.regexp_eatLoneUnicodePropertyNameOrValue = function(e) {
|
|
3626
|
+
return this.regexp_eatUnicodePropertyValue(e);
|
|
3627
|
+
}, q.regexp_eatCharacterClass = function(e) {
|
|
3628
|
+
if (e.eat(91)) {
|
|
3629
|
+
var t = e.eat(94), n = this.regexp_classContents(e);
|
|
3630
|
+
return e.eat(93) || e.raise("Unterminated character class"), t && n === X && e.raise("Negated character class may contain strings"), !0;
|
|
3631
|
+
}
|
|
3632
|
+
return !1;
|
|
3633
|
+
}, q.regexp_classContents = function(e) {
|
|
3634
|
+
return e.current() === 93 ? Y : e.switchV ? this.regexp_classSetExpression(e) : (this.regexp_nonEmptyClassRanges(e), Y);
|
|
3635
|
+
}, q.regexp_nonEmptyClassRanges = function(e) {
|
|
3636
|
+
for (; this.regexp_eatClassAtom(e);) {
|
|
3637
|
+
var t = e.lastIntValue;
|
|
3638
|
+
if (e.eat(45) && this.regexp_eatClassAtom(e)) {
|
|
3639
|
+
var n = e.lastIntValue;
|
|
3640
|
+
e.switchU && (t === -1 || n === -1) && e.raise("Invalid character class"), t !== -1 && n !== -1 && t > n && e.raise("Range out of order in character class");
|
|
3641
|
+
}
|
|
3642
|
+
}
|
|
3643
|
+
}, q.regexp_eatClassAtom = function(e) {
|
|
3644
|
+
var t = e.pos;
|
|
3645
|
+
if (e.eat(92)) {
|
|
3646
|
+
if (this.regexp_eatClassEscape(e)) return !0;
|
|
3647
|
+
if (e.switchU) {
|
|
3648
|
+
var n = e.current();
|
|
3649
|
+
(n === 99 || zt(n)) && e.raise("Invalid class escape"), e.raise("Invalid escape");
|
|
3650
|
+
}
|
|
3651
|
+
e.pos = t;
|
|
3652
|
+
}
|
|
3653
|
+
var r = e.current();
|
|
3654
|
+
return r === 93 ? !1 : (e.lastIntValue = r, e.advance(), !0);
|
|
3655
|
+
}, q.regexp_eatClassEscape = function(e) {
|
|
3656
|
+
var t = e.pos;
|
|
3657
|
+
if (e.eat(98)) return e.lastIntValue = 8, !0;
|
|
3658
|
+
if (e.switchU && e.eat(45)) return e.lastIntValue = 45, !0;
|
|
3659
|
+
if (!e.switchU && e.eat(99)) {
|
|
3660
|
+
if (this.regexp_eatClassControlLetter(e)) return !0;
|
|
3661
|
+
e.pos = t;
|
|
3662
|
+
}
|
|
3663
|
+
return this.regexp_eatCharacterClassEscape(e) || this.regexp_eatCharacterEscape(e);
|
|
3664
|
+
}, q.regexp_classSetExpression = function(e) {
|
|
3665
|
+
var t = Y, n;
|
|
3666
|
+
if (!this.regexp_eatClassSetRange(e)) if (n = this.regexp_eatClassSetOperand(e)) {
|
|
3667
|
+
n === X && (t = X);
|
|
3668
|
+
for (var r = e.pos; e.eatChars([38, 38]);) {
|
|
3669
|
+
if (e.current() !== 38 && (n = this.regexp_eatClassSetOperand(e))) {
|
|
3670
|
+
n !== X && (t = Y);
|
|
3671
|
+
continue;
|
|
3672
|
+
}
|
|
3673
|
+
e.raise("Invalid character in character class");
|
|
3674
|
+
}
|
|
3675
|
+
if (r !== e.pos) return t;
|
|
3676
|
+
for (; e.eatChars([45, 45]);) this.regexp_eatClassSetOperand(e) || e.raise("Invalid character in character class");
|
|
3677
|
+
if (r !== e.pos) return t;
|
|
3678
|
+
} else e.raise("Invalid character in character class");
|
|
3679
|
+
for (;;) if (!this.regexp_eatClassSetRange(e)) {
|
|
3680
|
+
if (n = this.regexp_eatClassSetOperand(e), !n) return t;
|
|
3681
|
+
n === X && (t = X);
|
|
3682
|
+
}
|
|
3683
|
+
}, q.regexp_eatClassSetRange = function(e) {
|
|
3684
|
+
var t = e.pos;
|
|
3685
|
+
if (this.regexp_eatClassSetCharacter(e)) {
|
|
3686
|
+
var n = e.lastIntValue;
|
|
3687
|
+
if (e.eat(45) && this.regexp_eatClassSetCharacter(e)) {
|
|
3688
|
+
var r = e.lastIntValue;
|
|
3689
|
+
return n !== -1 && r !== -1 && n > r && e.raise("Range out of order in character class"), !0;
|
|
3690
|
+
}
|
|
3691
|
+
e.pos = t;
|
|
3692
|
+
}
|
|
3693
|
+
return !1;
|
|
3694
|
+
}, q.regexp_eatClassSetOperand = function(e) {
|
|
3695
|
+
return this.regexp_eatClassSetCharacter(e) ? Y : this.regexp_eatClassStringDisjunction(e) || this.regexp_eatNestedClass(e);
|
|
3696
|
+
}, q.regexp_eatNestedClass = function(e) {
|
|
3697
|
+
var t = e.pos;
|
|
3698
|
+
if (e.eat(91)) {
|
|
3699
|
+
var n = e.eat(94), r = this.regexp_classContents(e);
|
|
3700
|
+
if (e.eat(93)) return n && r === X && e.raise("Negated character class may contain strings"), r;
|
|
3701
|
+
e.pos = t;
|
|
3702
|
+
}
|
|
3703
|
+
if (e.eat(92)) {
|
|
3704
|
+
var i = this.regexp_eatCharacterClassEscape(e);
|
|
3705
|
+
if (i) return i;
|
|
3706
|
+
e.pos = t;
|
|
3707
|
+
}
|
|
3708
|
+
return null;
|
|
3709
|
+
}, q.regexp_eatClassStringDisjunction = function(e) {
|
|
3710
|
+
var t = e.pos;
|
|
3711
|
+
if (e.eatChars([92, 113])) {
|
|
3712
|
+
if (e.eat(123)) {
|
|
3713
|
+
var n = this.regexp_classStringDisjunctionContents(e);
|
|
3714
|
+
if (e.eat(125)) return n;
|
|
3715
|
+
} else e.raise("Invalid escape");
|
|
3716
|
+
e.pos = t;
|
|
3717
|
+
}
|
|
3718
|
+
return null;
|
|
3719
|
+
}, q.regexp_classStringDisjunctionContents = function(e) {
|
|
3720
|
+
for (var t = this.regexp_classString(e); e.eat(124);) this.regexp_classString(e) === X && (t = X);
|
|
3721
|
+
return t;
|
|
3722
|
+
}, q.regexp_classString = function(e) {
|
|
3723
|
+
for (var t = 0; this.regexp_eatClassSetCharacter(e);) t++;
|
|
3724
|
+
return t === 1 ? Y : X;
|
|
3725
|
+
}, q.regexp_eatClassSetCharacter = function(e) {
|
|
3726
|
+
var t = e.pos;
|
|
3727
|
+
if (e.eat(92)) return this.regexp_eatCharacterEscape(e) || this.regexp_eatClassSetReservedPunctuator(e) ? !0 : e.eat(98) ? (e.lastIntValue = 8, !0) : (e.pos = t, !1);
|
|
3728
|
+
var n = e.current();
|
|
3729
|
+
return n < 0 || n === e.lookahead() && Nt(n) || Pt(n) ? !1 : (e.advance(), e.lastIntValue = n, !0);
|
|
3730
|
+
};
|
|
3731
|
+
function Nt(e) {
|
|
3732
|
+
return e === 33 || e >= 35 && e <= 38 || e >= 42 && e <= 44 || e === 46 || e >= 58 && e <= 64 || e === 94 || e === 96 || e === 126;
|
|
3733
|
+
}
|
|
3734
|
+
function Pt(e) {
|
|
3735
|
+
return e === 40 || e === 41 || e === 45 || e === 47 || e >= 91 && e <= 93 || e >= 123 && e <= 125;
|
|
3736
|
+
}
|
|
3737
|
+
q.regexp_eatClassSetReservedPunctuator = function(e) {
|
|
3738
|
+
var t = e.current();
|
|
3739
|
+
return Ft(t) ? (e.lastIntValue = t, e.advance(), !0) : !1;
|
|
3740
|
+
};
|
|
3741
|
+
function Ft(e) {
|
|
3742
|
+
return e === 33 || e === 35 || e === 37 || e === 38 || e === 44 || e === 45 || e >= 58 && e <= 62 || e === 64 || e === 96 || e === 126;
|
|
3743
|
+
}
|
|
3744
|
+
q.regexp_eatClassControlLetter = function(e) {
|
|
3745
|
+
var t = e.current();
|
|
3746
|
+
return It(t) || t === 95 ? (e.lastIntValue = t % 32, e.advance(), !0) : !1;
|
|
3747
|
+
}, q.regexp_eatHexEscapeSequence = function(e) {
|
|
3748
|
+
var t = e.pos;
|
|
3749
|
+
if (e.eat(120)) {
|
|
3750
|
+
if (this.regexp_eatFixedHexDigits(e, 2)) return !0;
|
|
3751
|
+
e.switchU && e.raise("Invalid escape"), e.pos = t;
|
|
3752
|
+
}
|
|
3753
|
+
return !1;
|
|
3754
|
+
}, q.regexp_eatDecimalDigits = function(e) {
|
|
3755
|
+
var t = e.pos, n = 0;
|
|
3756
|
+
for (e.lastIntValue = 0; It(n = e.current());) e.lastIntValue = 10 * e.lastIntValue + (n - 48), e.advance();
|
|
3757
|
+
return e.pos !== t;
|
|
3758
|
+
};
|
|
3759
|
+
function It(e) {
|
|
3760
|
+
return e >= 48 && e <= 57;
|
|
3761
|
+
}
|
|
3762
|
+
q.regexp_eatHexDigits = function(e) {
|
|
3763
|
+
var t = e.pos, n = 0;
|
|
3764
|
+
for (e.lastIntValue = 0; Lt(n = e.current());) e.lastIntValue = 16 * e.lastIntValue + Rt(n), e.advance();
|
|
3765
|
+
return e.pos !== t;
|
|
3766
|
+
};
|
|
3767
|
+
function Lt(e) {
|
|
3768
|
+
return e >= 48 && e <= 57 || e >= 65 && e <= 70 || e >= 97 && e <= 102;
|
|
3769
|
+
}
|
|
3770
|
+
function Rt(e) {
|
|
3771
|
+
return e >= 65 && e <= 70 ? 10 + (e - 65) : e >= 97 && e <= 102 ? 10 + (e - 97) : e - 48;
|
|
3772
|
+
}
|
|
3773
|
+
q.regexp_eatLegacyOctalEscapeSequence = function(e) {
|
|
3774
|
+
if (this.regexp_eatOctalDigit(e)) {
|
|
3775
|
+
var t = e.lastIntValue;
|
|
3776
|
+
if (this.regexp_eatOctalDigit(e)) {
|
|
3777
|
+
var n = e.lastIntValue;
|
|
3778
|
+
t <= 3 && this.regexp_eatOctalDigit(e) ? e.lastIntValue = t * 64 + n * 8 + e.lastIntValue : e.lastIntValue = t * 8 + n;
|
|
3779
|
+
} else e.lastIntValue = t;
|
|
3780
|
+
return !0;
|
|
3781
|
+
}
|
|
3782
|
+
return !1;
|
|
3783
|
+
}, q.regexp_eatOctalDigit = function(e) {
|
|
3784
|
+
var t = e.current();
|
|
3785
|
+
return zt(t) ? (e.lastIntValue = t - 48, e.advance(), !0) : (e.lastIntValue = 0, !1);
|
|
3786
|
+
};
|
|
3787
|
+
function zt(e) {
|
|
3788
|
+
return e >= 48 && e <= 55;
|
|
3789
|
+
}
|
|
3790
|
+
q.regexp_eatFixedHexDigits = function(e, t) {
|
|
3791
|
+
var n = e.pos;
|
|
3792
|
+
e.lastIntValue = 0;
|
|
3793
|
+
for (var r = 0; r < t; ++r) {
|
|
3794
|
+
var i = e.current();
|
|
3795
|
+
if (!Lt(i)) return e.pos = n, !1;
|
|
3796
|
+
e.lastIntValue = 16 * e.lastIntValue + Rt(i), e.advance();
|
|
3797
|
+
}
|
|
3798
|
+
return !0;
|
|
3799
|
+
};
|
|
3800
|
+
var Bt = function(e) {
|
|
3801
|
+
this.type = e.type, this.value = e.value, this.start = e.start, this.end = e.end, e.options.locations && (this.loc = new ge(e, e.startLoc, e.endLoc)), e.options.ranges && (this.range = [e.start, e.end]);
|
|
3802
|
+
}, Z = L.prototype;
|
|
3803
|
+
Z.next = function(e) {
|
|
3804
|
+
!e && this.type.keyword && this.containsEsc && this.raiseRecoverable(this.start, "Escape sequence in keyword " + this.type.keyword), this.options.onToken && this.options.onToken(new Bt(this)), this.lastTokEnd = this.end, this.lastTokStart = this.start, this.lastTokEndLoc = this.endLoc, this.lastTokStartLoc = this.startLoc, this.nextToken();
|
|
3805
|
+
}, Z.getToken = function() {
|
|
3806
|
+
return this.next(), new Bt(this);
|
|
3807
|
+
}, typeof Symbol < "u" && (Z[Symbol.iterator] = function() {
|
|
3808
|
+
var e = this;
|
|
3809
|
+
return { next: function() {
|
|
3810
|
+
var t = e.getToken();
|
|
3811
|
+
return {
|
|
3812
|
+
done: t.type === T.eof,
|
|
3813
|
+
value: t
|
|
3814
|
+
};
|
|
3815
|
+
} };
|
|
3816
|
+
}), Z.nextToken = function() {
|
|
3817
|
+
var e = this.curContext();
|
|
3818
|
+
if ((!e || !e.preserveSpace) && this.skipSpace(), this.start = this.pos, this.options.locations && (this.startLoc = this.curPosition()), this.pos >= this.input.length) return this.finishToken(T.eof);
|
|
3819
|
+
if (e.override) return e.override(this);
|
|
3820
|
+
this.readToken(this.fullCharCodeAtPos());
|
|
3821
|
+
}, Z.readToken = function(e) {
|
|
3822
|
+
return v(e, this.options.ecmaVersion >= 6) || e === 92 ? this.readWord() : this.getTokenFromCode(e);
|
|
3823
|
+
}, Z.fullCharCodeAt = function(e) {
|
|
3824
|
+
var t = this.input.charCodeAt(e);
|
|
3825
|
+
if (t <= 55295 || t >= 56320) return t;
|
|
3826
|
+
var n = this.input.charCodeAt(e + 1);
|
|
3827
|
+
return n <= 56319 || n >= 57344 ? t : (t << 10) + n - 56613888;
|
|
3828
|
+
}, Z.fullCharCodeAtPos = function() {
|
|
3829
|
+
return this.fullCharCodeAt(this.pos);
|
|
3830
|
+
}, Z.skipBlockComment = function() {
|
|
3831
|
+
var e = this.options.onComment && this.curPosition(), t = this.pos, n = this.input.indexOf("*/", this.pos += 2);
|
|
3832
|
+
if (n === -1 && this.raise(this.pos - 2, "Unterminated comment"), this.pos = n + 2, this.options.locations) for (var r = void 0, i = t; (r = ce(this.input, i, this.pos)) > -1;) ++this.curLine, i = this.lineStart = r;
|
|
3833
|
+
this.options.onComment && this.options.onComment(!0, this.input.slice(t + 2, n), t, this.pos, e, this.curPosition());
|
|
3834
|
+
}, Z.skipLineComment = function(e) {
|
|
3835
|
+
for (var t = this.pos, n = this.options.onComment && this.curPosition(), r = this.input.charCodeAt(this.pos += e); this.pos < this.input.length && !D(r);) r = this.input.charCodeAt(++this.pos);
|
|
3836
|
+
this.options.onComment && this.options.onComment(!1, this.input.slice(t + e, this.pos), t, this.pos, n, this.curPosition());
|
|
3837
|
+
}, Z.skipSpace = function() {
|
|
3838
|
+
loop: for (; this.pos < this.input.length;) {
|
|
3839
|
+
var e = this.input.charCodeAt(this.pos);
|
|
3840
|
+
switch (e) {
|
|
3841
|
+
case 32:
|
|
3842
|
+
case 160:
|
|
3843
|
+
++this.pos;
|
|
3844
|
+
break;
|
|
3845
|
+
case 13: this.input.charCodeAt(this.pos + 1) === 10 && ++this.pos;
|
|
3846
|
+
case 10:
|
|
3847
|
+
case 8232:
|
|
3848
|
+
case 8233:
|
|
3849
|
+
++this.pos, this.options.locations && (++this.curLine, this.lineStart = this.pos);
|
|
3850
|
+
break;
|
|
3851
|
+
case 47:
|
|
3852
|
+
switch (this.input.charCodeAt(this.pos + 1)) {
|
|
3853
|
+
case 42:
|
|
3854
|
+
this.skipBlockComment();
|
|
3855
|
+
break;
|
|
3856
|
+
case 47:
|
|
3857
|
+
this.skipLineComment(2);
|
|
3858
|
+
break;
|
|
3859
|
+
default: break loop;
|
|
3860
|
+
}
|
|
3861
|
+
break;
|
|
3862
|
+
default: if (e > 8 && e < 14 || e >= 5760 && le.test(String.fromCharCode(e))) ++this.pos;
|
|
3863
|
+
else break loop;
|
|
3864
|
+
}
|
|
3865
|
+
}
|
|
3866
|
+
}, Z.finishToken = function(e, t) {
|
|
3867
|
+
this.end = this.pos, this.options.locations && (this.endLoc = this.curPosition());
|
|
3868
|
+
var n = this.type;
|
|
3869
|
+
this.type = e, this.value = t, this.updateContext(n);
|
|
3870
|
+
}, Z.readToken_dot = function() {
|
|
3871
|
+
var e = this.input.charCodeAt(this.pos + 1);
|
|
3872
|
+
if (e >= 48 && e <= 57) return this.readNumber(!0);
|
|
3873
|
+
var t = this.input.charCodeAt(this.pos + 2);
|
|
3874
|
+
return this.options.ecmaVersion >= 6 && e === 46 && t === 46 ? (this.pos += 3, this.finishToken(T.ellipsis)) : (++this.pos, this.finishToken(T.dot));
|
|
3875
|
+
}, Z.readToken_slash = function() {
|
|
3876
|
+
var e = this.input.charCodeAt(this.pos + 1);
|
|
3877
|
+
return this.exprAllowed ? (++this.pos, this.readRegexp()) : e === 61 ? this.finishOp(T.assign, 2) : this.finishOp(T.slash, 1);
|
|
3878
|
+
}, Z.readToken_mult_modulo_exp = function(e) {
|
|
3879
|
+
var t = this.input.charCodeAt(this.pos + 1), n = 1, r = e === 42 ? T.star : T.modulo;
|
|
3880
|
+
return this.options.ecmaVersion >= 7 && e === 42 && t === 42 && (++n, r = T.starstar, t = this.input.charCodeAt(this.pos + 2)), t === 61 ? this.finishOp(T.assign, n + 1) : this.finishOp(r, n);
|
|
3881
|
+
}, Z.readToken_pipe_amp = function(e) {
|
|
3882
|
+
var t = this.input.charCodeAt(this.pos + 1);
|
|
3883
|
+
return t === e ? this.options.ecmaVersion >= 12 && this.input.charCodeAt(this.pos + 2) === 61 ? this.finishOp(T.assign, 3) : this.finishOp(e === 124 ? T.logicalOR : T.logicalAND, 2) : t === 61 ? this.finishOp(T.assign, 2) : this.finishOp(e === 124 ? T.bitwiseOR : T.bitwiseAND, 1);
|
|
3884
|
+
}, Z.readToken_caret = function() {
|
|
3885
|
+
return this.input.charCodeAt(this.pos + 1) === 61 ? this.finishOp(T.assign, 2) : this.finishOp(T.bitwiseXOR, 1);
|
|
3886
|
+
}, Z.readToken_plus_min = function(e) {
|
|
3887
|
+
var t = this.input.charCodeAt(this.pos + 1);
|
|
3888
|
+
return t === e ? t === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 && (this.lastTokEnd === 0 || E.test(this.input.slice(this.lastTokEnd, this.pos))) ? (this.skipLineComment(3), this.skipSpace(), this.nextToken()) : this.finishOp(T.incDec, 2) : t === 61 ? this.finishOp(T.assign, 2) : this.finishOp(T.plusMin, 1);
|
|
3889
|
+
}, Z.readToken_lt_gt = function(e) {
|
|
3890
|
+
var t = this.input.charCodeAt(this.pos + 1), n = 1;
|
|
3891
|
+
return t === e ? (n = e === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2, this.input.charCodeAt(this.pos + n) === 61 ? this.finishOp(T.assign, n + 1) : this.finishOp(T.bitShift, n)) : t === 33 && e === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 && this.input.charCodeAt(this.pos + 3) === 45 ? (this.skipLineComment(4), this.skipSpace(), this.nextToken()) : (t === 61 && (n = 2), this.finishOp(T.relational, n));
|
|
3892
|
+
}, Z.readToken_eq_excl = function(e) {
|
|
3893
|
+
var t = this.input.charCodeAt(this.pos + 1);
|
|
3894
|
+
return t === 61 ? this.finishOp(T.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2) : e === 61 && t === 62 && this.options.ecmaVersion >= 6 ? (this.pos += 2, this.finishToken(T.arrow)) : this.finishOp(e === 61 ? T.eq : T.prefix, 1);
|
|
3895
|
+
}, Z.readToken_question = function() {
|
|
3896
|
+
var e = this.options.ecmaVersion;
|
|
3897
|
+
if (e >= 11) {
|
|
3898
|
+
var t = this.input.charCodeAt(this.pos + 1);
|
|
3899
|
+
if (t === 46) {
|
|
3900
|
+
var n = this.input.charCodeAt(this.pos + 2);
|
|
3901
|
+
if (n < 48 || n > 57) return this.finishOp(T.questionDot, 2);
|
|
3902
|
+
}
|
|
3903
|
+
if (t === 63) return e >= 12 && this.input.charCodeAt(this.pos + 2) === 61 ? this.finishOp(T.assign, 3) : this.finishOp(T.coalesce, 2);
|
|
3904
|
+
}
|
|
3905
|
+
return this.finishOp(T.question, 1);
|
|
3906
|
+
}, Z.readToken_numberSign = function() {
|
|
3907
|
+
var e = this.options.ecmaVersion, t = 35;
|
|
3908
|
+
if (e >= 13 && (++this.pos, t = this.fullCharCodeAtPos(), v(t, !0) || t === 92)) return this.finishToken(T.privateId, this.readWord1());
|
|
3909
|
+
this.raise(this.pos, "Unexpected character '" + j(t) + "'");
|
|
3910
|
+
}, Z.getTokenFromCode = function(e) {
|
|
3911
|
+
switch (e) {
|
|
3912
|
+
case 46: return this.readToken_dot();
|
|
3913
|
+
case 40: return ++this.pos, this.finishToken(T.parenL);
|
|
3914
|
+
case 41: return ++this.pos, this.finishToken(T.parenR);
|
|
3915
|
+
case 59: return ++this.pos, this.finishToken(T.semi);
|
|
3916
|
+
case 44: return ++this.pos, this.finishToken(T.comma);
|
|
3917
|
+
case 91: return ++this.pos, this.finishToken(T.bracketL);
|
|
3918
|
+
case 93: return ++this.pos, this.finishToken(T.bracketR);
|
|
3919
|
+
case 123: return ++this.pos, this.finishToken(T.braceL);
|
|
3920
|
+
case 125: return ++this.pos, this.finishToken(T.braceR);
|
|
3921
|
+
case 58: return ++this.pos, this.finishToken(T.colon);
|
|
3922
|
+
case 96:
|
|
3923
|
+
if (this.options.ecmaVersion < 6) break;
|
|
3924
|
+
return ++this.pos, this.finishToken(T.backQuote);
|
|
3925
|
+
case 48:
|
|
3926
|
+
var t = this.input.charCodeAt(this.pos + 1);
|
|
3927
|
+
if (t === 120 || t === 88) return this.readRadixNumber(16);
|
|
3928
|
+
if (this.options.ecmaVersion >= 6) {
|
|
3929
|
+
if (t === 111 || t === 79) return this.readRadixNumber(8);
|
|
3930
|
+
if (t === 98 || t === 66) return this.readRadixNumber(2);
|
|
3931
|
+
}
|
|
3932
|
+
case 49:
|
|
3933
|
+
case 50:
|
|
3934
|
+
case 51:
|
|
3935
|
+
case 52:
|
|
3936
|
+
case 53:
|
|
3937
|
+
case 54:
|
|
3938
|
+
case 55:
|
|
3939
|
+
case 56:
|
|
3940
|
+
case 57: return this.readNumber(!1);
|
|
3941
|
+
case 34:
|
|
3942
|
+
case 39: return this.readString(e);
|
|
3943
|
+
case 47: return this.readToken_slash();
|
|
3944
|
+
case 37:
|
|
3945
|
+
case 42: return this.readToken_mult_modulo_exp(e);
|
|
3946
|
+
case 124:
|
|
3947
|
+
case 38: return this.readToken_pipe_amp(e);
|
|
3948
|
+
case 94: return this.readToken_caret();
|
|
3949
|
+
case 43:
|
|
3950
|
+
case 45: return this.readToken_plus_min(e);
|
|
3951
|
+
case 60:
|
|
3952
|
+
case 62: return this.readToken_lt_gt(e);
|
|
3953
|
+
case 61:
|
|
3954
|
+
case 33: return this.readToken_eq_excl(e);
|
|
3955
|
+
case 63: return this.readToken_question();
|
|
3956
|
+
case 126: return this.finishOp(T.prefix, 1);
|
|
3957
|
+
case 35: return this.readToken_numberSign();
|
|
3958
|
+
}
|
|
3959
|
+
this.raise(this.pos, "Unexpected character '" + j(e) + "'");
|
|
3960
|
+
}, Z.finishOp = function(e, t) {
|
|
3961
|
+
var n = this.input.slice(this.pos, this.pos + t);
|
|
3962
|
+
return this.pos += t, this.finishToken(e, n);
|
|
3963
|
+
}, Z.readRegexp = function() {
|
|
3964
|
+
for (var e, t, n = this.pos;;) {
|
|
3965
|
+
this.pos >= this.input.length && this.raise(n, "Unterminated regular expression");
|
|
3966
|
+
var r = this.input.charAt(this.pos);
|
|
3967
|
+
if (E.test(r) && this.raise(n, "Unterminated regular expression"), e) e = !1;
|
|
3968
|
+
else {
|
|
3969
|
+
if (r === "[") t = !0;
|
|
3970
|
+
else if (r === "]" && t) t = !1;
|
|
3971
|
+
else if (r === "/" && !t) break;
|
|
3972
|
+
e = r === "\\";
|
|
3973
|
+
}
|
|
3974
|
+
++this.pos;
|
|
3975
|
+
}
|
|
3976
|
+
var i = this.input.slice(n, this.pos);
|
|
3977
|
+
++this.pos;
|
|
3978
|
+
var a = this.pos, o = this.readWord1();
|
|
3979
|
+
this.containsEsc && this.unexpected(a);
|
|
3980
|
+
var s = this.regexpState ||= new J(this);
|
|
3981
|
+
s.reset(n, i, o), this.validateRegExpFlags(s), this.validateRegExpPattern(s);
|
|
3982
|
+
var c = null;
|
|
3983
|
+
try {
|
|
3984
|
+
c = new RegExp(i, o);
|
|
3985
|
+
} catch {}
|
|
3986
|
+
return this.finishToken(T.regexp, {
|
|
3987
|
+
pattern: i,
|
|
3988
|
+
flags: o,
|
|
3989
|
+
value: c
|
|
3990
|
+
});
|
|
3991
|
+
}, Z.readInt = function(e, t, n) {
|
|
3992
|
+
for (var r = this.options.ecmaVersion >= 12 && t === void 0, i = n && this.input.charCodeAt(this.pos) === 48, a = this.pos, o = 0, s = 0, c = 0, l = t ?? Infinity; c < l; ++c, ++this.pos) {
|
|
3993
|
+
var u = this.input.charCodeAt(this.pos), d = void 0;
|
|
3994
|
+
if (r && u === 95) {
|
|
3995
|
+
i && this.raiseRecoverable(this.pos, "Numeric separator is not allowed in legacy octal numeric literals"), s === 95 && this.raiseRecoverable(this.pos, "Numeric separator must be exactly one underscore"), c === 0 && this.raiseRecoverable(this.pos, "Numeric separator is not allowed at the first of digits"), s = u;
|
|
3996
|
+
continue;
|
|
3997
|
+
}
|
|
3998
|
+
if (d = u >= 97 ? u - 97 + 10 : u >= 65 ? u - 65 + 10 : u >= 48 && u <= 57 ? u - 48 : Infinity, d >= e) break;
|
|
3999
|
+
s = u, o = o * e + d;
|
|
4000
|
+
}
|
|
4001
|
+
return r && s === 95 && this.raiseRecoverable(this.pos - 1, "Numeric separator is not allowed at the last of digits"), this.pos === a || t != null && this.pos - a !== t ? null : o;
|
|
4002
|
+
};
|
|
4003
|
+
function Vt(e, t) {
|
|
4004
|
+
return t ? parseInt(e, 8) : parseFloat(e.replace(/_/g, ""));
|
|
4005
|
+
}
|
|
4006
|
+
function Ht(e) {
|
|
4007
|
+
return typeof BigInt == "function" ? BigInt(e.replace(/_/g, "")) : null;
|
|
4008
|
+
}
|
|
4009
|
+
Z.readRadixNumber = function(e) {
|
|
4010
|
+
var t = this.pos;
|
|
4011
|
+
this.pos += 2;
|
|
4012
|
+
var n = this.readInt(e);
|
|
4013
|
+
return n ?? this.raise(this.start + 2, "Expected number in radix " + e), this.options.ecmaVersion >= 11 && this.input.charCodeAt(this.pos) === 110 ? (n = Ht(this.input.slice(t, this.pos)), ++this.pos) : v(this.fullCharCodeAtPos()) && this.raise(this.pos, "Identifier directly after number"), this.finishToken(T.num, n);
|
|
4014
|
+
}, Z.readNumber = function(e) {
|
|
4015
|
+
var t = this.pos;
|
|
4016
|
+
!e && this.readInt(10, void 0, !0) === null && this.raise(t, "Invalid number");
|
|
4017
|
+
var n = this.pos - t >= 2 && this.input.charCodeAt(t) === 48;
|
|
4018
|
+
n && this.strict && this.raise(t, "Invalid number");
|
|
4019
|
+
var r = this.input.charCodeAt(this.pos);
|
|
4020
|
+
if (!n && !e && this.options.ecmaVersion >= 11 && r === 110) {
|
|
4021
|
+
var i = Ht(this.input.slice(t, this.pos));
|
|
4022
|
+
return ++this.pos, v(this.fullCharCodeAtPos()) && this.raise(this.pos, "Identifier directly after number"), this.finishToken(T.num, i);
|
|
4023
|
+
}
|
|
4024
|
+
n && /[89]/.test(this.input.slice(t, this.pos)) && (n = !1), r === 46 && !n && (++this.pos, this.readInt(10), r = this.input.charCodeAt(this.pos)), (r === 69 || r === 101) && !n && (r = this.input.charCodeAt(++this.pos), (r === 43 || r === 45) && ++this.pos, this.readInt(10) === null && this.raise(t, "Invalid number")), v(this.fullCharCodeAtPos()) && this.raise(this.pos, "Identifier directly after number");
|
|
4025
|
+
var a = Vt(this.input.slice(t, this.pos), n);
|
|
4026
|
+
return this.finishToken(T.num, a);
|
|
4027
|
+
}, Z.readCodePoint = function() {
|
|
4028
|
+
var e = this.input.charCodeAt(this.pos), t;
|
|
4029
|
+
if (e === 123) {
|
|
4030
|
+
this.options.ecmaVersion < 6 && this.unexpected();
|
|
4031
|
+
var n = ++this.pos;
|
|
4032
|
+
t = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos), ++this.pos, t > 1114111 && this.invalidStringToken(n, "Code point out of bounds");
|
|
4033
|
+
} else t = this.readHexChar(4);
|
|
4034
|
+
return t;
|
|
4035
|
+
}, Z.readString = function(e) {
|
|
4036
|
+
for (var t = "", n = ++this.pos;;) {
|
|
4037
|
+
this.pos >= this.input.length && this.raise(this.start, "Unterminated string constant");
|
|
4038
|
+
var r = this.input.charCodeAt(this.pos);
|
|
4039
|
+
if (r === e) break;
|
|
4040
|
+
r === 92 ? (t += this.input.slice(n, this.pos), t += this.readEscapedChar(!1), n = this.pos) : r === 8232 || r === 8233 ? (this.options.ecmaVersion < 10 && this.raise(this.start, "Unterminated string constant"), ++this.pos, this.options.locations && (this.curLine++, this.lineStart = this.pos)) : (D(r) && this.raise(this.start, "Unterminated string constant"), ++this.pos);
|
|
4041
|
+
}
|
|
4042
|
+
return t += this.input.slice(n, this.pos++), this.finishToken(T.string, t);
|
|
4043
|
+
};
|
|
4044
|
+
var Ut = {};
|
|
4045
|
+
Z.tryReadTemplateToken = function() {
|
|
4046
|
+
this.inTemplateElement = !0;
|
|
4047
|
+
try {
|
|
4048
|
+
this.readTmplToken();
|
|
4049
|
+
} catch (e) {
|
|
4050
|
+
if (e === Ut) this.readInvalidTemplateToken();
|
|
4051
|
+
else throw e;
|
|
4052
|
+
}
|
|
4053
|
+
this.inTemplateElement = !1;
|
|
4054
|
+
}, Z.invalidStringToken = function(e, t) {
|
|
4055
|
+
if (this.inTemplateElement && this.options.ecmaVersion >= 9) throw Ut;
|
|
4056
|
+
this.raise(e, t);
|
|
4057
|
+
}, Z.readTmplToken = function() {
|
|
4058
|
+
for (var e = "", t = this.pos;;) {
|
|
4059
|
+
this.pos >= this.input.length && this.raise(this.start, "Unterminated template");
|
|
4060
|
+
var n = this.input.charCodeAt(this.pos);
|
|
4061
|
+
if (n === 96 || n === 36 && this.input.charCodeAt(this.pos + 1) === 123) return this.pos === this.start && (this.type === T.template || this.type === T.invalidTemplate) ? n === 36 ? (this.pos += 2, this.finishToken(T.dollarBraceL)) : (++this.pos, this.finishToken(T.backQuote)) : (e += this.input.slice(t, this.pos), this.finishToken(T.template, e));
|
|
4062
|
+
if (n === 92) e += this.input.slice(t, this.pos), e += this.readEscapedChar(!0), t = this.pos;
|
|
4063
|
+
else if (D(n)) {
|
|
4064
|
+
switch (e += this.input.slice(t, this.pos), ++this.pos, n) {
|
|
4065
|
+
case 13: this.input.charCodeAt(this.pos) === 10 && ++this.pos;
|
|
4066
|
+
case 10:
|
|
4067
|
+
e += "\n";
|
|
4068
|
+
break;
|
|
4069
|
+
default:
|
|
4070
|
+
e += String.fromCharCode(n);
|
|
4071
|
+
break;
|
|
4072
|
+
}
|
|
4073
|
+
this.options.locations && (++this.curLine, this.lineStart = this.pos), t = this.pos;
|
|
4074
|
+
} else ++this.pos;
|
|
4075
|
+
}
|
|
4076
|
+
}, Z.readInvalidTemplateToken = function() {
|
|
4077
|
+
for (; this.pos < this.input.length; this.pos++) switch (this.input[this.pos]) {
|
|
4078
|
+
case "\\":
|
|
4079
|
+
++this.pos;
|
|
4080
|
+
break;
|
|
4081
|
+
case "$": if (this.input[this.pos + 1] !== "{") break;
|
|
4082
|
+
case "`": return this.finishToken(T.invalidTemplate, this.input.slice(this.start, this.pos));
|
|
4083
|
+
case "\r": this.input[this.pos + 1] === "\n" && ++this.pos;
|
|
4084
|
+
case "\n":
|
|
4085
|
+
case "\u2028":
|
|
4086
|
+
case "\u2029":
|
|
4087
|
+
++this.curLine, this.lineStart = this.pos + 1;
|
|
4088
|
+
break;
|
|
4089
|
+
}
|
|
4090
|
+
this.raise(this.start, "Unterminated template");
|
|
4091
|
+
}, Z.readEscapedChar = function(e) {
|
|
4092
|
+
var t = this.input.charCodeAt(++this.pos);
|
|
4093
|
+
switch (++this.pos, t) {
|
|
4094
|
+
case 110: return "\n";
|
|
4095
|
+
case 114: return "\r";
|
|
4096
|
+
case 120: return String.fromCharCode(this.readHexChar(2));
|
|
4097
|
+
case 117: return j(this.readCodePoint());
|
|
4098
|
+
case 116: return " ";
|
|
4099
|
+
case 98: return "\b";
|
|
4100
|
+
case 118: return "\v";
|
|
4101
|
+
case 102: return "\f";
|
|
4102
|
+
case 13: this.input.charCodeAt(this.pos) === 10 && ++this.pos;
|
|
4103
|
+
case 10: return this.options.locations && (this.lineStart = this.pos, ++this.curLine), "";
|
|
4104
|
+
case 56:
|
|
4105
|
+
case 57: if (this.strict && this.invalidStringToken(this.pos - 1, "Invalid escape sequence"), e) {
|
|
4106
|
+
var n = this.pos - 1;
|
|
4107
|
+
this.invalidStringToken(n, "Invalid escape sequence in template string");
|
|
4108
|
+
}
|
|
4109
|
+
default:
|
|
4110
|
+
if (t >= 48 && t <= 55) {
|
|
4111
|
+
var r = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0], i = parseInt(r, 8);
|
|
4112
|
+
return i > 255 && (r = r.slice(0, -1), i = parseInt(r, 8)), this.pos += r.length - 1, t = this.input.charCodeAt(this.pos), (r !== "0" || t === 56 || t === 57) && (this.strict || e) && this.invalidStringToken(this.pos - 1 - r.length, e ? "Octal literal in template string" : "Octal literal in strict mode"), String.fromCharCode(i);
|
|
4113
|
+
}
|
|
4114
|
+
return D(t) ? (this.options.locations && (this.lineStart = this.pos, ++this.curLine), "") : String.fromCharCode(t);
|
|
4115
|
+
}
|
|
4116
|
+
}, Z.readHexChar = function(e) {
|
|
4117
|
+
var t = this.pos, n = this.readInt(16, e);
|
|
4118
|
+
return n === null && this.invalidStringToken(t, "Bad character escape sequence"), n;
|
|
4119
|
+
}, Z.readWord1 = function() {
|
|
4120
|
+
this.containsEsc = !1;
|
|
4121
|
+
for (var e = "", t = !0, n = this.pos, r = this.options.ecmaVersion >= 6; this.pos < this.input.length;) {
|
|
4122
|
+
var i = this.fullCharCodeAtPos();
|
|
4123
|
+
if (y(i, r)) this.pos += i <= 65535 ? 1 : 2;
|
|
4124
|
+
else if (i === 92) {
|
|
4125
|
+
this.containsEsc = !0, e += this.input.slice(n, this.pos);
|
|
4126
|
+
var a = this.pos;
|
|
4127
|
+
this.input.charCodeAt(++this.pos) !== 117 && this.invalidStringToken(this.pos, "Expecting Unicode escape sequence \\uXXXX"), ++this.pos;
|
|
4128
|
+
var o = this.readCodePoint();
|
|
4129
|
+
(t ? v : y)(o, r) || this.invalidStringToken(a, "Invalid Unicode escape"), e += j(o), n = this.pos;
|
|
4130
|
+
} else break;
|
|
4131
|
+
t = !1;
|
|
4132
|
+
}
|
|
4133
|
+
return e + this.input.slice(n, this.pos);
|
|
4134
|
+
}, Z.readWord = function() {
|
|
4135
|
+
var e = this.readWord1(), t = T.name;
|
|
4136
|
+
return this.keywords.test(e) && (t = oe[e]), this.finishToken(t, e);
|
|
4137
|
+
}, L.acorn = {
|
|
4138
|
+
Parser: L,
|
|
4139
|
+
version: "8.17.0",
|
|
4140
|
+
defaultOptions: ve,
|
|
4141
|
+
Position: M,
|
|
4142
|
+
SourceLocation: ge,
|
|
4143
|
+
getLineInfo: _e,
|
|
4144
|
+
Node: Qe,
|
|
4145
|
+
TokenType: b,
|
|
4146
|
+
tokTypes: T,
|
|
4147
|
+
keywordTypes: oe,
|
|
4148
|
+
TokContext: H,
|
|
4149
|
+
tokContexts: U,
|
|
4150
|
+
isIdentifierChar: y,
|
|
4151
|
+
isIdentifierStart: v,
|
|
4152
|
+
Token: Bt,
|
|
4153
|
+
isNewLine: D,
|
|
4154
|
+
lineBreak: E,
|
|
4155
|
+
lineBreakG: se,
|
|
4156
|
+
nonASCIIwhitespace: le
|
|
4157
|
+
};
|
|
4158
|
+
function Wt(e, t) {
|
|
4159
|
+
return L.parse(e, t);
|
|
4160
|
+
}
|
|
4161
|
+
function Q(e, t, n) {
|
|
4162
|
+
return L.parseExpressionAt(e, t, n);
|
|
4163
|
+
}
|
|
4164
|
+
//#endregion
|
|
4165
|
+
//#region src/transformer.ts
|
|
4166
|
+
function Gt(e) {
|
|
4167
|
+
if (typeof e != "object" || !e) return e;
|
|
4168
|
+
if (Array.isArray(e)) return e.map(Gt);
|
|
4169
|
+
let t = {};
|
|
4170
|
+
for (let n of Object.keys(e)) t[n] = Gt(e[n]);
|
|
4171
|
+
return t;
|
|
4172
|
+
}
|
|
4173
|
+
var Kt = class {
|
|
4174
|
+
rawAst;
|
|
4175
|
+
constructor(e) {
|
|
4176
|
+
this.rawAst = e;
|
|
4177
|
+
}
|
|
4178
|
+
transform() {
|
|
4179
|
+
return {
|
|
4180
|
+
...this.rawAst,
|
|
4181
|
+
body: this.transformChildren(this.rawAst.body)
|
|
4182
|
+
};
|
|
4183
|
+
}
|
|
4184
|
+
transformChildren(e) {
|
|
4185
|
+
let t = [];
|
|
4186
|
+
for (let r of e) r.type === n.Text && typeof r.content == "string" && this.isWhitespaceOnly(r.content) || t.push(this.transformNode(r));
|
|
4187
|
+
return t;
|
|
4188
|
+
}
|
|
4189
|
+
transformNode(e) {
|
|
4190
|
+
if (e.type === n.Element) return e.tagName === "script" ? this.transformScriptElement(e) : {
|
|
4191
|
+
...e,
|
|
4192
|
+
attributes: e.attributes.map((e) => e.type === n.Attribute && e.value !== null && typeof e.value != "string" && e.value.type === n.Interpolation ? {
|
|
4193
|
+
...e,
|
|
4194
|
+
value: this.transformInterpolation(e.value)
|
|
4195
|
+
} : e),
|
|
4196
|
+
children: this.transformChildren(e.children)
|
|
4197
|
+
};
|
|
4198
|
+
if (e.type === n.Interpolation) return this.transformInterpolation(e);
|
|
4199
|
+
if (e.type === n.If) {
|
|
4200
|
+
let t = typeof e.test == "string" && e.test.trim().length > 0 ? Q(e.test, 0, { ecmaVersion: "latest" }) : e.test, n = null;
|
|
4201
|
+
return Array.isArray(e.alternate) ? n = this.transformChildren(e.alternate) : e.alternate !== null && (n = this.transformNode(e.alternate)), {
|
|
4202
|
+
...e,
|
|
4203
|
+
test: t,
|
|
4204
|
+
consequent: this.transformChildren(e.consequent),
|
|
4205
|
+
alternate: n
|
|
4206
|
+
};
|
|
4207
|
+
}
|
|
4208
|
+
return e.type === n.For ? {
|
|
4209
|
+
...e,
|
|
4210
|
+
iterable: typeof e.iterable == "string" ? Q(e.iterable, 0, { ecmaVersion: "latest" }) : e.iterable,
|
|
4211
|
+
key: typeof e.key == "string" && e.key.trim().length > 0 ? Q(e.key, 0, { ecmaVersion: "latest" }) : e.key ?? null,
|
|
4212
|
+
body: this.transformChildren(e.body)
|
|
4213
|
+
} : e.type === n.Switch ? this.transformSwitchToIfChain(e) : e;
|
|
4214
|
+
}
|
|
4215
|
+
transformSwitchToIfChain(e) {
|
|
4216
|
+
let t = typeof e.discriminant == "string" ? Q(e.discriminant, 0, { ecmaVersion: "latest" }) : e.discriminant, r = (i) => {
|
|
4217
|
+
let a = e.cases[i];
|
|
4218
|
+
if (!a) return null;
|
|
4219
|
+
if (a.expression === null) return this.transformChildren(a.body);
|
|
4220
|
+
let o = typeof a.expression == "string" && a.expression.trim().length > 0 ? Q(a.expression, 0, { ecmaVersion: "latest" }) : a.expression, s = {
|
|
4221
|
+
type: "BinaryExpression",
|
|
4222
|
+
operator: "===",
|
|
4223
|
+
left: Gt(t),
|
|
4224
|
+
right: o,
|
|
4225
|
+
start: 0,
|
|
4226
|
+
end: 0
|
|
4227
|
+
}, c = this.transformChildren(a.body), l = r(i + 1), u = null;
|
|
4228
|
+
return (Array.isArray(l) || l !== null && l.type === n.If) && (u = l), {
|
|
4229
|
+
type: n.If,
|
|
4230
|
+
test: s,
|
|
4231
|
+
consequent: c,
|
|
4232
|
+
alternate: u,
|
|
4233
|
+
loc: a.loc
|
|
4234
|
+
};
|
|
4235
|
+
}, i = r(0);
|
|
4236
|
+
return i ? Array.isArray(i) ? i[0] || {
|
|
4237
|
+
type: n.Comment,
|
|
4238
|
+
content: "empty switch",
|
|
4239
|
+
loc: e.loc
|
|
4240
|
+
} : i : {
|
|
4241
|
+
type: n.Comment,
|
|
4242
|
+
content: "empty switch",
|
|
4243
|
+
loc: e.loc
|
|
4244
|
+
};
|
|
4245
|
+
}
|
|
4246
|
+
transformInterpolation(e) {
|
|
4247
|
+
if (typeof e.expression != "string") return e;
|
|
4248
|
+
let t;
|
|
4249
|
+
try {
|
|
4250
|
+
t = Q(e.expression, 0, {
|
|
4251
|
+
ecmaVersion: "latest",
|
|
4252
|
+
allowAwaitOutsideFunction: !0
|
|
4253
|
+
});
|
|
4254
|
+
} catch (t) {
|
|
4255
|
+
throw new i(`Failed to parse JS expression in interpolation: ${t instanceof Error ? t.message : String(t)}`, e.loc.start.line, e.loc.start.column, e.loc.start.offset);
|
|
4256
|
+
}
|
|
4257
|
+
return {
|
|
4258
|
+
...e,
|
|
4259
|
+
expression: t
|
|
4260
|
+
};
|
|
4261
|
+
}
|
|
4262
|
+
transformScriptElement(e) {
|
|
4263
|
+
let t = e.children.map((e) => {
|
|
4264
|
+
if (e.type === n.Text && typeof e.content == "string") {
|
|
4265
|
+
let t;
|
|
4266
|
+
try {
|
|
4267
|
+
let n = Wt(e.content, {
|
|
4268
|
+
ecmaVersion: "latest",
|
|
4269
|
+
sourceType: "module",
|
|
4270
|
+
allowAwaitOutsideFunction: !0,
|
|
4271
|
+
allowReturnOutsideFunction: !0
|
|
4272
|
+
});
|
|
4273
|
+
t = n.body.length === 1 && n.body[0] !== void 0 ? n.body[0] : n.body;
|
|
4274
|
+
} catch (t) {
|
|
4275
|
+
throw new i(`Failed to parse script tag JS content: ${t instanceof Error ? t.message : String(t)}`, e.loc.start.line, e.loc.start.column, e.loc.start.offset);
|
|
4276
|
+
}
|
|
4277
|
+
return {
|
|
4278
|
+
...e,
|
|
4279
|
+
content: t
|
|
4280
|
+
};
|
|
4281
|
+
}
|
|
4282
|
+
return e;
|
|
4283
|
+
});
|
|
4284
|
+
return {
|
|
4285
|
+
...e,
|
|
4286
|
+
children: t
|
|
4287
|
+
};
|
|
4288
|
+
}
|
|
4289
|
+
isWhitespaceOnly(e) {
|
|
4290
|
+
if (e.length === 0) return !1;
|
|
4291
|
+
for (let t = 0; t < e.length; t++) {
|
|
4292
|
+
let n = e.charCodeAt(t);
|
|
4293
|
+
if (n !== 32 && n !== 9 && n !== 10 && n !== 13) return !1;
|
|
4294
|
+
}
|
|
4295
|
+
return !0;
|
|
4296
|
+
}
|
|
4297
|
+
}, qt = class {
|
|
4298
|
+
ast;
|
|
4299
|
+
bytecode = [];
|
|
4300
|
+
constants = [];
|
|
4301
|
+
nextRegisterId = 0;
|
|
4302
|
+
declaredVars = /* @__PURE__ */ new Set();
|
|
4303
|
+
imports = [];
|
|
4304
|
+
bindingPositions = /* @__PURE__ */ new Map();
|
|
4305
|
+
constructor(e) {
|
|
4306
|
+
this.ast = e;
|
|
4307
|
+
}
|
|
4308
|
+
generate() {
|
|
4309
|
+
if (this.bytecode = [], this.constants = [], this.nextRegisterId = 0, this.declaredVars = /* @__PURE__ */ new Set(), this.imports = [], this.bindingPositions = /* @__PURE__ */ new Map(), this.collectDeclaredVars(this.ast.body), this.ast.body.length === 0) {
|
|
4310
|
+
let e = this.allocRegister();
|
|
4311
|
+
return this.emit(a.CREATE_FRAGMENT, e), this.emit(a.RETURN, e), {
|
|
4312
|
+
bytecode: this.bytecode,
|
|
4313
|
+
constants: this.constants,
|
|
4314
|
+
reactiveBindings: this.buildReactiveBindings(),
|
|
4315
|
+
declaredVars: [...this.declaredVars],
|
|
4316
|
+
imports: this.imports
|
|
4317
|
+
};
|
|
4318
|
+
}
|
|
4319
|
+
if (this.ast.body.length === 1 && this.ast.body[0]?.type === n.Element) {
|
|
4320
|
+
let e = this.allocRegister();
|
|
4321
|
+
this.compileElement(this.ast.body[0], e), this.emit(a.RETURN, e);
|
|
4322
|
+
} else {
|
|
4323
|
+
let e = this.allocRegister();
|
|
4324
|
+
this.emit(a.CREATE_FRAGMENT, e);
|
|
4325
|
+
for (let t of this.ast.body) this.compileNode(t, e);
|
|
4326
|
+
this.emit(a.RETURN, e);
|
|
4327
|
+
}
|
|
4328
|
+
return {
|
|
4329
|
+
bytecode: this.bytecode,
|
|
4330
|
+
constants: this.constants,
|
|
4331
|
+
reactiveBindings: this.buildReactiveBindings(),
|
|
4332
|
+
declaredVars: [...this.declaredVars],
|
|
4333
|
+
imports: this.imports
|
|
4334
|
+
};
|
|
4335
|
+
}
|
|
4336
|
+
compileNode(e, t) {
|
|
4337
|
+
switch (e.type) {
|
|
4338
|
+
case n.Element:
|
|
4339
|
+
e.tagName === "script" ? this.compileScriptElement(e) : this.compileElementNode(e, t);
|
|
4340
|
+
break;
|
|
4341
|
+
case n.Text:
|
|
4342
|
+
this.compileTextNode(e, t);
|
|
4343
|
+
break;
|
|
4344
|
+
case n.Interpolation:
|
|
4345
|
+
this.compileInterpolationNode(e, t);
|
|
4346
|
+
break;
|
|
4347
|
+
case n.Comment:
|
|
4348
|
+
this.compileCommentNode(e, t);
|
|
4349
|
+
break;
|
|
4350
|
+
case n.If:
|
|
4351
|
+
this.compileIfNode(e, t);
|
|
4352
|
+
break;
|
|
4353
|
+
case n.For:
|
|
4354
|
+
this.compileForNode(e, t);
|
|
4355
|
+
break;
|
|
4356
|
+
}
|
|
4357
|
+
}
|
|
4358
|
+
filterRuntimeScriptAst(e) {
|
|
4359
|
+
if (Array.isArray(e)) {
|
|
4360
|
+
let t = e.filter((e) => e && e.type !== "ImportDeclaration");
|
|
4361
|
+
return t.length === 1 ? t[0] : t;
|
|
4362
|
+
}
|
|
4363
|
+
return e && typeof e == "object" && e.type === "ImportDeclaration" ? null : e;
|
|
4364
|
+
}
|
|
4365
|
+
compileScriptElement(e) {
|
|
4366
|
+
for (let t of e.children) if (t.type === n.Text && typeof t.content == "object" && t.content !== null) {
|
|
4367
|
+
let e = this.filterRuntimeScriptAst(t.content);
|
|
4368
|
+
if (e !== null && (!Array.isArray(e) || e.length > 0)) {
|
|
4369
|
+
let t = this.addConstant(e);
|
|
4370
|
+
this.emit(a.EXEC_SCRIPT, t);
|
|
4371
|
+
}
|
|
4372
|
+
}
|
|
4373
|
+
}
|
|
4374
|
+
isComponentTag(e) {
|
|
4375
|
+
if (this.imports.some((t) => t.localName === e)) return !0;
|
|
4376
|
+
let t = e.charAt(0);
|
|
4377
|
+
return t !== "" && t === t.toUpperCase() && t !== t.toLowerCase();
|
|
4378
|
+
}
|
|
4379
|
+
compileElement(e, t) {
|
|
4380
|
+
let r = this.isComponentTag(e.tagName), i = this.addConstant(e.tagName);
|
|
4381
|
+
if (r) {
|
|
4382
|
+
let r = { __drift_props__: !0 };
|
|
4383
|
+
for (let t of e.attributes) t.type === n.Attribute && (t.value === null ? r[t.name] = !0 : typeof t.value == "string" ? r[t.name] = t.value : t.value.type === n.Interpolation && (r[t.name] = t.value.expression));
|
|
4384
|
+
let o = this.addConstant(r), s = this.bytecode.length;
|
|
4385
|
+
this.emit(a.CREATE_ELEMENT, t, i, o);
|
|
4386
|
+
for (let t of e.attributes) t.type === n.Attribute && t.value !== null && typeof t.value != "string" && t.value.type === n.Interpolation && this.recordBindingPositions(t.value.expression, s, a.CREATE_ELEMENT);
|
|
4387
|
+
} else {
|
|
4388
|
+
this.emit(a.CREATE_ELEMENT, t, i);
|
|
4389
|
+
for (let n of e.attributes) this.compileAttributeNode(n, t);
|
|
4390
|
+
for (let n of e.children) this.compileNode(n, t);
|
|
4391
|
+
}
|
|
4392
|
+
}
|
|
4393
|
+
compileElementNode(e, t) {
|
|
4394
|
+
let n = this.allocRegister();
|
|
4395
|
+
this.compileElement(e, n), this.emit(a.APPEND_CHILD, t, n);
|
|
4396
|
+
}
|
|
4397
|
+
compileAttributeNode(e, t) {
|
|
4398
|
+
let r = this.addConstant(e.name);
|
|
4399
|
+
if (e.value === null) {
|
|
4400
|
+
let e = this.addConstant(!0);
|
|
4401
|
+
this.emit(a.SET_ATTR, t, r, e, 0);
|
|
4402
|
+
} else if (typeof e.value == "string") {
|
|
4403
|
+
let n = this.addConstant(e.value);
|
|
4404
|
+
this.emit(a.SET_ATTR, t, r, n, 0);
|
|
4405
|
+
} else if (e.value.type === n.Interpolation) {
|
|
4406
|
+
let n = this.addConstant(e.value.expression), i = this.bytecode.length;
|
|
4407
|
+
this.emit(a.SET_ATTR, t, r, n, 1), this.recordBindingPositions(e.value.expression, i, a.SET_ATTR);
|
|
4408
|
+
}
|
|
4409
|
+
}
|
|
4410
|
+
compileTextNode(e, t) {
|
|
4411
|
+
let n = this.allocRegister(), r = this.addConstant(e.content);
|
|
4412
|
+
this.emit(a.CREATE_TEXT, n, r), this.emit(a.APPEND_CHILD, t, n);
|
|
4413
|
+
}
|
|
4414
|
+
compileInterpolationNode(e, t) {
|
|
4415
|
+
let n = this.allocRegister(), r = this.addConstant(e.expression), i = this.bytecode.length;
|
|
4416
|
+
this.emit(a.INTERPOLATE_TEXT, n, r), this.emit(a.APPEND_CHILD, t, n), this.recordBindingPositions(e.expression, i, a.INTERPOLATE_TEXT);
|
|
4417
|
+
}
|
|
4418
|
+
compileCommentNode(e, t) {
|
|
4419
|
+
let n = this.allocRegister(), r = this.addConstant(e.content);
|
|
4420
|
+
this.emit(a.CREATE_COMMENT, n, r), this.emit(a.APPEND_CHILD, t, n);
|
|
4421
|
+
}
|
|
4422
|
+
compileNodesToSubModule(e) {
|
|
4423
|
+
let t = this.bytecode, n = this.constants, r = this.nextRegisterId, i = this.bindingPositions;
|
|
4424
|
+
this.bytecode = [], this.constants = [], this.nextRegisterId = 0, this.bindingPositions = /* @__PURE__ */ new Map();
|
|
4425
|
+
let o = this.allocRegister();
|
|
4426
|
+
this.emit(a.CREATE_FRAGMENT, o);
|
|
4427
|
+
for (let t of e) this.compileNode(t, o);
|
|
4428
|
+
this.emit(a.RETURN, o);
|
|
4429
|
+
let s = {
|
|
4430
|
+
bytecode: this.bytecode,
|
|
4431
|
+
constants: this.constants,
|
|
4432
|
+
reactiveBindings: this.buildReactiveBindings()
|
|
4433
|
+
};
|
|
4434
|
+
return this.bytecode = t, this.constants = n, this.nextRegisterId = r, this.bindingPositions = i, s;
|
|
4435
|
+
}
|
|
4436
|
+
collectDepsFromSubModule(e, t) {
|
|
4437
|
+
let n = new Set(e.reactiveBindings.map((e) => e.variable));
|
|
4438
|
+
if (t) for (let e of this.extractIdentifiers(t)) this.declaredVars.has(e) && n.add(e);
|
|
4439
|
+
return [...n];
|
|
4440
|
+
}
|
|
4441
|
+
compileIfNode(e, t) {
|
|
4442
|
+
let n = this.compileNodesToSubModule(e.consequent), r = this.addConstant(n), i = 255, o = null;
|
|
4443
|
+
if (e.alternate !== null) {
|
|
4444
|
+
let t;
|
|
4445
|
+
t = Array.isArray(e.alternate) ? e.alternate : [e.alternate], o = this.compileNodesToSubModule(t), i = this.addConstant(o);
|
|
4446
|
+
}
|
|
4447
|
+
let s = new Set(this.collectDepsFromSubModule(n, e.test));
|
|
4448
|
+
if (o) for (let e of this.collectDepsFromSubModule(o)) s.add(e);
|
|
4449
|
+
let c = this.addConstant(Array.from(s)), l = this.addConstant(e.test);
|
|
4450
|
+
this.emit(a.REACTIVE_IF, t, l, r, i, c);
|
|
4451
|
+
}
|
|
4452
|
+
compileForNode(e, t) {
|
|
4453
|
+
let n = this.compileNodesToSubModule(e.body), r = this.addConstant(n), i = this.addConstant(e.iterable), o = this.addConstant(e.item), s = e.index === null ? 255 : this.addConstant(e.index), c = e.key ? this.addConstant(e.key) : 255, l = this.collectDepsFromSubModule(n, e.iterable), u = this.addConstant(l);
|
|
4454
|
+
this.emit(a.REACTIVE_FOR, t, i, o, s, c, r, u);
|
|
4455
|
+
}
|
|
4456
|
+
collectDeclaredVars(e) {
|
|
4457
|
+
for (let t of e) if (t.type === n.Element && t.tagName === "script") {
|
|
4458
|
+
for (let e of t.children) if (e.type === n.Text && typeof e.content == "object" && e.content !== null) {
|
|
4459
|
+
let t = e.content;
|
|
4460
|
+
if (Array.isArray(t)) for (let e of t) this.extractVarNames(e);
|
|
4461
|
+
else this.extractVarNames(t);
|
|
4462
|
+
}
|
|
4463
|
+
}
|
|
4464
|
+
}
|
|
4465
|
+
extractVarNames(e) {
|
|
4466
|
+
if (!(!e || typeof e != "object")) {
|
|
4467
|
+
if (e.type === "VariableDeclaration") for (let t of e.declarations) this.extractBindingIdentifiers(t.id);
|
|
4468
|
+
else if (e.type === "FunctionDeclaration" && e.id?.type === "Identifier") this.declaredVars.add(e.id.name);
|
|
4469
|
+
else if (e.type === "ImportDeclaration" && Array.isArray(e.specifiers)) {
|
|
4470
|
+
let t = typeof e.source?.value == "string" ? e.source.value : "";
|
|
4471
|
+
for (let n of e.specifiers) if (n.local?.type === "Identifier") {
|
|
4472
|
+
let e = n.local.name;
|
|
4473
|
+
this.declaredVars.add(e);
|
|
4474
|
+
let r = n.type === "ImportDefaultSpecifier", i = n.type === "ImportSpecifier" && n.imported?.type === "Identifier" ? n.imported.name : void 0;
|
|
4475
|
+
this.imports.push({
|
|
4476
|
+
localName: e,
|
|
4477
|
+
source: t,
|
|
4478
|
+
isDefault: r,
|
|
4479
|
+
importedName: i
|
|
4480
|
+
});
|
|
4481
|
+
}
|
|
4482
|
+
}
|
|
4483
|
+
}
|
|
4484
|
+
}
|
|
4485
|
+
extractBindingIdentifiers(e) {
|
|
4486
|
+
if (!(!e || typeof e != "object")) if (e.type === "Identifier") this.declaredVars.add(e.name);
|
|
4487
|
+
else if (e.type === "ObjectPattern" && Array.isArray(e.properties)) for (let t of e.properties) t.type === "Property" ? this.extractBindingIdentifiers(t.value) : t.type === "RestElement" && this.extractBindingIdentifiers(t.argument);
|
|
4488
|
+
else if (e.type === "ArrayPattern" && Array.isArray(e.elements)) for (let t of e.elements) t && this.extractBindingIdentifiers(t);
|
|
4489
|
+
else e.type === "AssignmentPattern" && this.extractBindingIdentifiers(e.left);
|
|
4490
|
+
}
|
|
4491
|
+
extractIdentifiers(e) {
|
|
4492
|
+
let t = /* @__PURE__ */ new Set();
|
|
4493
|
+
if (!e || typeof e != "object" || !e.type) return t;
|
|
4494
|
+
switch (e.type) {
|
|
4495
|
+
case "Identifier":
|
|
4496
|
+
t.add(e.name);
|
|
4497
|
+
break;
|
|
4498
|
+
case "BinaryExpression":
|
|
4499
|
+
case "LogicalExpression":
|
|
4500
|
+
for (let n of this.extractIdentifiers(e.left)) t.add(n);
|
|
4501
|
+
for (let n of this.extractIdentifiers(e.right)) t.add(n);
|
|
4502
|
+
break;
|
|
4503
|
+
case "UnaryExpression":
|
|
4504
|
+
case "UpdateExpression":
|
|
4505
|
+
for (let n of this.extractIdentifiers(e.argument)) t.add(n);
|
|
4506
|
+
break;
|
|
4507
|
+
case "MemberExpression":
|
|
4508
|
+
for (let n of this.extractIdentifiers(e.object)) t.add(n);
|
|
4509
|
+
break;
|
|
4510
|
+
case "CallExpression":
|
|
4511
|
+
for (let n of this.extractIdentifiers(e.callee)) t.add(n);
|
|
4512
|
+
for (let n of e.arguments) for (let e of this.extractIdentifiers(n)) t.add(e);
|
|
4513
|
+
break;
|
|
4514
|
+
case "ConditionalExpression":
|
|
4515
|
+
for (let n of this.extractIdentifiers(e.test)) t.add(n);
|
|
4516
|
+
for (let n of this.extractIdentifiers(e.consequent)) t.add(n);
|
|
4517
|
+
for (let n of this.extractIdentifiers(e.alternate)) t.add(n);
|
|
4518
|
+
break;
|
|
4519
|
+
case "AssignmentExpression":
|
|
4520
|
+
for (let n of this.extractIdentifiers(e.left)) t.add(n);
|
|
4521
|
+
for (let n of this.extractIdentifiers(e.right)) t.add(n);
|
|
4522
|
+
break;
|
|
4523
|
+
case "ArrowFunctionExpression":
|
|
4524
|
+
case "FunctionExpression":
|
|
4525
|
+
for (let n of this.extractIdentifiers(e.body)) t.add(n);
|
|
4526
|
+
break;
|
|
4527
|
+
case "BlockStatement":
|
|
4528
|
+
for (let n of e.body) for (let e of this.extractIdentifiers(n)) t.add(e);
|
|
4529
|
+
break;
|
|
4530
|
+
case "ExpressionStatement":
|
|
4531
|
+
for (let n of this.extractIdentifiers(e.expression)) t.add(n);
|
|
4532
|
+
break;
|
|
4533
|
+
case "ReturnStatement":
|
|
4534
|
+
if (e.argument) for (let n of this.extractIdentifiers(e.argument)) t.add(n);
|
|
4535
|
+
break;
|
|
4536
|
+
case "NewExpression":
|
|
4537
|
+
for (let n of this.extractIdentifiers(e.callee)) t.add(n);
|
|
4538
|
+
if (e.arguments) for (let n of e.arguments) for (let e of this.extractIdentifiers(n)) t.add(e);
|
|
4539
|
+
break;
|
|
4540
|
+
case "ForStatement":
|
|
4541
|
+
if (e.init) for (let n of this.extractIdentifiers(e.init)) t.add(n);
|
|
4542
|
+
if (e.test) for (let n of this.extractIdentifiers(e.test)) t.add(n);
|
|
4543
|
+
if (e.update) for (let n of this.extractIdentifiers(e.update)) t.add(n);
|
|
4544
|
+
if (e.body) for (let n of this.extractIdentifiers(e.body)) t.add(n);
|
|
4545
|
+
break;
|
|
4546
|
+
case "ForOfStatement":
|
|
4547
|
+
case "ForInStatement":
|
|
4548
|
+
if (e.left) for (let n of this.extractIdentifiers(e.left)) t.add(n);
|
|
4549
|
+
if (e.right) for (let n of this.extractIdentifiers(e.right)) t.add(n);
|
|
4550
|
+
if (e.body) for (let n of this.extractIdentifiers(e.body)) t.add(n);
|
|
4551
|
+
break;
|
|
4552
|
+
case "WhileStatement":
|
|
4553
|
+
case "DoWhileStatement":
|
|
4554
|
+
if (e.test) for (let n of this.extractIdentifiers(e.test)) t.add(n);
|
|
4555
|
+
if (e.body) for (let n of this.extractIdentifiers(e.body)) t.add(n);
|
|
4556
|
+
break;
|
|
4557
|
+
}
|
|
4558
|
+
return t;
|
|
4559
|
+
}
|
|
4560
|
+
recordBindingPositions(e, t, n) {
|
|
4561
|
+
if (this.declaredVars.size === 0) return;
|
|
4562
|
+
let r = this.extractIdentifiers(e);
|
|
4563
|
+
for (let e of r) this.declaredVars.has(e) && (this.bindingPositions.has(e) || this.bindingPositions.set(e, []), this.bindingPositions.get(e).push({
|
|
4564
|
+
pc: t,
|
|
4565
|
+
opcode: n
|
|
4566
|
+
}));
|
|
4567
|
+
}
|
|
4568
|
+
buildReactiveBindings() {
|
|
4569
|
+
let e = [];
|
|
4570
|
+
for (let [t, n] of this.bindingPositions) e.push({
|
|
4571
|
+
variable: t,
|
|
4572
|
+
positions: n
|
|
4573
|
+
});
|
|
4574
|
+
return e;
|
|
4575
|
+
}
|
|
4576
|
+
allocRegister() {
|
|
4577
|
+
return this.nextRegisterId++;
|
|
4578
|
+
}
|
|
4579
|
+
addConstant(e) {
|
|
4580
|
+
e && typeof e == "object" && e.type && typeof e.type == "string" && (e = { __drift_fn__: `(scope, declaredVars, setScopeValue, inScopeChain, resolveIterable) => (${$(e)})` });
|
|
4581
|
+
let t = this.constants.findIndex((t) => this.isConstantEqual(t, e));
|
|
4582
|
+
return t === -1 ? (this.constants.push(e), this.constants.length - 1) : t;
|
|
4583
|
+
}
|
|
4584
|
+
isConstantEqual(e, t) {
|
|
4585
|
+
return e === t || typeof e == "object" && typeof t == "object" && e !== null && t !== null && JSON.stringify(e) === JSON.stringify(t);
|
|
4586
|
+
}
|
|
4587
|
+
emit(e, ...t) {
|
|
4588
|
+
this.bytecode.push(e, ...t);
|
|
4589
|
+
}
|
|
4590
|
+
emitJumpIfFalsePlaceholder(e) {
|
|
4591
|
+
let t = this.bytecode.length;
|
|
4592
|
+
return this.bytecode.push(a.JUMP_IF_FALSE, e, 0, 0), t;
|
|
4593
|
+
}
|
|
4594
|
+
emitJumpPlaceholder() {
|
|
4595
|
+
let e = this.bytecode.length;
|
|
4596
|
+
return this.bytecode.push(a.JUMP, 0, 0), e;
|
|
4597
|
+
}
|
|
4598
|
+
emitJump(e) {
|
|
4599
|
+
let t = e >> 8 & 255, n = e & 255;
|
|
4600
|
+
this.bytecode.push(a.JUMP, t, n);
|
|
4601
|
+
}
|
|
4602
|
+
emitLoopIterPlaceholder(e, t, n, r, i) {
|
|
4603
|
+
let o = this.bytecode.length, s = r >> 8 & 255, c = r & 255, l = i >> 8 & 255, u = i & 255;
|
|
4604
|
+
return this.bytecode.push(a.LOOP_ITER, e, t, n, s, c, l, u, 0, 0), o;
|
|
4605
|
+
}
|
|
4606
|
+
patchJump(e, t) {
|
|
4607
|
+
let n = t >> 8 & 255, r = t & 255, i = this.bytecode[e];
|
|
4608
|
+
i === a.JUMP_IF_FALSE ? (this.bytecode[e + 2] = n, this.bytecode[e + 3] = r) : i === a.JUMP ? (this.bytecode[e + 1] = n, this.bytecode[e + 2] = r) : i === a.LOOP_ITER && (this.bytecode[e + 8] = n, this.bytecode[e + 9] = r);
|
|
4609
|
+
}
|
|
4610
|
+
};
|
|
4611
|
+
function Jt(e) {
|
|
4612
|
+
return !e || typeof e != "object" ? null : e.type === "Identifier" ? e.name : e.type === "MemberExpression" ? Jt(e.object) : null;
|
|
4613
|
+
}
|
|
4614
|
+
function $(e, t) {
|
|
4615
|
+
if (e == null) return "undefined";
|
|
4616
|
+
if (typeof e != "object") return typeof e == "string" ? JSON.stringify(e) : String(e);
|
|
4617
|
+
if (Array.isArray(e)) return e.map((e) => $(e, t)).join("; ");
|
|
4618
|
+
switch (e.type) {
|
|
4619
|
+
case "Identifier": return t && t.has(e.name) ? e.name : `((typeof inScopeChain === 'function' ? inScopeChain(scope, ${JSON.stringify(e.name)}) : Object.prototype.hasOwnProperty.call(scope || {}, ${JSON.stringify(e.name)})) ? scope[${JSON.stringify(e.name)}] : (typeof globalThis !== 'undefined' && Object.prototype.hasOwnProperty.call(globalThis, ${JSON.stringify(e.name)}) ? globalThis[${JSON.stringify(e.name)}] : undefined))`;
|
|
4620
|
+
case "Literal": return typeof e.raw == "string" ? e.raw : typeof e.value == "string" ? JSON.stringify(e.value) : String(e.value);
|
|
4621
|
+
case "BinaryExpression":
|
|
4622
|
+
case "LogicalExpression": return `(${$(e.left, t)} ${e.operator} ${$(e.right, t)})`;
|
|
4623
|
+
case "UnaryExpression": return `(${e.operator} ${$(e.argument, t)})`;
|
|
4624
|
+
case "ConditionalExpression": return `(${$(e.test, t)} ? ${$(e.consequent, t)} : ${$(e.alternate, t)})`;
|
|
4625
|
+
case "MemberExpression": return e.computed ? `(${$(e.object, t)}[${$(e.property, t)}])` : `(${$(e.object, t)}.${e.property.name})`;
|
|
4626
|
+
case "CallExpression": {
|
|
4627
|
+
let n = `(${$(e.callee, t)}(${e.arguments ? e.arguments.map((e) => $(e, t)).join(", ") : ""}))`;
|
|
4628
|
+
if (e.callee?.type === "MemberExpression" && e.callee.property?.type === "Identifier") {
|
|
4629
|
+
let r = Jt(e.callee.object), i = e.callee.property.name;
|
|
4630
|
+
if (r && [
|
|
4631
|
+
"push",
|
|
4632
|
+
"pop",
|
|
4633
|
+
"shift",
|
|
4634
|
+
"unshift",
|
|
4635
|
+
"splice",
|
|
4636
|
+
"sort",
|
|
4637
|
+
"reverse"
|
|
4638
|
+
].includes(i) && (!t || !t.has(r))) return `(() => { const _res = ${n}; if (typeof setScopeValue === 'function' && scope) setScopeValue(scope, ${JSON.stringify(r)}, scope[${JSON.stringify(r)}]); return _res; })()`;
|
|
4639
|
+
}
|
|
4640
|
+
return n;
|
|
4641
|
+
}
|
|
4642
|
+
case "AssignmentExpression": {
|
|
4643
|
+
let n = $(e.right, t);
|
|
4644
|
+
if (e.left?.type === "Identifier") {
|
|
4645
|
+
let r = e.left.name;
|
|
4646
|
+
if (t && t.has(r)) return `(${r} ${e.operator} ${n})`;
|
|
4647
|
+
if (e.operator === "=") return `(typeof setScopeValue === 'function' ? setScopeValue(scope, ${JSON.stringify(r)}, ${n}) : ((scope || {})[${JSON.stringify(r)}] = ${n}))`;
|
|
4648
|
+
{
|
|
4649
|
+
let t = e.operator.slice(0, -1);
|
|
4650
|
+
return `(typeof setScopeValue === 'function' ? setScopeValue(scope, ${JSON.stringify(r)}, (scope[${JSON.stringify(r)}] ${t} ${n})) : ((scope || {})[${JSON.stringify(r)}] ${e.operator} ${n}))`;
|
|
4651
|
+
}
|
|
4652
|
+
}
|
|
4653
|
+
if (e.left?.type === "MemberExpression") {
|
|
4654
|
+
let r = Jt(e.left), i = `(${$(e.left, t)} ${e.operator} ${n})`;
|
|
4655
|
+
if (r && (!t || !t.has(r))) return `(() => { const _res = ${i}; if (typeof setScopeValue === 'function' && scope) setScopeValue(scope, ${JSON.stringify(r)}, scope[${JSON.stringify(r)}]); return _res; })()`;
|
|
4656
|
+
}
|
|
4657
|
+
if (e.left?.type === "ArrayPattern") {
|
|
4658
|
+
let r = [], i = e.left.elements || [];
|
|
4659
|
+
for (let e = 0; e < i.length; e++) {
|
|
4660
|
+
let n = i[e];
|
|
4661
|
+
if (n?.type === "Identifier") {
|
|
4662
|
+
let i = n.name;
|
|
4663
|
+
(!t || !t.has(i)) && r.push(`if (typeof setScopeValue === 'function' && scope) setScopeValue(scope, ${JSON.stringify(i)}, _val[${e}]);`);
|
|
4664
|
+
}
|
|
4665
|
+
}
|
|
4666
|
+
return `(() => { const _val = ${n} || []; ${r.join(" ")} return _val; })()`;
|
|
4667
|
+
}
|
|
4668
|
+
if (e.left?.type === "ObjectPattern") {
|
|
4669
|
+
let r = [], i = e.left.properties || [];
|
|
4670
|
+
for (let e of i) if (e.type === "Property" && e.value?.type === "Identifier") {
|
|
4671
|
+
let n = e.key?.name || (typeof e.key?.value == "string" ? e.key.value : String(e.key?.value)), i = e.value.name;
|
|
4672
|
+
(!t || !t.has(i)) && r.push(`if (typeof setScopeValue === 'function' && scope) setScopeValue(scope, ${JSON.stringify(i)}, _val[${JSON.stringify(n)}]);`);
|
|
4673
|
+
}
|
|
4674
|
+
return `(() => { const _val = ${n} || {}; ${r.join(" ")} return _val; })()`;
|
|
4675
|
+
}
|
|
4676
|
+
return `(${$(e.left, t)} ${e.operator} ${n})`;
|
|
4677
|
+
}
|
|
4678
|
+
case "UpdateExpression":
|
|
4679
|
+
if (e.argument?.type === "Identifier") {
|
|
4680
|
+
let n = e.argument.name;
|
|
4681
|
+
if (t && t.has(n)) return e.prefix ? `(${e.operator}${n})` : `(${n}${e.operator})`;
|
|
4682
|
+
let r = e.operator === "++" ? "+" : "-";
|
|
4683
|
+
return e.prefix ? `(typeof setScopeValue === 'function' ? (setScopeValue(scope, ${JSON.stringify(n)}, (Number(scope[${JSON.stringify(n)}]) || 0) ${r} 1), scope[${JSON.stringify(n)}]) : ((scope || {})[${JSON.stringify(n)}] = (Number((scope || {})[${JSON.stringify(n)}]) || 0) ${r} 1))` : `(() => { const _v = Number(scope[${JSON.stringify(n)}]) || 0; if (typeof setScopeValue === 'function') setScopeValue(scope, ${JSON.stringify(n)}, _v ${r} 1); else (scope || {})[${JSON.stringify(n)}] = _v ${r} 1; return _v; })()`;
|
|
4684
|
+
}
|
|
4685
|
+
if (e.argument?.type === "MemberExpression") {
|
|
4686
|
+
let n = Jt(e.argument), r = e.prefix ? `(${e.operator}${$(e.argument, t)})` : `(${$(e.argument, t)}${e.operator})`;
|
|
4687
|
+
if (n && (!t || !t.has(n))) return `(() => { const _res = ${r}; if (typeof setScopeValue === 'function' && scope) setScopeValue(scope, ${JSON.stringify(n)}, scope[${JSON.stringify(n)}]); return _res; })()`;
|
|
4688
|
+
}
|
|
4689
|
+
return e.prefix ? `(${e.operator}${$(e.argument, t)})` : `(${$(e.argument, t)}${e.operator})`;
|
|
4690
|
+
case "SequenceExpression": return `(${e.expressions ? e.expressions.map((e) => $(e, t)).join(", ") : ""})`;
|
|
4691
|
+
case "ArrayExpression": return `[${e.elements ? e.elements.map((e) => e?.type === "SpreadElement" ? "..." + $(e.argument, t) : $(e, t)).join(", ") : ""}]`;
|
|
4692
|
+
case "ObjectExpression": return `{${e.properties ? e.properties.map((e) => e.type === "SpreadElement" ? "..." + $(e.argument, t) : `${e.computed ? "[" + $(e.key, t) + "]" : e.key.name}: ${$(e.value, t)}`).join(", ") : ""}}`;
|
|
4693
|
+
case "SpreadElement": return `...${$(e.argument, t)}`;
|
|
4694
|
+
case "TemplateLiteral": return `\`${e.quasis ? e.quasis.map((n, r) => (n.value?.raw ?? "") + (e.expressions && e.expressions[r] ? "${" + $(e.expressions[r], t) + "}" : "")).join("") : ""}\``;
|
|
4695
|
+
case "TaggedTemplateExpression": return `${$(e.tag, t)}${$(e.quasi, t)}`;
|
|
4696
|
+
case "ThisExpression": return "scope";
|
|
4697
|
+
case "BlockStatement": {
|
|
4698
|
+
let n = new Set(t);
|
|
4699
|
+
return `{ ${(e.body ? e.body.map((e) => $(e, n)).filter(Boolean) : []).join("; ")}; }`;
|
|
4700
|
+
}
|
|
4701
|
+
case "ExpressionStatement": return $(e.expression, t);
|
|
4702
|
+
case "ReturnStatement": return `return ${e.argument ? $(e.argument, t) : ""}`;
|
|
4703
|
+
case "BreakStatement": return e.label ? `break ${e.label.name}` : "break";
|
|
4704
|
+
case "ContinueStatement": return e.label ? `continue ${e.label.name}` : "continue";
|
|
4705
|
+
case "IfStatement": return `if (${$(e.test, t)}) ${e.consequent.type === "BlockStatement" ? $(e.consequent, t) : `{ ${$(e.consequent, t)}; }`}${e.alternate ? ` else ${e.alternate.type === "BlockStatement" || e.alternate.type === "IfStatement" ? $(e.alternate, t) : `{ ${$(e.alternate, t)}; }`}` : ""}`;
|
|
4706
|
+
case "ForStatement": {
|
|
4707
|
+
let n = new Set(t);
|
|
4708
|
+
if (e.init?.type === "VariableDeclaration" && e.init.declarations) for (let t of e.init.declarations) {
|
|
4709
|
+
let e = t.id?.name;
|
|
4710
|
+
e && n.add(e);
|
|
4711
|
+
}
|
|
4712
|
+
let r = "";
|
|
4713
|
+
e.init?.type === "VariableDeclaration" && e.init.declarations ? r = "let " + e.init.declarations.map((e) => `${e.id.name} = ${e.init ? $(e.init, n) : "undefined"}`).join(", ") : e.init && (r = $(e.init, n));
|
|
4714
|
+
let i = e.test ? $(e.test, n) : "", a = e.update ? $(e.update, n) : "", o = e.body ? $(e.body, n) : "";
|
|
4715
|
+
return `(() => { for (${r}; ${i}; ${a}) ${o}; })()`;
|
|
4716
|
+
}
|
|
4717
|
+
case "ForOfStatement": {
|
|
4718
|
+
let n = new Set(t), r = e.left?.type === "VariableDeclaration" ? e.left.declarations[0]?.id?.name : e.left?.name;
|
|
4719
|
+
return r && n.add(r), `(() => { const _iter = (typeof resolveIterable === 'function' ? resolveIterable(${$(e.right, t)}) : (${$(e.right, t)} || [])); for (let ${r} of _iter) { if (scope) scope[${JSON.stringify(r)}] = ${r}; ${$(e.body, n)}; } })()`;
|
|
4720
|
+
}
|
|
4721
|
+
case "ForInStatement": {
|
|
4722
|
+
let n = new Set(t), r = e.left?.type === "VariableDeclaration" ? e.left.declarations[0]?.id?.name : e.left?.name;
|
|
4723
|
+
return r && n.add(r), `(() => { const _obj = ${$(e.right, t)}; if (_obj) { for (let ${r} in _obj) { if (scope) scope[${JSON.stringify(r)}] = ${r}; ${$(e.body, n)}; } } })()`;
|
|
4724
|
+
}
|
|
4725
|
+
case "WhileStatement": return `(() => { while (${$(e.test, t)}) ${$(e.body, t)}; })()`;
|
|
4726
|
+
case "DoWhileStatement": return `(() => { do ${$(e.body, t)} while (${$(e.test, t)}); })()`;
|
|
4727
|
+
case "ArrayPattern": return `[ ${e.elements ? e.elements.map((e) => e ? e.type === "RestElement" ? "..." + $(e.argument, t) : e.type === "AssignmentPattern" ? `${$(e.left, t)} = ${$(e.right, t)}` : e.name || $(e, t) : "").join(", ") : ""} ]`;
|
|
4728
|
+
case "ObjectPattern": return `{ ${e.properties ? e.properties.map((e) => {
|
|
4729
|
+
if (e.type === "Property") {
|
|
4730
|
+
let n = e.key?.name || $(e.key, t), r = e.value?.name || $(e.value, t);
|
|
4731
|
+
return n === r ? n : `${n}: ${r}`;
|
|
4732
|
+
}
|
|
4733
|
+
return e.type === "RestElement" ? `...${$(e.argument, t)}` : "";
|
|
4734
|
+
}).filter(Boolean).join(", ") : ""} }`;
|
|
4735
|
+
case "VariableDeclaration": {
|
|
4736
|
+
let n = new Set(t), r = [];
|
|
4737
|
+
if (e.declarations) for (let i of e.declarations) if (i.id?.type === "ObjectPattern") {
|
|
4738
|
+
let e = i.init ? $(i.init, t) : "undefined";
|
|
4739
|
+
for (let a of i.id.properties || []) if (a.type === "Property") {
|
|
4740
|
+
let i = a.key?.name || (typeof a.key?.value == "string" ? a.key.value : $(a.key, t)), o = a.value?.name, s = null;
|
|
4741
|
+
if (a.value?.type === "AssignmentPattern" ? (o = a.value.left?.name || $(a.value.left, t), s = $(a.value.right, t)) : o ||= $(a.value, t), o) {
|
|
4742
|
+
n.add(o);
|
|
4743
|
+
let t = `((${e} && (${JSON.stringify(i)} in ${e})) ? ${e}[${JSON.stringify(i)}] : ${s ?? "undefined"})`;
|
|
4744
|
+
r.push(`(typeof setScopeValue === 'function' ? setScopeValue(scope, ${JSON.stringify(o)}, ${t}) : ((scope || {})[${JSON.stringify(o)}] = ${t}))`);
|
|
4745
|
+
}
|
|
4746
|
+
}
|
|
4747
|
+
} else {
|
|
4748
|
+
let e = i.id?.name || $(i.id, t);
|
|
4749
|
+
i.id?.name && n.add(i.id.name);
|
|
4750
|
+
let a = i.init ? $(i.init, t) : "undefined";
|
|
4751
|
+
t && i.id?.name && t.has(i.id.name) ? r.push(`${i.id.name} = ${a}`) : r.push(`(typeof setScopeValue === 'function' ? setScopeValue(scope, ${JSON.stringify(e)}, ${a}) : ((scope || {})[${JSON.stringify(e)}] = ${a}))`);
|
|
4752
|
+
}
|
|
4753
|
+
return `(${r.filter(Boolean).join(", ") || "undefined"})`;
|
|
4754
|
+
}
|
|
4755
|
+
case "FunctionDeclaration": {
|
|
4756
|
+
let n = e.id?.name, r = new Set(t);
|
|
4757
|
+
n && r.add(n);
|
|
4758
|
+
let i = [];
|
|
4759
|
+
if (e.params) for (let n of e.params) if (n.type === "AssignmentPattern") {
|
|
4760
|
+
let e = n.left?.name || $(n.left, t), a = $(n.right, t);
|
|
4761
|
+
n.left?.name && r.add(n.left.name), i.push(`${e} = ${a}`);
|
|
4762
|
+
} else {
|
|
4763
|
+
let e = n.name || n.id?.name || n.left && n.left.name || $(n, t);
|
|
4764
|
+
e && (i.push(e), r.add(e));
|
|
4765
|
+
}
|
|
4766
|
+
if (e.body?.type === "BlockStatement" && Array.isArray(e.body.body)) for (let t of e.body.body) if (t.type === "VariableDeclaration" && t.declarations) for (let e of t.declarations) e.id?.name && r.add(e.id.name);
|
|
4767
|
+
else t.type === "FunctionDeclaration" && t.id?.name && r.add(t.id.name);
|
|
4768
|
+
let a = i.join(", "), o = e.body?.type === "BlockStatement" ? `{ ${e.body.body.map((e) => $(e, r)).filter(Boolean).join("; ")}; }` : `{ ${$(e.body, r)}; }`, s = `function ${n || ""}(${a}) ${o}`;
|
|
4769
|
+
return n ? `(typeof setScopeValue === 'function' ? setScopeValue(scope, ${JSON.stringify(n)}, ${s}) : ((scope || {})[${JSON.stringify(n)}] = ${s}))` : s;
|
|
4770
|
+
}
|
|
4771
|
+
case "ArrowFunctionExpression":
|
|
4772
|
+
case "FunctionExpression": {
|
|
4773
|
+
let n = new Set(t), r = [];
|
|
4774
|
+
if (e.params) for (let i of e.params) if (i.type === "AssignmentPattern") {
|
|
4775
|
+
let e = i.left?.name || $(i.left, t), a = $(i.right, t);
|
|
4776
|
+
i.left?.name && n.add(i.left.name), r.push(`${e} = ${a}`);
|
|
4777
|
+
} else {
|
|
4778
|
+
let e = i.name || i.id?.name || i.left && i.left.name || $(i, t);
|
|
4779
|
+
e && (r.push(e), n.add(e));
|
|
4780
|
+
}
|
|
4781
|
+
if (e.body?.type === "BlockStatement" && Array.isArray(e.body.body)) for (let t of e.body.body) if (t.type === "VariableDeclaration" && t.declarations) for (let e of t.declarations) e.id?.name && n.add(e.id.name);
|
|
4782
|
+
else t.type === "FunctionDeclaration" && t.id?.name && n.add(t.id.name);
|
|
4783
|
+
let i = r.join(", ");
|
|
4784
|
+
return e.body?.type === "BlockStatement" ? `((${i}) => ${`{ ${e.body.body.map((e) => $(e, n)).filter(Boolean).join("; ")}; }`})` : `((${i}) => ${$(e.body, n)})`;
|
|
4785
|
+
}
|
|
4786
|
+
case "NewExpression": return `new (${$(e.callee, t)})(${e.arguments ? e.arguments.map((e) => $(e, t)).join(", ") : ""})`;
|
|
4787
|
+
case "EmptyStatement":
|
|
4788
|
+
case "ImportDeclaration":
|
|
4789
|
+
case "ImportSpecifier":
|
|
4790
|
+
case "ImportDefaultSpecifier":
|
|
4791
|
+
case "ImportNamespaceSpecifier": return "";
|
|
4792
|
+
case "ParenthesizedExpression":
|
|
4793
|
+
case "ChainExpression": return $(e.expression, t);
|
|
4794
|
+
default: return "";
|
|
4795
|
+
}
|
|
4796
|
+
}
|
|
4797
|
+
//#endregion
|
|
4798
|
+
//#region src/index.ts
|
|
4799
|
+
function Yt(e, t = !1) {
|
|
4800
|
+
let n = new Kt(new f(new l(e)).parse()).transform(), r = new qt(n).generate();
|
|
4801
|
+
return t && (console.log("--- Transformed AST ---"), console.log(JSON.stringify(n, null, 2)), console.log("--- Compiled Module ---"), console.log(JSON.stringify(r, null, 2))), r;
|
|
4802
|
+
}
|
|
4803
|
+
//#endregion
|
|
4804
|
+
export { n as ASTNodeType, qt as DriftGenerator, l as DriftLexer, r as DriftLexerError, f as DriftParser, i as DriftParserError, Kt as DriftTransformer, t as LexerStateKind, a as Opcode, e as TokenType, $ as astToJS, Yt as compile };
|