aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/Pygments/py3/pygments/lexers/ml.py
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-05-20 07:58:40 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-05-20 08:05:00 +0300
commitbcd5bcc390793791d293d386b2ebefbe683fb4e1 (patch)
treec93e3b8c847237e7e7626f4a07f1b657bb34f04d /contrib/python/Pygments/py3/pygments/lexers/ml.py
parent1a9f1508fe9c8c5927ffebf33197a6108e70501d (diff)
downloadydb-bcd5bcc390793791d293d386b2ebefbe683fb4e1.tar.gz
Intermediate changes
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/lexers/ml.py')
-rw-r--r--contrib/python/Pygments/py3/pygments/lexers/ml.py114
1 files changed, 56 insertions, 58 deletions
diff --git a/contrib/python/Pygments/py3/pygments/lexers/ml.py b/contrib/python/Pygments/py3/pygments/lexers/ml.py
index 3dfa6d9345..ff50c6f0cb 100644
--- a/contrib/python/Pygments/py3/pygments/lexers/ml.py
+++ b/contrib/python/Pygments/py3/pygments/lexers/ml.py
@@ -4,7 +4,7 @@
Lexers for ML family languages.
- :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.
"""
@@ -20,14 +20,14 @@ __all__ = ['SMLLexer', 'OcamlLexer', 'OpaLexer', 'ReasonLexer', 'FStarLexer']
class SMLLexer(RegexLexer):
"""
For the Standard ML language.
-
- .. versionadded:: 1.5
"""
name = 'Standard ML'
aliases = ['sml']
filenames = ['*.sml', '*.sig', '*.fun']
mimetypes = ['text/x-standardml', 'application/x-standardml']
+ url = 'https://en.wikipedia.org/wiki/Standard_ML'
+ version_added = '1.5'
alphanumid_reserved = {
# Core
@@ -121,7 +121,7 @@ class SMLLexer(RegexLexer):
'core': [
# Punctuation that doesn't overlap symbolic identifiers
- (r'(%s)' % '|'.join(re.escape(z) for z in nonid_reserved),
+ (r'({})'.format('|'.join(re.escape(z) for z in nonid_reserved)),
Punctuation),
# Special constants: strings, floats, numbers in decimal and hex
@@ -137,8 +137,8 @@ class SMLLexer(RegexLexer):
# Labels
(r'#\s*[1-9][0-9]*', Name.Label),
- (r'#\s*(%s)' % alphanumid_re, Name.Label),
- (r'#\s+(%s)' % symbolicid_re, Name.Label),
+ (rf'#\s*({alphanumid_re})', Name.Label),
+ (rf'#\s+({symbolicid_re})', Name.Label),
# Some reserved words trigger a special, local lexer state change
(r'\b(datatype|abstype)\b(?!\')', Keyword.Reserved, 'dname'),
(r'\b(exception)\b(?!\')', Keyword.Reserved, 'ename'),
@@ -148,14 +148,14 @@ class SMLLexer(RegexLexer):
# Regular identifiers, long and otherwise
(r'\'[\w\']*', Name.Decorator),
- (r'(%s)(\.)' % alphanumid_re, long_id_callback, "dotted"),
- (r'(%s)' % alphanumid_re, id_callback),
- (r'(%s)' % symbolicid_re, id_callback),
+ (rf'({alphanumid_re})(\.)', long_id_callback, "dotted"),
+ (rf'({alphanumid_re})', id_callback),
+ (rf'({symbolicid_re})', id_callback),
],
'dotted': [
- (r'(%s)(\.)' % alphanumid_re, long_id_callback),
- (r'(%s)' % alphanumid_re, end_id_callback, "#pop"),
- (r'(%s)' % symbolicid_re, end_id_callback, "#pop"),
+ (rf'({alphanumid_re})(\.)', long_id_callback),
+ (rf'({alphanumid_re})', end_id_callback, "#pop"),
+ (rf'({symbolicid_re})', end_id_callback, "#pop"),
(r'\s+', Error),
(r'\S+', Error),
],
@@ -208,7 +208,7 @@ class SMLLexer(RegexLexer):
'string': stringy(String.Double),
'breakout': [
- (r'(?=\b(%s)\b(?!\'))' % '|'.join(alphanumid_reserved), Text, '#pop'),
+ (r'(?=\b({})\b(?!\'))'.format('|'.join(alphanumid_reserved)), Text, '#pop'),
],
# Dealing with what comes after module system keywords
@@ -216,7 +216,7 @@ class SMLLexer(RegexLexer):
include('whitespace'),
include('breakout'),
- (r'(%s)' % alphanumid_re, Name.Namespace),
+ (rf'({alphanumid_re})', Name.Namespace),
default('#pop'),
],
@@ -226,8 +226,8 @@ class SMLLexer(RegexLexer):
(r'\'[\w\']*', Name.Decorator),
(r'\(', Punctuation, 'tyvarseq'),
- (r'(%s)' % alphanumid_re, Name.Function, '#pop'),
- (r'(%s)' % symbolicid_re, Name.Function, '#pop'),
+ (rf'({alphanumid_re})', Name.Function, '#pop'),
+ (rf'({symbolicid_re})', Name.Function, '#pop'),
# Ignore interesting function declarations like "fun (x + y) = ..."
default('#pop'),
@@ -239,12 +239,12 @@ class SMLLexer(RegexLexer):
(r'\'[\w\']*', Name.Decorator),
(r'\(', Punctuation, 'tyvarseq'),
- (r'(%s)(\s*)(=(?!%s))' % (alphanumid_re, symbolicid_re),
+ (rf'({alphanumid_re})(\s*)(=(?!{symbolicid_re}))',
bygroups(Name.Variable, Text, Punctuation), '#pop'),
- (r'(%s)(\s*)(=(?!%s))' % (symbolicid_re, symbolicid_re),
+ (rf'({symbolicid_re})(\s*)(=(?!{symbolicid_re}))',
bygroups(Name.Variable, Text, Punctuation), '#pop'),
- (r'(%s)' % alphanumid_re, Name.Variable, '#pop'),
- (r'(%s)' % symbolicid_re, Name.Variable, '#pop'),
+ (rf'({alphanumid_re})', Name.Variable, '#pop'),
+ (rf'({symbolicid_re})', Name.Variable, '#pop'),
# Ignore interesting patterns like 'val (x, y)'
default('#pop'),
@@ -257,10 +257,10 @@ class SMLLexer(RegexLexer):
(r'\'[\w\']*', Name.Decorator),
(r'\(', Punctuation, 'tyvarseq'),
- (r'=(?!%s)' % symbolicid_re, Punctuation, ('#pop', 'typbind')),
+ (rf'=(?!{symbolicid_re})', Punctuation, ('#pop', 'typbind')),
- (r'(%s)' % alphanumid_re, Keyword.Type),
- (r'(%s)' % symbolicid_re, Keyword.Type),
+ (rf'({alphanumid_re})', Keyword.Type),
+ (rf'({symbolicid_re})', Keyword.Type),
(r'\S+', Error, '#pop'),
],
@@ -284,11 +284,11 @@ class SMLLexer(RegexLexer):
(r'\(', Punctuation, 'tyvarseq'),
(r'(=)(\s*)(datatype)',
bygroups(Punctuation, Text, Keyword.Reserved), '#pop'),
- (r'=(?!%s)' % symbolicid_re, Punctuation,
+ (rf'=(?!{symbolicid_re})', Punctuation,
('#pop', 'datbind', 'datcon')),
- (r'(%s)' % alphanumid_re, Keyword.Type),
- (r'(%s)' % symbolicid_re, Keyword.Type),
+ (rf'({alphanumid_re})', Keyword.Type),
+ (rf'({symbolicid_re})', Keyword.Type),
(r'\S+', Error, '#pop'),
],
@@ -300,9 +300,9 @@ class SMLLexer(RegexLexer):
(r'\b(withtype)\b(?!\')', Keyword.Reserved, ('#pop', 'tname')),
(r'\b(of)\b(?!\')', Keyword.Reserved),
- (r'(\|)(\s*)(%s)' % alphanumid_re,
+ (rf'(\|)(\s*)({alphanumid_re})',
bygroups(Punctuation, Text, Name.Class)),
- (r'(\|)(\s+)(%s)' % symbolicid_re,
+ (rf'(\|)(\s+)({symbolicid_re})',
bygroups(Punctuation, Text, Name.Class)),
include('breakout'),
@@ -314,20 +314,20 @@ class SMLLexer(RegexLexer):
'ename': [
include('whitespace'),
- (r'(and\b)(\s+)(%s)' % alphanumid_re,
+ (rf'(and\b)(\s+)({alphanumid_re})',
bygroups(Keyword.Reserved, Text, Name.Class)),
- (r'(and\b)(\s*)(%s)' % symbolicid_re,
+ (rf'(and\b)(\s*)({symbolicid_re})',
bygroups(Keyword.Reserved, Text, Name.Class)),
(r'\b(of)\b(?!\')', Keyword.Reserved),
- (r'(%s)|(%s)' % (alphanumid_re, symbolicid_re), Name.Class),
+ (rf'({alphanumid_re})|({symbolicid_re})', Name.Class),
default('#pop'),
],
'datcon': [
include('whitespace'),
- (r'(%s)' % alphanumid_re, Name.Class, '#pop'),
- (r'(%s)' % symbolicid_re, Name.Class, '#pop'),
+ (rf'({alphanumid_re})', Name.Class, '#pop'),
+ (rf'({symbolicid_re})', Name.Class, '#pop'),
(r'\S+', Error, '#pop'),
],
@@ -355,8 +355,6 @@ class SMLLexer(RegexLexer):
class OcamlLexer(RegexLexer):
"""
For the OCaml language.
-
- .. versionadded:: 0.7
"""
name = 'OCaml'
@@ -364,6 +362,7 @@ class OcamlLexer(RegexLexer):
aliases = ['ocaml']
filenames = ['*.ml', '*.mli', '*.mll', '*.mly']
mimetypes = ['text/x-ocaml']
+ version_added = '0.7'
keywords = (
'and', 'as', 'assert', 'begin', 'class', 'constraint', 'do', 'done',
@@ -399,11 +398,11 @@ class OcamlLexer(RegexLexer):
(r'\b([A-Z][\w\']*)(?=\s*\.)', Name.Namespace, 'dotted'),
(r'\b([A-Z][\w\']*)', Name.Class),
(r'\(\*(?![)])', Comment, 'comment'),
- (r'\b(%s)\b' % '|'.join(keywords), Keyword),
- (r'(%s)' % '|'.join(keyopts[::-1]), Operator),
- (r'(%s|%s)?%s' % (infix_syms, prefix_syms, operators), Operator),
- (r'\b(%s)\b' % '|'.join(word_operators), Operator.Word),
- (r'\b(%s)\b' % '|'.join(primitives), Keyword.Type),
+ (r'\b({})\b'.format('|'.join(keywords)), Keyword),
+ (r'({})'.format('|'.join(keyopts[::-1])), Operator),
+ (rf'({infix_syms}|{prefix_syms})?{operators}', Operator),
+ (r'\b({})\b'.format('|'.join(word_operators)), Operator.Word),
+ (r'\b({})\b'.format('|'.join(primitives)), Keyword.Type),
(r"[^\W\d][\w']*", Name),
@@ -448,14 +447,14 @@ class OcamlLexer(RegexLexer):
class OpaLexer(RegexLexer):
"""
Lexer for the Opa language.
-
- .. versionadded:: 1.5
"""
name = 'Opa'
aliases = ['opa']
filenames = ['*.opa']
mimetypes = ['text/x-opa']
+ url = 'http://opalang.org'
+ version_added = '1.5'
# most of these aren't strictly keywords
# but if you color only real keywords, you might just
@@ -557,8 +556,8 @@ class OpaLexer(RegexLexer):
# way to syntactic distinguish binding constructions
# unfortunately, this colors the equal in {x=2} too
(r'=(?!'+op_re+r')', Keyword),
- (r'(%s)+' % op_re, Operator),
- (r'(%s)+' % punc_re, Operator),
+ (rf'({op_re})+', Operator),
+ (rf'({punc_re})+', Operator),
# coercions
(r':', Operator, 'type'),
@@ -771,8 +770,6 @@ class OpaLexer(RegexLexer):
class ReasonLexer(RegexLexer):
"""
For the ReasonML language.
-
- .. versionadded:: 2.6
"""
name = 'ReasonML'
@@ -780,6 +777,7 @@ class ReasonLexer(RegexLexer):
aliases = ['reasonml', 'reason']
filenames = ['*.re', '*.rei']
mimetypes = ['text/x-reasonml']
+ version_added = '2.6'
keywords = (
'as', 'assert', 'begin', 'class', 'constraint', 'do', 'done', 'downto',
@@ -815,11 +813,11 @@ class ReasonLexer(RegexLexer):
(r'\b([A-Z][\w\']*)', Name.Class),
(r'//.*?\n', Comment.Single),
(r'\/\*(?!/)', Comment.Multiline, 'comment'),
- (r'\b(%s)\b' % '|'.join(keywords), Keyword),
- (r'(%s)' % '|'.join(keyopts[::-1]), Operator.Word),
- (r'(%s|%s)?%s' % (infix_syms, prefix_syms, operators), Operator),
- (r'\b(%s)\b' % '|'.join(word_operators), Operator.Word),
- (r'\b(%s)\b' % '|'.join(primitives), Keyword.Type),
+ (r'\b({})\b'.format('|'.join(keywords)), Keyword),
+ (r'({})'.format('|'.join(keyopts[::-1])), Operator.Word),
+ (rf'({infix_syms}|{prefix_syms})?{operators}', Operator),
+ (r'\b({})\b'.format('|'.join(word_operators)), Operator.Word),
+ (r'\b({})\b'.format('|'.join(primitives)), Keyword.Type),
(r"[^\W\d][\w']*", Name),
@@ -864,7 +862,6 @@ class ReasonLexer(RegexLexer):
class FStarLexer(RegexLexer):
"""
For the F* language.
- .. versionadded:: 2.7
"""
name = 'FStar'
@@ -872,6 +869,7 @@ class FStarLexer(RegexLexer):
aliases = ['fstar']
filenames = ['*.fst', '*.fsti']
mimetypes = ['text/x-fstar']
+ version_added = '2.7'
keywords = (
'abstract', 'attributes', 'noeq', 'unopteq', 'and'
@@ -912,12 +910,12 @@ class FStarLexer(RegexLexer):
(r'\b([A-Z][\w\']*)', Name.Class),
(r'\(\*(?![)])', Comment, 'comment'),
(r'\/\/.+$', Comment),
- (r'\b(%s)\b' % '|'.join(keywords), Keyword),
- (r'\b(%s)\b' % '|'.join(assume_keywords), Name.Exception),
- (r'\b(%s)\b' % '|'.join(decl_keywords), Keyword.Declaration),
- (r'(%s)' % '|'.join(keyopts[::-1]), Operator),
- (r'(%s|%s)?%s' % (infix_syms, prefix_syms, operators), Operator),
- (r'\b(%s)\b' % '|'.join(primitives), Keyword.Type),
+ (r'\b({})\b'.format('|'.join(keywords)), Keyword),
+ (r'\b({})\b'.format('|'.join(assume_keywords)), Name.Exception),
+ (r'\b({})\b'.format('|'.join(decl_keywords)), Keyword.Declaration),
+ (r'({})'.format('|'.join(keyopts[::-1])), Operator),
+ (rf'({infix_syms}|{prefix_syms})?{operators}', Operator),
+ (r'\b({})\b'.format('|'.join(primitives)), Keyword.Type),
(r"[^\W\d][\w']*", Name),