1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-03-19 21:10:15 +02:00

Improve numbers parsing in Kotlin

This commit is contained in:
Victor Kropp 2019-02-08 23:50:23 +01:00 committed by Alec Thomas
parent f4dea84888
commit b5ccb8dc32
3 changed files with 18 additions and 1 deletions

View File

@ -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")},

View File

@ -10,6 +10,7 @@ fun main(args: Array<String>) {
StringBuilder().apply {
append(multiline)
}
val unsigned = 0x00UL + 123u + 76.54
}
/*
*/

View File

@ -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"},