-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Open
Labels
Description
Describe the issue
highlight.js highlighting of Kotlin number literals doesn't match the actual number literals Kotlin accepts, including false-positives and false-negatives.
Which language seems to have the issue?
kotlin
Are you using highlight
or highlightAuto
?
No
...
Sample Code to Reproduce
https://jsfiddle.net/u3fn8t9m/
// Correct
val croissants = 34L
val muesli = 34f
val porridge = 34F
// False Negatives
// valid Kotlin - wrong highlighted
val schnitzel = 100u
val hagelslag = 23U
val churros = 99UL
// False Positives
// invalid Kotlin - still highlighted
val muesli = 34l
val melange = 34d
val bagel = 34D
Expected behavior
I expect the highlighting to match the official Kotlin grammar.
Additional context
From the Kotlin Spec section 1.2.3 Literals there are only 3 Rules that define suffixes for number literals:
FloatLiteral:
DoubleLiteral ('f' |'F')
| DecDigits ('f' |'F')
UnsignedLiteral
(IntegerLiteral | HexLiteral | BinLiteral) ('u' |'U') ['L']
LongLiteral
(IntegerLiteral | HexLiteral | BinLiteral)'L'
However, the current grammar for Kotlin reuses Java numerical parsing which does have significant differences.