What's the best to test and debug grammars?

I got asked how to debug SyntaxNode with my code, which is to get the underlying tree via node.cursor.tree, though now I have updated it to just also accept TreeCursor and SyntaxNode. And I had a length bug causing the range to be out of bounds, which the current code does not account for (to should default to Infinity rather than input.length to circumvent that). Rather than keep replying to this forum post with updates, I just made it into a public Gist:

7 Likes