diff --git a/dist/shared.js b/dist/shared.js index 83400e0..bc6aa71 100644 --- a/dist/shared.js +++ b/dist/shared.js @@ -35,14 +35,14 @@ export function MapTreeRefs(tree, str, sharedRef) { ref: Reference.blank(), bytes: 0 }; - while (stack.length > 0) { + while (true) { const curr = stack.pop(); if (!curr) - continue; + break; if (curr.ref === sharedRef) { // Don't calculate forward progression if not needed - if (cursor.bytes !== curr.end) - ProgressCursor(str, curr.end, cursor); + if (cursor.bytes !== curr.start) + ProgressCursor(str, curr.start, cursor); curr.ref = new ReferenceRange(cursor.ref.clone(), cursor.ref // no alloc fill in ); stack.push(curr); // revisit node for ref.end mapping (after children) diff --git a/docs/source/changelog.md b/docs/source/changelog.md index e65ed62..b5e353c 100644 --- a/docs/source/changelog.md +++ b/docs/source/changelog.md @@ -2,6 +2,11 @@ ## Version 4.0.5 +### Fixes: + - [x] References generated on successful pass not having the correct start reference + +## Version 4.0.5 + ### Fixes: - [x] Hexadecimal characters weren't encoding correctly (`\x6b` == `k`) - [x] Reduced changes of wasm infinitely allocating to basically zero (as long as you don't try and parse an infinite string) diff --git a/docs/source/static/dist/bnf-parser.js b/docs/source/static/dist/bnf-parser.js index f81c172..6fcadca 100644 --- a/docs/source/static/dist/bnf-parser.js +++ b/docs/source/static/dist/bnf-parser.js @@ -1794,14 +1794,14 @@ function MapTreeRefs$1(tree, str, sharedRef) { ref: Reference$1.blank(), bytes: 0 }; - while (stack.length > 0) { + while (true) { const curr = stack.pop(); if (!curr) - continue; + break; if (curr.ref === sharedRef) { // Don't calculate forward progression if not needed - if (cursor.bytes !== curr.end) - ProgressCursor$1(str, curr.end, cursor); + if (cursor.bytes !== curr.start) + ProgressCursor$1(str, curr.start, cursor); curr.ref = new ReferenceRange$1(cursor.ref.clone(), cursor.ref // no alloc fill in ); stack.push(curr); // revisit node for ref.end mapping (after children) @@ -1956,14 +1956,14 @@ function MapTreeRefs(tree, str, sharedRef) { ref: Reference.blank(), bytes: 0 }; - while (stack.length > 0) { + while (true) { const curr = stack.pop(); if (!curr) - continue; + break; if (curr.ref === sharedRef) { // Don't calculate forward progression if not needed - if (cursor.bytes !== curr.end) - ProgressCursor(str, curr.end, cursor); + if (cursor.bytes !== curr.start) + ProgressCursor(str, curr.start, cursor); curr.ref = new ReferenceRange(cursor.ref.clone(), cursor.ref // no alloc fill in ); stack.push(curr); // revisit node for ref.end mapping (after children) diff --git a/source/wasm/run.ts b/source/wasm/run.ts index c63f468..a0409c9 100644 --- a/source/wasm/run.ts +++ b/source/wasm/run.ts @@ -80,13 +80,13 @@ function MapTreeRefs(tree: SyntaxNode, str: string, sharedRef: ReferenceRange) { bytes: 0 }; - while (stack.length > 0) { + while (true) { const curr = stack.pop(); - if (!curr) continue; + if (!curr) break; if (curr.ref === sharedRef) { // Don't calculate forward progression if not needed - if (cursor.bytes !== curr.end) ProgressCursor(str, curr.end, cursor); + if (cursor.bytes !== curr.start) ProgressCursor(str, curr.start, cursor); curr.ref = new ReferenceRange( cursor.ref.clone(),