Replies: 2 comments 4 replies
-
This treads dangerously close to designing a new package format, but what about emitting the generated tree-sitter code in a zipped release? It wouldn't necessarily even be tightly bound to github. Everyone has access to a CI system these days, which could run on checkin and generate/upload the code. Anyway I support the idea of adding go bindings during |
Beta Was this translation helpful? Give feedback.
-
There's definitely an smacker/go-tree-sitter is really nice, but one challenge is that if you want to write a custom parser or use another parser in the ecosystem you have to get that added to smaker/go-tree-sitter instead of being able to just take on a new dependency in your application. I think having a canonical list of well supported parsers for a binding language is great, but there will always be cases where applications want to pull in a parser that the rest of the community might not want or care about. Another use case is just testing newer versions of a parser or delaying upgrading to the latest version until some bug gets fixed. In terms of committing generated C code, I think that warrants a separate discussion. |
Beta Was this translation helpful? Give feedback.
-
The smacker/go-tree-sitter repo is a popular set of Go bindings around the core tree-sitter library. It also includes a selection of languages grammars directly in the repository, making it very ergonomic to use tree-sitter to parse those particular languages from Go. In particular, the way that @smacker is vendoring the generated C files for each language grammar means that everything plays very nicely with
go mod
andgo build
, which is perfectly willing and able to compile C code as part of the build, but doesn't want to delegate to external tools liketree-sitter generate
ormake
. The per-language Go wrapper code is nice and small, and boilerplate.The individual language grammars already include bindings for Node and Rust, which can be auto-generated as part of
tree-sitter generate
. That makes it easy for us to publish NPM and Rust packages for individual languages, e.g.tree-sitter-python
[npm] [rust].The individual language grammars currently have their generated C source code checked into git. It should be easy to add the small amount of Go wrapper code as a new binding that is automatically created by
tree-sitter generate
. That would mean thatgo-tree-sitter
could be simplified to only contain the Go API around tree-sitter itself, and users of that library could usego mod
to depend on particular language grammars (and particular pinned versions of those grammars, if needed), instead of delegating that decision togo-tree-sitter
.If you only consider what I typed above, I think this proposal is really compelling. But unfortunately it depends on checking the generated C code into the language repos. We've discussed not doing this moving forward: #730 (comment).
So now we have conflicting requirements: there are real usability wins to not checking the generated code into git, but on the other hand, that would preclude us from (easily, automatically) creating Go modules for each of the language grammars.
Thoughts? Opinions? Other concerns I haven't thought of?
Beta Was this translation helpful? Give feedback.
All reactions