unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#59435: 29.0.50; tree-sitter fails to fontify or indent simple function
       [not found] <871qpw7s9k.fsf.ref@yahoo.com>
@ 2022-11-21  6:09 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-11-21  9:45   ` Yuan Fu
  2022-11-23 23:31   ` Yuan Fu
  0 siblings, 2 replies; 13+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-11-21  6:09 UTC (permalink / raw)
  To: 59435


c-ts-mode cannot fontify the following code:

ifsubmitbufl (tp)
{
  register	*kb1 = tp;
  extern	 tbase, i_len;
  register	 l = len;

again:
  
  highprio (); /* tbase is used by protoureg */
  iomap (&UBR, tbase += UBR_SIZ);
  UBR->addr_l = kb1;
  UBR->addr_m = kb1 >> 010;
  UBR->mode_l = 07777 &~ UBR_INST;
  UBR->mode_m = 0;
  UBR->long_l = l;
  UBR->long_m = l >> 010;

  iounmap ();
  tally_iostat (tbase);
  iospoke (UBR, P_LOCK);
  resetprio ();

  SWITCH (S_WAIT|S_HIGH|S_IMMED, 0700, again); /* this returns to
						  BR->senv[0], except
						  if CL_HI */
}

here, ifsubmitbufl, tbase, l and again are fontified as types.  They are
fontified correctly by CC Mode, as three identifiers and one label.

Trying to indent after "again:" results in text being indented to column
0.

In GNU Emacs 29.0.50 (build 3, x86_64-pc-linux-gnu) of 2022-11-21 built
 on trinity
Repository revision: c1a95056214d9bf18bc2c34e938205f1da916bba
Repository branch: feature/tree-sitter
Windowing system distributor 'The X.Org Foundation', version 11.0.12101099
System Description: Fedora Linux 37 (Workstation Edition)

Configured using:
 'configure --with-tree-sitter --with-x-toolkit=no --without-cairo
 --with-dumping=unexec'

Configured features:
ACL DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LCMS2
LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY OLDXMENU PNG RSVG
SECCOMP SOUND SQLITE3 THREADS TIFF TREE_SITTER UNEXEC WEBP X11 XDBE XFT
XIM XINPUT2 XPM ZLIB





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#59435: 29.0.50; tree-sitter fails to fontify or indent simple function
  2022-11-21  6:09 ` bug#59435: 29.0.50; tree-sitter fails to fontify or indent simple function Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-11-21  9:45   ` Yuan Fu
  2022-11-21 11:57     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-11-21 13:52     ` Stefan Kangas
  2022-11-23 23:31   ` Yuan Fu
  1 sibling, 2 replies; 13+ messages in thread
From: Yuan Fu @ 2022-11-21  9:45 UTC (permalink / raw)
  To: Po Lu; +Cc: 59435



> On Nov 20, 2022, at 10:09 PM, Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors <bug-gnu-emacs@gnu.org> wrote:
> 
> 
> c-ts-mode cannot fontify the following code:
> 
> ifsubmitbufl (tp)
> {
>  register	*kb1 = tp;
>  extern	 tbase, i_len;
>  register	 l = len;
> 
> again:
> 
>  highprio (); /* tbase is used by protoureg */
>  iomap (&UBR, tbase += UBR_SIZ);
>  UBR->addr_l = kb1;
>  UBR->addr_m = kb1 >> 010;
>  UBR->mode_l = 07777 &~ UBR_INST;
>  UBR->mode_m = 0;
>  UBR->long_l = l;
>  UBR->long_m = l >> 010;
> 
>  iounmap ();
>  tally_iostat (tbase);
>  iospoke (UBR, P_LOCK);
>  resetprio ();
> 
>  SWITCH (S_WAIT|S_HIGH|S_IMMED, 0700, again); /* this returns to
> 						  BR->senv[0], except
> 						  if CL_HI */
> }
> 
> here, ifsubmitbufl, tbase, l and again are fontified as types.  They are
> fontified correctly by CC Mode, as three identifiers and one label.

Thanks, I fixe the label’s face. As for ifsubmitbufl, tbase, and l, I don’t really understand the syntax here, and I think neither does tree-sitter . In general tree-sitter struggles with nonstandard (in its book anyway) syntax. And there aren’t much we can do (except for maybe improve tree-sitter-c’s parser).

> 
> Trying to indent after "again:" results in text being indented to column
> 0.

Seems to work fine here. I don’t see anything I changed recently that could affect this, either.

Yuan




