[python mode] Add match/case to py3 keywords

This commit is contained in:
yoyoyodog123 2022-12-23 03:07:17 -06:00 committed by GitHub
parent f124e29923
commit d4a6699187
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 3 deletions

View File

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

View File

@ -71,4 +71,19 @@
" [keyword pass]",
" [keyword else]:",
" [variable baz]()")
MT("dedentCase",
"[keyword match] [variable x]:",
" [keyword case] [variable y]:",
" [variable foo]()")
MT("dedentCasePass",
"[keyword match] [variable x]:",
" [keyword case] [variable y]:",
" [keyword pass]")
MT("dedentCaseInFunction",
"[keyword def] [def foo]():",
" [keyword match] [variable x]:",
" [keyword case] [variable y]:",
" [variable foo]()")
})();