@danielx/civet 0.7.29 → 0.7.31
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/CHANGELOG.md +10 -0
- package/README.md +2 -1
- package/dist/browser.js +360 -118
- package/dist/civet +1 -0
- package/dist/main.js +280 -105
- package/dist/main.mjs +280 -105
- package/package.json +2 -2
package/dist/civet
CHANGED
|
@@ -516,6 +516,7 @@ Options:
|
|
|
516
516
|
--no-cache Disable compiler caching (slow, for debugging)
|
|
517
517
|
--typecheck Run TypeScript and output diagnostics
|
|
518
518
|
--emit-declaration Run TypeScript and emit .d.ts files (if no errors)
|
|
519
|
+
--trace XX Log detailed parsing notes to a file, for parser debugging
|
|
519
520
|
|
|
520
521
|
You can use - to read from stdin or (prefixed by -o) write to stdout.
|
|
521
522
|
|
package/dist/main.js
CHANGED
|
@@ -678,7 +678,7 @@ var statementTypes = /* @__PURE__ */ new Set([
|
|
|
678
678
|
"ForStatement",
|
|
679
679
|
"IfStatement",
|
|
680
680
|
"IterationStatement",
|
|
681
|
-
"
|
|
681
|
+
"LabelledStatement",
|
|
682
682
|
"ReturnStatement",
|
|
683
683
|
"SwitchStatement",
|
|
684
684
|
"ThrowStatement",
|
|
@@ -723,13 +723,16 @@ function isExit(node) {
|
|
|
723
723
|
return node.expressions.some((s) => isExit(s[1]));
|
|
724
724
|
}
|
|
725
725
|
case "IterationStatement": {
|
|
726
|
-
return node
|
|
726
|
+
return isLoopStatement(node) && gatherRecursiveWithinFunction(node.block, ($) => $.type === "BreakStatement").length === 0;
|
|
727
727
|
}
|
|
728
728
|
default: {
|
|
729
729
|
return false;
|
|
730
730
|
}
|
|
731
731
|
}
|
|
732
732
|
}
|
|
733
|
+
function isLoopStatement(node) {
|
|
734
|
+
return node.type === "IterationStatement" && node.condition?.type === "ParenthesizedExpression" && node.condition.expression?.type === "Literal" && node.condition.expression?.raw === "true";
|
|
735
|
+
}
|
|
733
736
|
function isComma(node) {
|
|
734
737
|
if (node?.token === ",") {
|
|
735
738
|
return node;
|
|
@@ -1095,7 +1098,7 @@ function parenthesizeType(type) {
|
|
|
1095
1098
|
}
|
|
1096
1099
|
return ["(", type, ")"];
|
|
1097
1100
|
}
|
|
1098
|
-
function wrapIIFE(expressions, asyncFlag) {
|
|
1101
|
+
function wrapIIFE(expressions, asyncFlag, generator) {
|
|
1099
1102
|
let prefix;
|
|
1100
1103
|
const async = [];
|
|
1101
1104
|
if (asyncFlag) {
|
|
@@ -1121,23 +1124,49 @@ function wrapIIFE(expressions, asyncFlag) {
|
|
|
1121
1124
|
};
|
|
1122
1125
|
const signature = {
|
|
1123
1126
|
modifier: {
|
|
1124
|
-
async: !!async.length
|
|
1127
|
+
async: !!async.length,
|
|
1128
|
+
generator: !!generator
|
|
1125
1129
|
},
|
|
1126
1130
|
returnType: void 0
|
|
1127
1131
|
};
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1132
|
+
let fn;
|
|
1133
|
+
if (generator) {
|
|
1134
|
+
fn = makeNode({
|
|
1135
|
+
type: "FunctionExpression",
|
|
1136
|
+
signature,
|
|
1137
|
+
parameters,
|
|
1138
|
+
returnType: void 0,
|
|
1139
|
+
ts: false,
|
|
1140
|
+
async,
|
|
1141
|
+
block,
|
|
1142
|
+
generator,
|
|
1143
|
+
children: [async, "function", generator, parameters, block]
|
|
1144
|
+
});
|
|
1145
|
+
} else {
|
|
1146
|
+
fn = makeNode({
|
|
1147
|
+
type: "ArrowFunction",
|
|
1148
|
+
signature,
|
|
1149
|
+
parameters,
|
|
1150
|
+
returnType: void 0,
|
|
1151
|
+
ts: false,
|
|
1152
|
+
async,
|
|
1153
|
+
block,
|
|
1154
|
+
children: [async, parameters, "=>", block]
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
const children = [makeLeftHandSideExpression(fn), "()"];
|
|
1158
|
+
if (fn.type === "FunctionExpression") {
|
|
1159
|
+
if (gatherRecursiveWithinFunction(block, (a1) => typeof a1 === "object" && a1 != null && "token" in a1 && a1.token === "this").length) {
|
|
1160
|
+
children.splice(1, 0, ".bind(this)");
|
|
1161
|
+
}
|
|
1162
|
+
if (gatherRecursiveWithinFunction(block, (a2) => typeof a2 === "object" && a2 != null && "token" in a2 && a2.token === "arguments").length) {
|
|
1163
|
+
let ref2;
|
|
1164
|
+
children[children.length - 1] = (ref2 = parameters.children)[ref2.length - 1] = "(arguments)";
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1138
1167
|
const exp = makeNode({
|
|
1139
1168
|
type: "CallExpression",
|
|
1140
|
-
children
|
|
1169
|
+
children
|
|
1141
1170
|
});
|
|
1142
1171
|
if (prefix) {
|
|
1143
1172
|
return makeLeftHandSideExpression([prefix, exp]);
|
|
@@ -1758,7 +1787,7 @@ function assignResults(node, collect) {
|
|
|
1758
1787
|
({ type } = exp);
|
|
1759
1788
|
}
|
|
1760
1789
|
let ref4;
|
|
1761
|
-
switch (
|
|
1790
|
+
switch (type) {
|
|
1762
1791
|
case "BreakStatement":
|
|
1763
1792
|
case "ContinueStatement":
|
|
1764
1793
|
case "DebuggerStatement":
|
|
@@ -1979,6 +2008,58 @@ function insertSwitchReturns(exp) {
|
|
|
1979
2008
|
return insertReturn(clause);
|
|
1980
2009
|
});
|
|
1981
2010
|
}
|
|
2011
|
+
function processBreakContinueWith(statement) {
|
|
2012
|
+
let changed = false;
|
|
2013
|
+
for (const control of gatherRecursiveWithinFunction(
|
|
2014
|
+
statement.block,
|
|
2015
|
+
($) => $.type === "BreakStatement" || $.type === "ContinueStatement"
|
|
2016
|
+
)) {
|
|
2017
|
+
let controlName2 = function() {
|
|
2018
|
+
switch (control.type) {
|
|
2019
|
+
case "BreakStatement": {
|
|
2020
|
+
return "break";
|
|
2021
|
+
}
|
|
2022
|
+
case "ContinueStatement": {
|
|
2023
|
+
return "continue";
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
};
|
|
2027
|
+
var controlName = controlName2;
|
|
2028
|
+
if (control.with) {
|
|
2029
|
+
if (control.label) {
|
|
2030
|
+
let m1;
|
|
2031
|
+
if (!(m1 = statement.parent, typeof m1 === "object" && m1 != null && "type" in m1 && m1.type === "LabelledStatement" && "label" in m1 && typeof m1.label === "object" && m1.label != null && "name" in m1.label && m1.label.name === control.label.name)) {
|
|
2032
|
+
continue;
|
|
2033
|
+
}
|
|
2034
|
+
} else {
|
|
2035
|
+
const { ancestor } = findAncestor(
|
|
2036
|
+
control,
|
|
2037
|
+
(s) => s === statement || s.type === "IterationStatement" || s.type === "ForStatement" || s.type === "SwitchStatement" && control.type === "BreakStatement"
|
|
2038
|
+
);
|
|
2039
|
+
if (!(ancestor === statement)) {
|
|
2040
|
+
continue;
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
control.children.unshift(
|
|
2044
|
+
control.type === "BreakStatement" ? (changed = true, [statement.resultsRef, " =", control.with, ";"]) : (
|
|
2045
|
+
// control.type is "ContinueStatement"
|
|
2046
|
+
[statement.resultsRef, ".push(", trimFirstSpace(control.with), ");"]
|
|
2047
|
+
)
|
|
2048
|
+
);
|
|
2049
|
+
updateParentPointers(control.with, control);
|
|
2050
|
+
const i = control.children.findIndex(($1) => $1?.type === "Error");
|
|
2051
|
+
if (i >= 0) {
|
|
2052
|
+
control.children.splice(i, 1);
|
|
2053
|
+
}
|
|
2054
|
+
const block = control.parent;
|
|
2055
|
+
if (!(block?.type === "BlockStatement")) {
|
|
2056
|
+
throw new Error(`Expected parent of ${controlName2()} to be BlockStatement`);
|
|
2057
|
+
}
|
|
2058
|
+
braceBlock(block);
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
return changed;
|
|
2062
|
+
}
|
|
1982
2063
|
function wrapIterationReturningResults(statement, outer, collect) {
|
|
1983
2064
|
if (statement.type === "DoStatement" || statement.type === "ComptimeStatement") {
|
|
1984
2065
|
if (collect) {
|
|
@@ -1994,14 +2075,37 @@ function wrapIterationReturningResults(statement, outer, collect) {
|
|
|
1994
2075
|
"wrapIterationReturningResults should not be called twice on the same statement"
|
|
1995
2076
|
);
|
|
1996
2077
|
const resultsRef = statement.resultsRef = makeRef("results");
|
|
2078
|
+
let decl = "const";
|
|
2079
|
+
if (statement.type === "IterationStatement" || statement.type === "ForStatement") {
|
|
2080
|
+
if (processBreakContinueWith(statement)) {
|
|
2081
|
+
decl = "let";
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
const breakWithOnly = decl === "let" && isLoopStatement(statement) && gatherRecursive(
|
|
2085
|
+
statement.block,
|
|
2086
|
+
(s) => s.type === "BreakStatement" && !s.with,
|
|
2087
|
+
(s) => isFunction(s) || s.type === "IterationStatement"
|
|
2088
|
+
).length === 0;
|
|
1997
2089
|
const declaration = {
|
|
1998
2090
|
type: "Declaration",
|
|
1999
|
-
children: ["
|
|
2091
|
+
children: [decl, " ", resultsRef],
|
|
2092
|
+
decl,
|
|
2093
|
+
names: [],
|
|
2094
|
+
bindings: []
|
|
2000
2095
|
};
|
|
2096
|
+
if (decl === "const") {
|
|
2097
|
+
declaration.children.push("=[]");
|
|
2098
|
+
} else {
|
|
2099
|
+
if (!breakWithOnly) {
|
|
2100
|
+
declaration.children.push(";", resultsRef, "=[]");
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2001
2103
|
outer.children.unshift(["", declaration, ";"]);
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2104
|
+
if (!breakWithOnly) {
|
|
2105
|
+
assignResults(statement.block, (node) => {
|
|
2106
|
+
return [resultsRef, ".push(", node, ")"];
|
|
2107
|
+
});
|
|
2108
|
+
}
|
|
2005
2109
|
if (collect) {
|
|
2006
2110
|
statement.children.push(collect(resultsRef));
|
|
2007
2111
|
} else {
|
|
@@ -2067,8 +2171,8 @@ function processSignature(f) {
|
|
|
2067
2171
|
}
|
|
2068
2172
|
if (hasYield(block) && !f.generator?.length) {
|
|
2069
2173
|
if (f.type === "ArrowFunction") {
|
|
2070
|
-
gatherRecursiveWithinFunction(block, ($) =>
|
|
2071
|
-
const i = y.children.findIndex(($
|
|
2174
|
+
gatherRecursiveWithinFunction(block, ($2) => $2.type === "YieldExpression").forEach((y) => {
|
|
2175
|
+
const i = y.children.findIndex(($3) => $3.type === "Yield");
|
|
2072
2176
|
return y.children.splice(i + 1, 0, {
|
|
2073
2177
|
type: "Error",
|
|
2074
2178
|
message: "Can't use yield inside of => arrow function"
|
|
@@ -2096,31 +2200,55 @@ function processFunctions(statements, config2) {
|
|
|
2096
2200
|
});
|
|
2097
2201
|
}
|
|
2098
2202
|
function expressionizeIteration(exp) {
|
|
2099
|
-
const { async, subtype, block, children, statement } = exp;
|
|
2203
|
+
const { async, generator, subtype, block, children, statement } = exp;
|
|
2100
2204
|
const i = children.indexOf(statement);
|
|
2101
2205
|
if (i < 0) {
|
|
2102
2206
|
throw new Error("Could not find iteration statement in iteration expression");
|
|
2103
2207
|
}
|
|
2104
2208
|
if (subtype === "DoStatement" || subtype === "ComptimeStatement") {
|
|
2105
|
-
children.splice(i, 1, wrapIIFE([["", statement, void 0]], async));
|
|
2209
|
+
children.splice(i, 1, wrapIIFE([["", statement, void 0]], async, generator));
|
|
2106
2210
|
updateParentPointers(exp);
|
|
2107
2211
|
return;
|
|
2108
2212
|
}
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
[
|
|
2122
|
-
|
|
2123
|
-
|
|
2213
|
+
if (generator) {
|
|
2214
|
+
assignResults(block, (node) => {
|
|
2215
|
+
return {
|
|
2216
|
+
type: "YieldExpression",
|
|
2217
|
+
expression: node,
|
|
2218
|
+
children: ["yield ", node]
|
|
2219
|
+
};
|
|
2220
|
+
});
|
|
2221
|
+
braceBlock(block);
|
|
2222
|
+
children.splice(
|
|
2223
|
+
i,
|
|
2224
|
+
1,
|
|
2225
|
+
wrapIIFE([
|
|
2226
|
+
["", statement, void 0],
|
|
2227
|
+
// Prevent implicit return in generator, by adding an explicit return
|
|
2228
|
+
["", {
|
|
2229
|
+
type: "ReturnStatement",
|
|
2230
|
+
expression: void 0,
|
|
2231
|
+
children: [";return"]
|
|
2232
|
+
}, void 0]
|
|
2233
|
+
], async, generator)
|
|
2234
|
+
);
|
|
2235
|
+
} else {
|
|
2236
|
+
exp.resultsRef ??= makeRef("results");
|
|
2237
|
+
const { resultsRef } = exp;
|
|
2238
|
+
assignResults(block, (node) => {
|
|
2239
|
+
return [resultsRef, ".push(", node, ")"];
|
|
2240
|
+
});
|
|
2241
|
+
braceBlock(block);
|
|
2242
|
+
children.splice(
|
|
2243
|
+
i,
|
|
2244
|
+
1,
|
|
2245
|
+
wrapIIFE([
|
|
2246
|
+
["", ["const ", resultsRef, "=[]"], ";"],
|
|
2247
|
+
["", statement, void 0],
|
|
2248
|
+
["", wrapWithReturn(resultsRef)]
|
|
2249
|
+
], async)
|
|
2250
|
+
);
|
|
2251
|
+
}
|
|
2124
2252
|
updateParentPointers(exp);
|
|
2125
2253
|
}
|
|
2126
2254
|
function skipImplicitArguments(args) {
|
|
@@ -2134,7 +2262,7 @@ function skipImplicitArguments(args) {
|
|
|
2134
2262
|
return false;
|
|
2135
2263
|
}
|
|
2136
2264
|
function processCoffeeDo(ws, expression) {
|
|
2137
|
-
ws =
|
|
2265
|
+
ws = trimFirstSpace(ws);
|
|
2138
2266
|
const args = [];
|
|
2139
2267
|
if (typeof expression === "object" && expression != null && "type" in expression && expression.type === "ArrowFunction" || typeof expression === "object" && expression != null && "type" in expression && expression.type === "FunctionExpression") {
|
|
2140
2268
|
const { parameters } = expression;
|
|
@@ -2168,7 +2296,7 @@ function processCoffeeDo(ws, expression) {
|
|
|
2168
2296
|
expression = {
|
|
2169
2297
|
...expression,
|
|
2170
2298
|
parameters: newParameters,
|
|
2171
|
-
children: expression.children.map(($
|
|
2299
|
+
children: expression.children.map(($4) => $4 === parameters ? newParameters : $4)
|
|
2172
2300
|
};
|
|
2173
2301
|
}
|
|
2174
2302
|
return {
|
|
@@ -2189,7 +2317,7 @@ function makeAmpersandFunction(rhs) {
|
|
|
2189
2317
|
ref = makeRef("$");
|
|
2190
2318
|
inplacePrepend(ref, body);
|
|
2191
2319
|
}
|
|
2192
|
-
if (startsWithPredicate(body, ($
|
|
2320
|
+
if (startsWithPredicate(body, ($5) => $5.type === "ObjectExpression")) {
|
|
2193
2321
|
body = makeLeftHandSideExpression(body);
|
|
2194
2322
|
}
|
|
2195
2323
|
const parameters = makeNode({
|
|
@@ -3450,7 +3578,7 @@ function prependStatementExpressionBlock(initializer, statement) {
|
|
|
3450
3578
|
const blockStatement = ["", statementExp];
|
|
3451
3579
|
let ref;
|
|
3452
3580
|
if (statementExp.type === "IterationExpression") {
|
|
3453
|
-
if (statementExp.async) {
|
|
3581
|
+
if (statementExp.async || statementExp.generator) {
|
|
3454
3582
|
return;
|
|
3455
3583
|
}
|
|
3456
3584
|
const statement2 = statementExp.statement;
|
|
@@ -5998,7 +6126,8 @@ function attachPostfixStatementAsExpression(exp, post) {
|
|
|
5998
6126
|
type: "IterationExpression",
|
|
5999
6127
|
children: [statement],
|
|
6000
6128
|
block: statement.block,
|
|
6001
|
-
statement
|
|
6129
|
+
statement,
|
|
6130
|
+
generator: statement.generator
|
|
6002
6131
|
};
|
|
6003
6132
|
}
|
|
6004
6133
|
case "IfStatement": {
|
|
@@ -6525,6 +6654,7 @@ var grammar = {
|
|
|
6525
6654
|
ReservedBinary,
|
|
6526
6655
|
ArgumentsWithTrailingMemberExpressions,
|
|
6527
6656
|
TrailingMemberExpressions,
|
|
6657
|
+
IndentedTrailingMemberExpression,
|
|
6528
6658
|
AllowedTrailingMemberExpressions,
|
|
6529
6659
|
TrailingCallExpressions,
|
|
6530
6660
|
AllowedTrailingCallExpressions,
|
|
@@ -6793,6 +6923,7 @@ var grammar = {
|
|
|
6793
6923
|
BlockStatement,
|
|
6794
6924
|
LabelledStatement,
|
|
6795
6925
|
Label,
|
|
6926
|
+
LabelIdentifier,
|
|
6796
6927
|
LabelledItem,
|
|
6797
6928
|
IfStatement,
|
|
6798
6929
|
ElseClause,
|
|
@@ -7852,7 +7983,7 @@ var ExplicitArguments$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(OpenParen, (0
|
|
|
7852
7983
|
function ExplicitArguments(ctx, state2) {
|
|
7853
7984
|
return (0, import_lib3.$EVENT)(ctx, state2, "ExplicitArguments", ExplicitArguments$0);
|
|
7854
7985
|
}
|
|
7855
|
-
var ApplicationStart$0 = (0, import_lib3.$S)(IndentedApplicationAllowed, (0, import_lib3.$Y)((0, import_lib3.$S)(IndentedFurther, (0, import_lib3.$N)(IdentifierBinaryOp), (0, import_lib3.$N)(
|
|
7986
|
+
var ApplicationStart$0 = (0, import_lib3.$S)(IndentedApplicationAllowed, (0, import_lib3.$Y)((0, import_lib3.$S)(IndentedFurther, (0, import_lib3.$N)(IdentifierBinaryOp))), (0, import_lib3.$N)(IndentedTrailingMemberExpression));
|
|
7856
7987
|
var ApplicationStart$1 = (0, import_lib3.$S)((0, import_lib3.$N)(EOS), (0, import_lib3.$Y)((0, import_lib3.$S)(_, (0, import_lib3.$C)(BracedApplicationAllowed, (0, import_lib3.$N)((0, import_lib3.$EXPECT)($L1, 'ApplicationStart "{"'))), (0, import_lib3.$N)(ForbiddenImplicitCalls))));
|
|
7857
7988
|
var ApplicationStart$$ = [ApplicationStart$0, ApplicationStart$1];
|
|
7858
7989
|
function ApplicationStart(ctx, state2) {
|
|
@@ -7893,20 +8024,20 @@ var ArgumentsWithTrailingMemberExpressions$0 = (0, import_lib3.$TS)((0, import_l
|
|
|
7893
8024
|
function ArgumentsWithTrailingMemberExpressions(ctx, state2) {
|
|
7894
8025
|
return (0, import_lib3.$EVENT)(ctx, state2, "ArgumentsWithTrailingMemberExpressions", ArgumentsWithTrailingMemberExpressions$0);
|
|
7895
8026
|
}
|
|
7896
|
-
var TrailingMemberExpressions$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$Q)(MemberExpressionRest), (0, import_lib3.$Q)(
|
|
7897
|
-
return
|
|
7898
|
-
if (Array.isArray(memberExpressionRest)) {
|
|
7899
|
-
return [ws, ...memberExpressionRest];
|
|
7900
|
-
}
|
|
7901
|
-
return {
|
|
7902
|
-
...memberExpressionRest,
|
|
7903
|
-
children: [ws, ...memberExpressionRest.children]
|
|
7904
|
-
};
|
|
7905
|
-
}));
|
|
8027
|
+
var TrailingMemberExpressions$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$Q)(MemberExpressionRest), (0, import_lib3.$Q)(IndentedTrailingMemberExpression)), function($skip, $loc, $0, $1, $2) {
|
|
8028
|
+
return [...$1, ...$2];
|
|
7906
8029
|
});
|
|
7907
8030
|
function TrailingMemberExpressions(ctx, state2) {
|
|
7908
8031
|
return (0, import_lib3.$EVENT)(ctx, state2, "TrailingMemberExpressions", TrailingMemberExpressions$0);
|
|
7909
8032
|
}
|
|
8033
|
+
var IndentedTrailingMemberExpression$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(IndentedAtLeast, (0, import_lib3.$Y)((0, import_lib3.$S)((0, import_lib3.$E)((0, import_lib3.$EXPECT)($L6, 'IndentedTrailingMemberExpression "?"')), (0, import_lib3.$EXPECT)($L7, 'IndentedTrailingMemberExpression "."'), (0, import_lib3.$N)((0, import_lib3.$EXPECT)($R3, "IndentedTrailingMemberExpression /[0-9]/")))), MemberExpressionRest), function($skip, $loc, $0, $1, $2, $3) {
|
|
8034
|
+
var ws = $1;
|
|
8035
|
+
var rest = $3;
|
|
8036
|
+
return prepend(ws, rest);
|
|
8037
|
+
});
|
|
8038
|
+
function IndentedTrailingMemberExpression(ctx, state2) {
|
|
8039
|
+
return (0, import_lib3.$EVENT)(ctx, state2, "IndentedTrailingMemberExpression", IndentedTrailingMemberExpression$0);
|
|
8040
|
+
}
|
|
7910
8041
|
var AllowedTrailingMemberExpressions$0 = (0, import_lib3.$T)((0, import_lib3.$S)(TrailingMemberPropertyAllowed, TrailingMemberExpressions), function(value) {
|
|
7911
8042
|
return value[1];
|
|
7912
8043
|
});
|
|
@@ -12450,8 +12581,10 @@ var Statement$1 = VariableStatement;
|
|
|
12450
12581
|
var Statement$2 = (0, import_lib3.$T)((0, import_lib3.$S)(IfStatement, (0, import_lib3.$N)(ShouldExpressionize)), function(value) {
|
|
12451
12582
|
return value[0];
|
|
12452
12583
|
});
|
|
12453
|
-
var Statement$3 = (0, import_lib3.$
|
|
12454
|
-
|
|
12584
|
+
var Statement$3 = (0, import_lib3.$TS)((0, import_lib3.$S)(IterationStatement, (0, import_lib3.$N)(ShouldExpressionize)), function($skip, $loc, $0, $1, $2) {
|
|
12585
|
+
if ($1.generator)
|
|
12586
|
+
return $skip;
|
|
12587
|
+
return $1;
|
|
12455
12588
|
});
|
|
12456
12589
|
var Statement$4 = (0, import_lib3.$T)((0, import_lib3.$S)(SwitchStatement, (0, import_lib3.$N)(ShouldExpressionize)), function(value) {
|
|
12457
12590
|
return value[0];
|
|
@@ -12522,11 +12655,22 @@ var Label$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Colon, Identifier, Whites
|
|
|
12522
12655
|
var colon = $1;
|
|
12523
12656
|
var id = $2;
|
|
12524
12657
|
var w = $3;
|
|
12525
|
-
return
|
|
12658
|
+
return {
|
|
12659
|
+
type: "Label",
|
|
12660
|
+
name: id.name,
|
|
12661
|
+
children: [id, colon, w]
|
|
12662
|
+
};
|
|
12526
12663
|
});
|
|
12527
12664
|
function Label(ctx, state2) {
|
|
12528
12665
|
return (0, import_lib3.$EVENT)(ctx, state2, "Label", Label$0);
|
|
12529
12666
|
}
|
|
12667
|
+
var LabelIdentifier$0 = (0, import_lib3.$T)((0, import_lib3.$S)((0, import_lib3.$E)(Colon), Identifier), function(value) {
|
|
12668
|
+
var id = value[1];
|
|
12669
|
+
return id;
|
|
12670
|
+
});
|
|
12671
|
+
function LabelIdentifier(ctx, state2) {
|
|
12672
|
+
return (0, import_lib3.$EVENT)(ctx, state2, "LabelIdentifier", LabelIdentifier$0);
|
|
12673
|
+
}
|
|
12530
12674
|
var LabelledItem$0 = Statement;
|
|
12531
12675
|
var LabelledItem$1 = FunctionDeclaration;
|
|
12532
12676
|
var LabelledItem$$ = [LabelledItem$0, LabelledItem$1];
|
|
@@ -12623,7 +12767,8 @@ var IterationExpression$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_
|
|
|
12623
12767
|
children: [statement],
|
|
12624
12768
|
block: statement.block,
|
|
12625
12769
|
statement,
|
|
12626
|
-
async
|
|
12770
|
+
async,
|
|
12771
|
+
generator: statement.generator
|
|
12627
12772
|
};
|
|
12628
12773
|
});
|
|
12629
12774
|
function IterationExpression(ctx, state2) {
|
|
@@ -12642,8 +12787,9 @@ var LoopStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(LoopClause, Block
|
|
|
12642
12787
|
function LoopStatement(ctx, state2) {
|
|
12643
12788
|
return (0, import_lib3.$EVENT)(ctx, state2, "LoopStatement", LoopStatement$0);
|
|
12644
12789
|
}
|
|
12645
|
-
var LoopClause$0 = (0, import_lib3.$
|
|
12646
|
-
var kind = $
|
|
12790
|
+
var LoopClause$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Loop, (0, import_lib3.$E)((0, import_lib3.$S)((0, import_lib3.$E)(_), Star))), function($skip, $loc, $0, $1, $2) {
|
|
12791
|
+
var kind = $1;
|
|
12792
|
+
var generator = $2;
|
|
12647
12793
|
const expression = {
|
|
12648
12794
|
type: "Literal",
|
|
12649
12795
|
children: ["true"],
|
|
@@ -12658,33 +12804,41 @@ var LoopClause$0 = (0, import_lib3.$TV)(Loop, function($skip, $loc, $0, $1) {
|
|
|
12658
12804
|
type: "IterationStatement",
|
|
12659
12805
|
subtype: kind.token,
|
|
12660
12806
|
children: [kind, condition],
|
|
12661
|
-
condition
|
|
12807
|
+
condition,
|
|
12808
|
+
generator
|
|
12662
12809
|
};
|
|
12663
12810
|
});
|
|
12664
12811
|
function LoopClause(ctx, state2) {
|
|
12665
12812
|
return (0, import_lib3.$EVENT)(ctx, state2, "LoopClause", LoopClause$0);
|
|
12666
12813
|
}
|
|
12667
|
-
var DoWhileStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Do, NoPostfixBracedOrEmptyBlock, __, WhileClause), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
12668
|
-
var
|
|
12669
|
-
var
|
|
12814
|
+
var DoWhileStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Do, (0, import_lib3.$E)((0, import_lib3.$S)((0, import_lib3.$E)(_), Star)), NoPostfixBracedOrEmptyBlock, __, WhileClause), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
12815
|
+
var d = $1;
|
|
12816
|
+
var generator = $2;
|
|
12817
|
+
var block = $3;
|
|
12818
|
+
var ws = $4;
|
|
12819
|
+
var clause = $5;
|
|
12670
12820
|
return {
|
|
12671
12821
|
...clause,
|
|
12672
12822
|
type: "IterationStatement",
|
|
12673
12823
|
subtype: "do-while",
|
|
12674
|
-
children:
|
|
12675
|
-
block
|
|
12824
|
+
children: [d, block, ws, clause],
|
|
12825
|
+
block,
|
|
12826
|
+
generator
|
|
12676
12827
|
};
|
|
12677
12828
|
});
|
|
12678
12829
|
function DoWhileStatement(ctx, state2) {
|
|
12679
12830
|
return (0, import_lib3.$EVENT)(ctx, state2, "DoWhileStatement", DoWhileStatement$0);
|
|
12680
12831
|
}
|
|
12681
|
-
var DoStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Do, NoPostfixBracedOrEmptyBlock), function($skip, $loc, $0, $1, $2) {
|
|
12682
|
-
var
|
|
12832
|
+
var DoStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Do, (0, import_lib3.$E)((0, import_lib3.$S)((0, import_lib3.$E)(_), Star)), NoPostfixBracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3) {
|
|
12833
|
+
var d = $1;
|
|
12834
|
+
var generator = $2;
|
|
12835
|
+
var block = $3;
|
|
12683
12836
|
block = trimFirstSpace(block);
|
|
12684
12837
|
return {
|
|
12685
12838
|
type: "DoStatement",
|
|
12686
12839
|
children: [block],
|
|
12687
|
-
block
|
|
12840
|
+
block,
|
|
12841
|
+
generator
|
|
12688
12842
|
};
|
|
12689
12843
|
});
|
|
12690
12844
|
function DoStatement(ctx, state2) {
|
|
@@ -12719,10 +12873,11 @@ var WhileStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(WhileClause, Blo
|
|
|
12719
12873
|
function WhileStatement(ctx, state2) {
|
|
12720
12874
|
return (0, import_lib3.$EVENT)(ctx, state2, "WhileStatement", WhileStatement$0);
|
|
12721
12875
|
}
|
|
12722
|
-
var WhileClause$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$C)(While, Until), (0, import_lib3.$E)(_), Condition), function($skip, $loc, $0, $1, $2, $3) {
|
|
12876
|
+
var WhileClause$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$C)(While, Until), (0, import_lib3.$E)((0, import_lib3.$S)((0, import_lib3.$E)(_), Star)), (0, import_lib3.$E)(_), Condition), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
12723
12877
|
var kind = $1;
|
|
12724
|
-
var
|
|
12725
|
-
var
|
|
12878
|
+
var generator = $2;
|
|
12879
|
+
var ws = $3;
|
|
12880
|
+
var condition = $4;
|
|
12726
12881
|
if (kind.negated) {
|
|
12727
12882
|
kind = { ...kind, token: "while" };
|
|
12728
12883
|
condition = negateCondition(condition);
|
|
@@ -12732,6 +12887,7 @@ var WhileClause$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$C)
|
|
|
12732
12887
|
subtype: kind.token,
|
|
12733
12888
|
children: [kind, ws, condition],
|
|
12734
12889
|
condition,
|
|
12890
|
+
generator,
|
|
12735
12891
|
negated: kind.negated
|
|
12736
12892
|
};
|
|
12737
12893
|
});
|
|
@@ -12751,16 +12907,18 @@ var ForStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(ForClause, BlockOr
|
|
|
12751
12907
|
function ForStatement(ctx, state2) {
|
|
12752
12908
|
return (0, import_lib3.$EVENT)(ctx, state2, "ForStatement", ForStatement$0);
|
|
12753
12909
|
}
|
|
12754
|
-
var ForClause$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(For, __, ForStatementControl), function($skip, $loc, $0, $1, $2, $3) {
|
|
12755
|
-
var
|
|
12910
|
+
var ForClause$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(For, (0, import_lib3.$E)((0, import_lib3.$S)((0, import_lib3.$E)(_), Star)), __, ForStatementControl), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
12911
|
+
var generator = $2;
|
|
12912
|
+
var c = $4;
|
|
12756
12913
|
const { children, declaration } = c;
|
|
12757
12914
|
return {
|
|
12758
12915
|
type: "ForStatement",
|
|
12759
|
-
children: [$1, ...$
|
|
12916
|
+
children: [$1, ...$3, ...children],
|
|
12760
12917
|
declaration,
|
|
12761
12918
|
block: null,
|
|
12762
12919
|
blockPrefix: c.blockPrefix,
|
|
12763
|
-
hoistDec: c.hoistDec
|
|
12920
|
+
hoistDec: c.hoistDec,
|
|
12921
|
+
generator
|
|
12764
12922
|
};
|
|
12765
12923
|
});
|
|
12766
12924
|
function ForClause(ctx, state2) {
|
|
@@ -13527,11 +13685,21 @@ var ExpressionStatement$$ = [ExpressionStatement$0, ExpressionStatement$1];
|
|
|
13527
13685
|
function ExpressionStatement(ctx, state2) {
|
|
13528
13686
|
return (0, import_lib3.$EVENT_C)(ctx, state2, "ExpressionStatement", ExpressionStatement$$);
|
|
13529
13687
|
}
|
|
13530
|
-
var KeywordStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Break, (0, import_lib3.$E)((0, import_lib3.$S)(_, (0, import_lib3.$E)(
|
|
13688
|
+
var KeywordStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Break, (0, import_lib3.$E)((0, import_lib3.$S)(_, LabelIdentifier)), (0, import_lib3.$E)((0, import_lib3.$S)(_, With, MaybeNestedExtendedExpression))), function($skip, $loc, $0, $1, $2, $3) {
|
|
13689
|
+
const children = [$1];
|
|
13690
|
+
if ($2)
|
|
13691
|
+
children.push($2);
|
|
13692
|
+
if ($3)
|
|
13693
|
+
children.push({
|
|
13694
|
+
type: "Error",
|
|
13695
|
+
subtype: "Warning",
|
|
13696
|
+
message: "'break with' outside of loop that returns a value"
|
|
13697
|
+
});
|
|
13531
13698
|
return {
|
|
13532
13699
|
type: "BreakStatement",
|
|
13533
|
-
|
|
13534
|
-
|
|
13700
|
+
label: $2?.[1],
|
|
13701
|
+
with: $3?.[2],
|
|
13702
|
+
children
|
|
13535
13703
|
};
|
|
13536
13704
|
});
|
|
13537
13705
|
var KeywordStatement$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(Continue, _, Switch), function($skip, $loc, $0, $1, $2, $3) {
|
|
@@ -13541,11 +13709,21 @@ var KeywordStatement$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(Continue, _, S
|
|
|
13541
13709
|
children: []
|
|
13542
13710
|
};
|
|
13543
13711
|
});
|
|
13544
|
-
var KeywordStatement$2 = (0, import_lib3.$TS)((0, import_lib3.$S)(Continue, (0, import_lib3.$E)((0, import_lib3.$S)(_, (0, import_lib3.$E)(
|
|
13712
|
+
var KeywordStatement$2 = (0, import_lib3.$TS)((0, import_lib3.$S)(Continue, (0, import_lib3.$E)((0, import_lib3.$S)(_, LabelIdentifier)), (0, import_lib3.$E)((0, import_lib3.$S)(_, With, MaybeNestedExtendedExpression))), function($skip, $loc, $0, $1, $2, $3) {
|
|
13713
|
+
const children = [$1];
|
|
13714
|
+
if ($2)
|
|
13715
|
+
children.push($2);
|
|
13716
|
+
if ($3)
|
|
13717
|
+
children.push({
|
|
13718
|
+
type: "Error",
|
|
13719
|
+
subtype: "Warning",
|
|
13720
|
+
message: "'continue with' outside of loop that returns a value"
|
|
13721
|
+
});
|
|
13545
13722
|
return {
|
|
13546
13723
|
type: "ContinueStatement",
|
|
13547
|
-
|
|
13548
|
-
|
|
13724
|
+
label: $2?.[1],
|
|
13725
|
+
with: $3?.[2],
|
|
13726
|
+
children
|
|
13549
13727
|
};
|
|
13550
13728
|
});
|
|
13551
13729
|
var KeywordStatement$3 = DebuggerStatement;
|
|
@@ -17694,19 +17872,6 @@ var Reset$0 = (0, import_lib3.$TV)((0, import_lib3.$EXPECT)($L0, 'Reset ""'), fu
|
|
|
17694
17872
|
}
|
|
17695
17873
|
});
|
|
17696
17874
|
Object.assign(config, initialConfig);
|
|
17697
|
-
return {
|
|
17698
|
-
type: "ParserMeta",
|
|
17699
|
-
children: [],
|
|
17700
|
-
getStateKey() {
|
|
17701
|
-
const stateInt = state.currentIndent.level % 256 << 8 | state.classImplicitCallForbidden << 7 | state.indentedApplicationForbidden << 6 | state.bracedApplicationForbidden << 5 | state.trailingMemberPropertyForbidden << 4 | state.newlineBinaryOpForbidden << 3 | // This is slightly different than the rest of the state,
|
|
17702
|
-
// since it is affected by the directive prologue and may be hit
|
|
17703
|
-
// by the EOL rule early in the parse. Later if we wanted to
|
|
17704
|
-
// allow block scoping of the compat directives we would need to
|
|
17705
|
-
// add them all here.
|
|
17706
|
-
config.coffeeComment << 2;
|
|
17707
|
-
return [stateInt, state.currentJSXTag];
|
|
17708
|
-
}
|
|
17709
|
-
};
|
|
17710
17875
|
});
|
|
17711
17876
|
function Reset(ctx, state2) {
|
|
17712
17877
|
return (0, import_lib3.$EVENT)(ctx, state2, "Reset", Reset$0);
|
|
@@ -17908,6 +18073,15 @@ Object.defineProperties(state, {
|
|
|
17908
18073
|
}
|
|
17909
18074
|
}
|
|
17910
18075
|
});
|
|
18076
|
+
function getStateKey() {
|
|
18077
|
+
const stateInt = state.currentIndent.level % 256 << 8 | state.classImplicitCallForbidden << 7 | state.indentedApplicationForbidden << 6 | state.bracedApplicationForbidden << 5 | state.trailingMemberPropertyForbidden << 4 | state.newlineBinaryOpForbidden << 3 | // This is slightly different than the rest of the state,
|
|
18078
|
+
// since it is affected by the directive prologue and may be hit
|
|
18079
|
+
// by the EOL rule early in the parse. Later if we wanted to
|
|
18080
|
+
// allow block scoping of the compat directives we would need to
|
|
18081
|
+
// add them all here.
|
|
18082
|
+
config.coffeeComment << 2;
|
|
18083
|
+
return [stateInt, state.currentJSXTag];
|
|
18084
|
+
}
|
|
17911
18085
|
function parseProgram(input, options) {
|
|
17912
18086
|
filename = options?.filename;
|
|
17913
18087
|
initialConfig = options?.parseOptions;
|
|
@@ -18134,7 +18308,11 @@ var encodeBase64 = function(value) {
|
|
|
18134
18308
|
})();
|
|
18135
18309
|
};
|
|
18136
18310
|
var base64Encode = function(src) {
|
|
18137
|
-
|
|
18311
|
+
if (typeof Buffer !== "undefined") {
|
|
18312
|
+
return Buffer.from(src).toString("base64");
|
|
18313
|
+
} else {
|
|
18314
|
+
return btoa(src);
|
|
18315
|
+
}
|
|
18138
18316
|
};
|
|
18139
18317
|
var vlqTable = new Uint8Array(128);
|
|
18140
18318
|
var vlqChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -18438,7 +18616,6 @@ var makeCache = function({ hits, trace } = {}) {
|
|
|
18438
18616
|
meta.logs = logs;
|
|
18439
18617
|
}
|
|
18440
18618
|
const stateCache = new StateCache();
|
|
18441
|
-
let getStateKey = null;
|
|
18442
18619
|
const stack = [];
|
|
18443
18620
|
const events = {
|
|
18444
18621
|
meta,
|
|
@@ -18467,14 +18644,12 @@ var makeCache = function({ hits, trace } = {}) {
|
|
|
18467
18644
|
return;
|
|
18468
18645
|
},
|
|
18469
18646
|
exit: function(ruleName, state2, result) {
|
|
18470
|
-
if (ruleName
|
|
18471
|
-
|
|
18472
|
-
}
|
|
18473
|
-
if (!uncacheable.has(ruleName)) {
|
|
18474
|
-
const [stateKey, tagKey] = getStateKey();
|
|
18475
|
-
const key = [tagKey, stateKey, state2.pos, ruleName];
|
|
18476
|
-
stateCache.set(key, result);
|
|
18647
|
+
if (uncacheable.has(ruleName)) {
|
|
18648
|
+
return;
|
|
18477
18649
|
}
|
|
18650
|
+
const [stateKey, tagKey] = getStateKey();
|
|
18651
|
+
const key = [tagKey, stateKey, state2.pos, ruleName];
|
|
18652
|
+
stateCache.set(key, result);
|
|
18478
18653
|
if (getConfig().verbose && result) {
|
|
18479
18654
|
console.log(`Parsed ${JSON.stringify(state2.input.slice(state2.pos, result.pos))} [pos ${state2.pos}-${result.pos}] as ${ruleName}`);
|
|
18480
18655
|
}
|