Skip to content

Commit 4cebf34

Browse files
Bro: Removed variable and minor improvements (#3186)
1 parent 929c33e commit 4cebf34

File tree

4 files changed

+28
-30
lines changed

4 files changed

+28
-30
lines changed

components/prism-bro.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,18 @@ Prism.languages.bro = {
1616
'boolean': /\b[TF]\b/,
1717

1818
'function': {
19-
pattern: /(?:event|function|hook) \w+(?:::\w+)?/,
20-
inside: {
21-
keyword: /^(?:event|function|hook)/
22-
}
23-
},
24-
25-
'variable': {
26-
pattern: /(?:global|local) \w+/i,
27-
inside: {
28-
keyword: /(?:global|local)/
29-
}
19+
pattern: /(\b(?:event|function|hook)[ \t]+)\w+(?:::\w+)?/,
20+
lookbehind: true
3021
},
3122

3223
'builtin': /(?:@(?:load(?:-(?:plugin|sigs))?|unload|prefixes|ifn?def|else|(?:end)?if|DIR|FILENAME))|(?:&?(?:add_func|create_expire|default|delete_func|encrypt|error_handler|expire_func|group|log|mergeable|optional|persistent|priority|raw_output|read_expire|redef|rotate_interval|rotate_size|synchronized|type_column|write_expire))/,
3324

3425
'constant': {
35-
pattern: /const \w+/i,
36-
inside: {
37-
keyword: /const/
38-
}
26+
pattern: /(\bconst[ \t]+)\w+/i,
27+
lookbehind: true
3928
},
4029

41-
'keyword': /\b(?:add|addr|alarm|any|bool|break|continue|count|delete|double|else|enum|export|file|for|function|if|in|int|interval|module|next|of|opaque|pattern|port|print|record|return|schedule|set|string|subnet|table|time|timeout|using|vector|when)\b/,
30+
'keyword': /\b(?:add|addr|alarm|any|bool|break|const|continue|count|delete|double|else|enum|event|export|file|for|function|global|hook|if|in|int|interval|local|module|next|of|opaque|pattern|port|print|record|return|schedule|set|string|subnet|table|time|timeout|using|vector|when)\b/,
4231

4332
'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&|\|\|?|\?|\*|\/|~|\^|%/,
4433

components/prism-bro.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/languages/bro/function_feature.test

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ event foo::bar
88
----------------------------------------------------
99

1010
[
11-
["function", [["keyword", "function"], " foo"]],
12-
["function", [["keyword", "hook"], " foo"]],
13-
["function", [["keyword", "event"], " foo"]],
14-
["function", [["keyword", "function"], " foo::bar"]],
15-
["function", [["keyword", "hook"], " foo::bar"]],
16-
["function", [["keyword", "event"], " foo::bar"]]
11+
["keyword", "function"], ["function", "foo"],
12+
["keyword", "hook"], ["function", "foo"],
13+
["keyword", "event"], ["function", "foo"],
14+
["keyword", "function"], ["function", "foo::bar"],
15+
["keyword", "hook"], ["function", "foo::bar"],
16+
["keyword", "event"], ["function", "foo::bar"]
1717
]
1818

1919
----------------------------------------------------
2020

21-
Checks for the function feature
21+
Checks for the function feature

tests/languages/bro/variable_feature.test

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,28 @@ local baz = 66;
77
----------------------------------------------------
88

99
[
10-
["variable", [["keyword", "local"], " foo"]],
11-
["variable", [["keyword", "global"], " foo"]],
12-
["variable", [["keyword", "local"], " bool"]],
10+
["keyword", "local"],
11+
" foo\r\n",
12+
13+
["keyword", "global"],
14+
" foo\r\n",
15+
16+
["keyword", "local"],
17+
["keyword", "bool"],
1318
["operator", "="],
1419
["boolean", "T"],
1520
["punctuation", ";"],
16-
["constant", [["keyword", "const"], " bar"]],
17-
["variable", [["keyword", "local"], " baz"]],
21+
22+
["keyword", "const"],
23+
["constant", "bar"],
24+
25+
["keyword", "local"],
26+
" baz ",
1827
["operator", "="],
1928
["number", "66"],
2029
["punctuation", ";"]
2130
]
2231

2332
----------------------------------------------------
2433

25-
Checks for the highlighting of variables
34+
Checks for the highlighting of variables

0 commit comments

Comments
 (0)