clarity-pattern-parser 10.2.11 → 10.2.13

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.
@@ -205,11 +205,17 @@
205
205
  }
206
206
  normalize(startIndex = this._firstIndex) {
207
207
  let length = 0;
208
+ let runningOffset = startIndex;
208
209
  if (this.children.length === 0) {
209
210
  length = this._value.length;
210
211
  }
211
212
  else {
212
- length = this.children.reduce((acc, c) => acc + c.normalize(acc + startIndex), startIndex) - startIndex;
213
+ for (let x = 0; x < this.children.length; x++) {
214
+ const child = this.children[x];
215
+ const childLength = child.normalize(runningOffset);
216
+ runningOffset += childLength;
217
+ length += childLength;
218
+ }
213
219
  }
214
220
  this._firstIndex = startIndex;
215
221
  this._lastIndex = Math.max(startIndex + length - 1, 0);
@@ -2947,7 +2953,7 @@
2947
2953
  }
2948
2954
  else if (lastBinaryNode != null && lastUnaryNode != null && delimiterNode != null) {
2949
2955
  const precedence = this._precedenceMap[name];
2950
- const lastPrecendece = lastBinaryNode == null ? 0 : this._precedenceMap[lastBinaryNode.name] || -1;
2956
+ const lastPrecendece = lastBinaryNode == null ? 0 : this._precedenceMap[lastBinaryNode.name] == null ? -1 : this._precedenceMap[lastBinaryNode.name];
2951
2957
  const association = this._binaryAssociation[i];
2952
2958
  if (precedence === lastPrecendece && association === Association.right) {
2953
2959
  const node = createNode(name, [lastUnaryNode, delimiterNode]);