diff options
Diffstat (limited to 'pygments/lexers/solidity.py')
-rw-r--r-- | pygments/lexers/solidity.py | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/pygments/lexers/solidity.py b/pygments/lexers/solidity.py index f47887d6..af0672ee 100644 --- a/pygments/lexers/solidity.py +++ b/pygments/lexers/solidity.py @@ -13,7 +13,7 @@ import re from pygments.lexer import RegexLexer, bygroups, include, words from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ - Number, Punctuation + Number, Punctuation, Whitespace __all__ = ['SolidityLexer'] @@ -33,7 +33,7 @@ class SolidityLexer(RegexLexer): flags = re.MULTILINE | re.UNICODE datatype = ( - r'\b(address|bool|((bytes|hash|int|string|uint)(8|16|24|32|40|48|56|64' + 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' ) @@ -44,14 +44,13 @@ class SolidityLexer(RegexLexer): 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+)?' + + bygroups(Keyword, 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)), + bygroups(Keyword.Type, Whitespace, Keyword, 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_]\w*)\b', Keyword), + bygroups(Keyword.Type, 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', @@ -83,11 +82,11 @@ class SolidityLexer(RegexLexer): include('whitespace'), include('comments'), (r'(\^|>=|<)(\s*)(\d+\.\d+\.\d+)', - bygroups(Operator, Text.WhiteSpace, Keyword)), + bygroups(Operator, Whitespace, Keyword)), (r';', Punctuation, '#pop') ], 'whitespace': [ - (r'\s+', Text.WhiteSpace), - (r'\n', Text.WhiteSpace) + (r'\s+', Whitespace), + (r'\n', Whitespace) ] } |