From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Tree-sitter maturity Date: Sun, 29 Dec 2024 16:30:52 -0800 Message-ID: <77FBB3FF-A0F5-416C-AE35-39C0D818FBA9@gmail.com> References: <1ed88fca-788a-fe9f-b6c8-edb2f49751c9@mavit.org.uk> <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> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\)) 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="6711"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Daniel Colascione , Lynn Winebarger , Philip Kaludercic , emacs-devel , Eli Zaretskii , Richard Stallman , manphiz@gmail.com To: =?utf-8?Q?Bj=C3=B6rn_Bidar?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Dec 30 01:32:10 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 1tS3ha-0001XA-MY for ged-emacs-devel@m.gmane-mx.org; Mon, 30 Dec 2024 01:32:10 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tS3gl-0005Uy-CW; Sun, 29 Dec 2024 19:31:19 -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 1tS3gf-0005UW-GT for emacs-devel@gnu.org; Sun, 29 Dec 2024 19:31:14 -0500 Original-Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tS3gd-0006Fp-Aa; Sun, 29 Dec 2024 19:31:13 -0500 Original-Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-21683192bf9so112893445ad.3; Sun, 29 Dec 2024 16:31:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735518666; x=1736123466; darn=gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=erIxtAHiILR0sD/8RNdOKt0S0DhE+nzDdaewYlea92E=; b=P58kZ6Gdc2EOyBGxkewGpzk1Ixb4w7qgQ9eqkanCK9wlR1P79pr1WPEkLU74o9ofsF etslSSGT3bSZDg0zry1hnhMPFD9Gak6/lGGHuUglbwTxFrUAt/BavsgwEVbNCLA2LK38 /inYAarjd5t3Vi3yK90X6Yf8p/99IdZNRNNnxxc0K/eOX92JjC6ZDRitCWHg9rUZ40xn 393tc1+bWauLNo7R6oUrrEzoVgTPHJYAgNsBcqBNwQRcBDEjHI7/cuLuYRbnWVIHB3Ib TCq7WnCyMoEBHfzLGDVU4UmNZOE2nExXGVdHGT7vv6CZqwLsy6X0V6zLJwbv4/1DW0f1 bwgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735518666; x=1736123466; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=erIxtAHiILR0sD/8RNdOKt0S0DhE+nzDdaewYlea92E=; b=Ey3rxdLiHRkd9OTx3Dtpav+Esh9oUKzIBJHgtWmRk+vJ1YsJp4tiBZp89rJUwy8Ts+ 3bNfnc2uKSvEJIbpFINf7Q7KxnFJwXOLFw0BMs05tAUiiJw8DZV+IiRWPidi/54Ejv5S y5Cu77D090y5fg5vNsxUGg+AFpvTxg1/AZDH053lJVlMTFTTEfqm1cfkaEJL29s0+Ok3 SaE1+qs0/UqdwB60b5phlTTZEx87jCvaMXWP6AxagcLHiTF57kmV8eVSPNaMzXo5oUgS wDsXnRTxgGQbufrF+dQU8v81GHrrPnxFilR4O01YIqJOgKc4Kp9NYNmT7W2rj46od7+N OFXQ== X-Forwarded-Encrypted: i=1; AJvYcCUUfWz+N4nwn3qyfXIyz0sJ6djlYStpSSpVBgYstiX+qSYAJHKH3fWd858eB9NDc0dFrKpD/t6aRqT1rDg=@gnu.org, AJvYcCWn0kpt+4y340cIeHHTz9fZx87dyEzYfKFYQBzmEk4qIPRcWfHFWD0KktUkWlwniiiv8GTx@gnu.org, AJvYcCXjpz6OdtmrvAco82gbXeybM9GIna0jFiEUyQyR+WlAHnBLjDKv7YFjlp84K+MgRLVNOyT7@gnu.org X-Gm-Message-State: AOJu0YxXVcdh83Z64yCGXppW4V1pwa7d3bGtBMINAwxqtNYaVkcyia08 s3U71ixQOQhJ2jXjXP5lmrHcGkW2a5gsrPuyRAwEbcdZ7PyqSoPS X-Gm-Gg: ASbGncuGvxll2SQBdOR9p2jNeIsGS1u33Z5KXqNGg9pOGvfwihmrkAW56a7ao2Br9Zn Lz+Uh6Z70MKgJo+1XrT6Joye8cOr1K4wuAkBwMgj6SbzIcHboUTWyBxqkdpQ2eQ2oZvo9qiTDHN AqIsoL7VEXJTIQFZc6TCjJqbTkCaNk/fsK/9oqjVPMQUCiNQ4wj46hblwZHIdtqbJSkm5+UxxVI 9ecVXuIQAyaZNMbS/vj/cKnCZXv9W+JVdyznukWzHDQ62z1GYFHP2rfb8DQRyaaQF4vjHysDUcl 43Y6 X-Google-Smtp-Source: AGHT+IFSeK7Q6OkiendmiVR1e/+LV+U730HR5hyyd6mSQJ2uVLfIdxibzpnz0O8P86V/y7HHIyuksg== X-Received: by 2002:a17:902:ce83:b0:216:5b8b:9062 with SMTP id d9443c01a7336-219e70dd21cmr513016985ad.54.1735518665972; Sun, 29 Dec 2024 16:31:05 -0800 (PST) Original-Received: from smtpclient.apple ([2601:646:8f81:6120:f1c9:d034:5332:4d9a]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dca01415sm168634005ad.231.2024.12.29.16.31.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Dec 2024 16:31:05 -0800 (PST) In-Reply-To: <6771db94.050a0220.386e00.e451SMTPIN_ADDED_BROKEN@mx.google.com> X-Mailer: Apple Mail (2.3776.700.51) Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=casouri@gmail.com; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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:327378 Archived-At: > 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 = figure >>>> vendoring both the source and the generated code would be best, as = it'd >>>> allow building Emacs anywhere but still make it convenient on = systems with >>>> needed tools (JS runtime, Rust, etc.) to update and modify the = grammar. 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 = guardrails we >>>> can build to make sure it doesn't happen. >>>>=20 >>>=20 >>> I looked into this last year. The tree-sitter library provides a = parsing >>> engine that references a fairly standard LR type parsing table in = binary >>> form. I got stuck in adding a generic primitive functionality for = reading >>> and writing arbitrary binary data structures based on a data = description >>> 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 = expert >>> on the possible security implications. >>>=20 >>> Other than that, emacs already has the code for calculating (LA)LR = parsing >>> tables in the semantic packages. The tree-sitter grammar compiler = may have >>> additional logic for providing multiple starting symbols, but the = parsing >>> 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 = need it to develop the grammar, but compiling grammar.js to parser.c = only requires the tree-sitter CLI which is written in Rust. Yuan=