-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
source.zeek.js
252 lines (250 loc) · 9.29 KB
/
source.zeek.js
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/zeek/zeek-sublime>
// and licensed `bsd-3-clause`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.zeek', '.bro'],
names: ['zeek', 'bro'],
patterns: [
{
begin: '(##!|##<|##|#)',
beginCaptures: {1: {name: 'punctuation.definition.comment.zeek'}},
end: '$',
name: 'comment.line.zeek'
},
{
begin: '(\\")',
beginCaptures: {1: {name: 'punctuation.definition.string.begin.zeek'}},
end: '(\\")',
endCaptures: {1: {name: 'punctuation.definition.string.end.zeek'}},
name: 'string.quoted.double.zeek',
patterns: [
{match: '\\\\.', name: 'constant.character.escape.zeek'},
{
match: '%-?[0-9]*(\\.[0-9]+)?[DTdxsefg]',
name: 'constant.other.placeholder.zeek'
}
]
},
{
begin: '(/)(?=.*/)',
beginCaptures: {1: {name: 'punctuation.definition.string.begin.zeek'}},
end: '(/)',
endCaptures: {1: {name: 'punctuation.definition.string.end.zeek'}},
name: 'string.regexp.zeek',
patterns: [{match: '\\\\.', name: 'constant.character.escape.zeek'}]
},
{
captures: {1: {name: 'keyword.other.zeek'}},
match: '(@(load-plugin|load-sigs|load|unload)).*$',
name: 'meta.preprocessor.zeek'
},
{
captures: {1: {name: 'keyword.other.zeek'}},
match: '(@(DEBUG|DIR|FILENAME|deprecated|if|ifdef|ifndef|else|endif))',
name: 'meta.preprocessor.zeek'
},
{
captures: {
1: {name: 'keyword.other.zeek'},
2: {name: 'keyword.operator.zeek'}
},
match: '(@prefixes)\\s*(\\+?=).*$',
name: 'meta.preprocessor.zeek'
},
{
match:
'\\&\\b(redef|priority|log|optional|default|add_func|delete_func|expire_func|read_expire|write_expire|create_expire|synchronized|persistent|rotate_interval|rotate_size|encrypt|raw_output|mergeable|error_handler|type_column|deprecated|on_change|backend|broker_store|broker_allow_complex_type|is_assigned|is_used)\\b',
name: 'storage.modifier.attribute.zeek'
},
{match: '\\b(T|F)\\b', name: 'constant.language.zeek'},
{
match: '\\b\\d{1,5}/(udp|tcp|icmp|unknown)\\b',
name: 'constant.numeric.port.zeek'
},
{
match:
'\\b(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[0-9]{1,2})\\.(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[0-9]{1,2})\\.(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[0-9]{1,2})\\.(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[0-9]{1,2})\\b',
name: 'constant.numeric.addr.zeek'
},
{
match:
'\\[([0-9a-fA-F]{0,4}:){2,7}([0-9a-fA-F]{0,4})?((25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[0-9]{1,2})\\.(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[0-9]{1,2})\\.(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[0-9]{1,2})\\.(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[0-9]{1,2}))?\\]',
name: 'constant.numeric.addr.zeek'
},
{
match:
'(((?:(\\d*\\.\\d*)([eE][+-]?\\d+)?)|(?:(\\d*)([eE][+-]?\\d+))|(?:(\\d*\\.\\d*)))|\\d+)\\s*(day|hr|min|msec|usec|sec)s?',
name: 'constant.numeric.float.decimal.interval.zeek'
},
{
match:
'((?:(\\d*\\.\\d*)([eE][+-]?\\d+)?)|(?:(\\d*)([eE][+-]?\\d+))|(?:(\\d*\\.\\d*)))',
name: 'constant.numeric.float.decimal.zeek'
},
{
match:
'\\b(([A-Za-z0-9][A-Za-z0-9\\-]*)(?:\\.([A-Za-z0-9][A-Za-z0-9\\-]*))+)\\b',
name: 'constant.numeric.hostname.zeek'
},
{
match: '\\b(0x[0-9a-fA-F]+)\\b',
name: 'constant.numeric.integer.hexadecimal.zeek'
},
{match: '\\b(\\d+)\\b', name: 'constant.numeric.integer.decimal.zeek'},
{match: '(==)|(!=)|(<=)|(<)|(>=)|(>)', name: 'keyword.operator.zeek'},
{match: '(&&)|(||)|(!)', name: 'keyword.operator.zeek'},
{match: '(=)|(\\+=)|(-=)', name: 'keyword.operator.zeek'},
{
match: '(\\+\\+)|(\\+)|(--)|(-)|(\\*)|(/)|(%)',
name: 'keyword.operator.zeek'
},
{match: '(&)|(\\|)|(\\^)|(~)', name: 'keyword.operator.zeek'},
{match: '\\b(in|as|is)\\b', name: 'keyword.operator.zeek'},
{match: ';', name: 'punctuation.terminator.zeek'},
{match: '\\??\\$', name: 'punctuation.accessor.zeek'},
{match: '::', name: 'punctuation.accessor.zeek'},
{match: '(\\?)', name: 'keyword.operator.zeek'},
{match: '(?<=\\S)(:)', name: 'punctuation.separator.zeek'},
{match: '(,)', name: 'punctuation.separator.zeek'},
{match: '(:)', name: 'keyword.operator.zeek'},
{
captures: {
1: {name: 'keyword.other.zeek'},
2: {name: 'entity.name.namespace.zeek'}
},
match:
'(module)\\s+(([A-Za-z_][A-Za-z_0-9]*)(?:::([A-Za-z_][A-Za-z_0-9]*))*)',
name: 'meta.namespace.zeek'
},
{match: '\\b(export)\\b', name: 'keyword.other.zeek'},
{match: '\\b(if|else)\\b', name: 'keyword.control.conditional.zeek'},
{match: '\\b(for|while)\\b', name: 'keyword.control.zeek'},
{
match: '\\b(return|break|next|continue|fallthrough)\\b',
name: 'keyword.control.zeek'
},
{match: '\\b(switch|default|case)\\b', name: 'keyword.control.zeek'},
{match: '\\b(add|delete|copy)\\b', name: 'keyword.other.zeek'},
{match: '\\b(print)\\b', name: 'keyword.other.zeek'},
{match: '\\b(when|timeout|schedule)\\b', name: 'keyword.control.zeek'},
{
captures: {
1: {name: 'keyword.other.zeek'},
2: {name: 'entity.name.struct.record.zeek'},
3: {name: 'punctuation.separator.zeek'},
4: {
name: 'storage.type.struct.record.zeek keyword.declaration.struct.record.zeek'
}
},
match:
'\\b(type)\\s+((?:[A-Za-z_][A-Za-z_0-9]*)(?:::(?:[A-Za-z_][A-Za-z_0-9]*))*)\\s*(:)\\s*\\b(record)\\b',
name: 'meta.struct.record.zeek'
},
{
captures: {
1: {name: 'keyword.other.zeek'},
2: {name: 'entity.name.enum.zeek'},
3: {name: 'punctuation.separator.zeek'},
4: {name: 'storage.type.enum.zeek keyword.declaration.enum.zeek'}
},
match:
'\\b(type)\\s+((?:[A-Za-z_][A-Za-z_0-9]*)(?:::(?:[A-Za-z_][A-Za-z_0-9]*))*)\\s*(:)\\s*\\b(enum)\\b',
name: 'meta.enum.zeek'
},
{
captures: {
1: {name: 'keyword.other.zeek'},
2: {name: 'entity.name.type.zeek'},
3: {name: 'punctuation.separator.zeek'}
},
match:
'\\b(type)\\s+((?:[A-Za-z_][A-Za-z_0-9]*)(?:::(?:[A-Za-z_][A-Za-z_0-9]*))*)\\s*(:)',
name: 'meta.type.zeek'
},
{
captures: {
1: {name: 'keyword.other.zeek'},
2: {
name: 'storage.type.struct.record.zeek keyword.declaration.struct.record.zeek'
},
3: {name: 'entity.name.struct.record.zeek'}
},
match:
'\\b(redef)\\s+(record)\\s+((?:[A-Za-z_][A-Za-z_0-9]*)(?:::(?:[A-Za-z_][A-Za-z_0-9]*))*)\\b',
name: 'meta.struct.record.zeek'
},
{
captures: {
1: {name: 'keyword.other.zeek'},
2: {name: 'storage.type.enum.zeek keyword.declaration.enum.zeek'},
3: {name: 'entity.name.enum.zeek'}
},
match:
'\\b(redef)\\s+(enum)\\s+((?:[A-Za-z_][A-Za-z_0-9]*)(?:::(?:[A-Za-z_][A-Za-z_0-9]*))*)\\b',
name: 'meta.enum.zeek'
},
{
captures: {
1: {name: 'storage.type.zeek'},
2: {name: 'entity.name.function.event.zeek'}
},
match:
'\\b(event)\\s+((?:[A-Za-z_][A-Za-z_0-9]*)(?:::(?:[A-Za-z_][A-Za-z_0-9]*))*)(?=\\s*\\()'
},
{
captures: {
1: {name: 'storage.type.zeek'},
2: {name: 'entity.name.function.hook.zeek'}
},
match:
'\\b(hook)\\s+((?:[A-Za-z_][A-Za-z_0-9]*)(?:::(?:[A-Za-z_][A-Za-z_0-9]*))*)(?=\\s*\\()'
},
{
captures: {
1: {name: 'storage.type.zeek'},
2: {name: 'entity.name.function.zeek'}
},
match:
'\\b(function)\\s+((?:[A-Za-z_][A-Za-z_0-9]*)(?:::(?:[A-Za-z_][A-Za-z_0-9]*))*)(?=\\s*\\()'
},
{match: '\\b(redef)\\b', name: 'keyword.other.zeek'},
{match: '\\b(any)\\b', name: 'storage.type.zeek'},
{match: '\\b(enum|record|set|table|vector)\\b', name: 'storage.type.zeek'},
{
captures: {
1: {name: 'storage.type.zeek'},
2: {name: 'keyword.operator.zeek'},
3: {name: 'storage.type.zeek'}
},
match:
'\\b(opaque)\\s+(of)\\s+((?:[A-Za-z_][A-Za-z_0-9]*)(?:::(?:[A-Za-z_][A-Za-z_0-9]*))*)\\b'
},
{match: '\\b(of)\\b', name: 'keyword.operator.zeek'},
{
match:
'\\b(addr|bool|count|double|file|int|interval|pattern|port|string|subnet|time)\\b',
name: 'storage.type.zeek'
},
{match: '\\b(function|hook|event)\\b', name: 'storage.type.zeek'},
{match: '\\b(global|local|const|option)\\b', name: 'storage.modifier.zeek'},
{
match:
'\\b((?:[A-Za-z_][A-Za-z_0-9]*)(?:::(?:[A-Za-z_][A-Za-z_0-9]*))*)(?=\\s*\\()',
name: 'entity.name.function.call.zeek'
},
{match: '\\{', name: 'punctuation.section.block.begin.zeek'},
{match: '\\}', name: 'punctuation.section.block.end.zeek'},
{match: '\\[', name: 'punctuation.section.brackets.begin.zeek'},
{match: '\\]', name: 'punctuation.section.brackets.end.zeek'},
{match: '\\(', name: 'punctuation.section.parens.begin.zeek'},
{match: '\\)', name: 'punctuation.section.parens.end.zeek'}
],
scopeName: 'source.zeek'
}
export default grammar