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 introduction documentation Date: Tue, 27 Dec 2022 18:52:54 -0800 Message-ID: <3F91FDEA-881A-49DB-BB52-5A0D81C004CE@gmail.com> References: <87tu1vxs3a.fsf@ledu-giraud.fr> <831qozjob7.fsf@gnu.org> <87cz8jxoat.fsf@ledu-giraud.fr> <83wn6ri7pn.fsf@gnu.org> <5e0a3185-de82-b339-0fa2-956779e63d6f@cornell.edu> <868rj6vfep.fsf@gmail.com> <4895891b-e5ea-9c37-f51b-df2e479ee758@yandex.ru> <83y1qt11xq.fsf@gnu.org> <9eb013da-d0fc-8e17-c6e3-1e8f913aebfa@yandex.ru> <83pmc50xxc.fsf@gnu.org> <71cfe4e8-3bb8-b0a6-9be5-8c0a6d92cfab@yandex.ru> <83h6xg29z3.fsf@gnu.org> <838ris22n4.fsf@gnu.org> <8335901zz3.fsf@gnu.org> <87cz84y5le.fsf@posteo.net> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) 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="22825"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Philip Kaludercic , Eli Zaretskii , Dmitry Gutov , Tim Cross , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 28 03:53:53 2022 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 1pAMZk-0005ix-IK for ged-emacs-devel@m.gmane-mx.org; Wed, 28 Dec 2022 03:53:52 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pAMYx-0004zC-OQ; Tue, 27 Dec 2022 21:53:03 -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 1pAMYw-0004z4-R1 for emacs-devel@gnu.org; Tue, 27 Dec 2022 21:53:02 -0500 Original-Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pAMYu-0006WN-Ve; Tue, 27 Dec 2022 21:53:02 -0500 Original-Received: by mail-pj1-x102c.google.com with SMTP id gv5-20020a17090b11c500b00223f01c73c3so15485713pjb.0; Tue, 27 Dec 2022 18:52:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=nFd3Vif8Bhj+xKaRshk+LhnYzkBMqY+HVT7P5/9Euis=; b=cvW+QkhcuQ/tRp4VHKfM/XvBK7x5XI6YkUkB/wDSqgeUtX+LtBSY/FY74tG30CATOi 1AlfiLYc9avLi3iLuaoRnWiQjIaOlC6M/AWOHTNkAp1JpfsAPcqqI/9hKmUaKJpprNny oldLbnn6pwuoczxL7rinUFEG2wWfX/z40mb762XQMoSmks4R+NADe8GybjrEpG+9v+4x QYelQX0yMkHoWfK27QmP9S3fJ8f38T7+SNskSzbtzRWHq2Nvzoet7VQcwJr7LUWWvrB/ oUWNVeaHycZfYLzYvYqJ/SSsfp7xSPWgFzanxthfDxcFXKUJeoH4bvG8aGYAHHMEa1t9 GGHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=nFd3Vif8Bhj+xKaRshk+LhnYzkBMqY+HVT7P5/9Euis=; b=nhSeYGOwKXAxde+HYacUglCxoI45yEkpa9LFTgEsurlvk25KQa4WlZuRU50TywOjNe R1DRZM9Xrs8iJL5zRv76DXO+6vJyory1nQhkog+4TMlp34jSoK+rZVgR22xlHK3WSHkM CNWj2AlxVGYQXV2ezdOmH+iKNYgKR6O9mrXAB5Syvb247HaOMrb+Cfr47b/QrSxqu2co WjX1bW58cusJ9dE8cd4j5ScNUZvkS4kYB6QNoGAlu0YjMvK+iaGstByp7Yk3IQqD1ac+ nAARI9sWq2Q1B9m9KB+aqadw54dTMMuOKSlCQNJAlg3G8+yMyPyOLXv9fhQlyZk28gP7 ZaYA== X-Gm-Message-State: AFqh2kpd3oD+VNeChcxDCatMmZZd0vIj1BTXY2GFL1Ieag/YBQCIMDFI hDtevM4n/wTwPDTI0iXDvmY= X-Google-Smtp-Source: AMrXdXtsKmAzpEUQfIJNovFhr2DUq+r7wX1jdCh425DEi1ONoGg9NG4sffw+lNlZtBO4p03em4zAFQ== X-Received: by 2002:a05:6a21:6da5:b0:a4:414c:84c5 with SMTP id wl37-20020a056a216da500b000a4414c84c5mr37731290pzb.12.1672195977829; Tue, 27 Dec 2022 18:52:57 -0800 (PST) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id h10-20020a170902680a00b00186ff402508sm2677926plk.281.2022.12.27.18.52.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Dec 2022 18:52:57 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=casouri@gmail.com; helo=mail-pj1-x102c.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:301994 Archived-At: > On Dec 27, 2022, at 1:13 PM, Stefan Monnier = wrote: >=20 >> It should be possible to port this, but I question if it is worth >> the effort. >=20 > 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 =E2=80=9CDSL=E2=80=9D 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=E2=80=99t 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=E2=80=99t try this, but = this is what the documentation says.) The javascript converter itself seems pretty straightforward, too, so = it=E2=80=99s probably not very hard to port it to something else: = https://github.com/tree-sitter/tree-sitter/blob/master/cli/npm/dsl.d.ts >=20 >> though considering that Emacs isn't the first editor with TreeSitter >> support, I wonder why this hasn't happened yet.=20 >=20 > 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). >=20 > 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=