mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 22:02:55 +01:00
Update Python grammar to include keywords introduced in Python 3
This supports https://github.com/microsoft/monaco-editor/issues/1762. Note the new Python 3 keywords are: * `async` * `await` * `nonlocal` I also reorganized the list a bit because it seems like it contains a mixture of keywords and builtins (and `self`, which is neither...), so it is helpful to be specific to illustrate how to properly maintain the list.
This commit is contained in:
parent
618f2cff2d
commit
99f2e84186
1 changed files with 13 additions and 7 deletions
|
|
@ -55,9 +55,18 @@ export const language = <ILanguage>{
|
||||||
tokenPostfix: '.python',
|
tokenPostfix: '.python',
|
||||||
|
|
||||||
keywords: [
|
keywords: [
|
||||||
|
// This section is the result of running
|
||||||
|
// `for k in keyword.kwlist: print(' "' + k + '",')` in a Python REPL,
|
||||||
|
// though note that the output from Python 3 is not a strict superset of the
|
||||||
|
// output from Python 2.
|
||||||
|
'False', // promoted to keyword.kwlist in Python 3
|
||||||
|
'None', // promoted to keyword.kwlist in Python 3
|
||||||
|
'True', // promoted to keyword.kwlist in Python 3
|
||||||
'and',
|
'and',
|
||||||
'as',
|
'as',
|
||||||
'assert',
|
'assert',
|
||||||
|
'async', // new in Python 3
|
||||||
|
'await', // new in Python 3
|
||||||
'break',
|
'break',
|
||||||
'class',
|
'class',
|
||||||
'continue',
|
'continue',
|
||||||
|
|
@ -66,7 +75,7 @@ export const language = <ILanguage>{
|
||||||
'elif',
|
'elif',
|
||||||
'else',
|
'else',
|
||||||
'except',
|
'except',
|
||||||
'exec',
|
'exec', // Python 2, but not 3.
|
||||||
'finally',
|
'finally',
|
||||||
'for',
|
'for',
|
||||||
'from',
|
'from',
|
||||||
|
|
@ -76,14 +85,13 @@ export const language = <ILanguage>{
|
||||||
'in',
|
'in',
|
||||||
'is',
|
'is',
|
||||||
'lambda',
|
'lambda',
|
||||||
'None',
|
'nonlocal', // new in Python 3
|
||||||
'not',
|
'not',
|
||||||
'or',
|
'or',
|
||||||
'pass',
|
'pass',
|
||||||
'print',
|
'print', // Python 2, but not 3.
|
||||||
'raise',
|
'raise',
|
||||||
'return',
|
'return',
|
||||||
'self',
|
|
||||||
'try',
|
'try',
|
||||||
'while',
|
'while',
|
||||||
'with',
|
'with',
|
||||||
|
|
@ -156,6 +164,7 @@ export const language = <ILanguage>{
|
||||||
'repr',
|
'repr',
|
||||||
'reversed',
|
'reversed',
|
||||||
'round',
|
'round',
|
||||||
|
'self',
|
||||||
'set',
|
'set',
|
||||||
'setattr',
|
'setattr',
|
||||||
'slice',
|
'slice',
|
||||||
|
|
@ -172,9 +181,6 @@ export const language = <ILanguage>{
|
||||||
'xrange',
|
'xrange',
|
||||||
'zip',
|
'zip',
|
||||||
|
|
||||||
'True',
|
|
||||||
'False',
|
|
||||||
|
|
||||||
'__dict__',
|
'__dict__',
|
||||||
'__methods__',
|
'__methods__',
|
||||||
'__members__',
|
'__members__',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue