From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Daniel_Mart=C3=ADn?= Newsgroups: gmane.emacs.devel Subject: Simplify the tree-sitter parser creation API Date: Sun, 15 May 2022 16:39:36 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32486"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun May 15 16:42:31 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 1nqFS3-0008FJ-1L for ged-emacs-devel@m.gmane-mx.org; Sun, 15 May 2022 16:42:31 +0200 Original-Received: from localhost ([::1]:35906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqFS2-0005iS-3J for ged-emacs-devel@m.gmane-mx.org; Sun, 15 May 2022 10:42:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38082) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqFPO-0003yv-QG for emacs-devel@gnu.org; Sun, 15 May 2022 10:39:51 -0400 Original-Received: from sonic306-20.consmr.mail.ir2.yahoo.com ([77.238.176.206]:43356) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nqFPM-0007Wo-4h for emacs-devel@gnu.org; Sun, 15 May 2022 10:39:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1652625581; bh=hF+aBCWh1wmU7WnqTckisao0LYOwR+PXusTUfISC+9w=; h=From:To:Subject:Date:References:From:Subject:Reply-To; b=r3OVw7d3jn6neVzCRawzoAuKJRV7iBcsk7bKrp851NfPksU5oeiFfGoK2LgBhVVh4WAMi12HCMIfkGmeHNFoajKKpDgkBydcP6CDFi4jsBrtn4ED//Fh9KQbZXjJP090SeGk6cDNCuayc/ZArO84OUnieeRX27h4bj9GnbPSOLzMdoepaKn4GOWFNw5IvkvQariLeBgbNhakH1k6ZdDFHplreznofQ+E5e+rfW93J038GQWwPSz9HuiX+9Ru9hhZGBTM5P3b0YkBc75b9zzmh4v3a3OOpIYl6sV3UuYkg3jiB5ljCH97CIptf2yZMK0dTLAC/Bl8D58UYM+Q9YyINQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1652625581; bh=6XAG1m0YduB64kzE7pRwIiSyvz8tJEzehH7Fx6XSiQG=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=Qqau4L9jtSr3E93L/fEcEdmXehI3W0HVM/fcNYJtuDugkr05CwsPm3m/dGadzbC7t6sydie3ACz5sw5KcES/SyddepP2WKQaaPZJboeHYnSZ134GKcRJYpv16M56f+LG5bnUz2i/lcI9goYplPPloxweeR3qGk2ok09nlhllkfVbq9aw1/F5e03gtN1C3G/7Fk6b4m5T8NzEE67tBGdSjcgCMn/Qqn2qVFyna2A0aiXShg7n1hpFBxhERJBWfbHHnpme6GdK2LW5nv8THn/FXU5/dbzqetCkAbnJSkl5zQv7b/+++Yf7fJRipsLHydQrfq4nuXyJO02b/ZSLq9TPlw== X-YMail-OSG: TNg5agoVM1lcS9TdtA_G4UzkJV4kyYBn0fXOpqFtHx9ispvEgvly9aJvrTrfY9N 9u_VxSvyLtyIGnrte_Q4V8JN8a2120Kkxg_wDkcPDGCuoy20NRYcYF0Omo6Ec1LopRkCpHDEqoqx biMHAf9kg9.BcQ_BqckfXUdGblXO3KJ0XlNjDpky_1UG.cPD2PK1o1HIGSBU.bgTQM.R1uTaJfhQ UZ3WF6I.Zmg.3XkCMUwvy066egMR.rmCwXgBoN.mdHxJ1Emm6rQHNcaokYAv3BJYxxjCFP40Al6M EGufY1Wn5bVK3_E7xsJrT7AFW4JGhTiUi9J9pV11Wh8ohPB5t2dTFSy0nB.PZQsIVoSQuygBMq6t 2EFbkOk_RcPc5U2C3WucPax7bhz7isihJXSShA44eXDLb_tUBLpSD5DI7vgojEnuv8f7ikDn4syv V73dFVD.nSPv1L9muVmTAgjGgIqaI0FBlv4eGaU5RrdcF4rc1Jn0eOM4PV6C3b2XGHvPvHiXCH5V l_AIM1QQanWFlu_fqj6ZOJ0n9sIr0XnS62d7bCREdS8t8Dy8wkQD5zF7HF34jwaXqNtsjhc1w0e. XCRzFcShH56hxOrYZIGiOITPR1XvrqeN08fAqcExMJz9zhuXhSeHfFv_8CC9Ew6iYvkkeM5CgG3Y CSqln4xEpcbGiwG9bPG86NlmsGp7XLiUVX2i9ePj6mnNVn7TogSlTMQ9nXDAsmj4CHGsjq8hGV1q y6zm9dO9Wuc6xGYDaEh.I2webOSSVbuJ2llq6SiEL3OHoSG7wIf8._iVncvonGH4T59BNqM5qgcq 0BqwSHyYbcJEoUp7pQ3Eb9ANYGdNS0En3EU3v5nJE1 X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic306.consmr.mail.ir2.yahoo.com with HTTP; Sun, 15 May 2022 14:39:41 +0000 Original-Received: by hermes--canary-production-ir2-695448f88c-c29cs (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 2ef3534abfad4f2d38b038635b8974b9; Sun, 15 May 2022 14:39:38 +0000 (UTC) X-Mailer: WebService/1.1.20188 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=77.238.176.206; envelope-from=mardani29@yahoo.es; helo=sonic306-20.consmr.mail.ir2.yahoo.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" Xref: news.gmane.io gmane.emacs.devel:289794 Archived-At: Currently, there are three functions to create a tree-sitter parser: - treesit-get-parser-create - treesit-get-parser - treesit-parser-create I think this set of similarly named functions can be reduced, so that developers don't need to remember a lot of APIs. How I understand the problem of creating a tree-sitter parser is that we need three things from the developer: - A programming language (a symbol). - A buffer (optional, default to the current buffer). - Whether to create or reuse an existing parser for that language. I think it would be simpler to have just one parser creation API like (treesit-make-parser LANGUAGE &optional BUFFER ALWAYS-NEW) There are similar API patterns like this one already in Emacs. With this proposed API, the common case, which is to create a parser for the current buffer, and to try to reuse one if it already exists, is very simple from the POV of an ELisp developer integrating with tree-sitter: (treesit-make-parser 'c) Any thoughts?