1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-01-28 03:29:41 +02:00

[Python]Add match and case to Keywords (#756)

This commit is contained in:
JakobDev 2023-03-03 14:14:44 +01:00 committed by GitHub
parent ecb69ce50b
commit 96a518bb94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 1 deletions

View File

@ -206,7 +206,7 @@
</rule>
</state>
<state name="keywords">
<rule pattern="(yield from|nonlocal|continue|finally|except|lambda|assert|global|return|raise|yield|while|break|await|async|pass|else|elif|with|try|for|del|as|if)\b">
<rule pattern="(yield from|nonlocal|continue|finally|except|lambda|assert|global|return|raise|yield|while|break|await|async|pass|else|elif|with|try|for|del|as|if|match|case)\b">
<token type="Keyword"/>
</rule>
<rule pattern="(False|True|None)\b">

View File

@ -0,0 +1,5 @@
var = 1
match var:
case 1:
print("Test")

View File

@ -0,0 +1,23 @@
[
{"type":"Name","value":"var"},
{"type":"Text","value":" "},
{"type":"Operator","value":"="},
{"type":"Text","value":" "},
{"type":"LiteralNumberInteger","value":"1"},
{"type":"Text","value":"\n\n"},
{"type":"Keyword","value":"match"},
{"type":"Text","value":" "},
{"type":"Name","value":"var"},
{"type":"Punctuation","value":":"},
{"type":"Text","value":"\n "},
{"type":"Keyword","value":"case"},
{"type":"Text","value":" "},
{"type":"LiteralNumberInteger","value":"1"},
{"type":"Punctuation","value":":"},
{"type":"Text","value":"\n "},
{"type":"NameBuiltin","value":"print"},
{"type":"Punctuation","value":"("},
{"type":"LiteralStringDouble","value":"\"Test\""},
{"type":"Punctuation","value":")"},
{"type":"Text","value":"\n"}
]