mirror of
https://github.com/alecthomas/chroma.git
synced 2025-02-09 13:23:51 +02:00
Fix regex from as? to as\?; add one more test case for !==
This commit is contained in:
parent
8a54f9ea89
commit
aac329441b
@ -26,7 +26,7 @@ var Kotlin = internal.Register(MustNewLexer(
|
||||
{`\n`, Text, nil},
|
||||
{`!==|!in|!is|===`, Operator, nil},
|
||||
{`%=|&&|\*=|\+\+|\+=|--|-=|->|\.\.|\/=|::|<=|==|>=|!!|!=|\|\||\?[:.]`, Operator, nil},
|
||||
{`[~!%^&*()+=|\[\]:;,.<>/?-]`, Punctuation, nil},
|
||||
{`[~!%^&*()+=|\[\]:;,.<>\/?-]`, Punctuation, nil},
|
||||
{`[{}]`, Punctuation, nil},
|
||||
{`"""[^"]*"""`, LiteralString, nil},
|
||||
{`"(\\\\|\\"|[^"\n])*["\n]`, LiteralString, nil},
|
||||
@ -37,7 +37,7 @@ var Kotlin = internal.Register(MustNewLexer(
|
||||
{`(package|import)(\s+)`, ByGroups(Keyword, Text), Push("package")},
|
||||
{`(val|var)(\s+)`, ByGroups(Keyword, Text), Push("property")},
|
||||
{`(fun)(\s+)(<[^>]*>\s+)?`, ByGroups(Keyword, Text, Text), Push("function")},
|
||||
{`(abstract|actual|annotation|as|as?|break|by|catch|class|companion|const|constructor|continue|crossinline|data|delegate|do|dynamic|else|enum|expect|external|false|field|file|final|finally|for|fun|get|if|import|in|infix|init|inline|inner|interface|internal|is|it|lateinit|noinline|null|object|open|operator|out|override|package|param|private|property|protected|public|receiver|reified|return|sealed|set|setparam|super|suspend|tailrec|this|throw|true|try|typealias|typeof|val|var|vararg|when|where|while)\b`, Keyword, nil},
|
||||
{`(abstract|actual|annotation|as|as\?|break|by|catch|class|companion|const|constructor|continue|crossinline|data|delegate|do|dynamic|else|enum|expect|external|false|field|file|final|finally|for|fun|get|if|import|in|infix|init|inline|inner|interface|internal|is|it|lateinit|noinline|null|object|open|operator|out|override|package|param|private|property|protected|public|receiver|reified|return|sealed|set|setparam|super|suspend|tailrec|this|throw|true|try|typealias|typeof|val|var|vararg|when|where|while)\b`, Keyword, nil},
|
||||
{"(@?[" + kotlinIdentifier + "]*`)", Name, nil},
|
||||
},
|
||||
"package": {
|
||||
@ -50,6 +50,10 @@ var Kotlin = internal.Register(MustNewLexer(
|
||||
{"(@?[" + kotlinIdentifier + " ]*`)", NameProperty, Pop(1)},
|
||||
},
|
||||
"function": {
|
||||
|
||||
{`[~!%^&*()+=|\[\]:;,.<>\/?-]`, Punctuation, nil},
|
||||
{`(abstract|actual|annotation|as|as\?|break|by|catch|class|companion|const|constructor|continue|crossinline|data|delegate|do|dynamic|else|enum|expect|external|false|field|file|final|finally|for|fun|get|if|import|in|infix|init|inline|inner|interface|internal|is|it|lateinit|noinline|null|object|open|operator|out|override|package|param|private|property|protected|public|receiver|reified|return|sealed|set|setparam|super|suspend|tailrec|this|throw|true|try|typealias|typeof|val|var|vararg|when|where|while)\b`, Keyword, nil},
|
||||
|
||||
{"(@?[" + kotlinIdentifier + " ]*`)", NameFunction, Pop(1)},
|
||||
},
|
||||
},
|
||||
|
3
lexers/testdata/kotlin.actual
vendored
3
lexers/testdata/kotlin.actual
vendored
@ -62,7 +62,8 @@ fun moreOperators(arg: Any?) {
|
||||
in emptyList<Int>() -> { }
|
||||
}
|
||||
|
||||
println(arg === Unit)
|
||||
if(arg !== Boolean)
|
||||
println(arg === Unit)
|
||||
}
|
||||
|
||||
class X {
|
||||
|
43
lexers/testdata/kotlin.expected
vendored
43
lexers/testdata/kotlin.expected
vendored
@ -171,7 +171,7 @@
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"{"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Keyword","value":"a"},
|
||||
{"type":"Name","value":"a"},
|
||||
{"type":"Punctuation","value":","},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Name","value":"_"},
|
||||
@ -186,7 +186,7 @@
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"NameFunction","value":"someOperators"},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"Keyword","value":"a"},
|
||||
{"type":"Name","value":"a"},
|
||||
{"type":"Punctuation","value":":"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Name","value":"Int"},
|
||||
@ -220,7 +220,7 @@
|
||||
{"type":"Name","value":"println"},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Keyword","value":"a"},
|
||||
{"type":"Name","value":"a"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"%"},
|
||||
{"type":"Text","value":" "},
|
||||
@ -233,30 +233,30 @@
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Keyword","value":"in"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Keyword","value":"a"},
|
||||
{"type":"Name","value":"a"},
|
||||
{"type":"Operator","value":".."},
|
||||
{"type":"Name","value":"b"},
|
||||
{"type":"Punctuation","value":")"},
|
||||
{"type":"Text","value":"\n \n "},
|
||||
{"type":"Keyword","value":"a"},
|
||||
{"type":"Name","value":"a"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"%="},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"LiteralNumber","value":"2"},
|
||||
{"type":"Text","value":"\n\t"},
|
||||
{"type":"Keyword","value":"a"},
|
||||
{"type":"Name","value":"a"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"\u0026\u0026"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Name","value":"b"},
|
||||
{"type":"Text","value":"\n\t"},
|
||||
{"type":"Keyword","value":"a"},
|
||||
{"type":"Name","value":"a"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"*="},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"LiteralNumber","value":"2"},
|
||||
{"type":"Text","value":"\n\t"},
|
||||
{"type":"Keyword","value":"a"},
|
||||
{"type":"Name","value":"a"},
|
||||
{"type":"Operator","value":"++"},
|
||||
{"type":"Text","value":"\n\t"},
|
||||
{"type":"Name","value":"b"},
|
||||
@ -266,17 +266,17 @@
|
||||
{"type":"Name","value":"b"},
|
||||
{"type":"Operator","value":"--"},
|
||||
{"type":"Text","value":"\n\t"},
|
||||
{"type":"Keyword","value":"a"},
|
||||
{"type":"Name","value":"a"},
|
||||
{"type":"Operator","value":"-="},
|
||||
{"type":"LiteralNumber","value":"1"},
|
||||
{"type":"Text","value":"\n\t"},
|
||||
{"type":"Keyword","value":"a"},
|
||||
{"type":"Name","value":"a"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"/="},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"LiteralNumber","value":"2"},
|
||||
{"type":"Text","value":"\n\t"},
|
||||
{"type":"Keyword","value":"a"},
|
||||
{"type":"Name","value":"a"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"\u003c="},
|
||||
{"type":"Text","value":" "},
|
||||
@ -286,9 +286,9 @@
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"=="},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Keyword","value":"a"},
|
||||
{"type":"Name","value":"a"},
|
||||
{"type":"Text","value":"\n\t"},
|
||||
{"type":"Keyword","value":"a"},
|
||||
{"type":"Name","value":"a"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"\u003e="},
|
||||
{"type":"Text","value":" "},
|
||||
@ -297,23 +297,23 @@
|
||||
{"type":"Name","value":"nullable"},
|
||||
{"type":"Operator","value":"!!"},
|
||||
{"type":"Text","value":"\n\t"},
|
||||
{"type":"Keyword","value":"a"},
|
||||
{"type":"Name","value":"a"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"!="},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Name","value":"b"},
|
||||
{"type":"Text","value":"\n\t"},
|
||||
{"type":"Keyword","value":"a"},
|
||||
{"type":"Name","value":"a"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"||"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Name","value":"b"},
|
||||
{"type":"Text","value":"\n\t"},
|
||||
{"type":"Keyword","value":"a"},
|
||||
{"type":"Name","value":"a"},
|
||||
{"type":"Operator","value":"?."},
|
||||
{"type":"Name","value":"foo"},
|
||||
{"type":"Text","value":"\n\t"},
|
||||
{"type":"Keyword","value":"a"},
|
||||
{"type":"Name","value":"a"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"?:"},
|
||||
{"type":"Text","value":" "},
|
||||
@ -395,6 +395,15 @@
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Punctuation","value":"}"},
|
||||
{"type":"Text","value":"\n\n "},
|
||||
{"type":"Keyword","value":"if"},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"Name","value":"arg"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"!=="},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Name","value":"Boolean"},
|
||||
{"type":"Punctuation","value":")"},
|
||||
{"type":"Text","value":"\n \t"},
|
||||
{"type":"Name","value":"println"},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"Name","value":"arg"},
|
||||
|
Loading…
x
Reference in New Issue
Block a user