diff options
| author | shadchin <[email protected]> | 2022-02-10 16:44:30 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:44:30 +0300 | 
| commit | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch) | |
| tree | 012bb94d777798f1f56ac1cec429509766d05181 /contrib/python/Pygments/py2/pygments/lexers/solidity.py | |
| parent | 6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/Pygments/py2/pygments/lexers/solidity.py')
| -rw-r--r-- | contrib/python/Pygments/py2/pygments/lexers/solidity.py | 186 | 
1 files changed, 93 insertions, 93 deletions
| diff --git a/contrib/python/Pygments/py2/pygments/lexers/solidity.py b/contrib/python/Pygments/py2/pygments/lexers/solidity.py index 99668371979..c16daa3f35c 100644 --- a/contrib/python/Pygments/py2/pygments/lexers/solidity.py +++ b/contrib/python/Pygments/py2/pygments/lexers/solidity.py @@ -1,93 +1,93 @@ -# -*- coding: utf-8 -*- -""" -    pygments.lexers.solidity -    ~~~~~~~~~~~~~~~~~~~~~~~~ - -    Lexers for Solidity. - -    :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. -    :license: BSD, see LICENSE for details. -""" - -import re - -from pygments.lexer import RegexLexer, bygroups, include, words -from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ -    Number, Punctuation - -__all__ = ['SolidityLexer'] - - -class SolidityLexer(RegexLexer): -    """ -    For Solidity source code. - -    .. versionadded:: 2.5 -    """ - -    name = 'Solidity' -    aliases = ['solidity'] -    filenames = ['*.sol'] -    mimetypes = [] - -    flags = re.MULTILINE | re.UNICODE - -    datatype = ( -        r'\b(address|bool|((bytes|hash|int|string|uint)(8|16|24|32|40|48|56|64' -        r'|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208' -        r'|216|224|232|240|248|256)?))\b' -    ) - -    tokens = { -        'root': [ -            include('whitespace'), -            include('comments'), -            (r'\bpragma\s+solidity\b', Keyword, 'pragma'), -            (r'\b(contract)(\s+)([a-zA-Z_]\w*)', -             bygroups(Keyword, Text.WhiteSpace, Name.Entity)), -            (datatype + r'(\s+)((external|public|internal|private)\s+)?' + -             r'([a-zA-Z_]\w*)', -             bygroups(Keyword.Type, None, None, None, Text.WhiteSpace, Keyword, -                      None, Name.Variable)), -            (r'\b(enum|event|function|struct)(\s+)([a-zA-Z_]\w*)', -             bygroups(Keyword.Type, Text.WhiteSpace, Name.Variable)), -            (r'\b(msg|block|tx)\.([A-Za-z_][A-Za-z0-9_]*)\b', Keyword), -            (words(( -                'block', 'break', 'constant', 'constructor', 'continue', -                'contract', 'do', 'else', 'external', 'false', 'for', -                'function', 'if', 'import', 'inherited', 'internal', 'is', -                'library', 'mapping', 'memory', 'modifier', 'msg', 'new', -                'payable', 'private', 'public', 'require', 'return', -                'returns', 'struct', 'suicide', 'throw', 'this', 'true', -                'tx', 'var', 'while'), prefix=r'\b', suffix=r'\b'), -             Keyword.Type), -            (words(('keccak256',), prefix=r'\b', suffix=r'\b'), Name.Builtin), -            (datatype, Keyword.Type), -            include('constants'), -            (r'[a-zA-Z_]\w*', Text), -            (r'[!<=>+*/-]', Operator), -            (r'[.;:{}(),\[\]]', Punctuation) -        ], -        'comments': [ -            (r'//(\n|[\w\W]*?[^\\]\n)', Comment.Single), -            (r'/(\\\n)?[*][\w\W]*?[*](\\\n)?/', Comment.Multiline), -            (r'/(\\\n)?[*][\w\W]*', Comment.Multiline) -        ], -        'constants': [ -            (r'("([\\]"|.)*?")', String.Double), -            (r"('([\\]'|.)*?')", String.Single), -            (r'\b0[xX][0-9a-fA-F]+\b', Number.Hex), -            (r'\b\d+\b', Number.Decimal), -        ], -        'pragma': [ -            include('whitespace'), -            include('comments'), -            (r'(\^|>=|<)(\s*)(\d+\.\d+\.\d+)', -             bygroups(Operator, Text.WhiteSpace, Keyword)), -            (r';', Punctuation, '#pop') -        ], -        'whitespace': [ -            (r'\s+', Text.WhiteSpace), -            (r'\n', Text.WhiteSpace) -        ] -    } +# -*- coding: utf-8 -*-  +"""  +    pygments.lexers.solidity  +    ~~~~~~~~~~~~~~~~~~~~~~~~  +  +    Lexers for Solidity.  +  +    :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS.  +    :license: BSD, see LICENSE for details.  +"""  +  +import re  +  +from pygments.lexer import RegexLexer, bygroups, include, words  +from pygments.token import Text, Comment, Operator, Keyword, Name, String, \  +    Number, Punctuation  +  +__all__ = ['SolidityLexer']  +  +  +class SolidityLexer(RegexLexer):  +    """  +    For Solidity source code.  +  +    .. versionadded:: 2.5  +    """  +  +    name = 'Solidity'  +    aliases = ['solidity']  +    filenames = ['*.sol']  +    mimetypes = []  +  +    flags = re.MULTILINE | re.UNICODE  +  +    datatype = (  +        r'\b(address|bool|((bytes|hash|int|string|uint)(8|16|24|32|40|48|56|64'  +        r'|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208'  +        r'|216|224|232|240|248|256)?))\b'  +    )  +  +    tokens = {  +        'root': [  +            include('whitespace'),  +            include('comments'),  +            (r'\bpragma\s+solidity\b', Keyword, 'pragma'),  +            (r'\b(contract)(\s+)([a-zA-Z_]\w*)',  +             bygroups(Keyword, Text.WhiteSpace, Name.Entity)),  +            (datatype + r'(\s+)((external|public|internal|private)\s+)?' +  +             r'([a-zA-Z_]\w*)',  +             bygroups(Keyword.Type, None, None, None, Text.WhiteSpace, Keyword,  +                      None, Name.Variable)),  +            (r'\b(enum|event|function|struct)(\s+)([a-zA-Z_]\w*)',  +             bygroups(Keyword.Type, Text.WhiteSpace, Name.Variable)),  +            (r'\b(msg|block|tx)\.([A-Za-z_][A-Za-z0-9_]*)\b', Keyword),  +            (words((  +                'block', 'break', 'constant', 'constructor', 'continue',  +                'contract', 'do', 'else', 'external', 'false', 'for',  +                'function', 'if', 'import', 'inherited', 'internal', 'is',  +                'library', 'mapping', 'memory', 'modifier', 'msg', 'new',  +                'payable', 'private', 'public', 'require', 'return',  +                'returns', 'struct', 'suicide', 'throw', 'this', 'true',  +                'tx', 'var', 'while'), prefix=r'\b', suffix=r'\b'),  +             Keyword.Type),  +            (words(('keccak256',), prefix=r'\b', suffix=r'\b'), Name.Builtin),  +            (datatype, Keyword.Type),  +            include('constants'),  +            (r'[a-zA-Z_]\w*', Text),  +            (r'[!<=>+*/-]', Operator),  +            (r'[.;:{}(),\[\]]', Punctuation)  +        ],  +        'comments': [  +            (r'//(\n|[\w\W]*?[^\\]\n)', Comment.Single),  +            (r'/(\\\n)?[*][\w\W]*?[*](\\\n)?/', Comment.Multiline),  +            (r'/(\\\n)?[*][\w\W]*', Comment.Multiline)  +        ],  +        'constants': [  +            (r'("([\\]"|.)*?")', String.Double),  +            (r"('([\\]'|.)*?')", String.Single),  +            (r'\b0[xX][0-9a-fA-F]+\b', Number.Hex),  +            (r'\b\d+\b', Number.Decimal),  +        ],  +        'pragma': [  +            include('whitespace'),  +            include('comments'),  +            (r'(\^|>=|<)(\s*)(\d+\.\d+\.\d+)',  +             bygroups(Operator, Text.WhiteSpace, Keyword)),  +            (r';', Punctuation, '#pop')  +        ],  +        'whitespace': [  +            (r'\s+', Text.WhiteSpace),  +            (r'\n', Text.WhiteSpace)  +        ]  +    }  | 
