@trebco/treb 30.6.3 → 30.8.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.
@@ -136,9 +136,10 @@ const binary_operators_precendence: PrecedenceList = {
136
136
  ':': 13, // range operator
137
137
  };
138
138
 
139
- /**
139
+ /* *
140
140
  * binary ops are sorted by length so we can compare long ops first
141
- */
141
+ switching to a composite w/ unary operators
142
+ * /
142
143
  const binary_operators = Object.keys(binary_operators_precendence).sort(
143
144
  (a, b) => b.length - a.length,
144
145
  );
@@ -147,8 +148,17 @@ const binary_operators = Object.keys(binary_operators_precendence).sort(
147
148
  * unary operators. atm we have no precedence issues, unary operators
148
149
  * always have absolute precedence. (for numbers, these are properly part
149
150
  * of the number, but consider `=-SUM(1,2)` -- this is an operator).
151
+ *
152
+ * implicit intersection operator should now have precedence over +/-.
153
+ */
154
+ const unary_operators: PrecedenceList = { '@': 50, '-': 100, '+': 100 };
155
+
156
+ /**
157
+ * to avoid the double - and +, we're just adding our one extra unary
158
+ * operator. doing this dynamically would be silly, although this does
159
+ * make this code more fragile.
150
160
  */
151
- const unary_operators: PrecedenceList = { '-': 100, '+': 100 };
161
+ const composite_operators: string[] = [...Object.keys(binary_operators_precendence), '@'].sort((a, b) => b.length - a.length);
152
162
 
153
163
  /**
154
164
  * parser for spreadsheet language.
@@ -2092,7 +2102,7 @@ export class Parser {
2092
2102
  }
2093
2103
 
2094
2104
  protected ConsumeOperator(): ExpressionUnit | null {
2095
- for (const operator of binary_operators) {
2105
+ for (const operator of composite_operators) {
2096
2106
  if (this.expression.substr(this.index, operator.length) === operator) {
2097
2107
  const position = this.index;
2098
2108
  this.index += operator.length;