From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?B?VHXhuqVuLUFuaCBOZ3V54buFbg==?= Newsgroups: gmane.emacs.devel Subject: Re: Tree-sitter api Date: Tue, 7 Sep 2021 22:38:52 +0700 Message-ID: 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> 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="3745"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Yuan Fu , Theodor Thornhill , =?UTF-8?Q?Cl=C3=A9ment_Pit=2DClaudel?= , emacs-devel , Stefan Monnier , Stephen Leake To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Sep 07 17:39:52 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 1mNdCR-0000iD-Oe for ged-emacs-devel@m.gmane-mx.org; Tue, 07 Sep 2021 17:39:51 +0200 Original-Received: from localhost ([::1]:38436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNdCQ-0004SF-Gl for ged-emacs-devel@m.gmane-mx.org; Tue, 07 Sep 2021 11:39:50 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNdBp-0003kf-9p for emacs-devel@gnu.org; Tue, 07 Sep 2021 11:39:13 -0400 Original-Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:46960) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mNdBn-0002M9-Qd; Tue, 07 Sep 2021 11:39:12 -0400 Original-Received: by mail-pj1-x1036.google.com with SMTP id u11-20020a17090adb4b00b00181668a56d6so2372737pjx.5; Tue, 07 Sep 2021 08:39:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=JsbEZMsQmWmk8xpAXUm3sDZkd5lPk5k2CpsLlQ1GElk=; b=XItJSLUru+wy6XXoTxGFJ+zJ6dVVidmnanoulXLt6OXATgZdUcwNRTE/e+/ryfI0L2 V3XaCsF+QjExeK3NjjxstAbf8dCcXhOdwi7AIN7OUejspCHqqXZHCLwGjuK7B+EYC9Ks HEQ/NMkMZjJJo6o1GCCiSpWnx7BaPIBgmxs6jBh5wAV1Izl7URYI7/cMjZYmB6IJvI32 kKLi5GJVfA/3v0fUXufbhAQJFq69X1tQbJGXsIftrCQLTSCuviVqZCy5SRbaiFAlp9Ad zaxJYID6ySZ1BUCwzTUpqvYuVXuaD0uQDxPUjl8jWkhqWcLiD9++2zVjDY8Ke0KO4ekk ZO+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=JsbEZMsQmWmk8xpAXUm3sDZkd5lPk5k2CpsLlQ1GElk=; b=HSD3cbjifWbyX7M5IO4hGDNmtUhUS2Te/TNf2h3v6WAHyHvVOgH2pRM+KpVu8snMkX JjUkf3UbHQLa9PxzrAPZDA3jmgUoq2QVhtdPXQSy7xQkHGOlPvMP8SbPNPFbH/EQ7z7P HrNvBEoucZbIMXDEZ9BI86Z7aF1YnQrj+d5ZWAKPbVXLeAfEehsdneQMCQUAZY5L/u3k FVGOlCH27F8FFtzqYCHtOodnbaElGFabUK1zoPlr88GlKrXmN2pxzancoTeFGOMvJR/e NQvMNlZJ2jbDw3Edc3B63i+mAgm3iCZKAmMnGBVuuUbCWpe5n4LTzlHNs5vRCAR1QvEw NLsw== X-Gm-Message-State: AOAM532IIiyza1wd76wCnFlLbj8xWPNJ1Bg6u571sq1n20jZWRe6XY0R sStSDx539+dtNDltLw6Wv2R9TNgRSm2CndEBJPTjJUeBfXsC2jxo X-Google-Smtp-Source: ABdhPJwXRAYYxlmxV0RaanVcFJzxwy3fA3vzfVDkzuGQadj8ZQ6Oc1+vy3ccG0kwXhikYfh4VLHoDvaLJI76mMXZmaI= X-Received: by 2002:a17:902:e790:b0:12c:c0f3:605c with SMTP id cp16-20020a170902e79000b0012cc0f3605cmr15463868plb.70.1631029148911; Tue, 07 Sep 2021 08:39:08 -0700 (PDT) In-Reply-To: <83tuiys1y4.fsf@gnu.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=ubolonton@gmail.com; helo=mail-pj1-x1036.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:274254 Archived-At: On Mon, Sep 6, 2021 at 12:33 PM Eli Zaretskii wrote: > I understand that a language module gets compiled into a shared > library, either as part of building TS or separately. But what should > Emacs do to "load" the module, and when should it do that? And how do > we intend to handle the situation where a module is needed, but is not > available (i.e. its loading fails)? 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. To locate the module, I think there are 2 possible approaches: 1. Emacs consults a new search path variable to look for the module, which = is named `[.ext]`, and calls `dynlib_open` with the absolute path. 2. Emacs calls `dynlib_open` with the basename `tree-sitter-[.ext]`, relying on the module being correctly put on the system's library search = path, e.g. by the distro's package manager. Option 2 sounds better to me, but option 1 is how people do it at the momen= t. (And no distro has packaged these AFAICT.) > Emacs has a load-on-demand infrastructure for shared libraries, but it > only exists on MS-Windows, where we support installations of Emacs > binaries without some of the optional libraries, and want to handle > that gracefully. However, this doesn't seem to be a similar > situation; for starters, load-on-demand needs to know at Emacs build > time the names of entry points (functions and variables) we need to > import from each shared library. So I guess we are talking about some > (slightly) different mechanism here? For each language, the entry point is a single function `TSLanguage (*tree_sitter_) ()`, where `lang` is the name declared in the grammar's DSL source. It's ensured= by the parser generator (the `tree-sitter` CLI program). --=20 Tu=E1=BA=A5n-Anh Nguy=E1=BB=85n Software Engineer