From: Johannes Sixt Date: Sat, 05 Mar 2022 14:17:17 GMT Subject: Re: [PATCH v4] userdiff: add builtin diff driver for Kotlin language. Message-ID: <4118762b-e2f1-4f77-68f3-e61cbe65aff7@kdbg.org> In-Reply-To: <20220305094004.250570-1-jaydeepjd.8914@gmail.com> Am 05.03.22 um 10:40 schrieb Jaydeep P Das: > +_32_33.find(arr) > +X.fill().find() > +X.u.f+1 > +X.u-+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