Commit 22bf9c55dbc25e6ac2f085c117632e95d5646093

wayward710 2016-04-07T01:12:38

Fixed issues pointed out in previous pull request

diff --git a/components/prism-bro.js b/components/prism-bro.js
index 1f8d841..d76ea1d 100644
--- a/components/prism-bro.js
+++ b/components/prism-bro.js
@@ -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,
diff --git a/examples.js b/examples.js
index 02897d3..a686fa7 100644
--- a/examples.js
+++ b/examples.js
@@ -85,7 +85,7 @@ function fileExists(filepath) {
 				return true;
 			}
 		}
-		return true;
+		return false;
 	});
 }
 
diff --git a/examples/prism-bro.html b/examples/prism-bro.html
index c8a7f18..cddf567 100644
--- a/examples/prism-bro.html
+++ b/examples/prism-bro.html
@@ -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.