@primmel/primmel 1.21.13 → 1.21.15
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/src/check.d.ts.map +1 -1
- package/dist/src/check.js +31 -3
- package/dist/src/check.js.map +1 -1
- package/dist/src/expressions/index.d.ts +14 -0
- package/dist/src/expressions/index.d.ts.map +1 -1
- package/dist/src/expressions/index.js +42 -2
- package/dist/src/expressions/index.js.map +1 -1
- package/dist/src/ser-des/config/process.d.ts.map +1 -1
- package/dist/src/ser-des/config/process.js +7 -4
- package/dist/src/ser-des/config/process.js.map +1 -1
- package/dist-browser/index.mjs +665 -645
- package/dist-cli/primmel.mjs +52 -7
- package/package.json +1 -1
package/dist-cli/primmel.mjs
CHANGED
|
@@ -2561,7 +2561,7 @@ var OPERATORS = [
|
|
|
2561
2561
|
".",
|
|
2562
2562
|
"|"
|
|
2563
2563
|
];
|
|
2564
|
-
var NAV_OPS = /* @__PURE__ */ new Set(["forAll", "exists", "select"]);
|
|
2564
|
+
var NAV_OPS = /* @__PURE__ */ new Set(["forAll", "exists", "select", "collect"]);
|
|
2565
2565
|
function lex(src) {
|
|
2566
2566
|
const tokens = [];
|
|
2567
2567
|
let i = 0;
|
|
@@ -2695,6 +2695,29 @@ var ExprParser = class {
|
|
|
2695
2695
|
return inner;
|
|
2696
2696
|
}
|
|
2697
2697
|
if (tok.kind === "name") {
|
|
2698
|
+
if (tok.value === "true" || tok.value === "false") {
|
|
2699
|
+
return { type: "bool", value: tok.value === "true" };
|
|
2700
|
+
}
|
|
2701
|
+
if (tok.value === "if") {
|
|
2702
|
+
const cond = this.parseLevel(0);
|
|
2703
|
+
const thenTok = this.take();
|
|
2704
|
+
if (thenTok.kind !== "name" || thenTok.value !== "then") {
|
|
2705
|
+
throw new Error('expression: expected "then" in the conditional');
|
|
2706
|
+
}
|
|
2707
|
+
const whenTrue = this.parseLevel(0);
|
|
2708
|
+
const elseTok = this.take();
|
|
2709
|
+
if (elseTok.kind !== "name" || elseTok.value !== "else") {
|
|
2710
|
+
throw new Error('expression: expected "else" in the conditional');
|
|
2711
|
+
}
|
|
2712
|
+
const whenFalse = this.parseLevel(0);
|
|
2713
|
+
const endTok = this.take();
|
|
2714
|
+
if (endTok.kind !== "name" || endTok.value !== "endif") {
|
|
2715
|
+
throw new Error(
|
|
2716
|
+
'expression: expected "endif" to close the conditional'
|
|
2717
|
+
);
|
|
2718
|
+
}
|
|
2719
|
+
return { type: "ifelse", cond, then: whenTrue, else: whenFalse };
|
|
2720
|
+
}
|
|
2698
2721
|
const segs = [tok.value];
|
|
2699
2722
|
while (this.peek()?.kind === "op" && this.peek().value === ".") {
|
|
2700
2723
|
this.take();
|
|
@@ -2734,7 +2757,7 @@ var ExprParser = class {
|
|
|
2734
2757
|
const opTok = this.take();
|
|
2735
2758
|
if (opTok.kind !== "name" || !NAV_OPS.has(opTok.value)) {
|
|
2736
2759
|
throw new Error(
|
|
2737
|
-
"expression: expected a collection iterator (forAll | exists | select)"
|
|
2760
|
+
"expression: expected a collection iterator (forAll | exists | select | collect)"
|
|
2738
2761
|
);
|
|
2739
2762
|
}
|
|
2740
2763
|
if (this.peek()?.kind !== "op" || this.peek().value !== "(") {
|
|
@@ -2785,6 +2808,13 @@ function freeIdentifiers(ast) {
|
|
|
2785
2808
|
return;
|
|
2786
2809
|
case "str":
|
|
2787
2810
|
return;
|
|
2811
|
+
case "bool":
|
|
2812
|
+
return;
|
|
2813
|
+
case "ifelse":
|
|
2814
|
+
walk(node.cond, bound);
|
|
2815
|
+
walk(node.then, bound);
|
|
2816
|
+
walk(node.else, bound);
|
|
2817
|
+
return;
|
|
2788
2818
|
case "name": {
|
|
2789
2819
|
if (bound.has(node.path[0].split(".")[0])) {
|
|
2790
2820
|
return;
|
|
@@ -2823,6 +2853,10 @@ function renderExpression(ast) {
|
|
|
2823
2853
|
return String(ast.value);
|
|
2824
2854
|
case "str":
|
|
2825
2855
|
return "'" + ast.value + "'";
|
|
2856
|
+
case "bool":
|
|
2857
|
+
return ast.value ? "true" : "false";
|
|
2858
|
+
case "ifelse":
|
|
2859
|
+
return "if " + renderExpression(ast.cond) + " then " + renderExpression(ast.then) + " else " + renderExpression(ast.else) + " endif";
|
|
2826
2860
|
case "name":
|
|
2827
2861
|
return ast.path.join(".");
|
|
2828
2862
|
case "call":
|
|
@@ -4080,9 +4114,6 @@ var dumpProcess = function(process2, ctx) {
|
|
|
4080
4114
|
}
|
|
4081
4115
|
out += " }\n";
|
|
4082
4116
|
}
|
|
4083
|
-
for (const req of process2.stepRequires ?? []) {
|
|
4084
|
-
out += " requires { " + req + " }\n";
|
|
4085
|
-
}
|
|
4086
4117
|
const inputIds = process2.inputRefs && process2.inputRefs.length > 0 ? process2.inputRefs : process2.input.map((r) => r.id);
|
|
4087
4118
|
if (inputIds.length > 0) {
|
|
4088
4119
|
out += " reference_data_registry {\n";
|
|
@@ -26538,9 +26569,12 @@ function checkPackage(dir, options = {}) {
|
|
|
26538
26569
|
if (INLINE_FUNCTION_WORDS.has(call)) {
|
|
26539
26570
|
continue;
|
|
26540
26571
|
}
|
|
26572
|
+
if (globalExprNames.has(call)) {
|
|
26573
|
+
continue;
|
|
26574
|
+
}
|
|
26541
26575
|
if (call.includes(".")) {
|
|
26542
26576
|
const root = call.split(".")[0];
|
|
26543
|
-
if (argNames.has(root) || root === "self" || CONTEXT_ROOTS.has(root)) {
|
|
26577
|
+
if (argNames.has(root) || globalExprNames.has(root) || root === "self" || CONTEXT_ROOTS.has(root)) {
|
|
26544
26578
|
continue;
|
|
26545
26579
|
}
|
|
26546
26580
|
}
|
|
@@ -26700,6 +26734,17 @@ function checkPackage(dir, options = {}) {
|
|
|
26700
26734
|
return null;
|
|
26701
26735
|
case "str":
|
|
26702
26736
|
return null;
|
|
26737
|
+
case "bool":
|
|
26738
|
+
return null;
|
|
26739
|
+
case "ifelse": {
|
|
26740
|
+
kindOf(node.cond);
|
|
26741
|
+
const l = kindOf(node.then);
|
|
26742
|
+
const r = kindOf(node.else);
|
|
26743
|
+
if (l !== void 0 && r !== void 0 && l !== null && r !== null && l !== r) {
|
|
26744
|
+
kindMixErr(node, l, r);
|
|
26745
|
+
}
|
|
26746
|
+
return l !== void 0 && l !== null ? l : r;
|
|
26747
|
+
}
|
|
26703
26748
|
case "name": {
|
|
26704
26749
|
const root = node.path[0];
|
|
26705
26750
|
if (node.path.length > 1 && (root === "self" || CONTEXT_ROOTS.has(root))) {
|
|
@@ -26747,7 +26792,7 @@ function checkPackage(dir, options = {}) {
|
|
|
26747
26792
|
case "unop":
|
|
26748
26793
|
return node.op === "not" ? null : kindOf(node.operand);
|
|
26749
26794
|
case "nav":
|
|
26750
|
-
return node.op === "select" ? void 0 : null;
|
|
26795
|
+
return node.op === "select" ? void 0 : node.op === "collect" ? kindOf(node.body) : null;
|
|
26751
26796
|
case "binop": {
|
|
26752
26797
|
if (["<=", ">=", "<", ">", "=", "!=", "\u2260"].includes(node.op)) {
|
|
26753
26798
|
const l2 = kindOf(node.left);
|
package/package.json
CHANGED