Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Python]Add match and case to Keywords
  • Loading branch information
JakobDev authored Mar 3, 2023
commit fd0312ca703c6bb58610a9223d64aff2c073689e
2 changes: 1 addition & 1 deletion lexers/embedded/python.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var = 1

match var:
case 1:
print("Test")
23 changes: 23 additions & 0 deletions lexers/testdata/python/test_structural_pattern_matching.expected
Original file line number Diff line number Diff line change
@@ -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"}
]