^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#59435: 29.0.50; tree-sitter fails to fontify or indent simple function
  2022-11-21  9:45   ` Yuan Fu
@ 2022-11-21 11:57     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-11-21 13:53       ` Eli Zaretskii
  2022-11-21 13:52     ` Stefan Kangas
  1 sibling, 1 reply; 13+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-11-21 11:57 UTC (permalink / raw)
  To: Yuan Fu; +Cc: 59435

Yuan Fu <casouri@gmail.com> writes:

>> On Nov 20, 2022, at 10:09 PM, Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors <bug-gnu-emacs@gnu.org> wrote:
>> 
>> 
>> c-ts-mode cannot fontify the following code:
>> 
>> ifsubmitbufl (tp)
>> {
>>  register	*kb1 = tp;
>>  extern	 tbase, i_len;
>>  register	 l = len;
>> 
>> again:
>> 
>>  highprio (); /* tbase is used by protoureg */
>>  iomap (&UBR, tbase += UBR_SIZ);
>>  UBR->addr_l = kb1;
>>  UBR->addr_m = kb1 >> 010;
>>  UBR->mode_l = 07777 &~ UBR_INST;
>>  UBR->mode_m = 0;
>>  UBR->long_l = l;
>>  UBR->long_m = l >> 010;
>> 
>>  iounmap ();
>>  tally_iostat (tbase);
>>  iospoke (UBR, P_LOCK);
>>  resetprio ();
>> 
>>  SWITCH (S_WAIT|S_HIGH|S_IMMED, 0700, again); /* this returns to
>> 						  BR->senv[0], except
>> 						  if CL_HI */
>> }
>> 
>> here, ifsubmitbufl, tbase, l and again are fontified as types.  They are
>> fontified correctly by CC Mode, as three identifiers and one label.
>
> Thanks, I fixe the label’s face.

Thanks.

> As for ifsubmitbufl, tbase, and l, I don’t really understand the
> syntax here, and I think neither does tree-sitter . In general
> tree-sitter struggles with nonstandard (in its book anyway) syntax.

Well, that code is 100% valid C.  "*kb1, tbase, i_len, l" are implicitly
int (which on that machine is 16 bits wide), and so is the value of
"ifsubmitbufl" and "tp".

> And there aren’t much we can do (except for maybe improve
> tree-sitter-c’s parser).

Would someone try that?

> Seems to work fine here. I don’t see anything I changed recently that
> could affect this, either.

Sorry, I think I meant "before".  Place point after "l = len;", then
press RET.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#59435: 29.0.50; tree-sitter fails to fontify or indent simple function
  2022-11-21  9:45   ` Yuan Fu
  2022-11-21 11:57     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-11-21 13:52     ` Stefan Kangas
  1 sibling, 0 replies; 13+ messages in thread
From: Stefan Kangas @ 2022-11-21 13:52 UTC (permalink / raw)
  To: Yuan Fu, Po Lu; +Cc: 59435

Yuan Fu <casouri@gmail.com> writes:

> And there aren’t much we can do (except for maybe improve
> tree-sitter-c’s parser).

We should report these cases as bugs though, right?

IOW, I'm thinking that, going forward, perhaps in these cases it makes
sense for us to close bugs once there is a corresponding bug reported
against the relevant treesitter grammar.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#59435: 29.0.50; tree-sitter fails to fontify or indent simple function
  2022-11-21 11:57     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-11-21 13:53       ` Eli Zaretskii
  2022-11-24 23:38         ` Richard Stallman
  0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2022-11-21 13:53 UTC (permalink / raw)
  To: Po Lu; +Cc: 59435, casouri

> Cc: 59435@debbugs.gnu.org
> Date: Mon, 21 Nov 2022 19:57:08 +0800
> From:  Po Lu via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> > As for ifsubmitbufl, tbase, and l, I don’t really understand the
> > syntax here, and I think neither does tree-sitter . In general
> > tree-sitter struggles with nonstandard (in its book anyway) syntax.
> 
> Well, that code is 100% valid C.

It's K&R C, which is used very rarely these days, and it sounds like the
next version of GCC will reject it, since C2x makes it invalid.

So I see no catastrophe that c-ts-mode doesn't support this.  You can always
opt not to use c-ts-mode if you need this style supported.  Of course, if
tree-sitter's parser is updated to add such support, we'll all be happier.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#59435: 29.0.50; tree-sitter fails to fontify or indent  simple function
  2022-11-21  6:09 ` bug#59435: 29.0.50; tree-sitter fails to fontify or indent simple function Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-11-21  9:45   ` Yuan Fu
