unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: emacs-devel@gnu.org
Subject: Re: RFR cc-langs.el: change syntax for @ in Java
Date: Mon, 12 Apr 2021 13:36:07 +0000	[thread overview]
Message-ID: <YHRMx5S9kzcy8REB@ACM> (raw)
In-Reply-To: <m2h7kgsn52.fsf@fastmail.fm>

Hello, Filipp.

On Thu, Apr 08, 2021 at 20:26:49 +0300, Filipp Gunbin wrote:
> Hi Alan,

> On 08/04/2021 10:15 +0000, Alan Mackenzie wrote:

> > I've just run the CC Mode test suite with this amendment, and it
> > produces the following successes on annotations-1.java:

> > annotations-1.java:4: Expected analysis ((inclass 1) (topmost-intro 21)), got ((inclass 21) (topmost-intro 21))
> > annotations-1.java:4: Expected indentation 0, got 32
> > annotations-1.java:5: Expected analysis ((class-close 1)), got ((class-close 21))

> > ..  So, there are things to sort out before we can apply the change.

> I think these breakages are not real breakages, but rather the resfile
> could be updated.

I've had a more thorough look at it.  In cc-langs.el, there are several
places where @ is treated as a symbol character, namely:

L375: c-make-mode-syntax-table (which you have proposed modifying)
L419: c-identifier-syntax-modifications
L636: c-symbol-start
L1969: c-paragraph-start (I think this one only applies in comments)
L2198: c-class-decl-kwds (The "@interface" keyword)

We need to consider whether to amend some or all of these places, so
that @ ceases to be a (starting) character of an identifier.

I'm also a bit worried that in

    @NonNull
    @TestClass
    @FooBar
    public class Annotations {

, the last line gets parsed as ((annotation-top-cont 21)), where it
really ought to be a topmost-intro.  But this problem is present without
your patch, anyway.

In summary, I think the motivation for the change (highlighting symbols
correctly) is valid, but the change is going to be more involved than
the patch you've supplied.

Do you want to look at all these things, or should I?


> This class:

> --8<---------------cut here---------------start------------->8---
> @NonNull
> @TestClass
> @FooBar public class Annotations {

> }
> --8<---------------cut here---------------end--------------->8---

> previosly "started" at the @NonNull line, but now "starts" at @FooBar
> line, which is absolutely correct.

Are you saying here that @FooBar is actually a part of the declaration
of class Annotations?  If so, why not @NonNull and @TestClass as well?

> So here's the updated patch (now against the cc-mode repo).
> Thanks.

Thank you!

> diff -r 10abd4587dad cc-langs.el
> --- a/cc-langs.el	Mon Mar 29 15:20:53 2021 +0000
> +++ b/cc-langs.el	Thu Apr 08 20:22:56 2021 +0300
> @@ -365,12 +365,14 @@
>         (let ((table (make-syntax-table)))
>  	 (c-populate-syntax-table table)
>  	 ;; Mode specific syntaxes.
> -	 ,(cond ((or (c-major-mode-is 'objc-mode) (c-major-mode-is 'java-mode))
> +	 ,(cond ((c-major-mode-is 'objc-mode)
>  		 ;; Let '@' be part of symbols in ObjC to cope with
>  		 ;; its compiler directives as single keyword tokens.
>  		 ;; This is then necessary since it's assumed that
>  		 ;; every keyword is a single symbol.
>  		 `(modify-syntax-entry ?@ "_" table))
> +		((c-major-mode-is 'java-mode)
> +		 `(modify-syntax-entry ?@ "'" table))
>  		((c-major-mode-is 'pike-mode)
>  		 `(modify-syntax-entry ?@ "." table)))
>  	 table)))
> diff -r 10abd4587dad tests/annotations-1.res
> --- a/tests/annotations-1.res	Mon Mar 29 15:20:53 2021 +0000
> +++ b/tests/annotations-1.res	Thu Apr 08 20:22:56 2021 +0300
> @@ -1,8 +1,8 @@
>  ((topmost-intro <0,0>))
>  ((annotation-top-cont <1,0>))
>  ((annotation-top-cont <1,0>))
> -((inclass <3,0>) (topmost-intro <1,0>))
> -((class-close <4,0>))
> +((inclass <1,0>) (topmost-intro <1,0>))
> +((class-close <2,0>))
>  ((topmost-intro <1,0>))
>  ((topmost-intro <2,0>))
>  ((inclass <1,0>) (topmost-intro <1,0>))

-- 
Alan Mackenzie (Nuremberg, Germany).



  reply	other threads:[~2021-04-12 13:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07 20:41 RFR cc-langs.el: change syntax for @ in Java Filipp Gunbin
2021-04-08  9:29 ` Alan Mackenzie
2021-04-08 10:15 ` Alan Mackenzie
2021-04-08 11:31   ` Filipp Gunbin
2021-04-08 17:26   ` Filipp Gunbin
2021-04-12 13:36     ` Alan Mackenzie [this message]
2021-04-12 17:33       ` Filipp Gunbin
2021-04-13 10:28         ` Alan Mackenzie
2021-04-13 14:45           ` Filipp Gunbin
2021-04-14 19:55             ` Alan Mackenzie
2021-04-14 21:31               ` Ergus
2021-04-15 14:42               ` Filipp Gunbin

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=YHRMx5S9kzcy8REB@ACM \
    --to=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    /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).