diff options
author | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-06-09 14:39:19 +0300 |
---|---|---|
committer | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-06-09 14:39:19 +0300 |
commit | c04b663c7bb4b750deeb8f48f620497ec13da8fa (patch) | |
tree | 151ebc8bfdd2ad918caf5e6e2d8013e14272ddf8 /contrib/python/Pygments/py3/pygments/lexers/javascript.py | |
parent | 0d55ca22c507d18c2f35718687e0b06d9915397b (diff) | |
download | ydb-c04b663c7bb4b750deeb8f48f620497ec13da8fa.tar.gz |
intermediate changes
ref:2d4f292087954c9344efdabb7b2a67f466263c65
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/lexers/javascript.py')
-rw-r--r-- | contrib/python/Pygments/py3/pygments/lexers/javascript.py | 327 |
1 files changed, 181 insertions, 146 deletions
diff --git a/contrib/python/Pygments/py3/pygments/lexers/javascript.py b/contrib/python/Pygments/py3/pygments/lexers/javascript.py index 7ddd1148e6f..1896fb46f6a 100644 --- a/contrib/python/Pygments/py3/pygments/lexers/javascript.py +++ b/contrib/python/Pygments/py3/pygments/lexers/javascript.py @@ -4,7 +4,7 @@ Lexers for JavaScript and related languages. - :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS. + :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ @@ -13,7 +13,7 @@ import re from pygments.lexer import bygroups, combined, default, do_insertions, include, \ inherit, Lexer, RegexLexer, this, using, words from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ - Number, Punctuation, Other, Generic + Number, Punctuation, Other, Generic, Whitespace from pygments.util import get_bool_opt import pygments.unistring as uni @@ -37,18 +37,19 @@ class JavascriptLexer(RegexLexer): """ name = 'JavaScript' + url = 'https://www.ecma-international.org/publications-and-standards/standards/ecma-262/' aliases = ['javascript', 'js'] filenames = ['*.js', '*.jsm', '*.mjs', '*.cjs'] mimetypes = ['application/javascript', 'application/x-javascript', 'text/x-javascript', 'text/javascript'] - flags = re.DOTALL | re.UNICODE | re.MULTILINE + flags = re.DOTALL | re.MULTILINE tokens = { 'commentsandwhitespace': [ - (r'\s+', Text), + (r'\s+', Whitespace), (r'<!--', Comment), - (r'//.*?\n', Comment.Single), + (r'//.*?$', Comment.Single), (r'/\*.*?\*/', Comment.Multiline) ], 'slashstartsregex': [ @@ -59,10 +60,10 @@ class JavascriptLexer(RegexLexer): default('#pop') ], 'badregex': [ - (r'\n', Text, '#pop') + (r'\n', Whitespace, '#pop') ], 'root': [ - (r'\A#! ?/.*?\n', Comment.Hashbang), # recognized by node.js + (r'\A#! ?/.*?$', Comment.Hashbang), # recognized by node.js (r'^(?=\s|/|<!--)', Text, 'slashstartsregex'), include('commentsandwhitespace'), @@ -110,7 +111,7 @@ class JavascriptLexer(RegexLexer): # Match stuff like: super(argument, list) (r'(super)(\s*)(\([\w,?.$\s]+\s*\))', - bygroups(Keyword, Text), 'slashstartsregex'), + bygroups(Keyword, Whitespace), 'slashstartsregex'), # Match stuff like: function() {...} (r'([a-zA-Z_?.$][\w?.$]*)(?=\(\) \{)', Name.Other, 'slashstartsregex'), @@ -136,12 +137,13 @@ class JavascriptLexer(RegexLexer): class TypeScriptLexer(JavascriptLexer): """ - For `TypeScript <http://typescriptlang.org/>`_ source code. + For TypeScript source code. .. versionadded:: 1.6 """ name = 'TypeScript' + url = 'https://www.typescriptlang.org/' aliases = ['typescript', 'ts'] filenames = ['*.ts'] mimetypes = ['application/x-typescript', 'text/x-typescript'] @@ -159,11 +161,11 @@ class TypeScriptLexer(JavascriptLexer): # Match variable type keywords (r'\b(string|boolean|number)\b', Keyword.Type), # Match stuff like: module name {...} - (r'\b(module)(\s*)(\s*[\w?.$][\w?.$]*)(\s*)', - bygroups(Keyword.Reserved, Text, Name.Other, Text), 'slashstartsregex'), + (r'\b(module)(\s*)([\w?.$]+)(\s*)', + bygroups(Keyword.Reserved, Whitespace, Name.Other, Whitespace), 'slashstartsregex'), # Match stuff like: (function: return type) - (r'([\w?.$][\w?.$]*)(\s*:\s*)([\w?.$][\w?.$]*)', - bygroups(Name.Other, Text, Keyword.Type)), + (r'([\w?.$]+)(\s*)(:)(\s*)([\w?.$]+)', + bygroups(Name.Other, Whitespace, Operator, Whitespace, Keyword.Type)), # Match stuff like: Decorators (r'@' + JS_IDENT, Keyword.Declaration), inherit, @@ -173,15 +175,13 @@ class TypeScriptLexer(JavascriptLexer): class KalLexer(RegexLexer): """ - For `Kal`_ source code. - - .. _Kal: http://rzimmerman.github.io/kal - + For Kal source code. .. versionadded:: 2.0 """ name = 'Kal' + url = 'http://rzimmerman.github.io/kal' aliases = ['kal'] filenames = ['*.kal'] mimetypes = ['text/kal', 'application/kal'] @@ -189,18 +189,20 @@ class KalLexer(RegexLexer): flags = re.DOTALL tokens = { 'commentsandwhitespace': [ - (r'\s+', Text), + (r'\s+', Whitespace), (r'###[^#].*?###', Comment.Multiline), - (r'#(?!##[^#]).*?\n', Comment.Single), + (r'(#(?!##[^#]).*?)(\n)', bygroups(Comment.Single, Whitespace)), ], 'functiondef': [ - (r'[$a-zA-Z_][\w$]*\s*', Name.Function, '#pop'), + (r'([$a-zA-Z_][\w$]*)(\s*)', bygroups(Name.Function, Whitespace), + '#pop'), include('commentsandwhitespace'), ], 'classdef': [ - (r'\binherits\s+from\b', Keyword), - (r'[$a-zA-Z_][\w$]*\s*\n', Name.Class, '#pop'), - (r'[$a-zA-Z_][\w$]*\s*', Name.Class), + (r'\b(inherits)(\s+)(from)\b', + bygroups(Keyword, Whitespace, Keyword)), + (r'([$a-zA-Z_][\w$]*)(?=\s*\n)', Name.Class, '#pop'), + (r'[$a-zA-Z_][\w$]*\b', Name.Class), include('commentsandwhitespace'), ], 'listcomprehension': [ @@ -209,7 +211,7 @@ class KalLexer(RegexLexer): include('root'), ], 'waitfor': [ - (r'\n', Punctuation, '#pop'), + (r'\n', Whitespace, '#pop'), (r'\bfrom\b', Keyword), include('root'), ], @@ -221,29 +223,48 @@ class KalLexer(RegexLexer): Operator), (r'\b(and|or|isnt|is|not|but|bitwise|mod|\^|xor|exists|' r'doesnt\s+exist)\b', Operator.Word), - (r'(?:\([^()]+\))?\s*>', Name.Function), + (r'(\([^()]+\))?(\s*)(>)', + bygroups(Name.Function, Whitespace, Punctuation)), (r'[{(]', Punctuation), (r'\[', Punctuation, 'listcomprehension'), (r'[})\].,]', Punctuation), (r'\b(function|method|task)\b', Keyword.Declaration, 'functiondef'), (r'\bclass\b', Keyword.Declaration, 'classdef'), - (r'\b(safe\s+)?wait\s+for\b', Keyword, 'waitfor'), + (r'\b(safe(?=\s))?(\s*)(wait(?=\s))(\s+)(for)\b', + bygroups(Keyword, Whitespace, Keyword, Whitespace, + Keyword), 'waitfor'), (r'\b(me|this)(\.[$a-zA-Z_][\w.$]*)?\b', Name.Variable.Instance), - (r'(?<![.$])(for(\s+(parallel|series))?|in|of|while|until|' - r'break|return|continue|' - r'when|if|unless|else|otherwise|except\s+when|' - r'throw|raise|fail\s+with|try|catch|finally|new|delete|' - r'typeof|instanceof|super|run\s+in\s+parallel|' - r'inherits\s+from)\b', Keyword), - (r'(?<![.$])(true|false|yes|no|on|off|null|nothing|none|' - r'NaN|Infinity|undefined)\b', - Keyword.Constant), - (r'(Array|Boolean|Date|Error|Function|Math|' - r'Number|Object|RegExp|String|decodeURI|' - r'decodeURIComponent|encodeURI|encodeURIComponent|' - r'eval|isFinite|isNaN|isSafeInteger|parseFloat|parseInt|document|' - r'window|globalThis|Symbol|print)\b', Name.Builtin), - (r'[$a-zA-Z_][\w.$]*\s*(:|[+\-*/]?\=)?\b', Name.Variable), + (r'(?<![.$])(run)(\s+)(in)(\s+)(parallel)\b', + bygroups(Keyword, Whitespace, Keyword, Whitespace, Keyword)), + (r'(?<![.$])(for)(\s+)(parallel|series)?\b', + bygroups(Keyword, Whitespace, Keyword)), + (r'(?<![.$])(except)(\s+)(when)?\b', + bygroups(Keyword, Whitespace, Keyword)), + (r'(?<![.$])(fail)(\s+)(with)?\b', + bygroups(Keyword, Whitespace, Keyword)), + (r'(?<![.$])(inherits)(\s+)(from)?\b', + bygroups(Keyword, Whitespace, Keyword)), + (r'(?<![.$])(for)(\s+)(parallel|series)?\b', + bygroups(Keyword, Whitespace, Keyword)), + (words(( + 'in', 'of', 'while', 'until', 'break', 'return', 'continue', + 'when', 'if', 'unless', 'else', 'otherwise', 'throw', 'raise', + 'try', 'catch', 'finally', 'new', 'delete', 'typeof', + 'instanceof', 'super'), prefix=r'(?<![.$])', suffix=r'\b'), + Keyword), + (words(( + 'true', 'false', 'yes', 'no', 'on', 'off', 'null', 'nothing', + 'none', 'NaN', 'Infinity', 'undefined'), prefix=r'(?<![.$])', + suffix=r'\b'), Keyword.Constant), + (words(( + 'Array', 'Boolean', 'Date', 'Error', 'Function', 'Math', + 'Number', 'Object', 'RegExp', 'String', 'decodeURI', + 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'eval', + 'isFinite', 'isNaN', 'isSafeInteger', 'parseFloat', 'parseInt', + 'document', 'window', 'globalThis', 'Symbol', 'print'), + suffix=r'\b'), Name.Builtin), + (r'([$a-zA-Z_][\w.$]*)(\s*)(:|[+\-*/]?\=)?\b', + bygroups(Name.Variable, Whitespace, Operator)), (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), (r'0x[0-9a-fA-F]+', Number.Hex), (r'[0-9]+', Number.Integer), @@ -288,14 +309,13 @@ class KalLexer(RegexLexer): class LiveScriptLexer(RegexLexer): """ - For `LiveScript`_ source code. - - .. _LiveScript: https://livescript.net/ + For LiveScript source code. .. versionadded:: 1.6 """ name = 'LiveScript' + url = 'https://livescript.net/' aliases = ['livescript', 'live-script'] filenames = ['*.ls'] mimetypes = ['text/livescript'] @@ -303,9 +323,9 @@ class LiveScriptLexer(RegexLexer): flags = re.DOTALL tokens = { 'commentsandwhitespace': [ - (r'\s+', Text), + (r'\s+', Whitespace), (r'/\*.*?\*/', Comment.Multiline), - (r'#.*?\n', Comment.Single), + (r'(#.*?)(\n)', bygroups(Comment.Single, Whitespace)), ], 'multilineregex': [ include('commentsandwhitespace'), @@ -346,10 +366,13 @@ class LiveScriptLexer(RegexLexer): r'decodeURIComponent|encodeURI|encodeURIComponent|' r'eval|isFinite|isNaN|parseFloat|parseInt|document|window|' r'globalThis|Symbol|Symbol|BigInt)\b', Name.Builtin), - (r'[$a-zA-Z_][\w.\-:$]*\s*[:=]\s', Name.Variable, - 'slashstartsregex'), - (r'@[$a-zA-Z_][\w.\-:$]*\s*[:=]\s', Name.Variable.Instance, - 'slashstartsregex'), + (r'([$a-zA-Z_][\w.\-:$]*)(\s*)([:=])(\s+)', + bygroups(Name.Variable, Whitespace, Operator, Whitespace), + 'slashstartsregex'), + (r'(@[$a-zA-Z_][\w.\-:$]*)(\s*)([:=])(\s+)', + bygroups(Name.Variable.Instance, Whitespace, Operator, + Whitespace), + 'slashstartsregex'), (r'@', Name.Other, 'slashstartsregex'), (r'@?[$a-zA-Z_][\w-]*', Name.Other, 'slashstartsregex'), (r'[0-9]+\.[0-9]+([eE][0-9]+)?[fd]?(?:[a-zA-Z_]+)?', Number.Float), @@ -399,12 +422,13 @@ class LiveScriptLexer(RegexLexer): class DartLexer(RegexLexer): """ - For `Dart <http://dart.dev/>`_ source code. + For Dart source code. .. versionadded:: 1.5 """ name = 'Dart' + url = 'http://dart.dev/' aliases = ['dart'] filenames = ['*.dart'] mimetypes = ['text/x-dart'] @@ -417,11 +441,11 @@ class DartLexer(RegexLexer): (r'#!(.*?)$', Comment.Preproc), (r'\b(import|export)\b', Keyword, 'import_decl'), (r'\b(library|source|part of|part)\b', Keyword), - (r'[^\S\n]+', Text), - (r'//.*?\n', Comment.Single), + (r'[^\S\n]+', Whitespace), + (r'(//.*?)(\n)', bygroups(Comment.Single, Whitespace)), (r'/\*.*?\*/', Comment.Multiline), (r'\b(class|extension|mixin)\b(\s+)', - bygroups(Keyword.Declaration, Text), 'class'), + bygroups(Keyword.Declaration, Whitespace), 'class'), (r'\b(as|assert|break|case|catch|const|continue|default|do|else|finally|' r'for|if|in|is|new|rethrow|return|super|switch|this|throw|try|while)\b', Keyword), @@ -440,7 +464,7 @@ class DartLexer(RegexLexer): # DIGIT+ (‘.’ DIGIT*)? EXPONENT? (r'\d+(\.\d*)?([eE][+-]?\d+)?', Number), (r'\.\d+([eE][+-]?\d+)?', Number), # ‘.’ DIGIT+ EXPONENT? - (r'\n', Text) + (r'\n', Whitespace) # pseudo-keyword negate intentionally left out ], 'class': [ @@ -448,7 +472,7 @@ class DartLexer(RegexLexer): ], 'import_decl': [ include('string_literal'), - (r'\s+', Text), + (r'\s+', Whitespace), (r'\b(as|deferred|show|hide)\b', Keyword), (r'[a-zA-Z_$]\w*', Name), (r'\,', Punctuation), @@ -502,7 +526,7 @@ class DartLexer(RegexLexer): class LassoLexer(RegexLexer): """ - For `Lasso <http://www.lassosoft.com/>`_ source code, covering both Lasso 9 + For Lasso source code, covering both Lasso 9 syntax and LassoScript for Lasso 8.6 and earlier. For Lasso embedded in HTML, use the `LassoHtmlLexer`. @@ -529,7 +553,7 @@ class LassoLexer(RegexLexer): 'root': [ (r'^#![ \S]+lasso9\b', Comment.Preproc, 'lasso'), (r'(?=\[|<)', Other, 'delimiters'), - (r'\s+', Other), + (r'\s+', Whitespace), default(('delimiters', 'lassofile')), ], 'delimiters': [ @@ -565,8 +589,8 @@ class LassoLexer(RegexLexer): include('lasso'), ], 'whitespacecomments': [ - (r'\s+', Text), - (r'//.*?\n', Comment.Single), + (r'\s+', Whitespace), + (r'(//.*?)(\s*)$', bygroups(Comment.Single, Whitespace)), (r'/\*\*!.*?\*/', String.Doc), (r'/\*.*?\*/', Comment.Multiline), ], @@ -586,18 +610,20 @@ class LassoLexer(RegexLexer): # names (r'\$[a-z_][\w.]*', Name.Variable), (r'#([a-z_][\w.]*|\d+\b)', Name.Variable.Instance), - (r"(\.\s*)('[a-z_][\w.]*')", - bygroups(Name.Builtin.Pseudo, Name.Variable.Class)), - (r"(self)(\s*->\s*)('[a-z_][\w.]*')", - bygroups(Name.Builtin.Pseudo, Operator, Name.Variable.Class)), - (r'(\.\.?\s*)([a-z_][\w.]*(=(?!=))?)', - bygroups(Name.Builtin.Pseudo, Name.Other.Member)), - (r'(->\\?\s*|&\s*)([a-z_][\w.]*(=(?!=))?)', - bygroups(Operator, Name.Other.Member)), + (r"(\.)(\s*)('[a-z_][\w.]*')", + bygroups(Name.Builtin.Pseudo, Whitespace, Name.Variable.Class)), + (r"(self)(\s*)(->)(\s*)('[a-z_][\w.]*')", + bygroups(Name.Builtin.Pseudo, Whitespace, Operator, Whitespace, + Name.Variable.Class)), + (r'(\.\.?)(\s*)([a-z_][\w.]*(=(?!=))?)', + bygroups(Name.Builtin.Pseudo, Whitespace, Name.Other.Member)), + (r'(->\\?|&)(\s*)([a-z_][\w.]*(=(?!=))?)', + bygroups(Operator, Whitespace, Name.Other.Member)), (r'(?<!->)(self|inherited|currentcapture|givenblock)\b', Name.Builtin.Pseudo), (r'-(?!infinity)[a-z_][\w.]*', Name.Attribute), - (r'::\s*[a-z_][\w.]*', Name.Label), + (r'(::)(\s*)([a-z_][\w.]*)', + bygroups(Punctuation, Whitespace, Name.Label)), (r'(error_(code|msg)_\w+|Error_AddError|Error_ColumnRestriction|' r'Error_DatabaseConnectionUnavailable|Error_DatabaseTimeout|' r'Error_DeleteError|Error_FieldRestriction|Error_FileNotFound|' @@ -609,18 +635,20 @@ class LassoLexer(RegexLexer): r'Error_UpdateError)\b', Name.Exception), # definitions - (r'(define)(\s+)([a-z_][\w.]*)(\s*=>\s*)(type|trait|thread)\b', - bygroups(Keyword.Declaration, Text, Name.Class, Operator, Keyword)), - (r'(define)(\s+)([a-z_][\w.]*)(\s*->\s*)([a-z_][\w.]*=?|[-+*/%])', - bygroups(Keyword.Declaration, Text, Name.Class, Operator, - Name.Function), 'signature'), + (r'(define)(\s+)([a-z_][\w.]*)(\s*)(=>)(\s*)(type|trait|thread)\b', + bygroups(Keyword.Declaration, Whitespace, Name.Class, + Whitespace, Operator, Whitespace, Keyword)), + (r'(define)(\s+)([a-z_][\w.]*)(\s*)(->)(\s*)([a-z_][\w.]*=?|[-+*/%])', + bygroups(Keyword.Declaration, Whitespace, Name.Class, + Whitespace, Operator, Whitespace, Name.Function), + 'signature'), (r'(define)(\s+)([a-z_][\w.]*)', - bygroups(Keyword.Declaration, Text, Name.Function), 'signature'), + bygroups(Keyword.Declaration, Whitespace, Name.Function), 'signature'), (r'(public|protected|private|provide)(\s+)(([a-z_][\w.]*=?|[-+*/%])' - r'(?=\s*\())', bygroups(Keyword, Text, Name.Function), + r'(?=\s*\())', bygroups(Keyword, Whitespace, Name.Function), 'signature'), (r'(public|protected|private|provide)(\s+)([a-z_][\w.]*)', - bygroups(Keyword, Text, Name.Function)), + bygroups(Keyword, Whitespace, Name.Function)), # keywords (r'(true|false|none|minimal|full|all|void)\b', Keyword.Constant), @@ -628,8 +656,8 @@ class LassoLexer(RegexLexer): (r'(array|date|decimal|duration|integer|map|pair|string|tag|xml|' r'null|boolean|bytes|keyword|list|locale|queue|set|stack|' r'staticarray)\b', Keyword.Type), - (r'([a-z_][\w.]*)(\s+)(in)\b', bygroups(Name, Text, Keyword)), - (r'(let|into)(\s+)([a-z_][\w.]*)', bygroups(Keyword, Text, Name)), + (r'([a-z_][\w.]*)(\s+)(in)\b', bygroups(Name, Whitespace, Keyword)), + (r'(let|into)(\s+)([a-z_][\w.]*)', bygroups(Keyword, Whitespace, Name)), (r'require\b', Keyword, 'requiresection'), (r'(/?)(Namespace_Using)\b', bygroups(Punctuation, Keyword.Namespace)), (r'(/?)(Cache|Database_Names|Database_SchemaNames|' @@ -655,8 +683,9 @@ class LassoLexer(RegexLexer): # other (r',', Punctuation, 'commamember'), (r'(and|or|not)\b', Operator.Word), - (r'([a-z_][\w.]*)(\s*::\s*[a-z_][\w.]*)?(\s*=(?!=))', - bygroups(Name, Name.Label, Operator)), + (r'([a-z_][\w.]*)(\s*)(::)(\s*)([a-z_][\w.]*)?(\s*=(?!=))', + bygroups(Name, Whitespace, Punctuation, Whitespace, Name.Label, + Operator)), (r'(/?)([\w.]+)', bygroups(Punctuation, Name.Other)), (r'(=)(n?bw|n?ew|n?cn|lte?|gte?|n?eq|n?rx|ft)\b', bygroups(Operator, Operator.Word)), @@ -695,7 +724,8 @@ class LassoLexer(RegexLexer): (r'(([a-z_][\w.]*=?|[-+*/%])(?=\s*\())', Name, 'requiresignature'), (r'(([a-z_][\w.]*=?|[-+*/%])(?=(\s*::\s*[\w.]+)?\s*,))', Name), (r'[a-z_][\w.]*=?|[-+*/%]', Name, '#pop'), - (r'::\s*[a-z_][\w.]*', Name.Label), + (r'(::)(\s*)([a-z_][\w.]*)', + bygroups(Punctuation, Whitespace, Name.Label)), (r',', Punctuation), include('whitespacecomments'), ], @@ -703,7 +733,8 @@ class LassoLexer(RegexLexer): (r'(\)(?=(\s*::\s*[\w.]+)?\s*,))', Punctuation, '#pop'), (r'\)', Punctuation, '#pop:2'), (r'-?[a-z_][\w.]*', Name.Attribute), - (r'::\s*[a-z_][\w.]*', Name.Label), + (r'(::)(\s*)([a-z_][\w.]*)', + bygroups(Punctuation, Whitespace, Name.Label)), (r'\.\.\.', Name.Builtin.Pseudo), (r'[(,]', Punctuation), include('whitespacecomments'), @@ -784,11 +815,11 @@ class ObjectiveJLexer(RegexLexer): using(this))), # class definition - (r'(@interface|@implementation)(\s+)', bygroups(Keyword, Text), + (r'(@interface|@implementation)(\s+)', bygroups(Keyword, Whitespace), 'classname'), - (r'(@class|@protocol)(\s*)', bygroups(Keyword, Text), + (r'(@class|@protocol)(\s*)', bygroups(Keyword, Whitespace), 'forward_classname'), - (r'(\s*)(@end)(\s*)', bygroups(Text, Keyword, Text)), + (r'(\s*)(@end)(\s*)', bygroups(Whitespace, Keyword, Whitespace)), include('statements'), ('[{()}]', Punctuation), @@ -796,20 +827,20 @@ class ObjectiveJLexer(RegexLexer): ], 'whitespace': [ (r'(@import)(\s+)("(?:\\\\|\\"|[^"])*")', - bygroups(Comment.Preproc, Text, String.Double)), + bygroups(Comment.Preproc, Whitespace, String.Double)), (r'(@import)(\s+)(<(?:\\\\|\\>|[^>])*>)', - bygroups(Comment.Preproc, Text, String.Double)), + bygroups(Comment.Preproc, Whitespace, String.Double)), (r'(#(?:include|import))(\s+)("(?:\\\\|\\"|[^"])*")', - bygroups(Comment.Preproc, Text, String.Double)), + bygroups(Comment.Preproc, Whitespace, String.Double)), (r'(#(?:include|import))(\s+)(<(?:\\\\|\\>|[^>])*>)', - bygroups(Comment.Preproc, Text, String.Double)), + bygroups(Comment.Preproc, Whitespace, String.Double)), (r'#if\s+0', Comment.Preproc, 'if0'), (r'#', Comment.Preproc, 'macro'), - (r'\n', Text), - (r'\s+', Text), - (r'\\\n', Text), # line continuation + (r'\s+', Whitespace), + (r'(\\)(\n)', + bygroups(String.Escape, Whitespace)), # line continuation (r'//(\n|(.|\n)*?[^\\]\n)', Comment.Single), (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline), (r'<!--', Comment), @@ -822,7 +853,7 @@ class ObjectiveJLexer(RegexLexer): default('#pop'), ], 'badregex': [ - (r'\n', Text, '#pop'), + (r'\n', Whitespace, '#pop'), ], 'statements': [ (r'(L|@)?"', String, 'string'), @@ -889,10 +920,10 @@ class ObjectiveJLexer(RegexLexer): (r'([a-zA-Z_]\w*)', Name.Class, '#pop'), ], 'forward_classname': [ - (r'([a-zA-Z_]\w*)(\s*,\s*)', - bygroups(Name.Class, Text), '#push'), - (r'([a-zA-Z_]\w*)(\s*;?)', - bygroups(Name.Class, Text), '#pop'), + (r'([a-zA-Z_]\w*)(\s*)(,)(\s*)', + bygroups(Name.Class, Whitespace, Text, Whitespace), '#push'), + (r'([a-zA-Z_]\w*)(\s*)(;?)', + bygroups(Name.Class, Whitespace, Text), '#pop'), ], 'function_signature': [ include('whitespace'), @@ -955,21 +986,21 @@ class ObjectiveJLexer(RegexLexer): (r'"', String, '#pop'), (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape), (r'[^\\"\n]+', String), # all other characters - (r'\\\n', String), # line continuation + (r'(\\)(\n)', bygroups(String.Escape, Whitespace)), # line continuation (r'\\', String), # stray backslash ], 'macro': [ (r'[^/\n]+', Comment.Preproc), (r'/[*](.|\n)*?[*]/', Comment.Multiline), - (r'//.*?\n', Comment.Single, '#pop'), + (r'(//.*?)(\n)', bygroups(Comment.Single, Whitespace), '#pop'), (r'/', Comment.Preproc), - (r'(?<=\\)\n', Comment.Preproc), - (r'\n', Comment.Preproc, '#pop'), + (r'(?<=\\)\n', Whitespace), + (r'\n', Whitespace, '#pop'), ], 'if0': [ (r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'), (r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'), - (r'.*?\n', Comment), + (r'(.*?)(\n)', bygroups(Comment, Whitespace)), ] } @@ -982,14 +1013,13 @@ class ObjectiveJLexer(RegexLexer): class CoffeeScriptLexer(RegexLexer): """ - For `CoffeeScript`_ source code. - - .. _CoffeeScript: http://coffeescript.org + For CoffeeScript source code. .. versionadded:: 1.3 """ name = 'CoffeeScript' + url = 'http://coffeescript.org' aliases = ['coffeescript', 'coffee-script', 'coffee'] filenames = ['*.coffee'] mimetypes = ['text/coffeescript'] @@ -1002,9 +1032,9 @@ class CoffeeScriptLexer(RegexLexer): flags = re.DOTALL tokens = { 'commentsandwhitespace': [ - (r'\s+', Text), + (r'\s+', Whitespace), (r'###[^#].*?###', Comment.Multiline), - (r'#(?!##[^#]).*?\n', Comment.Single), + (r'(#(?!##[^#]).*?)(\n)', bygroups(Comment.Single, Whitespace)), ], 'multilineregex': [ (r'[^/#]+', String.Regex), @@ -1043,10 +1073,12 @@ class CoffeeScriptLexer(RegexLexer): r'decodeURIComponent|encodeURI|encodeURIComponent|' r'eval|isFinite|isNaN|parseFloat|parseInt|document|window|globalThis|Symbol)\b', Name.Builtin), - (r'[$a-zA-Z_][\w.:$]*\s*[:=]\s', Name.Variable, - 'slashstartsregex'), - (r'@[$a-zA-Z_][\w.:$]*\s*[:=]\s', Name.Variable.Instance, - 'slashstartsregex'), + (r'([$a-zA-Z_][\w.:$]*)(\s*)([:=])(\s+)', + bygroups(Name.Variable, Whitespace, Operator, Whitespace), + 'slashstartsregex'), + (r'(@[$a-zA-Z_][\w.:$]*)(\s*)([:=])(\s+)', + bygroups(Name.Variable.Instance, Whitespace, Operator, Whitespace), + 'slashstartsregex'), (r'@', Name.Other, 'slashstartsregex'), (r'@?[$a-zA-Z_][\w$]*', Name.Other), (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), @@ -1095,11 +1127,12 @@ class CoffeeScriptLexer(RegexLexer): class MaskLexer(RegexLexer): """ - For `Mask <https://github.com/atmajs/MaskJS>`__ markup. + For Mask markup. .. versionadded:: 2.0 """ name = 'Mask' + url = 'https://github.com/atmajs/MaskJS' aliases = ['mask'] filenames = ['*.mask'] mimetypes = ['text/x-mask'] @@ -1107,8 +1140,8 @@ class MaskLexer(RegexLexer): flags = re.MULTILINE | re.IGNORECASE | re.DOTALL tokens = { 'root': [ - (r'\s+', Text), - (r'//.*?\n', Comment.Single), + (r'\s+', Whitespace), + (r'(//.*?)(\n)', bygroups(Comment.Single, Whitespace)), (r'/\*.*?\*/', Comment.Multiline), (r'[{};>]', Punctuation), (r"'''", String, 'string-trpl-single'), @@ -1143,19 +1176,23 @@ class MaskLexer(RegexLexer): ], 'interpolation': [ (r'\]', String.Interpol, '#pop'), - (r'\s*:', String.Interpol, 'expression'), - (r'\s*\w+:', Name.Other), + (r'(\s*)(:)', bygroups(Whitespace, String.Interpol), 'expression'), + (r'(\s*)(\w+)(:)', bygroups(Whitespace, Name.Other, Punctuation)), (r'[^\]]+', String.Interpol) ], 'expression': [ (r'[^\]]+', using(JavascriptLexer), '#pop') ], 'node': [ - (r'\s+', Text), + (r'\s+', Whitespace), (r'\.', Name.Variable.Class, 'node-class'), (r'\#', Name.Function, 'node-id'), - (r'style[ \t]*=', Name.Attribute, 'node-attr-style-value'), - (r'[\w:-]+[ \t]*=', Name.Attribute, 'node-attr-value'), + (r'(style)([ \t]*)(=)', + bygroups(Name.Attribute, Whitespace, Operator), + 'node-attr-style-value'), + (r'([\w:-]+)([ \t]*)(=)', + bygroups(Name.Attribute, Whitespace, Operator), + 'node-attr-value'), (r'[\w:-]+', Name.Attribute), (r'[>{;]', Punctuation, '#pop') ], @@ -1170,20 +1207,20 @@ class MaskLexer(RegexLexer): default('#pop') ], 'node-attr-value': [ - (r'\s+', Text), + (r'\s+', Whitespace), (r'\w+', Name.Variable, '#pop'), (r"'", String, 'string-single-pop2'), (r'"', String, 'string-double-pop2'), default('#pop') ], 'node-attr-style-value': [ - (r'\s+', Text), + (r'\s+', Whitespace), (r"'", String.Single, 'css-single-end'), (r'"', String.Single, 'css-double-end'), include('node-attr-value') ], 'css-base': [ - (r'\s+', Text), + (r'\s+', Whitespace), (r";", Punctuation), (r"[\w\-]+\s*:", Name.Builtin) ], @@ -1210,9 +1247,7 @@ class MaskLexer(RegexLexer): class EarlGreyLexer(RegexLexer): """ - For `Earl-Grey`_ source code. - - .. _Earl-Grey: https://breuleux.github.io/earl-grey/ + For Earl-Grey source code. .. versionadded: 2.1 """ @@ -1224,12 +1259,12 @@ class EarlGreyLexer(RegexLexer): tokens = { 'root': [ - (r'\n', Text), + (r'\n', Whitespace), include('control'), (r'[^\S\n]+', Text), - (r';;.*\n', Comment), + (r'(;;.*)(\n)', bygroups(Comment, Whitespace)), (r'[\[\]{}:(),;]', Punctuation), - (r'\\\n', Text), + (r'(\\)(\n)', bygroups(String.Escape, Whitespace)), (r'\\', Text), include('errors'), (words(( @@ -1268,7 +1303,7 @@ class EarlGreyLexer(RegexLexer): bygroups(Punctuation, Name.Class.DBS)), (r'(\[)([\^#][a-zA-Z$_](?:[\w$\-]*[\w$])?)(\])', bygroups(Punctuation, Name.Entity.DBS, Punctuation)), - (r'\s+', Text), + (r'\s+', Whitespace), (r'%', Operator.DBS, '#pop'), ], 'import_paths': [ @@ -1298,8 +1333,8 @@ class EarlGreyLexer(RegexLexer): (?!and|as|each\*|each|in|is|mod|of|or|when|where|with) (?=(?:[+\-*/~^<>%&|?!@#.])?[a-zA-Z$_](?:[\w$-]*[\w$])?)''', Keyword.Control), - (r'([a-zA-Z$_](?:[\w$-]*[\w$])?)(?!\n)\s+(?=[\'"\d{\[(])', - Keyword.Control), + (r'([a-zA-Z$_](?:[\w$-]*[\w$])?)(?!\n)(\s+)(?=[\'"\d{\[(])', + bygroups(Keyword.Control, Whitespace)), (r'''(?x) (?: (?<=[%=])| @@ -1308,11 +1343,11 @@ class EarlGreyLexer(RegexLexer): (?<=each\*|where) )(\s+) ([a-zA-Z$_](?:[\w$-]*[\w$])?)(:)''', - bygroups(Text, Keyword.Control, Punctuation)), + bygroups(Whitespace, Keyword.Control, Punctuation)), (r'''(?x) (?<![+\-*/~^<>%&|?!@#.])(\s+) ([a-zA-Z$_](?:[\w$-]*[\w$])?)(:)''', - bygroups(Text, Keyword.Control, Punctuation)), + bygroups(Whitespace, Keyword.Control, Punctuation)), ], 'nested': [ (r'''(?x) @@ -1426,25 +1461,24 @@ class EarlGreyLexer(RegexLexer): class JuttleLexer(RegexLexer): """ - For `Juttle`_ source code. - - .. _Juttle: https://github.com/juttle/juttle + For Juttle source code. .. versionadded:: 2.2 """ name = 'Juttle' + url = 'http://juttle.github.io/' aliases = ['juttle'] filenames = ['*.juttle'] mimetypes = ['application/juttle', 'application/x-juttle', 'text/x-juttle', 'text/juttle'] - flags = re.DOTALL | re.UNICODE | re.MULTILINE + flags = re.DOTALL | re.MULTILINE tokens = { 'commentsandwhitespace': [ - (r'\s+', Text), - (r'//.*?\n', Comment.Single), + (r'\s+', Whitespace), + (r'(//.*?)(\n)', bygroups(Comment.Single, Whitespace)), (r'/\*.*?\*/', Comment.Multiline) ], 'slashstartsregex': [ @@ -1525,8 +1559,9 @@ class NodeConsoleLexer(Lexer): for match in line_re.finditer(text): line = match.group() if line.startswith('> '): - insertions.append((len(curcode), - [(0, Generic.Prompt, line[:2])])) + insertions.append((len(curcode), + [(0, Generic.Prompt, line[:1]), + (1, Whitespace, line[1:2])])) curcode += line[2:] elif line.startswith('...'): @@ -1534,21 +1569,21 @@ class NodeConsoleLexer(Lexer): code = line.lstrip('.') lead = len(line) - len(code) - insertions.append((len(curcode), + insertions.append((len(curcode), [(0, Generic.Prompt, line[:lead])])) curcode += code else: if curcode: - yield from do_insertions(insertions, + yield from do_insertions(insertions, jslexer.get_tokens_unprocessed(curcode)) curcode = '' insertions = [] - yield from do_insertions([], + yield from do_insertions([], jslexer.get_tokens_unprocessed(line)) if curcode: - yield from do_insertions(insertions, + yield from do_insertions(insertions, jslexer.get_tokens_unprocessed(curcode)) |