@ 2022-11-23 23:31   ` Yuan Fu
  1 sibling, 0 replies; 13+ messages in thread
From: Yuan Fu @ 2022-11-23 23:31 UTC (permalink / raw)
  To: Po Lu; +Cc: 59435


Po Lu <luangruo@yahoo.com> writes:

> Yuan Fu <casouri@gmail.com> writes:
>
>>> On Nov 20, 2022, at 10:09 PM, Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors <bug-gnu-emacs@gnu.org> wrote:
>>> 
>>> 
>>> c-ts-mode cannot fontify the following code:
>>> 
>>> ifsubmitbufl (tp)
>>> {
>>>  register	*kb1 = tp;
>>>  extern	 tbase, i_len;
>>>  register	 l = len;
>>> 
>>> again:
>>> 
>>>  highprio (); /* tbase is used by protoureg */
>>>  iomap (&UBR, tbase += UBR_SIZ);
>>>  UBR->addr_l = kb1;
>>>  UBR->addr_m = kb1 >> 010;
>>>  UBR->mode_l = 07777 &~ UBR_INST;
>>>  UBR->mode_m = 0;
>>>  UBR->long_l = l;
>>>  UBR->long_m = l >> 010;
>>> 
>>>  iounmap ();
>>>  tally_iostat (tbase);
>>>  iospoke (UBR, P_LOCK);
>>>  resetprio ();
>>> 
>>>  SWITCH (S_WAIT|S_HIGH|S_IMMED, 0700, again); /* this returns to
>>> 						  BR->senv[0], except
>>> 						  if CL_HI */
>>> }
>>> 
>>> here, ifsubmitbufl, tbase, l and again are fontified as types.  They are
>>> fontified correctly by CC Mode, as three identifiers and one label.
>>
>> Thanks, I fixe the label’s face.
>
> Thanks.
>
>> As for ifsubmitbufl, tbase, and l, I don’t really understand the
>> syntax here, and I think neither does tree-sitter . In general
>> tree-sitter struggles with nonstandard (in its book anyway) syntax.
>
> Well, that code is 100% valid C.  "*kb1, tbase, i_len, l" are implicitly
> int (which on that machine is 16 bits wide), and so is the value of
> "ifsubmitbufl" and "tp".
>
>> And there aren’t much we can do (except for maybe improve
>> tree-sitter-c’s parser).
>
> Would someone try that?
>
>> Seems to work fine here. I don’t see anything I changed recently that
>> could affect this, either.
>
> Sorry, I think I meant "before".  Place point after "l = len;", then
> press RET.

That seems to work too. It is indented as much as the previous line.

Yuan




^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#59435: 29.0.50; tree-sitter fails to fontify or indent simple function
  2022-11-21 13:53       ` Eli Zaretskii
@ 2022-11-24 23:38         ` Richard Stallman
  2022-11-25  5:12           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
                             ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Richard Stallman @ 2022-11-24 23:38 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: luangruo, 59435, casouri

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > It's K&R C, which is used very rarely these days, and it sounds like the
  > next version of GCC will reject it, since C2x makes it invalid.

The GNU policy is to continue supporting old forms of syntax for many
years after the latest version of a language specification has
deprecated it.  Old programs are sometimes very important.  We should
refuse to aid the crusades to compel people to "upgrade".

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)







^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#59435: 29.0.50; tree-sitter fails to fontify or indent simple function
  2022-11-24 23:38         ` Richard Stallman
@ 2022-11-25  5:12           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-11-28 21:37             ` Richard Stallman
  2022-11-25  6:38           ` Yuan Fu
  2022-11-25  7:45           ` Eli Zaretskii
  2 siblings, 1 reply; 13+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-11-25  5:12 UTC (permalink / raw)
  To: Richard Stallman; +Cc: 59435, Eli Zaretskii, casouri

Richard Stallman <rms@gnu.org> writes:

> The GNU policy is to continue supporting old forms of syntax for many
> years after the latest version of a language specification has
> deprecated it.  Old programs are sometimes very important.  We should
> refuse to aid the crusades to compel people to "upgrade".

Well, it seems that one such crusade is already taking place.  The
crusade will even affect software like Autoconf, especially the
countless configure scripts that have already been generated and are
being included with software:

  https://gcc.gnu.org/pipermail/gcc/2022-November/239883.html
  https://lwn.net/Articles/913505/

Looking at the comments in the latter article, you can see that the
crusade has already been demonstrated to break many pieces of software:
SDL, zsh, just to name a few.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#59435: 29.0.50; tree-sitter fails to fontify or indent simple function
  2022-11-24 23:38         ` Richard Stallman
  2022-11-25  5:12           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-11-25  6:38           ` Yuan Fu
  2022-11-25  7:45           ` Eli Zaretskii
  2 siblings, 0 replies; 13+ messages in thread
