[Top][All Lists]

[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: Fri, 30 Dec 2022 03:06:37 -0800

> On Dec 27, 2022, at 8:44 AM, Philip Kaludercic <philipk@posteo.net> wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> It doesn't need any project, it is literally two command lines.
>>> Here's an example:
>>>  gcc -O2 -I.   -c -o parser.o parser.c
>>>  gcc  -shared parser.o scanner.o  -ltree-sitter -o 
>>> libtree-sitter-c-sharp.dll
>> AFAIK `parser.c` is a file generated from the actual grammar's source,
>> itself written in Javascript.
>> So the above instructions are akin to downloading a precompiled binary
>> and installing it.  While it is the most convenient path for the
>> end-users, it's important w.r.t Freedom to make sure that grammars can
>> also be regenerated from source by the end users.
> I have asked the question before, but freedom or not, the above is a
> nuisance to run for every language.  If the process is as automatic as
> the above example demonstrates, shouldn't Emacs have a command to take a
> grammar and compile+install it?  I guess this could be more complicated
> if the grammar is generated using a custom tool-chain for each language
> (or is it always Javascript?), but nothing impossible.

Though the magic of programming, such command now exists: 
treesit-install-language-grammar. It needs recipes to work, though. The recipe 
would involve https://github.com, which I guess is probably too heretical to 
include in Emacs source, so I left the recipes empty. I tested the install 
command with these recipes:

(setq treesit-language-source-alist
      '((python "https://github.com/tree-sitter/tree-sitter-python.git";)
        (typescript "https://github.com/tree-sitter/tree-sitter-typescript.git";
                    "typescript/src" "typescript")))


reply via email to

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