Description
(Please correct me if anything of the following is wrong)
If I understand it correctly, for all parser implementations there is always a tree_sitter_<lang>
function, and it always has the same signature.
Currently jtreesitter only provides a Language(MemorySegment)
constructor, so you have to generate boilerplate code which looks up the tree_sitter_<lang>
function and invokes it (as done in the test code). This can be an obstacle for new users of jtreesitter because they either have to be a bit familiar with java.lang.foreign
, or blindly copy code they don't understand.
It would be useful if Language
provided a convenience method for this, for example:
public static Language loadLanguage(SymbolLookup parserLibrary, String languageName)
The user could then easily use SymbolLookup#libraryLookup
to load the library and then use that Language#loadLanguage
method.
If you want I can try to create a proof-of-concept PR for this.