Permalink
Browse files

Fixed issues pointed out in previous pull request

  • Loading branch information...
1 parent ff93a9c commit 22bf9c55dbc25e6ac2f085c117632e95d5646093 @wayward710 wayward710 committed with zeitgeist87 Apr 7, 2016
Showing with 36 additions and 86 deletions.
  1. +30 −85 components/prism-bro.js
  2. +1 −1 examples.js
  3. +5 −0 examples/prism-bro.html
@@ -1,97 +1,42 @@
Prism.languages.bro = {
- 'comment': [
- {
- pattern: /(^|[^\\$])#.*/,
- lookbehind: true
- }
- ],
- 'string': /(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
+ 'comment': {
+ pattern: /(^|[^\\$])#.*/,
+ lookbehind: true
+ },
+
+ 'string': /(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
- 'boolean': /\b(T|F)\b/,
+ 'boolean': /\b(T|F)\b/,
- 'keyword': [
- /\b(break|next|continue)\b/,
- /\b(alarm|using|of|add|delete)\b/,
- /\b(export)\b/,
- /\b(print|return|schedule)\b/,
- /\b(when|timeout)\b/,
- /\b(addr|any|bool|count)\b/,
- /\b(double|enum)\b/,
- /\b(file|int|interval)\b/,
- /\b(pattern|opaque)\b/,
- /\b(port|record|set)\b/,
- /\b(string|subnet|table)\b/,
- /\b(time|vector)\b/,
- /\b(for|if|else)\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)\b/,
+
'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&|\|\|?|\?|\*|\/|~|\^|%/,
-
- 'function': [
- {
- pattern: /function [a-zA-Z0-9_]+(::[a-zA-Z0-9_]+)?/i,
- inside: {
- keyword: /function/
- }
- },
-
- {
- pattern: /hook [a-zA-Z0-9_]+(::[a-zA-Z0-9_]+)?/i,
- inside: {
- keyword: /hook/
- }
+
+ 'function': {
+ pattern: /(?:function|hook|event) [a-zA-Z0-9_]+(::[a-zA-Z0-9_]+)?/,
+ inside: {
+ keyword: /^(?:function|hook|event)/
+ }
},
-
- {
- pattern: /event [a-zA-Z0-9_]+(::[a-zA-Z0-9_]+)?/i,
- inside: {
- keyword: /event/
- }
- }
- ],
-
- 'variable':
- [{
- pattern: /global [a-zA-Z0-9_]+/i,
- inside: {
- keyword: /global/
- }
+
+ 'variable': {
+ pattern: /(?:global|local) [a-zA-Z0-9_]+/i,
+ inside: {
+ keyword: /(?:global|local)/
+ }
+
},
- {
- pattern: /local [a-zA-Z0-9_]+/i,
- inside: {
- keyword: /local/
- }
- }],
-
-
- 'number': [
- /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,
-
- ],
-
- 'italic': /\b(TODO|FIXME|XXX)\b/,
+
+ 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,
+
+ 'italic': /\b(TODO|FIXME|XXX)\b/,
'punctuation': /[{}[\];(),.:]/,
-
+
'builtin':
- [
- /@load\s+/,
- /@load-sigs\s+/,
- /@load-plugin\s+/,
- /@unload\s+/,
- /@prefixes\s+/,
- /@if\s+/,
- /@ifdef\s+/,
- /@ifndef\s+/,
- /@else\s+/,
- /@endif\s+/,
- /@DIR\s+/,
- /@FILENAME\s+/,
- {pattern: /&(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)/,
- }
- ],
-
+ /(@(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,
View
@@ -85,7 +85,7 @@ function fileExists(filepath) {
return true;
}
}
- return true;
+ return false;
});
}
@@ -16,6 +16,11 @@
-123.456
</code></pre>
+<h2>Misc</h2>
+<pre><code>
+@ifndef ourexp
+</code></pre>
+
<h2>Full example</h2>
<pre><code>
##! Scan detector ported from Bro 1.x.

0 comments on commit 22bf9c5

Please sign in to comment.