emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tree-sitter api


From: Yuan Fu
Subject: Re: Tree-sitter api
Date: Tue, 7 Sep 2021 20:06:45 -0700

>> 
>> Emacs should "load" the module when it's asked to do so, by a function, e.g.
>> `tree-sitter-load-lang`. When loading fails, it should signal an error.
> 
> So this has to be an explicit load initiated by a Lisp program?  How
> would that program know which module to load for a given language?  (I
> thought TS would load the module it needs whenever support for a
> language is requested.)

TS doesn’t load the module, it expects the user to pass it a pointer to the 
language definition. How does the user get the language definition is not its 
business. The user is supposed to combine TS and a language definition to 
create a workable parser. See:

bool ts_parser_set_language(TSParser *self, const TSLanguage *language);

TS only wants a pointer to a TSLanguage.

All the language modules have regular names, i.e., tree-sitter-<lang>.so, so I 
think we can just calculate the name from the language name; or we can add a 
backup: use an alist to map language names to module names to cover possible 
irregular names.

Yuan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]