Skip to content

Commit

Permalink
Bro: Removed variable and minor improvements (#3186)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Nov 22, 2021
1 parent 929c33e commit 4cebf34
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 30 deletions.
21 changes: 5 additions & 16 deletions components/prism-bro.js
Expand Up @@ -16,29 +16,18 @@ Prism.languages.bro = {
'boolean': /\b[TF]\b/,

'function': {
pattern: /(?:event|function|hook) \w+(?:::\w+)?/,
inside: {
keyword: /^(?:event|function|hook)/
}
},

'variable': {
pattern: /(?:global|local) \w+/i,
inside: {
keyword: /(?:global|local)/
}
pattern: /(\b(?:event|function|hook)[ \t]+)\w+(?:::\w+)?/,
lookbehind: true
},

'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))/,

'constant': {
pattern: /const \w+/i,
inside: {
keyword: /const/
}
pattern: /(\bconst[ \t]+)\w+/i,
lookbehind: true
},

'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/,
'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/,

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

Expand Down
2 changes: 1 addition & 1 deletion components/prism-bro.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions tests/languages/bro/function_feature.test
Expand Up @@ -8,14 +8,14 @@ event foo::bar
----------------------------------------------------

[
["function", [["keyword", "function"], " foo"]],
["function", [["keyword", "hook"], " foo"]],
["function", [["keyword", "event"], " foo"]],
["function", [["keyword", "function"], " foo::bar"]],
["function", [["keyword", "hook"], " foo::bar"]],
["function", [["keyword", "event"], " foo::bar"]]
["keyword", "function"], ["function", "foo"],
["keyword", "hook"], ["function", "foo"],
["keyword", "event"], ["function", "foo"],
["keyword", "function"], ["function", "foo::bar"],
["keyword", "hook"], ["function", "foo::bar"],
["keyword", "event"], ["function", "foo::bar"]
]

----------------------------------------------------

Checks for the function feature
Checks for the function feature
21 changes: 15 additions & 6 deletions tests/languages/bro/variable_feature.test
Expand Up @@ -7,19 +7,28 @@ local baz = 66;
----------------------------------------------------

[
["variable", [["keyword", "local"], " foo"]],
["variable", [["keyword", "global"], " foo"]],
["variable", [["keyword", "local"], " bool"]],
["keyword", "local"],
" foo\r\n",

["keyword", "global"],
" foo\r\n",

["keyword", "local"],
["keyword", "bool"],
["operator", "="],
["boolean", "T"],
["punctuation", ";"],
["constant", [["keyword", "const"], " bar"]],
["variable", [["keyword", "local"], " baz"]],

["keyword", "const"],
["constant", "bar"],

["keyword", "local"],
" baz ",
["operator", "="],
["number", "66"],
["punctuation", ";"]
]

----------------------------------------------------

Checks for the highlighting of variables
Checks for the highlighting of variables

0 comments on commit 4cebf34

Please sign in to comment.