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

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

From: Johannes Sixt <hidden>
Date: 2022-03-04 13:59:38

Am 04.03.22 um 13:28 schrieb Jaydeep Das:
On 3/4/22 01:34, Johannes Sixt wrote:
quoted
Am 03.03.22 um 12:41 schrieb Jaydeep Das:
quoted
How about modifying the number match regex to:

`[0-9._]+([Ee][-+]?[0-9]+)?[fFlLuU]*[^a-zA-Z]` ?

The `[^a-zA-Z]` in the end would make sure to not match
the `.F` in `X.Find`.
 
quoted
No, you cannot do that, because then in X.u+1 you have three tokens X
.u+ 1, which you do not want, either.
If X is an integer here, then
No, I mean X literally, i.e., an identifier.
In C/C++ 2.f is equivalent to 2.000000
However in Kotlin 2.f is invalid syntax. 2.0f is valid.

So is implementing a proper regex for invalid syntax really
necessary?
No, that's not necessary. It can be assumed that invalid syntax does not
occur. For this reason...
quoted
Have a look at the regex in the cpp driver. I think we need something
like this:

   /* integers floatingpoint numbers */
   "|[0-9][0-9_.]*([Ee][*-]?[0-9]+)?[FfLl]*"
... I propose this loose [0-9_.]* after the first digit, even though it
would match "9.8_7._65"; we can assume that this invalid token will not
occur.

BTW, make that [FfLlUl] near the end.
quoted
   /* floatingpoint numbers that begin with a decimal point */
   "|[.][0-9][0-9_]*([Ee][*-]?[0-9]+)?[FfLl]*"
quoted
Drop the second option if numbers such as .5 are invalid syntax in
Kotlin.
.5 is valid syntax in Kotlin.
OK, then we need this second branch, which ensures that there is a digit
after the fullstop.

-- 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