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: Tue, 7 Sep 2021 20:06:45 -0700 Message-ID: <7B1F90DE-A992-4F51-B391-0A4E5A598780@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> 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="10525"; 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 Wed Sep 08 05:07:29 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 1mNnvt-0002dj-HP for ged-emacs-devel@m.gmane-mx.org; Wed, 08 Sep 2021 05:07:29 +0200 Original-Received: from localhost ([::1]:51576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNnvs-0005Bv-0d for ged-emacs-devel@m.gmane-mx.org; Tue, 07 Sep 2021 23:07:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50188) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNnvH-0004Xc-ND for emacs-devel@gnu.org; Tue, 07 Sep 2021 23:06:51 -0400 Original-Received: from mail-qt1-x82e.google.com ([2607:f8b0:4864:20::82e]:38591) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mNnvG-0004Vc-5z; Tue, 07 Sep 2021 23:06:51 -0400 Original-Received: by mail-qt1-x82e.google.com with SMTP id g11so686990qtk.5; Tue, 07 Sep 2021 20:06:49 -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=QiFBcJlkbKBkg0lz+p5nhukjeAYBgrMKIOiW5mVrWz8=; b=cqQfdarfyiYMLi4pDtAb5hDuXzwm0TPJK4GZwBzevpeoFV+fbUyNRZ9Bo26X5d/KDm 5/KWwsPrsO+iMBnm3yhMs+zNVDTQXPm/aA4q1DR+a/so9tVDlMRHZMPUjKQhLD+mQNBY 4FnLvOMUHkuPS17zjS5sbdoLyqy1g5xYtOSotPbO1Ugqd/TDCmAwCf0VJYQ0lvaysRkc Ttba24c/08HYw623ddnRhNUEPJaqJg/+LjjL1usNUfkWii/R9g7NW+3br2WLsdhPbaGU G7h6Rz8ZStQDrKqOAtNUAY0Qtan96gNX8sUtj1rXEj5caJ91UCuPv0C2UIbDQLUu1Wzv EfKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=QiFBcJlkbKBkg0lz+p5nhukjeAYBgrMKIOiW5mVrWz8=; b=MeLTX6HQ9ssEpEBQ2aO6cszCAIsWO4oFB4CYG20SRBMbFpPFwl64nT1l06bXEhzHMi MWrLKuR1gvXD/kX7TfaLf+N8N7+pyv53HU/FhF/M0LZhyfoZ8l54twM2jxcs7tv8Agu3 eID5SrLLqVggG81ZGBH9a2WEYayCSmHNrrs4JjZLPuCTl4xVVfmNHaa7fZMdIkVHrCvr 4dlo5KnT5EiHxtrau6i5+p/ql4UH8/esf8hvHXW/F9bgzvbOQ7OYzffuXBTx50VQHetD XzUXkoiqrYyzj8vsAVTbQ3CNycli9iFWtV28mGERVKPFFECyoLDAa2QWUwM/H70TEQZs sM2w== X-Gm-Message-State: AOAM533khvcC4VO2eDAATvGAMTPZROhMEtYrZExm+s1f9W+DxwA2163s eFIiqXe+y/ZerUDf9Nc3cpKFymvO42ofB5oo X-Google-Smtp-Source: ABdhPJwNFA7Kvd8RzjkSSBjfFm9CxAompWu2Q4L7bq7xPwZTD8uTXCrR7dsld4YGW2HYj8HM2RDPMA== X-Received: by 2002:ac8:7409:: with SMTP id p9mr1663520qtq.370.1631070408303; Tue, 07 Sep 2021 20:06:48 -0700 (PDT) Original-Received: from smtpclient.apple ([2600:1700:2ec7:8c9f:6060:4c16:d77f:14ab]) by smtp.gmail.com with ESMTPSA id u7sm692712qtc.75.2021.09.07.20.06.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Sep 2021 20:06:47 -0700 (PDT) In-Reply-To: <835yvcpdip.fsf@gnu.org> X-Mailer: Apple Mail (2.3654.120.0.1.13) Received-SPF: pass client-ip=2607:f8b0:4864:20::82e; envelope-from=casouri@gmail.com; helo=mail-qt1-x82e.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:274301 Archived-At: >>=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.) 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: bool ts_parser_set_language(TSParser *self, const TSLanguage *language); TS only wants a pointer to a TSLanguage. 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. Yuan