mirror of
https://github.com/alecthomas/chroma.git
synced 2025-03-17 20:58:08 +02:00
Improve numbers parsing in Kotlin
This commit is contained in:
parent
f4dea84888
commit
b5ccb8dc32
@ -30,7 +30,7 @@ var Kotlin = internal.Register(MustNewLexer(
|
||||
{`"""[^"]*"""`, LiteralString, nil},
|
||||
{`"(\\\\|\\"|[^"\n])*["\n]`, LiteralString, nil},
|
||||
{`'\\.'|'[^\\]'`, LiteralStringChar, nil},
|
||||
{`[0-9](\.[0-9]*)?([eE][+-][0-9]+)?[flFL]?|0[xX][0-9a-fA-F]+[Ll]?`, LiteralNumber, nil},
|
||||
{`0[xX][0-9a-fA-F]+[Uu]?[Ll]?|[0-9]+(\.[0-9]*)?([eE][+-][0-9]+)?[fF]?[Uu]?[Ll]?`, LiteralNumber, nil},
|
||||
{`(companion)(\s+)(object)`, ByGroups(Keyword, Text, Keyword), nil},
|
||||
{`(class|interface|object)(\s+)`, ByGroups(Keyword, Text), Push("class")},
|
||||
{`(package|import)(\s+)`, ByGroups(Keyword, Text), Push("package")},
|
||||
|
1
lexers/testdata/kotlin.actual
vendored
1
lexers/testdata/kotlin.actual
vendored
@ -10,6 +10,7 @@ fun main(args: Array<String>) {
|
||||
StringBuilder().apply {
|
||||
append(multiline)
|
||||
}
|
||||
val unsigned = 0x00UL + 123u + 76.54
|
||||
}
|
||||
/*
|
||||
*/
|
||||
|
16
lexers/testdata/kotlin.expected
vendored
16
lexers/testdata/kotlin.expected
vendored
@ -53,6 +53,22 @@
|
||||
{"type":"Punctuation","value":")"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Punctuation","value":"}"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Keyword","value":"val"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"NameProperty","value":"unsigned"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"="},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"LiteralNumber","value":"0x00UL"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"+"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"LiteralNumber","value":"123u"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"+"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"LiteralNumber","value":"76.54"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"Punctuation","value":"}"},
|
||||
{"type":"Text","value":"\n"},
|
||||
|
Loading…
x
Reference in New Issue
Block a user