# What's the best to test and debug grammars?

**URL:** https://discuss.codemirror.net/t/whats-the-best-to-test-and-debug-grammars/2542
**Category:** Lezer
**Created:** [July 26, 2020, 4:47pm UTC](https://discuss.codemirror.net/t/whats-the-best-to-test-and-debug-grammars/2542 "2020-07-26T16:47:38Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![grayen](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/grayen/32/994_2.png) [@grayen](https://discuss.codemirror.net/u/grayen)
#### Post date: [May 19, 2021, 12:17pm UTC](https://discuss.codemirror.net/t/whats-the-best-to-test-and-debug-grammars/2542/5 "2021-05-19T12:17:39Z")

</div>

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:

> <https://gist.github.com/msteen/e4828fbf25d6efef73576fc43ac479d2>

---

_[View the full topic](https://discuss.codemirror.net/t/whats-the-best-to-test-and-debug-grammars/2542)._
