mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 23:13:02 +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',
|
||||
|
||||
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',
|
||||
'as',
|
||||
'assert',
|
||||
'async', // new in Python 3
|
||||
'await', // new in Python 3
|
||||
'break',
|
||||
'class',
|
||||
'continue',
|
||||
|
|
@ -66,7 +75,7 @@ export const language = <ILanguage>{
|
|||
'elif',
|
||||
'else',
|
||||
'except',
|
||||
'exec',
|
||||
'exec', // Python 2, but not 3.
|
||||
'finally',
|
||||
'for',
|
||||
'from',
|
||||
|
|
@ -76,14 +85,13 @@ export const language = <ILanguage>{
|
|||
'in',
|
||||
'is',
|
||||
'lambda',
|
||||
'None',
|
||||
'nonlocal', // new in Python 3
|
||||
'not',
|
||||
'or',
|
||||
'pass',
|
||||
'print',
|
||||
'print', // Python 2, but not 3.
|
||||
'raise',
|
||||
'return',
|
||||
'self',
|
||||
'try',
|
||||
'while',
|
||||
'with',
|
||||
|
|
@ -156,6 +164,7 @@ export const language = <ILanguage>{
|
|||
'repr',
|
||||
'reversed',
|
||||
'round',
|
||||
'self',
|
||||
'set',
|
||||
'setattr',
|
||||
'slice',
|
||||
|
|
@ -172,9 +181,6 @@ export const language = <ILanguage>{
|
|||
'xrange',
|
||||
'zip',
|
||||
|
||||
'True',
|
||||
'False',
|
||||
|
||||
'__dict__',
|
||||
'__methods__',
|
||||
'__members__',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue