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 api Date: Thu, 9 Sep 2021 19:06:28 -0700 Message-ID: <3E8CA8E4-E623-4051-A76D-508C6CF94B6A@gmail.com> References: <83r1f7hydn.fsf@gnu.org> <95F37923-5BF9-4D81-B361-267CF119FBCA@gmail.com> <735AF34C-FD18-4A6A-A99D-E5D8EB4DE4F3@gmail.com> <40611F1F-7B5C-4885-A2CA-CE709ED8D22B@gmail.com> <4E876354-10D1-46B3-8124-CAE916261F08@gmail.com> <0A3F5464-B90D-4D47-BBDD-CCA26D877F43@gmail.com> <83tuiys1y4.fsf@gnu.org> <835yvcpdip.fsf@gnu.org> <7B1F90DE-A992-4F51-B391-0A4E5A598780@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) 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="26952"; mail-complaints-to="usenet@ciao.gmane.io" Cc: =?utf-8?B?VHXhuqVuLUFuaCBOZ3V54buFbg==?= , Theodor Thornhill , =?utf-8?Q?Cl=C3=A9ment_Pit-Claudel?= , emacs-devel@gnu.org, Stefan Monnier , Stephen Leake To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 10 04:07:12 2021 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 1mOVwe-0006rR-AY for ged-emacs-devel@m.gmane-mx.org; Fri, 10 Sep 2021 04:07:12 +0200 Original-Received: from localhost ([::1]:35176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOVwd-0004BV-1t for ged-emacs-devel@m.gmane-mx.org; Thu, 09 Sep 2021 22:07:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOVw2-0003Uu-Kt for emacs-devel@gnu.org; Thu, 09 Sep 2021 22:06:34 -0400 Original-Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]:37556) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mOVw0-0000Eu-UQ; Thu, 09 Sep 2021 22:06:34 -0400 Original-Received: by mail-qk1-x735.google.com with SMTP id w78so477985qkb.4; Thu, 09 Sep 2021 19:06:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=BW1znuSod62twO3jQo4ryT8eEjXBxTzYHnC76fqQ12I=; b=ElPBuqtBaL3m6Qt+wni+1gDXZtQjcO0jpv1q/t1EDURp6Wj3Zzisre5IjsoFnjge+2 tc5uA/oNuXk8f3cdwROKQ7eOq4hVzIQ+Gyd8ecMKpLQVGH9PwQUxkLEQm4tYqF64HqfS RgYjTF6tzUsVBAXQbhVyoCGgkZNiwoTYfTAeh0O3yTKOQzgkUe/LMe3gep+TN3i5OcXY Q+7zDxOq/BA5n/fQ1+yLLV2nhGiXjQ9FmfIm9hjBImBBRn+FXUQmKhnfLepCxWnLXQtc IBPaDUndd/KOOOeweJ54c4xR1+55aIcLCHdpSJJ5WWuRBxohFti0smVZVgViZmfyKgTf Y06Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=BW1znuSod62twO3jQo4ryT8eEjXBxTzYHnC76fqQ12I=; b=SiPR9+TfIy2PTHEetumUGx3pnQrBuGKFH1lvM7uvJdjLRRKjvTNm0jrp5DWUwVsXfm W/vqdx3xgtcLotQqh8dIGm6yHR1glthzLe+l90o2dGw8vwaq3sudBpEVzbHi/5HYlV/7 m4jkRQFSTWaeciCrd3y/DwOvPo2gR3SM46ac67Op/nQK8LyNFw+ao1WMlhPelAzzU25Q s0aQyxjo0FgtlmiEWkjjMRX4hgfqCNNJODXIhcqBR1FRNvDf9ZzGzcupNmBcZZSLn2zj TW75/2Q72t81cLijrg3vpinHK79igOCZhPkSIG8Uz+yg+kiBDEYA8HcsFuD8r87DIPwK wOiQ== X-Gm-Message-State: AOAM530i/ixVEAz+ueb26GIPEABTs6XuJfh5Jmx20bCic5LAl1LRe/Gm QG2quKAS0mJhKGlhD0+yQIY44nNGxXZ1EA== X-Google-Smtp-Source: ABdhPJxXtnVA1vLy29UxexJT/nC3Jr28NE5//tfHZ4ZR31QyHVzTujO1Hh7KBQUObgcmgGaQkDGIAg== X-Received: by 2002:ae9:f70c:: with SMTP id s12mr5815062qkg.254.1631239590998; Thu, 09 Sep 2021 19:06:30 -0700 (PDT) Original-Received: from smtpclient.apple ([2600:1700:2ec7:8c9f:a158:bbab:fca1:1f4e]) by smtp.gmail.com with ESMTPSA id i16sm2250256qtw.15.2021.09.09.19.06.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Sep 2021 19:06:30 -0700 (PDT) In-Reply-To: <7B1F90DE-A992-4F51-B391-0A4E5A598780@gmail.com> X-Mailer: Apple Mail (2.3654.120.0.1.13) Received-SPF: pass client-ip=2607:f8b0:4864:20::735; envelope-from=casouri@gmail.com; helo=mail-qk1-x735.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.23 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" Xref: news.gmane.io gmane.emacs.devel:274486 Archived-At: > On Sep 7, 2021, at 8:06 PM, Yuan Fu wrote: >=20 >>>=20 >>> Emacs should "load" the module when it's asked to do so, by a = function, e.g. >>> `tree-sitter-load-lang`. When loading fails, it should signal an = error. >>=20 >> So this has to be an explicit load initiated by a Lisp program? How >> would that program know which module to load for a given language? = (I >> thought TS would load the module it needs whenever support for a >> language is requested.) >=20 > TS doesn=E2=80=99t load the module, it expects the user to pass it a = pointer to the language definition. How does the user get the language = definition is not its business. The user is supposed to combine TS and a = language definition to create a workable parser. See: >=20 > bool ts_parser_set_language(TSParser *self, const TSLanguage = *language); >=20 > TS only wants a pointer to a TSLanguage. >=20 > All the language modules have regular names, i.e., = tree-sitter-.so, so I think we can just calculate the name from = the language name; or we can add a backup: use an alist to map language = names to module names to cover possible irregular names. If you think it=E2=80=99s fine, Eli, I=E2=80=99ll start working on this. Yuan=