-
+
{node.type} - {node.varbs}
-
{#each values as color}
@@ -52,14 +58,19 @@
-
+ {#if checkWhere(node.where, color, node.varbs[0])}
+
+ {:else}
+
✗
+ removed by where
+ {/if}
@@ -67,33 +78,5 @@
→{nodeResult.result}
+
-
diff --git a/packages/palette-lint/src/lint-language/lint-language.ts b/packages/palette-lint/src/lint-language/lint-language.ts
index 259fc88..40e0acb 100644
--- a/packages/palette-lint/src/lint-language/lint-language.ts
+++ b/packages/palette-lint/src/lint-language/lint-language.ts
@@ -161,6 +161,10 @@ export class LLNode {
toString() {
return "Node";
}
+ copy() {
+ console.log("asd", this);
+ return new LLNode();
+ }
}
export class LLExpression extends LLNode {
@@ -185,6 +189,9 @@ export class LLExpression extends LLNode {
toString(): string {
return this.value.toString();
}
+ copy() {
+ return new LLExpression(this.value);
+ }
}
const ConjunctionTypes = ["and", "or", "not", "none", "id"] as const;
@@ -241,6 +248,9 @@ export class LLConjunction extends LLNode {
if (childrenTypes.some((x) => x === false)) return false;
return new LLConjunction(exprType, childrenTypes);
}
+ copy() {
+ return new LLConjunction(this.type, this.children);
+ }
toString(): string {
if (this.type === "id") return this.children[0].toString();
if (this.type === "none") return "";
@@ -267,6 +277,9 @@ export class LLValueArray extends LLNode {
if (childrenTypes.some((x) => x === false)) return false;
return new LLValueArray(childrenTypes);
}
+ copy() {
+ return new LLValueArray(this.children);
+ }
toString(): string {
return `[${this.children.map((x) => x.toString()).join(", ")}]`;
}
@@ -285,6 +298,9 @@ export class LLBool extends LLNode {
if (typeof value !== "boolean") return false;
return new LLBool(value);
}
+ copy() {
+ return new LLBool(this.value);
+ }
toString(): string {
return this.value ? "TRUE" : "FALSE";
}
@@ -304,6 +320,9 @@ export class LLVariable extends LLNode {
if (typeof value !== "string") return false;
return new LLVariable(value);
}
+ copy() {
+ return new LLVariable(this.value);
+ }
toString(): string {
return this.value;
}
@@ -333,6 +352,9 @@ export class LLColor extends LLNode {
}
return false;
}
+ copy() {
+ return new LLColor(this.value, this.constructorString);
+ }
toString(): string {
return this.constructorString;
// return this.value.toHex();
@@ -352,6 +374,9 @@ export class LLNumber extends LLNode {
if (typeof value !== "number") return false;
return new LLNumber(value);
}
+ copy() {
+ return new LLNumber(this.value);
+ }
toString(): string {
return this.value.toString();
}
@@ -402,6 +427,9 @@ export class LLNumberOp extends LLNode {
}
return new LLNumberOp(opType, leftType, rightType);
}
+ copy() {
+ return new LLNumberOp(this.type, this.left, this.right);
+ }
toString(): string {
let left = this.left.toString();
let right = this.right.toString();
@@ -542,6 +570,9 @@ export class LLPredicate extends LLNode {
if (!leftType || !rightType) return false;
return new LLPredicate(predicateType, leftType, rightType, threshold);
}
+ copy() {
+ return new LLPredicate(this.type, this.left, this.right, this.threshold);
+ }
toString(): string {
let type = "" + this.type;
const left = this.left.toString();
@@ -586,6 +617,9 @@ export class LLValue extends LLNode {
if (!value) return false;
return value;
}
+ copy() {
+ return new LLValue(this.value);
+ }
toString(): string {
return this.value.toString();
}
@@ -677,6 +711,9 @@ export class LLValueFunction extends LLNode {
const params = getParams(op, node);
return new LLValueFunction(op.primaryKey, input, params);
}
+ copy() {
+ return new LLValueFunction(this.type, this.input, this.params);
+ }
toString(): string {
const params = Object.values(this.params).join(", ");
const paramString = params.length ? `, ${params}` : "";
@@ -897,6 +934,15 @@ export class LLQuantifier extends LLNode {
where && tryTypes([LLPredicate, LLValueFunction], options)(where)
);
}
+ copy() {
+ return new LLQuantifier(
+ this.type,
+ this.input,
+ this.predicate,
+ this.varbs,
+ this.where
+ );
+ }
toString(): string {
const varbs = this.varbs.join(", ");
let target = this.input.toString();
@@ -994,6 +1040,9 @@ export class LLAggregate extends LLNode {
}
return new LLAggregate(reduceType, childType);
}
+ copy() {
+ return new LLAggregate(this.type, this.children);
+ }
toString(): string {
return `${this.type}(${this.children.toString()})`;
}
@@ -1104,6 +1153,9 @@ export class LLMap extends LLNode {
}
return new LLMap(op, childType, func, varb);
}
+ copy() {
+ return new LLMap(this.type, this.children, this.func, this.varb);
+ }
toString(): string {
const type = this.type;
const funcStr = this.func.toString();