Premier commit déjà bien avancé

This commit is contained in:
2025-11-10 18:33:24 +01:00
commit db4f0508cb
652 changed files with 440521 additions and 0 deletions

View File

@ -0,0 +1,14 @@
import {Tree} from "@lezer/common"
export function compareTree(a: Tree, b: Tree) {
let curA = a.cursor(), curB = b.cursor()
for (;;) {
let mismatch = null, next = false
if (curA.type != curB.type) mismatch = `Node type mismatch (${curA.name} vs ${curB.name})`
else if (curA.from != curB.from) mismatch = `Start pos mismatch for ${curA.name}: ${curA.from} vs ${curB.from}`
else if (curA.to != curB.to) mismatch = `End pos mismatch for ${curA.name}: ${curA.to} vs ${curB.to}`
else if ((next = curA.next()) != curB.next()) mismatch = `Tree size mismatch`
if (mismatch) throw new Error(`${mismatch}\n ${a}\n ${b}`)
if (!next) break
}
}