1
|
ace.define("ace/mode/zeek_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
2
|
"use strict";
|
3
|
|
4
|
var oop = require("../lib/oop");
|
5
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
6
|
|
7
|
var ZeekHighlightRules = function() {
|
8
|
|
9
|
this.$rules = {
|
10
|
"start": [
|
11
|
{
|
12
|
token: "comment.line",
|
13
|
regex: "#.*$"
|
14
|
},
|
15
|
{
|
16
|
token: "string.double",
|
17
|
regex: /"/,
|
18
|
next: "string-state"
|
19
|
},
|
20
|
{
|
21
|
token: "string.regexp",
|
22
|
regex: "(/)(?=.*/)",
|
23
|
next: "pattern-state"
|
24
|
},
|
25
|
{
|
26
|
token: ["keyword.other", "meta.preprocessor"],
|
27
|
regex: /(@(?:load-plugin|load-sigs|load|unload))(.*$)/
|
28
|
},
|
29
|
{
|
30
|
token: "keyword.other",
|
31
|
regex: /@(?:DEBUG|DIR|FILENAME|deprecated|if|ifdef|ifndef|else|endif)/
|
32
|
},
|
33
|
{
|
34
|
token: [
|
35
|
"keyword.other",
|
36
|
"meta.preprocessor",
|
37
|
"keyword.operator",
|
38
|
"meta.preprocessor"
|
39
|
],
|
40
|
regex: /(@prefixes)(\s*)(\+?=)(.*$)/
|
41
|
},
|
42
|
{
|
43
|
token: "storage.modifier.attribute",
|
44
|
regex: /\&\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)\b/
|
45
|
},
|
46
|
{
|
47
|
token: "constant.language",
|
48
|
regex: /\b(?:T|F)\b/
|
49
|
},
|
50
|
{
|
51
|
token: "constant.numeric.port",
|
52
|
regex: /\b\d{1,5}\/(?:udp|tcp|icmp|unknown)\b/
|
53
|
},
|
54
|
{
|
55
|
token: "constant.numeric.addr",
|
56
|
regex: /\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/,
|
57
|
comment: "IPv4 address"
|
58
|
},
|
59
|
{
|
60
|
token: "constant.numeric.addr",
|
61
|
regex: /\[(?:[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}))?\]/,
|
62
|
comment: "IPv6 address"
|
63
|
},
|
64
|
{
|
65
|
token: "constant.numeric.float.decimal.interval",
|
66
|
regex: /(?:(?:\d*\.\d*(?:[eE][+-]?\d+)?|\d*[eE][+-]?\d+|\d*\.\d*)|\d+)\s*(?:day|hr|min|msec|usec|sec)s?/
|
67
|
},
|
68
|
{
|
69
|
token: "constant.numeric.float.decimal",
|
70
|
regex: /\d*\.\d*(?:[eE][+-]?\d+)?|\d*[eE][+-]?\d+|\d*\.\d*/
|
71
|
},
|
72
|
{
|
73
|
token: "constant.numeric.hostname",
|
74
|
regex: /\b[A-Za-z0-9][A-Za-z0-9\-]*(?:\.[A-Za-z0-9][A-Za-z0-9\-]*)+\b/
|
75
|
},
|
76
|
{
|
77
|
token: "constant.numeric.integer.hexadecimal",
|
78
|
regex: /\b0x[0-9a-fA-F]+\b/
|
79
|
},
|
80
|
{
|
81
|
token: "constant.numeric.integer.decimal",
|
82
|
regex: /\b\d+\b/
|
83
|
},
|
84
|
{
|
85
|
token: "keyword.operator",
|
86
|
regex: /==|!=|<=|<|>=|>/
|
87
|
},
|
88
|
{
|
89
|
token: "keyword.operator",
|
90
|
regex: /(&&)|(\|\|)|(!)/
|
91
|
},
|
92
|
{
|
93
|
token: "keyword.operator",
|
94
|
regex: /=|\+=|-=/
|
95
|
},
|
96
|
{
|
97
|
token: "keyword.operator",
|
98
|
regex: /\+\+|\+|--|-|\*|\/|%/
|
99
|
},
|
100
|
{
|
101
|
token: "keyword.operator",
|
102
|
regex: /&|\||\^|~/
|
103
|
},
|
104
|
{
|
105
|
token: "keyword.operator",
|
106
|
regex: /\b(?:in|as|is)\b/
|
107
|
},
|
108
|
{
|
109
|
token: "punctuation.terminator",
|
110
|
regex: /;/
|
111
|
},
|
112
|
{
|
113
|
token: "punctuation.accessor",
|
114
|
regex: /\??\$/
|
115
|
},
|
116
|
{
|
117
|
token: "punctuation.accessor",
|
118
|
regex: /::/
|
119
|
},
|
120
|
{
|
121
|
token: "keyword.operator",
|
122
|
regex: /\?/
|
123
|
},
|
124
|
{
|
125
|
token: "punctuation.separator",
|
126
|
regex: /:/
|
127
|
},
|
128
|
{
|
129
|
token: "punctuation.separator",
|
130
|
regex: /,/
|
131
|
},
|
132
|
{
|
133
|
token: [
|
134
|
"keyword.other",
|
135
|
"meta.namespace",
|
136
|
"entity.name.namespace"
|
137
|
],
|
138
|
regex: /(module)(\s+)([A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*)/
|
139
|
},
|
140
|
{
|
141
|
token: "keyword.other",
|
142
|
regex: /\bexport\b/
|
143
|
},
|
144
|
{
|
145
|
token: "keyword.control.conditional",
|
146
|
regex: /\b(?:if|else)\b/
|
147
|
},
|
148
|
{
|
149
|
token: "keyword.control",
|
150
|
regex: /\b(?:for|while)\b/
|
151
|
},
|
152
|
{
|
153
|
token: "keyword.control",
|
154
|
regex: /\b(?:return|break|next|continue|fallthrough)\b/
|
155
|
},
|
156
|
{
|
157
|
token: "keyword.control",
|
158
|
regex: /\b(?:switch|default|case)\b/
|
159
|
},
|
160
|
{
|
161
|
token: "keyword.other",
|
162
|
regex: /\b(?:add|delete)\b/
|
163
|
},
|
164
|
{
|
165
|
token: "keyword.other",
|
166
|
regex: /\bprint\b/
|
167
|
},
|
168
|
{
|
169
|
token: "keyword.control",
|
170
|
regex: /\b(?:when|timeout|schedule)\b/
|
171
|
},
|
172
|
{
|
173
|
token: [
|
174
|
"keyword.other",
|
175
|
"meta.struct.record",
|
176
|
"entity.name.struct.record",
|
177
|
"meta.struct.record",
|
178
|
"punctuation.separator",
|
179
|
"meta.struct.record",
|
180
|
"storage.type.struct.record"
|
181
|
],
|
182
|
regex: /\b(type)(\s+)([A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*)(\s*)(:)(\s*\b)(record)\b/
|
183
|
},
|
184
|
{
|
185
|
token: [
|
186
|
"keyword.other",
|
187
|
"meta.enum",
|
188
|
"entity.name.enum",
|
189
|
"meta.enum",
|
190
|
"punctuation.separator",
|
191
|
"meta.enum",
|
192
|
"storage.type.enum"
|
193
|
],
|
194
|
regex: /\b(type)(\s+)([A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*)(\s*)(:)(\s*\b)(enum)\b/
|
195
|
},
|
196
|
{
|
197
|
token: [
|
198
|
"keyword.other",
|
199
|
"meta.type",
|
200
|
"entity.name.type",
|
201
|
"meta.type",
|
202
|
"punctuation.separator"
|
203
|
],
|
204
|
regex: /\b(type)(\s+)([A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*)(\s*)(:)/
|
205
|
},
|
206
|
{
|
207
|
token: [
|
208
|
"keyword.other",
|
209
|
"meta.struct.record",
|
210
|
"storage.type.struct.record",
|
211
|
"meta.struct.record",
|
212
|
"entity.name.struct.record"
|
213
|
],
|
214
|
regex: /\b(redef)(\s+)(record)(\s+)([A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*)\b/
|
215
|
},
|
216
|
{
|
217
|
token: [
|
218
|
"keyword.other",
|
219
|
"meta.enum",
|
220
|
"storage.type.enum",
|
221
|
"meta.enum",
|
222
|
"entity.name.enum"
|
223
|
],
|
224
|
regex: /\b(redef)(\s+)(enum)(\s+)([A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*)\b/
|
225
|
},
|
226
|
{
|
227
|
token: [
|
228
|
"storage.type",
|
229
|
"text",
|
230
|
"entity.name.function.event"
|
231
|
],
|
232
|
regex: /\b(event)(\s+)([A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*)(?=s*\()/
|
233
|
},
|
234
|
{
|
235
|
token: [
|
236
|
"storage.type",
|
237
|
"text",
|
238
|
"entity.name.function.hook"
|
239
|
],
|
240
|
regex: /\b(hook)(\s+)([A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*)(?=s*\()/
|
241
|
},
|
242
|
{
|
243
|
token: [
|
244
|
"storage.type",
|
245
|
"text",
|
246
|
"entity.name.function"
|
247
|
],
|
248
|
regex: /\b(function)(\s+)([A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*)(?=s*\()/
|
249
|
},
|
250
|
{
|
251
|
token: "keyword.other",
|
252
|
regex: /\bredef\b/
|
253
|
},
|
254
|
{
|
255
|
token: "storage.type",
|
256
|
regex: /\bany\b/
|
257
|
},
|
258
|
{
|
259
|
token: "storage.type",
|
260
|
regex: /\b(?:enum|record|set|table|vector)\b/
|
261
|
},
|
262
|
{
|
263
|
token: [
|
264
|
"storage.type",
|
265
|
"text",
|
266
|
"keyword.operator",
|
267
|
"text",
|
268
|
"storage.type"
|
269
|
],
|
270
|
regex: /\b(opaque)(\s+)(of)(\s+)([A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*)\b/
|
271
|
},
|
272
|
{
|
273
|
token: "keyword.operator",
|
274
|
regex: /\bof\b/
|
275
|
},
|
276
|
{
|
277
|
token: "storage.type",
|
278
|
regex: /\b(?:addr|bool|count|double|file|int|interval|pattern|port|string|subnet|time)\b/
|
279
|
},
|
280
|
{
|
281
|
token: "storage.type",
|
282
|
regex: /\b(?:function|hook|event)\b/
|
283
|
},
|
284
|
{
|
285
|
token: "storage.modifier",
|
286
|
regex: /\b(?:global|local|const|option)\b/
|
287
|
},
|
288
|
{
|
289
|
token: "entity.name.function.call",
|
290
|
regex: /\b[A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*(?=s*\()/
|
291
|
},
|
292
|
{
|
293
|
token: "punctuation.section.block.begin",
|
294
|
regex: /\{/
|
295
|
},
|
296
|
{
|
297
|
token: "punctuation.section.block.end",
|
298
|
regex: /\}/
|
299
|
},
|
300
|
{
|
301
|
token: "punctuation.section.brackets.begin",
|
302
|
regex: /\[/
|
303
|
},
|
304
|
{
|
305
|
token: "punctuation.section.brackets.end",
|
306
|
regex: /\]/
|
307
|
},
|
308
|
{
|
309
|
token: "punctuation.section.parens.begin",
|
310
|
regex: /\(/
|
311
|
},
|
312
|
{
|
313
|
token: "punctuation.section.parens.end",
|
314
|
regex: /\)/
|
315
|
}
|
316
|
|
317
|
], // state: start
|
318
|
|
319
|
"string-state": [
|
320
|
{
|
321
|
token: "constant.character.escape",
|
322
|
regex: /\\./
|
323
|
},
|
324
|
{
|
325
|
token: "string.double",
|
326
|
regex: /"/,
|
327
|
next: "start"
|
328
|
},
|
329
|
{
|
330
|
token: "constant.other.placeholder",
|
331
|
regex: /%-?[0-9]*(\.[0-9]+)?[DTdxsefg]/
|
332
|
},
|
333
|
{
|
334
|
token: "string.double",
|
335
|
regex: "."
|
336
|
}
|
337
|
], // state: string-state
|
338
|
|
339
|
"pattern-state": [
|
340
|
{
|
341
|
token: "constant.character.escape",
|
342
|
regex: /\\./
|
343
|
},
|
344
|
{
|
345
|
token: "string.regexp",
|
346
|
regex: "/",
|
347
|
next: "start"
|
348
|
},
|
349
|
{
|
350
|
token: "string.regexp",
|
351
|
regex: "."
|
352
|
}
|
353
|
] // state: pattern-state
|
354
|
|
355
|
};
|
356
|
|
357
|
this.normalizeRules();
|
358
|
};
|
359
|
|
360
|
ZeekHighlightRules.metaData = {
|
361
|
fileTypes: ["bro", "zeek"],
|
362
|
name: "Zeek",
|
363
|
scopeName: "source.zeek"
|
364
|
};
|
365
|
|
366
|
|
367
|
oop.inherits(ZeekHighlightRules, TextHighlightRules);
|
368
|
|
369
|
exports.ZeekHighlightRules = ZeekHighlightRules;
|
370
|
});
|
371
|
|
372
|
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
373
|
"use strict";
|
374
|
|
375
|
var oop = require("../../lib/oop");
|
376
|
var Range = require("../../range").Range;
|
377
|
var BaseFoldMode = require("./fold_mode").FoldMode;
|
378
|
|
379
|
var FoldMode = exports.FoldMode = function(commentRegex) {
|
380
|
if (commentRegex) {
|
381
|
this.foldingStartMarker = new RegExp(
|
382
|
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
383
|
);
|
384
|
this.foldingStopMarker = new RegExp(
|
385
|
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
386
|
);
|
387
|
}
|
388
|
};
|
389
|
oop.inherits(FoldMode, BaseFoldMode);
|
390
|
|
391
|
(function() {
|
392
|
|
393
|
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
394
|
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
395
|
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
396
|
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
397
|
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
398
|
this._getFoldWidgetBase = this.getFoldWidget;
|
399
|
this.getFoldWidget = function(session, foldStyle, row) {
|
400
|
var line = session.getLine(row);
|
401
|
|
402
|
if (this.singleLineBlockCommentRe.test(line)) {
|
403
|
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
404
|
return "";
|
405
|
}
|
406
|
|
407
|
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
408
|
|
409
|
if (!fw && this.startRegionRe.test(line))
|
410
|
return "start"; // lineCommentRegionStart
|
411
|
|
412
|
return fw;
|
413
|
};
|
414
|
|
415
|
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
416
|
var line = session.getLine(row);
|
417
|
|
418
|
if (this.startRegionRe.test(line))
|
419
|
return this.getCommentRegionBlock(session, line, row);
|
420
|
|
421
|
var match = line.match(this.foldingStartMarker);
|
422
|
if (match) {
|
423
|
var i = match.index;
|
424
|
|
425
|
if (match[1])
|
426
|
return this.openingBracketBlock(session, match[1], row, i);
|
427
|
|
428
|
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
429
|
|
430
|
if (range && !range.isMultiLine()) {
|
431
|
if (forceMultiline) {
|
432
|
range = this.getSectionRange(session, row);
|
433
|
} else if (foldStyle != "all")
|
434
|
range = null;
|
435
|
}
|
436
|
|
437
|
return range;
|
438
|
}
|
439
|
|
440
|
if (foldStyle === "markbegin")
|
441
|
return;
|
442
|
|
443
|
var match = line.match(this.foldingStopMarker);
|
444
|
if (match) {
|
445
|
var i = match.index + match[0].length;
|
446
|
|
447
|
if (match[1])
|
448
|
return this.closingBracketBlock(session, match[1], row, i);
|
449
|
|
450
|
return session.getCommentFoldRange(row, i, -1);
|
451
|
}
|
452
|
};
|
453
|
|
454
|
this.getSectionRange = function(session, row) {
|
455
|
var line = session.getLine(row);
|
456
|
var startIndent = line.search(/\S/);
|
457
|
var startRow = row;
|
458
|
var startColumn = line.length;
|
459
|
row = row + 1;
|
460
|
var endRow = row;
|
461
|
var maxRow = session.getLength();
|
462
|
while (++row < maxRow) {
|
463
|
line = session.getLine(row);
|
464
|
var indent = line.search(/\S/);
|
465
|
if (indent === -1)
|
466
|
continue;
|
467
|
if (startIndent > indent)
|
468
|
break;
|
469
|
var subRange = this.getFoldWidgetRange(session, "all", row);
|
470
|
|
471
|
if (subRange) {
|
472
|
if (subRange.start.row <= startRow) {
|
473
|
break;
|
474
|
} else if (subRange.isMultiLine()) {
|
475
|
row = subRange.end.row;
|
476
|
} else if (startIndent == indent) {
|
477
|
break;
|
478
|
}
|
479
|
}
|
480
|
endRow = row;
|
481
|
}
|
482
|
|
483
|
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
484
|
};
|
485
|
this.getCommentRegionBlock = function(session, line, row) {
|
486
|
var startColumn = line.search(/\s*$/);
|
487
|
var maxRow = session.getLength();
|
488
|
var startRow = row;
|
489
|
|
490
|
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
491
|
var depth = 1;
|
492
|
while (++row < maxRow) {
|
493
|
line = session.getLine(row);
|
494
|
var m = re.exec(line);
|
495
|
if (!m) continue;
|
496
|
if (m[1]) depth--;
|
497
|
else depth++;
|
498
|
|
499
|
if (!depth) break;
|
500
|
}
|
501
|
|
502
|
var endRow = row;
|
503
|
if (endRow > startRow) {
|
504
|
return new Range(startRow, startColumn, endRow, line.length);
|
505
|
}
|
506
|
};
|
507
|
|
508
|
}).call(FoldMode.prototype);
|
509
|
|
510
|
});
|
511
|
|
512
|
ace.define("ace/mode/zeek",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/zeek_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module) {
|
513
|
"use strict";
|
514
|
|
515
|
var oop = require("../lib/oop");
|
516
|
var TextMode = require("./text").Mode;
|
517
|
var ZeekHighlightRules = require("./zeek_highlight_rules").ZeekHighlightRules;
|
518
|
var FoldMode = require("./folding/cstyle").FoldMode;
|
519
|
|
520
|
var Mode = function() {
|
521
|
this.HighlightRules = ZeekHighlightRules;
|
522
|
this.foldingRules = new FoldMode();
|
523
|
};
|
524
|
oop.inherits(Mode, TextMode);
|
525
|
|
526
|
(function() {
|
527
|
this.lineCommentStart = "#";
|
528
|
this.$id = "ace/mode/zeek";
|
529
|
}).call(Mode.prototype);
|
530
|
|
531
|
exports.Mode = Mode;
|
532
|
}); (function() {
|
533
|
ace.require(["ace/mode/zeek"], function(m) {
|
534
|
if (typeof module == "object" && typeof exports == "object" && module) {
|
535
|
module.exports = m;
|
536
|
}
|
537
|
});
|
538
|
})();
|
539
|
|