@graffiticode/basis 1.5.8 → 1.5.10
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/package.json +1 -1
- package/src/compiler.js +44 -2
package/package.json
CHANGED
package/src/compiler.js
CHANGED
|
@@ -49,6 +49,10 @@ class Visitor {
|
|
|
49
49
|
fn(node, options, resume);
|
|
50
50
|
}
|
|
51
51
|
} catch (x) {
|
|
52
|
+
console.log(
|
|
53
|
+
"Vistor/visit()",
|
|
54
|
+
"ERROR: " + x
|
|
55
|
+
);
|
|
52
56
|
resume(error(x.stack));
|
|
53
57
|
}
|
|
54
58
|
}
|
|
@@ -278,6 +282,11 @@ export class Checker extends Visitor {
|
|
|
278
282
|
const val = node;
|
|
279
283
|
resume(err, val);
|
|
280
284
|
}
|
|
285
|
+
IF(node, options, resume) {
|
|
286
|
+
const err = [];
|
|
287
|
+
const val = node;
|
|
288
|
+
resume(err, val);
|
|
289
|
+
}
|
|
281
290
|
OF(node, options, resume) {
|
|
282
291
|
const err = [];
|
|
283
292
|
const val = node;
|
|
@@ -365,6 +374,11 @@ export class Transformer extends Visitor {
|
|
|
365
374
|
return nid;
|
|
366
375
|
}
|
|
367
376
|
match(options, patterns, node) {
|
|
377
|
+
// console.log(
|
|
378
|
+
// "match()",
|
|
379
|
+
// "patterns=" + JSON.stringify(patterns, null, 2),
|
|
380
|
+
// "node=" + JSON.stringify(node, null, 2),
|
|
381
|
+
// );
|
|
368
382
|
if (patterns.size === 0 || node === undefined) {
|
|
369
383
|
return false;
|
|
370
384
|
}
|
|
@@ -681,9 +695,14 @@ export class Transformer extends Visitor {
|
|
|
681
695
|
CASE(node, options, resume) {
|
|
682
696
|
// FIXME this isn't ASYNC compatible
|
|
683
697
|
options.SYNC = true;
|
|
684
|
-
this.visit(node.elts[0], options, (
|
|
698
|
+
this.visit(node.elts[0], options, (e0, v0) => {
|
|
685
699
|
const e0Node = this.node(node.elts[0]);
|
|
686
|
-
const expr = (
|
|
700
|
+
const expr = (
|
|
701
|
+
e0Node.tag === 'BOOL' ||
|
|
702
|
+
e0Node.tag === 'NUM'
|
|
703
|
+
) && e0Node || {
|
|
704
|
+
tag: 'STR', elts: [`${v0}`]
|
|
705
|
+
};
|
|
687
706
|
let foundMatch = false;
|
|
688
707
|
const patterns = [];
|
|
689
708
|
for (var i = 1; i < node.elts.length; i++) {
|
|
@@ -711,6 +730,29 @@ export class Transformer extends Visitor {
|
|
|
711
730
|
});
|
|
712
731
|
});
|
|
713
732
|
}
|
|
733
|
+
IF(node, options, resume) {
|
|
734
|
+
this.visit(node.elts[0], options, (e0, v0) => {
|
|
735
|
+
if (!!v0) {
|
|
736
|
+
this.visit(node.elts[1], options, (e1, v1) => {
|
|
737
|
+
const err = [
|
|
738
|
+
...e0,
|
|
739
|
+
...e1,
|
|
740
|
+
];
|
|
741
|
+
const val = v1;
|
|
742
|
+
resume(err, val);
|
|
743
|
+
});
|
|
744
|
+
} else {
|
|
745
|
+
this.visit(node.elts[2], options, (e2, v2) => {
|
|
746
|
+
const err = [
|
|
747
|
+
...e0,
|
|
748
|
+
...e2,
|
|
749
|
+
];
|
|
750
|
+
const val = v2;
|
|
751
|
+
resume(err, val);
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
});
|
|
755
|
+
}
|
|
714
756
|
}
|
|
715
757
|
|
|
716
758
|
export class Renderer {
|