@danielx/civet 0.6.82 → 0.6.83
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 +1726 -1599
- package/dist/civet +0 -0
- package/dist/main.js +1726 -1599
- package/dist/main.mjs +1726 -1599
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -268,27 +268,25 @@ function makeLeftHandSideExpression(expression) {
|
|
|
268
268
|
return expression;
|
|
269
269
|
}
|
|
270
270
|
switch (expression.type) {
|
|
271
|
-
case "Ref":
|
|
272
271
|
case "AmpersandRef":
|
|
272
|
+
case "CallExpression":
|
|
273
273
|
case "Identifier":
|
|
274
|
+
case "JSXElement":
|
|
275
|
+
case "JSXFragment":
|
|
274
276
|
case "Literal":
|
|
275
|
-
case "IterationExpression":
|
|
276
|
-
case "CallExpression":
|
|
277
277
|
case "MemberExpression":
|
|
278
278
|
case "NewExpression":
|
|
279
279
|
case "ParenthesizedExpression":
|
|
280
|
-
case "
|
|
281
|
-
case "
|
|
282
|
-
case "SwitchExpression":
|
|
283
|
-
case "ThrowExpression":
|
|
284
|
-
case "TryExpression":
|
|
280
|
+
case "Ref":
|
|
281
|
+
case "StatementExpression":
|
|
285
282
|
return expression;
|
|
286
283
|
}
|
|
287
284
|
return makeNode({
|
|
288
285
|
type: "ParenthesizedExpression",
|
|
289
286
|
children: ["(", expression, ")"],
|
|
290
287
|
expression,
|
|
291
|
-
implicit: true
|
|
288
|
+
implicit: true,
|
|
289
|
+
parent: void 0
|
|
292
290
|
});
|
|
293
291
|
}
|
|
294
292
|
function updateParentPointers(node, parent, depth = 1) {
|
|
@@ -403,7 +401,9 @@ function wrapIIFE(expressions, async) {
|
|
|
403
401
|
type: "BlockStatement",
|
|
404
402
|
expressions,
|
|
405
403
|
children: ["{", expressions, "}"],
|
|
406
|
-
bare: false
|
|
404
|
+
bare: false,
|
|
405
|
+
root: false,
|
|
406
|
+
parent: void 0
|
|
407
407
|
});
|
|
408
408
|
const parameters = {
|
|
409
409
|
type: "Parameters",
|
|
@@ -442,11 +442,18 @@ function wrapWithReturn(expression) {
|
|
|
442
442
|
children
|
|
443
443
|
});
|
|
444
444
|
}
|
|
445
|
-
var typeNeedsNoParens;
|
|
445
|
+
var assert, typeNeedsNoParens;
|
|
446
446
|
var init_util = __esm({
|
|
447
447
|
"source/parser/util.civet"() {
|
|
448
448
|
"use strict";
|
|
449
449
|
init_traversal();
|
|
450
|
+
assert = {
|
|
451
|
+
equal(a, b, msg) {
|
|
452
|
+
if (a !== b) {
|
|
453
|
+
throw new Error(`Assertion failed [${msg}]: ${a} !== ${b}`);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
};
|
|
450
457
|
typeNeedsNoParens = /* @__PURE__ */ new Set([
|
|
451
458
|
"IdentifierType",
|
|
452
459
|
"ImportType",
|
|
@@ -606,6 +613,17 @@ function makeEmptyBlock() {
|
|
|
606
613
|
empty: true
|
|
607
614
|
};
|
|
608
615
|
}
|
|
616
|
+
function makeBlockFragment() {
|
|
617
|
+
const expressions = [];
|
|
618
|
+
return {
|
|
619
|
+
type: "BlockStatement",
|
|
620
|
+
children: expressions,
|
|
621
|
+
parent: void 0,
|
|
622
|
+
expressions,
|
|
623
|
+
bare: false,
|
|
624
|
+
root: false
|
|
625
|
+
};
|
|
626
|
+
}
|
|
609
627
|
function replaceBlockExpression(node, child, replacement) {
|
|
610
628
|
let found = false;
|
|
611
629
|
const { expressions } = node;
|
|
@@ -737,523 +755,800 @@ var init_block = __esm({
|
|
|
737
755
|
}
|
|
738
756
|
});
|
|
739
757
|
|
|
740
|
-
// source/parser/
|
|
741
|
-
function
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
children
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
758
|
+
// source/parser/binding.civet
|
|
759
|
+
function adjustAtBindings(statements, asThis = false) {
|
|
760
|
+
gatherRecursiveAll(statements, (n) => n.type === "AtBindingProperty").forEach((binding) => {
|
|
761
|
+
const { ref } = binding;
|
|
762
|
+
if (asThis) {
|
|
763
|
+
const atBinding = binding.binding;
|
|
764
|
+
atBinding.children.pop();
|
|
765
|
+
atBinding.type = void 0;
|
|
766
|
+
binding.children.unshift(ref.id, ": this.", ref.base);
|
|
767
|
+
binding.type = "Property";
|
|
768
|
+
binding.ref = void 0;
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
if (ref.names[0] !== ref.base) {
|
|
772
|
+
return binding.children.unshift(ref.base, ": ");
|
|
773
|
+
}
|
|
774
|
+
;
|
|
775
|
+
return;
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
function adjustBindingElements(elements) {
|
|
779
|
+
const names = elements.flatMap((p) => p.names || []), { length } = elements;
|
|
780
|
+
let blockPrefix, restIndex = -1, restCount = 0;
|
|
781
|
+
elements.forEach(({ type }, i) => {
|
|
782
|
+
if (type === "BindingRestElement") {
|
|
783
|
+
if (restIndex < 0)
|
|
784
|
+
restIndex = i;
|
|
785
|
+
return restCount++;
|
|
786
|
+
}
|
|
787
|
+
;
|
|
788
|
+
return;
|
|
789
|
+
});
|
|
790
|
+
if (restCount === 0) {
|
|
791
|
+
return {
|
|
792
|
+
children: elements,
|
|
793
|
+
names,
|
|
794
|
+
blockPrefix,
|
|
795
|
+
length
|
|
796
|
+
};
|
|
797
|
+
} else if (restCount === 1) {
|
|
798
|
+
const rest = elements[restIndex];
|
|
799
|
+
const after = elements.slice(restIndex + 1);
|
|
800
|
+
const restIdentifier = rest.binding.ref || rest.binding;
|
|
801
|
+
names.push(...rest.names || []);
|
|
802
|
+
let l = after.length;
|
|
803
|
+
if (l) {
|
|
804
|
+
if (arrayElementHasTrailingComma(after[l - 1]))
|
|
805
|
+
l++;
|
|
806
|
+
blockPrefix = {
|
|
807
|
+
type: "PostRestBindingElements",
|
|
808
|
+
children: ["[", insertTrimmingSpace(after, ""), "] = ", restIdentifier, ".splice(-", l.toString(), ")"],
|
|
809
|
+
names: after.flatMap((p) => p.names)
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
return {
|
|
813
|
+
names,
|
|
814
|
+
children: [...elements.slice(0, restIndex), {
|
|
815
|
+
...rest,
|
|
816
|
+
children: rest.children.slice(0, -1)
|
|
817
|
+
// remove trailing comma
|
|
818
|
+
}],
|
|
819
|
+
blockPrefix,
|
|
820
|
+
length
|
|
821
|
+
};
|
|
769
822
|
}
|
|
823
|
+
const err = {
|
|
824
|
+
type: "Error",
|
|
825
|
+
children: ["Multiple rest elements in array pattern"]
|
|
826
|
+
};
|
|
770
827
|
return {
|
|
771
|
-
|
|
772
|
-
children: [
|
|
828
|
+
names,
|
|
829
|
+
children: [...elements, err],
|
|
830
|
+
blockPrefix,
|
|
831
|
+
length
|
|
773
832
|
};
|
|
774
833
|
}
|
|
775
|
-
function
|
|
776
|
-
const
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
if (
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
834
|
+
function gatherBindingCode(statements, opts) {
|
|
835
|
+
const thisAssignments = [];
|
|
836
|
+
const splices = [];
|
|
837
|
+
function insertRestSplices(s, p, thisAssignments2) {
|
|
838
|
+
gatherRecursiveAll(s, (n) => n.blockPrefix || opts?.injectParamProps && n.accessModifier || n.type === "AtBinding").forEach((n) => {
|
|
839
|
+
if (n.type === "AtBinding") {
|
|
840
|
+
const { ref } = n;
|
|
841
|
+
const { id } = ref;
|
|
842
|
+
thisAssignments2.push([`this.${id} = `, ref]);
|
|
843
|
+
return;
|
|
785
844
|
}
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
845
|
+
if (opts?.injectParamProps && n.type === "Parameter" && n.accessModifier) {
|
|
846
|
+
n.names.forEach((id) => ({
|
|
847
|
+
push: thisAssignments2.push({
|
|
848
|
+
type: "AssignmentExpression",
|
|
849
|
+
children: [`this.${id} = `, id],
|
|
850
|
+
js: true
|
|
851
|
+
})
|
|
852
|
+
}));
|
|
853
|
+
return;
|
|
854
|
+
}
|
|
855
|
+
const { blockPrefix } = n;
|
|
856
|
+
p.push(blockPrefix);
|
|
857
|
+
return insertRestSplices(blockPrefix, p, thisAssignments2);
|
|
858
|
+
});
|
|
795
859
|
}
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
860
|
+
insertRestSplices(statements, splices, thisAssignments);
|
|
861
|
+
return [splices, thisAssignments];
|
|
862
|
+
}
|
|
863
|
+
function arrayElementHasTrailingComma(elementNode) {
|
|
864
|
+
const lastChild = elementNode.children.at(-1);
|
|
865
|
+
return lastChild && lastChild[lastChild.length - 1]?.token === ",";
|
|
866
|
+
}
|
|
867
|
+
var init_binding = __esm({
|
|
868
|
+
"source/parser/binding.civet"() {
|
|
869
|
+
"use strict";
|
|
870
|
+
init_traversal();
|
|
871
|
+
init_util();
|
|
872
|
+
}
|
|
873
|
+
});
|
|
874
|
+
|
|
875
|
+
// source/parser/op.civet
|
|
876
|
+
function getPrecedence(op) {
|
|
877
|
+
if (typeof op === "string") {
|
|
878
|
+
return precedenceMap.get(op) ?? (() => {
|
|
879
|
+
throw new Error(`Unknown operator: ${op}`);
|
|
880
|
+
})();
|
|
881
|
+
} else if (typeof op.prec === "number") {
|
|
882
|
+
return op.prec;
|
|
883
|
+
} else {
|
|
884
|
+
return precedenceMap.get(op.prec ?? op.token) ?? (op.relational ? precedenceRelational : precedenceCustomDefault);
|
|
801
885
|
}
|
|
802
|
-
return [constructInvocation(fn, arg), null];
|
|
803
886
|
}
|
|
804
|
-
function
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
let
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
if (pipe.token === "|>=") {
|
|
817
|
-
let initRef;
|
|
818
|
-
if (i === 0) {
|
|
819
|
-
outer:
|
|
820
|
-
switch (arg.type) {
|
|
821
|
-
case "MemberExpression":
|
|
822
|
-
if (arg.children.length <= 2)
|
|
823
|
-
break;
|
|
824
|
-
case "CallExpression":
|
|
825
|
-
const access = arg.children.pop();
|
|
826
|
-
switch (access.type) {
|
|
827
|
-
case "PropertyAccess":
|
|
828
|
-
case "SliceExpression":
|
|
829
|
-
break;
|
|
830
|
-
default:
|
|
831
|
-
children.unshift({
|
|
832
|
-
type: "Error",
|
|
833
|
-
$loc: pipe.token.$loc,
|
|
834
|
-
message: `Can't assign to ${access.type}`
|
|
835
|
-
});
|
|
836
|
-
arg.children.push(access);
|
|
837
|
-
break outer;
|
|
838
|
-
}
|
|
839
|
-
usingRef = makeRef();
|
|
840
|
-
initRef = {
|
|
841
|
-
type: "AssignmentExpression",
|
|
842
|
-
children: [usingRef, " = ", arg, ","]
|
|
843
|
-
};
|
|
844
|
-
arg = {
|
|
845
|
-
type: "MemberExpression",
|
|
846
|
-
children: [usingRef, access]
|
|
847
|
-
};
|
|
848
|
-
break;
|
|
887
|
+
function processBinaryOpExpression($0) {
|
|
888
|
+
return recurse(expandChainedComparisons($0));
|
|
889
|
+
function recurse(expandedOps) {
|
|
890
|
+
let i = 2;
|
|
891
|
+
while (i < expandedOps.length) {
|
|
892
|
+
let op = expandedOps[i];
|
|
893
|
+
if (op.special) {
|
|
894
|
+
let advanceLeft2 = function(allowEqual) {
|
|
895
|
+
while (start >= 4) {
|
|
896
|
+
const prevPrec = getPrecedence(expandedOps[start - 2]);
|
|
897
|
+
if (!(prevPrec > prec || allowEqual && prevPrec === prec)) {
|
|
898
|
+
return prevPrec === prec;
|
|
849
899
|
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
900
|
+
start -= 4;
|
|
901
|
+
}
|
|
902
|
+
return false;
|
|
903
|
+
}, advanceRight2 = function(allowEqual) {
|
|
904
|
+
while (end + 4 < expandedOps.length) {
|
|
905
|
+
const nextPrec = getPrecedence(expandedOps[end + 2]);
|
|
906
|
+
if (!(nextPrec > prec || allowEqual && nextPrec === prec)) {
|
|
907
|
+
return nextPrec === prec;
|
|
908
|
+
}
|
|
909
|
+
end += 4;
|
|
910
|
+
}
|
|
911
|
+
return false;
|
|
912
|
+
};
|
|
913
|
+
var advanceLeft = advanceLeft2, advanceRight = advanceRight2;
|
|
914
|
+
let start = i - 2, end = i + 2;
|
|
915
|
+
const prec = getPrecedence(op);
|
|
916
|
+
let error;
|
|
917
|
+
switch (op.assoc) {
|
|
918
|
+
case "left":
|
|
919
|
+
case void 0: {
|
|
920
|
+
advanceLeft2(true);
|
|
921
|
+
advanceRight2(false);
|
|
922
|
+
break;
|
|
923
|
+
}
|
|
924
|
+
case "right": {
|
|
925
|
+
advanceLeft2(false);
|
|
926
|
+
advanceRight2(true);
|
|
927
|
+
break;
|
|
928
|
+
}
|
|
929
|
+
case "non": {
|
|
930
|
+
if (advanceLeft2(false) || advanceRight2(false)) {
|
|
931
|
+
error = {
|
|
932
|
+
type: "Error",
|
|
933
|
+
message: `non-associative operator ${op.token} used at same precedence level without parenthesization`
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
;
|
|
937
|
+
break;
|
|
938
|
+
}
|
|
939
|
+
case "arguments": {
|
|
940
|
+
if (advanceLeft2(false)) {
|
|
941
|
+
error = {
|
|
942
|
+
type: "Error",
|
|
943
|
+
message: `arguments operator ${op.token} used at same precedence level as ${expandedOps[start - 2].token} to the left`
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
advanceRight2(true);
|
|
947
|
+
break;
|
|
948
|
+
}
|
|
949
|
+
default: {
|
|
950
|
+
throw new Error(`Unsupported associativity: ${op.assoc}`);
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
let a = start === i - 2 ? expandedOps[start] : expandedOps.slice(start, i - 1);
|
|
954
|
+
let wsOp = expandedOps[i - 1];
|
|
955
|
+
let wsB = expandedOps[i + 1];
|
|
956
|
+
let b = end === i + 2 ? expandedOps[i + 2] : expandedOps.slice(i + 2, end + 1);
|
|
957
|
+
if (op.assoc === "arguments") {
|
|
958
|
+
let i2 = 2;
|
|
959
|
+
while (i2 < b.length) {
|
|
960
|
+
if (prec === getPrecedence(b[i2])) {
|
|
961
|
+
if (!(b[i2].token === op.token)) {
|
|
962
|
+
error ??= {
|
|
963
|
+
type: "Error",
|
|
964
|
+
message: `arguments operator ${op.token} used at same precedence level as ${b[i2].token} to the right`
|
|
965
|
+
};
|
|
966
|
+
}
|
|
967
|
+
b[i2] = ",";
|
|
968
|
+
}
|
|
969
|
+
i2 += 4;
|
|
867
970
|
}
|
|
868
971
|
} else {
|
|
869
|
-
|
|
870
|
-
type: "Error",
|
|
871
|
-
$loc: pipe.token.$loc,
|
|
872
|
-
message: "Can't use |>= in the middle of a pipeline"
|
|
873
|
-
});
|
|
972
|
+
b = recurse(b);
|
|
874
973
|
}
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
type: "ParenthesizedExpression",
|
|
883
|
-
children: ["(", {
|
|
884
|
-
type: "AssignmentExpression",
|
|
885
|
-
children: [usingRef, " = ", arg]
|
|
886
|
-
}, ")"]
|
|
887
|
-
};
|
|
888
|
-
returning = usingRef;
|
|
889
|
-
}
|
|
890
|
-
;
|
|
891
|
-
[result, returning] = constructPipeStep(
|
|
892
|
-
{
|
|
893
|
-
leadingComment: skipIfOnlyWS(leadingComment),
|
|
894
|
-
trailingComment: skipIfOnlyWS(trailingComment),
|
|
895
|
-
expr
|
|
896
|
-
},
|
|
897
|
-
arg,
|
|
898
|
-
returning
|
|
899
|
-
);
|
|
900
|
-
if (result.type === "ReturnStatement") {
|
|
901
|
-
if (i < l - 1) {
|
|
902
|
-
result.children.push({
|
|
903
|
-
type: "Error",
|
|
904
|
-
message: "Can't continue a pipeline after returning"
|
|
905
|
-
});
|
|
974
|
+
if (op.token === "instanceof" && b.type === "Literal" && b.children?.[0]?.type === "StringLiteral") {
|
|
975
|
+
a = ["typeof ", makeLeftHandSideExpression(a)];
|
|
976
|
+
if (op.negated) {
|
|
977
|
+
op = { ...op, token: "!==", negated: false };
|
|
978
|
+
} else {
|
|
979
|
+
op = { ...op, token: "===" };
|
|
980
|
+
}
|
|
906
981
|
}
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
children.push(";");
|
|
982
|
+
if (op.asConst) {
|
|
983
|
+
a = makeAsConst(a);
|
|
984
|
+
b = makeAsConst(b);
|
|
911
985
|
}
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
986
|
+
let children;
|
|
987
|
+
if (op.call) {
|
|
988
|
+
wsOp = insertTrimmingSpace(wsOp, "");
|
|
989
|
+
if (op.reversed) {
|
|
990
|
+
wsB = insertTrimmingSpace(wsB, "");
|
|
991
|
+
children = [wsOp, op.call, "(", wsB, b, ", ", a, ")", op.suffix];
|
|
992
|
+
} else {
|
|
993
|
+
children = [wsOp, op.call, "(", a, ",", wsB, b, ")", op.suffix];
|
|
994
|
+
}
|
|
995
|
+
} else if (op.method) {
|
|
996
|
+
wsOp = insertTrimmingSpace(wsOp, "");
|
|
997
|
+
wsB = insertTrimmingSpace(wsB, "");
|
|
998
|
+
if (op.reversed) {
|
|
999
|
+
if (end !== i + 2)
|
|
1000
|
+
b = makeLeftHandSideExpression(b);
|
|
1001
|
+
b = dotNumericLiteral(b);
|
|
1002
|
+
children = [wsB, b, wsOp, ".", op.method, "(", a, ")"];
|
|
1003
|
+
} else {
|
|
1004
|
+
if (start !== i - 2 || a.type === "NumericLiteral") {
|
|
1005
|
+
a = makeLeftHandSideExpression(a);
|
|
1006
|
+
}
|
|
1007
|
+
a = dotNumericLiteral(a);
|
|
1008
|
+
children = [a, wsOp, ".", op.method, "(", wsB, b, ")"];
|
|
1009
|
+
}
|
|
1010
|
+
} else if (op.token) {
|
|
1011
|
+
children = [a, wsOp, op, wsB, b];
|
|
1012
|
+
if (op.negated)
|
|
1013
|
+
children = ["(", ...children, ")"];
|
|
1014
|
+
} else {
|
|
1015
|
+
throw new Error("Unknown operator: " + JSON.stringify(op));
|
|
1016
|
+
}
|
|
1017
|
+
if (op.negated)
|
|
1018
|
+
children.unshift("!");
|
|
1019
|
+
if (error != null) {
|
|
1020
|
+
children.push(error);
|
|
1021
|
+
}
|
|
1022
|
+
expandedOps.splice(start, end - start + 1, {
|
|
1023
|
+
children
|
|
1024
|
+
});
|
|
1025
|
+
i = start + 2;
|
|
917
1026
|
} else {
|
|
918
|
-
|
|
1027
|
+
i += 4;
|
|
919
1028
|
}
|
|
920
1029
|
}
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
names: []
|
|
926
|
-
};
|
|
927
|
-
}
|
|
928
|
-
children.push(arg);
|
|
929
|
-
if (!children.some(($) => $?.type === "ReturnStatement") && children.some(($1) => $1 === ",")) {
|
|
930
|
-
const { parent } = s;
|
|
931
|
-
const parenthesizedExpression = makeLeftHandSideExpression({ ...s });
|
|
932
|
-
Object.assign(s, parenthesizedExpression, {
|
|
933
|
-
parent,
|
|
934
|
-
hoistDec: void 0
|
|
935
|
-
});
|
|
936
|
-
}
|
|
937
|
-
return addParentPointers(s, s.parent);
|
|
938
|
-
});
|
|
1030
|
+
return expandedOps;
|
|
1031
|
+
}
|
|
1032
|
+
;
|
|
1033
|
+
return recurse;
|
|
939
1034
|
}
|
|
940
|
-
|
|
941
|
-
"
|
|
942
|
-
"
|
|
943
|
-
|
|
944
|
-
init_util();
|
|
1035
|
+
function dotNumericLiteral(literal) {
|
|
1036
|
+
if (literal?.type === "Literal" && /^[+-]?(?:0|[1-9](?:_[0-9]|[0-9])*)$/.test(literal.raw)) {
|
|
1037
|
+
literal.children.push(".");
|
|
1038
|
+
literal.raw += ".";
|
|
945
1039
|
}
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
const counterRef = makeRef("i");
|
|
952
|
-
let stepRef;
|
|
953
|
-
if (stepExp) {
|
|
954
|
-
stepExp = insertTrimmingSpace(stepExp, "");
|
|
955
|
-
stepRef = maybeRef(stepExp, "step");
|
|
1040
|
+
return literal;
|
|
1041
|
+
}
|
|
1042
|
+
function makeAsConst(node) {
|
|
1043
|
+
if (Array.isArray(node) && node.length === 1) {
|
|
1044
|
+
node = node[0];
|
|
956
1045
|
}
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
const startRefDec = startRef !== start ? [startRef, " = ", start, ", "] : [];
|
|
960
|
-
const endRefDec = endRef !== end ? [endRef, " = ", end, ", "] : [];
|
|
961
|
-
let ascDec = [], ascRef, asc;
|
|
962
|
-
if (stepRef) {
|
|
963
|
-
if (stepRef !== stepExp) {
|
|
964
|
-
ascDec = [", ", stepRef, " = ", stepExp];
|
|
965
|
-
}
|
|
966
|
-
} else if (start.type === "Literal" && end.type === "Literal") {
|
|
967
|
-
asc = literalValue(start) <= literalValue(end);
|
|
1046
|
+
if (node.type === "Literal" && node.raw !== "null" || node.type === "ArrayExpression" || node.type === "ObjectExpression") {
|
|
1047
|
+
return { ...node, children: [...node.children, asConst] };
|
|
968
1048
|
} else {
|
|
969
|
-
|
|
970
|
-
ascDec = [", ", ascRef, " = ", startRef, " <= ", endRef];
|
|
1049
|
+
return node;
|
|
971
1050
|
}
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
varAssign = [...insertTrimmingSpace(varName, ""), " = "];
|
|
977
|
-
varLet = [",", ...varName, " = ", counterRef];
|
|
978
|
-
} else {
|
|
979
|
-
blockPrefix = [
|
|
980
|
-
["", forDeclaration, " = ", counterRef, ";"]
|
|
981
|
-
];
|
|
982
|
-
}
|
|
983
|
-
} else if (forDeclaration) {
|
|
984
|
-
varAssign = varLetAssign = [forDeclaration, " = "];
|
|
1051
|
+
}
|
|
1052
|
+
function isExistence(exp) {
|
|
1053
|
+
if (exp.type === "ParenthesizedExpression" && exp.implicit) {
|
|
1054
|
+
exp = exp.expression;
|
|
985
1055
|
}
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
const counterPart = inclusive ? [counterRef, " <= ", endRef, " : ", counterRef, " >= ", endRef] : [counterRef, " < ", endRef, " : ", counterRef, " > ", endRef];
|
|
992
|
-
const condition = stepRef ? [stepRef, " !== 0 && (", stepRef, " > 0 ? ", ...counterPart, ")"] : ascRef ? [ascRef, " ? ", ...counterPart] : asc ? counterPart.slice(0, 3) : counterPart.slice(4);
|
|
993
|
-
const increment = stepRef ? [...varAssign, counterRef, " += ", stepRef] : ascRef ? [...varAssign, ascRef, " ? ++", counterRef, " : --", counterRef] : [...varAssign, asc ? "++" : "--", counterRef];
|
|
994
|
-
return {
|
|
995
|
-
declaration,
|
|
996
|
-
children: [open, declaration, "; ", ...condition, "; ", ...increment, close],
|
|
997
|
-
blockPrefix
|
|
998
|
-
};
|
|
1056
|
+
if (exp.type === "Existence") {
|
|
1057
|
+
return exp;
|
|
1058
|
+
}
|
|
1059
|
+
;
|
|
1060
|
+
return;
|
|
999
1061
|
}
|
|
1000
|
-
function
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1062
|
+
function isRelationalOp(op) {
|
|
1063
|
+
return op.relational || getPrecedence(op) === precedenceRelational;
|
|
1064
|
+
}
|
|
1065
|
+
function expandChainedComparisons([first, binops]) {
|
|
1066
|
+
const results = [];
|
|
1067
|
+
let i = 0;
|
|
1068
|
+
const l = binops.length;
|
|
1069
|
+
let start = 0;
|
|
1070
|
+
let chains = [];
|
|
1071
|
+
let op;
|
|
1072
|
+
while (i < l) {
|
|
1073
|
+
[, op] = binops[i];
|
|
1074
|
+
if (isRelationalOp(op)) {
|
|
1075
|
+
chains.push(i);
|
|
1076
|
+
} else if (getPrecedence(op) < precedenceRelational) {
|
|
1077
|
+
processChains(op);
|
|
1078
|
+
first = void 0;
|
|
1079
|
+
}
|
|
1080
|
+
i++;
|
|
1006
1081
|
}
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
type: "Declaration",
|
|
1034
|
-
children: ["let ", ...expRefDec, counterRef, " = 0, ", lenRef, " = ", insertTrimmingSpace(expRef2, ""), ".length"],
|
|
1035
|
-
names: []
|
|
1036
|
-
};
|
|
1037
|
-
const condition = [counterRef, " < ", lenRef, "; "];
|
|
1038
|
-
const children = [open, declaration, "; ", condition, counterRef, increment, close];
|
|
1039
|
-
return { declaration, children, blockPrefix };
|
|
1082
|
+
if (op != null) {
|
|
1083
|
+
processChains(op);
|
|
1084
|
+
}
|
|
1085
|
+
return results;
|
|
1086
|
+
function processChains(op2) {
|
|
1087
|
+
if (first && isRelationalOp(op2)) {
|
|
1088
|
+
first = expandExistence(first);
|
|
1089
|
+
}
|
|
1090
|
+
if (chains.length > 1) {
|
|
1091
|
+
chains.forEach((index, k) => {
|
|
1092
|
+
if (k > 0) {
|
|
1093
|
+
results.push(" ", "&&", " ");
|
|
1094
|
+
}
|
|
1095
|
+
const binop = binops[index];
|
|
1096
|
+
let [, , , exp] = binop;
|
|
1097
|
+
exp = binop[3] = expandExistence(exp);
|
|
1098
|
+
let endIndex;
|
|
1099
|
+
if (k < chains.length - 1) {
|
|
1100
|
+
endIndex = chains[k + 1];
|
|
1101
|
+
} else {
|
|
1102
|
+
endIndex = i + 1;
|
|
1103
|
+
}
|
|
1104
|
+
results.push(first, ...binops.slice(start, endIndex).flat());
|
|
1105
|
+
first = [exp].concat(binops.slice(index + 1, endIndex));
|
|
1106
|
+
return start = endIndex;
|
|
1107
|
+
});
|
|
1040
1108
|
} else {
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1109
|
+
if (first) {
|
|
1110
|
+
results.push(first);
|
|
1111
|
+
}
|
|
1112
|
+
results.push(...binops.slice(start, i + 1).flat());
|
|
1113
|
+
start = i + 1;
|
|
1045
1114
|
}
|
|
1115
|
+
chains.length = 0;
|
|
1046
1116
|
}
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
};
|
|
1117
|
+
function expandExistence(exp) {
|
|
1118
|
+
const existence = isExistence(exp);
|
|
1119
|
+
if (existence) {
|
|
1120
|
+
results.push(existence, " ", "&&", " ");
|
|
1121
|
+
return existence.expression;
|
|
1122
|
+
}
|
|
1123
|
+
return exp;
|
|
1055
1124
|
}
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1125
|
+
;
|
|
1126
|
+
}
|
|
1127
|
+
var precedenceOrder, precedenceMap, precedenceStep, precedenceRelational, precedenceCustomDefault, asConst;
|
|
1128
|
+
var init_op = __esm({
|
|
1129
|
+
"source/parser/op.civet"() {
|
|
1130
|
+
"use strict";
|
|
1131
|
+
init_util();
|
|
1132
|
+
precedenceOrder = [
|
|
1133
|
+
["||", "??"],
|
|
1134
|
+
["^^"],
|
|
1135
|
+
["&&"],
|
|
1136
|
+
["|"],
|
|
1137
|
+
["^"],
|
|
1138
|
+
["&"],
|
|
1139
|
+
// NOTE: Equality and inequality merged because of relational chaining
|
|
1140
|
+
[
|
|
1141
|
+
"==",
|
|
1142
|
+
"!=",
|
|
1143
|
+
"===",
|
|
1144
|
+
"!==",
|
|
1145
|
+
"<",
|
|
1146
|
+
"<=",
|
|
1147
|
+
">",
|
|
1148
|
+
">=",
|
|
1149
|
+
"in",
|
|
1150
|
+
"instanceof"
|
|
1151
|
+
],
|
|
1152
|
+
// NOTE: Extra in-between level for default custom operators
|
|
1153
|
+
["custom"],
|
|
1154
|
+
["<<", ">>", ">>>"],
|
|
1155
|
+
["+", "-"],
|
|
1156
|
+
["*", "/", "%"],
|
|
1157
|
+
["**"]
|
|
1158
|
+
];
|
|
1159
|
+
precedenceMap = /* @__PURE__ */ new Map();
|
|
1160
|
+
for (let i1 = 0, len = precedenceOrder.length; i1 < len; i1++) {
|
|
1161
|
+
const prec = i1;
|
|
1162
|
+
const ops = precedenceOrder[i1];
|
|
1163
|
+
for (let i2 = 0, len1 = ops.length; i2 < len1; i2++) {
|
|
1164
|
+
const op = ops[i2];
|
|
1165
|
+
precedenceMap.set(op, prec);
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
precedenceStep = 1 / 64;
|
|
1169
|
+
precedenceRelational = precedenceMap.get("==");
|
|
1170
|
+
precedenceCustomDefault = precedenceMap.get("custom");
|
|
1171
|
+
asConst = {
|
|
1172
|
+
ts: true,
|
|
1173
|
+
children: [" as const"]
|
|
1062
1174
|
};
|
|
1063
1175
|
}
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1176
|
+
});
|
|
1177
|
+
|
|
1178
|
+
// source/parser/pattern-matching.civet
|
|
1179
|
+
function processPatternMatching(statements, ReservedWord) {
|
|
1180
|
+
gatherRecursiveAll(statements, ($) => $.type === "SwitchStatement").forEach((s) => {
|
|
1181
|
+
const { caseBlock } = s;
|
|
1182
|
+
const { clauses } = caseBlock;
|
|
1183
|
+
for (const c of clauses) {
|
|
1184
|
+
if (c.type === "WhenClause" && c.break) {
|
|
1185
|
+
const last = c.block?.expressions?.at(-1)?.[1];
|
|
1186
|
+
if (isExit(last)) {
|
|
1187
|
+
c.children.splice(c.children.indexOf(c.break), 1);
|
|
1188
|
+
c.break = void 0;
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
let errors = false;
|
|
1193
|
+
let isPattern = false;
|
|
1194
|
+
if (clauses.some(($1) => $1.type === "PatternClause")) {
|
|
1195
|
+
isPattern = true;
|
|
1196
|
+
clauses.forEach((c) => {
|
|
1197
|
+
if (!(c.type === "PatternClause" || c.type === "DefaultClause")) {
|
|
1198
|
+
errors = true;
|
|
1199
|
+
return c.children.push({
|
|
1200
|
+
type: "Error",
|
|
1201
|
+
message: "Can't mix pattern matching and non-pattern matching clauses"
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
;
|
|
1205
|
+
return;
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
if (errors || !isPattern) {
|
|
1209
|
+
return;
|
|
1210
|
+
}
|
|
1211
|
+
let { condition } = s;
|
|
1212
|
+
if (condition.type === "ParenthesizedExpression") {
|
|
1213
|
+
condition = condition.expression;
|
|
1214
|
+
}
|
|
1215
|
+
let hoistDec, refAssignment = [], ref = maybeRef(condition, "m");
|
|
1216
|
+
if (ref !== condition) {
|
|
1070
1217
|
hoistDec = {
|
|
1071
1218
|
type: "Declaration",
|
|
1072
|
-
children: ["let ",
|
|
1219
|
+
children: ["let ", ref],
|
|
1073
1220
|
names: []
|
|
1074
1221
|
};
|
|
1075
|
-
|
|
1076
|
-
type: "
|
|
1077
|
-
children: [
|
|
1078
|
-
|
|
1079
|
-
}, ";"]);
|
|
1080
|
-
break;
|
|
1222
|
+
refAssignment = [{
|
|
1223
|
+
type: "AssignmentExpression",
|
|
1224
|
+
children: [ref, " = ", condition]
|
|
1225
|
+
}, ","];
|
|
1081
1226
|
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
names: []
|
|
1089
|
-
};
|
|
1090
|
-
exp = {
|
|
1091
|
-
type: "AssignmentExpression",
|
|
1092
|
-
children: [" ", expRef2, " =", exp]
|
|
1093
|
-
};
|
|
1227
|
+
let prev = [], root = prev;
|
|
1228
|
+
const l = clauses.length;
|
|
1229
|
+
clauses.forEach((c, i) => {
|
|
1230
|
+
if (c.type === "DefaultClause") {
|
|
1231
|
+
prev.push(c.block);
|
|
1232
|
+
return;
|
|
1094
1233
|
}
|
|
1095
|
-
let {
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
};
|
|
1234
|
+
let { patterns, block } = c;
|
|
1235
|
+
let pattern = patterns[0];
|
|
1236
|
+
const indent = block.expressions?.[0]?.[0] || "";
|
|
1237
|
+
const alternativeConditions = patterns.map((pattern2, i2) => {
|
|
1238
|
+
const conditions = [];
|
|
1239
|
+
getPatternConditions(pattern2, ref, conditions);
|
|
1240
|
+
return conditions;
|
|
1241
|
+
});
|
|
1242
|
+
const conditionExpression = alternativeConditions.map((conditions, i2) => {
|
|
1243
|
+
const conditionArray = conditions.map((c2, i3) => {
|
|
1244
|
+
if (i3 === 0)
|
|
1245
|
+
return c2;
|
|
1246
|
+
return [" && ", ...c2];
|
|
1247
|
+
});
|
|
1248
|
+
if (i2 === 0)
|
|
1249
|
+
return conditionArray;
|
|
1250
|
+
return [" || ", ...conditionArray];
|
|
1251
|
+
});
|
|
1252
|
+
const condition2 = {
|
|
1253
|
+
type: "ParenthesizedExpression",
|
|
1254
|
+
children: ["(", ...refAssignment, conditionExpression, ")"],
|
|
1255
|
+
expression: conditionExpression
|
|
1256
|
+
};
|
|
1257
|
+
const prefix = [];
|
|
1258
|
+
switch (pattern.type) {
|
|
1259
|
+
case "ArrayBindingPattern":
|
|
1260
|
+
if (pattern.length === 0)
|
|
1261
|
+
break;
|
|
1262
|
+
case "ObjectBindingPattern": {
|
|
1263
|
+
if (pattern.properties?.length === 0)
|
|
1264
|
+
break;
|
|
1265
|
+
let [splices, thisAssignments] = gatherBindingCode(pattern);
|
|
1266
|
+
const patternBindings = nonMatcherBindings(pattern);
|
|
1267
|
+
splices = splices.map((s2) => [", ", nonMatcherBindings(s2)]);
|
|
1268
|
+
thisAssignments = thisAssignments.map((a) => [indent, a, ";"]);
|
|
1269
|
+
const duplicateDeclarations = aggregateDuplicateBindings([patternBindings, splices], ReservedWord);
|
|
1270
|
+
prefix.push([indent, "const ", patternBindings, " = ", ref, splices, ";"]);
|
|
1271
|
+
prefix.push(...thisAssignments);
|
|
1272
|
+
prefix.push(...duplicateDeclarations.map((d) => [indent, d, ";"]));
|
|
1273
|
+
break;
|
|
1274
|
+
}
|
|
1109
1275
|
}
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1276
|
+
block.expressions.unshift(...prefix);
|
|
1277
|
+
const next = [];
|
|
1278
|
+
braceBlock(block);
|
|
1279
|
+
if (i < l - 1)
|
|
1280
|
+
next.push("\n", "else ");
|
|
1281
|
+
prev.push(["", {
|
|
1282
|
+
type: "IfStatement",
|
|
1283
|
+
children: ["if", condition2, block, next],
|
|
1284
|
+
then: block,
|
|
1285
|
+
else: next,
|
|
1286
|
+
hoistDec
|
|
1287
|
+
}]);
|
|
1288
|
+
hoistDec = void 0;
|
|
1289
|
+
refAssignment = [];
|
|
1290
|
+
return prev = next;
|
|
1291
|
+
});
|
|
1292
|
+
s.type = "PatternMatchingStatement";
|
|
1293
|
+
s.children = [root];
|
|
1294
|
+
return addParentPointers(s, s.parent);
|
|
1295
|
+
});
|
|
1296
|
+
}
|
|
1297
|
+
function getPatternConditions(pattern, ref, conditions) {
|
|
1298
|
+
if (pattern.rest)
|
|
1299
|
+
return;
|
|
1300
|
+
switch (pattern.type) {
|
|
1301
|
+
case "ArrayBindingPattern": {
|
|
1302
|
+
const { elements, length } = pattern, hasRest = elements.some((e) => e.rest), comparator = hasRest ? " >= " : " === ", l = [comparator, (length - hasRest).toString()];
|
|
1303
|
+
conditions.push(
|
|
1304
|
+
["Array.isArray(", ref, ")"],
|
|
1305
|
+
[ref, ".length", l]
|
|
1306
|
+
);
|
|
1307
|
+
elements.forEach(({ children: [, e] }, i) => {
|
|
1308
|
+
const subRef = [ref, "[", i.toString(), "]"];
|
|
1309
|
+
return getPatternConditions(e, subRef, conditions);
|
|
1310
|
+
});
|
|
1311
|
+
const { blockPrefix } = pattern;
|
|
1312
|
+
if (blockPrefix) {
|
|
1313
|
+
const postElements = blockPrefix.children[1], { length: postLength } = postElements;
|
|
1314
|
+
postElements.forEach(({ children: [, e] }, i) => {
|
|
1315
|
+
const subRef = [ref, "[", ref, ".length - ", (postLength + i).toString(), "]"];
|
|
1316
|
+
return getPatternConditions(e, subRef, conditions);
|
|
1317
|
+
});
|
|
1113
1318
|
}
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1319
|
+
break;
|
|
1320
|
+
}
|
|
1321
|
+
case "ObjectBindingPattern": {
|
|
1322
|
+
conditions.push(
|
|
1323
|
+
["typeof ", ref, " === 'object'"],
|
|
1324
|
+
[ref, " != null"]
|
|
1325
|
+
);
|
|
1326
|
+
pattern.properties.forEach((p) => {
|
|
1327
|
+
switch (p.type) {
|
|
1328
|
+
case "PinProperty":
|
|
1329
|
+
case "BindingProperty": {
|
|
1330
|
+
const { name, value } = p;
|
|
1331
|
+
let subRef;
|
|
1332
|
+
switch (name.type) {
|
|
1333
|
+
case "ComputedPropertyName":
|
|
1334
|
+
conditions.push([name.expression, " in ", ref]);
|
|
1335
|
+
subRef = [ref, name];
|
|
1336
|
+
break;
|
|
1337
|
+
case "Literal":
|
|
1338
|
+
case "StringLiteral":
|
|
1339
|
+
case "NumericLiteral":
|
|
1340
|
+
conditions.push([name, " in ", ref]);
|
|
1341
|
+
subRef = [ref, "[", name, "]"];
|
|
1342
|
+
break;
|
|
1343
|
+
default:
|
|
1344
|
+
conditions.push(["'", name, "' in ", ref]);
|
|
1345
|
+
subRef = [ref, ".", name];
|
|
1346
|
+
}
|
|
1347
|
+
if (value) {
|
|
1348
|
+
getPatternConditions(value, subRef, conditions);
|
|
1349
|
+
}
|
|
1350
|
+
break;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
});
|
|
1354
|
+
break;
|
|
1355
|
+
}
|
|
1356
|
+
case "ConditionFragment": {
|
|
1357
|
+
let { children } = pattern;
|
|
1358
|
+
if (children.length) {
|
|
1359
|
+
let [first, ...rest] = children;
|
|
1360
|
+
let [ws, ...op] = first;
|
|
1361
|
+
ws = [" "].concat(ws);
|
|
1362
|
+
first = [ws, ...op];
|
|
1363
|
+
children = [first, ...rest];
|
|
1120
1364
|
}
|
|
1365
|
+
conditions.push(
|
|
1366
|
+
processBinaryOpExpression([ref, children])
|
|
1367
|
+
);
|
|
1368
|
+
break;
|
|
1369
|
+
}
|
|
1370
|
+
case "RegularExpressionLiteral": {
|
|
1371
|
+
conditions.push(
|
|
1372
|
+
["typeof ", ref, " === 'string'"],
|
|
1373
|
+
[pattern, ".test(", ref, ")"]
|
|
1374
|
+
);
|
|
1121
1375
|
break;
|
|
1122
1376
|
}
|
|
1377
|
+
case "PinPattern":
|
|
1378
|
+
conditions.push([
|
|
1379
|
+
ref,
|
|
1380
|
+
" === ",
|
|
1381
|
+
pattern.expression
|
|
1382
|
+
]);
|
|
1383
|
+
break;
|
|
1384
|
+
case "Literal":
|
|
1385
|
+
conditions.push([
|
|
1386
|
+
ref,
|
|
1387
|
+
" === ",
|
|
1388
|
+
pattern
|
|
1389
|
+
]);
|
|
1390
|
+
break;
|
|
1123
1391
|
default:
|
|
1124
|
-
|
|
1125
|
-
throw new Error(`for item, index must use 'of' or 'in' instead of '${inOf.token}'`);
|
|
1126
|
-
})();
|
|
1392
|
+
break;
|
|
1127
1393
|
}
|
|
1128
|
-
return {
|
|
1129
|
-
declaration,
|
|
1130
|
-
children: [awaits, eachOwnError, open, declaration, ws, inOf, exp, step, close],
|
|
1131
|
-
// omit declaration2, replace each with eachOwnError
|
|
1132
|
-
blockPrefix,
|
|
1133
|
-
hoistDec
|
|
1134
|
-
};
|
|
1135
1394
|
}
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
"
|
|
1139
|
-
|
|
1140
|
-
}
|
|
1141
|
-
});
|
|
1142
|
-
|
|
1143
|
-
// source/parser/binding.civet
|
|
1144
|
-
function adjustAtBindings(statements, asThis = false) {
|
|
1145
|
-
gatherRecursiveAll(statements, (n) => n.type === "AtBindingProperty").forEach((binding) => {
|
|
1146
|
-
const { ref } = binding;
|
|
1147
|
-
if (asThis) {
|
|
1148
|
-
const atBinding = binding.binding;
|
|
1149
|
-
atBinding.children.pop();
|
|
1150
|
-
atBinding.type = void 0;
|
|
1151
|
-
binding.children.unshift(ref.id, ": this.", ref.base);
|
|
1152
|
-
binding.type = "Property";
|
|
1153
|
-
binding.ref = void 0;
|
|
1154
|
-
return;
|
|
1395
|
+
function elideMatchersFromArrayBindings(elements) {
|
|
1396
|
+
return elements.map((el) => {
|
|
1397
|
+
if (el.type === "BindingRestElement") {
|
|
1398
|
+
return ["", el, void 0];
|
|
1155
1399
|
}
|
|
1156
|
-
|
|
1157
|
-
|
|
1400
|
+
const { children: [ws, e, delim] } = el;
|
|
1401
|
+
switch (e.type) {
|
|
1402
|
+
case "Literal":
|
|
1403
|
+
case "RegularExpressionLiteral":
|
|
1404
|
+
case "StringLiteral":
|
|
1405
|
+
case "PinPattern":
|
|
1406
|
+
return delim;
|
|
1407
|
+
default:
|
|
1408
|
+
return [ws, nonMatcherBindings(e), delim];
|
|
1158
1409
|
}
|
|
1159
|
-
;
|
|
1160
|
-
return;
|
|
1161
1410
|
});
|
|
1162
1411
|
}
|
|
1163
|
-
function
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1412
|
+
function elideMatchersFromPropertyBindings(properties) {
|
|
1413
|
+
return properties.map((p) => {
|
|
1414
|
+
switch (p.type) {
|
|
1415
|
+
case "BindingProperty": {
|
|
1416
|
+
const { children, name, value } = p;
|
|
1417
|
+
const [ws] = children;
|
|
1418
|
+
switch (value && value.type) {
|
|
1419
|
+
case "ArrayBindingPattern":
|
|
1420
|
+
case "ObjectBindingPattern":
|
|
1421
|
+
return {
|
|
1422
|
+
...p,
|
|
1423
|
+
children: [ws, name, ": ", nonMatcherBindings(value), p.delim]
|
|
1424
|
+
};
|
|
1425
|
+
case "Identifier":
|
|
1426
|
+
return p;
|
|
1427
|
+
case "Literal":
|
|
1428
|
+
case "RegularExpressionLiteral":
|
|
1429
|
+
case "StringLiteral":
|
|
1430
|
+
default:
|
|
1431
|
+
return {
|
|
1432
|
+
...p,
|
|
1433
|
+
children: [ws, name, p.delim]
|
|
1434
|
+
};
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
case "PinProperty":
|
|
1438
|
+
case "BindingRestProperty":
|
|
1439
|
+
default:
|
|
1440
|
+
return p;
|
|
1441
|
+
}
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1444
|
+
function nonMatcherBindings(pattern) {
|
|
1445
|
+
switch (pattern.type) {
|
|
1446
|
+
case "ArrayBindingPattern": {
|
|
1447
|
+
const elements = elideMatchersFromArrayBindings(pattern.elements);
|
|
1448
|
+
const children = ["[", elements, "]"];
|
|
1449
|
+
return {
|
|
1450
|
+
...pattern,
|
|
1451
|
+
children,
|
|
1452
|
+
elements
|
|
1195
1453
|
};
|
|
1196
1454
|
}
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
...
|
|
1201
|
-
children:
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1455
|
+
case "PostRestBindingElements": {
|
|
1456
|
+
const els = elideMatchersFromArrayBindings(pattern.children[1]);
|
|
1457
|
+
return {
|
|
1458
|
+
...pattern,
|
|
1459
|
+
children: [
|
|
1460
|
+
pattern.children[0],
|
|
1461
|
+
els,
|
|
1462
|
+
...pattern.children.slice(2)
|
|
1463
|
+
]
|
|
1464
|
+
};
|
|
1465
|
+
}
|
|
1466
|
+
case "ObjectBindingPattern":
|
|
1467
|
+
return ["{", elideMatchersFromPropertyBindings(pattern.properties), "}"];
|
|
1468
|
+
default:
|
|
1469
|
+
return pattern;
|
|
1207
1470
|
}
|
|
1208
|
-
const err = {
|
|
1209
|
-
type: "Error",
|
|
1210
|
-
children: ["Multiple rest elements in array pattern"]
|
|
1211
|
-
};
|
|
1212
|
-
return {
|
|
1213
|
-
names,
|
|
1214
|
-
children: [...elements, err],
|
|
1215
|
-
blockPrefix,
|
|
1216
|
-
length
|
|
1217
|
-
};
|
|
1218
1471
|
}
|
|
1219
|
-
function
|
|
1220
|
-
const
|
|
1221
|
-
const
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
const
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
type: "AssignmentExpression",
|
|
1234
|
-
children: [`this.${id} = `, id],
|
|
1235
|
-
js: true
|
|
1236
|
-
})
|
|
1237
|
-
}));
|
|
1472
|
+
function aggregateDuplicateBindings(bindings, ReservedWord) {
|
|
1473
|
+
const props = gatherRecursiveAll(bindings, ($2) => $2.type === "BindingProperty");
|
|
1474
|
+
const arrayBindings = gatherRecursiveAll(bindings, ($3) => $3.type === "ArrayBindingPattern");
|
|
1475
|
+
arrayBindings.forEach((a) => {
|
|
1476
|
+
const { elements } = a;
|
|
1477
|
+
return elements.forEach((element) => {
|
|
1478
|
+
if (Array.isArray(element)) {
|
|
1479
|
+
const [, e] = element;
|
|
1480
|
+
if (e.type === "Identifier") {
|
|
1481
|
+
return props.push(e);
|
|
1482
|
+
} else if (e.type === "BindingRestElement") {
|
|
1483
|
+
return props.push(e);
|
|
1484
|
+
}
|
|
1485
|
+
;
|
|
1238
1486
|
return;
|
|
1239
1487
|
}
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
return insertRestSplices(blockPrefix, p, thisAssignments2);
|
|
1488
|
+
;
|
|
1489
|
+
return;
|
|
1243
1490
|
});
|
|
1491
|
+
});
|
|
1492
|
+
const declarations = [];
|
|
1493
|
+
const propsGroupedByName = /* @__PURE__ */ new Map();
|
|
1494
|
+
for (const p of props) {
|
|
1495
|
+
const { name, value } = p;
|
|
1496
|
+
const key = value?.name || name?.name || name;
|
|
1497
|
+
if (propsGroupedByName.has(key)) {
|
|
1498
|
+
propsGroupedByName.get(key).push(p);
|
|
1499
|
+
} else {
|
|
1500
|
+
propsGroupedByName.set(key, [p]);
|
|
1501
|
+
}
|
|
1244
1502
|
}
|
|
1245
|
-
|
|
1246
|
-
|
|
1503
|
+
propsGroupedByName.forEach((shared, key) => {
|
|
1504
|
+
if (!key) {
|
|
1505
|
+
return;
|
|
1506
|
+
}
|
|
1507
|
+
if (ReservedWord({ fail() {
|
|
1508
|
+
} }, {
|
|
1509
|
+
pos: 0,
|
|
1510
|
+
input: key
|
|
1511
|
+
})) {
|
|
1512
|
+
shared.forEach((p) => {
|
|
1513
|
+
return aliasBinding(p, makeRef(`_${key}`, key));
|
|
1514
|
+
});
|
|
1515
|
+
return;
|
|
1516
|
+
}
|
|
1517
|
+
if (shared.length === 1) {
|
|
1518
|
+
return;
|
|
1519
|
+
}
|
|
1520
|
+
const refs = shared.map((p) => {
|
|
1521
|
+
const ref = makeRef(key);
|
|
1522
|
+
aliasBinding(p, ref);
|
|
1523
|
+
return ref;
|
|
1524
|
+
});
|
|
1525
|
+
return declarations.push(["const ", key, " = [", ...refs.map((r, i) => {
|
|
1526
|
+
return i === 0 ? r : [", ", r];
|
|
1527
|
+
}), "]"]);
|
|
1528
|
+
});
|
|
1529
|
+
return declarations;
|
|
1247
1530
|
}
|
|
1248
|
-
function
|
|
1249
|
-
|
|
1250
|
-
|
|
1531
|
+
function aliasBinding(p, ref) {
|
|
1532
|
+
if (p.type === "Identifier") {
|
|
1533
|
+
p.children[0] = ref;
|
|
1534
|
+
} else if (p.type === "BindingRestElement") {
|
|
1535
|
+
aliasBinding(p.binding, ref);
|
|
1536
|
+
} else if (p.value?.type === "Identifier") {
|
|
1537
|
+
aliasBinding(p.value, ref);
|
|
1538
|
+
} else {
|
|
1539
|
+
p.value = ref;
|
|
1540
|
+
const index = p.children.indexOf(p.name);
|
|
1541
|
+
p.children.splice(index + 1, 0, ": ", ref);
|
|
1542
|
+
}
|
|
1251
1543
|
}
|
|
1252
|
-
var
|
|
1253
|
-
"source/parser/
|
|
1544
|
+
var init_pattern_matching = __esm({
|
|
1545
|
+
"source/parser/pattern-matching.civet"() {
|
|
1254
1546
|
"use strict";
|
|
1255
1547
|
init_traversal();
|
|
1256
1548
|
init_util();
|
|
1549
|
+
init_block();
|
|
1550
|
+
init_binding();
|
|
1551
|
+
init_op();
|
|
1257
1552
|
}
|
|
1258
1553
|
});
|
|
1259
1554
|
|
|
@@ -1372,8 +1667,9 @@ function processReturnValue(func) {
|
|
|
1372
1667
|
return r.children.splice(-1, 1, " ", ref);
|
|
1373
1668
|
});
|
|
1374
1669
|
if (!(block.children.at(-2)?.type === "ReturnStatement")) {
|
|
1670
|
+
const indent = getIndent(block.expressions.at(-1)) || ";";
|
|
1375
1671
|
block.expressions.push([
|
|
1376
|
-
[
|
|
1672
|
+
[indent],
|
|
1377
1673
|
{
|
|
1378
1674
|
type: "ReturnStatement",
|
|
1379
1675
|
expression: ref,
|
|
@@ -1416,36 +1712,36 @@ function patternAsValue(pattern) {
|
|
|
1416
1712
|
return pattern;
|
|
1417
1713
|
}
|
|
1418
1714
|
}
|
|
1419
|
-
function
|
|
1715
|
+
function assignResults(node, collect) {
|
|
1420
1716
|
if (!node)
|
|
1421
1717
|
return;
|
|
1422
1718
|
switch (node.type) {
|
|
1423
1719
|
case "BlockStatement":
|
|
1424
1720
|
if (node.expressions.length) {
|
|
1425
|
-
|
|
1721
|
+
assignResults(node.expressions.at(-1), collect);
|
|
1426
1722
|
} else {
|
|
1427
|
-
node.expressions.push([
|
|
1723
|
+
node.expressions.push(["", collect("void 0"), ";"]);
|
|
1428
1724
|
}
|
|
1429
1725
|
return;
|
|
1430
1726
|
case "CaseBlock":
|
|
1431
1727
|
node.clauses.forEach((clause) => {
|
|
1432
|
-
return
|
|
1728
|
+
return assignResults(clause, collect);
|
|
1433
1729
|
});
|
|
1434
1730
|
return;
|
|
1435
1731
|
case "WhenClause":
|
|
1436
|
-
insertPush(node.block, ref);
|
|
1437
|
-
return;
|
|
1438
1732
|
case "DefaultClause":
|
|
1439
|
-
|
|
1733
|
+
case "PatternClause": {
|
|
1734
|
+
assignResults(node.block, collect);
|
|
1440
1735
|
return;
|
|
1736
|
+
}
|
|
1441
1737
|
}
|
|
1442
|
-
if (!Array.isArray(node))
|
|
1738
|
+
if (!Array.isArray(node)) {
|
|
1443
1739
|
return;
|
|
1740
|
+
}
|
|
1444
1741
|
let [, exp] = node;
|
|
1445
1742
|
if (!exp) {
|
|
1446
1743
|
return;
|
|
1447
1744
|
}
|
|
1448
|
-
const indent = getIndent(node);
|
|
1449
1745
|
const outer = exp;
|
|
1450
1746
|
let { type } = exp;
|
|
1451
1747
|
if (type === "LabelledStatement") {
|
|
@@ -1461,46 +1757,44 @@ function insertPush(node, ref) {
|
|
|
1461
1757
|
case "ThrowStatement":
|
|
1462
1758
|
return;
|
|
1463
1759
|
case "Declaration":
|
|
1464
|
-
exp.children.push([
|
|
1465
|
-
"
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
patternAsValue(exp.bindings.at(-1).pattern),
|
|
1469
|
-
")"
|
|
1470
|
-
]]);
|
|
1760
|
+
exp.children.push([
|
|
1761
|
+
"",
|
|
1762
|
+
[";", collect(patternAsValue(exp.bindings.at(-1).pattern))]
|
|
1763
|
+
]);
|
|
1471
1764
|
return;
|
|
1472
1765
|
case "ForStatement":
|
|
1473
1766
|
case "IterationStatement":
|
|
1474
1767
|
case "DoStatement":
|
|
1475
|
-
wrapIterationReturningResults(exp, outer,
|
|
1768
|
+
wrapIterationReturningResults(exp, outer, collect);
|
|
1476
1769
|
return;
|
|
1477
1770
|
case "BlockStatement":
|
|
1478
|
-
|
|
1771
|
+
assignResults(exp.expressions[exp.expressions.length - 1], collect);
|
|
1479
1772
|
return;
|
|
1480
1773
|
case "IfStatement":
|
|
1481
|
-
|
|
1774
|
+
assignResults(exp.then, collect);
|
|
1482
1775
|
if (exp.then.bare && !exp.then.semicolon) {
|
|
1483
1776
|
exp.then.children.push(exp.then.semicolon = ";");
|
|
1484
1777
|
}
|
|
1485
|
-
if (exp.else)
|
|
1486
|
-
|
|
1487
|
-
else
|
|
1488
|
-
exp.children.push([" else {
|
|
1778
|
+
if (exp.else) {
|
|
1779
|
+
assignResults(exp.else[2], collect);
|
|
1780
|
+
} else {
|
|
1781
|
+
exp.children.push([" else {", collect("undefined"), "}"]);
|
|
1782
|
+
}
|
|
1489
1783
|
return;
|
|
1490
1784
|
case "PatternMatchingStatement":
|
|
1491
|
-
|
|
1785
|
+
assignResults(exp.children[0][0], collect);
|
|
1492
1786
|
return;
|
|
1493
1787
|
case "SwitchStatement":
|
|
1494
|
-
|
|
1788
|
+
assignResults(exp.children[2], collect);
|
|
1495
1789
|
return;
|
|
1496
1790
|
case "TryStatement":
|
|
1497
|
-
exp.blocks.forEach((block) =>
|
|
1791
|
+
exp.blocks.forEach((block) => assignResults(block, collect));
|
|
1498
1792
|
return;
|
|
1499
1793
|
}
|
|
1500
|
-
if (node
|
|
1794
|
+
if (node.at(-1)?.type === "SemicolonDelimiter") {
|
|
1501
1795
|
return;
|
|
1502
|
-
|
|
1503
|
-
node
|
|
1796
|
+
}
|
|
1797
|
+
node[1] = collect(node[1]);
|
|
1504
1798
|
}
|
|
1505
1799
|
function insertReturn(node, outerNode = node) {
|
|
1506
1800
|
if (!node)
|
|
@@ -1613,24 +1907,31 @@ function insertSwitchReturns(exp) {
|
|
|
1613
1907
|
return insertReturn(clause);
|
|
1614
1908
|
});
|
|
1615
1909
|
}
|
|
1616
|
-
function wrapIterationReturningResults(statement, outer,
|
|
1910
|
+
function wrapIterationReturningResults(statement, outer, collect) {
|
|
1617
1911
|
if (statement.type === "DoStatement") {
|
|
1618
|
-
if (
|
|
1619
|
-
|
|
1912
|
+
if (collect) {
|
|
1913
|
+
assignResults(statement.block, collect);
|
|
1620
1914
|
} else {
|
|
1621
1915
|
insertReturn(statement.block, outer);
|
|
1622
1916
|
}
|
|
1623
1917
|
return;
|
|
1624
1918
|
}
|
|
1625
|
-
|
|
1919
|
+
assert.equal(
|
|
1920
|
+
statement.resultsRef,
|
|
1921
|
+
void 0,
|
|
1922
|
+
"wrapIterationReturningResults should not be called twice on the same statement"
|
|
1923
|
+
);
|
|
1924
|
+
const resultsRef = statement.resultsRef = makeRef("results");
|
|
1626
1925
|
const declaration = {
|
|
1627
1926
|
type: "Declaration",
|
|
1628
|
-
children: ["const ", resultsRef, "=[]
|
|
1927
|
+
children: ["const ", resultsRef, "=[]"]
|
|
1629
1928
|
};
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1929
|
+
outer.children.unshift(["", declaration, ";"]);
|
|
1930
|
+
assignResults(statement.block, (node) => {
|
|
1931
|
+
return [resultsRef, ".push(", node, ")"];
|
|
1932
|
+
});
|
|
1933
|
+
if (collect) {
|
|
1934
|
+
statement.children.push(collect(resultsRef));
|
|
1634
1935
|
} else {
|
|
1635
1936
|
statement.children.push(";return ", resultsRef, ";");
|
|
1636
1937
|
}
|
|
@@ -1713,8 +2014,11 @@ function expressionizeIteration(exp) {
|
|
|
1713
2014
|
updateParentPointers(exp);
|
|
1714
2015
|
return;
|
|
1715
2016
|
}
|
|
1716
|
-
|
|
1717
|
-
|
|
2017
|
+
exp.resultsRef ??= makeRef("results");
|
|
2018
|
+
const { resultsRef } = exp;
|
|
2019
|
+
assignResults(block, (node) => {
|
|
2020
|
+
return [resultsRef, ".push(", node, ")"];
|
|
2021
|
+
});
|
|
1718
2022
|
braceBlock(block);
|
|
1719
2023
|
children.splice(
|
|
1720
2024
|
i,
|
|
@@ -1727,6 +2031,19 @@ function expressionizeIteration(exp) {
|
|
|
1727
2031
|
);
|
|
1728
2032
|
updateParentPointers(exp);
|
|
1729
2033
|
}
|
|
2034
|
+
function skipImplicitArguments(args) {
|
|
2035
|
+
if (args.length === 1) {
|
|
2036
|
+
let arg0 = args[0];
|
|
2037
|
+
if (Array.isArray(arg0)) {
|
|
2038
|
+
arg0 = arg0[1];
|
|
2039
|
+
}
|
|
2040
|
+
if (arg0.type === "StatementExpression") {
|
|
2041
|
+
arg0 = arg0.statement;
|
|
2042
|
+
}
|
|
2043
|
+
return arg0.type === "IterationExpression" && arg0.subtype !== "DoStatement" && !arg0.async && isEmptyBareBlock(arg0.block);
|
|
2044
|
+
}
|
|
2045
|
+
return false;
|
|
2046
|
+
}
|
|
1730
2047
|
var init_function = __esm({
|
|
1731
2048
|
"source/parser/function.civet"() {
|
|
1732
2049
|
"use strict";
|
|
@@ -1737,864 +2054,757 @@ var init_function = __esm({
|
|
|
1737
2054
|
}
|
|
1738
2055
|
});
|
|
1739
2056
|
|
|
1740
|
-
// source/parser/
|
|
1741
|
-
function
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
}
|
|
1749
|
-
|
|
1750
|
-
|
|
2057
|
+
// source/parser/declaration.civet
|
|
2058
|
+
function processAssignmentDeclaration(decl, pattern, suffix, ws, assign, e) {
|
|
2059
|
+
decl = {
|
|
2060
|
+
...decl,
|
|
2061
|
+
$loc: {
|
|
2062
|
+
pos: assign.$loc.pos - 1,
|
|
2063
|
+
length: assign.$loc.length + 1
|
|
2064
|
+
}
|
|
2065
|
+
};
|
|
2066
|
+
let [splices, assignments] = gatherBindingCode(pattern);
|
|
2067
|
+
splices = splices.map((s) => [", ", s]);
|
|
2068
|
+
const thisAssignments = assignments.map((a) => ["", a, ";"]);
|
|
2069
|
+
const initializer = [ws, assign, e];
|
|
2070
|
+
const binding = makeNode({
|
|
2071
|
+
type: "Binding",
|
|
2072
|
+
pattern,
|
|
2073
|
+
initializer,
|
|
2074
|
+
splices,
|
|
2075
|
+
suffix,
|
|
2076
|
+
thisAssignments,
|
|
2077
|
+
children: [pattern, suffix, initializer]
|
|
2078
|
+
});
|
|
2079
|
+
const children = [decl, binding];
|
|
2080
|
+
return makeNode({
|
|
2081
|
+
type: "Declaration",
|
|
2082
|
+
names: pattern.names,
|
|
2083
|
+
decl,
|
|
2084
|
+
bindings: [binding],
|
|
2085
|
+
splices,
|
|
2086
|
+
thisAssignments,
|
|
2087
|
+
children
|
|
2088
|
+
});
|
|
1751
2089
|
}
|
|
1752
|
-
function
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
let advanceLeft2 = function(allowEqual) {
|
|
1760
|
-
while (start >= 4) {
|
|
1761
|
-
const prevPrec = getPrecedence(expandedOps[start - 2]);
|
|
1762
|
-
if (!(prevPrec > prec || allowEqual && prevPrec === prec)) {
|
|
1763
|
-
return prevPrec === prec;
|
|
1764
|
-
}
|
|
1765
|
-
start -= 4;
|
|
1766
|
-
}
|
|
1767
|
-
return false;
|
|
1768
|
-
}, advanceRight2 = function(allowEqual) {
|
|
1769
|
-
while (end + 4 < expandedOps.length) {
|
|
1770
|
-
const nextPrec = getPrecedence(expandedOps[end + 2]);
|
|
1771
|
-
if (!(nextPrec > prec || allowEqual && nextPrec === prec)) {
|
|
1772
|
-
return nextPrec === prec;
|
|
1773
|
-
}
|
|
1774
|
-
end += 4;
|
|
1775
|
-
}
|
|
1776
|
-
return false;
|
|
1777
|
-
};
|
|
1778
|
-
var advanceLeft = advanceLeft2, advanceRight = advanceRight2;
|
|
1779
|
-
let start = i - 2, end = i + 2;
|
|
1780
|
-
const prec = getPrecedence(op);
|
|
1781
|
-
let error;
|
|
1782
|
-
switch (op.assoc) {
|
|
1783
|
-
case "left":
|
|
1784
|
-
case void 0: {
|
|
1785
|
-
advanceLeft2(true);
|
|
1786
|
-
advanceRight2(false);
|
|
1787
|
-
break;
|
|
1788
|
-
}
|
|
1789
|
-
case "right": {
|
|
1790
|
-
advanceLeft2(false);
|
|
1791
|
-
advanceRight2(true);
|
|
1792
|
-
break;
|
|
1793
|
-
}
|
|
1794
|
-
case "non": {
|
|
1795
|
-
if (advanceLeft2(false) || advanceRight2(false)) {
|
|
1796
|
-
error = {
|
|
1797
|
-
type: "Error",
|
|
1798
|
-
message: `non-associative operator ${op.token} used at same precedence level without parenthesization`
|
|
1799
|
-
};
|
|
1800
|
-
}
|
|
1801
|
-
;
|
|
1802
|
-
break;
|
|
1803
|
-
}
|
|
1804
|
-
case "arguments": {
|
|
1805
|
-
if (advanceLeft2(false)) {
|
|
1806
|
-
error = {
|
|
1807
|
-
type: "Error",
|
|
1808
|
-
message: `arguments operator ${op.token} used at same precedence level as ${expandedOps[start - 2].token} to the left`
|
|
1809
|
-
};
|
|
1810
|
-
}
|
|
1811
|
-
advanceRight2(true);
|
|
1812
|
-
break;
|
|
1813
|
-
}
|
|
1814
|
-
default: {
|
|
1815
|
-
throw new Error(`Unsupported associativity: ${op.assoc}`);
|
|
1816
|
-
}
|
|
1817
|
-
}
|
|
1818
|
-
let a = start === i - 2 ? expandedOps[start] : expandedOps.slice(start, i - 1);
|
|
1819
|
-
let wsOp = expandedOps[i - 1];
|
|
1820
|
-
let wsB = expandedOps[i + 1];
|
|
1821
|
-
let b = end === i + 2 ? expandedOps[i + 2] : expandedOps.slice(i + 2, end + 1);
|
|
1822
|
-
if (op.assoc === "arguments") {
|
|
1823
|
-
let i2 = 2;
|
|
1824
|
-
while (i2 < b.length) {
|
|
1825
|
-
if (prec === getPrecedence(b[i2])) {
|
|
1826
|
-
if (!(b[i2].token === op.token)) {
|
|
1827
|
-
error ??= {
|
|
1828
|
-
type: "Error",
|
|
1829
|
-
message: `arguments operator ${op.token} used at same precedence level as ${b[i2].token} to the right`
|
|
1830
|
-
};
|
|
1831
|
-
}
|
|
1832
|
-
b[i2] = ",";
|
|
1833
|
-
}
|
|
1834
|
-
i2 += 4;
|
|
1835
|
-
}
|
|
1836
|
-
} else {
|
|
1837
|
-
b = recurse(b);
|
|
1838
|
-
}
|
|
1839
|
-
if (op.token === "instanceof" && b.type === "Literal" && b.children?.[0]?.type === "StringLiteral") {
|
|
1840
|
-
a = ["typeof ", makeLeftHandSideExpression(a)];
|
|
1841
|
-
if (op.negated) {
|
|
1842
|
-
op = { ...op, token: "!==", negated: false };
|
|
1843
|
-
} else {
|
|
1844
|
-
op = { ...op, token: "===" };
|
|
1845
|
-
}
|
|
1846
|
-
}
|
|
1847
|
-
if (op.asConst) {
|
|
1848
|
-
a = makeAsConst(a);
|
|
1849
|
-
b = makeAsConst(b);
|
|
1850
|
-
}
|
|
1851
|
-
let children;
|
|
1852
|
-
if (op.call) {
|
|
1853
|
-
wsOp = insertTrimmingSpace(wsOp, "");
|
|
1854
|
-
if (op.reversed) {
|
|
1855
|
-
wsB = insertTrimmingSpace(wsB, "");
|
|
1856
|
-
children = [wsOp, op.call, "(", wsB, b, ", ", a, ")", op.suffix];
|
|
1857
|
-
} else {
|
|
1858
|
-
children = [wsOp, op.call, "(", a, ",", wsB, b, ")", op.suffix];
|
|
1859
|
-
}
|
|
1860
|
-
} else if (op.method) {
|
|
1861
|
-
wsOp = insertTrimmingSpace(wsOp, "");
|
|
1862
|
-
wsB = insertTrimmingSpace(wsB, "");
|
|
1863
|
-
if (op.reversed) {
|
|
1864
|
-
if (end !== i + 2)
|
|
1865
|
-
b = makeLeftHandSideExpression(b);
|
|
1866
|
-
b = dotNumericLiteral(b);
|
|
1867
|
-
children = [wsB, b, wsOp, ".", op.method, "(", a, ")"];
|
|
1868
|
-
} else {
|
|
1869
|
-
if (start !== i - 2 || a.type === "NumericLiteral") {
|
|
1870
|
-
a = makeLeftHandSideExpression(a);
|
|
1871
|
-
}
|
|
1872
|
-
a = dotNumericLiteral(a);
|
|
1873
|
-
children = [a, wsOp, ".", op.method, "(", wsB, b, ")"];
|
|
1874
|
-
}
|
|
1875
|
-
} else if (op.token) {
|
|
1876
|
-
children = [a, wsOp, op, wsB, b];
|
|
1877
|
-
if (op.negated)
|
|
1878
|
-
children = ["(", ...children, ")"];
|
|
1879
|
-
} else {
|
|
1880
|
-
throw new Error("Unknown operator: " + JSON.stringify(op));
|
|
1881
|
-
}
|
|
1882
|
-
if (op.negated)
|
|
1883
|
-
children.unshift("!");
|
|
1884
|
-
if (error != null) {
|
|
1885
|
-
children.push(error);
|
|
1886
|
-
}
|
|
1887
|
-
expandedOps.splice(start, end - start + 1, {
|
|
1888
|
-
children
|
|
1889
|
-
});
|
|
1890
|
-
i = start + 2;
|
|
1891
|
-
} else {
|
|
1892
|
-
i += 4;
|
|
2090
|
+
function processDeclarations(statements) {
|
|
2091
|
+
gatherRecursiveAll(statements, ($) => $.type === "Declaration").forEach((statement) => {
|
|
2092
|
+
const { bindings } = statement;
|
|
2093
|
+
return bindings?.forEach((binding) => {
|
|
2094
|
+
const suffix = binding.suffix;
|
|
2095
|
+
if (suffix && suffix.optional && suffix.t) {
|
|
2096
|
+
convertOptionalType(suffix);
|
|
1893
2097
|
}
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
2098
|
+
const { initializer } = binding;
|
|
2099
|
+
if (initializer) {
|
|
2100
|
+
return prependStatementExpressionBlock(initializer, statement);
|
|
2101
|
+
}
|
|
2102
|
+
;
|
|
2103
|
+
return;
|
|
2104
|
+
});
|
|
2105
|
+
});
|
|
1899
2106
|
}
|
|
1900
|
-
function
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
2107
|
+
function prependStatementExpressionBlock(initializer, statement) {
|
|
2108
|
+
let exp = initializer[2];
|
|
2109
|
+
let ws;
|
|
2110
|
+
if (Array.isArray(exp)) {
|
|
2111
|
+
ws = exp[0];
|
|
2112
|
+
exp = exp[1];
|
|
1904
2113
|
}
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
function makeAsConst(node) {
|
|
1908
|
-
if (Array.isArray(node) && node.length === 1) {
|
|
1909
|
-
node = node[0];
|
|
2114
|
+
if (!(exp.type === "StatementExpression")) {
|
|
2115
|
+
return;
|
|
1910
2116
|
}
|
|
1911
|
-
|
|
1912
|
-
|
|
2117
|
+
const pre = [];
|
|
2118
|
+
const statementExp = exp.statement;
|
|
2119
|
+
const blockStatement = ["", statementExp];
|
|
2120
|
+
let ref;
|
|
2121
|
+
if (statementExp.type === "IterationExpression") {
|
|
2122
|
+
if (statementExp.async) {
|
|
2123
|
+
return;
|
|
2124
|
+
}
|
|
2125
|
+
const statement2 = statementExp.statement;
|
|
2126
|
+
blockStatement[1] = statement2;
|
|
2127
|
+
if (statement2.type === "DoStatement") {
|
|
2128
|
+
ref = initializer[2] = makeRef();
|
|
2129
|
+
assignResults(blockStatement, (resultNode) => {
|
|
2130
|
+
return makeNode({
|
|
2131
|
+
type: "AssignmentExpression",
|
|
2132
|
+
children: [ref, " = ", resultNode]
|
|
2133
|
+
});
|
|
2134
|
+
});
|
|
2135
|
+
const refDec = {
|
|
2136
|
+
type: "Declaration",
|
|
2137
|
+
children: ["let ", ref, ";"]
|
|
2138
|
+
};
|
|
2139
|
+
pre.unshift(refDec);
|
|
2140
|
+
} else {
|
|
2141
|
+
wrapIterationReturningResults(statement2, { children: blockStatement }, function() {
|
|
2142
|
+
});
|
|
2143
|
+
ref = initializer[2] = statement2.resultsRef;
|
|
2144
|
+
}
|
|
1913
2145
|
} else {
|
|
1914
|
-
|
|
2146
|
+
ref = initializer[2] = makeRef();
|
|
2147
|
+
assignResults(blockStatement, (resultNode) => {
|
|
2148
|
+
return makeNode({
|
|
2149
|
+
type: "AssignmentExpression",
|
|
2150
|
+
children: [ref, " = ", resultNode]
|
|
2151
|
+
});
|
|
2152
|
+
});
|
|
2153
|
+
const refDec = {
|
|
2154
|
+
type: "Declaration",
|
|
2155
|
+
children: ["let ", ref, ";"]
|
|
2156
|
+
};
|
|
2157
|
+
pre.unshift(refDec);
|
|
2158
|
+
if (ws) {
|
|
2159
|
+
pre.push(ws);
|
|
2160
|
+
}
|
|
1915
2161
|
}
|
|
2162
|
+
statement.children.unshift(pre, blockStatement, ";");
|
|
2163
|
+
updateParentPointers(blockStatement, statement);
|
|
2164
|
+
return ref;
|
|
1916
2165
|
}
|
|
1917
|
-
function
|
|
1918
|
-
if (
|
|
1919
|
-
|
|
2166
|
+
function processDeclarationCondition(condition, rootCondition, parent) {
|
|
2167
|
+
if (!(condition.type === "DeclarationCondition")) {
|
|
2168
|
+
return;
|
|
1920
2169
|
}
|
|
1921
|
-
|
|
1922
|
-
|
|
2170
|
+
const { decl, bindings } = condition.declaration;
|
|
2171
|
+
const binding = bindings[0];
|
|
2172
|
+
const { pattern, suffix, initializer, splices, thisAssignments } = binding;
|
|
2173
|
+
let ref = prependStatementExpressionBlock(initializer, parent);
|
|
2174
|
+
if (ref) {
|
|
2175
|
+
Object.assign(condition, {
|
|
2176
|
+
type: "AssignmentExpression",
|
|
2177
|
+
children: [ref],
|
|
2178
|
+
pattern,
|
|
2179
|
+
ref,
|
|
2180
|
+
statementDeclaration: true
|
|
2181
|
+
});
|
|
2182
|
+
} else {
|
|
2183
|
+
ref = makeRef();
|
|
2184
|
+
const grandparent = condition.parent?.parent;
|
|
2185
|
+
const children = (
|
|
2186
|
+
// Check that the declaration is a plain assignment (no pattern-matching) and the immediate grandchild of an `if` or `while`
|
|
2187
|
+
// More complex conditions (triggered by pattern matching or `until`/`unless`) don't need double parens
|
|
2188
|
+
// @ts-ignore Just because pattern might not have a type at runtime doesn't mean it's unsafe
|
|
2189
|
+
pattern.type === "Identifier" && (grandparent?.type === "IfStatement" || grandparent?.type === "WhileStatement") ? ["(", ref, initializer, ")"] : [ref, initializer]
|
|
2190
|
+
);
|
|
2191
|
+
Object.assign(condition, {
|
|
2192
|
+
type: "AssignmentExpression",
|
|
2193
|
+
children,
|
|
2194
|
+
hoistDec: {
|
|
2195
|
+
type: "Declaration",
|
|
2196
|
+
children: ["let ", ref, suffix],
|
|
2197
|
+
names: []
|
|
2198
|
+
},
|
|
2199
|
+
pattern,
|
|
2200
|
+
ref
|
|
2201
|
+
});
|
|
1923
2202
|
}
|
|
1924
|
-
;
|
|
1925
|
-
|
|
2203
|
+
addParentPointers(condition, parent);
|
|
2204
|
+
Object.assign(rootCondition, {
|
|
2205
|
+
blockPrefix: [
|
|
2206
|
+
["", [decl, pattern, suffix, " = ", ref, ...splices], ";"],
|
|
2207
|
+
...thisAssignments
|
|
2208
|
+
]
|
|
2209
|
+
});
|
|
1926
2210
|
}
|
|
1927
|
-
function
|
|
1928
|
-
|
|
2211
|
+
function processDeclarationConditions(node) {
|
|
2212
|
+
gatherRecursiveAll(node, (n) => {
|
|
2213
|
+
return n.type === "IfStatement" || n.type === "IterationStatement" || n.type === "SwitchStatement";
|
|
2214
|
+
}).forEach(processDeclarationConditionStatement);
|
|
1929
2215
|
}
|
|
1930
|
-
function
|
|
1931
|
-
const
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
let start = 0;
|
|
1935
|
-
let chains = [];
|
|
1936
|
-
let op;
|
|
1937
|
-
while (i < l) {
|
|
1938
|
-
[, op] = binops[i];
|
|
1939
|
-
if (isRelationalOp(op)) {
|
|
1940
|
-
chains.push(i);
|
|
1941
|
-
} else if (getPrecedence(op) < precedenceRelational) {
|
|
1942
|
-
processChains(op);
|
|
1943
|
-
first = void 0;
|
|
1944
|
-
}
|
|
1945
|
-
i++;
|
|
2216
|
+
function processDeclarationConditionStatement(s) {
|
|
2217
|
+
const { condition } = s;
|
|
2218
|
+
if (!condition?.expression) {
|
|
2219
|
+
return;
|
|
1946
2220
|
}
|
|
1947
|
-
|
|
1948
|
-
|
|
2221
|
+
let { expression } = condition;
|
|
2222
|
+
if (typeof expression === "object" && expression != null && "type" in expression && expression.type === "UnaryExpression" && "children" in expression && Array.isArray(expression.children) && expression.children.length === 2 && expression.children[0] === "!" && typeof expression.children[1] === "object" && expression.children[1] != null && "type" in expression.children[1] && expression.children[1].type === "ParenthesizedExpression" && "expression" in expression.children[1]) {
|
|
2223
|
+
const { type: type1, children: [, { type: type2, expression: expression2 }] } = expression;
|
|
2224
|
+
const type = [type1, type2];
|
|
2225
|
+
expression = expression2;
|
|
1949
2226
|
}
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
exp = binop[3] = expandExistence(exp);
|
|
1963
|
-
let endIndex;
|
|
1964
|
-
if (k < chains.length - 1) {
|
|
1965
|
-
endIndex = chains[k + 1];
|
|
1966
|
-
} else {
|
|
1967
|
-
endIndex = i + 1;
|
|
1968
|
-
}
|
|
1969
|
-
results.push(first, ...binops.slice(start, endIndex).flat());
|
|
1970
|
-
first = [exp].concat(binops.slice(index + 1, endIndex));
|
|
1971
|
-
return start = endIndex;
|
|
2227
|
+
processDeclarationCondition(expression, condition.expression, s);
|
|
2228
|
+
const { ref, pattern } = expression;
|
|
2229
|
+
if (pattern) {
|
|
2230
|
+
let conditions = [];
|
|
2231
|
+
getPatternConditions(pattern, ref, conditions);
|
|
2232
|
+
conditions = conditions.filter((c) => {
|
|
2233
|
+
return !(c.length === 3 && c[0] === "typeof " && c[1] === ref && c[2] === " === 'object'") && !(c.length === 2 && c[0] === ref && c[1] === " != null");
|
|
2234
|
+
});
|
|
2235
|
+
if (conditions.length) {
|
|
2236
|
+
condition.children.unshift("(");
|
|
2237
|
+
conditions.forEach(function(c) {
|
|
2238
|
+
return condition.children.push(" && ", c);
|
|
1972
2239
|
});
|
|
1973
|
-
|
|
1974
|
-
if (first) {
|
|
1975
|
-
results.push(first);
|
|
1976
|
-
}
|
|
1977
|
-
results.push(...binops.slice(start, i + 1).flat());
|
|
1978
|
-
start = i + 1;
|
|
1979
|
-
}
|
|
1980
|
-
chains.length = 0;
|
|
1981
|
-
}
|
|
1982
|
-
function expandExistence(exp) {
|
|
1983
|
-
const existence = isExistence(exp);
|
|
1984
|
-
if (existence) {
|
|
1985
|
-
results.push(existence, " ", "&&", " ");
|
|
1986
|
-
return existence.expression;
|
|
1987
|
-
}
|
|
1988
|
-
return exp;
|
|
1989
|
-
}
|
|
1990
|
-
;
|
|
1991
|
-
}
|
|
1992
|
-
var precedenceOrder, precedenceMap, precedenceStep, precedenceRelational, precedenceCustomDefault, asConst;
|
|
1993
|
-
var init_op = __esm({
|
|
1994
|
-
"source/parser/op.civet"() {
|
|
1995
|
-
"use strict";
|
|
1996
|
-
init_util();
|
|
1997
|
-
precedenceOrder = [
|
|
1998
|
-
["||", "??"],
|
|
1999
|
-
["^^"],
|
|
2000
|
-
["&&"],
|
|
2001
|
-
["|"],
|
|
2002
|
-
["^"],
|
|
2003
|
-
["&"],
|
|
2004
|
-
// NOTE: Equality and inequality merged because of relational chaining
|
|
2005
|
-
[
|
|
2006
|
-
"==",
|
|
2007
|
-
"!=",
|
|
2008
|
-
"===",
|
|
2009
|
-
"!==",
|
|
2010
|
-
"<",
|
|
2011
|
-
"<=",
|
|
2012
|
-
">",
|
|
2013
|
-
">=",
|
|
2014
|
-
"in",
|
|
2015
|
-
"instanceof"
|
|
2016
|
-
],
|
|
2017
|
-
// NOTE: Extra in-between level for default custom operators
|
|
2018
|
-
["custom"],
|
|
2019
|
-
["<<", ">>", ">>>"],
|
|
2020
|
-
["+", "-"],
|
|
2021
|
-
["*", "/", "%"],
|
|
2022
|
-
["**"]
|
|
2023
|
-
];
|
|
2024
|
-
precedenceMap = /* @__PURE__ */ new Map();
|
|
2025
|
-
for (let i1 = 0, len = precedenceOrder.length; i1 < len; i1++) {
|
|
2026
|
-
const prec = i1;
|
|
2027
|
-
const ops = precedenceOrder[i1];
|
|
2028
|
-
for (let i2 = 0, len1 = ops.length; i2 < len1; i2++) {
|
|
2029
|
-
const op = ops[i2];
|
|
2030
|
-
precedenceMap.set(op, prec);
|
|
2031
|
-
}
|
|
2240
|
+
condition.children.push(")");
|
|
2032
2241
|
}
|
|
2033
|
-
precedenceStep = 1 / 64;
|
|
2034
|
-
precedenceRelational = precedenceMap.get("==");
|
|
2035
|
-
precedenceCustomDefault = precedenceMap.get("custom");
|
|
2036
|
-
asConst = {
|
|
2037
|
-
ts: true,
|
|
2038
|
-
children: [" as const"]
|
|
2039
|
-
};
|
|
2040
2242
|
}
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
const { clauses } = caseBlock;
|
|
2048
|
-
for (const c of clauses) {
|
|
2049
|
-
if (c.type === "WhenClause" && c.break) {
|
|
2050
|
-
const last = c.block?.expressions?.at(-1)?.[1];
|
|
2051
|
-
if (isExit(last)) {
|
|
2052
|
-
c.children.splice(c.children.indexOf(c.break), 1);
|
|
2053
|
-
c.break = void 0;
|
|
2054
|
-
}
|
|
2243
|
+
switch (s.type) {
|
|
2244
|
+
case "IfStatement": {
|
|
2245
|
+
const { else: e } = s;
|
|
2246
|
+
const block = blockWithPrefix(condition.expression.blockPrefix, s.then);
|
|
2247
|
+
if (block.bare && e && !block.semicolon) {
|
|
2248
|
+
block.children.push(block.semicolon = ";");
|
|
2055
2249
|
}
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
clauses.forEach((c) => {
|
|
2062
|
-
if (!(c.type === "PatternClause" || c.type === "DefaultClause")) {
|
|
2063
|
-
errors = true;
|
|
2064
|
-
return c.children.push({
|
|
2065
|
-
type: "Error",
|
|
2066
|
-
message: "Can't mix pattern matching and non-pattern matching clauses"
|
|
2067
|
-
});
|
|
2250
|
+
s.children = s.children.map((c) => {
|
|
2251
|
+
if (c === s.then) {
|
|
2252
|
+
return block;
|
|
2253
|
+
} else {
|
|
2254
|
+
return c;
|
|
2068
2255
|
}
|
|
2069
|
-
;
|
|
2070
|
-
return;
|
|
2071
2256
|
});
|
|
2257
|
+
s.then = block;
|
|
2258
|
+
updateParentPointers(block, s);
|
|
2259
|
+
break;
|
|
2072
2260
|
}
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
}
|
|
2080
|
-
let hoistDec, refAssignment = [], ref = maybeRef(condition, "m");
|
|
2081
|
-
if (ref !== condition) {
|
|
2082
|
-
hoistDec = {
|
|
2083
|
-
type: "Declaration",
|
|
2084
|
-
children: ["let ", ref],
|
|
2085
|
-
names: []
|
|
2086
|
-
};
|
|
2087
|
-
refAssignment = [{
|
|
2088
|
-
type: "AssignmentExpression",
|
|
2089
|
-
children: [ref, " = ", condition]
|
|
2090
|
-
}, ","];
|
|
2261
|
+
case "IterationStatement": {
|
|
2262
|
+
const { children, block } = s;
|
|
2263
|
+
const newBlock = blockWithPrefix(condition.expression.blockPrefix, block);
|
|
2264
|
+
s.children = children.map((c) => c?.type === "BlockStatement" ? newBlock : c);
|
|
2265
|
+
updateParentPointers(newBlock, s);
|
|
2266
|
+
break;
|
|
2091
2267
|
}
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
if (c.type === "DefaultClause") {
|
|
2096
|
-
prev.push(c.block);
|
|
2268
|
+
case "SwitchStatement": {
|
|
2269
|
+
const { blockPrefix, ref: ref2, statementDeclaration } = condition.expression;
|
|
2270
|
+
if (!blockPrefix) {
|
|
2097
2271
|
return;
|
|
2098
2272
|
}
|
|
2099
|
-
|
|
2100
|
-
let pattern = patterns[0];
|
|
2101
|
-
const indent = block.expressions?.[0]?.[0] || "";
|
|
2102
|
-
const alternativeConditions = patterns.map((pattern2, i2) => {
|
|
2103
|
-
const conditions = [];
|
|
2104
|
-
getPatternConditions(pattern2, ref, conditions);
|
|
2105
|
-
return conditions;
|
|
2106
|
-
});
|
|
2107
|
-
const conditionExpression = alternativeConditions.map((conditions, i2) => {
|
|
2108
|
-
const conditionArray = conditions.map((c2, i3) => {
|
|
2109
|
-
if (i3 === 0)
|
|
2110
|
-
return c2;
|
|
2111
|
-
return [" && ", ...c2];
|
|
2112
|
-
});
|
|
2113
|
-
if (i2 === 0)
|
|
2114
|
-
return conditionArray;
|
|
2115
|
-
return [" || ", ...conditionArray];
|
|
2116
|
-
});
|
|
2117
|
-
const condition2 = {
|
|
2273
|
+
const newCondition = {
|
|
2118
2274
|
type: "ParenthesizedExpression",
|
|
2119
|
-
children: ["(",
|
|
2120
|
-
expression:
|
|
2275
|
+
children: ["(", ref2, ")"],
|
|
2276
|
+
expression: ref2,
|
|
2277
|
+
parent: s
|
|
2121
2278
|
};
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
case "ObjectBindingPattern": {
|
|
2128
|
-
if (pattern.properties?.length === 0)
|
|
2129
|
-
break;
|
|
2130
|
-
let [splices, thisAssignments] = gatherBindingCode(pattern);
|
|
2131
|
-
const patternBindings = nonMatcherBindings(pattern);
|
|
2132
|
-
splices = splices.map((s2) => [", ", nonMatcherBindings(s2)]);
|
|
2133
|
-
thisAssignments = thisAssignments.map((a) => [indent, a, ";"]);
|
|
2134
|
-
const duplicateDeclarations = aggregateDuplicateBindings([patternBindings, splices], ReservedWord);
|
|
2135
|
-
prefix.push([indent, "const ", patternBindings, " = ", ref, splices, ";"]);
|
|
2136
|
-
prefix.push(...thisAssignments);
|
|
2137
|
-
prefix.push(...duplicateDeclarations.map((d) => [indent, d, ";"]));
|
|
2138
|
-
break;
|
|
2279
|
+
s.children = s.children.map(function(c) {
|
|
2280
|
+
if (c === s.condition) {
|
|
2281
|
+
return newCondition;
|
|
2282
|
+
} else {
|
|
2283
|
+
return c;
|
|
2139
2284
|
}
|
|
2140
|
-
}
|
|
2141
|
-
block.expressions.unshift(...prefix);
|
|
2142
|
-
const next = [];
|
|
2143
|
-
braceBlock(block);
|
|
2144
|
-
if (i < l - 1)
|
|
2145
|
-
next.push("\n", "else ");
|
|
2146
|
-
prev.push(["", {
|
|
2147
|
-
type: "IfStatement",
|
|
2148
|
-
children: ["if", condition2, block, next],
|
|
2149
|
-
then: block,
|
|
2150
|
-
else: next,
|
|
2151
|
-
hoistDec
|
|
2152
|
-
}]);
|
|
2153
|
-
hoistDec = void 0;
|
|
2154
|
-
refAssignment = [];
|
|
2155
|
-
return prev = next;
|
|
2156
|
-
});
|
|
2157
|
-
s.type = "PatternMatchingStatement";
|
|
2158
|
-
s.children = [root];
|
|
2159
|
-
return addParentPointers(s, s.parent);
|
|
2160
|
-
});
|
|
2161
|
-
}
|
|
2162
|
-
function getPatternConditions(pattern, ref, conditions) {
|
|
2163
|
-
if (pattern.rest)
|
|
2164
|
-
return;
|
|
2165
|
-
switch (pattern.type) {
|
|
2166
|
-
case "ArrayBindingPattern": {
|
|
2167
|
-
const { elements, length } = pattern, hasRest = elements.some((e) => e.rest), comparator = hasRest ? " >= " : " === ", l = [comparator, (length - hasRest).toString()];
|
|
2168
|
-
conditions.push(
|
|
2169
|
-
["Array.isArray(", ref, ")"],
|
|
2170
|
-
[ref, ".length", l]
|
|
2171
|
-
);
|
|
2172
|
-
elements.forEach(({ children: [, e] }, i) => {
|
|
2173
|
-
const subRef = [ref, "[", i.toString(), "]"];
|
|
2174
|
-
return getPatternConditions(e, subRef, conditions);
|
|
2175
2285
|
});
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2286
|
+
s.condition = newCondition;
|
|
2287
|
+
updateParentPointers(s);
|
|
2288
|
+
if (statementDeclaration) {
|
|
2289
|
+
const block = makeEmptyBlock();
|
|
2290
|
+
replaceBlockExpression(s.parent, s, block);
|
|
2291
|
+
block.expressions.push(["", s]);
|
|
2292
|
+
s.children.splice(s.children.findIndex(($1) => $1.token === "switch"), 0, blockPrefix);
|
|
2293
|
+
s.parent = block;
|
|
2294
|
+
} else {
|
|
2295
|
+
const block = blockWithPrefix([["", [{
|
|
2296
|
+
type: "Declaration",
|
|
2297
|
+
children: ["let ", ...condition.expression.children]
|
|
2298
|
+
}], ";"], ...blockPrefix], makeEmptyBlock());
|
|
2299
|
+
updateParentPointers(block, s.parent);
|
|
2300
|
+
replaceBlockExpression(s.parent, s, block);
|
|
2301
|
+
block.expressions.push(["", s]);
|
|
2302
|
+
s.parent = block;
|
|
2183
2303
|
}
|
|
2304
|
+
;
|
|
2184
2305
|
break;
|
|
2185
2306
|
}
|
|
2186
|
-
case "ObjectBindingPattern": {
|
|
2187
|
-
conditions.push(
|
|
2188
|
-
["typeof ", ref, " === 'object'"],
|
|
2189
|
-
[ref, " != null"]
|
|
2190
|
-
);
|
|
2191
|
-
pattern.properties.forEach((p) => {
|
|
2192
|
-
switch (p.type) {
|
|
2193
|
-
case "PinProperty":
|
|
2194
|
-
case "BindingProperty": {
|
|
2195
|
-
const { name, value } = p;
|
|
2196
|
-
let subRef;
|
|
2197
|
-
switch (name.type) {
|
|
2198
|
-
case "ComputedPropertyName":
|
|
2199
|
-
conditions.push([name.expression, " in ", ref]);
|
|
2200
|
-
subRef = [ref, name];
|
|
2201
|
-
break;
|
|
2202
|
-
case "Literal":
|
|
2203
|
-
case "StringLiteral":
|
|
2204
|
-
case "NumericLiteral":
|
|
2205
|
-
conditions.push([name, " in ", ref]);
|
|
2206
|
-
subRef = [ref, "[", name, "]"];
|
|
2207
|
-
break;
|
|
2208
|
-
default:
|
|
2209
|
-
conditions.push(["'", name, "' in ", ref]);
|
|
2210
|
-
subRef = [ref, ".", name];
|
|
2211
|
-
}
|
|
2212
|
-
if (value) {
|
|
2213
|
-
getPatternConditions(value, subRef, conditions);
|
|
2214
|
-
}
|
|
2215
|
-
break;
|
|
2216
|
-
}
|
|
2217
|
-
}
|
|
2218
|
-
});
|
|
2219
|
-
break;
|
|
2220
|
-
}
|
|
2221
|
-
case "ConditionFragment": {
|
|
2222
|
-
let { children } = pattern;
|
|
2223
|
-
if (children.length) {
|
|
2224
|
-
let [first, ...rest] = children;
|
|
2225
|
-
let [ws, ...op] = first;
|
|
2226
|
-
ws = [" "].concat(ws);
|
|
2227
|
-
first = [ws, ...op];
|
|
2228
|
-
children = [first, ...rest];
|
|
2229
|
-
}
|
|
2230
|
-
conditions.push(
|
|
2231
|
-
processBinaryOpExpression([ref, children])
|
|
2232
|
-
);
|
|
2233
|
-
break;
|
|
2234
|
-
}
|
|
2235
|
-
case "RegularExpressionLiteral": {
|
|
2236
|
-
conditions.push(
|
|
2237
|
-
["typeof ", ref, " === 'string'"],
|
|
2238
|
-
[pattern, ".test(", ref, ")"]
|
|
2239
|
-
);
|
|
2240
|
-
break;
|
|
2241
|
-
}
|
|
2242
|
-
case "PinPattern":
|
|
2243
|
-
conditions.push([
|
|
2244
|
-
ref,
|
|
2245
|
-
" === ",
|
|
2246
|
-
pattern.expression
|
|
2247
|
-
]);
|
|
2248
|
-
break;
|
|
2249
|
-
case "Literal":
|
|
2250
|
-
conditions.push([
|
|
2251
|
-
ref,
|
|
2252
|
-
" === ",
|
|
2253
|
-
pattern
|
|
2254
|
-
]);
|
|
2255
|
-
break;
|
|
2256
|
-
default:
|
|
2257
|
-
break;
|
|
2258
2307
|
}
|
|
2259
2308
|
}
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
};
|
|
2290
|
-
case "Identifier":
|
|
2291
|
-
return p;
|
|
2292
|
-
case "Literal":
|
|
2293
|
-
case "RegularExpressionLiteral":
|
|
2294
|
-
case "StringLiteral":
|
|
2295
|
-
default:
|
|
2296
|
-
return {
|
|
2297
|
-
...p,
|
|
2298
|
-
children: [ws, name, p.delim]
|
|
2299
|
-
};
|
|
2300
|
-
}
|
|
2309
|
+
var init_declaration = __esm({
|
|
2310
|
+
"source/parser/declaration.civet"() {
|
|
2311
|
+
"use strict";
|
|
2312
|
+
init_block();
|
|
2313
|
+
init_traversal();
|
|
2314
|
+
init_pattern_matching();
|
|
2315
|
+
init_util();
|
|
2316
|
+
init_function();
|
|
2317
|
+
init_binding();
|
|
2318
|
+
}
|
|
2319
|
+
});
|
|
2320
|
+
|
|
2321
|
+
// source/parser/unary.civet
|
|
2322
|
+
function processUnaryExpression(pre, exp, post) {
|
|
2323
|
+
if (!(pre.length || post))
|
|
2324
|
+
return exp;
|
|
2325
|
+
if (post?.token === "?") {
|
|
2326
|
+
post = {
|
|
2327
|
+
$loc: post.$loc,
|
|
2328
|
+
token: " != null"
|
|
2329
|
+
};
|
|
2330
|
+
if (pre.length) {
|
|
2331
|
+
const lastPre = pre[pre.length - 1];
|
|
2332
|
+
if (lastPre.token === "!") {
|
|
2333
|
+
post.token = " == null";
|
|
2334
|
+
pre = pre.slice(0, -1);
|
|
2335
|
+
} else if (lastPre.length === 2 && lastPre[0].token === "!") {
|
|
2336
|
+
post.token = " == null";
|
|
2337
|
+
pre = pre.slice(0, -1);
|
|
2301
2338
|
}
|
|
2302
|
-
case "PinProperty":
|
|
2303
|
-
case "BindingRestProperty":
|
|
2304
|
-
default:
|
|
2305
|
-
return p;
|
|
2306
2339
|
}
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2340
|
+
const existence = {
|
|
2341
|
+
type: "Existence",
|
|
2342
|
+
expression: exp,
|
|
2343
|
+
children: [exp, post]
|
|
2344
|
+
};
|
|
2345
|
+
exp = makeLeftHandSideExpression(existence);
|
|
2346
|
+
if (pre.length) {
|
|
2314
2347
|
return {
|
|
2315
|
-
|
|
2316
|
-
children,
|
|
2317
|
-
elements
|
|
2348
|
+
type: "UnaryExpression",
|
|
2349
|
+
children: [...pre, exp]
|
|
2318
2350
|
};
|
|
2319
2351
|
}
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2352
|
+
return exp;
|
|
2353
|
+
}
|
|
2354
|
+
if (exp.type === "Literal") {
|
|
2355
|
+
if (pre.length === 1) {
|
|
2356
|
+
const { token } = pre[0];
|
|
2357
|
+
if (token === "-" || token === "+") {
|
|
2358
|
+
const children = [pre[0], ...exp.children];
|
|
2359
|
+
if (post)
|
|
2360
|
+
exp.children.push(post);
|
|
2361
|
+
return {
|
|
2362
|
+
type: "Literal",
|
|
2363
|
+
children,
|
|
2364
|
+
raw: `${token}${exp.raw}`
|
|
2365
|
+
};
|
|
2366
|
+
}
|
|
2330
2367
|
}
|
|
2331
|
-
case "ObjectBindingPattern":
|
|
2332
|
-
return ["{", elideMatchersFromPropertyBindings(pattern.properties), "}"];
|
|
2333
|
-
default:
|
|
2334
|
-
return pattern;
|
|
2335
2368
|
}
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
const [, e] = element;
|
|
2345
|
-
if (e.type === "Identifier") {
|
|
2346
|
-
return props.push(e);
|
|
2347
|
-
} else if (e.type === "BindingRestElement") {
|
|
2348
|
-
return props.push(e);
|
|
2369
|
+
let ref;
|
|
2370
|
+
while (ref = pre.length) {
|
|
2371
|
+
const l = ref;
|
|
2372
|
+
const last = pre[l - 1];
|
|
2373
|
+
if (last.type === "Await") {
|
|
2374
|
+
if (last.op) {
|
|
2375
|
+
if (exp.type !== "ParenthesizedExpression") {
|
|
2376
|
+
exp = ["(", exp, ")"];
|
|
2349
2377
|
}
|
|
2350
|
-
|
|
2351
|
-
|
|
2378
|
+
exp = {
|
|
2379
|
+
type: "CallExpression",
|
|
2380
|
+
children: [...last.children, "Promise", last.op, exp]
|
|
2381
|
+
};
|
|
2382
|
+
pre = pre.slice(0, -1);
|
|
2383
|
+
} else {
|
|
2384
|
+
exp = {
|
|
2385
|
+
type: "AwaitExpression",
|
|
2386
|
+
children: [...last.children, exp]
|
|
2387
|
+
};
|
|
2388
|
+
pre = pre.slice(0, -1);
|
|
2352
2389
|
}
|
|
2353
|
-
;
|
|
2354
|
-
return;
|
|
2355
|
-
});
|
|
2356
|
-
});
|
|
2357
|
-
const declarations = [];
|
|
2358
|
-
const propsGroupedByName = /* @__PURE__ */ new Map();
|
|
2359
|
-
for (const p of props) {
|
|
2360
|
-
const { name, value } = p;
|
|
2361
|
-
const key = value?.name || name?.name || name;
|
|
2362
|
-
if (propsGroupedByName.has(key)) {
|
|
2363
|
-
propsGroupedByName.get(key).push(p);
|
|
2364
2390
|
} else {
|
|
2365
|
-
|
|
2391
|
+
break;
|
|
2366
2392
|
}
|
|
2367
2393
|
}
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
if (ReservedWord({ fail() {
|
|
2373
|
-
} }, {
|
|
2374
|
-
pos: 0,
|
|
2375
|
-
input: key
|
|
2376
|
-
})) {
|
|
2377
|
-
shared.forEach((p) => {
|
|
2378
|
-
return aliasBinding(p, makeRef(`_${key}`, key));
|
|
2379
|
-
});
|
|
2380
|
-
return;
|
|
2381
|
-
}
|
|
2382
|
-
if (shared.length === 1) {
|
|
2383
|
-
return;
|
|
2384
|
-
}
|
|
2385
|
-
const refs = shared.map((p) => {
|
|
2386
|
-
const ref = makeRef(key);
|
|
2387
|
-
aliasBinding(p, ref);
|
|
2388
|
-
return ref;
|
|
2389
|
-
});
|
|
2390
|
-
return declarations.push(["const ", key, " = [", ...refs.map((r, i) => {
|
|
2391
|
-
return i === 0 ? r : [", ", r];
|
|
2392
|
-
}), "]"]);
|
|
2393
|
-
});
|
|
2394
|
-
return declarations;
|
|
2395
|
-
}
|
|
2396
|
-
function processDeclarationCondition(condition, rootCondition, parent) {
|
|
2397
|
-
if (!(condition.type === "DeclarationCondition")) {
|
|
2398
|
-
return;
|
|
2399
|
-
}
|
|
2400
|
-
const ref = makeRef();
|
|
2401
|
-
const { decl, bindings } = condition.declaration;
|
|
2402
|
-
const binding = bindings[0];
|
|
2403
|
-
const { pattern, suffix, initializer, splices, thisAssignments } = binding;
|
|
2404
|
-
const grandparent = condition.parent?.parent;
|
|
2405
|
-
const children = (
|
|
2406
|
-
// Check that the declaration is a plain assignment (no pattern-matching) and the immediate grandchild of an `if` or `while`
|
|
2407
|
-
// More complex conditions (triggered by pattern matching or `until`/`unless`) don't need double parens
|
|
2408
|
-
// @ts-ignore Just because pattern might not have a type at runtime doesn't mean it's unsafe
|
|
2409
|
-
pattern.type === "Identifier" && (grandparent?.type === "IfStatement" || grandparent?.type === "WhileStatement") ? ["(", ref, initializer, ")"] : [ref, initializer]
|
|
2410
|
-
);
|
|
2411
|
-
Object.assign(condition, {
|
|
2412
|
-
type: "AssignmentExpression",
|
|
2413
|
-
children,
|
|
2414
|
-
hoistDec: {
|
|
2415
|
-
type: "Declaration",
|
|
2416
|
-
children: ["let ", ref, suffix],
|
|
2417
|
-
names: []
|
|
2418
|
-
},
|
|
2419
|
-
pattern,
|
|
2420
|
-
ref
|
|
2421
|
-
});
|
|
2422
|
-
addParentPointers(condition, parent);
|
|
2423
|
-
Object.assign(rootCondition, {
|
|
2424
|
-
blockPrefix: [
|
|
2425
|
-
["", [decl, pattern, suffix, " = ", ref, ...splices], ";"],
|
|
2426
|
-
...thisAssignments
|
|
2427
|
-
]
|
|
2428
|
-
});
|
|
2429
|
-
}
|
|
2430
|
-
function processDeclarationConditions(node) {
|
|
2431
|
-
gatherRecursiveAll(node, (n) => {
|
|
2432
|
-
return n.type === "IfStatement" || n.type === "IterationStatement" || n.type === "SwitchStatement";
|
|
2433
|
-
}).forEach(processDeclarationConditionStatement);
|
|
2394
|
+
return {
|
|
2395
|
+
type: "UnaryExpression",
|
|
2396
|
+
children: [...pre, exp, post]
|
|
2397
|
+
};
|
|
2434
2398
|
}
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2399
|
+
var init_unary = __esm({
|
|
2400
|
+
"source/parser/unary.civet"() {
|
|
2401
|
+
"use strict";
|
|
2402
|
+
init_util();
|
|
2439
2403
|
}
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2404
|
+
});
|
|
2405
|
+
|
|
2406
|
+
// source/parser/pipe.civet
|
|
2407
|
+
function constructInvocation(fn, arg) {
|
|
2408
|
+
const fnArr = [fn.leadingComment, fn.expr, fn.trailingComment];
|
|
2409
|
+
let expr = fn.expr;
|
|
2410
|
+
while (expr.type === "ParenthesizedExpression") {
|
|
2411
|
+
expr = expr.expression;
|
|
2445
2412
|
}
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2413
|
+
if (expr.ampersandBlock) {
|
|
2414
|
+
const { ref, body } = expr;
|
|
2415
|
+
ref.type = "PipedExpression";
|
|
2416
|
+
ref.children = [makeLeftHandSideExpression(arg)];
|
|
2417
|
+
updateParentPointers(ref);
|
|
2418
|
+
return makeNode({
|
|
2419
|
+
type: "UnwrappedExpression",
|
|
2420
|
+
children: [skipIfOnlyWS(fn.leadingComment), body, skipIfOnlyWS(fn.trailingComment)]
|
|
2453
2421
|
});
|
|
2454
|
-
if (conditions.length) {
|
|
2455
|
-
condition.children.unshift("(");
|
|
2456
|
-
conditions.forEach(function(c) {
|
|
2457
|
-
return condition.children.push(" && ", c);
|
|
2458
|
-
});
|
|
2459
|
-
condition.children.push(")");
|
|
2460
|
-
}
|
|
2461
2422
|
}
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2423
|
+
expr = fn.expr;
|
|
2424
|
+
const lhs = makeLeftHandSideExpression(expr);
|
|
2425
|
+
let comment = skipIfOnlyWS(fn.trailingComment);
|
|
2426
|
+
if (comment)
|
|
2427
|
+
lhs.children.splice(2, 0, comment);
|
|
2428
|
+
comment = skipIfOnlyWS(fn.leadingComment);
|
|
2429
|
+
if (comment)
|
|
2430
|
+
lhs.children.splice(1, 0, comment);
|
|
2431
|
+
switch (arg.type) {
|
|
2432
|
+
case "CommaExpression":
|
|
2433
|
+
arg = makeLeftHandSideExpression(arg);
|
|
2434
|
+
break;
|
|
2435
|
+
}
|
|
2436
|
+
return {
|
|
2437
|
+
type: "CallExpression",
|
|
2438
|
+
children: [lhs, "(", arg, ")"]
|
|
2439
|
+
};
|
|
2440
|
+
}
|
|
2441
|
+
function constructPipeStep(fn, arg, returning) {
|
|
2442
|
+
let children = [[fn.leadingComment, fn.expr, fn.trailingComment].map(skipIfOnlyWS), " ", arg];
|
|
2443
|
+
switch (fn.expr.token) {
|
|
2444
|
+
case "yield":
|
|
2445
|
+
case "await":
|
|
2446
|
+
if (fn.expr.op) {
|
|
2447
|
+
children = processUnaryExpression([fn.expr], arg, void 0);
|
|
2448
|
+
}
|
|
2449
|
+
if (returning) {
|
|
2450
|
+
return [
|
|
2451
|
+
children,
|
|
2452
|
+
returning
|
|
2453
|
+
];
|
|
2454
|
+
}
|
|
2455
|
+
return [
|
|
2456
|
+
children,
|
|
2457
|
+
null
|
|
2458
|
+
];
|
|
2459
|
+
case "return":
|
|
2460
|
+
return [{
|
|
2461
|
+
type: "ReturnStatement",
|
|
2462
|
+
children
|
|
2463
|
+
}, null];
|
|
2464
|
+
}
|
|
2465
|
+
if (returning) {
|
|
2466
|
+
return [
|
|
2467
|
+
constructInvocation(fn, arg),
|
|
2468
|
+
returning
|
|
2469
|
+
];
|
|
2470
|
+
}
|
|
2471
|
+
return [constructInvocation(fn, arg), null];
|
|
2472
|
+
}
|
|
2473
|
+
function processPipelineExpressions(statements) {
|
|
2474
|
+
gatherRecursiveAll(statements, (n) => n.type === "PipelineExpression").forEach((s) => {
|
|
2475
|
+
const [ws, , body] = s.children;
|
|
2476
|
+
let [, arg] = s.children;
|
|
2477
|
+
let i = 0, l = body.length;
|
|
2478
|
+
const children = [ws];
|
|
2479
|
+
let usingRef = null;
|
|
2480
|
+
for (i = 0; i < l; i++) {
|
|
2481
|
+
const step = body[i];
|
|
2482
|
+
const [leadingComment, pipe, trailingComment, expr] = step;
|
|
2483
|
+
const returns = pipe.token === "||>";
|
|
2484
|
+
let ref, result, returning = returns ? arg : null;
|
|
2485
|
+
if (pipe.token === "|>=") {
|
|
2486
|
+
let initRef;
|
|
2487
|
+
if (i === 0) {
|
|
2488
|
+
outer:
|
|
2489
|
+
switch (arg.type) {
|
|
2490
|
+
case "MemberExpression":
|
|
2491
|
+
if (arg.children.length <= 2)
|
|
2492
|
+
break;
|
|
2493
|
+
case "CallExpression":
|
|
2494
|
+
const access = arg.children.pop();
|
|
2495
|
+
switch (access.type) {
|
|
2496
|
+
case "PropertyAccess":
|
|
2497
|
+
case "SliceExpression":
|
|
2498
|
+
break;
|
|
2499
|
+
default:
|
|
2500
|
+
children.unshift({
|
|
2501
|
+
type: "Error",
|
|
2502
|
+
$loc: pipe.token.$loc,
|
|
2503
|
+
message: `Can't assign to ${access.type}`
|
|
2504
|
+
});
|
|
2505
|
+
arg.children.push(access);
|
|
2506
|
+
break outer;
|
|
2507
|
+
}
|
|
2508
|
+
usingRef = makeRef();
|
|
2509
|
+
initRef = {
|
|
2510
|
+
type: "AssignmentExpression",
|
|
2511
|
+
children: [usingRef, " = ", arg, ","]
|
|
2512
|
+
};
|
|
2513
|
+
arg = {
|
|
2514
|
+
type: "MemberExpression",
|
|
2515
|
+
children: [usingRef, access]
|
|
2516
|
+
};
|
|
2517
|
+
break;
|
|
2518
|
+
}
|
|
2519
|
+
const lhs = [[
|
|
2520
|
+
[initRef],
|
|
2521
|
+
arg,
|
|
2522
|
+
[],
|
|
2523
|
+
{ token: "=", children: [" = "] }
|
|
2524
|
+
]];
|
|
2525
|
+
Object.assign(s, {
|
|
2526
|
+
type: "AssignmentExpression",
|
|
2527
|
+
children: [lhs, children],
|
|
2528
|
+
names: null,
|
|
2529
|
+
lhs,
|
|
2530
|
+
assigned: arg,
|
|
2531
|
+
exp: children
|
|
2532
|
+
});
|
|
2533
|
+
arg = clone(arg);
|
|
2534
|
+
if (arg.children[0].type === "Ref") {
|
|
2535
|
+
arg.children[0] = usingRef;
|
|
2536
|
+
}
|
|
2537
|
+
} else {
|
|
2538
|
+
children.unshift({
|
|
2539
|
+
type: "Error",
|
|
2540
|
+
$loc: pipe.token.$loc,
|
|
2541
|
+
message: "Can't use |>= in the middle of a pipeline"
|
|
2542
|
+
});
|
|
2543
|
+
}
|
|
2544
|
+
} else {
|
|
2545
|
+
if (i === 0)
|
|
2546
|
+
s.children = children;
|
|
2547
|
+
}
|
|
2548
|
+
if (returns && (ref = needsRef(arg))) {
|
|
2549
|
+
usingRef = usingRef || ref;
|
|
2550
|
+
arg = {
|
|
2551
|
+
type: "ParenthesizedExpression",
|
|
2552
|
+
children: ["(", {
|
|
2553
|
+
type: "AssignmentExpression",
|
|
2554
|
+
children: [usingRef, " = ", arg]
|
|
2555
|
+
}, ")"]
|
|
2556
|
+
};
|
|
2557
|
+
returning = usingRef;
|
|
2558
|
+
}
|
|
2559
|
+
;
|
|
2560
|
+
[result, returning] = constructPipeStep(
|
|
2561
|
+
{
|
|
2562
|
+
leadingComment: skipIfOnlyWS(leadingComment),
|
|
2563
|
+
trailingComment: skipIfOnlyWS(trailingComment),
|
|
2564
|
+
expr
|
|
2565
|
+
},
|
|
2566
|
+
arg,
|
|
2567
|
+
returning
|
|
2568
|
+
);
|
|
2569
|
+
if (result.type === "ReturnStatement") {
|
|
2570
|
+
if (i < l - 1) {
|
|
2571
|
+
result.children.push({
|
|
2572
|
+
type: "Error",
|
|
2573
|
+
message: "Can't continue a pipeline after returning"
|
|
2574
|
+
});
|
|
2575
|
+
}
|
|
2576
|
+
arg = result;
|
|
2577
|
+
if (children[children.length - 1] === ",") {
|
|
2578
|
+
children.pop();
|
|
2579
|
+
children.push(";");
|
|
2580
|
+
}
|
|
2581
|
+
break;
|
|
2469
2582
|
}
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
const { children, block } = s;
|
|
2476
|
-
const newBlock = blockWithPrefix(condition.expression.blockPrefix, block);
|
|
2477
|
-
s.children = children.map((c) => c?.type === "BlockStatement" ? newBlock : c);
|
|
2478
|
-
updateParentPointers(newBlock, s);
|
|
2479
|
-
break;
|
|
2480
|
-
}
|
|
2481
|
-
case "SwitchStatement": {
|
|
2482
|
-
const { blockPrefix, ref: ref2 } = condition.expression;
|
|
2483
|
-
if (!blockPrefix) {
|
|
2484
|
-
return;
|
|
2583
|
+
if (returning) {
|
|
2584
|
+
arg = returning;
|
|
2585
|
+
children.push(result, ",");
|
|
2586
|
+
} else {
|
|
2587
|
+
arg = result;
|
|
2485
2588
|
}
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
expression: ref2,
|
|
2490
|
-
parent: s
|
|
2491
|
-
};
|
|
2492
|
-
s.children[1] = s.condition;
|
|
2493
|
-
updateParentPointers(s);
|
|
2494
|
-
const block = blockWithPrefix([["", [{
|
|
2589
|
+
}
|
|
2590
|
+
if (usingRef) {
|
|
2591
|
+
s.hoistDec = {
|
|
2495
2592
|
type: "Declaration",
|
|
2496
|
-
children: ["let ",
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
replaceBlockExpression(s.parent, s, block);
|
|
2500
|
-
block.expressions.push(["", s]);
|
|
2501
|
-
s.parent = block;
|
|
2502
|
-
break;
|
|
2593
|
+
children: ["let ", usingRef],
|
|
2594
|
+
names: []
|
|
2595
|
+
};
|
|
2503
2596
|
}
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
const index = p.children.indexOf(p.name);
|
|
2516
|
-
p.children.splice(index + 1, 0, ": ", ref);
|
|
2517
|
-
}
|
|
2597
|
+
children.push(arg);
|
|
2598
|
+
if (!children.some(($) => $?.type === "ReturnStatement") && children.some(($1) => $1 === ",")) {
|
|
2599
|
+
const { parent } = s;
|
|
2600
|
+
const parenthesizedExpression = makeLeftHandSideExpression({ ...s });
|
|
2601
|
+
Object.assign(s, parenthesizedExpression, {
|
|
2602
|
+
parent,
|
|
2603
|
+
hoistDec: void 0
|
|
2604
|
+
});
|
|
2605
|
+
}
|
|
2606
|
+
return addParentPointers(s, s.parent);
|
|
2607
|
+
});
|
|
2518
2608
|
}
|
|
2519
|
-
var
|
|
2520
|
-
"source/parser/
|
|
2609
|
+
var init_pipe = __esm({
|
|
2610
|
+
"source/parser/pipe.civet"() {
|
|
2521
2611
|
"use strict";
|
|
2522
2612
|
init_traversal();
|
|
2523
2613
|
init_util();
|
|
2524
|
-
|
|
2525
|
-
init_binding();
|
|
2526
|
-
init_op();
|
|
2614
|
+
init_unary();
|
|
2527
2615
|
}
|
|
2528
2616
|
});
|
|
2529
2617
|
|
|
2530
|
-
// source/parser/
|
|
2531
|
-
function
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2618
|
+
// source/parser/for.civet
|
|
2619
|
+
function forRange(open, forDeclaration, range, stepExp, close) {
|
|
2620
|
+
const { start, end, inclusive } = range;
|
|
2621
|
+
const counterRef = makeRef("i");
|
|
2622
|
+
let stepRef;
|
|
2623
|
+
if (stepExp) {
|
|
2624
|
+
stepExp = insertTrimmingSpace(stepExp, "");
|
|
2625
|
+
stepRef = maybeRef(stepExp, "step");
|
|
2626
|
+
}
|
|
2627
|
+
const startRef = maybeRef(start, "start");
|
|
2628
|
+
const endRef = maybeRef(end, "end");
|
|
2629
|
+
const startRefDec = startRef !== start ? [startRef, " = ", start, ", "] : [];
|
|
2630
|
+
const endRefDec = endRef !== end ? [endRef, " = ", end, ", "] : [];
|
|
2631
|
+
let ascDec = [], ascRef, asc;
|
|
2632
|
+
if (stepRef) {
|
|
2633
|
+
if (stepRef !== stepExp) {
|
|
2634
|
+
ascDec = [", ", stepRef, " = ", stepExp];
|
|
2635
|
+
}
|
|
2636
|
+
} else if (start.type === "Literal" && end.type === "Literal") {
|
|
2637
|
+
asc = literalValue(start) <= literalValue(end);
|
|
2638
|
+
} else {
|
|
2639
|
+
ascRef = makeRef("asc");
|
|
2640
|
+
ascDec = [", ", ascRef, " = ", startRef, " <= ", endRef];
|
|
2641
|
+
}
|
|
2642
|
+
let varAssign = [], varLetAssign = varAssign, varLet = varAssign, blockPrefix;
|
|
2643
|
+
if (forDeclaration?.declare) {
|
|
2644
|
+
if (forDeclaration.declare.token === "let") {
|
|
2645
|
+
const varName = forDeclaration.children.splice(1);
|
|
2646
|
+
varAssign = [...insertTrimmingSpace(varName, ""), " = "];
|
|
2647
|
+
varLet = [",", ...varName, " = ", counterRef];
|
|
2648
|
+
} else {
|
|
2649
|
+
blockPrefix = [
|
|
2650
|
+
["", forDeclaration, " = ", counterRef, ";"]
|
|
2651
|
+
];
|
|
2652
|
+
}
|
|
2653
|
+
} else if (forDeclaration) {
|
|
2654
|
+
varAssign = varLetAssign = [forDeclaration, " = "];
|
|
2655
|
+
}
|
|
2656
|
+
const declaration = {
|
|
2657
|
+
type: "Declaration",
|
|
2658
|
+
children: ["let ", ...startRefDec, ...endRefDec, counterRef, " = ", ...varLetAssign, startRef, ...varLet, ...ascDec],
|
|
2659
|
+
names: forDeclaration?.names
|
|
2660
|
+
};
|
|
2661
|
+
const counterPart = inclusive ? [counterRef, " <= ", endRef, " : ", counterRef, " >= ", endRef] : [counterRef, " < ", endRef, " : ", counterRef, " > ", endRef];
|
|
2662
|
+
const condition = stepRef ? [stepRef, " !== 0 && (", stepRef, " > 0 ? ", ...counterPart, ")"] : ascRef ? [ascRef, " ? ", ...counterPart] : asc ? counterPart.slice(0, 3) : counterPart.slice(4);
|
|
2663
|
+
const increment = stepRef ? [...varAssign, counterRef, " += ", stepRef] : ascRef ? [...varAssign, ascRef, " ? ++", counterRef, " : --", counterRef] : [...varAssign, asc ? "++" : "--", counterRef];
|
|
2664
|
+
return {
|
|
2665
|
+
declaration,
|
|
2666
|
+
children: [open, declaration, "; ", ...condition, "; ", ...increment, close],
|
|
2667
|
+
blockPrefix
|
|
2668
|
+
};
|
|
2669
|
+
}
|
|
2670
|
+
function processForInOf($0, getRef) {
|
|
2671
|
+
let [awaits, eachOwn, open, declaration, declaration2, ws, inOf, exp, step, close] = $0;
|
|
2672
|
+
if (exp.type === "RangeExpression" && inOf.token === "of" && !declaration2) {
|
|
2673
|
+
return forRange(open, declaration, exp, step, close);
|
|
2674
|
+
} else if (step) {
|
|
2675
|
+
throw new Error("for..of/in cannot use 'by' except with range literals");
|
|
2676
|
+
}
|
|
2677
|
+
let eachOwnError;
|
|
2678
|
+
let hoistDec, blockPrefix = [];
|
|
2679
|
+
if (eachOwn && eachOwn[0].token === "each") {
|
|
2680
|
+
if (inOf.token === "of") {
|
|
2681
|
+
const counterRef = makeRef("i");
|
|
2682
|
+
const lenRef = makeRef("len");
|
|
2683
|
+
const expRef2 = maybeRef(exp);
|
|
2684
|
+
const increment = "++";
|
|
2685
|
+
let assignmentNames = [...declaration.names];
|
|
2686
|
+
if (declaration2) {
|
|
2687
|
+
const [, , ws22, decl22] = declaration2;
|
|
2688
|
+
blockPrefix.push(["", [
|
|
2689
|
+
insertTrimmingSpace(ws22, ""),
|
|
2690
|
+
decl22,
|
|
2691
|
+
" = ",
|
|
2692
|
+
counterRef
|
|
2693
|
+
], ";"]);
|
|
2694
|
+
assignmentNames.push(...decl22.names);
|
|
2547
2695
|
}
|
|
2696
|
+
const expRefDec = expRef2 !== exp ? [insertTrimmingSpace(expRef2, " "), " = ", insertTrimmingSpace(exp, ""), ", "] : [];
|
|
2697
|
+
blockPrefix.push(["", {
|
|
2698
|
+
type: "Declaration",
|
|
2699
|
+
children: [declaration, " = ", insertTrimmingSpace(expRef2, ""), "[", counterRef, "]"],
|
|
2700
|
+
names: assignmentNames
|
|
2701
|
+
}, ";"]);
|
|
2702
|
+
declaration = {
|
|
2703
|
+
type: "Declaration",
|
|
2704
|
+
children: ["let ", ...expRefDec, counterRef, " = 0, ", lenRef, " = ", insertTrimmingSpace(expRef2, ""), ".length"],
|
|
2705
|
+
names: []
|
|
2706
|
+
};
|
|
2707
|
+
const condition = [counterRef, " < ", lenRef, "; "];
|
|
2708
|
+
const children = [open, declaration, "; ", condition, counterRef, increment, close];
|
|
2709
|
+
return { declaration, children, blockPrefix };
|
|
2710
|
+
} else {
|
|
2711
|
+
eachOwnError = {
|
|
2712
|
+
type: "Error",
|
|
2713
|
+
message: "'each' is only meaningful in for..of loops"
|
|
2714
|
+
};
|
|
2548
2715
|
}
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2716
|
+
}
|
|
2717
|
+
let own = eachOwn && eachOwn[0].token === "own";
|
|
2718
|
+
let expRef;
|
|
2719
|
+
if (own && inOf.token !== "in") {
|
|
2720
|
+
own = false;
|
|
2721
|
+
eachOwnError = {
|
|
2722
|
+
type: "Error",
|
|
2723
|
+
message: "'own' is only meaningful in for..in loops"
|
|
2553
2724
|
};
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2725
|
+
}
|
|
2726
|
+
if (!declaration2 && !own) {
|
|
2727
|
+
return {
|
|
2728
|
+
declaration,
|
|
2729
|
+
blockPrefix,
|
|
2730
|
+
children: [awaits, eachOwnError, open, declaration, ws, inOf, expRef ?? exp, step, close]
|
|
2731
|
+
// omit declaration2, replace eachOwn with eachOwnError, replace exp with expRef
|
|
2732
|
+
};
|
|
2733
|
+
}
|
|
2734
|
+
let ws2, decl2;
|
|
2735
|
+
if (declaration2)
|
|
2736
|
+
[, , ws2, decl2] = declaration2;
|
|
2737
|
+
switch (inOf.token) {
|
|
2738
|
+
case "of": {
|
|
2739
|
+
const counterRef = makeRef("i");
|
|
2740
|
+
hoistDec = {
|
|
2741
|
+
type: "Declaration",
|
|
2742
|
+
children: ["let ", counterRef, " = 0"],
|
|
2743
|
+
names: []
|
|
2559
2744
|
};
|
|
2745
|
+
blockPrefix.push(["", {
|
|
2746
|
+
type: "Declaration",
|
|
2747
|
+
children: [insertTrimmingSpace(ws2, ""), decl2, " = ", counterRef, "++"],
|
|
2748
|
+
names: decl2.names
|
|
2749
|
+
}, ";"]);
|
|
2750
|
+
break;
|
|
2560
2751
|
}
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2752
|
+
case "in": {
|
|
2753
|
+
const expRef2 = maybeRef(exp);
|
|
2754
|
+
if (expRef2 !== exp) {
|
|
2755
|
+
hoistDec = {
|
|
2756
|
+
type: "Declaration",
|
|
2757
|
+
children: ["let ", expRef2],
|
|
2758
|
+
names: []
|
|
2759
|
+
};
|
|
2760
|
+
exp = {
|
|
2761
|
+
type: "AssignmentExpression",
|
|
2762
|
+
children: [" ", expRef2, " =", exp]
|
|
2763
|
+
};
|
|
2764
|
+
}
|
|
2765
|
+
let { binding } = declaration;
|
|
2766
|
+
if (binding?.type !== "Identifier") {
|
|
2767
|
+
const keyRef = makeRef("key");
|
|
2768
|
+
blockPrefix.push(["", [
|
|
2769
|
+
declaration,
|
|
2770
|
+
" = ",
|
|
2771
|
+
keyRef
|
|
2772
|
+
], ";"]);
|
|
2773
|
+
declaration = {
|
|
2774
|
+
type: "ForDeclaration",
|
|
2775
|
+
binding: binding = keyRef,
|
|
2776
|
+
children: ["const ", keyRef],
|
|
2777
|
+
names: []
|
|
2574
2778
|
};
|
|
2575
2779
|
}
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
if (l) {
|
|
2580
|
-
const last = pre[l - 1];
|
|
2581
|
-
if (last.type === "Await" && last.op) {
|
|
2582
|
-
if (exp.type !== "ParenthesizedExpression") {
|
|
2583
|
-
exp = ["(", exp, ")"];
|
|
2780
|
+
if (own) {
|
|
2781
|
+
const hasPropRef = getRef("hasProp");
|
|
2782
|
+
blockPrefix.push(["", ["if (!", hasPropRef, "(", insertTrimmingSpace(expRef2, ""), ", ", insertTrimmingSpace(binding, ""), ")) continue"], ";"]);
|
|
2584
2783
|
}
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2784
|
+
if (decl2) {
|
|
2785
|
+
blockPrefix.push(["", {
|
|
2786
|
+
type: "Declaration",
|
|
2787
|
+
children: [insertTrimmingSpace(ws2, ""), decl2, " = ", insertTrimmingSpace(expRef2, ""), "[", insertTrimmingSpace(binding, ""), "]"],
|
|
2788
|
+
names: decl2.names
|
|
2789
|
+
}, ";"]);
|
|
2790
|
+
}
|
|
2791
|
+
break;
|
|
2589
2792
|
}
|
|
2793
|
+
default:
|
|
2794
|
+
(() => {
|
|
2795
|
+
throw new Error(`for item, index must use 'of' or 'in' instead of '${inOf.token}'`);
|
|
2796
|
+
})();
|
|
2590
2797
|
}
|
|
2591
2798
|
return {
|
|
2592
|
-
|
|
2593
|
-
children: [
|
|
2799
|
+
declaration,
|
|
2800
|
+
children: [awaits, eachOwnError, open, declaration, ws, inOf, exp, step, close],
|
|
2801
|
+
// omit declaration2, replace each with eachOwnError
|
|
2802
|
+
blockPrefix,
|
|
2803
|
+
hoistDec
|
|
2594
2804
|
};
|
|
2595
2805
|
}
|
|
2596
|
-
var
|
|
2597
|
-
"source/parser/
|
|
2806
|
+
var init_for = __esm({
|
|
2807
|
+
"source/parser/for.civet"() {
|
|
2598
2808
|
"use strict";
|
|
2599
2809
|
init_util();
|
|
2600
2810
|
}
|
|
@@ -2919,7 +3129,6 @@ __export(lib_exports, {
|
|
|
2919
3129
|
dedentBlockString: () => dedentBlockString,
|
|
2920
3130
|
dedentBlockSubstitutions: () => dedentBlockSubstitutions,
|
|
2921
3131
|
deepCopy: () => deepCopy,
|
|
2922
|
-
expressionizeIfClause: () => expressionizeIfClause,
|
|
2923
3132
|
expressionizeTypeIf: () => expressionizeTypeIf,
|
|
2924
3133
|
forRange: () => forRange,
|
|
2925
3134
|
gatherBindingCode: () => gatherBindingCode,
|
|
@@ -2954,6 +3163,7 @@ __export(lib_exports, {
|
|
|
2954
3163
|
quoteString: () => quoteString,
|
|
2955
3164
|
reorderBindingRestProperty: () => reorderBindingRestProperty,
|
|
2956
3165
|
replaceNodes: () => replaceNodes,
|
|
3166
|
+
skipImplicitArguments: () => skipImplicitArguments,
|
|
2957
3167
|
typeOfJSX: () => typeOfJSX,
|
|
2958
3168
|
wrapIIFE: () => wrapIIFE
|
|
2959
3169
|
});
|
|
@@ -2992,16 +3202,71 @@ function negateCondition(condition) {
|
|
|
2992
3202
|
};
|
|
2993
3203
|
return { ...condition, expression, children };
|
|
2994
3204
|
}
|
|
2995
|
-
function
|
|
2996
|
-
|
|
3205
|
+
function isExpression(node) {
|
|
3206
|
+
if (Array.isArray(node)) {
|
|
3207
|
+
return node.every(isExpression);
|
|
3208
|
+
}
|
|
3209
|
+
if (typeof node === "string") {
|
|
3210
|
+
return true;
|
|
3211
|
+
}
|
|
3212
|
+
switch (node?.type) {
|
|
3213
|
+
case "BlockStatement":
|
|
3214
|
+
case "DebuggerStatement":
|
|
3215
|
+
case "Declaration":
|
|
3216
|
+
case "IfStatement":
|
|
3217
|
+
case "IterationStatement":
|
|
3218
|
+
case "ReturnStatement":
|
|
3219
|
+
case "SwitchStatement":
|
|
3220
|
+
case "ThrowStatement":
|
|
3221
|
+
case "TryStatement":
|
|
3222
|
+
return false;
|
|
3223
|
+
}
|
|
3224
|
+
return true;
|
|
3225
|
+
}
|
|
3226
|
+
function expressionizeBlock(blockOrExpression) {
|
|
3227
|
+
let ref1;
|
|
3228
|
+
if ((ref1 = blockOrExpression) && "expressions" in ref1) {
|
|
3229
|
+
const { expressions } = ref1;
|
|
3230
|
+
const l = expressions.length;
|
|
3231
|
+
const results = [];
|
|
3232
|
+
let i1 = 0;
|
|
3233
|
+
for (const [ws, s, _delim] of expressions) {
|
|
3234
|
+
const i = i1++;
|
|
3235
|
+
if (!isExpression(s))
|
|
3236
|
+
return;
|
|
3237
|
+
const wrapped = makeLeftHandSideExpression(s);
|
|
3238
|
+
if (i === l - 1) {
|
|
3239
|
+
results.push([ws, wrapped]);
|
|
3240
|
+
} else {
|
|
3241
|
+
results.push([ws, wrapped, ","]);
|
|
3242
|
+
}
|
|
3243
|
+
}
|
|
3244
|
+
if (results.length > 1) {
|
|
3245
|
+
return makeLeftHandSideExpression(results);
|
|
3246
|
+
}
|
|
3247
|
+
return results;
|
|
3248
|
+
} else {
|
|
3249
|
+
return blockOrExpression;
|
|
3250
|
+
}
|
|
3251
|
+
}
|
|
3252
|
+
function expressionizeIfStatement(statement) {
|
|
3253
|
+
const { condition, then: b, else: e } = statement;
|
|
2997
3254
|
const [...condRest] = condition.children, [closeParen] = condRest.splice(-1);
|
|
3255
|
+
const expressionizedBlock = expressionizeBlock(b);
|
|
3256
|
+
if (!expressionizedBlock) {
|
|
3257
|
+
return wrapIIFE([["", statement]]);
|
|
3258
|
+
}
|
|
2998
3259
|
const children = [
|
|
2999
3260
|
...condRest,
|
|
3000
3261
|
"?",
|
|
3001
|
-
|
|
3262
|
+
expressionizedBlock
|
|
3002
3263
|
];
|
|
3003
3264
|
if (e) {
|
|
3004
|
-
|
|
3265
|
+
const e2 = expressionizeBlock(e[2]);
|
|
3266
|
+
if (!e2) {
|
|
3267
|
+
return wrapIIFE([["", statement]]);
|
|
3268
|
+
}
|
|
3269
|
+
children.push(e[0], ":", e2, ...e.slice(3));
|
|
3005
3270
|
} else {
|
|
3006
3271
|
children.push(":void 0");
|
|
3007
3272
|
}
|
|
@@ -3065,17 +3330,17 @@ function processCallMemberExpression(node) {
|
|
|
3065
3330
|
let call = children[1];
|
|
3066
3331
|
const args = [...call.args];
|
|
3067
3332
|
call = { ...call, args };
|
|
3068
|
-
let
|
|
3069
|
-
if (
|
|
3070
|
-
const comma =
|
|
3333
|
+
let ref2;
|
|
3334
|
+
if (ref2 = isComma(args.at(-1))) {
|
|
3335
|
+
const comma = ref2;
|
|
3071
3336
|
comma.token = "";
|
|
3072
3337
|
}
|
|
3073
3338
|
let commaCount = 0;
|
|
3074
|
-
for (let
|
|
3075
|
-
const arg = args[
|
|
3076
|
-
let
|
|
3077
|
-
if (
|
|
3078
|
-
const comma =
|
|
3339
|
+
for (let i2 = 0, len1 = args.length; i2 < len1; i2++) {
|
|
3340
|
+
const arg = args[i2];
|
|
3341
|
+
let ref3;
|
|
3342
|
+
if (ref3 = isComma(arg)) {
|
|
3343
|
+
const comma = ref3;
|
|
3079
3344
|
comma.token = `)${op.token}(`;
|
|
3080
3345
|
commaCount++;
|
|
3081
3346
|
}
|
|
@@ -3212,9 +3477,9 @@ function replaceNode(node, newNode) {
|
|
|
3212
3477
|
throw new Error("replaceNode failed: node has no parent");
|
|
3213
3478
|
}
|
|
3214
3479
|
function recurse(children) {
|
|
3215
|
-
for (let
|
|
3216
|
-
const i =
|
|
3217
|
-
const child = children[
|
|
3480
|
+
for (let i3 = 0, len2 = children.length; i3 < len2; i3++) {
|
|
3481
|
+
const i = i3;
|
|
3482
|
+
const child = children[i3];
|
|
3218
3483
|
if (child === node) {
|
|
3219
3484
|
children[i] = newNode;
|
|
3220
3485
|
return true;
|
|
@@ -3381,55 +3646,6 @@ function makeGetterMethod(name, ws, value, returnType, block, kind = { token: "g
|
|
|
3381
3646
|
parameters
|
|
3382
3647
|
};
|
|
3383
3648
|
}
|
|
3384
|
-
function processAssignmentDeclaration(decl, pattern, suffix, ws, assign, e) {
|
|
3385
|
-
decl = {
|
|
3386
|
-
...decl,
|
|
3387
|
-
$loc: {
|
|
3388
|
-
pos: assign.$loc.pos - 1,
|
|
3389
|
-
length: assign.$loc.length + 1
|
|
3390
|
-
}
|
|
3391
|
-
};
|
|
3392
|
-
let [splices, assignments] = gatherBindingCode(pattern);
|
|
3393
|
-
splices = splices.map((s) => [", ", s]);
|
|
3394
|
-
const thisAssignments = assignments.map((a) => ["", a, ";"]);
|
|
3395
|
-
const initializer = [ws, assign, e];
|
|
3396
|
-
const binding = makeNode({
|
|
3397
|
-
type: "Binding",
|
|
3398
|
-
pattern,
|
|
3399
|
-
initializer,
|
|
3400
|
-
splices,
|
|
3401
|
-
suffix,
|
|
3402
|
-
thisAssignments,
|
|
3403
|
-
children: [pattern, suffix, initializer]
|
|
3404
|
-
});
|
|
3405
|
-
const children = [decl, binding];
|
|
3406
|
-
return makeNode({
|
|
3407
|
-
type: "Declaration",
|
|
3408
|
-
names: pattern.names,
|
|
3409
|
-
decl,
|
|
3410
|
-
bindings: [binding],
|
|
3411
|
-
splices,
|
|
3412
|
-
thisAssignments,
|
|
3413
|
-
children
|
|
3414
|
-
});
|
|
3415
|
-
}
|
|
3416
|
-
function processDeclarations(statements) {
|
|
3417
|
-
gatherRecursiveAll(statements, ($) => $.type === "Declaration").forEach(({ bindings }) => {
|
|
3418
|
-
return bindings?.forEach((binding) => {
|
|
3419
|
-
const suffix = binding.suffix;
|
|
3420
|
-
if (suffix && suffix.optional && suffix.t) {
|
|
3421
|
-
convertOptionalType(suffix);
|
|
3422
|
-
}
|
|
3423
|
-
const { initializer } = binding;
|
|
3424
|
-
if (initializer) {
|
|
3425
|
-
const exp = initializer[2];
|
|
3426
|
-
return exp;
|
|
3427
|
-
}
|
|
3428
|
-
;
|
|
3429
|
-
return;
|
|
3430
|
-
});
|
|
3431
|
-
});
|
|
3432
|
-
}
|
|
3433
3649
|
function processBindingPatternLHS(lhs, tail) {
|
|
3434
3650
|
adjustAtBindings(lhs, true);
|
|
3435
3651
|
const [splices, thisAssignments] = gatherBindingCode(lhs);
|
|
@@ -3483,8 +3699,25 @@ function processAssignments(statements) {
|
|
|
3483
3699
|
return exp.children.push(...post);
|
|
3484
3700
|
return;
|
|
3485
3701
|
});
|
|
3486
|
-
|
|
3702
|
+
replaceNodesRecursive(statements, (n) => n.type === "AssignmentExpression" && n.names === null, (exp) => {
|
|
3487
3703
|
let { lhs: $1, exp: $2 } = exp, tail = [], i = 0, len = $1.length;
|
|
3704
|
+
let block;
|
|
3705
|
+
if (exp.parent.type === "BlockStatement" && !$1.at(-1)?.at(-1)?.special) {
|
|
3706
|
+
block = makeBlockFragment();
|
|
3707
|
+
let ref4;
|
|
3708
|
+
if (ref4 = prependStatementExpressionBlock([null, null, $2], block)) {
|
|
3709
|
+
const ref = ref4;
|
|
3710
|
+
exp.children = exp.children.map(function(c) {
|
|
3711
|
+
if (c === $2)
|
|
3712
|
+
return ref;
|
|
3713
|
+
else
|
|
3714
|
+
return c;
|
|
3715
|
+
});
|
|
3716
|
+
$2 = ref;
|
|
3717
|
+
} else {
|
|
3718
|
+
block = void 0;
|
|
3719
|
+
}
|
|
3720
|
+
}
|
|
3488
3721
|
if ($1.some((left) => left[left.length - 1].special)) {
|
|
3489
3722
|
if ($1.length !== 1)
|
|
3490
3723
|
throw new Error("Only one assignment with id= is allowed");
|
|
@@ -3499,7 +3732,7 @@ function processAssignments(statements) {
|
|
|
3499
3732
|
exp.exp = $2 = [call, "(", lhs, ", ", $2, ")"]
|
|
3500
3733
|
);
|
|
3501
3734
|
if (omitLhs) {
|
|
3502
|
-
|
|
3735
|
+
return $2;
|
|
3503
3736
|
}
|
|
3504
3737
|
}
|
|
3505
3738
|
let wrapped = false;
|
|
@@ -3544,7 +3777,7 @@ function processAssignments(statements) {
|
|
|
3544
3777
|
}
|
|
3545
3778
|
exp.children = [$1];
|
|
3546
3779
|
exp.names = [];
|
|
3547
|
-
return;
|
|
3780
|
+
return exp;
|
|
3548
3781
|
}
|
|
3549
3782
|
} else if (lhs.type === "ObjectBindingPattern" || lhs.type === "ArrayBindingPattern") {
|
|
3550
3783
|
processBindingPatternLHS(lhs, tail);
|
|
@@ -3556,11 +3789,19 @@ function processAssignments(statements) {
|
|
|
3556
3789
|
const index = exp.children.indexOf($2);
|
|
3557
3790
|
if (index < 0)
|
|
3558
3791
|
throw new Error("Assertion error: exp not in AssignmentExpression");
|
|
3559
|
-
|
|
3792
|
+
exp.children.splice(index + 1, 0, ...tail);
|
|
3793
|
+
if (block) {
|
|
3794
|
+
block.parent = exp.parent;
|
|
3795
|
+
block.expressions.push(["", exp]);
|
|
3796
|
+
exp.parent = block;
|
|
3797
|
+
return block;
|
|
3798
|
+
}
|
|
3799
|
+
return exp;
|
|
3560
3800
|
});
|
|
3561
3801
|
}
|
|
3562
3802
|
function attachPostfixStatementAsExpression(exp, post) {
|
|
3563
|
-
|
|
3803
|
+
const postfixStatement = post[1];
|
|
3804
|
+
switch (postfixStatement.type) {
|
|
3564
3805
|
case "ForStatement":
|
|
3565
3806
|
case "IterationStatement":
|
|
3566
3807
|
case "DoStatement": {
|
|
@@ -3573,9 +3814,9 @@ function attachPostfixStatementAsExpression(exp, post) {
|
|
|
3573
3814
|
};
|
|
3574
3815
|
}
|
|
3575
3816
|
case "IfStatement":
|
|
3576
|
-
return
|
|
3817
|
+
return expressionizeIfStatement({ ...postfixStatement, then: exp });
|
|
3577
3818
|
default:
|
|
3578
|
-
(() => {
|
|
3819
|
+
return (() => {
|
|
3579
3820
|
throw new Error("Unknown postfix statement");
|
|
3580
3821
|
})();
|
|
3581
3822
|
}
|
|
@@ -3614,6 +3855,42 @@ function processTypes(node) {
|
|
|
3614
3855
|
}
|
|
3615
3856
|
});
|
|
3616
3857
|
}
|
|
3858
|
+
function processStatementExpressions(statements) {
|
|
3859
|
+
gatherRecursiveAll(statements, ($) => $.type === "StatementExpression").forEach((_exp) => {
|
|
3860
|
+
const exp = _exp;
|
|
3861
|
+
const { statement } = exp;
|
|
3862
|
+
let ws;
|
|
3863
|
+
if (!(exp.children[0] === exp.statement)) {
|
|
3864
|
+
ws = exp.children[0];
|
|
3865
|
+
}
|
|
3866
|
+
let ref5;
|
|
3867
|
+
switch (statement.type) {
|
|
3868
|
+
case "IfStatement": {
|
|
3869
|
+
if (ref5 = expressionizeIfStatement(statement)) {
|
|
3870
|
+
const expression = ref5;
|
|
3871
|
+
exp.statement = expression;
|
|
3872
|
+
exp.children = [exp.statement];
|
|
3873
|
+
} else {
|
|
3874
|
+
exp.children = wrapIIFE([["", statement]]);
|
|
3875
|
+
}
|
|
3876
|
+
;
|
|
3877
|
+
break;
|
|
3878
|
+
}
|
|
3879
|
+
case "IterationExpression": {
|
|
3880
|
+
;
|
|
3881
|
+
break;
|
|
3882
|
+
}
|
|
3883
|
+
default: {
|
|
3884
|
+
exp.children = wrapIIFE([["", statement]]);
|
|
3885
|
+
}
|
|
3886
|
+
}
|
|
3887
|
+
if (ws) {
|
|
3888
|
+
return exp.children.unshift(ws);
|
|
3889
|
+
}
|
|
3890
|
+
;
|
|
3891
|
+
return;
|
|
3892
|
+
});
|
|
3893
|
+
}
|
|
3617
3894
|
function processProgram(root, config, m, ReservedWord) {
|
|
3618
3895
|
assert.equal(m.forbidBracedApplication.length, 1, "forbidBracedApplication");
|
|
3619
3896
|
assert.equal(m.forbidClassImplicitCall.length, 1, "forbidClassImplicitCall");
|
|
@@ -3628,6 +3905,7 @@ function processProgram(root, config, m, ReservedWord) {
|
|
|
3628
3905
|
processPipelineExpressions(statements);
|
|
3629
3906
|
processDeclarations(statements);
|
|
3630
3907
|
processAssignments(statements);
|
|
3908
|
+
processStatementExpressions(statements);
|
|
3631
3909
|
processPatternMatching(statements, ReservedWord);
|
|
3632
3910
|
gatherRecursiveAll(statements, (n) => n.type === "IterationExpression").forEach((e) => expressionizeIteration(e));
|
|
3633
3911
|
hoistRefDecs(statements);
|
|
@@ -3732,9 +4010,9 @@ function replaceNodes(root, predicate, replacer) {
|
|
|
3732
4010
|
return root;
|
|
3733
4011
|
}
|
|
3734
4012
|
}
|
|
3735
|
-
for (let
|
|
3736
|
-
const i =
|
|
3737
|
-
const node = array[
|
|
4013
|
+
for (let i4 = 0, len3 = array.length; i4 < len3; i4++) {
|
|
4014
|
+
const i = i4;
|
|
4015
|
+
const node = array[i4];
|
|
3738
4016
|
if (!(node != null)) {
|
|
3739
4017
|
return;
|
|
3740
4018
|
}
|
|
@@ -3746,6 +4024,34 @@ function replaceNodes(root, predicate, replacer) {
|
|
|
3746
4024
|
}
|
|
3747
4025
|
return root;
|
|
3748
4026
|
}
|
|
4027
|
+
function replaceNodesRecursive(root, predicate, replacer) {
|
|
4028
|
+
if (!(root != null)) {
|
|
4029
|
+
return root;
|
|
4030
|
+
}
|
|
4031
|
+
const array = Array.isArray(root) ? root : root.children;
|
|
4032
|
+
if (!array) {
|
|
4033
|
+
if (predicate(root)) {
|
|
4034
|
+
return replacer(root, root);
|
|
4035
|
+
} else {
|
|
4036
|
+
return root;
|
|
4037
|
+
}
|
|
4038
|
+
}
|
|
4039
|
+
for (let i5 = 0, len4 = array.length; i5 < len4; i5++) {
|
|
4040
|
+
const i = i5;
|
|
4041
|
+
const node = array[i5];
|
|
4042
|
+
if (!(node != null)) {
|
|
4043
|
+
continue;
|
|
4044
|
+
}
|
|
4045
|
+
if (predicate(node)) {
|
|
4046
|
+
const ret = replacer(node, root);
|
|
4047
|
+
replaceNodesRecursive(ret, predicate, replacer);
|
|
4048
|
+
array[i] = ret;
|
|
4049
|
+
} else {
|
|
4050
|
+
replaceNodesRecursive(node, predicate, replacer);
|
|
4051
|
+
}
|
|
4052
|
+
}
|
|
4053
|
+
return root;
|
|
4054
|
+
}
|
|
3749
4055
|
function typeOfJSX(node, config, getRef) {
|
|
3750
4056
|
switch (node.type) {
|
|
3751
4057
|
case "JSXElement":
|
|
@@ -3810,13 +4116,14 @@ function typeOfJSXFragment(node, config, getRef) {
|
|
|
3810
4116
|
;
|
|
3811
4117
|
return;
|
|
3812
4118
|
}
|
|
3813
|
-
var xor
|
|
4119
|
+
var xor;
|
|
3814
4120
|
var init_lib = __esm({
|
|
3815
4121
|
"source/parser/lib.civet"() {
|
|
3816
4122
|
"use strict";
|
|
3817
4123
|
init_traversal();
|
|
3818
4124
|
init_util();
|
|
3819
4125
|
init_block();
|
|
4126
|
+
init_declaration();
|
|
3820
4127
|
init_pipe();
|
|
3821
4128
|
init_for();
|
|
3822
4129
|
init_function();
|
|
@@ -3827,19 +4134,12 @@ var init_lib = __esm({
|
|
|
3827
4134
|
init_auto_dec();
|
|
3828
4135
|
init_string();
|
|
3829
4136
|
xor = (a, b) => a ? !b && a : b;
|
|
3830
|
-
assert = {
|
|
3831
|
-
equal(a, b, msg) {
|
|
3832
|
-
if (a !== b) {
|
|
3833
|
-
throw new Error(`Assertion failed [${msg}]: ${a} !== ${b}`);
|
|
3834
|
-
}
|
|
3835
|
-
}
|
|
3836
|
-
};
|
|
3837
4137
|
}
|
|
3838
4138
|
});
|
|
3839
4139
|
|
|
3840
|
-
//
|
|
4140
|
+
// ../Hera/dist/machine.js
|
|
3841
4141
|
var require_machine = __commonJS({
|
|
3842
|
-
"
|
|
4142
|
+
"../Hera/dist/machine.js"(exports, module) {
|
|
3843
4143
|
"use strict";
|
|
3844
4144
|
var __defProp2 = Object.defineProperty;
|
|
3845
4145
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -4310,8 +4610,6 @@ var require_parser = __commonJS({
|
|
|
4310
4610
|
$TV,
|
|
4311
4611
|
$Y,
|
|
4312
4612
|
Parser,
|
|
4313
|
-
ParserContext,
|
|
4314
|
-
ParserOptions,
|
|
4315
4613
|
Validator
|
|
4316
4614
|
} = require_machine();
|
|
4317
4615
|
var grammar = {
|
|
@@ -4328,7 +4626,7 @@ var require_parser = __commonJS({
|
|
|
4328
4626
|
NestedNonAssignmentExtendedExpression,
|
|
4329
4627
|
ExpressionizedStatementWithTrailingCallExpressions,
|
|
4330
4628
|
ExpressionizedStatement,
|
|
4331
|
-
|
|
4629
|
+
StatementExpression,
|
|
4332
4630
|
CommaExpression,
|
|
4333
4631
|
Arguments,
|
|
4334
4632
|
ImplicitArguments,
|
|
@@ -4590,14 +4888,6 @@ var require_parser = __commonJS({
|
|
|
4590
4888
|
ElseClause,
|
|
4591
4889
|
IfClause,
|
|
4592
4890
|
UnlessClause,
|
|
4593
|
-
IfExpression,
|
|
4594
|
-
UnlessExpression,
|
|
4595
|
-
ElseExpressionClause,
|
|
4596
|
-
ExpressionBlock,
|
|
4597
|
-
ElseExpressionBlock,
|
|
4598
|
-
NestedBlockExpressions,
|
|
4599
|
-
NestedBlockExpression,
|
|
4600
|
-
BlockExpressionPart,
|
|
4601
4891
|
IterationStatement,
|
|
4602
4892
|
_IterationStatement,
|
|
4603
4893
|
IterationExpression,
|
|
@@ -4621,7 +4911,6 @@ var require_parser = __commonJS({
|
|
|
4621
4911
|
ForBinding,
|
|
4622
4912
|
SwitchStatement,
|
|
4623
4913
|
EmptyCondition,
|
|
4624
|
-
SwitchExpression,
|
|
4625
4914
|
CaseBlock,
|
|
4626
4915
|
NestedCaseClauses,
|
|
4627
4916
|
NestedCaseClause,
|
|
@@ -4633,7 +4922,6 @@ var require_parser = __commonJS({
|
|
|
4633
4922
|
ImpliedColon,
|
|
4634
4923
|
IgnoreColon,
|
|
4635
4924
|
TryStatement,
|
|
4636
|
-
TryExpression,
|
|
4637
4925
|
CatchClause,
|
|
4638
4926
|
CatchBind,
|
|
4639
4927
|
FinallyClause,
|
|
@@ -4674,8 +4962,6 @@ var require_parser = __commonJS({
|
|
|
4674
4962
|
Break,
|
|
4675
4963
|
Continue,
|
|
4676
4964
|
Debugger,
|
|
4677
|
-
DebuggerExpression,
|
|
4678
|
-
ThrowExpression,
|
|
4679
4965
|
MaybeNestedExpression,
|
|
4680
4966
|
ImportDeclaration,
|
|
4681
4967
|
ImpliedImport,
|
|
@@ -5505,22 +5791,26 @@ var require_parser = __commonJS({
|
|
|
5505
5791
|
function ExpressionizedStatementWithTrailingCallExpressions(ctx, state) {
|
|
5506
5792
|
return $EVENT(ctx, state, "ExpressionizedStatementWithTrailingCallExpressions", ExpressionizedStatementWithTrailingCallExpressions$0);
|
|
5507
5793
|
}
|
|
5508
|
-
var ExpressionizedStatement$0 = $
|
|
5509
|
-
|
|
5794
|
+
var ExpressionizedStatement$0 = $TS($S($EXPECT($R0, "ExpressionizedStatement /(?=async|debugger|if|unless|do|for|loop|until|while|switch|throw|try)/"), StatementExpression), function($skip, $loc, $0, $1, $2) {
|
|
5795
|
+
var statement = $2;
|
|
5796
|
+
return {
|
|
5797
|
+
type: "StatementExpression",
|
|
5798
|
+
statement,
|
|
5799
|
+
children: [statement]
|
|
5800
|
+
};
|
|
5510
5801
|
});
|
|
5511
5802
|
function ExpressionizedStatement(ctx, state) {
|
|
5512
5803
|
return $EVENT(ctx, state, "ExpressionizedStatement", ExpressionizedStatement$0);
|
|
5513
5804
|
}
|
|
5514
|
-
var
|
|
5515
|
-
var
|
|
5516
|
-
var
|
|
5517
|
-
var
|
|
5518
|
-
var
|
|
5519
|
-
var
|
|
5520
|
-
var
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
return $EVENT_C(ctx, state, "_ExpressionizedStatement", _ExpressionizedStatement$$);
|
|
5805
|
+
var StatementExpression$0 = DebuggerStatement;
|
|
5806
|
+
var StatementExpression$1 = IfStatement;
|
|
5807
|
+
var StatementExpression$2 = IterationExpression;
|
|
5808
|
+
var StatementExpression$3 = SwitchStatement;
|
|
5809
|
+
var StatementExpression$4 = ThrowStatement;
|
|
5810
|
+
var StatementExpression$5 = TryStatement;
|
|
5811
|
+
var StatementExpression$$ = [StatementExpression$0, StatementExpression$1, StatementExpression$2, StatementExpression$3, StatementExpression$4, StatementExpression$5];
|
|
5812
|
+
function StatementExpression(ctx, state) {
|
|
5813
|
+
return $EVENT_C(ctx, state, "StatementExpression", StatementExpression$$);
|
|
5524
5814
|
}
|
|
5525
5815
|
var CommaExpression$0 = $TS($S(AssignmentExpression, $Q($S(CommaDelimiter, AssignmentExpression))), function($skip, $loc, $0, $1, $2) {
|
|
5526
5816
|
if ($2.length == 0)
|
|
@@ -5546,14 +5836,8 @@ var require_parser = __commonJS({
|
|
|
5546
5836
|
var ws = $3;
|
|
5547
5837
|
var args = $4;
|
|
5548
5838
|
var close = $5;
|
|
5549
|
-
if (args
|
|
5550
|
-
|
|
5551
|
-
if (Array.isArray(arg0))
|
|
5552
|
-
arg0 = arg0[1];
|
|
5553
|
-
if (arg0.type === "IterationExpression" && arg0.subtype !== "DoStatement" && !arg0.async && isEmptyBareBlock(arg0.block)) {
|
|
5554
|
-
return $skip;
|
|
5555
|
-
}
|
|
5556
|
-
}
|
|
5839
|
+
if (skipImplicitArguments(args))
|
|
5840
|
+
return $skip;
|
|
5557
5841
|
return {
|
|
5558
5842
|
type: "Call",
|
|
5559
5843
|
args,
|
|
@@ -6111,8 +6395,12 @@ var require_parser = __commonJS({
|
|
|
6111
6395
|
function PipelineHeadItem(ctx, state) {
|
|
6112
6396
|
return $EVENT_C(ctx, state, "PipelineHeadItem", PipelineHeadItem$$);
|
|
6113
6397
|
}
|
|
6114
|
-
var PipelineTailItem$0 =
|
|
6115
|
-
|
|
6398
|
+
var PipelineTailItem$0 = $T($S(AwaitOp, $N(AccessStart)), function(value) {
|
|
6399
|
+
return value[0];
|
|
6400
|
+
});
|
|
6401
|
+
var PipelineTailItem$1 = $T($S(Yield, $N(AccessStart)), function(value) {
|
|
6402
|
+
return value[0];
|
|
6403
|
+
});
|
|
6116
6404
|
var PipelineTailItem$2 = $T($S(Return, $N(AccessStart)), function(value) {
|
|
6117
6405
|
return value[0];
|
|
6118
6406
|
});
|
|
@@ -6148,6 +6436,9 @@ var require_parser = __commonJS({
|
|
|
6148
6436
|
return $skip;
|
|
6149
6437
|
const [exp, ws, close] = $3;
|
|
6150
6438
|
switch (exp.type) {
|
|
6439
|
+
case "StatementExpression":
|
|
6440
|
+
if (exp.statement.type !== "IterationExpression")
|
|
6441
|
+
break;
|
|
6151
6442
|
case "IterationExpression":
|
|
6152
6443
|
return exp;
|
|
6153
6444
|
case "ParenthesizedExpression":
|
|
@@ -7675,7 +7966,7 @@ var require_parser = __commonJS({
|
|
|
7675
7966
|
if (prefix.length) {
|
|
7676
7967
|
body = {
|
|
7677
7968
|
type: "UnaryExpression",
|
|
7678
|
-
children: [prefix, body, void 0]
|
|
7969
|
+
children: [processUnaryExpression(prefix, body, void 0)]
|
|
7679
7970
|
};
|
|
7680
7971
|
}
|
|
7681
7972
|
const parameters = {
|
|
@@ -9632,7 +9923,13 @@ var require_parser = __commonJS({
|
|
|
9632
9923
|
return { $loc, token: $0 };
|
|
9633
9924
|
});
|
|
9634
9925
|
var UnaryOp$1 = AwaitOp;
|
|
9635
|
-
var UnaryOp$2 = $S($C(Delete, Void, Typeof), $N($
|
|
9926
|
+
var UnaryOp$2 = $TS($S($C(Delete, Void, Typeof), $N($EXPECT($R21, "UnaryOp /[:.]/")), $E(_)), function($skip, $loc, $0, $1, $2, $3) {
|
|
9927
|
+
var op = $1;
|
|
9928
|
+
var ws = $3;
|
|
9929
|
+
if (!ws)
|
|
9930
|
+
return [op, [" "]];
|
|
9931
|
+
return [op, ws];
|
|
9932
|
+
});
|
|
9636
9933
|
var UnaryOp$3 = $T($S(Not, $N($EXPECT($R21, "UnaryOp /[:.]/")), $E($EXPECT($L16, 'UnaryOp " "')), $E(_)), function(value) {
|
|
9637
9934
|
return [value[0], value[3]];
|
|
9638
9935
|
});
|
|
@@ -9640,18 +9937,15 @@ var require_parser = __commonJS({
|
|
|
9640
9937
|
function UnaryOp(ctx, state) {
|
|
9641
9938
|
return $EVENT_C(ctx, state, "UnaryOp", UnaryOp$$);
|
|
9642
9939
|
}
|
|
9643
|
-
var AwaitOp$0 = $TS($S(Await, $E($S(Dot, IdentifierName)), $
|
|
9940
|
+
var AwaitOp$0 = $TS($S(Await, $E($S(Dot, IdentifierName)), $E(_)), function($skip, $loc, $0, $1, $2, $3) {
|
|
9644
9941
|
var a = $1;
|
|
9645
9942
|
var op = $2;
|
|
9646
9943
|
var ws = $3;
|
|
9647
|
-
|
|
9648
|
-
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
};
|
|
9653
|
-
}
|
|
9654
|
-
return [a, ...ws || []];
|
|
9944
|
+
return {
|
|
9945
|
+
...a,
|
|
9946
|
+
op,
|
|
9947
|
+
children: [a, ...ws || [" "]]
|
|
9948
|
+
};
|
|
9655
9949
|
});
|
|
9656
9950
|
function AwaitOp(ctx, state) {
|
|
9657
9951
|
return $EVENT(ctx, state, "AwaitOp", AwaitOp$0);
|
|
@@ -9864,120 +10158,6 @@ var require_parser = __commonJS({
|
|
|
9864
10158
|
function UnlessClause(ctx, state) {
|
|
9865
10159
|
return $EVENT(ctx, state, "UnlessClause", UnlessClause$0);
|
|
9866
10160
|
}
|
|
9867
|
-
var IfExpression$0 = $TS($S(IfClause, ExpressionBlock, $E(ElseExpressionClause)), function($skip, $loc, $0, $1, $2, $3) {
|
|
9868
|
-
var clause = $1;
|
|
9869
|
-
var b = $2;
|
|
9870
|
-
var e = $3;
|
|
9871
|
-
return expressionizeIfClause(clause, b, e);
|
|
9872
|
-
});
|
|
9873
|
-
function IfExpression(ctx, state) {
|
|
9874
|
-
return $EVENT(ctx, state, "IfExpression", IfExpression$0);
|
|
9875
|
-
}
|
|
9876
|
-
var UnlessExpression$0 = $TS($S(UnlessClause, ExpressionBlock, $E(ElseExpressionClause)), function($skip, $loc, $0, $1, $2, $3) {
|
|
9877
|
-
var clause = $1;
|
|
9878
|
-
var b = $2;
|
|
9879
|
-
var e = $3;
|
|
9880
|
-
return expressionizeIfClause(clause, b, e);
|
|
9881
|
-
});
|
|
9882
|
-
function UnlessExpression(ctx, state) {
|
|
9883
|
-
return $EVENT(ctx, state, "UnlessExpression", UnlessExpression$0);
|
|
9884
|
-
}
|
|
9885
|
-
var ElseExpressionClause$0 = $TS($S($C($S(Nested, Else), $S($E(_), Else)), ElseExpressionBlock), function($skip, $loc, $0, $1, $2) {
|
|
9886
|
-
return [...$1, $2];
|
|
9887
|
-
});
|
|
9888
|
-
function ElseExpressionClause(ctx, state) {
|
|
9889
|
-
return $EVENT(ctx, state, "ElseExpressionClause", ElseExpressionClause$0);
|
|
9890
|
-
}
|
|
9891
|
-
var ExpressionBlock$0 = $TS($S(InsertOpenParen, NestedBlockExpressions, InsertNewline, InsertIndent, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
9892
|
-
var exps = $2;
|
|
9893
|
-
exps = exps.flat();
|
|
9894
|
-
if (exps.length === 1) {
|
|
9895
|
-
let [ws, exp] = exps[0];
|
|
9896
|
-
switch (exp.type) {
|
|
9897
|
-
case "Identifier":
|
|
9898
|
-
case "Literal":
|
|
9899
|
-
return [ws, exp];
|
|
9900
|
-
}
|
|
9901
|
-
}
|
|
9902
|
-
exps = exps.map((e, i) => {
|
|
9903
|
-
if (i === exps.length - 1) {
|
|
9904
|
-
return e.slice(0, -1);
|
|
9905
|
-
}
|
|
9906
|
-
return e;
|
|
9907
|
-
});
|
|
9908
|
-
return {
|
|
9909
|
-
type: "BlockExpressions",
|
|
9910
|
-
expressions: exps,
|
|
9911
|
-
children: [$1, exps, $3, $4, $5]
|
|
9912
|
-
};
|
|
9913
|
-
});
|
|
9914
|
-
var ExpressionBlock$1 = $S(Then, ExtendedExpression);
|
|
9915
|
-
var ExpressionBlock$$ = [ExpressionBlock$0, ExpressionBlock$1];
|
|
9916
|
-
function ExpressionBlock(ctx, state) {
|
|
9917
|
-
return $EVENT_C(ctx, state, "ExpressionBlock", ExpressionBlock$$);
|
|
9918
|
-
}
|
|
9919
|
-
var ElseExpressionBlock$0 = $TS($S(InsertOpenParen, NestedBlockExpressions, InsertNewline, InsertIndent, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
9920
|
-
var exps = $2;
|
|
9921
|
-
exps = exps.flat();
|
|
9922
|
-
if (exps.length === 1) {
|
|
9923
|
-
let [ws, exp] = exps[0];
|
|
9924
|
-
switch (exp.type) {
|
|
9925
|
-
case "Identifier":
|
|
9926
|
-
case "Literal":
|
|
9927
|
-
return [ws, exp];
|
|
9928
|
-
}
|
|
9929
|
-
}
|
|
9930
|
-
exps = exps.map((e, i) => {
|
|
9931
|
-
if (i === exps.length - 1) {
|
|
9932
|
-
return e.slice(0, -1);
|
|
9933
|
-
}
|
|
9934
|
-
return e;
|
|
9935
|
-
});
|
|
9936
|
-
return {
|
|
9937
|
-
type: "BlockExpressions",
|
|
9938
|
-
expressions: exps,
|
|
9939
|
-
children: [$1, exps, $3, $4, $5]
|
|
9940
|
-
};
|
|
9941
|
-
});
|
|
9942
|
-
var ElseExpressionBlock$1 = $T($S($N(EOS), ExpressionWithObjectApplicationForbidden), function(value) {
|
|
9943
|
-
return value[1];
|
|
9944
|
-
});
|
|
9945
|
-
var ElseExpressionBlock$$ = [ElseExpressionBlock$0, ElseExpressionBlock$1];
|
|
9946
|
-
function ElseExpressionBlock(ctx, state) {
|
|
9947
|
-
return $EVENT_C(ctx, state, "ElseExpressionBlock", ElseExpressionBlock$$);
|
|
9948
|
-
}
|
|
9949
|
-
var NestedBlockExpressions$0 = $TS($S(PushIndent, $Q(NestedBlockExpression), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
|
|
9950
|
-
var exps = $2;
|
|
9951
|
-
if (!exps.length)
|
|
9952
|
-
return $skip;
|
|
9953
|
-
return exps;
|
|
9954
|
-
});
|
|
9955
|
-
function NestedBlockExpressions(ctx, state) {
|
|
9956
|
-
return $EVENT(ctx, state, "NestedBlockExpressions", NestedBlockExpressions$0);
|
|
9957
|
-
}
|
|
9958
|
-
var NestedBlockExpression$0 = $TS($S(Nested, $P(BlockExpressionPart)), function($skip, $loc, $0, $1, $2) {
|
|
9959
|
-
var nested = $1;
|
|
9960
|
-
var expressions = $2;
|
|
9961
|
-
return [
|
|
9962
|
-
[nested, ...expressions[0]],
|
|
9963
|
-
...expressions.slice(1).map((s) => ["", ...s])
|
|
9964
|
-
];
|
|
9965
|
-
});
|
|
9966
|
-
function NestedBlockExpression(ctx, state) {
|
|
9967
|
-
return $EVENT(ctx, state, "NestedBlockExpression", NestedBlockExpression$0);
|
|
9968
|
-
}
|
|
9969
|
-
var BlockExpressionPart$0 = $TS($S($N(EOS), $E(_), PostfixedExpression, ExpressionDelimiter), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
9970
|
-
var ws = $2;
|
|
9971
|
-
var exp = $3;
|
|
9972
|
-
var delimiter = $4;
|
|
9973
|
-
if (ws) {
|
|
9974
|
-
exp = { ...exp, children: [ws, ...exp.children] };
|
|
9975
|
-
}
|
|
9976
|
-
return [exp, delimiter];
|
|
9977
|
-
});
|
|
9978
|
-
function BlockExpressionPart(ctx, state) {
|
|
9979
|
-
return $EVENT(ctx, state, "BlockExpressionPart", BlockExpressionPart$0);
|
|
9980
|
-
}
|
|
9981
10161
|
var IterationStatement$0 = $T($S($EXPECT($R23, "IterationStatement /(?=loop|do|for|until|while)/"), _IterationStatement), function(value) {
|
|
9982
10162
|
return value[1];
|
|
9983
10163
|
});
|
|
@@ -10394,18 +10574,6 @@ var require_parser = __commonJS({
|
|
|
10394
10574
|
function EmptyCondition(ctx, state) {
|
|
10395
10575
|
return $EVENT(ctx, state, "EmptyCondition", EmptyCondition$0);
|
|
10396
10576
|
}
|
|
10397
|
-
var SwitchExpression$0 = $TV(SwitchStatement, function($skip, $loc, $0, $1) {
|
|
10398
|
-
var s = $0;
|
|
10399
|
-
return {
|
|
10400
|
-
type: "SwitchExpression",
|
|
10401
|
-
// wrap with IIFE
|
|
10402
|
-
children: wrapIIFE([["", s]]),
|
|
10403
|
-
statement: s
|
|
10404
|
-
};
|
|
10405
|
-
});
|
|
10406
|
-
function SwitchExpression(ctx, state) {
|
|
10407
|
-
return $EVENT(ctx, state, "SwitchExpression", SwitchExpression$0);
|
|
10408
|
-
}
|
|
10409
10577
|
var CaseBlock$0 = $TS($S($E($C(Nested, _)), OpenBrace, NestedCaseClauses, __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
10410
10578
|
var clauses = $3;
|
|
10411
10579
|
return {
|
|
@@ -10587,17 +10755,6 @@ var require_parser = __commonJS({
|
|
|
10587
10755
|
function TryStatement(ctx, state) {
|
|
10588
10756
|
return $EVENT(ctx, state, "TryStatement", TryStatement$0);
|
|
10589
10757
|
}
|
|
10590
|
-
var TryExpression$0 = $TV(TryStatement, function($skip, $loc, $0, $1) {
|
|
10591
|
-
var t = $0;
|
|
10592
|
-
return {
|
|
10593
|
-
type: "TryExpression",
|
|
10594
|
-
blocks: t.blocks,
|
|
10595
|
-
children: wrapIIFE([["", t]])
|
|
10596
|
-
};
|
|
10597
|
-
});
|
|
10598
|
-
function TryExpression(ctx, state) {
|
|
10599
|
-
return $EVENT(ctx, state, "TryExpression", TryExpression$0);
|
|
10600
|
-
}
|
|
10601
10758
|
var CatchClause$0 = $TS($S($C(Nested, _), Catch, $E(CatchBind), $C(BracedThenClause, BracedOrEmptyBlock)), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
10602
10759
|
var block = $4;
|
|
10603
10760
|
return {
|
|
@@ -10932,26 +11089,6 @@ var require_parser = __commonJS({
|
|
|
10932
11089
|
function Debugger(ctx, state) {
|
|
10933
11090
|
return $EVENT(ctx, state, "Debugger", Debugger$0);
|
|
10934
11091
|
}
|
|
10935
|
-
var DebuggerExpression$0 = $TV(DebuggerStatement, function($skip, $loc, $0, $1) {
|
|
10936
|
-
var s = $0;
|
|
10937
|
-
return {
|
|
10938
|
-
type: "DebuggerExpression",
|
|
10939
|
-
children: wrapIIFE([["", s]])
|
|
10940
|
-
};
|
|
10941
|
-
});
|
|
10942
|
-
function DebuggerExpression(ctx, state) {
|
|
10943
|
-
return $EVENT(ctx, state, "DebuggerExpression", DebuggerExpression$0);
|
|
10944
|
-
}
|
|
10945
|
-
var ThrowExpression$0 = $TV(ThrowStatement, function($skip, $loc, $0, $1) {
|
|
10946
|
-
var s = $0;
|
|
10947
|
-
return {
|
|
10948
|
-
type: "ThrowExpression",
|
|
10949
|
-
children: wrapIIFE([["", s]])
|
|
10950
|
-
};
|
|
10951
|
-
});
|
|
10952
|
-
function ThrowExpression(ctx, state) {
|
|
10953
|
-
return $EVENT(ctx, state, "ThrowExpression", ThrowExpression$0);
|
|
10954
|
-
}
|
|
10955
11092
|
var MaybeNestedExpression$0 = $TS($S($N(EOS), ExtendedExpression), function($skip, $loc, $0, $1, $2) {
|
|
10956
11093
|
return $2;
|
|
10957
11094
|
});
|
|
@@ -14069,7 +14206,9 @@ var require_parser = __commonJS({
|
|
|
14069
14206
|
function TripleSlashDirective(ctx, state) {
|
|
14070
14207
|
return $EVENT(ctx, state, "TripleSlashDirective", TripleSlashDirective$0);
|
|
14071
14208
|
}
|
|
14072
|
-
var DirectivePrologue$0 = PrologueString
|
|
14209
|
+
var DirectivePrologue$0 = $T($S(PrologueString, $N($S(__, $C(AccessStart, Pipe)))), function(value) {
|
|
14210
|
+
return value[0];
|
|
14211
|
+
});
|
|
14073
14212
|
function DirectivePrologue(ctx, state) {
|
|
14074
14213
|
return $EVENT(ctx, state, "DirectivePrologue", DirectivePrologue$0);
|
|
14075
14214
|
}
|
|
@@ -14604,9 +14743,9 @@ var require_parser = __commonJS({
|
|
|
14604
14743
|
}
|
|
14605
14744
|
}
|
|
14606
14745
|
});
|
|
14607
|
-
if (typeof
|
|
14608
|
-
Object.assign(module.config,
|
|
14609
|
-
|
|
14746
|
+
if (typeof parse2 !== "undefined") {
|
|
14747
|
+
Object.assign(module.config, parse2.config);
|
|
14748
|
+
parse2.config = module.config;
|
|
14610
14749
|
} else {
|
|
14611
14750
|
Object.assign(module.config, exports.parse.config);
|
|
14612
14751
|
exports.parse.config = module.config;
|
|
@@ -14757,7 +14896,7 @@ var require_parser = __commonJS({
|
|
|
14757
14896
|
};
|
|
14758
14897
|
}();
|
|
14759
14898
|
exports.default = parser;
|
|
14760
|
-
exports.parse = parser.parse;
|
|
14899
|
+
var parse2 = exports.parse = parser.parse;
|
|
14761
14900
|
exports.Program = Program;
|
|
14762
14901
|
exports.TopLevelStatements = TopLevelStatements;
|
|
14763
14902
|
exports.NestedTopLevelStatements = NestedTopLevelStatements;
|
|
@@ -14771,7 +14910,7 @@ var require_parser = __commonJS({
|
|
|
14771
14910
|
exports.NestedNonAssignmentExtendedExpression = NestedNonAssignmentExtendedExpression;
|
|
14772
14911
|
exports.ExpressionizedStatementWithTrailingCallExpressions = ExpressionizedStatementWithTrailingCallExpressions;
|
|
14773
14912
|
exports.ExpressionizedStatement = ExpressionizedStatement;
|
|
14774
|
-
exports.
|
|
14913
|
+
exports.StatementExpression = StatementExpression;
|
|
14775
14914
|
exports.CommaExpression = CommaExpression;
|
|
14776
14915
|
exports.Arguments = Arguments;
|
|
14777
14916
|
exports.ImplicitArguments = ImplicitArguments;
|
|
@@ -15033,14 +15172,6 @@ var require_parser = __commonJS({
|
|
|
15033
15172
|
exports.ElseClause = ElseClause;
|
|
15034
15173
|
exports.IfClause = IfClause;
|
|
15035
15174
|
exports.UnlessClause = UnlessClause;
|
|
15036
|
-
exports.IfExpression = IfExpression;
|
|
15037
|
-
exports.UnlessExpression = UnlessExpression;
|
|
15038
|
-
exports.ElseExpressionClause = ElseExpressionClause;
|
|
15039
|
-
exports.ExpressionBlock = ExpressionBlock;
|
|
15040
|
-
exports.ElseExpressionBlock = ElseExpressionBlock;
|
|
15041
|
-
exports.NestedBlockExpressions = NestedBlockExpressions;
|
|
15042
|
-
exports.NestedBlockExpression = NestedBlockExpression;
|
|
15043
|
-
exports.BlockExpressionPart = BlockExpressionPart;
|
|
15044
15175
|
exports.IterationStatement = IterationStatement;
|
|
15045
15176
|
exports._IterationStatement = _IterationStatement;
|
|
15046
15177
|
exports.IterationExpression = IterationExpression;
|
|
@@ -15064,7 +15195,6 @@ var require_parser = __commonJS({
|
|
|
15064
15195
|
exports.ForBinding = ForBinding;
|
|
15065
15196
|
exports.SwitchStatement = SwitchStatement;
|
|
15066
15197
|
exports.EmptyCondition = EmptyCondition;
|
|
15067
|
-
exports.SwitchExpression = SwitchExpression;
|
|
15068
15198
|
exports.CaseBlock = CaseBlock;
|
|
15069
15199
|
exports.NestedCaseClauses = NestedCaseClauses;
|
|
15070
15200
|
exports.NestedCaseClause = NestedCaseClause;
|
|
@@ -15076,7 +15206,6 @@ var require_parser = __commonJS({
|
|
|
15076
15206
|
exports.ImpliedColon = ImpliedColon;
|
|
15077
15207
|
exports.IgnoreColon = IgnoreColon;
|
|
15078
15208
|
exports.TryStatement = TryStatement;
|
|
15079
|
-
exports.TryExpression = TryExpression;
|
|
15080
15209
|
exports.CatchClause = CatchClause;
|
|
15081
15210
|
exports.CatchBind = CatchBind;
|
|
15082
15211
|
exports.FinallyClause = FinallyClause;
|
|
@@ -15117,8 +15246,6 @@ var require_parser = __commonJS({
|
|
|
15117
15246
|
exports.Break = Break;
|
|
15118
15247
|
exports.Continue = Continue;
|
|
15119
15248
|
exports.Debugger = Debugger;
|
|
15120
|
-
exports.DebuggerExpression = DebuggerExpression;
|
|
15121
|
-
exports.ThrowExpression = ThrowExpression;
|
|
15122
15249
|
exports.MaybeNestedExpression = MaybeNestedExpression;
|
|
15123
15250
|
exports.ImportDeclaration = ImportDeclaration;
|
|
15124
15251
|
exports.ImpliedImport = ImpliedImport;
|