diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
commit | 718c552901d703c502ccbefdfc3c9028d608b947 (patch) | |
tree | 46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/python/Pygments/py2/pygments/lexers/clean.py | |
parent | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff) | |
download | ydb-718c552901d703c502ccbefdfc3c9028d608b947.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/Pygments/py2/pygments/lexers/clean.py')
-rw-r--r-- | contrib/python/Pygments/py2/pygments/lexers/clean.py | 356 |
1 files changed, 178 insertions, 178 deletions
diff --git a/contrib/python/Pygments/py2/pygments/lexers/clean.py b/contrib/python/Pygments/py2/pygments/lexers/clean.py index 59b183b850..176f92d293 100644 --- a/contrib/python/Pygments/py2/pygments/lexers/clean.py +++ b/contrib/python/Pygments/py2/pygments/lexers/clean.py @@ -1,178 +1,178 @@ -# -*- coding: utf-8 -*- -""" - pygments.lexers.clean - ~~~~~~~~~~~~~~~~~~~~~ - - Lexer for the Clean language. - - :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. - :license: BSD, see LICENSE for details. -""" - -from pygments.lexer import ExtendedRegexLexer, words, include, bygroups -from pygments.token import Comment, Error, Keyword, Literal, Name, Number, \ - Operator, Punctuation, String, Whitespace - -__all__ = ['CleanLexer'] - - -class CleanLexer(ExtendedRegexLexer): - """ - Lexer for the general purpose, state-of-the-art, pure and lazy functional - programming language Clean (http://clean.cs.ru.nl/Clean). - - .. versionadded: 2.2 - """ - name = 'Clean' - aliases = ['clean'] - filenames = ['*.icl', '*.dcl'] - - keywords = ( - 'case', 'ccall', 'class', 'code', 'code inline', 'derive', 'export', - 'foreign', 'generic', 'if', 'in', 'infix', 'infixl', 'infixr', - 'instance', 'let', 'of', 'otherwise', 'special', 'stdcall', 'where', - 'with') - - modulewords = ('implementation', 'definition', 'system') - - lowerId = r'[a-z`][\w\d`]*' - upperId = r'[A-Z`][\w\d`]*' - funnyId = r'[~@#\$%\^?!+\-*<>\\/|&=:]+' - scoreUpperId = r'_' + upperId - scoreLowerId = r'_' + lowerId - moduleId = r'[a-zA-Z_][a-zA-Z0-9_.`]+' - classId = '|'.join([lowerId, upperId, funnyId]) - - tokens = { - 'root': [ - include('comments'), - include('keywords'), - include('module'), - include('import'), - include('whitespace'), - include('literals'), - include('operators'), - include('delimiters'), - include('names'), - ], - 'whitespace': [ - (r'\s+', Whitespace), - ], - 'comments': [ - (r'//.*\n', Comment.Single), - (r'/\*', Comment.Multi, 'comments.in'), - (r'/\*\*', Comment.Special, 'comments.in'), - ], - 'comments.in': [ - (r'\*\/', Comment.Multi, '#pop'), - (r'/\*', Comment.Multi, '#push'), - (r'[^*/]+', Comment.Multi), - (r'\*(?!/)', Comment.Multi), - (r'/', Comment.Multi), - ], - 'keywords': [ - (words(keywords, prefix=r'\b', suffix=r'\b'), Keyword), - ], - 'module': [ - (words(modulewords, prefix=r'\b', suffix=r'\b'), Keyword.Namespace), - (r'\bmodule\b', Keyword.Namespace, 'module.name'), - ], - 'module.name': [ - include('whitespace'), - (moduleId, Name.Class, '#pop'), - ], - 'import': [ - (r'\b(import)\b(\s*)', bygroups(Keyword, Whitespace), 'import.module'), - (r'\b(from)\b(\s*)\b(' + moduleId + r')\b(\s*)\b(import)\b', - bygroups(Keyword, Whitespace, Name.Class, Whitespace, Keyword), - 'import.what'), - ], - 'import.module': [ - (r'\b(qualified)\b(\s*)', bygroups(Keyword, Whitespace)), - (r'(\s*)\b(as)\b', bygroups(Whitespace, Keyword), ('#pop', 'import.module.as')), - (moduleId, Name.Class), - (r'(\s*)(,)(\s*)', bygroups(Whitespace, Punctuation, Whitespace)), - (r'\s*', Whitespace, '#pop'), - ], - 'import.module.as': [ - include('whitespace'), - (lowerId, Name.Class, '#pop'), - (upperId, Name.Class, '#pop'), - ], - 'import.what': [ - (r'\b(class)\b(\s+)(' + classId + r')', - bygroups(Keyword, Whitespace, Name.Class), 'import.what.class'), - (r'\b(instance)(\s+)(' + classId + r')(\s+)', - bygroups(Keyword, Whitespace, Name.Class, Whitespace), 'import.what.instance'), - (r'(::)(\s*)\b(' + upperId + r')\b', - bygroups(Punctuation, Whitespace, Name.Class), 'import.what.type'), - (r'\b(generic)\b(\s+)\b(' + lowerId + '|' + upperId + r')\b', - bygroups(Keyword, Whitespace, Name)), - include('names'), - (r'(,)(\s+)', bygroups(Punctuation, Whitespace)), - (r'$', Whitespace, '#pop'), - include('whitespace'), - ], - 'import.what.class': [ - (r',', Punctuation, '#pop'), - (r'\(', Punctuation, 'import.what.class.members'), - (r'$', Whitespace, '#pop:2'), - include('whitespace'), - ], - 'import.what.class.members': [ - (r',', Punctuation), - (r'\.\.', Punctuation), - (r'\)', Punctuation, '#pop'), - include('names'), - ], - 'import.what.instance': [ - (r'[,)]', Punctuation, '#pop'), - (r'\(', Punctuation, 'import.what.instance'), - (r'$', Whitespace, '#pop:2'), - include('whitespace'), - include('names'), - ], - 'import.what.type': [ - (r',', Punctuation, '#pop'), - (r'[({]', Punctuation, 'import.what.type.consesandfields'), - (r'$', Whitespace, '#pop:2'), - include('whitespace'), - ], - 'import.what.type.consesandfields': [ - (r',', Punctuation), - (r'\.\.', Punctuation), - (r'[)}]', Punctuation, '#pop'), - include('names'), - ], - 'literals': [ - (r'\'([^\'\\]|\\(x[\da-fA-F]+|\d+|.))\'', Literal.Char), - (r'[+~-]?0[0-7]+\b', Number.Oct), - (r'[+~-]?\d+\.\d+(E[+-]?\d+)?', Number.Float), - (r'[+~-]?\d+\b', Number.Integer), - (r'[+~-]?0x[\da-fA-F]+\b', Number.Hex), - (r'True|False', Literal), - (r'"', String.Double, 'literals.stringd'), - ], - 'literals.stringd': [ - (r'[^\\"\n]+', String.Double), - (r'"', String.Double, '#pop'), - (r'\\.', String.Double), - (r'[$\n]', Error, '#pop'), - ], - 'operators': [ - (r'[-~@#\$%\^?!+*<>\\/|&=:\.]+', Operator), - (r'\b_+\b', Operator), - ], - 'delimiters': [ - (r'[,;(){}\[\]]', Punctuation), - (r'(\')([\w`.]+)(\')', - bygroups(Punctuation, Name.Class, Punctuation)), - ], - 'names': [ - (lowerId, Name), - (scoreLowerId, Name), - (funnyId, Name.Function), - (upperId, Name.Class), - (scoreUpperId, Name.Class), - ] - } +# -*- coding: utf-8 -*- +""" + pygments.lexers.clean + ~~~~~~~~~~~~~~~~~~~~~ + + Lexer for the Clean language. + + :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.lexer import ExtendedRegexLexer, words, include, bygroups +from pygments.token import Comment, Error, Keyword, Literal, Name, Number, \ + Operator, Punctuation, String, Whitespace + +__all__ = ['CleanLexer'] + + +class CleanLexer(ExtendedRegexLexer): + """ + Lexer for the general purpose, state-of-the-art, pure and lazy functional + programming language Clean (http://clean.cs.ru.nl/Clean). + + .. versionadded: 2.2 + """ + name = 'Clean' + aliases = ['clean'] + filenames = ['*.icl', '*.dcl'] + + keywords = ( + 'case', 'ccall', 'class', 'code', 'code inline', 'derive', 'export', + 'foreign', 'generic', 'if', 'in', 'infix', 'infixl', 'infixr', + 'instance', 'let', 'of', 'otherwise', 'special', 'stdcall', 'where', + 'with') + + modulewords = ('implementation', 'definition', 'system') + + lowerId = r'[a-z`][\w\d`]*' + upperId = r'[A-Z`][\w\d`]*' + funnyId = r'[~@#\$%\^?!+\-*<>\\/|&=:]+' + scoreUpperId = r'_' + upperId + scoreLowerId = r'_' + lowerId + moduleId = r'[a-zA-Z_][a-zA-Z0-9_.`]+' + classId = '|'.join([lowerId, upperId, funnyId]) + + tokens = { + 'root': [ + include('comments'), + include('keywords'), + include('module'), + include('import'), + include('whitespace'), + include('literals'), + include('operators'), + include('delimiters'), + include('names'), + ], + 'whitespace': [ + (r'\s+', Whitespace), + ], + 'comments': [ + (r'//.*\n', Comment.Single), + (r'/\*', Comment.Multi, 'comments.in'), + (r'/\*\*', Comment.Special, 'comments.in'), + ], + 'comments.in': [ + (r'\*\/', Comment.Multi, '#pop'), + (r'/\*', Comment.Multi, '#push'), + (r'[^*/]+', Comment.Multi), + (r'\*(?!/)', Comment.Multi), + (r'/', Comment.Multi), + ], + 'keywords': [ + (words(keywords, prefix=r'\b', suffix=r'\b'), Keyword), + ], + 'module': [ + (words(modulewords, prefix=r'\b', suffix=r'\b'), Keyword.Namespace), + (r'\bmodule\b', Keyword.Namespace, 'module.name'), + ], + 'module.name': [ + include('whitespace'), + (moduleId, Name.Class, '#pop'), + ], + 'import': [ + (r'\b(import)\b(\s*)', bygroups(Keyword, Whitespace), 'import.module'), + (r'\b(from)\b(\s*)\b(' + moduleId + r')\b(\s*)\b(import)\b', + bygroups(Keyword, Whitespace, Name.Class, Whitespace, Keyword), + 'import.what'), + ], + 'import.module': [ + (r'\b(qualified)\b(\s*)', bygroups(Keyword, Whitespace)), + (r'(\s*)\b(as)\b', bygroups(Whitespace, Keyword), ('#pop', 'import.module.as')), + (moduleId, Name.Class), + (r'(\s*)(,)(\s*)', bygroups(Whitespace, Punctuation, Whitespace)), + (r'\s*', Whitespace, '#pop'), + ], + 'import.module.as': [ + include('whitespace'), + (lowerId, Name.Class, '#pop'), + (upperId, Name.Class, '#pop'), + ], + 'import.what': [ + (r'\b(class)\b(\s+)(' + classId + r')', + bygroups(Keyword, Whitespace, Name.Class), 'import.what.class'), + (r'\b(instance)(\s+)(' + classId + r')(\s+)', + bygroups(Keyword, Whitespace, Name.Class, Whitespace), 'import.what.instance'), + (r'(::)(\s*)\b(' + upperId + r')\b', + bygroups(Punctuation, Whitespace, Name.Class), 'import.what.type'), + (r'\b(generic)\b(\s+)\b(' + lowerId + '|' + upperId + r')\b', + bygroups(Keyword, Whitespace, Name)), + include('names'), + (r'(,)(\s+)', bygroups(Punctuation, Whitespace)), + (r'$', Whitespace, '#pop'), + include('whitespace'), + ], + 'import.what.class': [ + (r',', Punctuation, '#pop'), + (r'\(', Punctuation, 'import.what.class.members'), + (r'$', Whitespace, '#pop:2'), + include('whitespace'), + ], + 'import.what.class.members': [ + (r',', Punctuation), + (r'\.\.', Punctuation), + (r'\)', Punctuation, '#pop'), + include('names'), + ], + 'import.what.instance': [ + (r'[,)]', Punctuation, '#pop'), + (r'\(', Punctuation, 'import.what.instance'), + (r'$', Whitespace, '#pop:2'), + include('whitespace'), + include('names'), + ], + 'import.what.type': [ + (r',', Punctuation, '#pop'), + (r'[({]', Punctuation, 'import.what.type.consesandfields'), + (r'$', Whitespace, '#pop:2'), + include('whitespace'), + ], + 'import.what.type.consesandfields': [ + (r',', Punctuation), + (r'\.\.', Punctuation), + (r'[)}]', Punctuation, '#pop'), + include('names'), + ], + 'literals': [ + (r'\'([^\'\\]|\\(x[\da-fA-F]+|\d+|.))\'', Literal.Char), + (r'[+~-]?0[0-7]+\b', Number.Oct), + (r'[+~-]?\d+\.\d+(E[+-]?\d+)?', Number.Float), + (r'[+~-]?\d+\b', Number.Integer), + (r'[+~-]?0x[\da-fA-F]+\b', Number.Hex), + (r'True|False', Literal), + (r'"', String.Double, 'literals.stringd'), + ], + 'literals.stringd': [ + (r'[^\\"\n]+', String.Double), + (r'"', String.Double, '#pop'), + (r'\\.', String.Double), + (r'[$\n]', Error, '#pop'), + ], + 'operators': [ + (r'[-~@#\$%\^?!+*<>\\/|&=:\.]+', Operator), + (r'\b_+\b', Operator), + ], + 'delimiters': [ + (r'[,;(){}\[\]]', Punctuation), + (r'(\')([\w`.]+)(\')', + bygroups(Punctuation, Name.Class, Punctuation)), + ], + 'names': [ + (lowerId, Name), + (scoreLowerId, Name), + (funnyId, Name.Function), + (upperId, Name.Class), + (scoreUpperId, Name.Class), + ] + } |