News for hackers. Stuff that matters.
Re:How to Get Started with Tree-Sitter by awayto on Sunday May 28, 2023 @06:25PM (#36108373)
I worked with tree sitter a bit for a small project. It seems to be the case that, while it covers a large set of languages, the actual implementation of each subset doesn't follow the exact same underlying API. And it follows that there is no universal AST parser as far as I can tell. Languages have many types of atomic parts to such an extent that unifying them is a tremendously complex task.
Re:How to Get Started with Tree-Sitter by avodonosov on Sunday May 28, 2023 @07:26PM (#36108792)
Have you used the `tree-sitter tags` command?
Re:How to Get Started with Tree-Sitter by awayto on Sunday May 28, 2023 @07:44PM (#36108923)
Unfortunately not. My stint of use was focused around dynamically loading in any given tree-sitter-langaugeName package via docker and then parsing any given file type in a runtime environment, in order to coalesce differing languages' parts into a unified metadata structure.

So, I wasn't trying to identify named things, like the tags command might seem to do, but more generic parts of the langauges like function, var, import/export statements, etc. I ultimately made my own walk functionality, but pulling out those atomic parts per language is still a very heavy task (basically need a mini lexer for each lang), even though TS seems to provide all the info to do the task.