unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattias.engdegard@gmail.com>
To: Yuan Fu <casouri@gmail.com>
Cc: contovob@tcd.ie, 64017@debbugs.gnu.org
Subject: bug#64017: Wrong conversion from Emacs to Tree-sitter S-expression syntax
Date: Fri, 16 Jun 2023 13:25:48 +0200	[thread overview]
Message-ID: <0CBD145C-0A92-4258-A5F3-6FC616E89ED8@gmail.com> (raw)
In-Reply-To: <C921E626-2783-48D6-A161-C45F016FA634@gmail.com>

16 juni 2023 kl. 00.08 skrev Yuan Fu <casouri@gmail.com>:

>> (By the way, why is the conversion written in C? Was Lisp too slow?)
> 
> Because I wasn't sure if it’s ok for C functions to rely on Lisp functions, plus the function is simple enough. Right now if one doesn’t 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’t 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’t 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?






  reply	other threads:[~2023-06-16 11:25 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 [this message]
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

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=0CBD145C-0A92-4258-A5F3-6FC616E89ED8@gmail.com \
    --to=mattias.engdegard@gmail.com \
    --cc=64017@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=contovob@tcd.ie \
    /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).