emacs-devel
[Top][All Lists]
Advanced

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

Re: Tree-sitter introduction documentation


From: Yuan Fu
Subject: Re: Tree-sitter introduction documentation
Date: Tue, 27 Dec 2022 18:52:54 -0800


> On Dec 27, 2022, at 1:13 PM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> 
>> It should be possible to port this, but I question if it is worth
>> the effort.
> 
> I think it's worth the effort in order to help empower our users to make
> changes to their grammars.  Otherwise we're back to grammars whose
> source is legally-speaking Free but that most of ours users wouldn't
> know how to change.

The “DSL” used to describe language grammar is reasonably straightforward, and 
our manual explains it to some degree (see the end of section 37.1 Tree-sitter 
Language Definitions). Though one probably need some additional knowledge on 
writing parsers to work on the grammar.

The cli doesn’t have any dependencies, so only node itself is required. One 
should only need to run

npm install tree-sitter-cli

and

tree-sitter generate

To convert a grammar.js to parser.c. (I didn’t try this, but this is what the 
documentation says.)

The javascript converter itself seems pretty straightforward, too, so it’s 
probably not very hard to port it to something else: 
https://github.com/tree-sitter/tree-sitter/blob/master/cli/npm/dsl.d.ts

> 
>> though considering that Emacs isn't the first editor with TreeSitter
>> support, I wonder why this hasn't happened yet. 
> 
> My guess is lack of motivation on one side (most editors using
> Tree-sitter already provide built-in support to automatically install
> relevant grammars, which is even simpler (but not empowering) for the
> end users since they don't need administrators access to install the
> relevant grammars).
> 
> On the other side is probably the difficulty of packaging Rust and JS
> libraries which tend to be horribly misbehaved w.r.t what distributions
> expect (with things like vendoring or dependencies on very specific
> versions of libraries).

For tree-sitter, the dependency is pretty sane, with just node and a C/C++ 
compiler you can convert grammar.js to a loadable library.

Yuan


reply via email to

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