Re: [PATCH v5] userdiff: add builtin diff driver for kotlin language.
- From
Johannes Sixt <j6t@kdbg.org>
- Date
- Mar 7, 2022, 07:07 UTC
- Message-ID
- <8799cd42-bb05-a827-187d-33fb03565f21@kdbg.org>
- In-Reply-To
- <20220306111539.336475-1-jaydeepjd.8914@gmail.com>
Am 06.03.22 um 12:15 schrieb Jaydeep P Das:
Show 18 quoted lines
> diff --git a/userdiff.c b/userdiff.c
> index 8578cb0d12..cd2155bbfe 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]*"
> + /* floating point numbers beginning with decimal point */
> + "|[.][0-9][0-9]*([Ee][-+]?[0-9]+)?[fFlLuU]?"I guess that the suffix u is intended to mark unsigned integers. So, I would say that the alternatives [fFlL] and [fFlLuU] should be swapped.
Furthermore, is it intentional that you do not recognize the '_' digit separator in floating point numbers that begin with a decimal point?
> + /* unary and binary operators */ > + "|[-+*/<>%&^|=!]?==?|--|\\+\\+|<<?=?|>>?=?|&&|\\|[|]?|->|\\.\\*|!!|::|[?:.][.:]"),
What is the justification that there is still "|&&|\\|[|]?|" instead of "|&&|\\|\\||" that I suggested (and I think I stressed that the point is that single-character operators are matched elsewhere) and to which you said "yes, right"?
Also, the part "|<<?=?|>>?=?|" can match <, >, <=, and >=, all of which are matched by other expressions, so you could reduce it to "|<<=|>>=|", because that are the only tokens that they must match.
-- Hannes