-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it compilable as a c library #44
Conversation
In principle I think I'm ok with adding a Makefile for the stated purpose. Would you mind explaining your use case in more detail though [1]? The Also, AFAIU, it won't work as-is on Windows (unless one uses something like mingw-w64 / msys2). A dynamic library can also be created using the tree-sitter cli as is already done by nvim-treesitter, Emacs 29+, AUR package, etc. This approach allows building a dynamic library for Windows as well. I can understand if you don't want to be dependent on the tree-sitter cli, just mentioning the option. [1] At the moment, I don't think this grammar works with everything in ClojureDart. IIUC, there is at least one thing that is different. I haven't tried to support this yet and I'm not sure how practical it will be as I don't understand the details at this time. [2] Of the 220+ tree-sitter grammar repositories I looked at, around 15 (6%) of them have a |
Thank you for the quick response! As I'm new to tree-sitter I'm certainly doing things wrong. Thanks to your pointers I begin to understand that all tools seem to develop their own custom build solutions (eg https://github.com/nvim-treesitter/nvim-treesitter/blob/7ba61ca7f5fe48c95afa03a8298788b67207fd6d/lua/nvim-treesitter/install.lua#L302-L432). The actual shared contract is either the json file (if tree-sitter CLI installed) or the c/h files generated by the CLI on another machine. Closing this PR and scripting my own build ;-) As for ClojureDart, I don't believe you need to change anything to the grammar: ClojureDart has made no change to the reader (to not break cljc). We are just using However while quickly playing I noticed that your grammar doesn't prevent I have a question: I see that Thanks! |
I have some notes here about the various files involved going from
Yes, I also find that unintuitive and opened an issue about the confusing nature of "automatic compilation". FWIW, the
That should produce If you don't mind using rust tooling like cargo, you can get access to the various changes since the latest release (0.20.7) in 2022-09 including the above functionality by building the cli from source. If you have other general tree-sitter questions, perhaps you know already, but FWIW, there is a GitHub discussions area and a recently started Discord server (announced here). I don't mind trying to answer questions, but I'm not the most knowledgeable about this topic :) Regarding ClojureDart, thanks for the explanation. I will take a closer look and try to understand properly (Ah...I think I get it now, I failed to think of
Yes, in general, tree-sitter grammars / parsers are made to be on the side of "tolerant" in accepting invalid input. It's what the tree-sitter creator maxbrunsfeld has advocated a few times.
Regarding why
I did experiment with the idea of [1] I did this recently by writing |
I copier the missing files (one makefile and two templates) copied from grammars under the tree-sitter organization to allow compiling the Clojure grammar to a dynamic library.