Re: [PATCH v6] userdiff: add builtin diff driver for kotlin language.
- From
Johannes Sixt <j6t@kdbg.org>
- Date
- Mar 11, 2022, 20:07 UTC
- Message-ID
- <16543315-8515-a4d7-d75b-e7fe9731a7cf@kdbg.org>
- In-Reply-To
- <20220311072716.674808-1-jaydeepjd.8914@gmail.com>
Am 11.03.22 um 08:27 schrieb Jaydeep P Das:
Show 10 quoted lines
> The xfuncname pattern finds func/class declarations > in diffs to display as a hunk header. The word_regex > pattern finds individual tokens in Kotlin code to generate > appropriate diffs. > > This patch adds xfuncname regex and word_regex for Kotlin > language. > > Signed-off-by: Jaydeep P Das <jaydeepjd.8914@gmail.com> > ---
Thank you. At first, I thought this round is it, but then I noticed this line:
> +<RED>0xFF_EC_DE_5E 0b100_000 1<RESET><GREEN>0xFF_E1_DE_5E 0b100_100 2<RESET>00_000
Notice how the change from 100_000 to 200_000 breaks out the first digit into its own token.
Show 16 quoted lines
> diff --git a/userdiff.c b/userdiff.c
> index 8578cb0d12..c416c9b426 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_]*([.][0-9_]*)([Ee][-+]?[0-9]+)?[fFlLuU]*"This line matches a non-empty digit sequence of any length, and I thought the longest match would win. Why is that not the case here? Frankly, I'm scratching my head over it. Any ideas?
Show 7 quoted lines
> + /* floating point numbers beginning with decimal point */
> + "|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]?"
> + /* unary and binary operators */
> + "|[-+*/<>%&^|=!]==?|--|\\+\\+|<<=|>>=|&&|\\|\\||->|\\.\\*|!!|[?:.][.:]"),
> PATTERNS("markdown",
> "^ {0,3}#{1,6}[ \t].*",
> /* -- */-- Hannes