@danielx/civet 0.6.18 → 0.6.19
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/browser.js +171 -230
- package/dist/main.js +171 -230
- package/dist/main.mjs +171 -230
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -157,15 +157,8 @@ var Civet = (() => {
|
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
function arrayElementHasTrailingComma(elementNode) {
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
if (lastChild) {
|
|
163
|
-
const l2 = lastChild.length;
|
|
164
|
-
if (lastChild[l2 - 1]?.token === ",") {
|
|
165
|
-
return true;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return false;
|
|
160
|
+
const lastChild = elementNode.children.at(-1);
|
|
161
|
+
return lastChild && lastChild[lastChild.length - 1]?.token === ",";
|
|
169
162
|
}
|
|
170
163
|
var assert = {
|
|
171
164
|
equal(a, b, msg) {
|
|
@@ -592,7 +585,15 @@ var Civet = (() => {
|
|
|
592
585
|
case "EmptyStatement":
|
|
593
586
|
case "ReturnStatement":
|
|
594
587
|
case "ThrowStatement":
|
|
588
|
+
return;
|
|
595
589
|
case "Declaration":
|
|
590
|
+
exp.children.push(["", [
|
|
591
|
+
";",
|
|
592
|
+
ref,
|
|
593
|
+
".push(",
|
|
594
|
+
patternAsValue(exp.bindings.at(-1).pattern),
|
|
595
|
+
")"
|
|
596
|
+
]]);
|
|
596
597
|
return;
|
|
597
598
|
case "ForStatement":
|
|
598
599
|
case "IterationStatement":
|
|
@@ -845,6 +846,39 @@ var Civet = (() => {
|
|
|
845
846
|
const indent = expressions[index][0];
|
|
846
847
|
expressions.splice(index, 0, [indent, dec, ";"]);
|
|
847
848
|
}
|
|
849
|
+
function patternAsValue(pattern) {
|
|
850
|
+
switch (pattern.type) {
|
|
851
|
+
case "ArrayBindingPattern": {
|
|
852
|
+
const children = [...pattern.children];
|
|
853
|
+
const index = children.indexOf(pattern.elements);
|
|
854
|
+
if (index < 0)
|
|
855
|
+
throw new Error("failed to find elements in ArrayBindingPattern");
|
|
856
|
+
children[index] = pattern.elements.map((el) => {
|
|
857
|
+
const [ws, e, delim] = el.children;
|
|
858
|
+
return { ...el, children: [ws, patternAsValue(e), delim] };
|
|
859
|
+
});
|
|
860
|
+
return { ...pattern, children };
|
|
861
|
+
}
|
|
862
|
+
case "ObjectBindingPattern": {
|
|
863
|
+
const children = [...pattern.children];
|
|
864
|
+
const index = children.indexOf(pattern.properties);
|
|
865
|
+
if (index < 0)
|
|
866
|
+
throw new Error("failed to find properties in ArrayBindingPattern");
|
|
867
|
+
children[index] = pattern.properties.map(patternAsValue);
|
|
868
|
+
return { ...pattern, children };
|
|
869
|
+
}
|
|
870
|
+
case "Identifier":
|
|
871
|
+
case "BindingProperty": {
|
|
872
|
+
const children = [pattern.name, pattern.delim];
|
|
873
|
+
if (isWhitespaceOrEmpty(pattern.children[0])) {
|
|
874
|
+
children.unshift(pattern.children[0]);
|
|
875
|
+
}
|
|
876
|
+
return { ...pattern, children };
|
|
877
|
+
}
|
|
878
|
+
default:
|
|
879
|
+
return pattern;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
848
882
|
function insertReturn(node) {
|
|
849
883
|
if (!node)
|
|
850
884
|
return;
|
|
@@ -886,7 +920,12 @@ var Civet = (() => {
|
|
|
886
920
|
case "EmptyStatement":
|
|
887
921
|
case "ReturnStatement":
|
|
888
922
|
case "ThrowStatement":
|
|
923
|
+
return;
|
|
889
924
|
case "Declaration":
|
|
925
|
+
exp.children.push(["", {
|
|
926
|
+
type: "ReturnStatement",
|
|
927
|
+
children: [";return ", patternAsValue(exp.bindings.at(-1).pattern)]
|
|
928
|
+
}]);
|
|
890
929
|
return;
|
|
891
930
|
case "ForStatement":
|
|
892
931
|
case "IterationStatement":
|
|
@@ -1301,72 +1340,59 @@ var Civet = (() => {
|
|
|
1301
1340
|
children: [s, parts, e]
|
|
1302
1341
|
};
|
|
1303
1342
|
}
|
|
1304
|
-
function
|
|
1305
|
-
|
|
1306
|
-
...
|
|
1343
|
+
function processAssignmentDeclaration(decl, id, suffix, ws, assign, e) {
|
|
1344
|
+
decl = {
|
|
1345
|
+
...decl,
|
|
1307
1346
|
$loc: {
|
|
1308
|
-
pos:
|
|
1309
|
-
length:
|
|
1347
|
+
pos: assign.$loc.pos - 1,
|
|
1348
|
+
length: assign.$loc.length + 1
|
|
1310
1349
|
}
|
|
1311
1350
|
};
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
exp
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1351
|
+
if (decl.token.startsWith("const")) {
|
|
1352
|
+
let exp;
|
|
1353
|
+
if (e.type === "FunctionExpression") {
|
|
1354
|
+
exp = e;
|
|
1355
|
+
} else {
|
|
1356
|
+
exp = e[1];
|
|
1357
|
+
}
|
|
1358
|
+
if (exp?.children?.[0]?.token?.match(/^\s+$/))
|
|
1359
|
+
exp.children.shift();
|
|
1360
|
+
if (id.type === "Identifier" && exp?.type === "FunctionExpression" && !exp.id) {
|
|
1361
|
+
const i = exp.children.findIndex((c) => c?.token === "function") + 1;
|
|
1362
|
+
exp = {
|
|
1363
|
+
...exp,
|
|
1364
|
+
children: [...exp.children.slice(0, i), " ", id, suffix, ws, ...exp.children.slice(i)]
|
|
1365
|
+
};
|
|
1366
|
+
return {
|
|
1367
|
+
type: "Declaration",
|
|
1368
|
+
decl,
|
|
1369
|
+
children: [exp],
|
|
1370
|
+
names: id.names
|
|
1371
|
+
};
|
|
1372
|
+
}
|
|
1331
1373
|
}
|
|
1332
1374
|
let [splices, thisAssignments] = gatherBindingCode(id);
|
|
1333
1375
|
splices = splices.map((s) => [", ", s]);
|
|
1334
1376
|
thisAssignments = thisAssignments.map((a) => ["", a, ";"]);
|
|
1335
|
-
const
|
|
1336
|
-
const
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
type: "Declaration",
|
|
1340
|
-
names: id.names,
|
|
1341
|
-
children,
|
|
1342
|
-
binding,
|
|
1377
|
+
const initializer = [ws, assign, e];
|
|
1378
|
+
const binding = {
|
|
1379
|
+
type: "Binding",
|
|
1380
|
+
pattern: id,
|
|
1343
1381
|
initializer,
|
|
1344
1382
|
splices,
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
function processLetAssignmentDeclaration(l, id, suffix, ws, la, e) {
|
|
1349
|
-
l = {
|
|
1350
|
-
...l,
|
|
1351
|
-
$loc: {
|
|
1352
|
-
pos: la.$loc.pos - 1,
|
|
1353
|
-
length: la.$loc.length + 1
|
|
1354
|
-
}
|
|
1383
|
+
suffix,
|
|
1384
|
+
thisAssignments,
|
|
1385
|
+
children: [id, suffix, initializer]
|
|
1355
1386
|
};
|
|
1356
|
-
|
|
1357
|
-
splices = splices.map((s) => [", ", s]);
|
|
1358
|
-
thisAssignments = thisAssignments.map((a) => ["", a, ";"]);
|
|
1359
|
-
const binding = [l, id, suffix, ...ws];
|
|
1360
|
-
const initializer = [la, e];
|
|
1361
|
-
const children = [binding, initializer];
|
|
1387
|
+
const children = [decl, binding];
|
|
1362
1388
|
return {
|
|
1363
1389
|
type: "Declaration",
|
|
1364
1390
|
names: id.names,
|
|
1365
|
-
|
|
1366
|
-
binding,
|
|
1367
|
-
initializer,
|
|
1391
|
+
decl,
|
|
1392
|
+
bindings: [binding],
|
|
1368
1393
|
splices,
|
|
1369
|
-
thisAssignments
|
|
1394
|
+
thisAssignments,
|
|
1395
|
+
children
|
|
1370
1396
|
};
|
|
1371
1397
|
}
|
|
1372
1398
|
function implicitFunctionBlock(f) {
|
|
@@ -1577,9 +1603,9 @@ var Civet = (() => {
|
|
|
1577
1603
|
const subRef = [ref, "[", i.toString(), "]"];
|
|
1578
1604
|
getPatternConditions(e, subRef, conditions);
|
|
1579
1605
|
});
|
|
1580
|
-
const
|
|
1581
|
-
if (
|
|
1582
|
-
const postElements =
|
|
1606
|
+
const { blockPrefix } = pattern;
|
|
1607
|
+
if (blockPrefix) {
|
|
1608
|
+
const postElements = blockPrefix.children[1], { length: postLength } = postElements;
|
|
1583
1609
|
postElements.forEach(({ children: [, e] }, i) => {
|
|
1584
1610
|
const subRef = [ref, "[", ref, ".length - ", (postLength + i).toString(), "]"];
|
|
1585
1611
|
getPatternConditions(e, subRef, conditions);
|
|
@@ -1666,15 +1692,15 @@ var Civet = (() => {
|
|
|
1666
1692
|
if (el.type === "BindingRestElement") {
|
|
1667
1693
|
return ["", el, void 0];
|
|
1668
1694
|
}
|
|
1669
|
-
const { children: [ws, e,
|
|
1695
|
+
const { children: [ws, e, delim] } = el;
|
|
1670
1696
|
switch (e.type) {
|
|
1671
1697
|
case "Literal":
|
|
1672
1698
|
case "RegularExpressionLiteral":
|
|
1673
1699
|
case "StringLiteral":
|
|
1674
1700
|
case "PinPattern":
|
|
1675
|
-
return
|
|
1701
|
+
return delim;
|
|
1676
1702
|
default:
|
|
1677
|
-
return [ws, nonMatcherBindings(e),
|
|
1703
|
+
return [ws, nonMatcherBindings(e), delim];
|
|
1678
1704
|
}
|
|
1679
1705
|
});
|
|
1680
1706
|
}
|
|
@@ -1684,13 +1710,12 @@ var Civet = (() => {
|
|
|
1684
1710
|
case "BindingProperty": {
|
|
1685
1711
|
const { children, name, value } = p;
|
|
1686
1712
|
const [ws] = children;
|
|
1687
|
-
const sep = children[children.length - 1];
|
|
1688
1713
|
switch (value && value.type) {
|
|
1689
1714
|
case "ArrayBindingPattern":
|
|
1690
1715
|
case "ObjectBindingPattern":
|
|
1691
1716
|
return {
|
|
1692
1717
|
...p,
|
|
1693
|
-
children: [ws, name, ": ", nonMatcherBindings(value)]
|
|
1718
|
+
children: [ws, name, ": ", nonMatcherBindings(value), p.delim]
|
|
1694
1719
|
};
|
|
1695
1720
|
case "Identifier":
|
|
1696
1721
|
return p;
|
|
@@ -1700,7 +1725,7 @@ var Civet = (() => {
|
|
|
1700
1725
|
default:
|
|
1701
1726
|
return {
|
|
1702
1727
|
...p,
|
|
1703
|
-
children: [ws, name,
|
|
1728
|
+
children: [ws, name, p.delim]
|
|
1704
1729
|
};
|
|
1705
1730
|
}
|
|
1706
1731
|
}
|
|
@@ -2370,9 +2395,20 @@ var Civet = (() => {
|
|
|
2370
2395
|
let rest = props[restIndex];
|
|
2371
2396
|
props = props.slice(0, restIndex);
|
|
2372
2397
|
if (after.length) {
|
|
2373
|
-
const
|
|
2374
|
-
rest = {
|
|
2375
|
-
|
|
2398
|
+
const { delim: restDelim } = rest, lastAfterProp = after[after.length - 1], { delim: lastDelim, children: lastAfterChildren } = lastAfterProp;
|
|
2399
|
+
rest = {
|
|
2400
|
+
...rest,
|
|
2401
|
+
delim: lastDelim,
|
|
2402
|
+
children: [...rest.children.slice(0, -1), lastDelim]
|
|
2403
|
+
};
|
|
2404
|
+
after = [
|
|
2405
|
+
...after.slice(0, -1),
|
|
2406
|
+
{
|
|
2407
|
+
...lastAfterProp,
|
|
2408
|
+
delim: restDelim,
|
|
2409
|
+
children: [...lastAfterChildren.slice(0, -1), restDelim]
|
|
2410
|
+
}
|
|
2411
|
+
];
|
|
2376
2412
|
}
|
|
2377
2413
|
const children = [...props, ...after, rest];
|
|
2378
2414
|
return {
|
|
@@ -2552,8 +2588,7 @@ var Civet = (() => {
|
|
|
2552
2588
|
processBinaryOpExpression,
|
|
2553
2589
|
processCallMemberExpression,
|
|
2554
2590
|
processCoffeeInterpolation,
|
|
2555
|
-
|
|
2556
|
-
processLetAssignmentDeclaration,
|
|
2591
|
+
processAssignmentDeclaration,
|
|
2557
2592
|
processParams,
|
|
2558
2593
|
processProgram,
|
|
2559
2594
|
processReturnValue,
|
|
@@ -3094,7 +3129,6 @@ ${input.slice(result.pos)}
|
|
|
3094
3129
|
BindingProperty,
|
|
3095
3130
|
BindingRestProperty,
|
|
3096
3131
|
NestedBindingElements,
|
|
3097
|
-
NestedBindingElement,
|
|
3098
3132
|
BindingElement,
|
|
3099
3133
|
BindingRestElement,
|
|
3100
3134
|
EmptyBindingPattern,
|
|
@@ -3316,7 +3350,6 @@ ${input.slice(result.pos)}
|
|
|
3316
3350
|
Initializer,
|
|
3317
3351
|
VariableStatement,
|
|
3318
3352
|
VariableDeclarationList,
|
|
3319
|
-
VariableDeclaration,
|
|
3320
3353
|
NumericLiteral,
|
|
3321
3354
|
NumericLiteralKind,
|
|
3322
3355
|
DecimalBigIntegerLiteral,
|
|
@@ -7342,7 +7375,7 @@ ${input.slice(result.pos)}
|
|
|
7342
7375
|
var c = $3;
|
|
7343
7376
|
return {
|
|
7344
7377
|
type: "ObjectBindingPattern",
|
|
7345
|
-
children: $
|
|
7378
|
+
children: [$1, $2, c.children, $4, $5],
|
|
7346
7379
|
names: c.names,
|
|
7347
7380
|
properties: c.children
|
|
7348
7381
|
};
|
|
@@ -7403,6 +7436,7 @@ ${input.slice(result.pos)}
|
|
|
7403
7436
|
return props.map(([prop, delim]) => {
|
|
7404
7437
|
return {
|
|
7405
7438
|
...prop,
|
|
7439
|
+
delim,
|
|
7406
7440
|
children: [...prop.children, delim]
|
|
7407
7441
|
};
|
|
7408
7442
|
});
|
|
@@ -7432,11 +7466,10 @@ ${input.slice(result.pos)}
|
|
|
7432
7466
|
var ArrayBindingPattern$0 = $TS($S($E(_), OpenBracket, ArrayBindingPatternContent, __, CloseBracket), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
7433
7467
|
var c = $3;
|
|
7434
7468
|
return {
|
|
7469
|
+
...c,
|
|
7435
7470
|
type: "ArrayBindingPattern",
|
|
7436
|
-
children: $0,
|
|
7437
|
-
names: c.names,
|
|
7438
7471
|
elements: c.children,
|
|
7439
|
-
|
|
7472
|
+
children: [$1, $2, c.children, $4, $5]
|
|
7440
7473
|
};
|
|
7441
7474
|
});
|
|
7442
7475
|
function ArrayBindingPattern(state) {
|
|
@@ -7522,14 +7555,14 @@ ${input.slice(result.pos)}
|
|
|
7522
7555
|
}
|
|
7523
7556
|
}
|
|
7524
7557
|
var NestedBindingElementList$0 = $TS($S(Nested, BindingElementList), function($skip, $loc, $0, $1, $2) {
|
|
7525
|
-
var
|
|
7558
|
+
var indent = $1;
|
|
7526
7559
|
var elements = $2;
|
|
7527
7560
|
return elements.map((element, i) => {
|
|
7528
7561
|
if (i > 0)
|
|
7529
7562
|
return element;
|
|
7530
7563
|
return {
|
|
7531
7564
|
...element,
|
|
7532
|
-
children: [
|
|
7565
|
+
children: [indent, ...element.children.slice(1)]
|
|
7533
7566
|
};
|
|
7534
7567
|
});
|
|
7535
7568
|
});
|
|
@@ -7644,13 +7677,13 @@ ${input.slice(result.pos)}
|
|
|
7644
7677
|
var BindingProperty$1 = $TS($S($E(_), PropertyName, $E(_), Colon, $E(_), $C(BindingIdentifier, BindingPattern), $E(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
|
|
7645
7678
|
var name = $2;
|
|
7646
7679
|
var value = $6;
|
|
7647
|
-
var
|
|
7680
|
+
var initializer = $7;
|
|
7648
7681
|
return {
|
|
7649
7682
|
type: "BindingProperty",
|
|
7650
7683
|
children: $0,
|
|
7651
7684
|
name,
|
|
7652
7685
|
value,
|
|
7653
|
-
|
|
7686
|
+
initializer,
|
|
7654
7687
|
names: value.names
|
|
7655
7688
|
};
|
|
7656
7689
|
});
|
|
@@ -7658,14 +7691,14 @@ ${input.slice(result.pos)}
|
|
|
7658
7691
|
var ws = $1;
|
|
7659
7692
|
var pin = $2;
|
|
7660
7693
|
var binding = $3;
|
|
7661
|
-
var
|
|
7694
|
+
var initializer = $4;
|
|
7662
7695
|
if (binding.type === "AtBinding") {
|
|
7663
7696
|
return {
|
|
7664
7697
|
type: "AtBindingProperty",
|
|
7665
7698
|
children: $0,
|
|
7666
7699
|
binding,
|
|
7667
7700
|
ref: binding.ref,
|
|
7668
|
-
|
|
7701
|
+
initializer,
|
|
7669
7702
|
names: []
|
|
7670
7703
|
};
|
|
7671
7704
|
}
|
|
@@ -7685,7 +7718,7 @@ ${input.slice(result.pos)}
|
|
|
7685
7718
|
children: $0,
|
|
7686
7719
|
name: binding,
|
|
7687
7720
|
value: void 0,
|
|
7688
|
-
|
|
7721
|
+
initializer,
|
|
7689
7722
|
names: binding.names,
|
|
7690
7723
|
identifier: binding
|
|
7691
7724
|
};
|
|
@@ -7782,36 +7815,6 @@ ${input.slice(result.pos)}
|
|
|
7782
7815
|
return result;
|
|
7783
7816
|
}
|
|
7784
7817
|
}
|
|
7785
|
-
var NestedBindingElement$0 = $TS($S(Nested, BindingElement), function($skip, $loc, $0, $1, $2) {
|
|
7786
|
-
var indent = $1;
|
|
7787
|
-
var element = $2;
|
|
7788
|
-
return {
|
|
7789
|
-
...element,
|
|
7790
|
-
children: [indent, ...element.children]
|
|
7791
|
-
};
|
|
7792
|
-
});
|
|
7793
|
-
function NestedBindingElement(state) {
|
|
7794
|
-
let eventData;
|
|
7795
|
-
if (state.events) {
|
|
7796
|
-
const result = state.events.enter?.("NestedBindingElement", state);
|
|
7797
|
-
if (result) {
|
|
7798
|
-
if (result.cache)
|
|
7799
|
-
return result.cache;
|
|
7800
|
-
eventData = result.data;
|
|
7801
|
-
}
|
|
7802
|
-
}
|
|
7803
|
-
if (state.tokenize) {
|
|
7804
|
-
const result = $TOKEN("NestedBindingElement", state, NestedBindingElement$0(state));
|
|
7805
|
-
if (state.events)
|
|
7806
|
-
state.events.exit?.("NestedBindingElement", state, result, eventData);
|
|
7807
|
-
return result;
|
|
7808
|
-
} else {
|
|
7809
|
-
const result = NestedBindingElement$0(state);
|
|
7810
|
-
if (state.events)
|
|
7811
|
-
state.events.exit?.("NestedBindingElement", state, result, eventData);
|
|
7812
|
-
return result;
|
|
7813
|
-
}
|
|
7814
|
-
}
|
|
7815
7818
|
var BindingElement$0 = BindingRestElement;
|
|
7816
7819
|
var BindingElement$1 = $TS($S($E(_), $C(BindingIdentifier, BindingPattern), $E(Initializer)), function($skip, $loc, $0, $1, $2, $3) {
|
|
7817
7820
|
var ws = $1;
|
|
@@ -7820,6 +7823,7 @@ ${input.slice(result.pos)}
|
|
|
7820
7823
|
if (binding.children) {
|
|
7821
7824
|
binding = {
|
|
7822
7825
|
...binding,
|
|
7826
|
+
initializer,
|
|
7823
7827
|
children: [...binding.children, initializer]
|
|
7824
7828
|
};
|
|
7825
7829
|
}
|
|
@@ -7865,7 +7869,7 @@ ${input.slice(result.pos)}
|
|
|
7865
7869
|
var binding = $3;
|
|
7866
7870
|
return {
|
|
7867
7871
|
type: "BindingRestElement",
|
|
7868
|
-
children: [
|
|
7872
|
+
children: [ws, [dots, binding]],
|
|
7869
7873
|
binding,
|
|
7870
7874
|
name: binding.name,
|
|
7871
7875
|
names: binding.names,
|
|
@@ -13476,17 +13480,19 @@ ${input.slice(result.pos)}
|
|
|
13476
13480
|
type: "Ref",
|
|
13477
13481
|
base: "ref"
|
|
13478
13482
|
};
|
|
13479
|
-
const {
|
|
13483
|
+
const { decl, bindings } = dec;
|
|
13484
|
+
const binding = bindings[0];
|
|
13485
|
+
const { pattern, suffix, initializer, splices, thisAssignments } = binding;
|
|
13480
13486
|
const initCondition = {
|
|
13481
13487
|
type: "AssignmentExpression",
|
|
13482
|
-
children: [ref,
|
|
13488
|
+
children: [ref, initializer],
|
|
13483
13489
|
hoistDec: {
|
|
13484
13490
|
type: "Declaration",
|
|
13485
|
-
children: ["let ", ref],
|
|
13491
|
+
children: ["let ", ref, suffix],
|
|
13486
13492
|
names: []
|
|
13487
13493
|
},
|
|
13488
13494
|
blockPrefix: [
|
|
13489
|
-
["", [
|
|
13495
|
+
["", [decl, pattern, suffix, " = ", ref, ...splices], ";"],
|
|
13490
13496
|
...thisAssignments
|
|
13491
13497
|
]
|
|
13492
13498
|
};
|
|
@@ -15185,26 +15191,23 @@ ${input.slice(result.pos)}
|
|
|
15185
15191
|
return result;
|
|
15186
15192
|
}
|
|
15187
15193
|
}
|
|
15188
|
-
var LexicalDeclaration$0 = $TS($S(LetOrConst, LexicalBinding, $Q($S(__, Comma, LexicalBinding))), function($skip, $loc, $0, $1, $2, $3) {
|
|
15189
|
-
var
|
|
15194
|
+
var LexicalDeclaration$0 = $TS($S(LetOrConst, LexicalBinding, $Q($S(__, Comma, __, LexicalBinding))), function($skip, $loc, $0, $1, $2, $3) {
|
|
15195
|
+
var decl = $1;
|
|
15190
15196
|
var binding = $2;
|
|
15191
15197
|
var tail = $3;
|
|
15192
|
-
const
|
|
15198
|
+
const bindings = [binding].concat(tail.map(([, , , b]) => b));
|
|
15193
15199
|
return {
|
|
15194
15200
|
type: "Declaration",
|
|
15195
15201
|
children: $0,
|
|
15196
|
-
names:
|
|
15197
|
-
|
|
15198
|
-
|
|
15199
|
-
|
|
15200
|
-
|
|
15201
|
-
initializer: binding.initializer,
|
|
15202
|
-
splices,
|
|
15203
|
-
thisAssignments
|
|
15202
|
+
names: bindings.flatMap((b) => b.names),
|
|
15203
|
+
bindings,
|
|
15204
|
+
decl,
|
|
15205
|
+
splices: bindings.flatMap((b) => b.splices),
|
|
15206
|
+
thisAssignments: bindings.flatMap((b) => b.thisAssignments)
|
|
15204
15207
|
};
|
|
15205
15208
|
});
|
|
15206
15209
|
var LexicalDeclaration$1 = $TS($S(InsertConst, $C(BindingPattern, BindingIdentifier), $E(TypeSuffix), __, ConstAssignment, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
15207
|
-
return
|
|
15210
|
+
return processAssignmentDeclaration(...$0);
|
|
15208
15211
|
});
|
|
15209
15212
|
var LexicalDeclaration$2 = $TS($S(InsertLet, $C(BindingPattern, BindingIdentifier), $E(TypeSuffix), __, LetAssignment, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
15210
15213
|
var l = $1;
|
|
@@ -15213,7 +15216,7 @@ ${input.slice(result.pos)}
|
|
|
15213
15216
|
var ws = $4;
|
|
15214
15217
|
var la = $5;
|
|
15215
15218
|
var e = $6;
|
|
15216
|
-
return
|
|
15219
|
+
return processAssignmentDeclaration(...$0);
|
|
15217
15220
|
});
|
|
15218
15221
|
function LexicalDeclaration(state) {
|
|
15219
15222
|
let eventData;
|
|
@@ -15287,48 +15290,32 @@ ${input.slice(result.pos)}
|
|
|
15287
15290
|
return result;
|
|
15288
15291
|
}
|
|
15289
15292
|
}
|
|
15290
|
-
var LexicalBinding$0 = $TS($S(BindingPattern, $E(TypeSuffix),
|
|
15291
|
-
var
|
|
15293
|
+
var LexicalBinding$0 = $TS($S(BindingPattern, $E(TypeSuffix), Initializer), function($skip, $loc, $0, $1, $2, $3) {
|
|
15294
|
+
var pattern = $1;
|
|
15292
15295
|
var suffix = $2;
|
|
15293
|
-
var
|
|
15294
|
-
|
|
15295
|
-
const bindingChildren = [...binding.children];
|
|
15296
|
-
if (suffix)
|
|
15297
|
-
bindingChildren.push(suffix);
|
|
15298
|
-
if (ws)
|
|
15299
|
-
bindingChildren.push(...ws);
|
|
15300
|
-
binding = {
|
|
15301
|
-
...binding,
|
|
15302
|
-
children: bindingChildren
|
|
15303
|
-
};
|
|
15304
|
-
const [splices, thisAssignments] = gatherBindingCode(binding.children);
|
|
15296
|
+
var initializer = $3;
|
|
15297
|
+
const [splices, thisAssignments] = gatherBindingCode(pattern);
|
|
15305
15298
|
return {
|
|
15306
|
-
|
|
15307
|
-
|
|
15308
|
-
|
|
15299
|
+
type: "Binding",
|
|
15300
|
+
children: $0,
|
|
15301
|
+
names: pattern.names,
|
|
15302
|
+
pattern,
|
|
15303
|
+
suffix,
|
|
15309
15304
|
initializer,
|
|
15310
15305
|
splices: splices.map((s) => [",", s]),
|
|
15311
15306
|
thisAssignments: thisAssignments.map((s) => ["", s, ";"])
|
|
15312
15307
|
};
|
|
15313
15308
|
});
|
|
15314
|
-
var LexicalBinding$1 = $TS($S(BindingIdentifier, $E(TypeSuffix), $E(
|
|
15315
|
-
var
|
|
15309
|
+
var LexicalBinding$1 = $TS($S(BindingIdentifier, $E(TypeSuffix), $E(Initializer)), function($skip, $loc, $0, $1, $2, $3) {
|
|
15310
|
+
var pattern = $1;
|
|
15316
15311
|
var suffix = $2;
|
|
15317
|
-
var
|
|
15318
|
-
var initializer = $4;
|
|
15319
|
-
const bindingChildren = [...binding.children];
|
|
15320
|
-
if (suffix)
|
|
15321
|
-
bindingChildren.push(suffix);
|
|
15322
|
-
if (ws)
|
|
15323
|
-
bindingChildren.push(...ws);
|
|
15324
|
-
binding = {
|
|
15325
|
-
...binding,
|
|
15326
|
-
children: bindingChildren
|
|
15327
|
-
};
|
|
15312
|
+
var initializer = $3;
|
|
15328
15313
|
return {
|
|
15329
|
-
|
|
15330
|
-
|
|
15331
|
-
|
|
15314
|
+
type: "Binding",
|
|
15315
|
+
children: $0,
|
|
15316
|
+
names: pattern.names,
|
|
15317
|
+
pattern,
|
|
15318
|
+
suffix,
|
|
15332
15319
|
initializer,
|
|
15333
15320
|
splices: [],
|
|
15334
15321
|
thisAssignments: []
|
|
@@ -15380,9 +15367,10 @@ ${input.slice(result.pos)}
|
|
|
15380
15367
|
}
|
|
15381
15368
|
}
|
|
15382
15369
|
var VariableStatement$0 = $TS($S(Var, __, VariableDeclarationList), function($skip, $loc, $0, $1, $2, $3) {
|
|
15383
|
-
return
|
|
15370
|
+
return {
|
|
15371
|
+
...$3,
|
|
15384
15372
|
children: [$1, ...$2, ...$3.children]
|
|
15385
|
-
}
|
|
15373
|
+
};
|
|
15386
15374
|
});
|
|
15387
15375
|
function VariableStatement(state) {
|
|
15388
15376
|
let eventData;
|
|
@@ -15406,18 +15394,15 @@ ${input.slice(result.pos)}
|
|
|
15406
15394
|
return result;
|
|
15407
15395
|
}
|
|
15408
15396
|
}
|
|
15409
|
-
var VariableDeclarationList$0 = $TS($S(
|
|
15410
|
-
|
|
15411
|
-
|
|
15412
|
-
|
|
15413
|
-
} else {
|
|
15414
|
-
children = [$1];
|
|
15415
|
-
}
|
|
15416
|
-
const names = children.flatMap((c) => c.names || []);
|
|
15397
|
+
var VariableDeclarationList$0 = $TS($S(LexicalBinding, $Q($S(__, Comma, __, LexicalBinding))), function($skip, $loc, $0, $1, $2) {
|
|
15398
|
+
var binding = $1;
|
|
15399
|
+
var tail = $2;
|
|
15400
|
+
const bindings = [binding].concat(tail.map(([, , , b]) => b));
|
|
15417
15401
|
return {
|
|
15418
15402
|
type: "Declaration",
|
|
15419
|
-
children,
|
|
15420
|
-
|
|
15403
|
+
children: [binding, ...tail],
|
|
15404
|
+
bindings,
|
|
15405
|
+
names: bindings.flatMap((b) => b.names)
|
|
15421
15406
|
};
|
|
15422
15407
|
});
|
|
15423
15408
|
function VariableDeclarationList(state) {
|
|
@@ -15442,49 +15427,6 @@ ${input.slice(result.pos)}
|
|
|
15442
15427
|
return result;
|
|
15443
15428
|
}
|
|
15444
15429
|
}
|
|
15445
|
-
var VariableDeclaration$0 = $TS($S(BindingPattern, $E(TypeSuffix), Initializer), function($skip, $loc, $0, $1, $2, $3) {
|
|
15446
|
-
const children = [...$1.children];
|
|
15447
|
-
if ($2)
|
|
15448
|
-
children.push($2);
|
|
15449
|
-
children.push($3);
|
|
15450
|
-
return {
|
|
15451
|
-
children,
|
|
15452
|
-
names: $1.names
|
|
15453
|
-
};
|
|
15454
|
-
});
|
|
15455
|
-
var VariableDeclaration$1 = $TS($S(BindingIdentifier, $E(TypeSuffix), $E(Initializer)), function($skip, $loc, $0, $1, $2, $3) {
|
|
15456
|
-
const children = [...$1.children];
|
|
15457
|
-
if ($2)
|
|
15458
|
-
children.push($2);
|
|
15459
|
-
if ($3)
|
|
15460
|
-
children.push($3);
|
|
15461
|
-
return {
|
|
15462
|
-
children,
|
|
15463
|
-
names: $1.names
|
|
15464
|
-
};
|
|
15465
|
-
});
|
|
15466
|
-
function VariableDeclaration(state) {
|
|
15467
|
-
let eventData;
|
|
15468
|
-
if (state.events) {
|
|
15469
|
-
const result = state.events.enter?.("VariableDeclaration", state);
|
|
15470
|
-
if (result) {
|
|
15471
|
-
if (result.cache)
|
|
15472
|
-
return result.cache;
|
|
15473
|
-
eventData = result.data;
|
|
15474
|
-
}
|
|
15475
|
-
}
|
|
15476
|
-
if (state.tokenize) {
|
|
15477
|
-
const result = $TOKEN("VariableDeclaration", state, VariableDeclaration$0(state) || VariableDeclaration$1(state));
|
|
15478
|
-
if (state.events)
|
|
15479
|
-
state.events.exit?.("VariableDeclaration", state, result, eventData);
|
|
15480
|
-
return result;
|
|
15481
|
-
} else {
|
|
15482
|
-
const result = VariableDeclaration$0(state) || VariableDeclaration$1(state);
|
|
15483
|
-
if (state.events)
|
|
15484
|
-
state.events.exit?.("VariableDeclaration", state, result, eventData);
|
|
15485
|
-
return result;
|
|
15486
|
-
}
|
|
15487
|
-
}
|
|
15488
15430
|
var NumericLiteral$0 = $TS($S(NumericLiteralKind), function($skip, $loc, $0, $1) {
|
|
15489
15431
|
return { type: "NumericLiteral", $loc, token: $1 };
|
|
15490
15432
|
});
|
|
@@ -21245,9 +21187,9 @@ ${input.slice(result.pos)}
|
|
|
21245
21187
|
["let ", id, " = {};\n"],
|
|
21246
21188
|
...block.properties.map((property, i) => {
|
|
21247
21189
|
let init, isString;
|
|
21248
|
-
if (property.
|
|
21190
|
+
if (property.initializer) {
|
|
21249
21191
|
init = replaceNodes(
|
|
21250
|
-
deepCopy(property.
|
|
21192
|
+
deepCopy(property.initializer),
|
|
21251
21193
|
(n) => n.type === "Identifier" && names.has(n.name),
|
|
21252
21194
|
(n) => [id, '["', n.name, '"]']
|
|
21253
21195
|
);
|
|
@@ -21410,11 +21352,11 @@ ${input.slice(result.pos)}
|
|
|
21410
21352
|
}
|
|
21411
21353
|
var EnumProperty$0 = $TS($S(Identifier, $E($S(__, Equals, ExtendedExpression)), ObjectPropertyDelimiter), function($skip, $loc, $0, $1, $2, $3) {
|
|
21412
21354
|
var name = $1;
|
|
21413
|
-
var
|
|
21355
|
+
var initializer = $2;
|
|
21414
21356
|
return {
|
|
21415
21357
|
type: "EnumProperty",
|
|
21416
21358
|
name,
|
|
21417
|
-
|
|
21359
|
+
initializer,
|
|
21418
21360
|
children: $0
|
|
21419
21361
|
};
|
|
21420
21362
|
});
|
|
@@ -24227,8 +24169,7 @@ ${input.slice(result.pos)}
|
|
|
24227
24169
|
processBinaryOpExpression,
|
|
24228
24170
|
processCallMemberExpression,
|
|
24229
24171
|
processCoffeeInterpolation,
|
|
24230
|
-
|
|
24231
|
-
processLetAssignmentDeclaration,
|
|
24172
|
+
processAssignmentDeclaration,
|
|
24232
24173
|
processProgram,
|
|
24233
24174
|
processUnaryExpression,
|
|
24234
24175
|
quoteString,
|