GNU bug report logs - #59468
29.0.50; c-ts-mode cannot fontify after macros are encountered

Previous Next

Package: emacs;

Reported by: Po Lu <luangruo <at> yahoo.com>

Date: Tue, 22 Nov 2022 01:52:02 UTC

Severity: normal

Found in version 29.0.50

Full log


Message #17 received at 59468 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: luangruo <at> yahoo.com, 59468 <at> debbugs.gnu.org
Subject: Re: bug#59468: 29.0.50; c-ts-mode cannot fontify after macros are 
 encountered
Date: Tue, 22 Nov 2022 20:13:49 -0800

> On Nov 22, 2022, at 7:30 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
>> Cc: 59468 <at> debbugs.gnu.org
>> From: Yuan Fu <casouri <at> 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



This bug report was last modified 2 years and 302 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.