unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Yuan Fu <casouri@gmail.com>
Cc: luangruo@yahoo.com, holgerschurig@gmail.com, Emacs-devel@gnu.org
Subject: Re: tree-sitter: conceptional problem solvable at Emacs' level?
Date: Fri, 10 Feb 2023 10:42:09 +0200	[thread overview]
Message-ID: <837cwplxni.fsf@gnu.org> (raw)
In-Reply-To: <0DDF6978-D75A-4137-9D93-6200908675B6@gmail.com> (message from Yuan Fu on Thu, 9 Feb 2023 23:33:10 -0800)

> From: Yuan Fu <casouri@gmail.com>
> Date: Thu, 9 Feb 2023 23:33:10 -0800
> Cc: Holger Schurig <holgerschurig@gmail.com>,
>  Emacs-devel@gnu.org
> 
> > Parsers (without a full C preprocessor inside) can only work for
> > languages like Python, which cannot be enhanced with syntax-modifying
> > macros.
> 
> Right. Our best hope is for someone to try extend the current tree-sitter-c grammar, but I don’t know how feasible it is. Emacs can also do some limited workaround, but the potential in that department is slim.

I think we still have a way to go before we reach the above
conclusions (which basically mean we give up on improving the
situation with C/C++ macros).  We should explore other approaches.

One such approach would be to perform our own analysis when the parser
returns an error node due to macros.

Another possibility is to complicate the function we pass to
tree-sitter with which to read buffer text, in a way that replaces the
text of a macro with something else (in the simplest case, just space
characters), so as to avoid errors in the parser, and again analyze
the macros in our own code.

And I'm sure there are other alternatives.  This issue is not unique
to Emacs, so studying how other IDEs deal with it could also yield
ideas.

Volunteers interested in improving support for C/C++ based on
tree-sitter are very welcome to step forward and work on these issues.

Thanks.



  reply	other threads:[~2023-02-10  8:42 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-09  8:09 tree-sitter: conceptional problem solvable at Emacs' level? Holger Schurig
2023-02-09  8:17 ` Po Lu
2023-02-09  8:50   ` Eli Zaretskii
2023-02-09 10:13     ` Po Lu
2023-02-09 10:55       ` Eli Zaretskii
2023-02-10  7:33   ` Yuan Fu
2023-02-10  8:42     ` Eli Zaretskii [this message]
     [not found]       ` <CAOpc7mHX6s0B8vdDee+9FMvQejGTSL3jzgwVekS7Esg-AOf=jw@mail.gmail.com>
2023-02-10 11:48         ` Eli Zaretskii
2023-02-11  2:17           ` Po Lu
2023-02-11  6:25             ` Konstantin Kharlamov
2023-02-11  6:36               ` Konstantin Kharlamov
2023-02-11  6:51                 ` Theodor Thornhill
2023-02-11  7:11                   ` Konstantin Kharlamov
2023-02-11  7:53                     ` Konstantin Kharlamov
2023-02-11  8:22                     ` Konstantin Kharlamov
2023-02-11  8:41                       ` Theodor Thornhill
2023-02-11  9:37                         ` Konstantin Kharlamov
2023-02-11 10:25                           ` Konstantin Kharlamov
2023-02-11  8:43                     ` Eli Zaretskii
2023-04-16 19:21                   ` Konstantin Kharlamov
2023-02-11  9:34       ` Ihor Radchenko
2023-02-11 10:42         ` Eli Zaretskii
2023-02-11 13:58         ` Lynn Winebarger
2023-02-09 16:25 ` Ergus
2023-02-09 20:09   ` Dmitry Gutov
2023-02-10  7:41     ` Holger Schurig

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=837cwplxni.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=Emacs-devel@gnu.org \
    --cc=casouri@gmail.com \
    --cc=holgerschurig@gmail.com \
    --cc=luangruo@yahoo.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).