simple-graph-query 2.5.1 → 2.5.2
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.
|
@@ -49080,6 +49080,12 @@ class ForgeExprEvaluator extends AbstractParseTreeVisitor_1.AbstractParseTreeVis
|
|
|
49080
49080
|
this.cacheResult(ctx, freeVarsKey, value);
|
|
49081
49081
|
return value;
|
|
49082
49082
|
}
|
|
49083
|
+
if (multExpr.TWO_TOK() && result.length > 2) {
|
|
49084
|
+
this.environmentStack.pop();
|
|
49085
|
+
const value = false;
|
|
49086
|
+
this.cacheResult(ctx, freeVarsKey, value);
|
|
49087
|
+
return value;
|
|
49088
|
+
}
|
|
49083
49089
|
}
|
|
49084
49090
|
}
|
|
49085
49091
|
this.environmentStack.pop();
|
|
@@ -49111,7 +49117,9 @@ class ForgeExprEvaluator extends AbstractParseTreeVisitor_1.AbstractParseTreeVis
|
|
|
49111
49117
|
return value;
|
|
49112
49118
|
}
|
|
49113
49119
|
else if (multExpr.TWO_TOK()) {
|
|
49114
|
-
|
|
49120
|
+
const value = result.length === 2;
|
|
49121
|
+
this.cacheResult(ctx, freeVarsKey, value);
|
|
49122
|
+
return value;
|
|
49115
49123
|
}
|
|
49116
49124
|
}
|
|
49117
49125
|
// TODO: don't have support for SUM_TOK yet
|
|
@@ -49205,12 +49213,27 @@ class ForgeExprEvaluator extends AbstractParseTreeVisitor_1.AbstractParseTreeVis
|
|
|
49205
49213
|
if (!isBoolean(leftChildValue)) {
|
|
49206
49214
|
throw new Error("IMP operator expected 2 boolean operands!");
|
|
49207
49215
|
}
|
|
49216
|
+
const expr3Values = ctx.expr3() ?? [];
|
|
49217
|
+
const thenExpr = expr3Values[0];
|
|
49218
|
+
const elseExpr = expr3Values[1];
|
|
49219
|
+
if (ctx.ELSE_TOK()) {
|
|
49220
|
+
if (!thenExpr || !elseExpr) {
|
|
49221
|
+
throw new Error("Expected the ELSE operator to have 2 operands!");
|
|
49222
|
+
}
|
|
49223
|
+
const branchValue = this.visit(leftChildValue ? thenExpr : elseExpr);
|
|
49224
|
+
if (!isBoolean(branchValue)) {
|
|
49225
|
+
throw new Error("IMP operator expected 2 boolean operands!");
|
|
49226
|
+
}
|
|
49227
|
+
return branchValue;
|
|
49228
|
+
}
|
|
49208
49229
|
if (!leftChildValue) {
|
|
49209
49230
|
// short circuit if the antecedent is false
|
|
49210
49231
|
return true;
|
|
49211
49232
|
}
|
|
49212
|
-
|
|
49213
|
-
|
|
49233
|
+
if (!thenExpr) {
|
|
49234
|
+
throw new Error("Expected the IMP operator to have a consequent expression!");
|
|
49235
|
+
}
|
|
49236
|
+
const rightChildValue = this.visit(thenExpr);
|
|
49214
49237
|
if (!isBoolean(rightChildValue)) {
|
|
49215
49238
|
throw new Error("IMP operator expected 2 boolean operands!");
|
|
49216
49239
|
}
|
|
@@ -49426,37 +49449,31 @@ class ForgeExprEvaluator extends AbstractParseTreeVisitor_1.AbstractParseTreeVis
|
|
|
49426
49449
|
results = leftNum >= rightNum;
|
|
49427
49450
|
break;
|
|
49428
49451
|
case "in":
|
|
49452
|
+
case "ni": {
|
|
49453
|
+
let membershipResult;
|
|
49429
49454
|
// this should be true if the left value is equal to the right value,
|
|
49430
49455
|
// or a subset of it
|
|
49431
49456
|
if (isTupleArray(leftChildValue) && isTupleArray(rightChildValue)) {
|
|
49432
49457
|
if (areTupleArraysEqual(leftChildValue, rightChildValue)) {
|
|
49433
|
-
|
|
49458
|
+
membershipResult = true;
|
|
49434
49459
|
}
|
|
49435
49460
|
else {
|
|
49436
49461
|
// check if left is subset of right
|
|
49437
|
-
|
|
49462
|
+
membershipResult = isTupleArraySubset(leftChildValue, rightChildValue);
|
|
49438
49463
|
}
|
|
49439
49464
|
}
|
|
49440
49465
|
else if (isTupleArray(rightChildValue)) {
|
|
49441
|
-
|
|
49466
|
+
membershipResult = rightChildValue.some((tuple) => tuple.length === 1 && tuple[0] === leftChildValue);
|
|
49442
49467
|
}
|
|
49443
49468
|
else {
|
|
49444
49469
|
// left is a tuple array but right is a single value, so false
|
|
49445
|
-
|
|
49470
|
+
membershipResult = false;
|
|
49446
49471
|
}
|
|
49472
|
+
results = ctx.compareOp()?.text === "ni" ? !membershipResult : membershipResult;
|
|
49447
49473
|
break;
|
|
49474
|
+
}
|
|
49448
49475
|
case "is":
|
|
49449
49476
|
throw new Error("**NOT IMPLEMENTING FOR NOW** Type Check (`is`)");
|
|
49450
|
-
case "ni":
|
|
49451
|
-
results.push(["**UNIMPLEMENTED** Set Non-Membership (`ni`)"]);
|
|
49452
|
-
// TODO: implement this using leftValue and rightValue
|
|
49453
|
-
// for now, just returning over here. what we need to do instead
|
|
49454
|
-
// is to implement this, set the value of results to what we get
|
|
49455
|
-
// from this, and then call break (so that we can negate before
|
|
49456
|
-
// returning the final value, if required)
|
|
49457
|
-
return results;
|
|
49458
|
-
// removed by dead control flow
|
|
49459
|
-
{} // redundant, but it won't be once we implement the TODO above
|
|
49460
49477
|
default:
|
|
49461
49478
|
throw new Error(`Unexpected compare operator provided: ${ctx.compareOp()?.text}`);
|
|
49462
49479
|
}
|
|
@@ -49479,13 +49496,13 @@ class ForgeExprEvaluator extends AbstractParseTreeVisitor_1.AbstractParseTreeVis
|
|
|
49479
49496
|
const childrenResults = this.visit(ctx.expr8());
|
|
49480
49497
|
//console.log('childrenResults:', childrenResults);
|
|
49481
49498
|
if (ctx.SET_TOK()) {
|
|
49482
|
-
|
|
49499
|
+
return childrenResults;
|
|
49483
49500
|
}
|
|
49484
49501
|
if (ctx.ONE_TOK()) {
|
|
49485
49502
|
return isTupleArray(childrenResults) && childrenResults.length === 1;
|
|
49486
49503
|
}
|
|
49487
49504
|
if (ctx.TWO_TOK()) {
|
|
49488
|
-
|
|
49505
|
+
return isTupleArray(childrenResults) && childrenResults.length === 2;
|
|
49489
49506
|
}
|
|
49490
49507
|
if (ctx.NO_TOK()) {
|
|
49491
49508
|
return isTupleArray(childrenResults) && childrenResults.length === 0;
|
package/package.json
CHANGED