From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: Tree-sitter maturity Date: Tue, 31 Dec 2024 09:48:54 +0000 Message-ID: <87v7v02neh.fsf@posteo.net> References: <67428b3d.c80a0220.2f3036.adbdSMTPIN_ADDED_BROKEN@mx.google.com> <86ldwdm7xg.fsf@gnu.org> <6765355b.c80a0220.1a6b24.3117SMTPIN_ADDED_BROKEN@mx.google.com> <00554790-CACA-4233-8846-9E091CF1F7AA@gmail.com> <86msgl2red.fsf@gnu.org> <87o710sr7y.fsf@debian-hx90.lan> <8734i9tmze.fsf@posteo.net> <86plldwb7w.fsf@gnu.org> <87ttapryxr.fsf@posteo.net> <0883EB00-3BB2-4BC8-95D1-45F4497C0526@dancol.org> <87msge8bv8.fsf@dancol.org> <6771db94.050a0220.386e00.e451SMTPIN_ADDED_BROKEN@mx.google.com> <77FBB3FF-A0F5-416C-AE35-39C0D818FBA9@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28046"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Yuan Fu , =?utf-8?Q?Bj=C3=B6rn?= Bidar , Lynn Winebarger , emacs-devel , Eli Zaretskii , Richard Stallman , manphiz@gmail.com To: Daniel Colascione Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Dec 31 10:49:50 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tSYsn-00077t-Tj for ged-emacs-devel@m.gmane-mx.org; Tue, 31 Dec 2024 10:49:50 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSYs7-0001Ip-Gp; Tue, 31 Dec 2024 04:49:07 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSYs4-0001IQ-GZ for emacs-devel@gnu.org; Tue, 31 Dec 2024 04:49:04 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSYs2-0001lb-Cw for emacs-devel@gnu.org; Tue, 31 Dec 2024 04:49:04 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 6059D240101 for ; Tue, 31 Dec 2024 10:48:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1735638537; bh=DHUkZwAaCmJGGJSuN3yWJTgFpXzleB+/aY0ejSo2MZ8=; h=From:To:Cc:Subject:Autocrypt:OpenPGP:Date:Message-ID:MIME-Version: Content-Type:Content-Transfer-Encoding:From; b=cOOruTiF4OO5qiMGnWl5TQlsFdhBNAE2poV5UGLXZmZacOvsr0eC25pvukBzwDgNU BQBsi+GYTF/f/iX4xBVQCrwix3w3Uha59sLVu+yWvDHOhxPTRKCBkgNJTC1oWs+91H +tSCb0ub3S38rk8KmKmWuqdrW2ejSw3NRwK3ozbmnwC5T+fcJw7T2yBmMY9qV9BGNF X+yqtxBaDDCVVhPsjVRVKaAMba2sUQHQOGWRp6DLF5nBrv9zqWkAJlWbT2PngGR//C dEOFTGFIPbUC8mmrr4j90y9w/yd28+lBl+d9UAovisRSzfnBIMM3+Yn7qME+Oy99bC smdzSZFeYp5rg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4YMp870sLQz6tm8; Tue, 31 Dec 2024 10:48:55 +0100 (CET) In-Reply-To: (Daniel Colascione's message of "Sun, 29 Dec 2024 19:36:19 -0500") Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM OpenPGP: id=7126E1DE2F0CE35C770BED01F2C3CC513DB89F66; url="https://keys.openpgp.org/vks/v1/by-fingerprint/7126E1DE2F0CE35C770BED01F2C3CC513DB89F66"; preference=signencrypt Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:327484 Archived-At: Daniel Colascione writes: > On December 29, 2024 7:30:52 PM EST, Yuan Fu wrote: >> >> >>> On Dec 29, 2024, at 3:29=E2=80=AFPM, Bj=C3=B6rn Bidar wrote: >>>=20 >>> Daniel Colascione writes: >>>=20 >>>> Lynn Winebarger writes: >>>>=20 >>>>> On Fri, Dec 27, 2024, 9:25=E2=80=AFAM Daniel Colascione wrote: >>>>>=20 >>>>>>=20 >>>>>>=20 >>>>>> It's a shame there's no way to write TS grammars in plain elisp. I f= igure >>>>>> vendoring both the source and the generated code would be best, as i= t'd >>>>>> allow building Emacs anywhere but still make it convenient on system= s with >>>>>> needed tools (JS runtime, Rust, etc.) to update and modify the gramm= ar. As >>>>>> with any scheme involving checking in generated outputs, the source = and >>>>>> output can get out of sync, but I think there are build time guardra= ils we >>>>>> can build to make sure it doesn't happen. >>>>>>=20 >>>>>=20 >>>>> I looked into this last year. The tree-sitter library provides a par= sing >>>>> engine that references a fairly standard LR type parsing table in bin= ary >>>>> form. I got stuck in adding a generic primitive functionality for re= ading >>>>> and writing arbitrary binary data structures based on a data descript= ion >>>>> DSL, since I wouldn't want to tie the interpreter core to the data >>>>> structures of an external, dynamically-loadable library. But, I wasn= 't >>>>> sure such an extension would be accepted into emacs, as I am not an e= xpert >>>>> on the possible security implications. >>>>>=20 >>>>> Other than that, emacs already has the code for calculating (LA)LR pa= rsing >>>>> tables in the semantic packages. The tree-sitter grammar compiler ma= y have >>>>> additional logic for providing multiple starting symbols, but the par= sing >>>>> engine should still function with a classic parsing table. >>>>=20 >>>> Thanks. Such an approach would let us treat tree-sitter grammars a lot >>>> more like font-lock-keywords, and I think for some modes, that'd be a >>>> good option. (Of course, SHTDI.) >>>>=20 >>>> Tree sitter, as wonderful as it is, strikes me as a bit of a Rube >>>> Goldberg machine architecturally: JS *and* Rust *and* C? Really? :-) >> >>> I was wondering the same. How the hell? There had been some talks to >>> support a more lightweight JavaScript interpreter as an alternative but >>> it hasn't gone anyway. Somehow because compatibility reason. I don't how >>> could node be dependency for these. Grammars are mostly without >>> dependencies except some have dependencies to other grammars on the >>> source level such as the C++ require the C grammar. >> >>I don=E2=80=99t think you need nodejs to build the grammar. You might nee= d it >> to develop the grammar, but compiling grammar.js to parser.c only >> requires the tree-sitter CLI which is written in Rust. >> >>Yuan > > Doesn't the CLI shell out to Node? Yes it does, but node is now an optional interpreter: https://github.com/tree-sitter/tree-sitter/blob/c712276676caa04c72357fe9ec1= 0dd5515500e95/cli/generate/src/lib.rs#L175