-
Notifications
You must be signed in to change notification settings - Fork 42
/
Yul.YAML-tmLanguage
192 lines (187 loc) · 7.11 KB
/
Yul.YAML-tmLanguage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# [PackageDev] target_format: plist, ext: tmLanguage
---
name: Yul
scopeName: source.yul
fileTypes: [yul, yulp]
uuid: ad87d2cd-8575-4afe-984e-9421a3788913
patterns:
- match: \/\/.*
name: comment
comment: Comments
- begin: (\/\*)
end: (\*\/)
name: comment
comment: Multiline comments
- match: \b(event|enum)\s+([A-Za-z_]\w*)\b
name: keyword
captures:
'2': {name: entity.name.function}
comment: Events
# we need this because of multiline!
- name: scope
#contentName: string.other.ssraw
begin: \b(object)\s+(\"[A-Za-z_]\w*\")(?:\s+(is)\s+)?
beginCaptures:
'1': {name: keyword}
'2': {name: string.quoted}
'3': {name: keyword}
end: \{
patterns:
#- include: $self
- name: string.quoted
match: '\"[A-Za-z_]\w*\"'
# contract Derived1 is Base(7) {
- include: "#numbers"
# - match: \b(contract|interface|library)\s+([A-Za-z_]\w*)(?:\s+(is)\s+((?:[A-Za-z_]\w*\,?\s*)*))?\b
# name: keyword
# captures:
# '1': {name: keyword}
# '2': {name: entity.name.function}
# '3': {name: keyword}
# '4': {name: entity.name.function}
# comment: Structures, function, event definitions
- match: \b(constructor|error|using|struct|type|modifier|fallback)(\s+[A-Za-z_]\w*)?\b
name: keyword
captures:
'2': {name: entity.name.function}
comment: Structures, function, event definitions
- match: \b(function)(\s+[A-Za-z_]\w*)?\b
name: keyword
captures:
'2': {name: entity.name.function}
comment: Structures, function, event definitions
# - match: \.(length|selector)\b
- match: \.(selector)\b
captures:
'1': {name: markup.italic}
comment: Special treatment for length and .selector
- match: \bthis\b
name: markup.italic
comment: this
- match: \bsuper\b
name: markup.italic
comment: Special treatment for "super"
- match: \b(address(?:\s+payable)?|string|bytes?\d*|int\d*|uint\d*|bool|u?fixed\d+x\d+)\s*(?:\[(\d*)\])?\s*(?:\[(\d*)\])?\s*(?:(indexed|memory|storage|calldata|payable|immutable)?\s*(\b[A-Za-z_]\w*)?\s*)?(?=[,\)\n])
captures:
'1': {name: constant.language}
'2': {name: constant.numeric}
'3': {name: constant.numeric}
'4': {name: keyword}
'5': {name: variable.parameter} # variable.parameter
comment: Built-in types function arguments
- match: \b(?:(indexed|memory|storage|calldata|payable|immutable)\s*(\b[A-Za-z_]\w*)?\s*)(?=[,\)\n])
captures:
'1': {name: keyword}
'2': {name: variable.parameter} # variable.parameter
comment: Other types function arguments, like structs... but can only detect them if they have a modifier, example -- function witness(instance memory w, instance memory a, instance memory a1, instance memory a1_odd, uint k)
- match: \b(true|false)\b
name: constant.language
comment: True and false keywords
- match: \b(address(?:\s*payable)?|string|bytes?\d*|int\d*|uint\d*|bool|u?fixed\d+x\d+)\b(?:(?:\s*\[(\d*)\])?(?:\s*\[(\d*)\])?(?:\s*\[(\d*)\])?\s*((?:private\s|public\s|internal\s|external\s|constant\s|immutable\s|memory\s|storage\s)*)\s*(?:[A-Za-z_]\w*)\s*(\=))?
captures:
'1': {name: constant.language}
'2': {name: constant.numeric}
'3': {name: constant.numeric}
'4': {name: constant.numeric}
'5': {name: keyword}
'6': {name: keyword}
comment: Variable definitions - bytes data; | uint x = uint(y); BUT also just appearances of basic types anywhere... good example -- "using SafeMath for uint256;"
- match: \b(payable)\s*\(
captures:
'1': {name: constant.language}
comment: Type conversion payable(...)
- match: \b(from)\s*(?=[\'\"])
captures:
'1': {name: keyword}
comment: import ... from
- match: \b(?:[A-Za-z_]\w*)\s+(as)\s+(?:[A-Za-z_]\w*)
captures:
'1': {name: keyword}
comment: import {Unauthorized, add as func, Point} from "./Foo.sol";
- match: \b(global); # using {plusOne, minusOne} for RestrictedNumber global;
captures:
'1': {name: keyword}
comment: import ... from
- match: \b(var|solidity|constant|pragma\s*(?:experimental|abicoder)?|code|data|hex|import|const|mstruct|mapping|payable|storage|memory|calldata|if|else|for|while|do|break|continue|returns?|try|catch|private|public|pure|view|internal|immutable|external|virtual|override|abstract|suicide|emit|is|throw|revert|assert|require|receive|delete)\b
name: keyword
comment: Langauge keywords
- include: "#numbers"
- match: \b(0[xX][a-fA-F0-9]+)\b
name: constant.numeric
comment: Hexadecimal
- match: (=|:=|!|>|<|\||&|\?|\^|~|\*|\+|\-|\/|\%)
name: keyword.operator
comment: Operators
- match: (\bhex\b|\bunicode\b)
name: markup.italic
comment: Operators
- match: \s\:\s
name: keyword.operator
comment: Ternary colon
- match: \bnow\b
name: support.type
comment: Now - it was removed in solidity 0.4 but we still include it because some old contracts use it
- match: \b_;
name: keyword
comment: modifier placeholder statement
#One novel construct found in Solidity is the placeholder statement _;. It may
#appear only in function modifiers, where it denotes the point of entry into the
#next modifier or the function body.
- match: \b(msg|block|tx)\.([A-Za-z_]\w*)\b
captures:
'1': {name: support.type}
'2': {name: support.type}
comment: msg and block special usage
- match: \b(abi)\.([A-Za-z_]\w*)\b
name: support.type
comment: abi functions
#we don't do this anymore, esp since we cannot distinguish between assembly and normal function.. and
# don't want addmod etc. to be italic in assembly since it's a normal opcode, should be the same as other opcodes
# - match: \b(addmod|mulmod|keccak256|sha256|sha3|ripemd160|ecrecover)\s*\(
- match: \b(blockhash|gasleft)\s*\(
captures:
'1': {name: support.type}
comment: Function call - some special built-in functions
# - match: \.(call|delegatecall|staticcall)\s*[\(\{]
# captures:
# '1': {name: markup.italic}
# comment: Function call - smart contract calls, also special params call{...}()
- match: \b([A-Za-z_]\w*)(?:\s*\[(\d*)\]\s*)?(?:\s*\[(\d*)\]\s*)?\(
captures:
'1': {name: entity.name.function}
'2': {name: constant.numeric}
'3': {name: constant.numeric}
comment: Function call, also for example - info.factories = new Factory[](factoryAddresses.length);
- match: (?:\.|(new\s+))([A-Za-z_]\w*)\{
captures:
'1': {name: keyword}
'2': {name: entity.name.function}
comment: Special parameters IWETH(wavaxTokenAddress).deposit{ ... }(); ... new UniswapV3Pool{...}() https://docs.soliditylang.org/en/v0.8.11/control-structures.html#external-function-calls , https://docs.soliditylang.org/en/v0.8.11/control-structures.html#creating-contracts-via-new
- match: \b(wei|gwei|ether|seconds|minutes|hours|days|weeks)\b
captures:
'1': {name: support.type}
comment: Ether and time units
- match: \bnew\b
name: keyword
comment: New
- match: \banonymous\b
name: keyword
comment: Event
- match: \bunchecked\b
name: keyword
comment: Unchecked
- match: \b(assembly|switch|let|case|default)\b
name: keyword
comment: Assembly stuff
- match: ([\"].*?[\"])
name: string.quoted
comment: Strings
- match: ([\'].*?[\'])
name: string.quoted
comment: Strings
repository:
numbers:
patterns:
- match: \b(?:[+-]?\.?\d[\d_eE]*)(?:\.\d+[\deE]*)?\b
name: constant.numeric
comment: Numbers, possibly with scientific notation