3 ms·
I've tried to write a parser using tree-sitter multiples times, but it's complicated enough that I've found it to be simpler to write my own parsers. Of course
by vsnf 3y ago
I've tried to write a parser using tree-sitter multiples times, but it's complicated enough that I've found it to be simpler to write my own parsers. Of course as a mere amateur, my parsers don't have certain nice to have features like good error messages, or good incomplete syntax recovery. I wish tree-sitter was easier to use.
- a1o 3y agoI didn't have much trouble writing tree-sitter parsers after taking a look to examples but I also resigned to writing my own parsers instead of using it. There were two concerns I couldn't shake from using it. 1. In C-like languages you usually can do forward declarations, so you can opaquely define something, use it and have it properly defined later, usually due to how things need to use other things in their declaration. You can't cleanly do this in tree-sitter, you will need to handwrite some C code for this on top. 2. Even though the resulting parser is a single C-file, it still depends on some tree-sitter library and building it requires nodejs and npm packages. This means that anyone updating my C/C++ codebase has to also understand JS tooling. I would rather not have such dependency. If tree-sitter could have standalone tools that could be built only using either a C or C++ compiler, I would not have such a problem.
- bfrog 3y agoI tried to write a vhdl treesitter grammar and I too found it hard. I got something working enough for decent highlights but not a complete grammar by any means.