@dra2020/baseclient 1.0.142 → 1.0.143
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/baseclient.js
CHANGED
|
@@ -1577,6 +1577,23 @@ function tokIsUnary(tt) {
|
|
|
1577
1577
|
case TokType.And: return false;
|
|
1578
1578
|
case TokType.Or: return false;
|
|
1579
1579
|
case TokType.Colon: return false;
|
|
1580
|
+
case TokType.GreaterThan: return false;
|
|
1581
|
+
case TokType.GreaterThanEqual: return false;
|
|
1582
|
+
case TokType.Equal: return false;
|
|
1583
|
+
case TokType.LessThan: return false;
|
|
1584
|
+
case TokType.LessThanEqual: return false;
|
|
1585
|
+
case TokType.NotEqual: return false;
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
function tokIsArithmetic(tt) {
|
|
1589
|
+
switch (tt) {
|
|
1590
|
+
case TokType.Text: return false;
|
|
1591
|
+
case TokType.OpenParen: return false;
|
|
1592
|
+
case TokType.CloseParen: return false;
|
|
1593
|
+
case TokType.Not: return false;
|
|
1594
|
+
case TokType.And: return false;
|
|
1595
|
+
case TokType.Or: return false;
|
|
1596
|
+
case TokType.Colon: return false;
|
|
1580
1597
|
// Nominally binary, but written as "prop: < 3" so appears as unary operator where test is comparative to prop value
|
|
1581
1598
|
case TokType.GreaterThan: return true;
|
|
1582
1599
|
case TokType.GreaterThanEqual: return true;
|
|
@@ -1709,6 +1726,8 @@ class Parser {
|
|
|
1709
1726
|
this.clauses = clauses;
|
|
1710
1727
|
this.combineParenthetical();
|
|
1711
1728
|
this.convertOpToText();
|
|
1729
|
+
this.combineArithmetic();
|
|
1730
|
+
this.convertOpToText();
|
|
1712
1731
|
this.combineBinary(TokType.Colon);
|
|
1713
1732
|
this.convertOpToText();
|
|
1714
1733
|
this.combineUnary();
|
|
@@ -1785,6 +1804,19 @@ class Parser {
|
|
|
1785
1804
|
}
|
|
1786
1805
|
}
|
|
1787
1806
|
}
|
|
1807
|
+
combineArithmetic() {
|
|
1808
|
+
// go backwards to handle not not
|
|
1809
|
+
for (let i = this.clauses.length - 1; i >= 0; i--) {
|
|
1810
|
+
let c = this.clauses[i];
|
|
1811
|
+
if (tokIsArithmetic(c.op.tt)) {
|
|
1812
|
+
let argclause = (i < this.clauses.length - 1) ? { op: c.op, operand1: this.clauses[i + 1] } : undefined;
|
|
1813
|
+
if (argclause)
|
|
1814
|
+
this.clauses.splice(i, 2, argclause);
|
|
1815
|
+
else
|
|
1816
|
+
this.clauses.splice(i, 1);
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1788
1820
|
combineUnary() {
|
|
1789
1821
|
// go backwards to handle not not
|
|
1790
1822
|
for (let i = this.clauses.length - 1; i >= 0; i--) {
|