unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: luangruo@yahoo.com, 59468@debbugs.gnu.org
Subject: bug#59468: 29.0.50; c-ts-mode cannot fontify after macros are  encountered
Date: Tue, 22 Nov 2022 20:13:49 -0800	[thread overview]
Message-ID: <928B0F3C-4C8C-49EF-AB27-D49BF5E27607@gmail.com> (raw)
In-Reply-To: <83tu2qz6s2.fsf@gnu.org>



> On Nov 22, 2022, at 7:30 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> Cc: 59468@debbugs.gnu.org
>> From: Yuan Fu <casouri@gmail.com>
>> Date: Tue, 22 Nov 2022 12:11:17 -0800
>> 
>> I’m not even sure the author of tree-sitter-c would accept changes that
>> try to parse macros: he has made it clear that the purpose of
>> tree-sitter-c is to support post-processed C and leave macros and
>> preprocessor to error-recovery.
> 
> What do you mean by "error-recovery"?

Basically if tree-sitter encounters something that doesn’t comply to the grammar, it tries to skip a number of tokens, and parse the rest of the file normally. This way any error is localized and the rest of the file can still be parsed. It could also insert “missing nodes” to the tree (eg, a missing parentheses) if that works better than skipping tokens. Those tokens that are skipped are put under an ERROR node, to indicated that they are skipped and normally shouldn’t be there in well-formed text.

> Is it possible to do something on our end for processing the error nodes,
> which would remedy the issue with macros?  Or maybe some other way of
> handling the macros by ourselves?

For each of the ERROR nodes, we can look at the skipped tokens inside, and look around with some regex searching. That would take some non-trivial effort, I imagine.

Yuan




  reply	other threads:[~2022-11-23  4:13 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87k03n4v0r.fsf.ref@yahoo.com>
2022-11-22  1:50 ` bug#59468: 29.0.50; c-ts-mode cannot fontify after macros are encountered Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-22 20:11   ` Yuan Fu
2022-11-23  0:41     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-23  3:30     ` Eli Zaretskii
2022-11-23  4:13       ` Yuan Fu [this message]
2022-11-23  7:36         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-23 12:53           ` Eli Zaretskii
2022-11-23 12:43         ` Eli Zaretskii
2022-11-23  1:27   ` Yuan Fu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-24  0:03   ` Yuan Fu
2022-11-24  0:36     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-24  9:19       ` Eli Zaretskii
2022-11-24 10:36         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-24 10:55           ` Eli Zaretskii
2022-11-24 12:12             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-26  2:39     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors

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=928B0F3C-4C8C-49EF-AB27-D49BF5E27607@gmail.com \
    --to=casouri@gmail.com \
    --cc=59468@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --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).