Skip to content

Commit d4a6699

Browse files
[python mode] Add match/case to py3 keywords
1 parent f124e29 commit d4a6699

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

mode/python/python.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"def", "del", "elif", "else", "except", "finally",
2121
"for", "from", "global", "if", "import",
2222
"lambda", "pass", "raise", "return",
23-
"try", "while", "with", "yield", "in"];
23+
"try", "while", "with", "yield", "in", "False", "True"];
2424
var commonBuiltins = ["abs", "all", "any", "bin", "bool", "bytearray", "callable", "chr",
2525
"classmethod", "compile", "complex", "delattr", "dict", "dir", "divmod",
2626
"enumerate", "eval", "filter", "float", "format", "frozenset",
@@ -60,15 +60,15 @@
6060
if (py3) {
6161
// since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator
6262
var identifiers = parserConf.identifiers|| /^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*/;
63-
myKeywords = myKeywords.concat(["nonlocal", "False", "True", "None", "async", "await"]);
63+
myKeywords = myKeywords.concat(["nonlocal", "None", "async", "await", "match", "case"]);
6464
myBuiltins = myBuiltins.concat(["ascii", "bytes", "exec", "print"]);
6565
var stringPrefixes = new RegExp("^(([rbuf]|(br)|(rb)|(fr)|(rf))?('{3}|\"{3}|['\"]))", "i");
6666
} else {
6767
var identifiers = parserConf.identifiers|| /^[_A-Za-z][_A-Za-z0-9]*/;
6868
myKeywords = myKeywords.concat(["exec", "print"]);
6969
myBuiltins = myBuiltins.concat(["apply", "basestring", "buffer", "cmp", "coerce", "execfile",
7070
"file", "intern", "long", "raw_input", "reduce", "reload",
71-
"unichr", "unicode", "xrange", "False", "True", "None"]);
71+
"unichr", "unicode", "xrange", "None"]);
7272
var stringPrefixes = new RegExp("^(([rubf]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i");
7373
}
7474
var keywords = wordRegexp(myKeywords);

mode/python/test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,19 @@
7171
" [keyword pass]",
7272
" [keyword else]:",
7373
" [variable baz]()")
74+
75+
MT("dedentCase",
76+
"[keyword match] [variable x]:",
77+
" [keyword case] [variable y]:",
78+
" [variable foo]()")
79+
MT("dedentCasePass",
80+
"[keyword match] [variable x]:",
81+
" [keyword case] [variable y]:",
82+
" [keyword pass]")
83+
84+
MT("dedentCaseInFunction",
85+
"[keyword def] [def foo]():",
86+
" [keyword match] [variable x]:",
87+
" [keyword case] [variable y]:",
88+
" [variable foo]()")
7489
})();

0 commit comments

Comments
 (0)