[Top][All Lists]

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

Re: Tree-sitter introduction documentation

From: Philip Kaludercic
Subject: Re: Tree-sitter introduction documentation
Date: Thu, 29 Dec 2022 17:12:35 +0000

Gregory Heytings <gregory@heytings.org> writes:

>>> That's not possible, no, at least not without a lot of
>>> complications that do not seem worth the price, compared to
>>> installing Node.js.  And note that even if that were feasible, it
>>> would only solve the first half of the problem: to transform a
>>> grammar.js file into its corresponding parser.c file, you also need
>>> the tree-sitter command line program.
>> Not necessarily, that could also be ported to JavaScript.
> I'm puzzled.  What would be the benefit of doing that?  Installing
> Node.js and tree-sitter is easy.

Not always, I always have issues with Node.js on Debian Stable.
Especially when external dependencies are added to the mix.

The advantage would be a simpler toolchain that would require less
effort for the user to get running, instead of dealing with version
mismatches and dependency resolution.

>> That being said, I don't imagine it to be an easy process.
> Indeed.  The generator is about 13500 lines of non-trivial Rust code.

I was under the impression that the main part of generating C code was
bundled in here:


But I see that it appears to include some other modules, which is
probably where a lot of the logic happens :/

>>> Indeed, grammar authors are not limited to the standard Node.js
>>> API, they can import other libraries.
>> How common is this in practice?  Is it encouraged?
> I don't know.  I'd guess it is not frequent, but neither encouraged
> nor discouraged.

This would be a nice thing to clarify.  I have also found out that there
is a Javascript interpreter written in Rust that could be used to remove
the Node.js dependency:  https://github.com/boa-dev/boa.  It would be
interesting to suggest this upstream and see if something like this
could be used at some point.

reply via email to

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