4 ms·
Alternatively, use tree-sitter[0] for the tooling. [0] https://tree-sitter.github.io/tree-sitter/ https://tree-sitter.github.io/tree-sitter/
by chaosite 3y ago
Alternatively, use tree-sitter[0] for the tooling.
[0] https://tree-sitter.github.io/tree-sitter/ https://tree-sitter.github.io/tree-sitter/
- Karellen 3y agoHuh. I didn't realise that tree-sitter had its own parser for each of the languages it supported. For some reason I thought it used existing compilers/parsers to be able to figure out which symbols would be valid at a given point. TIL.
- pfdietz 3y agoUsing existing parsers is a problem in things like C with preprocessors. You need more than just a file to use those; you need a build environment with all the includes files and command line options defining appropriate macros. Tree sitter makes a good effort attempt to parse such things but can't get it right in general.
- Karellen 3y agoAh, for some reason I thought tree-sitter did autocomplete, and that pretty much relies on being able to find and read the relevant include files too. I just checked and it doesn't do that, so if it's just doing enough for syntax highlighting, yeah, a custom parser is probably the best way to go about that. Thanks.