From: Yuan Fu @ 2022-11-25  6:38 UTC (permalink / raw)
  To: Richard Stallman; +Cc: Po Lu, 59435, Eli Zaretskii



> On Nov 24, 2022, at 3:38 PM, Richard Stallman <rms@gnu.org> wrote:
> 
> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
> 
>> It's K&R C, which is used very rarely these days, and it sounds like the
>> next version of GCC will reject it, since C2x makes it invalid.
> 
> The GNU policy is to continue supporting old forms of syntax for many
> years after the latest version of a language specification has
> deprecated it.  Old programs are sometimes very important.  We should
> refuse to aid the crusades to compel people to "upgrade”.

If I can support them,I definitely would. It’s just that they’ll have a lower priority when I decide where to put my limited resources on. And we are definitely not actively removing any support.

Yuan







^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#59435: 29.0.50; tree-sitter fails to fontify or indent simple function
  2022-11-24 23:38         ` Richard Stallman
  2022-11-25  5:12           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-11-25  6:38           ` Yuan Fu
@ 2022-11-25  7:45           ` Eli Zaretskii
  2022-11-28 21:37             ` Richard Stallman
  2 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2022-11-25  7:45 UTC (permalink / raw)
  To: rms; +Cc: luangruo, 59435, casouri

> From: Richard Stallman <rms@gnu.org>
> Cc: luangruo@yahoo.com, 59435@debbugs.gnu.org, casouri@gmail.com
> Date: Thu, 24 Nov 2022 18:38:30 -0500
> 
>   > It's K&R C, which is used very rarely these days, and it sounds like the
>   > next version of GCC will reject it, since C2x makes it invalid.
> 
> The GNU policy is to continue supporting old forms of syntax for many
> years after the latest version of a language specification has
> deprecated it.  Old programs are sometimes very important.  We should
> refuse to aid the crusades to compel people to "upgrade".

My point was that such code is extremely rare nowadays (or at least is
extremely rarely _edited_), and thus failure to fontify and/or indent it
correctly isn't a catastrophe IMO.  Unless you disagree with that opinion,
what you say is a tangent for this discussion (although I agree with what
you say regardless).





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#59435: 29.0.50; tree-sitter fails to fontify or indent simple function
  2022-11-25  5:12           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-11-28 21:37             ` Richard Stallman
  2022-11-29  0:46               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 13+ messages in thread
From: Richard Stallman @ 2022-11-28 21:37 UTC (permalink / raw)
  To: Po Lu; +Cc: 59435, eliz, casouri

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

I will look at those articles.
Is there any option to tell GCC to accept older syntax?

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)







^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#59435: 29.0.50; tree-sitter fails to fontify or indent simple function
  2022-11-25  7:45           ` Eli Zaretskii
@ 2022-11-28 21:37             ` Richard Stallman
  0 siblings, 0 replies; 13+ messages in thread
From: Richard Stallman @ 2022-11-28 21:37 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: luangruo, 59435, casouri

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > My point was that such code is extremely rare nowadays (or at least is
  > extremely rarely _edited_), and thus failure to fontify and/or indent it
  > correctly isn't a catastrophe IMO.

I agree with you on that point.

But it's a good thing it led to informing about that "crusade".
I'll talk with people about it off this list.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)







^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#59435: 29.0.50; tree-sitter fails to fontify or indent simple function
  2022-11-28 21:37             ` Richard Stallman
@ 2022-11-29  0:46               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 13+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-11-29  0:46 UTC (permalink / raw)
  To: Richard Stallman; +Cc: 59435, eliz, casouri

Richard Stallman <rms@gnu.org> writes:

> Is there any option to tell GCC to accept older syntax?

Yes.  But Autoconf does not know about those options, so generated
configure scripts that use the old syntax in tests will not work right.





^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-11-29  0:46 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <871qpw7s9k.fsf.ref@yahoo.com>
2022-11-21  6:09 ` bug#59435: 29.0.50; tree-sitter fails to fontify or indent simple function Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-21  9:45   ` Yuan Fu
2022-11-21 11:57     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-21 13:53       ` Eli Zaretskii
2022-11-24 23:38         ` Richard Stallman
2022-11-25  5:12           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-28 21:37             ` Richard Stallman
2022-11-29  0:46               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-25  6:38           ` Yuan Fu
2022-11-25  7:45           ` Eli Zaretskii
2022-11-28 21:37             ` Richard Stallman
2022-11-21 13:52     ` Stefan Kangas
2022-11-23 23:31   ` Yuan Fu

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