Since parser.c
and friends can be generated from grammar.js
(or
grammar.json
), wouldn't it
be ok to not commit them to one's grammar / parser repository?
On a few occasions 1 2 3 maxbrunsfeld has recommended including generated parse source.
Also, currently, various parties (e.g. nvim-treesitter, tree-sitter-langs, Emacs 29+, Cursorless, difftastic, helix-editor, semgrep, etc.) assume the inclusion of these files to varying degrees.
In late 2020, maxbrunsfeld sketched out a draft plan to move away from doing this. A few months later(?), a form of this was added to the Tree-sitter 1.0 Checklist (search for "Mergeable Git Repos").
Of the checked repositories, it appears that around 93% have
src/parser.c
committed.
ATM then, it appears most folks are doing so and numerous projects that use tree-sitter assume this kind of setup.
Not doing so probably means that it's less likely for the grammar / parser in question to get used as widely.
There appear to be what might be considered compromise options:
- https://github.com/alex-pinkus/tree-sitter-swift#where-is-your-parserc (related issue)
- https://github.com/DerekStride/tree-sitter-sql#installation (related issue)
- https://github.com/tree-sitter-perl/tree-sitter-perl#in-general
It's probably worth noting that there are security implications for what most folks are doing. (There might be some related activity attempting to address some of the concerns.)