Add support for keywords from python 3.10

* Update python REPL comment to include the actual `keyword` import
* Add support for `match`, `case`, and `_` soft keywords
This commit is contained in:
soof-golan 2022-05-19 14:45:57 +03:00
parent ab869e8469
commit 20a1e0750f

View file

@ -32,7 +32,7 @@ export const conf: languages.LanguageConfiguration = {
onEnterRules: [ onEnterRules: [
{ {
beforeText: new RegExp( beforeText: new RegExp(
'^\\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async).*?:\\s*$' '^\\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async|match|case).*?:\\s*$'
), ),
action: { indentAction: languages.IndentAction.Indent } action: { indentAction: languages.IndentAction.Indent }
} }
@ -52,18 +52,21 @@ export const language = <languages.IMonarchLanguage>{
keywords: [ keywords: [
// This section is the result of running // This section is the result of running
// `for k in keyword.kwlist: print(' "' + k + '",')` in a Python REPL, // `import keyword; for k in sorted(keyword.kwlist + keyword.softkwlist): print(" '" + k + "',")`
// in a Python REPL,
// though note that the output from Python 3 is not a strict superset of the // though note that the output from Python 3 is not a strict superset of the
// output from Python 2. // output from Python 2.
'False', // promoted to keyword.kwlist in Python 3 'False', // promoted to keyword.kwlist in Python 3
'None', // promoted to keyword.kwlist in Python 3 'None', // promoted to keyword.kwlist in Python 3
'True', // promoted to keyword.kwlist in Python 3 'True', // promoted to keyword.kwlist in Python 3
'_', // new in Python 3.10
'and', 'and',
'as', 'as',
'assert', 'assert',
'async', // new in Python 3 'async', // new in Python 3
'await', // new in Python 3 'await', // new in Python 3
'break', 'break',
'case', // new in Python 3.10
'class', 'class',
'continue', 'continue',
'def', 'def',
@ -81,6 +84,7 @@ export const language = <languages.IMonarchLanguage>{
'in', 'in',
'is', 'is',
'lambda', 'lambda',
'match', // new in Python 3.10
'nonlocal', // new in Python 3 'nonlocal', // new in Python 3
'not', 'not',
'or', 'or',