Skip to content

Commit

Permalink
Bro: Regexp simplification + don't use captures if not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote committed Oct 22, 2017
1 parent d28d178 commit 16979a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 8 additions & 10 deletions components/prism-bro.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,41 @@ Prism.languages.bro = {
pattern: /(^|[^\\$])#.*/,
lookbehind: true,
inside: {
'italic': /\b(TODO|FIXME|XXX)\b/
'italic': /\b(?:TODO|FIXME|XXX)\b/
}
},

'string': {
pattern: /(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
greedy: true
},

'boolean': /\b(T|F)\b/,
'boolean': /\b[TF]\b/,

'function': {
pattern: /(?:function|hook|event) [a-zA-Z0-9_]+(::[a-zA-Z0-9_]+)?/,
pattern: /(?:function|hook|event) \w+(?:::\w+)?/,
inside: {
keyword: /^(?:function|hook|event)/
}
},

'variable': {
pattern: /(?:global|local) [a-zA-Z0-9_]+/i,
pattern: /(?:global|local) \w+/i,
inside: {
keyword: /(?:global|local)/
}
},

'builtin':
/(@(load(-(sigs|plugin))?|unload|prefixes|ifn?def|else|(end)?if|DIR|FILENAME))|(&?(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|group|error_handler|type_column))/,
'builtin': /(?:@(?:load(?:-(?:sigs|plugin))?|unload|prefixes|ifn?def|else|(?:end)?if|DIR|FILENAME))|(?:&?(?: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|group|error_handler|type_column))/,

'constant': {
pattern: /const [a-zA-Z0-9_]+/i,
pattern: /const \w+/i,
inside: {
keyword: /const/
}
},

'keyword':
/\b(break|next|continue|alarm|using|of|add|delete|export|print|return|schedule|when|timeout|addr|any|bool|count|double|enum|file|int|interval|pattern|opaque|port|record|set|string|subnet|table|time|vector|for|if|else|in|module|function)\b/,
'keyword': /\b(?:break|next|continue|alarm|using|of|add|delete|export|print|return|schedule|when|timeout|addr|any|bool|count|double|enum|file|int|interval|pattern|opaque|port|record|set|string|subnet|table|time|vector|for|if|else|in|module|function)\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.

0 comments on commit 16979a3

Please sign in to comment.