From 00b1e3f916ed752682b2fb5d91dca9c17e9b9e32 Mon Sep 17 00:00:00 2001 From: Mestery <48163546+Mesteery@users.noreply.github.com> Date: Mon, 28 Dec 2020 23:30:32 +0100 Subject: [PATCH] Update keywords for JS and its variants Some of the keywords are missing for JavaScript and TypeScript. And some of reserved keywords have been moved to `keywords` and `declarations keywords`. There are also non-existent builtins that I removed. Added missing builtins. --- pygments/lexers/javascript.py | 68 +++++++++++++++++------------------ 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/pygments/lexers/javascript.py b/pygments/lexers/javascript.py index 92d6052ea5..7f8a08f879 100644 --- a/pygments/lexers/javascript.py +++ b/pygments/lexers/javascript.py @@ -67,7 +67,7 @@ class JavascriptLexer(RegexLexer): # Numeric literals (r'0[bB][01]+n?', Number.Bin), - (r'0[oO]?[0-7]+n?', Number.Oct), # Browsers support "0o7" and "07" notations + (r'0[oO]?[0-7]+n?', Number.Oct), # Browsers support "0o7" and "07" (< ES5) notations (r'0[xX][0-9a-fA-F]+n?', Number.Hex), (r'[0-9]+n', Number.Integer), # Javascript BigInt requires an "n" postfix # Javascript doesn't have actual integer literals, so every other @@ -82,18 +82,17 @@ class JavascriptLexer(RegexLexer): (r'[})\].]', Punctuation), (r'(for|in|while|do|break|return|continue|switch|case|default|if|else|' r'throw|try|catch|finally|new|delete|typeof|instanceof|void|yield|await|async|' - r'this|of)\b', Keyword, 'slashstartsregex'), - (r'(var|let|with|function)\b', Keyword.Declaration, 'slashstartsregex'), - (r'(abstract|boolean|byte|char|class|const|debugger|double|enum|export|' - r'extends|final|float|goto|implements|import|int|interface|long|native|' - r'package|private|protected|public|short|static|super|synchronized|throws|' - r'transient|volatile)\b', Keyword.Reserved), + r'this|of|static|export|import|debugger|extends|super)\b', Keyword, 'slashstartsregex'), + (r'(var|let|const|with|function|class)\b', Keyword.Declaration, 'slashstartsregex'), + (r'(abstract|boolean|byte|char|double|enum|final|float|goto' + r'implements|int|interface|long|native|package|private|protected' + r'public|short|synchronized|throws|transient|volatile)\b', Keyword.Reserved), (r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant), - (r'(Array|Boolean|Date|Error|Function|Math|netscape|' - r'Number|Object|Packages|RegExp|String|Promise|Proxy|sun|decodeURI|' + (r'(Array|Boolean|Date|BigInt|Error|Function|Math|' + r'Number|Object|RegExp|String|Promise|Proxy|decodeURI|' r'decodeURIComponent|encodeURI|encodeURIComponent|' r'Error|eval|isFinite|isNaN|isSafeInteger|parseFloat|parseInt|' - r'document|this|window)\b', Name.Builtin), + r'document|this|window|globalThis|Symbol)\b', Name.Builtin), (JS_IDENT, Name.Other), (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double), (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single), @@ -182,11 +181,11 @@ class KalLexer(RegexLexer): (r'(?