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.
- package/dist/index.browser.js +8 -2
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +8 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/ast/Node.test.ts +20 -2
- package/src/ast/Node.ts +7 -1
- package/src/patterns/ExpressionPattern.test.ts +11 -11
- package/src/patterns/ExpressionPattern.ts +2 -2
package/dist/index.js
CHANGED
|
@@ -203,11 +203,17 @@ class Node {
|
|
|
203
203
|
}
|
|
204
204
|
normalize(startIndex = this._firstIndex) {
|
|
205
205
|
let length = 0;
|
|
206
|
+
let runningOffset = startIndex;
|
|
206
207
|
if (this.children.length === 0) {
|
|
207
208
|
length = this._value.length;
|
|
208
209
|
}
|
|
209
210
|
else {
|
|
210
|
-
|
|
211
|
+
for (let x = 0; x < this.children.length; x++) {
|
|
212
|
+
const child = this.children[x];
|
|
213
|
+
const childLength = child.normalize(runningOffset);
|
|
214
|
+
runningOffset += childLength;
|
|
215
|
+
length += childLength;
|
|
216
|
+
}
|
|
211
217
|
}
|
|
212
218
|
this._firstIndex = startIndex;
|
|
213
219
|
this._lastIndex = Math.max(startIndex + length - 1, 0);
|
|
@@ -2945,7 +2951,7 @@ class ExpressionPattern {
|
|
|
2945
2951
|
}
|
|
2946
2952
|
else if (lastBinaryNode != null && lastUnaryNode != null && delimiterNode != null) {
|
|
2947
2953
|
const precedence = this._precedenceMap[name];
|
|
2948
|
-
const lastPrecendece = lastBinaryNode == null ? 0 : this._precedenceMap[lastBinaryNode.name]
|
|
2954
|
+
const lastPrecendece = lastBinaryNode == null ? 0 : this._precedenceMap[lastBinaryNode.name] == null ? -1 : this._precedenceMap[lastBinaryNode.name];
|
|
2949
2955
|
const association = this._binaryAssociation[i];
|
|
2950
2956
|
if (precedence === lastPrecendece && association === Association.right) {
|
|
2951
2957
|
const node = createNode(name, [lastUnaryNode, delimiterNode]);
|