@@ -39,17 +39,16 @@ func solidityRules() Rules {
39
39
{`/[*][\w\W]*` , CommentMultiline , nil },
40
40
},
41
41
"keywords-other" : {
42
- {Words (`` , `\b` , `for` , `in` , `while` , `do` , `break` , `return` , `returns` , `continue` , `if` , `else` , `throw` , `new` , `delete` ), Keyword , nil },
42
+ {Words (`` , `\b` , `for` , `in` , `while` , `do` , `break` , `return` , `returns` , `continue` , `if` , `else` , `try` , `catch` , ` throw` , `_` , ` new` , `delete` , `is` , `as` , `from` , `memory` , `storage ` ), Keyword , nil },
43
43
{`assembly\b` , Keyword , Push ("assembly" )},
44
- {Words (`` , `\b` , `contract` , `interface` , `enum` , `event` , `function` , `library` , `mapping` , `modifier` , `struct` , `var` ), KeywordDeclaration , nil },
44
+ {`(contract|interface|enum|event|struct)(\s+)([a-zA-Z_]\w*)` , ByGroups (KeywordDeclaration , Text , NameClass ), nil },
45
+ {`(function|modifier)(\s+)([a-zA-Z_]\w*)` , ByGroups (KeywordDeclaration , Text , NameFunction ), nil },
46
+ {Words (`` , `\b` , `contract` , `interface` , `enum` , `event` , `constructor` , `function` , `library` , `mapping` , `modifier` , `struct` , `var` ), KeywordDeclaration , nil },
47
+ {Words (`` , `\b` , `abstract` , `external` , `internal` , `private` , `public` ), Keyword , nil },
48
+ {Words (`` , `\b` , `anonymous` , `constant` , `immutable` , `indexed` , `override` , `payable` , `pure` , `view` , `virtual` ), Keyword , nil },
45
49
{`(import|using)\b` , KeywordNamespace , nil },
46
- {`pragma (solidity|experimental)\b` , KeywordReserved , nil },
47
- {`(_|as|constant|default|from|is)\b` , KeywordReserved , nil },
48
- {`payable\b` , KeywordReserved , nil },
49
- {`(memory|storage)\b` , KeywordReserved , nil },
50
- {`(external|internal|private|public)\b` , KeywordReserved , nil },
51
- {`(anonymous|indexed)\b` , KeywordReserved , nil },
52
- {`(abstract|pure|static|view)\b` , KeywordReserved , nil },
50
+ {`pragma (solidity|experimental)\b` , Keyword , nil },
51
+ {Words (`` , `\b` , `after` , `alias` , `apply` , `auto` , `case` , `copyof` , `default` , `define` , `final` , `implements` , `inline` , `let` , `macro` , `match` , `mutable` , `null` , `of` , `partial` , `promise` , `reference` , `relocatable` , `sealed` , `sizeof` , `static` , `supports` , `switch` , `typedef` , `typeof` , `unchecked` ), KeywordReserved , nil },
53
52
{`(true|false)\b` , KeywordConstant , nil },
54
53
{`(wei|finney|szabo|ether)\b` , KeywordConstant , nil },
55
54
{`(seconds|minutes|hours|days|weeks|years)\b` , KeywordConstant , nil },
@@ -99,15 +98,20 @@ func solidityRules() Rules {
99
98
{`\+\+|--|\*\*|\?|:|~|&&|\|\||=>|==?|!=?|(<<|>>>?|[-<>+*%&|^/])=?` , Operator , nil },
100
99
{`[{(\[;,]` , Punctuation , nil },
101
100
{`[})\].]` , Punctuation , nil },
102
- {`(block|msg|now|this|super|tx)\b` , NameBuiltin , nil },
103
- {`(sender|origin)\b` , NameBuiltin , nil },
104
- {`(gas|value)\b` , NameBuiltin , nil },
101
+ {`(abi|block|msg|tx)\b` , NameBuiltin , nil },
102
+ {`(?!abi\.)(decode|encode|encodePacked|encodeWithSelector|encodeWithSignature|encodeWithSelector)\b` , NameBuiltin , nil },
103
+ {`(?!block\.)(chainid|coinbase|difficulty|gaslimit|number|timestamp)\b` , NameBuiltin , nil },
104
+ {`(?!msg\.)(data|gas|sender|value)\b` , NameBuiltin , nil },
105
+ {`(?!tx\.)(gasprice|origin)\b` , NameBuiltin , nil },
106
+ {`(type)(\()([a-zA-Z_]\w*)(\))` , ByGroups (NameBuiltin , Punctuation , NameClass , Punctuation ), nil },
107
+ {`(?!type\([a-zA-Z_]\w*\)\.)(creationCode|interfaceId|max|min|name|runtimeCode)\b` , NameBuiltin , nil },
108
+ {`(now|this|super|gasleft)\b` , NameBuiltin , nil },
105
109
{`(selfdestruct|suicide)\b` , NameBuiltin , nil },
106
- {`(balance|send|transfer)\b` , NameBuiltin , nil },
110
+ {`(?!0x[0-9a-fA-F]+\.)( balance|code|codehash |send|transfer)\b` , NameBuiltin , nil },
107
111
{`(assert|revert|require)\b` , NameBuiltin , nil },
108
112
{`(call|callcode|delegatecall)\b` , NameBuiltin , nil },
109
113
{`selector\b` , NameBuiltin , nil },
110
- {`(addmod|ecrecover|keccak256|mulmod|ripemd160|sha256|sha3)\b` , NameFunction , nil },
114
+ {`(addmod|blockhash| ecrecover|keccak256|mulmod|ripemd160|sha256|sha3)\b` , NameBuiltin , nil },
111
115
{`[a-zA-Z_]\w*` , Name , nil },
112
116
},
113
117
}
0 commit comments