@fluffjs/cli 0.1.12 → 0.1.14
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/CodeGenerator.js +6 -0
- package/ExpressionTransformer.js +4 -4
- package/package.json +1 -1
package/CodeGenerator.js
CHANGED
|
@@ -247,6 +247,12 @@ export class CodeGenerator {
|
|
|
247
247
|
throw new Error(`Binding for ${binding.name} is missing expression`);
|
|
248
248
|
}
|
|
249
249
|
result.e = this.internExpression(binding.expression);
|
|
250
|
+
if (binding.pipes && binding.pipes.length > 0) {
|
|
251
|
+
result.p = binding.pipes.map(pipe => ({
|
|
252
|
+
n: pipe.name,
|
|
253
|
+
a: pipe.args.map(arg => this.internExpression(arg))
|
|
254
|
+
}));
|
|
255
|
+
}
|
|
250
256
|
return result;
|
|
251
257
|
}
|
|
252
258
|
internExpression(expr) {
|
package/ExpressionTransformer.js
CHANGED
|
@@ -190,7 +190,7 @@ export class ExpressionTransformer {
|
|
|
190
190
|
const { loc } = e;
|
|
191
191
|
return loc !== null && typeof loc === 'object' && 'index' in loc && typeof loc.index === 'number';
|
|
192
192
|
}
|
|
193
|
-
static tokenizeExpression(code, startPos = 0) {
|
|
193
|
+
static tokenizeExpression(code, delimiters, startPos = 0) {
|
|
194
194
|
const substring = code.slice(startPos);
|
|
195
195
|
let tokens = [];
|
|
196
196
|
try {
|
|
@@ -237,7 +237,7 @@ export class ExpressionTransformer {
|
|
|
237
237
|
tokenCount = i;
|
|
238
238
|
break;
|
|
239
239
|
}
|
|
240
|
-
if (depth === 0 && (token.type.label
|
|
240
|
+
if (depth === 0 && delimiters.includes(token.type.label)) {
|
|
241
241
|
stopIndex = token.start;
|
|
242
242
|
stopReason = 'delimiter';
|
|
243
243
|
tokenCount = i;
|
|
@@ -305,7 +305,7 @@ export class ExpressionTransformer {
|
|
|
305
305
|
static parsePrimaryExpression(text, startPos) {
|
|
306
306
|
const offset = startPos ?? 0;
|
|
307
307
|
const pipes = [];
|
|
308
|
-
const tokenResult = ExpressionTransformer.tokenizeExpression(text, offset);
|
|
308
|
+
const tokenResult = ExpressionTransformer.tokenizeExpression(text, ['|', ';'], offset);
|
|
309
309
|
if (tokenResult.tokenCount === 0) {
|
|
310
310
|
return {
|
|
311
311
|
expression: text.slice(offset)
|
|
@@ -344,7 +344,7 @@ export class ExpressionTransformer {
|
|
|
344
344
|
}
|
|
345
345
|
const prefix = `_arg${args.length + 1}=`;
|
|
346
346
|
const argText = prefix + text.slice(pos);
|
|
347
|
-
const argTokenResult = ExpressionTransformer.tokenizeExpression(argText, 0);
|
|
347
|
+
const argTokenResult = ExpressionTransformer.tokenizeExpression(argText, ['|', ':', ';'], 0);
|
|
348
348
|
const argEndPos = argTokenResult.index - prefix.length;
|
|
349
349
|
if (argTokenResult.tokenCount > 0) {
|
|
350
350
|
const argCandidate = text.slice(pos, pos + argEndPos)
|