aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/Pygments/py3/pygments/lexers/julia.py
diff options
context:
space:
mode:
authorilezhankin <ilezhankin@yandex-team.ru>2022-02-10 16:45:55 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:55 +0300
commit1d125034f06575234f83f24f08677955133f140e (patch)
treeec05fbbd61dc118d5de37f206ab978cff58774bd /contrib/python/Pygments/py3/pygments/lexers/julia.py
parent3a7a498715ef1b66f5054455421b845e45e3a653 (diff)
downloadydb-1d125034f06575234f83f24f08677955133f140e.tar.gz
Restoring authorship annotation for <ilezhankin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/lexers/julia.py')
-rw-r--r--contrib/python/Pygments/py3/pygments/lexers/julia.py172
1 files changed, 86 insertions, 86 deletions
diff --git a/contrib/python/Pygments/py3/pygments/lexers/julia.py b/contrib/python/Pygments/py3/pygments/lexers/julia.py
index 390d5d7158..d81dbc1a22 100644
--- a/contrib/python/Pygments/py3/pygments/lexers/julia.py
+++ b/contrib/python/Pygments/py3/pygments/lexers/julia.py
@@ -1,53 +1,53 @@
-"""
- pygments.lexers.julia
- ~~~~~~~~~~~~~~~~~~~~~
-
- Lexers for the Julia language.
-
+"""
+ pygments.lexers.julia
+ ~~~~~~~~~~~~~~~~~~~~~
+
+ Lexers for the Julia language.
+
:copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
- :license: BSD, see LICENSE for details.
-"""
-
-import re
-
+ :license: BSD, see LICENSE for details.
+"""
+
+import re
+
from pygments.lexer import Lexer, RegexLexer, bygroups, do_insertions, \
words, include
-from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
- Number, Punctuation, Generic
+from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
+ Number, Punctuation, Generic
from pygments.util import shebang_matches
from pygments.lexers._julia_builtins import OPERATORS_LIST, DOTTED_OPERATORS_LIST, \
KEYWORD_LIST, BUILTIN_LIST, LITERAL_LIST
-
-__all__ = ['JuliaLexer', 'JuliaConsoleLexer']
-
+
+__all__ = ['JuliaLexer', 'JuliaConsoleLexer']
+
# see https://docs.julialang.org/en/v1/manual/variables/#Allowed-Variable-Names
allowed_variable = \
'(?:[a-zA-Z_\u00A1-\U0010ffff][a-zA-Z_0-9!\u00A1-\U0010ffff]*)'
# see https://github.com/JuliaLang/julia/blob/master/src/flisp/julia_opsuffs.h
operator_suffixes = r'[²³¹ʰʲʳʷʸˡˢˣᴬᴮᴰᴱᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾᴿᵀᵁᵂᵃᵇᵈᵉᵍᵏᵐᵒᵖᵗᵘᵛᵝᵞᵟᵠᵡᵢᵣᵤᵥᵦᵧᵨᵩᵪᶜᶠᶥᶦᶫᶰᶸᶻᶿ′″‴‵‶‷⁗⁰ⁱ⁴⁵⁶⁷⁸⁹⁺⁻⁼⁽⁾ⁿ₀₁₂₃₄₅₆₇₈₉₊₋₌₍₎ₐₑₒₓₕₖₗₘₙₚₛₜⱼⱽ]*'
-
-class JuliaLexer(RegexLexer):
- """
- For `Julia <http://julialang.org/>`_ source code.
-
- .. versionadded:: 1.6
- """
-
- name = 'Julia'
- aliases = ['julia', 'jl']
- filenames = ['*.jl']
- mimetypes = ['text/x-julia', 'application/x-julia']
-
- flags = re.MULTILINE | re.UNICODE
-
- tokens = {
- 'root': [
- (r'\n', Text),
- (r'[^\S\n]+', Text),
- (r'#=', Comment.Multiline, "blockcomment"),
- (r'#.*$', Comment),
+
+class JuliaLexer(RegexLexer):
+ """
+ For `Julia <http://julialang.org/>`_ source code.
+
+ .. versionadded:: 1.6
+ """
+
+ name = 'Julia'
+ aliases = ['julia', 'jl']
+ filenames = ['*.jl']
+ mimetypes = ['text/x-julia', 'application/x-julia']
+
+ flags = re.MULTILINE | re.UNICODE
+
+ tokens = {
+ 'root': [
+ (r'\n', Text),
+ (r'[^\S\n]+', Text),
+ (r'#=', Comment.Multiline, "blockcomment"),
+ (r'#.*$', Comment),
(r'[\[\](),;]', Punctuation),
-
+
# symbols
# intercept range expressions first
(r'(' + allowed_variable + r')(\s*)(:)(' + allowed_variable + ')',
@@ -55,7 +55,7 @@ class JuliaLexer(RegexLexer):
# then match :name which does not follow closing brackets, digits, or the
# ::, <:, and :> operators
(r'(?<![\]):<>\d.])(:' + allowed_variable + ')', String.Symbol),
-
+
# type assertions - excludes expressions like ::typeof(sin) and ::avec[1]
(r'(?<=::)(\s*)(' + allowed_variable + r')\b(?![(\[])', bygroups(Text, Keyword.Type)),
# type comparisons
@@ -79,17 +79,17 @@ class JuliaLexer(RegexLexer):
# NOTE
# Patterns below work only for definition sites and thus hardly reliable.
#
- # functions
+ # functions
# (r'(function)(\s+)(' + allowed_variable + ')',
# bygroups(Keyword, Text, Name.Function)),
-
- # chars
- (r"'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,3}|\\u[a-fA-F0-9]{1,4}|"
- r"\\U[a-fA-F0-9]{1,6}|[^\\\'\n])'", String.Char),
-
- # try to match trailing transpose
+
+ # chars
+ (r"'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,3}|\\u[a-fA-F0-9]{1,4}|"
+ r"\\U[a-fA-F0-9]{1,6}|[^\\\'\n])'", String.Char),
+
+ # try to match trailing transpose
(r'(?<=[.\w)\]])(\'' + operator_suffixes + ')+', Operator),
-
+
# raw strings
(r'(raw)(""")', bygroups(String.Affix, String), 'tqrawstring'),
(r'(raw)(")', bygroups(String.Affix, String), 'rawstring'),
@@ -129,10 +129,10 @@ class JuliaLexer(RegexLexer):
# builtin literals
(words(LITERAL_LIST, suffix=r'\b'), Name.Builtin),
- # names
+ # names
(allowed_variable, Name),
-
- # numbers
+
+ # numbers
(r'(\d+((_\d+)+)?\.(?!\.)(\d+((_\d+)+)?)?|\.\d+((_\d+)+)?)([eEf][+-]?[0-9]+)?', Number.Float),
(r'\d+((_\d+)+)?[eEf][+-]?[0-9]+', Number.Float),
(r'0x[a-fA-F0-9]+((_[a-fA-F0-9]+)+)?(\.([a-fA-F0-9]+((_[a-fA-F0-9]+)+)?)?)?p[+-]?\d+', Number.Float),
@@ -143,14 +143,14 @@ class JuliaLexer(RegexLexer):
# single dot operator matched last to permit e.g. ".1" as a float
(words(['.']), Operator),
- ],
-
- "blockcomment": [
- (r'[^=#]', Comment.Multiline),
- (r'#=', Comment.Multiline, '#push'),
- (r'=#', Comment.Multiline, '#pop'),
- (r'[=#]', Comment.Multiline),
- ],
+ ],
+
+ "blockcomment": [
+ (r'[^=#]', Comment.Multiline),
+ (r'#=', Comment.Multiline, '#push'),
+ (r'=#', Comment.Multiline, '#pop'),
+ (r'[=#]', Comment.Multiline),
+ ],
'curly': [
(r'\{', Punctuation, '#push'),
@@ -182,7 +182,7 @@ class JuliaLexer(RegexLexer):
include('root'),
],
- 'string': [
+ 'string': [
(r'(")(' + allowed_variable + r'|\d+)?', bygroups(String, String.Affix), '#pop'),
# FIXME: This escape pattern is not perfect.
(r'\\([\\"\'$nrbtfav]|(x|u|U)[a-fA-F0-9]+|\d+)', String.Escape),
@@ -192,7 +192,7 @@ class JuliaLexer(RegexLexer):
String.Interpol),
(r'[^"$%\\]+', String),
(r'.', String),
- ],
+ ],
'tqstring': [
(r'(""")(' + allowed_variable + r'|\d+)?', bygroups(String, String.Affix), '#pop'),
(r'\\([\\"\'$nrbtfav]|(x|u|U)[a-fA-F0-9]+|\d+)', String.Escape),
@@ -226,33 +226,33 @@ class JuliaLexer(RegexLexer):
(r'[^\\`$]+', String.Backtick),
(r'.', String.Backtick),
],
- }
-
- def analyse_text(text):
- return shebang_matches(text, r'julia')
-
-
-class JuliaConsoleLexer(Lexer):
- """
- For Julia console sessions. Modeled after MatlabSessionLexer.
-
- .. versionadded:: 1.6
- """
- name = 'Julia console'
+ }
+
+ def analyse_text(text):
+ return shebang_matches(text, r'julia')
+
+
+class JuliaConsoleLexer(Lexer):
+ """
+ For Julia console sessions. Modeled after MatlabSessionLexer.
+
+ .. versionadded:: 1.6
+ """
+ name = 'Julia console'
aliases = ['jlcon', 'julia-repl']
-
- def get_tokens_unprocessed(self, text):
- jllexer = JuliaLexer(**self.options)
+
+ def get_tokens_unprocessed(self, text):
+ jllexer = JuliaLexer(**self.options)
start = 0
- curcode = ''
- insertions = []
+ curcode = ''
+ insertions = []
output = False
error = False
-
+
for line in text.splitlines(True):
- if line.startswith('julia>'):
+ if line.startswith('julia>'):
insertions.append((len(curcode), [(0, Generic.Prompt, line[:6])]))
- curcode += line[6:]
+ curcode += line[6:]
output = False
error = False
elif line.startswith('help?>') or line.startswith('shell>'):
@@ -263,12 +263,12 @@ class JuliaConsoleLexer(Lexer):
elif line.startswith(' ') and not output:
insertions.append((len(curcode), [(0, Text, line[:6])]))
curcode += line[6:]
- else:
- if curcode:
+ else:
+ if curcode:
yield from do_insertions(
insertions, jllexer.get_tokens_unprocessed(curcode))
- curcode = ''
- insertions = []
+ curcode = ''
+ insertions = []
if line.startswith('ERROR: ') or error:
yield start, Generic.Error, line
error = True
@@ -276,7 +276,7 @@ class JuliaConsoleLexer(Lexer):
yield start, Generic.Output, line
output = True
start += len(line)
-
+
if curcode:
yield from do_insertions(
insertions, jllexer.get_tokens_unprocessed(curcode))