emacs-devel
[Top][All Lists]
Advanced

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

Re: Tree-sitter api


From: Stefan Monnier
Subject: Re: Tree-sitter api
Date: Fri, 17 Sep 2021 08:23:27 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>> My point is, major mode writers need to read the source of the tree-sitter
>> language definition to do anything useful with tree-sitter
>
> If this is so, then why do we bother documenting the Lisp APIs for
> TS-related features?  If Lisp programmers need to read the TS sources
> to do anything useful in Emacs, let them read the sources, including
> the Lisp and C sources you are working on?

The "source of the tree-sitter language definition" is the language's
grammar (in the format defined by TS).  It's written in its own language
and is independent from the code of the TS runtime or the code of the
TS bindings in Emacs.

For a major mode to use TS, the major mode's code needs to know;
- The name of the language's grammar file.
  This can usually/often be guessed from the language's name and is
  a trivial piece of information.
- The names of the various nodes that will appear in the AST.
  Those are specific to the particular grammar being used, and the best
  place to find them is in the source code of the grammar, tho you can
  also just find them by experimentation.


        Stefan




reply via email to

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