Thread (44 messages) 44 messages, 4 authors, 2022-03-13

Re: [PATCH v5] userdiff: add builtin diff driver for kotlin language.

From: Johannes Sixt <hidden>
Date: 2022-03-07 07:08:06

Am 06.03.22 um 12:15 schrieb Jaydeep P Das:
quoted hunk ↗ jump to hunk
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help