Comment

Comment by avianlyric

Interesting use of treesitter. But I’m a little surprised that treesitters built in query language wasn’t used.

There’s no need to manually iterate through the tree, and use if statements to select nodes. Instead you can just write a couple of simple queries (and even use treesitters web UI to test the queries), and have the treesitter just provide all the nodes for you.

https://tree-sitter.github.io/tree-sitter/using-parsers#patt...

parent avianlyric 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton