@danielx/civet 0.5.84 → 0.5.85
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 +511 -225
- package/dist/main.js +511 -225
- package/dist/main.mjs +511 -225
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -129,16 +129,209 @@ var Civet = (() => {
|
|
|
129
129
|
function gatherRecursiveWithinFunction(node, predicate) {
|
|
130
130
|
return gatherRecursive(node, predicate, isFunction);
|
|
131
131
|
}
|
|
132
|
+
function insertTrimmingSpace(target, c) {
|
|
133
|
+
if (!target)
|
|
134
|
+
return target;
|
|
135
|
+
if (Array.isArray(target))
|
|
136
|
+
return target.map((e, i) => {
|
|
137
|
+
if (i === 0)
|
|
138
|
+
return insertTrimmingSpace(e, c);
|
|
139
|
+
return e;
|
|
140
|
+
});
|
|
141
|
+
if (target.children)
|
|
142
|
+
return Object.assign({}, target, {
|
|
143
|
+
children: target.children.map((e, i) => {
|
|
144
|
+
if (i === 0)
|
|
145
|
+
return insertTrimmingSpace(e, c);
|
|
146
|
+
return e;
|
|
147
|
+
})
|
|
148
|
+
});
|
|
149
|
+
if (target.token)
|
|
150
|
+
return Object.assign({}, target, {
|
|
151
|
+
token: target.token.replace(/^ ?/, c)
|
|
152
|
+
});
|
|
153
|
+
return target;
|
|
154
|
+
}
|
|
155
|
+
function getTrimmingSpace(target) {
|
|
156
|
+
if (!target)
|
|
157
|
+
return;
|
|
158
|
+
if (Array.isArray(target))
|
|
159
|
+
return getTrimmingSpace(target[0]);
|
|
160
|
+
if (target.children)
|
|
161
|
+
return getTrimmingSpace(target.children[0]);
|
|
162
|
+
if (target.token)
|
|
163
|
+
return target.token.match(/^ ?/)[0];
|
|
164
|
+
}
|
|
165
|
+
function needsRef(exp) {
|
|
166
|
+
switch (exp.type) {
|
|
167
|
+
case "Identifier":
|
|
168
|
+
case "Literal":
|
|
169
|
+
case "Ref":
|
|
170
|
+
return false;
|
|
171
|
+
default:
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function maybeRef(exp, base = "ref") {
|
|
176
|
+
if (!needsRef(exp))
|
|
177
|
+
return exp;
|
|
178
|
+
return {
|
|
179
|
+
type: "Ref",
|
|
180
|
+
base,
|
|
181
|
+
id: base
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function literalValue(literal) {
|
|
185
|
+
let { raw } = literal;
|
|
186
|
+
switch (raw) {
|
|
187
|
+
case "null":
|
|
188
|
+
return null;
|
|
189
|
+
case "true":
|
|
190
|
+
return true;
|
|
191
|
+
case "false":
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
if (raw.startsWith('"') && raw.endsWith('"') || raw.startsWith("'") && raw.endsWith("'")) {
|
|
195
|
+
return raw.slice(1, -1);
|
|
196
|
+
}
|
|
197
|
+
const numeric = literal.children.find(
|
|
198
|
+
(child) => child.type === "NumericLiteral"
|
|
199
|
+
);
|
|
200
|
+
if (numeric) {
|
|
201
|
+
raw = raw.replace(/_/g, "");
|
|
202
|
+
const { token } = numeric;
|
|
203
|
+
if (token.endsWith("n")) {
|
|
204
|
+
return BigInt(raw.slice(0, -1));
|
|
205
|
+
} else if (token.match(/[\.eE]/)) {
|
|
206
|
+
return parseFloat(raw);
|
|
207
|
+
} else if (token.startsWith("0")) {
|
|
208
|
+
switch (token.charAt(1).toLowerCase()) {
|
|
209
|
+
case "x":
|
|
210
|
+
return parseInt(raw.replace(/0[xX]/, ""), 16);
|
|
211
|
+
case "b":
|
|
212
|
+
return parseInt(raw.replace(/0[bB]/, ""), 2);
|
|
213
|
+
case "o":
|
|
214
|
+
return parseInt(raw.replace(/0[oO]/, ""), 8);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return parseInt(raw, 10);
|
|
218
|
+
}
|
|
219
|
+
throw new Error("Unrecognized literal " + JSON.stringify(literal));
|
|
220
|
+
}
|
|
221
|
+
function forRange(open, forDeclaration, range, stepExp, close) {
|
|
222
|
+
const { start, end, inclusive } = range;
|
|
223
|
+
const counterRef = {
|
|
224
|
+
type: "Ref",
|
|
225
|
+
base: "i",
|
|
226
|
+
id: "i"
|
|
227
|
+
};
|
|
228
|
+
let stepRef;
|
|
229
|
+
if (stepExp) {
|
|
230
|
+
stepExp = insertTrimmingSpace(stepExp, "");
|
|
231
|
+
stepRef = maybeRef(stepExp, "step");
|
|
232
|
+
}
|
|
233
|
+
const startRef = maybeRef(start, "start");
|
|
234
|
+
const endRef = maybeRef(end, "end");
|
|
235
|
+
const startRefDec = startRef !== start ? [startRef, " = ", start, ", "] : [];
|
|
236
|
+
const endRefDec = endRef !== end ? [endRef, " = ", end, ", "] : [];
|
|
237
|
+
let ascDec = [], ascRef, asc;
|
|
238
|
+
if (stepRef) {
|
|
239
|
+
if (stepRef !== stepExp) {
|
|
240
|
+
ascDec = [", ", stepRef, " = ", stepExp];
|
|
241
|
+
}
|
|
242
|
+
} else if (start.type === "Literal" && end.type === "Literal") {
|
|
243
|
+
asc = literalValue(start) <= literalValue(end);
|
|
244
|
+
} else {
|
|
245
|
+
ascRef = {
|
|
246
|
+
type: "Ref",
|
|
247
|
+
base: "asc",
|
|
248
|
+
id: "asc"
|
|
249
|
+
};
|
|
250
|
+
ascDec = [", ", ascRef, " = ", startRef, " <= ", endRef];
|
|
251
|
+
}
|
|
252
|
+
let varAssign = [], varLetAssign = varAssign, varLet = varAssign, blockPrefix;
|
|
253
|
+
if (forDeclaration?.declare) {
|
|
254
|
+
if (forDeclaration.declare.token === "let") {
|
|
255
|
+
const varName = forDeclaration.children.splice(1);
|
|
256
|
+
varAssign = [...insertTrimmingSpace(varName, ""), " = "];
|
|
257
|
+
varLet = [",", ...varName, " = ", counterRef];
|
|
258
|
+
} else {
|
|
259
|
+
blockPrefix = [
|
|
260
|
+
["", forDeclaration, " = ", counterRef, ";\n"]
|
|
261
|
+
];
|
|
262
|
+
}
|
|
263
|
+
} else if (forDeclaration) {
|
|
264
|
+
varAssign = varLetAssign = [forDeclaration, " = "];
|
|
265
|
+
blockPrefix = [
|
|
266
|
+
["", {
|
|
267
|
+
type: "AssignmentExpression",
|
|
268
|
+
children: [],
|
|
269
|
+
names: forDeclaration.names
|
|
270
|
+
}]
|
|
271
|
+
];
|
|
272
|
+
}
|
|
273
|
+
const declaration = {
|
|
274
|
+
type: "Declaration",
|
|
275
|
+
children: ["let ", ...startRefDec, ...endRefDec, counterRef, " = ", ...varLetAssign, startRef, ...varLet, ...ascDec],
|
|
276
|
+
names: forDeclaration?.names
|
|
277
|
+
};
|
|
278
|
+
const counterPart = inclusive ? [counterRef, " <= ", endRef, " : ", counterRef, " >= ", endRef] : [counterRef, " < ", endRef, " : ", counterRef, " > ", endRef];
|
|
279
|
+
const condition = stepRef ? [stepRef, " !== 0 && (", stepRef, " > 0 ? ", ...counterPart, ")"] : ascRef ? [ascRef, " ? ", ...counterPart] : asc ? counterPart.slice(0, 3) : counterPart.slice(4);
|
|
280
|
+
const increment = stepRef ? [...varAssign, counterRef, " += ", stepRef] : ascRef ? [...varAssign, ascRef, " ? ++", counterRef, " : --", counterRef] : [...varAssign, asc ? "++" : "--", counterRef];
|
|
281
|
+
return {
|
|
282
|
+
declaration,
|
|
283
|
+
children: [open, declaration, "; ", ...condition, "; ", ...increment, close],
|
|
284
|
+
blockPrefix
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
function modifyString(str) {
|
|
288
|
+
return str.replace(/(^.?|[^\\]{2})(\\\\)*\n/g, "$1$2\\n");
|
|
289
|
+
}
|
|
290
|
+
function quoteString(str) {
|
|
291
|
+
str = str.replace(/\\/g, "\\\\");
|
|
292
|
+
if (str.includes('"') && !str.includes("'")) {
|
|
293
|
+
return "'" + str.replace(/'/g, "\\'") + "'";
|
|
294
|
+
} else {
|
|
295
|
+
return '"' + str.replace(/"/g, '\\"') + '"';
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function processCoffeeInterpolation(s, parts, e, $loc) {
|
|
299
|
+
if (parts.length === 0 || parts.length === 1 && parts[0].token != null) {
|
|
300
|
+
return {
|
|
301
|
+
type: "StringLiteral",
|
|
302
|
+
token: parts.length ? `"${modifyString(parts[0].token)}"` : '""',
|
|
303
|
+
$loc
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
parts.forEach((part) => {
|
|
307
|
+
if (part.token) {
|
|
308
|
+
const str = part.token.replace(/(`|\$\{)/g, "\\$1");
|
|
309
|
+
part.token = modifyString(str);
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
s.token = e.token = "`";
|
|
313
|
+
return {
|
|
314
|
+
type: "TemplateLiteral",
|
|
315
|
+
children: [s, parts, e]
|
|
316
|
+
};
|
|
317
|
+
}
|
|
132
318
|
module.exports = {
|
|
133
319
|
clone,
|
|
134
320
|
deepCopy,
|
|
321
|
+
forRange,
|
|
135
322
|
gatherNodes,
|
|
136
323
|
gatherRecursive,
|
|
137
324
|
gatherRecursiveAll,
|
|
138
325
|
gatherRecursiveWithinFunction,
|
|
326
|
+
getTrimmingSpace,
|
|
139
327
|
hasAwait,
|
|
140
328
|
hasYield,
|
|
329
|
+
insertTrimmingSpace,
|
|
141
330
|
isFunction,
|
|
331
|
+
literalValue,
|
|
332
|
+
modifyString,
|
|
333
|
+
processCoffeeInterpolation,
|
|
334
|
+
quoteString,
|
|
142
335
|
removeParentPointers
|
|
143
336
|
};
|
|
144
337
|
}
|
|
@@ -705,6 +898,7 @@ ${input.slice(result.pos)}
|
|
|
705
898
|
BracedContent,
|
|
706
899
|
NestedBlockStatements,
|
|
707
900
|
NestedBlockStatement,
|
|
901
|
+
BlockStatementPart,
|
|
708
902
|
Literal,
|
|
709
903
|
LiteralContent,
|
|
710
904
|
NullLiteral,
|
|
@@ -782,6 +976,7 @@ ${input.slice(result.pos)}
|
|
|
782
976
|
ElseExpressionBlock,
|
|
783
977
|
NestedBlockExpressions,
|
|
784
978
|
NestedBlockExpression,
|
|
979
|
+
BlockExpressionPart,
|
|
785
980
|
IterationStatement,
|
|
786
981
|
IterationExpression,
|
|
787
982
|
LoopStatement,
|
|
@@ -798,6 +993,7 @@ ${input.slice(result.pos)}
|
|
|
798
993
|
CoffeeForIndex,
|
|
799
994
|
CoffeeForDeclaration,
|
|
800
995
|
ForStatementParameters,
|
|
996
|
+
ForRangeParameters,
|
|
801
997
|
ForInOfDeclaration,
|
|
802
998
|
ForDeclaration,
|
|
803
999
|
ForBinding,
|
|
@@ -1109,6 +1305,10 @@ ${input.slice(result.pos)}
|
|
|
1109
1305
|
NestedTypeList,
|
|
1110
1306
|
NestedType,
|
|
1111
1307
|
TypeConditional,
|
|
1308
|
+
TypeTemplateSubstitution,
|
|
1309
|
+
TypeTemplateLiteral,
|
|
1310
|
+
CoffeeStringTypeSubstitution,
|
|
1311
|
+
CoffeeInterpolatedDoubleQuotedTypeLiteral,
|
|
1112
1312
|
TypeLiteral,
|
|
1113
1313
|
InlineInterfaceLiteral,
|
|
1114
1314
|
InlineBasicInterfaceProperty,
|
|
@@ -1525,10 +1725,7 @@ ${input.slice(result.pos)}
|
|
|
1525
1725
|
return result;
|
|
1526
1726
|
}
|
|
1527
1727
|
}
|
|
1528
|
-
var TopLevelSingleLineStatements$0 = $
|
|
1529
|
-
var statements = $0;
|
|
1530
|
-
return statements.map(([, statement]) => statement);
|
|
1531
|
-
});
|
|
1728
|
+
var TopLevelSingleLineStatements$0 = $P(TopLevelStatement);
|
|
1532
1729
|
function TopLevelSingleLineStatements(state) {
|
|
1533
1730
|
let eventData;
|
|
1534
1731
|
if (state.events) {
|
|
@@ -1551,10 +1748,10 @@ ${input.slice(result.pos)}
|
|
|
1551
1748
|
return result;
|
|
1552
1749
|
}
|
|
1553
1750
|
}
|
|
1554
|
-
var TopLevelStatement$0 = $TS($S($E(_), ModuleItem, StatementDelimiter), function($skip, $loc, $0, $1, $2, $3) {
|
|
1555
|
-
var ws = $
|
|
1556
|
-
var statement = $
|
|
1557
|
-
var delimiter = $
|
|
1751
|
+
var TopLevelStatement$0 = $TS($S($N(EOS), $E(_), ModuleItem, StatementDelimiter), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
1752
|
+
var ws = $2;
|
|
1753
|
+
var statement = $3;
|
|
1754
|
+
var delimiter = $4;
|
|
1558
1755
|
if (ws) {
|
|
1559
1756
|
statement = {
|
|
1560
1757
|
...statement,
|
|
@@ -1785,7 +1982,7 @@ ${input.slice(result.pos)}
|
|
|
1785
1982
|
if (args.length === 1 && args[0].type === "IterationExpression" && args[0].subtype !== "DoStatement" && !args[0].async && module.isEmptyBareBlock(args[0].block)) {
|
|
1786
1983
|
return $skip;
|
|
1787
1984
|
}
|
|
1788
|
-
return [ta?.[0], open,
|
|
1985
|
+
return [ta?.[0], open, insertTrimmingSpace(ws, ""), args, close];
|
|
1789
1986
|
});
|
|
1790
1987
|
function ImplicitArguments(state) {
|
|
1791
1988
|
let eventData;
|
|
@@ -1995,7 +2192,7 @@ ${input.slice(result.pos)}
|
|
|
1995
2192
|
}
|
|
1996
2193
|
var ArgumentList$0 = $S(ArgumentPart, $P($S(CommaDelimiter, $C(NestedImplicitObjectLiteral, NestedArgumentList))));
|
|
1997
2194
|
var ArgumentList$1 = $TS($S(NestedImplicitObjectLiteral), function($skip, $loc, $0, $1) {
|
|
1998
|
-
return
|
|
2195
|
+
return insertTrimmingSpace($1, "");
|
|
1999
2196
|
});
|
|
2000
2197
|
var ArgumentList$2 = NestedArgumentList;
|
|
2001
2198
|
var ArgumentList$3 = $TS($S($E(_), ArgumentPart, $Q($S(CommaDelimiter, $E(_), ArgumentPart))), function($skip, $loc, $0, $1, $2, $3) {
|
|
@@ -2025,7 +2222,7 @@ ${input.slice(result.pos)}
|
|
|
2025
2222
|
}
|
|
2026
2223
|
var NonPipelineArgumentList$0 = $S(NonPipelineArgumentPart, $P($S(CommaDelimiter, $C(NestedImplicitObjectLiteral, NestedArgumentList))));
|
|
2027
2224
|
var NonPipelineArgumentList$1 = $TS($S(NestedImplicitObjectLiteral), function($skip, $loc, $0, $1) {
|
|
2028
|
-
return
|
|
2225
|
+
return insertTrimmingSpace($1, "");
|
|
2029
2226
|
});
|
|
2030
2227
|
var NonPipelineArgumentList$2 = NestedArgumentList;
|
|
2031
2228
|
var NonPipelineArgumentList$3 = $TS($S($E(_), NonPipelineArgumentPart, $Q($S(CommaDelimiter, $E(_), NonPipelineArgumentPart))), function($skip, $loc, $0, $1, $2, $3) {
|
|
@@ -2297,7 +2494,7 @@ ${input.slice(result.pos)}
|
|
|
2297
2494
|
var UnaryExpression$1 = $TS($S(CoffeeDoEnabled, Do, __, $C($S(LeftHandSideExpression, $N($S(__, AssignmentOpSymbol))), ArrowFunction, ExtendedExpression)), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
2298
2495
|
var ws = $3;
|
|
2299
2496
|
var exp = $4;
|
|
2300
|
-
ws =
|
|
2497
|
+
ws = insertTrimmingSpace(ws, "");
|
|
2301
2498
|
return ["(", ...ws, exp, ")()"];
|
|
2302
2499
|
});
|
|
2303
2500
|
function UnaryExpression(state) {
|
|
@@ -4308,7 +4505,7 @@ ${input.slice(result.pos)}
|
|
|
4308
4505
|
if (after.length) {
|
|
4309
4506
|
const spliceRef = module.getRef("splice");
|
|
4310
4507
|
blockPrefix = {
|
|
4311
|
-
children: ["[",
|
|
4508
|
+
children: ["[", insertTrimmingSpace(after, ""), "] = ", spliceRef, ".call(", restIdentifier, ", -", after.length.toString(), ")"],
|
|
4312
4509
|
names: after.flatMap((p) => p.names)
|
|
4313
4510
|
};
|
|
4314
4511
|
}
|
|
@@ -5816,7 +6013,7 @@ ${input.slice(result.pos)}
|
|
|
5816
6013
|
var w = $2;
|
|
5817
6014
|
var decl = $3;
|
|
5818
6015
|
decl.names.forEach((name) => module.operators.add(name));
|
|
5819
|
-
return [
|
|
6016
|
+
return [insertTrimmingSpace(w, ""), decl];
|
|
5820
6017
|
});
|
|
5821
6018
|
var OperatorDeclaration$1 = $TS($S(OperatorSignature, BracedBlock), function($skip, $loc, $0, $1, $2) {
|
|
5822
6019
|
var signature = $1;
|
|
@@ -5872,7 +6069,7 @@ ${input.slice(result.pos)}
|
|
|
5872
6069
|
if (!func) {
|
|
5873
6070
|
func = { $loc: op.$loc, token: "function" };
|
|
5874
6071
|
} else {
|
|
5875
|
-
func = [
|
|
6072
|
+
func = [insertTrimmingSpace(func[0], ""), func[1]];
|
|
5876
6073
|
}
|
|
5877
6074
|
return {
|
|
5878
6075
|
type: "FunctionSignature",
|
|
@@ -6532,6 +6729,7 @@ ${input.slice(result.pos)}
|
|
|
6532
6729
|
var statements = $2;
|
|
6533
6730
|
if (!statements.length)
|
|
6534
6731
|
return $skip;
|
|
6732
|
+
statements = statements.flat();
|
|
6535
6733
|
const first = statements[0];
|
|
6536
6734
|
const ws = first[0];
|
|
6537
6735
|
const indent = ws.at(-1);
|
|
@@ -6568,15 +6766,13 @@ ${input.slice(result.pos)}
|
|
|
6568
6766
|
return result;
|
|
6569
6767
|
}
|
|
6570
6768
|
}
|
|
6571
|
-
var NestedBlockStatement$0 = $TS($S(Nested, $
|
|
6769
|
+
var NestedBlockStatement$0 = $TS($S(Nested, $P(BlockStatementPart)), function($skip, $loc, $0, $1, $2) {
|
|
6572
6770
|
var nested = $1;
|
|
6573
|
-
var
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
}
|
|
6579
|
-
return [nested, statement, delimiter];
|
|
6771
|
+
var statements = $2;
|
|
6772
|
+
return [
|
|
6773
|
+
[nested, ...statements[0]],
|
|
6774
|
+
...statements.slice(1).map((s) => ["", ...s])
|
|
6775
|
+
];
|
|
6580
6776
|
});
|
|
6581
6777
|
function NestedBlockStatement(state) {
|
|
6582
6778
|
let eventData;
|
|
@@ -6600,6 +6796,37 @@ ${input.slice(result.pos)}
|
|
|
6600
6796
|
return result;
|
|
6601
6797
|
}
|
|
6602
6798
|
}
|
|
6799
|
+
var BlockStatementPart$0 = $TS($S($N(EOS), $E(_), StatementListItem, StatementDelimiter), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
6800
|
+
var ws = $2;
|
|
6801
|
+
var statement = $3;
|
|
6802
|
+
var delimiter = $4;
|
|
6803
|
+
if (ws) {
|
|
6804
|
+
statement = { ...statement, children: [ws, ...statement.children] };
|
|
6805
|
+
}
|
|
6806
|
+
return [statement, delimiter];
|
|
6807
|
+
});
|
|
6808
|
+
function BlockStatementPart(state) {
|
|
6809
|
+
let eventData;
|
|
6810
|
+
if (state.events) {
|
|
6811
|
+
const result = state.events.enter?.("BlockStatementPart", state);
|
|
6812
|
+
if (result) {
|
|
6813
|
+
if (result.cache)
|
|
6814
|
+
return result.cache;
|
|
6815
|
+
eventData = result.data;
|
|
6816
|
+
}
|
|
6817
|
+
}
|
|
6818
|
+
if (state.tokenize) {
|
|
6819
|
+
const result = $TOKEN("BlockStatementPart", state, BlockStatementPart$0(state));
|
|
6820
|
+
if (state.events)
|
|
6821
|
+
state.events.exit?.("BlockStatementPart", state, result, eventData);
|
|
6822
|
+
return result;
|
|
6823
|
+
} else {
|
|
6824
|
+
const result = BlockStatementPart$0(state);
|
|
6825
|
+
if (state.events)
|
|
6826
|
+
state.events.exit?.("BlockStatementPart", state, result, eventData);
|
|
6827
|
+
return result;
|
|
6828
|
+
}
|
|
6829
|
+
}
|
|
6603
6830
|
var Literal$0 = $TS($S(LiteralContent), function($skip, $loc, $0, $1) {
|
|
6604
6831
|
return {
|
|
6605
6832
|
type: "Literal",
|
|
@@ -6900,8 +7127,8 @@ ${input.slice(result.pos)}
|
|
|
6900
7127
|
const inclusive = range.token === "..";
|
|
6901
7128
|
range.token = ",";
|
|
6902
7129
|
if (s.type === "Literal" && e.type === "Literal") {
|
|
6903
|
-
const start =
|
|
6904
|
-
const end =
|
|
7130
|
+
const start = literalValue(s);
|
|
7131
|
+
const end = literalValue(e);
|
|
6905
7132
|
if (typeof start !== typeof end) {
|
|
6906
7133
|
throw new Error("Range start and end must be of the same type");
|
|
6907
7134
|
}
|
|
@@ -9204,6 +9431,7 @@ ${input.slice(result.pos)}
|
|
|
9204
9431
|
}
|
|
9205
9432
|
var ExpressionBlock$0 = $TS($S(InsertOpenParen, NestedBlockExpressions, InsertNewline, InsertIndent, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
9206
9433
|
var exps = $2;
|
|
9434
|
+
exps = exps.flat();
|
|
9207
9435
|
if (exps.length === 1) {
|
|
9208
9436
|
let [ws, exp] = exps[0];
|
|
9209
9437
|
switch (exp.type) {
|
|
@@ -9249,6 +9477,7 @@ ${input.slice(result.pos)}
|
|
|
9249
9477
|
}
|
|
9250
9478
|
var ElseExpressionBlock$0 = $TS($S(InsertOpenParen, NestedBlockExpressions, InsertNewline, InsertIndent, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
9251
9479
|
var exps = $2;
|
|
9480
|
+
exps = exps.flat();
|
|
9252
9481
|
if (exps.length === 1) {
|
|
9253
9482
|
let [ws, exp] = exps[0];
|
|
9254
9483
|
switch (exp.type) {
|
|
@@ -9322,7 +9551,14 @@ ${input.slice(result.pos)}
|
|
|
9322
9551
|
return result;
|
|
9323
9552
|
}
|
|
9324
9553
|
}
|
|
9325
|
-
var NestedBlockExpression$0 = $S(Nested,
|
|
9554
|
+
var NestedBlockExpression$0 = $TS($S(Nested, $P(BlockExpressionPart)), function($skip, $loc, $0, $1, $2) {
|
|
9555
|
+
var nested = $1;
|
|
9556
|
+
var expressions = $2;
|
|
9557
|
+
return [
|
|
9558
|
+
[nested, ...expressions[0]],
|
|
9559
|
+
...expressions.slice(1).map((s) => ["", ...s])
|
|
9560
|
+
];
|
|
9561
|
+
});
|
|
9326
9562
|
function NestedBlockExpression(state) {
|
|
9327
9563
|
let eventData;
|
|
9328
9564
|
if (state.events) {
|
|
@@ -9345,6 +9581,37 @@ ${input.slice(result.pos)}
|
|
|
9345
9581
|
return result;
|
|
9346
9582
|
}
|
|
9347
9583
|
}
|
|
9584
|
+
var BlockExpressionPart$0 = $TS($S($N(EOS), $E(_), PostfixedExpression, ExpressionDelimiter), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
9585
|
+
var ws = $2;
|
|
9586
|
+
var exp = $3;
|
|
9587
|
+
var delimiter = $4;
|
|
9588
|
+
if (ws) {
|
|
9589
|
+
exp = { ...exp, children: [ws, ...exp.children] };
|
|
9590
|
+
}
|
|
9591
|
+
return [exp, delimiter];
|
|
9592
|
+
});
|
|
9593
|
+
function BlockExpressionPart(state) {
|
|
9594
|
+
let eventData;
|
|
9595
|
+
if (state.events) {
|
|
9596
|
+
const result = state.events.enter?.("BlockExpressionPart", state);
|
|
9597
|
+
if (result) {
|
|
9598
|
+
if (result.cache)
|
|
9599
|
+
return result.cache;
|
|
9600
|
+
eventData = result.data;
|
|
9601
|
+
}
|
|
9602
|
+
}
|
|
9603
|
+
if (state.tokenize) {
|
|
9604
|
+
const result = $TOKEN("BlockExpressionPart", state, BlockExpressionPart$0(state));
|
|
9605
|
+
if (state.events)
|
|
9606
|
+
state.events.exit?.("BlockExpressionPart", state, result, eventData);
|
|
9607
|
+
return result;
|
|
9608
|
+
} else {
|
|
9609
|
+
const result = BlockExpressionPart$0(state);
|
|
9610
|
+
if (state.events)
|
|
9611
|
+
state.events.exit?.("BlockExpressionPart", state, result, eventData);
|
|
9612
|
+
return result;
|
|
9613
|
+
}
|
|
9614
|
+
}
|
|
9348
9615
|
var IterationStatement$0 = LoopStatement;
|
|
9349
9616
|
var IterationStatement$1 = $T($S($N(CoffeeDoEnabled), DoWhileStatement), function(value) {
|
|
9350
9617
|
return value[1];
|
|
@@ -9493,7 +9760,7 @@ ${input.slice(result.pos)}
|
|
|
9493
9760
|
}
|
|
9494
9761
|
var DoStatement$0 = $TS($S(Do, NoPostfixBracedBlock), function($skip, $loc, $0, $1, $2) {
|
|
9495
9762
|
var block = $2;
|
|
9496
|
-
block =
|
|
9763
|
+
block = insertTrimmingSpace(block, "");
|
|
9497
9764
|
return {
|
|
9498
9765
|
type: "DoStatement",
|
|
9499
9766
|
children: [block],
|
|
@@ -9595,7 +9862,16 @@ ${input.slice(result.pos)}
|
|
|
9595
9862
|
var clause = $1;
|
|
9596
9863
|
var block = $2;
|
|
9597
9864
|
if (clause.blockPrefix) {
|
|
9598
|
-
|
|
9865
|
+
const expressions = [...clause.blockPrefix, ...block.expressions];
|
|
9866
|
+
block = {
|
|
9867
|
+
...block,
|
|
9868
|
+
expressions,
|
|
9869
|
+
children: block.children === block.expressions ? expressions : block.children.map((c) => c === block.expressions ? expressions : c)
|
|
9870
|
+
};
|
|
9871
|
+
if (block.bare) {
|
|
9872
|
+
block.children = [" {\n", ...block.children, "\n}"];
|
|
9873
|
+
block.bare = false;
|
|
9874
|
+
}
|
|
9599
9875
|
}
|
|
9600
9876
|
return {
|
|
9601
9877
|
...clause,
|
|
@@ -9672,7 +9948,7 @@ ${input.slice(result.pos)}
|
|
|
9672
9948
|
[indent, {
|
|
9673
9949
|
type: "IfStatement",
|
|
9674
9950
|
then: block,
|
|
9675
|
-
children: ["if (!(",
|
|
9951
|
+
children: ["if (!(", insertTrimmingSpace($3, ""), ")) ", block]
|
|
9676
9952
|
}]
|
|
9677
9953
|
]
|
|
9678
9954
|
};
|
|
@@ -9727,7 +10003,7 @@ ${input.slice(result.pos)}
|
|
|
9727
10003
|
return result;
|
|
9728
10004
|
}
|
|
9729
10005
|
}
|
|
9730
|
-
var CoffeeForStatementParameters$0 = $TS($S($E($S(Await, __)), InsertOpenParen, CoffeeForDeclaration, $E(CoffeeForIndex), __, $C(In, Of, From), ExpressionWithIndentedApplicationForbidden, $E($S(
|
|
10006
|
+
var CoffeeForStatementParameters$0 = $TS($S($E($S(Await, __)), InsertOpenParen, CoffeeForDeclaration, $E(CoffeeForIndex), __, $C(In, Of, From), ExpressionWithIndentedApplicationForbidden, $E($S($E(_), By, ExpressionWithIndentedApplicationForbidden)), InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
|
|
9731
10007
|
var open = $2;
|
|
9732
10008
|
var declaration = $3;
|
|
9733
10009
|
var index = $4;
|
|
@@ -9737,8 +10013,8 @@ ${input.slice(result.pos)}
|
|
|
9737
10013
|
var close = $9;
|
|
9738
10014
|
let blockPrefix = [];
|
|
9739
10015
|
const indent = module.currentIndent.token + " ";
|
|
9740
|
-
exp =
|
|
9741
|
-
declaration =
|
|
10016
|
+
exp = insertTrimmingSpace(exp, "");
|
|
10017
|
+
declaration = insertTrimmingSpace(declaration, "");
|
|
9742
10018
|
if (kind.token === "from") {
|
|
9743
10019
|
if (step) {
|
|
9744
10020
|
throw new Error("Can't use 'by' with 'from' in CoffeeScript for loops");
|
|
@@ -9776,68 +10052,8 @@ ${input.slice(result.pos)}
|
|
|
9776
10052
|
case "Identifier":
|
|
9777
10053
|
expRef = exp;
|
|
9778
10054
|
break;
|
|
9779
|
-
case "RangeExpression":
|
|
9780
|
-
|
|
9781
|
-
let stepExp = step?.[2];
|
|
9782
|
-
let stepRef;
|
|
9783
|
-
if (stepExp) {
|
|
9784
|
-
stepExp = module.insertTrimmingSpace(stepExp, "");
|
|
9785
|
-
if (stepExp.type === "Literal") {
|
|
9786
|
-
stepRef = stepExp;
|
|
9787
|
-
} else {
|
|
9788
|
-
stepRef = {
|
|
9789
|
-
type: "Ref",
|
|
9790
|
-
base: "step",
|
|
9791
|
-
id: "step"
|
|
9792
|
-
};
|
|
9793
|
-
}
|
|
9794
|
-
}
|
|
9795
|
-
let startRef, endRef;
|
|
9796
|
-
if (start.type === "Literal") {
|
|
9797
|
-
startRef = start;
|
|
9798
|
-
} else if (start.type === "Identifier") {
|
|
9799
|
-
startRef = start;
|
|
9800
|
-
} else {
|
|
9801
|
-
startRef = {
|
|
9802
|
-
type: "Ref",
|
|
9803
|
-
base: "ref",
|
|
9804
|
-
id: "ref"
|
|
9805
|
-
};
|
|
9806
|
-
}
|
|
9807
|
-
if (end.type === "Literal") {
|
|
9808
|
-
endRef = end;
|
|
9809
|
-
} else if (end.type === "Identifier") {
|
|
9810
|
-
endRef = end;
|
|
9811
|
-
} else {
|
|
9812
|
-
endRef = {
|
|
9813
|
-
type: "Ref",
|
|
9814
|
-
base: "ref",
|
|
9815
|
-
id: "ref"
|
|
9816
|
-
};
|
|
9817
|
-
}
|
|
9818
|
-
const startRefDec = startRef !== start ? [startRef, " = ", start, ", "] : [];
|
|
9819
|
-
const endRefDec = endRef !== end ? [endRef, " = ", end, ", "] : [];
|
|
9820
|
-
const varRef2 = declaration;
|
|
9821
|
-
const ascDec = stepRef ? stepRef !== stepExp ? [", step = ", stepExp] : [] : [", asc = ", startRef, " <= ", endRef];
|
|
9822
|
-
declaration = {
|
|
9823
|
-
type: "Declaration",
|
|
9824
|
-
children: ["let ", ...startRefDec, ...endRefDec, counterRef, " = ", varRef2, " = ", startRef, ...ascDec],
|
|
9825
|
-
names: varRef2.names
|
|
9826
|
-
};
|
|
9827
|
-
blockPrefix.push(["", {
|
|
9828
|
-
type: "AssignmentExpression",
|
|
9829
|
-
children: [],
|
|
9830
|
-
names: varRef2.names
|
|
9831
|
-
}]);
|
|
9832
|
-
const counterPart = inclusive ? [counterRef, " <= ", endRef, " : ", counterRef, " >= ", endRef] : [counterRef, " < ", endRef, " : ", counterRef, " > ", endRef];
|
|
9833
|
-
const condition2 = stepRef ? [stepRef, " !== 0 && (", stepRef, " > 0 ? ", ...counterPart, ")"] : ["asc ? ", ...counterPart];
|
|
9834
|
-
const increment2 = stepRef ? [varRef2, " = ", counterRef, " += ", stepRef] : [varRef2, " = asc ? ++", counterRef, " : --", counterRef];
|
|
9835
|
-
return {
|
|
9836
|
-
declaration,
|
|
9837
|
-
children: [$1, open, declaration, "; ", ...condition2, "; ", ...increment2, close],
|
|
9838
|
-
blockPrefix
|
|
9839
|
-
};
|
|
9840
|
-
}
|
|
10055
|
+
case "RangeExpression":
|
|
10056
|
+
return forRange(open, declaration, exp, step?.[2], close);
|
|
9841
10057
|
default:
|
|
9842
10058
|
expRef = {
|
|
9843
10059
|
type: "Ref",
|
|
@@ -9848,11 +10064,11 @@ ${input.slice(result.pos)}
|
|
|
9848
10064
|
const varRef = declaration;
|
|
9849
10065
|
let increment = "++", indexAssignment, assignmentNames = [...varRef.names];
|
|
9850
10066
|
if (index) {
|
|
9851
|
-
index =
|
|
10067
|
+
index = insertTrimmingSpace(index, "");
|
|
9852
10068
|
indexAssignment = [index, "="];
|
|
9853
10069
|
assignmentNames.push(...index.names);
|
|
9854
10070
|
}
|
|
9855
|
-
const expRefDec = expRef !== exp ? [expRef, " = ",
|
|
10071
|
+
const expRefDec = expRef !== exp ? [expRef, " = ", insertTrimmingSpace(exp, ""), ", "] : [];
|
|
9856
10072
|
blockPrefix.push([indent, {
|
|
9857
10073
|
type: "AssignmentExpression",
|
|
9858
10074
|
children: [varRef, " = ", expRef, "[", indexAssignment, counterRef, "]\n"],
|
|
@@ -9866,7 +10082,7 @@ ${input.slice(result.pos)}
|
|
|
9866
10082
|
let condition = [counterRef, " < ", lenRef, "; "];
|
|
9867
10083
|
if (step) {
|
|
9868
10084
|
let [stepWs, , stepExp] = step;
|
|
9869
|
-
stepWs =
|
|
10085
|
+
stepWs = insertTrimmingSpace(stepWs, "");
|
|
9870
10086
|
if (stepExp.type === "Literal") {
|
|
9871
10087
|
increment = [" +=", ...stepWs, stepExp];
|
|
9872
10088
|
if (stepExp.raw[0] === "-") {
|
|
@@ -9898,6 +10114,7 @@ ${input.slice(result.pos)}
|
|
|
9898
10114
|
blockPrefix
|
|
9899
10115
|
};
|
|
9900
10116
|
});
|
|
10117
|
+
var CoffeeForStatementParameters$1 = ForRangeParameters;
|
|
9901
10118
|
function CoffeeForStatementParameters(state) {
|
|
9902
10119
|
let eventData;
|
|
9903
10120
|
if (state.events) {
|
|
@@ -9909,12 +10126,12 @@ ${input.slice(result.pos)}
|
|
|
9909
10126
|
}
|
|
9910
10127
|
}
|
|
9911
10128
|
if (state.tokenize) {
|
|
9912
|
-
const result = $TOKEN("CoffeeForStatementParameters", state, CoffeeForStatementParameters$0(state));
|
|
10129
|
+
const result = $TOKEN("CoffeeForStatementParameters", state, CoffeeForStatementParameters$0(state) || CoffeeForStatementParameters$1(state));
|
|
9913
10130
|
if (state.events)
|
|
9914
10131
|
state.events.exit?.("CoffeeForStatementParameters", state, result, eventData);
|
|
9915
10132
|
return result;
|
|
9916
10133
|
} else {
|
|
9917
|
-
const result = CoffeeForStatementParameters$0(state);
|
|
10134
|
+
const result = CoffeeForStatementParameters$0(state) || CoffeeForStatementParameters$1(state);
|
|
9918
10135
|
if (state.events)
|
|
9919
10136
|
state.events.exit?.("CoffeeForStatementParameters", state, result, eventData);
|
|
9920
10137
|
return result;
|
|
@@ -9924,7 +10141,7 @@ ${input.slice(result.pos)}
|
|
|
9924
10141
|
var ws1 = $1;
|
|
9925
10142
|
var ws2 = $3;
|
|
9926
10143
|
var id = $4;
|
|
9927
|
-
ws2 =
|
|
10144
|
+
ws2 = insertTrimmingSpace(ws1, "");
|
|
9928
10145
|
return {
|
|
9929
10146
|
...id,
|
|
9930
10147
|
children: [...ws1 || [], ...ws2 || [], ...id.children]
|
|
@@ -9998,20 +10215,41 @@ ${input.slice(result.pos)}
|
|
|
9998
10215
|
children: $0
|
|
9999
10216
|
};
|
|
10000
10217
|
});
|
|
10001
|
-
var ForStatementParameters$2 = $TS($S($E($S(Await, __)), OpenParen, __, ForInOfDeclaration, __, $C(In, Of), ExpressionWithIndentedApplicationForbidden, __, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
|
|
10218
|
+
var ForStatementParameters$2 = $TS($S($E($S(Await, __)), OpenParen, __, ForInOfDeclaration, __, $C(In, Of), ExpressionWithIndentedApplicationForbidden, $E($S(__, By, ExpressionWithIndentedApplicationForbidden)), __, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10) {
|
|
10219
|
+
var open = $2;
|
|
10002
10220
|
var declaration = $4;
|
|
10221
|
+
var op = $6;
|
|
10222
|
+
var exp = $7;
|
|
10223
|
+
var step = $8;
|
|
10224
|
+
var close = $10;
|
|
10225
|
+
if (exp.type === "RangeExpression" && op.token === "of") {
|
|
10226
|
+
return forRange(open, declaration, exp, step, close);
|
|
10227
|
+
} else if (step) {
|
|
10228
|
+
throw new Error("for..of/in cannot use 'by' except with range literals");
|
|
10229
|
+
}
|
|
10003
10230
|
return {
|
|
10004
10231
|
declaration,
|
|
10005
10232
|
children: $0
|
|
10006
10233
|
};
|
|
10007
10234
|
});
|
|
10008
|
-
var ForStatementParameters$3 = $TS($S($E($S(Await, __)), InsertOpenParen, ForInOfDeclaration, __, $C(In, Of), ExpressionWithIndentedApplicationForbidden, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
|
|
10235
|
+
var ForStatementParameters$3 = $TS($S($E($S(Await, __)), InsertOpenParen, ForInOfDeclaration, __, $C(In, Of), ExpressionWithIndentedApplicationForbidden, $E($S(__, By, ExpressionWithIndentedApplicationForbidden)), InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
|
|
10236
|
+
var open = $2;
|
|
10009
10237
|
var declaration = $3;
|
|
10238
|
+
var op = $5;
|
|
10239
|
+
var exp = $6;
|
|
10240
|
+
var step = $7;
|
|
10241
|
+
var close = $8;
|
|
10242
|
+
if (exp.type === "RangeExpression" && op.token === "of") {
|
|
10243
|
+
return forRange(open, declaration, exp, step, close);
|
|
10244
|
+
} else if (step) {
|
|
10245
|
+
throw new Error("for..of/in cannot use 'by' except with range literals");
|
|
10246
|
+
}
|
|
10010
10247
|
return {
|
|
10011
10248
|
declaration,
|
|
10012
10249
|
children: $0
|
|
10013
10250
|
};
|
|
10014
10251
|
});
|
|
10252
|
+
var ForStatementParameters$4 = ForRangeParameters;
|
|
10015
10253
|
function ForStatementParameters(state) {
|
|
10016
10254
|
let eventData;
|
|
10017
10255
|
if (state.events) {
|
|
@@ -10023,22 +10261,59 @@ ${input.slice(result.pos)}
|
|
|
10023
10261
|
}
|
|
10024
10262
|
}
|
|
10025
10263
|
if (state.tokenize) {
|
|
10026
|
-
const result = $TOKEN("ForStatementParameters", state, ForStatementParameters$0(state) || ForStatementParameters$1(state) || ForStatementParameters$2(state) || ForStatementParameters$3(state));
|
|
10264
|
+
const result = $TOKEN("ForStatementParameters", state, ForStatementParameters$0(state) || ForStatementParameters$1(state) || ForStatementParameters$2(state) || ForStatementParameters$3(state) || ForStatementParameters$4(state));
|
|
10027
10265
|
if (state.events)
|
|
10028
10266
|
state.events.exit?.("ForStatementParameters", state, result, eventData);
|
|
10029
10267
|
return result;
|
|
10030
10268
|
} else {
|
|
10031
|
-
const result = ForStatementParameters$0(state) || ForStatementParameters$1(state) || ForStatementParameters$2(state) || ForStatementParameters$3(state);
|
|
10269
|
+
const result = ForStatementParameters$0(state) || ForStatementParameters$1(state) || ForStatementParameters$2(state) || ForStatementParameters$3(state) || ForStatementParameters$4(state);
|
|
10032
10270
|
if (state.events)
|
|
10033
10271
|
state.events.exit?.("ForStatementParameters", state, result, eventData);
|
|
10034
10272
|
return result;
|
|
10035
10273
|
}
|
|
10036
10274
|
}
|
|
10275
|
+
var ForRangeParameters$0 = $TS($S($E($S(Await, __)), OpenParen, OpenBracket, RangeExpression, CloseBracket, $E($S(__, By, ExpressionWithIndentedApplicationForbidden)), CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
|
|
10276
|
+
var open = $2;
|
|
10277
|
+
var exp = $4;
|
|
10278
|
+
var step = $6;
|
|
10279
|
+
var close = $7;
|
|
10280
|
+
return forRange(open, null, exp, step, close);
|
|
10281
|
+
});
|
|
10282
|
+
var ForRangeParameters$1 = $TS($S($E($S(Await, __)), InsertOpenParen, OpenBracket, RangeExpression, CloseBracket, $E($S(__, By, ExpressionWithIndentedApplicationForbidden)), InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
|
|
10283
|
+
var open = $2;
|
|
10284
|
+
var exp = $4;
|
|
10285
|
+
var step = $6;
|
|
10286
|
+
var close = $7;
|
|
10287
|
+
return forRange(open, null, exp, step, close);
|
|
10288
|
+
});
|
|
10289
|
+
function ForRangeParameters(state) {
|
|
10290
|
+
let eventData;
|
|
10291
|
+
if (state.events) {
|
|
10292
|
+
const result = state.events.enter?.("ForRangeParameters", state);
|
|
10293
|
+
if (result) {
|
|
10294
|
+
if (result.cache)
|
|
10295
|
+
return result.cache;
|
|
10296
|
+
eventData = result.data;
|
|
10297
|
+
}
|
|
10298
|
+
}
|
|
10299
|
+
if (state.tokenize) {
|
|
10300
|
+
const result = $TOKEN("ForRangeParameters", state, ForRangeParameters$0(state) || ForRangeParameters$1(state));
|
|
10301
|
+
if (state.events)
|
|
10302
|
+
state.events.exit?.("ForRangeParameters", state, result, eventData);
|
|
10303
|
+
return result;
|
|
10304
|
+
} else {
|
|
10305
|
+
const result = ForRangeParameters$0(state) || ForRangeParameters$1(state);
|
|
10306
|
+
if (state.events)
|
|
10307
|
+
state.events.exit?.("ForRangeParameters", state, result, eventData);
|
|
10308
|
+
return result;
|
|
10309
|
+
}
|
|
10310
|
+
}
|
|
10037
10311
|
var ForInOfDeclaration$0 = $TS($S(Var, ForBinding), function($skip, $loc, $0, $1, $2) {
|
|
10038
10312
|
var binding = $2;
|
|
10039
10313
|
return {
|
|
10040
10314
|
type: "ForDeclaration",
|
|
10041
10315
|
children: $0,
|
|
10316
|
+
declare: $1,
|
|
10042
10317
|
names: binding.names
|
|
10043
10318
|
};
|
|
10044
10319
|
});
|
|
@@ -10066,12 +10341,13 @@ ${input.slice(result.pos)}
|
|
|
10066
10341
|
return result;
|
|
10067
10342
|
}
|
|
10068
10343
|
}
|
|
10069
|
-
var ForDeclaration$0 = $TS($S(LetOrConst,
|
|
10344
|
+
var ForDeclaration$0 = $TS($S(LetOrConst, ForBinding), function($skip, $loc, $0, $1, $2) {
|
|
10070
10345
|
var c = $1;
|
|
10071
|
-
var binding = $
|
|
10346
|
+
var binding = $2;
|
|
10072
10347
|
return {
|
|
10073
10348
|
type: "ForDeclaration",
|
|
10074
10349
|
children: [c, binding],
|
|
10350
|
+
declare: c,
|
|
10075
10351
|
names: binding.names
|
|
10076
10352
|
};
|
|
10077
10353
|
});
|
|
@@ -10081,6 +10357,7 @@ ${input.slice(result.pos)}
|
|
|
10081
10357
|
return {
|
|
10082
10358
|
type: "ForDeclaration",
|
|
10083
10359
|
children: [c, binding],
|
|
10360
|
+
declare: c,
|
|
10084
10361
|
names: binding.names
|
|
10085
10362
|
};
|
|
10086
10363
|
});
|
|
@@ -10407,9 +10684,9 @@ ${input.slice(result.pos)}
|
|
|
10407
10684
|
if (!first)
|
|
10408
10685
|
return $skip;
|
|
10409
10686
|
const result = rest.map(([ws, _comma, exp, col]) => {
|
|
10410
|
-
exp =
|
|
10687
|
+
exp = insertTrimmingSpace(exp, "");
|
|
10411
10688
|
if (ws.length)
|
|
10412
|
-
return [
|
|
10689
|
+
return [insertTrimmingSpace("case ", ws), exp, col];
|
|
10413
10690
|
return ["case ", exp, col];
|
|
10414
10691
|
});
|
|
10415
10692
|
result.unshift(first);
|
|
@@ -10659,7 +10936,7 @@ ${input.slice(result.pos)}
|
|
|
10659
10936
|
var close = $3;
|
|
10660
10937
|
if (expression.type === "ParenthesizedExpression")
|
|
10661
10938
|
return expression;
|
|
10662
|
-
expression =
|
|
10939
|
+
expression = insertTrimmingSpace(expression, "");
|
|
10663
10940
|
return {
|
|
10664
10941
|
type: "ParenthesizedExpression",
|
|
10665
10942
|
children: [open, expression, close],
|
|
@@ -11640,7 +11917,7 @@ ${input.slice(result.pos)}
|
|
|
11640
11917
|
...spec,
|
|
11641
11918
|
children: [
|
|
11642
11919
|
ws,
|
|
11643
|
-
|
|
11920
|
+
insertTrimmingSpace(spec[0], ""),
|
|
11644
11921
|
spec.children.slice(1)
|
|
11645
11922
|
]
|
|
11646
11923
|
};
|
|
@@ -12700,7 +12977,7 @@ ${input.slice(result.pos)}
|
|
|
12700
12977
|
var str = $2;
|
|
12701
12978
|
return {
|
|
12702
12979
|
type: "StringLiteral",
|
|
12703
|
-
token: `"${
|
|
12980
|
+
token: `"${modifyString(str.token)}"`,
|
|
12704
12981
|
$loc
|
|
12705
12982
|
};
|
|
12706
12983
|
});
|
|
@@ -12708,7 +12985,7 @@ ${input.slice(result.pos)}
|
|
|
12708
12985
|
var str = $2;
|
|
12709
12986
|
return {
|
|
12710
12987
|
type: "StringLiteral",
|
|
12711
|
-
token: `'${
|
|
12988
|
+
token: `'${modifyString(str.token)}'`,
|
|
12712
12989
|
$loc
|
|
12713
12990
|
};
|
|
12714
12991
|
});
|
|
@@ -12861,24 +13138,7 @@ ${input.slice(result.pos)}
|
|
|
12861
13138
|
var s = $2;
|
|
12862
13139
|
var parts = $3;
|
|
12863
13140
|
var e = $4;
|
|
12864
|
-
|
|
12865
|
-
return {
|
|
12866
|
-
type: "StringLiteral",
|
|
12867
|
-
token: parts.length ? `"${module.modifyString(parts[0].token)}"` : '""',
|
|
12868
|
-
$loc
|
|
12869
|
-
};
|
|
12870
|
-
}
|
|
12871
|
-
parts.forEach((part) => {
|
|
12872
|
-
if (part.token) {
|
|
12873
|
-
const str = part.token.replace(/(`|\$\{)/g, "\\$1");
|
|
12874
|
-
part.token = module.modifyString(str);
|
|
12875
|
-
}
|
|
12876
|
-
});
|
|
12877
|
-
s.token = e.token = "`";
|
|
12878
|
-
return {
|
|
12879
|
-
type: "TemplateLiteral",
|
|
12880
|
-
children: [s, parts, e]
|
|
12881
|
-
};
|
|
13141
|
+
return processCoffeeInterpolation(s, parts, e, $loc);
|
|
12882
13142
|
});
|
|
12883
13143
|
function CoffeeInterpolatedDoubleQuotedString(state) {
|
|
12884
13144
|
let eventData;
|
|
@@ -13718,7 +13978,7 @@ ${input.slice(result.pos)}
|
|
|
13718
13978
|
}
|
|
13719
13979
|
var Trimmed_$0 = $TV($Q(_), function($skip, $loc, $0, $1) {
|
|
13720
13980
|
var ws = $0;
|
|
13721
|
-
return
|
|
13981
|
+
return insertTrimmingSpace(ws, "");
|
|
13722
13982
|
});
|
|
13723
13983
|
function Trimmed_(state) {
|
|
13724
13984
|
let eventData;
|
|
@@ -16582,7 +16842,7 @@ ${input.slice(result.pos)}
|
|
|
16582
16842
|
if (part.name.type === "ComputedPropertyName") {
|
|
16583
16843
|
rest.push(part);
|
|
16584
16844
|
} else {
|
|
16585
|
-
parts.push([part.name, "={",
|
|
16845
|
+
parts.push([part.name, "={", insertTrimmingSpace(part.value, ""), "}"]);
|
|
16586
16846
|
}
|
|
16587
16847
|
break;
|
|
16588
16848
|
case "SpreadProperty":
|
|
@@ -16683,7 +16943,7 @@ ${input.slice(result.pos)}
|
|
|
16683
16943
|
}
|
|
16684
16944
|
}
|
|
16685
16945
|
var JSXShorthandString$0 = $TR($EXPECT($R52, fail, "JSXShorthandString /(?:[\\w\\-:]+|\\([^()]*\\)|\\[[^\\[\\]]*\\])+/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
|
|
16686
|
-
return
|
|
16946
|
+
return quoteString($0);
|
|
16687
16947
|
});
|
|
16688
16948
|
var JSXShorthandString$1 = $TS($S(TemplateLiteral), function($skip, $loc, $0, $1) {
|
|
16689
16949
|
return ["{", $1, "}"];
|
|
@@ -18783,7 +19043,110 @@ ${input.slice(result.pos)}
|
|
|
18783
19043
|
return result;
|
|
18784
19044
|
}
|
|
18785
19045
|
}
|
|
18786
|
-
var
|
|
19046
|
+
var TypeTemplateSubstitution$0 = $S(SubstitutionStart, Type, __, CloseBrace);
|
|
19047
|
+
function TypeTemplateSubstitution(state) {
|
|
19048
|
+
let eventData;
|
|
19049
|
+
if (state.events) {
|
|
19050
|
+
const result = state.events.enter?.("TypeTemplateSubstitution", state);
|
|
19051
|
+
if (result) {
|
|
19052
|
+
if (result.cache)
|
|
19053
|
+
return result.cache;
|
|
19054
|
+
eventData = result.data;
|
|
19055
|
+
}
|
|
19056
|
+
}
|
|
19057
|
+
if (state.tokenize) {
|
|
19058
|
+
const result = $TOKEN("TypeTemplateSubstitution", state, TypeTemplateSubstitution$0(state));
|
|
19059
|
+
if (state.events)
|
|
19060
|
+
state.events.exit?.("TypeTemplateSubstitution", state, result, eventData);
|
|
19061
|
+
return result;
|
|
19062
|
+
} else {
|
|
19063
|
+
const result = TypeTemplateSubstitution$0(state);
|
|
19064
|
+
if (state.events)
|
|
19065
|
+
state.events.exit?.("TypeTemplateSubstitution", state, result, eventData);
|
|
19066
|
+
return result;
|
|
19067
|
+
}
|
|
19068
|
+
}
|
|
19069
|
+
var TypeTemplateLiteral$0 = $TS($S(Backtick, $Q($C(TemplateCharacters, TypeTemplateSubstitution)), Backtick), function($skip, $loc, $0, $1, $2, $3) {
|
|
19070
|
+
return {
|
|
19071
|
+
type: "TemplateLiteral",
|
|
19072
|
+
children: $0
|
|
19073
|
+
};
|
|
19074
|
+
});
|
|
19075
|
+
var TypeTemplateLiteral$1 = CoffeeInterpolatedDoubleQuotedTypeLiteral;
|
|
19076
|
+
function TypeTemplateLiteral(state) {
|
|
19077
|
+
let eventData;
|
|
19078
|
+
if (state.events) {
|
|
19079
|
+
const result = state.events.enter?.("TypeTemplateLiteral", state);
|
|
19080
|
+
if (result) {
|
|
19081
|
+
if (result.cache)
|
|
19082
|
+
return result.cache;
|
|
19083
|
+
eventData = result.data;
|
|
19084
|
+
}
|
|
19085
|
+
}
|
|
19086
|
+
if (state.tokenize) {
|
|
19087
|
+
const result = $TOKEN("TypeTemplateLiteral", state, TypeTemplateLiteral$0(state) || TypeTemplateLiteral$1(state));
|
|
19088
|
+
if (state.events)
|
|
19089
|
+
state.events.exit?.("TypeTemplateLiteral", state, result, eventData);
|
|
19090
|
+
return result;
|
|
19091
|
+
} else {
|
|
19092
|
+
const result = TypeTemplateLiteral$0(state) || TypeTemplateLiteral$1(state);
|
|
19093
|
+
if (state.events)
|
|
19094
|
+
state.events.exit?.("TypeTemplateLiteral", state, result, eventData);
|
|
19095
|
+
return result;
|
|
19096
|
+
}
|
|
19097
|
+
}
|
|
19098
|
+
var CoffeeStringTypeSubstitution$0 = $S(CoffeeSubstitutionStart, Type, __, CloseBrace);
|
|
19099
|
+
function CoffeeStringTypeSubstitution(state) {
|
|
19100
|
+
let eventData;
|
|
19101
|
+
if (state.events) {
|
|
19102
|
+
const result = state.events.enter?.("CoffeeStringTypeSubstitution", state);
|
|
19103
|
+
if (result) {
|
|
19104
|
+
if (result.cache)
|
|
19105
|
+
return result.cache;
|
|
19106
|
+
eventData = result.data;
|
|
19107
|
+
}
|
|
19108
|
+
}
|
|
19109
|
+
if (state.tokenize) {
|
|
19110
|
+
const result = $TOKEN("CoffeeStringTypeSubstitution", state, CoffeeStringTypeSubstitution$0(state));
|
|
19111
|
+
if (state.events)
|
|
19112
|
+
state.events.exit?.("CoffeeStringTypeSubstitution", state, result, eventData);
|
|
19113
|
+
return result;
|
|
19114
|
+
} else {
|
|
19115
|
+
const result = CoffeeStringTypeSubstitution$0(state);
|
|
19116
|
+
if (state.events)
|
|
19117
|
+
state.events.exit?.("CoffeeStringTypeSubstitution", state, result, eventData);
|
|
19118
|
+
return result;
|
|
19119
|
+
}
|
|
19120
|
+
}
|
|
19121
|
+
var CoffeeInterpolatedDoubleQuotedTypeLiteral$0 = $TS($S(CoffeeInterpolationEnabled, DoubleQuote, $Q($C(CoffeeDoubleQuotedStringCharacters, CoffeeStringTypeSubstitution)), DoubleQuote), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
19122
|
+
var s = $2;
|
|
19123
|
+
var parts = $3;
|
|
19124
|
+
var e = $4;
|
|
19125
|
+
return processCoffeeInterpolation(s, parts, e, $loc);
|
|
19126
|
+
});
|
|
19127
|
+
function CoffeeInterpolatedDoubleQuotedTypeLiteral(state) {
|
|
19128
|
+
let eventData;
|
|
19129
|
+
if (state.events) {
|
|
19130
|
+
const result = state.events.enter?.("CoffeeInterpolatedDoubleQuotedTypeLiteral", state);
|
|
19131
|
+
if (result) {
|
|
19132
|
+
if (result.cache)
|
|
19133
|
+
return result.cache;
|
|
19134
|
+
eventData = result.data;
|
|
19135
|
+
}
|
|
19136
|
+
}
|
|
19137
|
+
if (state.tokenize) {
|
|
19138
|
+
const result = $TOKEN("CoffeeInterpolatedDoubleQuotedTypeLiteral", state, CoffeeInterpolatedDoubleQuotedTypeLiteral$0(state));
|
|
19139
|
+
if (state.events)
|
|
19140
|
+
state.events.exit?.("CoffeeInterpolatedDoubleQuotedTypeLiteral", state, result, eventData);
|
|
19141
|
+
return result;
|
|
19142
|
+
} else {
|
|
19143
|
+
const result = CoffeeInterpolatedDoubleQuotedTypeLiteral$0(state);
|
|
19144
|
+
if (state.events)
|
|
19145
|
+
state.events.exit?.("CoffeeInterpolatedDoubleQuotedTypeLiteral", state, result, eventData);
|
|
19146
|
+
return result;
|
|
19147
|
+
}
|
|
19148
|
+
}
|
|
19149
|
+
var TypeLiteral$0 = TypeTemplateLiteral;
|
|
18787
19150
|
var TypeLiteral$1 = Literal;
|
|
18788
19151
|
var TypeLiteral$2 = $TS($S($EXPECT($L161, fail, 'TypeLiteral "void"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
|
|
18789
19152
|
return { type: "VoidType", $loc, token: $1 };
|
|
@@ -20542,20 +20905,6 @@ ${input.slice(result.pos)}
|
|
|
20542
20905
|
}
|
|
20543
20906
|
}
|
|
20544
20907
|
});
|
|
20545
|
-
module.modifyString = function(str) {
|
|
20546
|
-
return str.replace(/(^.?|[^\\]{2})(\\\\)*\n/g, "$1$2\\n");
|
|
20547
|
-
};
|
|
20548
|
-
module.unmodifyString = function(str) {
|
|
20549
|
-
return str.replace(/\\n/g, "\n");
|
|
20550
|
-
};
|
|
20551
|
-
module.quoteString = function(str) {
|
|
20552
|
-
str = str.replace(/\\/g, "\\\\");
|
|
20553
|
-
if (str.includes('"') && !str.includes("'")) {
|
|
20554
|
-
return "'" + str.replace(/'/g, "\\'") + "'";
|
|
20555
|
-
} else {
|
|
20556
|
-
return '"' + str.replace(/"/g, '\\"') + '"';
|
|
20557
|
-
}
|
|
20558
|
-
};
|
|
20559
20908
|
});
|
|
20560
20909
|
function Reset(state) {
|
|
20561
20910
|
let eventData;
|
|
@@ -20601,8 +20950,8 @@ ${input.slice(result.pos)}
|
|
|
20601
20950
|
throw new Error("Glob pattern must have call or member expression value");
|
|
20602
20951
|
}
|
|
20603
20952
|
let value = part.value ?? part.name;
|
|
20604
|
-
const wValue =
|
|
20605
|
-
value = prefix.concat(
|
|
20953
|
+
const wValue = getTrimmingSpace(part.value);
|
|
20954
|
+
value = prefix.concat(insertTrimmingSpace(value, ""));
|
|
20606
20955
|
if (wValue)
|
|
20607
20956
|
value.unshift(wValue);
|
|
20608
20957
|
if (part.type === "SpreadProperty") {
|
|
@@ -20713,43 +21062,6 @@ ${input.slice(result.pos)}
|
|
|
20713
21062
|
};
|
|
20714
21063
|
}
|
|
20715
21064
|
};
|
|
20716
|
-
module.literalValue = function(literal) {
|
|
20717
|
-
let { raw } = literal;
|
|
20718
|
-
switch (raw) {
|
|
20719
|
-
case "null":
|
|
20720
|
-
return null;
|
|
20721
|
-
case "true":
|
|
20722
|
-
return true;
|
|
20723
|
-
case "false":
|
|
20724
|
-
return false;
|
|
20725
|
-
}
|
|
20726
|
-
if (raw.startsWith('"') && raw.endsWith('"') || raw.startsWith("'") && raw.endsWith("'")) {
|
|
20727
|
-
return raw.slice(1, -1);
|
|
20728
|
-
}
|
|
20729
|
-
const numeric = literal.children.find(
|
|
20730
|
-
(child) => child.type === "NumericLiteral"
|
|
20731
|
-
);
|
|
20732
|
-
if (numeric) {
|
|
20733
|
-
raw = raw.replace(/_/g, "");
|
|
20734
|
-
const { token } = numeric;
|
|
20735
|
-
if (token.endsWith("n")) {
|
|
20736
|
-
return BigInt(raw.slice(0, -1));
|
|
20737
|
-
} else if (token.match(/[\.eE]/)) {
|
|
20738
|
-
return parseFloat(raw);
|
|
20739
|
-
} else if (token.startsWith("0")) {
|
|
20740
|
-
switch (token.charAt(1).toLowerCase()) {
|
|
20741
|
-
case "x":
|
|
20742
|
-
return parseInt(raw.replace(/0[xX]/, ""), 16);
|
|
20743
|
-
case "b":
|
|
20744
|
-
return parseInt(raw.replace(/0[bB]/, ""), 2);
|
|
20745
|
-
case "o":
|
|
20746
|
-
return parseInt(raw.replace(/0[oO]/, ""), 8);
|
|
20747
|
-
}
|
|
20748
|
-
}
|
|
20749
|
-
return parseInt(raw, 10);
|
|
20750
|
-
}
|
|
20751
|
-
throw new Error("Unrecognized literal " + JSON.stringify(literal));
|
|
20752
|
-
};
|
|
20753
21065
|
module.expressionizeIfClause = function(clause, b, e) {
|
|
20754
21066
|
const children = clause.children.slice(1);
|
|
20755
21067
|
children.push("?", b);
|
|
@@ -21089,16 +21401,16 @@ ${input.slice(result.pos)}
|
|
|
21089
21401
|
}
|
|
21090
21402
|
let children;
|
|
21091
21403
|
if (op2.call) {
|
|
21092
|
-
wsOp =
|
|
21404
|
+
wsOp = insertTrimmingSpace(wsOp, "");
|
|
21093
21405
|
if (op2.reversed) {
|
|
21094
|
-
wsB =
|
|
21406
|
+
wsB = insertTrimmingSpace(wsB, "");
|
|
21095
21407
|
children = [wsOp, op2.call, "(", wsB, b, ", ", a, ")", op2.suffix];
|
|
21096
21408
|
} else {
|
|
21097
21409
|
children = [wsOp, op2.call, "(", a, ",", wsB, b, ")", op2.suffix];
|
|
21098
21410
|
}
|
|
21099
21411
|
} else if (op2.method) {
|
|
21100
|
-
wsOp =
|
|
21101
|
-
wsB =
|
|
21412
|
+
wsOp = insertTrimmingSpace(wsOp, "");
|
|
21413
|
+
wsB = insertTrimmingSpace(wsB, "");
|
|
21102
21414
|
if (op2.reversed) {
|
|
21103
21415
|
children = [wsB, b, wsOp, ".", op2.method, "(", a, ")"];
|
|
21104
21416
|
} else {
|
|
@@ -21208,39 +21520,6 @@ ${input.slice(result.pos)}
|
|
|
21208
21520
|
}
|
|
21209
21521
|
return target;
|
|
21210
21522
|
};
|
|
21211
|
-
module.insertTrimmingSpace = function(target, c) {
|
|
21212
|
-
if (!target)
|
|
21213
|
-
return target;
|
|
21214
|
-
if (Array.isArray(target))
|
|
21215
|
-
return target.map((e, i) => {
|
|
21216
|
-
if (i === 0)
|
|
21217
|
-
return module.insertTrimmingSpace(e, c);
|
|
21218
|
-
return e;
|
|
21219
|
-
});
|
|
21220
|
-
if (target.children)
|
|
21221
|
-
return Object.assign({}, target, {
|
|
21222
|
-
children: target.children.map((e, i) => {
|
|
21223
|
-
if (i === 0)
|
|
21224
|
-
return module.insertTrimmingSpace(e, c);
|
|
21225
|
-
return e;
|
|
21226
|
-
})
|
|
21227
|
-
});
|
|
21228
|
-
if (target.token)
|
|
21229
|
-
return Object.assign({}, target, {
|
|
21230
|
-
token: target.token.replace(/^ ?/, c)
|
|
21231
|
-
});
|
|
21232
|
-
return target;
|
|
21233
|
-
};
|
|
21234
|
-
module.getTrimmingSpace = function(target) {
|
|
21235
|
-
if (!target)
|
|
21236
|
-
return;
|
|
21237
|
-
if (Array.isArray(target))
|
|
21238
|
-
return module.getTrimmingSpace(target[0]);
|
|
21239
|
-
if (target.children)
|
|
21240
|
-
return module.getTrimmingSpace(target.children[0]);
|
|
21241
|
-
if (target.token)
|
|
21242
|
-
return target.token.match(/^ ?/)[0];
|
|
21243
|
-
};
|
|
21244
21523
|
const initialSpacingRe = /^(?:\r?\n|\n)*((?:\r?\n|\n)\s+)/;
|
|
21245
21524
|
module.dedentBlockSubstitutions = function($02) {
|
|
21246
21525
|
const [s, strWithSubstitutions, e] = $02;
|
|
@@ -21330,7 +21609,7 @@ ${input.slice(result.pos)}
|
|
|
21330
21609
|
const spliceRef = module.getRef("splice");
|
|
21331
21610
|
blockPrefix = {
|
|
21332
21611
|
type: "PostRestBindingElements",
|
|
21333
|
-
children: ["[",
|
|
21612
|
+
children: ["[", insertTrimmingSpace(after, ""), "] = ", spliceRef, ".call(", restIdentifier, ", -", after.length.toString(), ")"],
|
|
21334
21613
|
names: after.flatMap((p) => p.names)
|
|
21335
21614
|
};
|
|
21336
21615
|
}
|
|
@@ -22714,13 +22993,20 @@ ${input.slice(result.pos)}
|
|
|
22714
22993
|
var {
|
|
22715
22994
|
clone,
|
|
22716
22995
|
deepCopy,
|
|
22996
|
+
forRange,
|
|
22717
22997
|
gatherNodes,
|
|
22718
22998
|
gatherRecursive,
|
|
22719
22999
|
gatherRecursiveAll,
|
|
22720
23000
|
gatherRecursiveWithinFunction,
|
|
23001
|
+
getTrimmingSpace,
|
|
22721
23002
|
hasAwait,
|
|
22722
23003
|
hasYield,
|
|
23004
|
+
insertTrimmingSpace,
|
|
22723
23005
|
isFunction,
|
|
23006
|
+
literalValue,
|
|
23007
|
+
modifyString,
|
|
23008
|
+
processCoffeeInterpolation,
|
|
23009
|
+
quoteString,
|
|
22724
23010
|
removeParentPointers
|
|
22725
23011
|
} = require_lib();
|
|
22726
23012
|
}
|