unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: "Mattias Engdegård" <mattias.engdegard@gmail.com>
Cc: contovob@tcd.ie, 64017@debbugs.gnu.org
Subject: bug#64017: Wrong conversion from Emacs to Tree-sitter S-expression syntax
Date: Sat, 17 Jun 2023 16:02:58 -0700	[thread overview]
Message-ID: <AFA7E9F7-E149-4E66-99E1-2D3D1CF460D3@gmail.com> (raw)
In-Reply-To: <0CBD145C-0A92-4258-A5F3-6FC616E89ED8@gmail.com>

> 
> 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.

IMHO the query syntax is already pretty far away from a “proper sexp” that we expect, so changing these little things don’t have much benefit. For example, the field names and trailing capture names are not conventional, are we going to change them to be more sexpy too? 

In a proper sexp they would have been wrapped too, like

(field-name: node) rather than field-name: node
(@fn node) rather than node @fn

Not to mention using colon and @ to distinguish field-names and capture names from nodes—not very conventional either.

Also a more conventional sexp syntax would be much more verbose than the current one, and arguable harder to translate to the tree-sitter string syntax, which is ultimately what we feed to tree-sitter functions.

Yuan




      parent reply	other threads:[~2023-06-17 23:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12 14:14 bug#64017: Wrong conversion from Emacs to Tree-sitter S-expression syntax Mattias Engdegård
     [not found] ` <handler.64017.B.168657924917612.ack@debbugs.gnu.org>
2023-06-15 10:45   ` Mattias Engdegård
2023-06-15 22:13     ` Yuan Fu
2023-06-15 22:08 ` Yuan Fu
2023-06-16 11:25   ` Mattias Engdegård
2023-06-16 17:02     ` Mattias Engdegård
2023-06-16 17:33       ` Basil Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-17 10:47         ` Mattias Engdegård
2023-06-17 12:57           ` Eli Zaretskii
2023-06-17 13:30             ` Mattias Engdegård
2023-06-17 22:55               ` Yuan Fu
2023-06-18  8:47                 ` Mattias Engdegård
2023-06-17 23:02     ` Yuan Fu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AFA7E9F7-E149-4E66-99E1-2D3D1CF460D3@gmail.com \
    --to=casouri@gmail.com \
    --cc=64017@debbugs.gnu.org \
    --cc=contovob@tcd.ie \
    --cc=mattias.engdegard@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).