diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-05-20 07:58:40 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-05-20 08:05:00 +0300 |
commit | bcd5bcc390793791d293d386b2ebefbe683fb4e1 (patch) | |
tree | c93e3b8c847237e7e7626f4a07f1b657bb34f04d /contrib/python/Pygments/py3/pygments/lexers/basic.py | |
parent | 1a9f1508fe9c8c5927ffebf33197a6108e70501d (diff) | |
download | ydb-bcd5bcc390793791d293d386b2ebefbe683fb4e1.tar.gz |
Intermediate changes
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/lexers/basic.py')
-rw-r--r-- | contrib/python/Pygments/py3/pygments/lexers/basic.py | 105 |
1 files changed, 48 insertions, 57 deletions
diff --git a/contrib/python/Pygments/py3/pygments/lexers/basic.py b/contrib/python/Pygments/py3/pygments/lexers/basic.py index 8837dacbae..9cfdf46228 100644 --- a/contrib/python/Pygments/py3/pygments/lexers/basic.py +++ b/contrib/python/Pygments/py3/pygments/lexers/basic.py @@ -4,7 +4,7 @@ Lexers for BASIC like languages (other than VB.net). - :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS. + :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ @@ -23,8 +23,6 @@ __all__ = ['BlitzBasicLexer', 'BlitzMaxLexer', 'MonkeyLexer', 'CbmBasicV2Lexer', class BlitzMaxLexer(RegexLexer): """ For BlitzMax source code. - - .. versionadded:: 1.4 """ name = 'BlitzMax' @@ -32,14 +30,14 @@ class BlitzMaxLexer(RegexLexer): aliases = ['blitzmax', 'bmax'] filenames = ['*.bmx'] mimetypes = ['text/x-bmx'] + version_added = '1.4' bmax_vopwords = r'\b(Shl|Shr|Sar|Mod)\b' bmax_sktypes = r'@{1,2}|[!#$%]' bmax_lktypes = r'\b(Int|Byte|Short|Float|Double|Long)\b' bmax_name = r'[a-z_]\w*' - bmax_var = (r'(%s)(?:(?:([ \t]*)(%s)|([ \t]*:[ \t]*\b(?:Shl|Shr|Sar|Mod)\b)' - r'|([ \t]*)(:)([ \t]*)(?:%s|(%s)))(?:([ \t]*)(Ptr))?)') % \ - (bmax_name, bmax_sktypes, bmax_lktypes, bmax_name) + bmax_var = (rf'({bmax_name})(?:(?:([ \t]*)({bmax_sktypes})|([ \t]*:[ \t]*\b(?:Shl|Shr|Sar|Mod)\b)' + rf'|([ \t]*)(:)([ \t]*)(?:{bmax_lktypes}|({bmax_name})))(?:([ \t]*)(Ptr))?)') bmax_func = bmax_var + r'?((?:[ \t]|\.\.\n)*)([(])' flags = re.MULTILINE | re.IGNORECASE @@ -60,16 +58,14 @@ class BlitzMaxLexer(RegexLexer): (r'\$[0-9a-f]+', Number.Hex), (r'\%[10]+', Number.Bin), # Other - (r'(?:(?:(:)?([ \t]*)(:?%s|([+\-*/&|~]))|Or|And|Not|[=<>^]))' % - (bmax_vopwords), Operator), + (rf'(?:(?:(:)?([ \t]*)(:?{bmax_vopwords}|([+\-*/&|~]))|Or|And|Not|[=<>^]))', Operator), (r'[(),.:\[\]]', Punctuation), (r'(?:#[\w \t]*)', Name.Label), (r'(?:\?[\w \t]*)', Comment.Preproc), # Identifiers - (r'\b(New)\b([ \t]?)([(]?)(%s)' % (bmax_name), + (rf'\b(New)\b([ \t]?)([(]?)({bmax_name})', bygroups(Keyword.Reserved, Whitespace, Punctuation, Name.Class)), - (r'\b(Import|Framework|Module)([ \t]+)(%s\.%s)' % - (bmax_name, bmax_name), + (rf'\b(Import|Framework|Module)([ \t]+)({bmax_name}\.{bmax_name})', bygroups(Keyword.Reserved, Whitespace, Keyword.Namespace)), (bmax_func, bygroups(Name.Function, Whitespace, Keyword.Type, Operator, Whitespace, Punctuation, Whitespace, @@ -78,7 +74,7 @@ class BlitzMaxLexer(RegexLexer): (bmax_var, bygroups(Name.Variable, Whitespace, Keyword.Type, Operator, Whitespace, Punctuation, Whitespace, Keyword.Type, Name.Class, Whitespace, Keyword.Type)), - (r'\b(Type|Extends)([ \t]+)(%s)' % (bmax_name), + (rf'\b(Type|Extends)([ \t]+)({bmax_name})', bygroups(Keyword.Reserved, Whitespace, Name.Class)), # Keywords (r'\b(Ptr)\b', Keyword.Type), @@ -102,7 +98,7 @@ class BlitzMaxLexer(RegexLexer): 'RestoreData'), prefix=r'\b', suffix=r'\b'), Keyword.Reserved), # Final resolve (for variable names and such) - (r'(%s)' % (bmax_name), Name.Variable), + (rf'({bmax_name})', Name.Variable), ], 'string': [ (r'""', String.Double), @@ -115,8 +111,6 @@ class BlitzMaxLexer(RegexLexer): class BlitzBasicLexer(RegexLexer): """ For BlitzBasic source code. - - .. versionadded:: 2.0 """ name = 'BlitzBasic' @@ -124,11 +118,11 @@ class BlitzBasicLexer(RegexLexer): aliases = ['blitzbasic', 'b3d', 'bplus'] filenames = ['*.bb', '*.decls'] mimetypes = ['text/x-bb'] + version_added = '2.0' bb_sktypes = r'@{1,2}|[#$%]' bb_name = r'[a-z]\w*' - bb_var = (r'(%s)(?:([ \t]*)(%s)|([ \t]*)([.])([ \t]*)(?:(%s)))?') % \ - (bb_name, bb_sktypes, bb_name) + bb_var = (rf'({bb_name})(?:([ \t]*)({bb_sktypes})|([ \t]*)([.])([ \t]*)(?:({bb_name})))?') flags = re.MULTILINE | re.IGNORECASE tokens = { @@ -153,21 +147,21 @@ class BlitzBasicLexer(RegexLexer): Operator), (r'([+\-*/~=<>^])', Operator), (r'[(),:\[\]\\]', Punctuation), - (r'\.([ \t]*)(%s)' % bb_name, Name.Label), + (rf'\.([ \t]*)({bb_name})', Name.Label), # Identifiers - (r'\b(New)\b([ \t]+)(%s)' % (bb_name), + (rf'\b(New)\b([ \t]+)({bb_name})', bygroups(Keyword.Reserved, Whitespace, Name.Class)), - (r'\b(Gosub|Goto)\b([ \t]+)(%s)' % (bb_name), + (rf'\b(Gosub|Goto)\b([ \t]+)({bb_name})', bygroups(Keyword.Reserved, Whitespace, Name.Label)), - (r'\b(Object)\b([ \t]*)([.])([ \t]*)(%s)\b' % (bb_name), + (rf'\b(Object)\b([ \t]*)([.])([ \t]*)({bb_name})\b', bygroups(Operator, Whitespace, Punctuation, Whitespace, Name.Class)), - (r'\b%s\b([ \t]*)(\()' % bb_var, + (rf'\b{bb_var}\b([ \t]*)(\()', bygroups(Name.Function, Whitespace, Keyword.Type, Whitespace, Punctuation, Whitespace, Name.Class, Whitespace, Punctuation)), - (r'\b(Function)\b([ \t]+)%s' % bb_var, + (rf'\b(Function)\b([ \t]+){bb_var}', bygroups(Keyword.Reserved, Whitespace, Name.Function, Whitespace, Keyword.Type, Whitespace, Punctuation, Whitespace, Name.Class)), - (r'\b(Type)([ \t]+)(%s)' % (bb_name), + (rf'\b(Type)([ \t]+)({bb_name})', bygroups(Keyword.Reserved, Whitespace, Name.Class)), # Keywords (r'\b(Pi|True|False|Null)\b', Keyword.Constant), @@ -194,17 +188,15 @@ class BlitzBasicLexer(RegexLexer): class MonkeyLexer(RegexLexer): """ - For - `Monkey <https://en.wikipedia.org/wiki/Monkey_(programming_language)>`_ - source code. - - .. versionadded:: 1.6 + For Monkey source code. """ name = 'Monkey' aliases = ['monkey'] filenames = ['*.monkey'] mimetypes = ['text/x-monkey'] + url = 'https://blitzresearch.itch.io/monkeyx' + version_added = '1.6' name_variable = r'[a-z_]\w*' name_function = r'[A-Z]\w*' @@ -238,7 +230,7 @@ class MonkeyLexer(RegexLexer): (r'\$[0-9a-fA-Z]+', Number.Hex), (r'\%[10]+', Number.Bin), # Native data types - (r'\b%s\b' % keyword_type, Keyword.Type), + (rf'\b{keyword_type}\b', Keyword.Type), # Exception handling (r'(?i)\b(?:Try|Catch|Throw)\b', Keyword.Reserved), (r'Throwable', Name.Exception), @@ -274,21 +266,21 @@ class MonkeyLexer(RegexLexer): (r'(?i)(?:Not|Mod|Shl|Shr|And|Or)', Operator.Word), (r'[(){}!#,.:]', Punctuation), # catch the rest - (r'%s\b' % name_constant, Name.Constant), - (r'%s\b' % name_function, Name.Function), - (r'%s\b' % name_variable, Name.Variable), + (rf'{name_constant}\b', Name.Constant), + (rf'{name_function}\b', Name.Function), + (rf'{name_variable}\b', Name.Variable), ], 'funcname': [ - (r'(?i)%s\b' % name_function, Name.Function), + (rf'(?i){name_function}\b', Name.Function), (r':', Punctuation, 'classname'), (r'\s+', Whitespace), (r'\(', Punctuation, 'variables'), (r'\)', Punctuation, '#pop') ], 'classname': [ - (r'%s\.' % name_module, Name.Namespace), - (r'%s\b' % keyword_type, Keyword.Type), - (r'%s\b' % name_class, Name.Class), + (rf'{name_module}\.', Name.Namespace), + (rf'{keyword_type}\b', Keyword.Type), + (rf'{name_class}\b', Name.Class), # array (of given size) (r'(\[)(\s*)(\d*)(\s*)(\])', bygroups(Punctuation, Whitespace, Number.Integer, Whitespace, Punctuation)), @@ -300,9 +292,9 @@ class MonkeyLexer(RegexLexer): default('#pop') ], 'variables': [ - (r'%s\b' % name_constant, Name.Constant), - (r'%s\b' % name_variable, Name.Variable), - (r'%s' % keyword_type_special, Keyword.Type), + (rf'{name_constant}\b', Name.Constant), + (rf'{name_variable}\b', Name.Variable), + (rf'{keyword_type_special}', Keyword.Type), (r'\s+', Whitespace), (r':', Punctuation, 'classname'), (r',', Punctuation, '#push'), @@ -325,12 +317,12 @@ class MonkeyLexer(RegexLexer): class CbmBasicV2Lexer(RegexLexer): """ For CBM BASIC V2 sources. - - .. versionadded:: 1.6 """ name = 'CBM BASIC V2' aliases = ['cbmbas'] filenames = ['*.bas'] + url = 'https://en.wikipedia.org/wiki/Commodore_BASIC' + version_added = '1.6' flags = re.IGNORECASE @@ -362,17 +354,15 @@ class CbmBasicV2Lexer(RegexLexer): class QBasicLexer(RegexLexer): """ - For - `QBasic <http://en.wikipedia.org/wiki/QBasic>`_ - source code. - - .. versionadded:: 2.0 + For QBasic source code. """ name = 'QBasic' aliases = ['qbasic', 'basic'] filenames = ['*.BAS', '*.bas'] mimetypes = ['text/basic'] + url = 'https://en.wikipedia.org/wiki/QBasic' + version_added = '2.0' declarations = ('DATA', 'LET') @@ -475,26 +465,26 @@ class QBasicLexer(RegexLexer): # can't use regular \b because of X$() # XXX: use words() here 'declarations': [ - (r'\b(%s)(?=\(|\b)' % '|'.join(map(re.escape, declarations)), + (r'\b({})(?=\(|\b)'.format('|'.join(map(re.escape, declarations))), Keyword.Declaration), ], 'functions': [ - (r'\b(%s)(?=\(|\b)' % '|'.join(map(re.escape, functions)), + (r'\b({})(?=\(|\b)'.format('|'.join(map(re.escape, functions))), Keyword.Reserved), ], 'metacommands': [ - (r'\b(%s)(?=\(|\b)' % '|'.join(map(re.escape, metacommands)), + (r'\b({})(?=\(|\b)'.format('|'.join(map(re.escape, metacommands))), Keyword.Constant), ], 'operators': [ - (r'\b(%s)(?=\(|\b)' % '|'.join(map(re.escape, operators)), Operator.Word), + (r'\b({})(?=\(|\b)'.format('|'.join(map(re.escape, operators))), Operator.Word), ], 'statements': [ - (r'\b(%s)\b' % '|'.join(map(re.escape, statements)), + (r'\b({})\b'.format('|'.join(map(re.escape, statements))), Keyword.Reserved), ], 'keywords': [ - (r'\b(%s)\b' % '|'.join(keywords), Keyword), + (r'\b({})\b'.format('|'.join(keywords)), Keyword), ], } @@ -506,12 +496,13 @@ class QBasicLexer(RegexLexer): class VBScriptLexer(RegexLexer): """ VBScript is scripting language that is modeled on Visual Basic. - - .. versionadded:: 2.4 """ name = 'VBScript' aliases = ['vbscript'] filenames = ['*.vbs', '*.VBS'] + url = 'https://learn.microsoft.com/en-us/previous-versions/t0aew7h6(v=vs.85)' + version_added = '2.4' + flags = re.IGNORECASE tokens = { @@ -573,8 +564,6 @@ class BBCBasicLexer(RegexLexer): """ BBC Basic was supplied on the BBC Micro, and later Acorn RISC OS. It is also used by BBC Basic For Windows. - - .. versionadded:: 2.4 """ base_keywords = ['OTHERWISE', 'AND', 'DIV', 'EOR', 'MOD', 'OR', 'ERROR', 'LINE', 'OFF', 'STEP', 'SPC', 'TAB', 'ELSE', 'THEN', @@ -607,6 +596,8 @@ class BBCBasicLexer(RegexLexer): name = 'BBC Basic' aliases = ['bbcbasic'] filenames = ['*.bbc'] + url = 'https://www.bbcbasic.co.uk/bbcbasic.html' + version_added = '2.4' tokens = { 'root': [ |