diff options
author | nkozlovskiy <nmk@ydb.tech> | 2023-09-29 12:24:06 +0300 |
---|---|---|
committer | nkozlovskiy <nmk@ydb.tech> | 2023-09-29 12:41:34 +0300 |
commit | e0e3e1717e3d33762ce61950504f9637a6e669ed (patch) | |
tree | bca3ff6939b10ed60c3d5c12439963a1146b9711 /contrib/python/Pygments/py3/pygments/lexers/sophia.py | |
parent | 38f2c5852db84c7b4d83adfcb009eb61541d1ccd (diff) | |
download | ydb-e0e3e1717e3d33762ce61950504f9637a6e669ed.tar.gz |
add ydb deps
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/lexers/sophia.py')
-rw-r--r-- | contrib/python/Pygments/py3/pygments/lexers/sophia.py | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/contrib/python/Pygments/py3/pygments/lexers/sophia.py b/contrib/python/Pygments/py3/pygments/lexers/sophia.py new file mode 100644 index 0000000000..fc4928c31e --- /dev/null +++ b/contrib/python/Pygments/py3/pygments/lexers/sophia.py @@ -0,0 +1,103 @@ +""" + pygments.lexers.sophia + ~~~~~~~~~~~~~~~~~~~~~~ + + Lexer for Sophia. + + Derived from pygments/lexers/reason.py. + + :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.lexer import RegexLexer, include, default, words +from pygments.token import Comment, Keyword, Name, Number, Operator, \ + Punctuation, String, Text + +__all__ = ['SophiaLexer'] + +class SophiaLexer(RegexLexer): + """ + A Sophia lexer. + + .. versionadded:: 2.11 + """ + + name = 'Sophia' + aliases = ['sophia'] + filenames = ['*.aes'] + mimetypes = [] + + keywords = ( + 'contract', 'include', 'let', 'switch', 'type', 'record', 'datatype', + 'if', 'elif', 'else', 'function', 'stateful', 'payable', 'public', + 'entrypoint', 'private', 'indexed', 'namespace', 'interface', 'main', + 'using', 'as', 'for', 'hiding', + ) + + builtins = ('state', 'put', 'abort', 'require') + + word_operators = ('mod', 'band', 'bor', 'bxor', 'bnot') + + primitive_types = ('int', 'address', 'bool', 'bits', 'bytes', 'string', + 'list', 'option', 'char', 'unit', 'map', 'event', + 'hash', 'signature', 'oracle', 'oracle_query') + + tokens = { + 'escape-sequence': [ + (r'\\[\\"\'ntbr]', String.Escape), + (r'\\[0-9]{3}', String.Escape), + (r'\\x[0-9a-fA-F]{2}', String.Escape), + ], + 'root': [ + (r'\s+', Text.Whitespace), + (r'(true|false)\b', Keyword.Constant), + (r'\b([A-Z][\w\']*)(?=\s*\.)', Name.Class, 'dotted'), + (r'\b([A-Z][\w\']*)', Name.Function), + (r'//.*?\n', Comment.Single), + (r'\/\*(?!/)', Comment.Multiline, 'comment'), + + (r'0[xX][\da-fA-F][\da-fA-F_]*', Number.Hex), + (r'#[\da-fA-F][\da-fA-F_]*', Name.Label), + (r'\d[\d_]*', Number.Integer), + + (words(keywords, suffix=r'\b'), Keyword), + (words(builtins, suffix=r'\b'), Name.Builtin), + (words(word_operators, prefix=r'\b', suffix=r'\b'), Operator.Word), + (words(primitive_types, prefix=r'\b', suffix=r'\b'), Keyword.Type), + + (r'[=!<>+\\*/:&|?~@^-]', Operator.Word), + (r'[.;:{}(),\[\]]', Punctuation), + + (r"(ak_|ok_|oq_|ct_)[\w']*", Name.Label), + (r"[^\W\d][\w']*", Name), + + (r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'", + String.Char), + (r"'.'", String.Char), + (r"'[a-z][\w]*", Name.Variable), + + (r'"', String.Double, 'string') + ], + 'comment': [ + (r'[^/*]+', Comment.Multiline), + (r'\/\*', Comment.Multiline, '#push'), + (r'\*\/', Comment.Multiline, '#pop'), + (r'\*', Comment.Multiline), + ], + 'string': [ + (r'[^\\"]+', String.Double), + include('escape-sequence'), + (r'\\\n', String.Double), + (r'"', String.Double, '#pop'), + ], + 'dotted': [ + (r'\s+', Text), + (r'\.', Punctuation), + (r'[A-Z][\w\']*(?=\s*\.)', Name.Function), + (r'[A-Z][\w\']*', Name.Function, '#pop'), + (r'[a-z_][\w\']*', Name, '#pop'), + default('#pop'), + ], + } + |