Skip to content

Commit

Permalink
[Python]Add match and case to Keywords (#756)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobDev committed Mar 3, 2023
1 parent ecb69ce commit 96a518b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lexers/embedded/python.xml
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
@@ -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
@@ -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"}
]

0 comments on commit 96a518b

Please sign in to comment.