Re: [PATCH v4] userdiff: add builtin diff driver for Kotlin language.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 05.03.22 um 10:40 schrieb Jaydeep P Das:
> +<RED>_32<RESET><GREEN>_33<RESET>.find(arr)
> +X<RED>.fill()<RESET><GREEN>.find()<RESET>
> +X<RED>.u<RESET><GREEN>.f<RESET>+1
> +X.u<RED>-<RESET><GREEN>+<RESET>2

Nice move to include these new tests!

> diff --git a/userdiff.c b/userdiff.c
> index 8578cb0d12..24821a0f69 100644
> --- a/userdiff.c
> +++ b/userdiff.c
> @@ -168,6 +168,18 @@ PATTERNS("java",
>  	 "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
>  	 "|[-+*/<>%&^|=!]="
>  	 "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"),
> +PATTERNS("kotlin",
> +	 "^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$",
> +	 /* -- */
> +	 "[a-zA-Z_][a-zA-Z0-9_]*"
> +	 /* hexadecimal and binary numbers */
> +	 "|0[xXbB][0-9a-fA-F_]+[lLuU]*"
> +	 /* integers and floats */
> +	 "|[0-9][0-9_.]*([Ee][-+]?[0-9]+)?[fFlL]*"

Good!

> +	 /* method calls */
> +	 "|[.][a-zA-Z()0-9]+"

This matches both .empty() as well as .125, but only the .5e part of
.5e-3 and only the .find(x part of .find(x/2). Is that intended?

I find the desire to have method calls as an entire token a bit strange.
In other languages, the last expression part is actually split into many
tokens: . find ( x / 2 ).

BTW, I'm in no way saying that this must be changed (personally I do not
care at all as I'm not writing Kotlin), so if you say that is how people
want Kotlin code to be split with --word-diff, I will believe you.

> +	 /* unary and binary operators */
> +	 "|[-+*/<>%&^|=!]?=(=)?|--|\\+\\+|<<?=?|>>?=?|&&?|[|]?\\||\\|->\\*?|\\.\\*"),

Is the part

	 "|\\|->\\*?|"

actually meant to be something else? Does Kotlin have the tokens "|->"
and "|->*"?

A final minor nit: There is "|&&?|[|]?\\||" that could just be
"|&&|\\|\\||" (remember: single character operators are matched implicitly).

>  PATTERNS("markdown",
>  	 "^ {0,3}#{1,6}[ \t].*",
>  	 /* -- */

-- Hannes



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux