From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#64017: Wrong conversion from Emacs to Tree-sitter S-expression syntax Date: Fri, 16 Jun 2023 13:25:48 +0200 Message-ID: <0CBD145C-0A92-4258-A5F3-6FC616E89ED8@gmail.com> References: <43D49A55-2C3F-4EA4-8DF8-0CD9A516573E@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) 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="15272"; mail-complaints-to="usenet@ciao.gmane.io" Cc: contovob@tcd.ie, 64017@debbugs.gnu.org To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jun 16 13:26:19 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1qA7at-0003qq-KD for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 16 Jun 2023 13:26:19 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qA7ae-0003MM-0s; Fri, 16 Jun 2023 07:26:04 -0400 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 1qA7ac-0003MD-Ou for bug-gnu-emacs@gnu.org; Fri, 16 Jun 2023 07:26:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qA7ac-0008Vu-F1 for bug-gnu-emacs@gnu.org; Fri, 16 Jun 2023 07:26:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qA7ac-0003U5-18 for bug-gnu-emacs@gnu.org; Fri, 16 Jun 2023 07:26:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 16 Jun 2023 11:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64017 X-GNU-PR-Package: emacs X-Debbugs-Original-Cc: Basil Contovounesios , Bug Report Emacs Original-Received: via spool by submit@debbugs.gnu.org id=B.168691475813384 (code B ref -1); Fri, 16 Jun 2023 11:26:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 16 Jun 2023 11:25:58 +0000 Original-Received: from localhost ([127.0.0.1]:48712 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qA7aX-0003To-Rt for submit@debbugs.gnu.org; Fri, 16 Jun 2023 07:25:58 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:58826) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qA7aV-0003Tf-34 for submit@debbugs.gnu.org; Fri, 16 Jun 2023 07:25:55 -0400 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 1qA7aU-0003Lf-O3 for bug-gnu-emacs@gnu.org; Fri, 16 Jun 2023 07:25:54 -0400 Original-Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qA7aT-0008Ot-20 for bug-gnu-emacs@gnu.org; Fri, 16 Jun 2023 07:25:54 -0400 Original-Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-4f762b3227dso842835e87.1 for ; Fri, 16 Jun 2023 04:25:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686914750; x=1689506750; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:from:to:cc:subject :date:message-id:reply-to; bh=I2xiNVZDWgDTxWlM/lLH22vLRbBhF0rKiOH7UYIju3o=; b=Q6u6e4jDMQvl5n6HRdnq8Tm+IIywoDQFsxtiK6WUc+jnLcue6Y6SHNBQ7gqUX3gSNd 72NfJcIH9KszDsS8XgKClkh1WRaqikeJ2/p7UjLyAWpR7HnFlYuUh3jWFYKsfekJYJgD ueQ8w+mWSxqZqTGhDjA4JGXKCTfkxGTe7MuzfDMY1/m5Sgi2RTuLRjEdfwutgBb7MHVS pST3VD8E8kb3AIVi0vhAUfiKxtHWPZOTO3gPUQ8NZLbsLpS2fzKmnraoOtzH3j3WhiaH RyCvQIVFktLX5pg+AefM85fkLwmuJIvEwBCDzd7zb+gmy86BYOTia3fy8nH/xR8U7PMQ 9WwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686914750; x=1689506750; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=I2xiNVZDWgDTxWlM/lLH22vLRbBhF0rKiOH7UYIju3o=; b=I4SwSAVK+ai/JFY1FZX9ttJM8HqUw68rTZMciXJxvY5AHMWcYqvHX2Udltd/riIbbF YnEauw8Lzx4AhMy1QRnOL10m4smTUUVS0ce0nGCzogBWp0sjz+E4Vsu/jaypbMbwQ0xN SiurWL4AhecGo+HGEo4YUFXXPAVFdsQtpSmBwJd1Se9lWeODGi/1nYsdvDXIvFuJ0iil wZsX1DapR1KyjVvQC9Gp5N8PgzFw2IGL+vfAiBXpR0cOq5Lg/SLRrgMbke3YSUXwwFyy iNkh9TFZk3Pm1bU8o4sUmTpOI1xr793Yvt9RQ/DN71XGZChvsXlz4mJLWEMjxfU5zN5H PTNQ== X-Gm-Message-State: AC+VfDyifGIc9hBYq4ARWkKCJl528KUajRDTnva50emJpkNYgNniND3J GQJgquvpd5AOh/h7qWw8jiI= X-Google-Smtp-Source: ACHHUZ7fk1mo24OBUqvrIPFCtl0b3mUfnZiehmfGf1WZpTDmJrMooQCi9gvQ7q0saLM2Mgc2EVBP0w== X-Received: by 2002:ac2:5b5b:0:b0:4f6:2b50:8a1a with SMTP id i27-20020ac25b5b000000b004f62b508a1amr603035lfp.8.1686914749672; Fri, 16 Jun 2023 04:25:49 -0700 (PDT) Original-Received: from smtpclient.apple (c188-150-165-235.bredband.tele2.se. [188.150.165.235]) by smtp.gmail.com with ESMTPSA id s2-20020a19ad42000000b004f6284b3064sm2974541lfd.140.2023.06.16.04.25.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Jun 2023 04:25:49 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3654.120.0.1.15) Received-SPF: pass client-ip=2a00:1450:4864:20::12f; envelope-from=mattias.engdegard@gmail.com; helo=mail-lf1-x12f.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:263470 Archived-At: 16 juni 2023 kl. 00.08 skrev Yuan Fu : >> (By the way, why is the conversion written in C? Was Lisp too slow?) >=20 > Because I wasn't sure if it=E2=80=99s ok for C functions to rely on = Lisp functions, plus the function is simple enough. Right now if one = doesn=E2=80=99t load treesit.el, all the C functions work fine. All right, let's keep it there for now. I fixed the string conversion bug in 8657afac77. >> Ideally we should not need to expose the tree-sitter s-exp query = syntax at all. Surely Emacs s-exps should be preferable in every case? > It shouldn=E2=80=99t hurt to expose the tree-sitter sexp. Other = editors mainly use the string syntax. Most of them probably aren't written in Lisp. But fine, let's keep it as = an alternative syntax. > The difference between tree-sitter syntax and Elisp sexp syntax is = petty small (anchor, predicates), so the text describing the tree-sitter = syntax is basically describing Elisp sexp syntax. Yes, so it seemed to me but reading the source code (lib/src/query.c) = seems to indicate that what I thought were symbols -- *, +, ?, @thing, = #thing -- appear to be special postfix and prefix operators. = (Ironically, there doesn't seem to be a grammar for this language = anywhere, or am I mistaken?) Thus a structurally correct Lispish translation of (teet "toot"* (#equal "fie" @fum)) should arguable be something like (teet (* "toot") ((# equal) "fie" (@ fum))) rather than the current (teet "toot" :* (:equal "fie @fum)) but I'm not demanding that it all be changed at this stage. > With that said if someone makes it describe Elisp sexp syntax first, I = wouldn=E2=80=99t mind. I'll have a look. Wouldn't it be reasonable to use the Elisp syntax, = briefly state how it corresponds to the 'native' syntax, and refer to = the official tree-sitter documentation for details about the latter?