Commit 2664796c7959c13150cf4328d6a07b972b09e6e4

Simon Reynolds 2015-02-07T16:44:50

Removed newline consumption in single line comment and split numbers regex to handle hex, binary, integer and decimal numbers separately

diff --git a/components/prism-fsharp.js b/components/prism-fsharp.js
index 682c667..09072df 100644
--- a/components/prism-fsharp.js
+++ b/components/prism-fsharp.js
@@ -5,12 +5,25 @@ Prism.languages.fsharp = Prism.languages.extend('clike', {
 			lookbehind: true
 		},
 		{
-			pattern: /(^|[^\\:])\/\/.*?(\r?\n|$)/g,
+			pattern: /(^|[^\\:])\/\/.*/g,
 			lookbehind: true
 		}
 	],
 	'keyword': /\b(abstract|and|as|assert|base|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|global|if|in|inherit|inline|interface|internal|lazy|let|let!|match|member|module|mutable|namespace|new|not|null|of|open|or|override|private|public|rec|return|return!|select|static|struct|then|to|true|try|type|upcast|use|use!|val|void|when|while|with|yield|yield!|asr|land|lor|lsl|lsr|lxor|mod|sig|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|include|method|mixin|object|parallel|process|protected|pure|sealed|tailcall|trait|virtual|volatile)\b/g,
 	'string': /@?("""|"|')((\\|\n)?.)*?\1(B)?/g,
 	'preprocessor': /^\s*#.*/gm,
-	'number': /\b-?(0x)?(\d[a-fA-F]?)*\.?((\d\.?[a-fA-F]?)(y|uy|s|us|l|ul|un|L|UL|F|f|lf|LF|I|M|m))?\b/g
+	'number': [
+		{
+			pattern: /\b-?(0x((\d*)|([a-fA-F]*))*(un|LF)?)\b/g
+		},
+		{
+			pattern: /\b-?(0b((0|1))*(y|uy)?)\b/g
+		},
+		{
+			pattern: /\b-?(\d*\.(f|\d)?\d*(f|F|m|M|((E|e)(\+|-)?\d*))?)\b/g
+		},
+		{
+			pattern: /\b-?(\d{1,}(y|uy|s|us|l|u|ul|L|UL|I)?)\b/g
+		}
+	]
 });
\ No newline at end of file
diff --git a/components/prism-fsharp.min.js b/components/prism-fsharp.min.js
index 811719a..09aa2fb 100644
--- a/components/prism-fsharp.min.js
+++ b/components/prism-fsharp.min.js
@@ -1 +1 @@
-Prism.languages.fsharp=Prism.languages.extend("clike",{comment:[{pattern:/(^|[^\\])\(\*[\w\W]*?\*\)/g,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*?(\r?\n|$)/g,lookbehind:!0}],keyword:/\b(abstract|and|as|assert|base|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|global|if|in|inherit|inline|interface|internal|lazy|let|let!|match|member|module|mutable|namespace|new|not|null|of|open|or|override|private|public|rec|return|return!|select|static|struct|then|to|true|try|type|upcast|use|use!|val|void|when|while|with|yield|yield!|asr|land|lor|lsl|lsr|lxor|mod|sig|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|include|method|mixin|object|parallel|process|protected|pure|sealed|tailcall|trait|virtual|volatile)\b/g,string:/@?("""|"|')((\\|\n)?.)*?\1(B)?/g,preprocessor:/^\s*#.*/gm,number:/\b-?(0x)?(\d[a-fA-F]?)*\.?((\d\.?[a-fA-F]?)(y|uy|s|us|l|ul|un|L|UL|F|f|lf|LF|I|M|m))?\b/g});
\ No newline at end of file
+Prism.languages.fsharp=Prism.languages.extend("clike",{comment:[{pattern:/(^|[^\\])\(\*[\w\W]*?\*\)/g,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/g,lookbehind:!0}],keyword:/\b(abstract|and|as|assert|base|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|global|if|in|inherit|inline|interface|internal|lazy|let|let!|match|member|module|mutable|namespace|new|not|null|of|open|or|override|private|public|rec|return|return!|select|static|struct|then|to|true|try|type|upcast|use|use!|val|void|when|while|with|yield|yield!|asr|land|lor|lsl|lsr|lxor|mod|sig|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|include|method|mixin|object|parallel|process|protected|pure|sealed|tailcall|trait|virtual|volatile)\b/g,string:/@?("""|"|')((\\|\n)?.)*?\1(B)?/g,preprocessor:/^\s*#.*/gm,number:[{pattern:/\b-?(0x((\d*)|([a-fA-F]*))*(un|LF)?)\b/g},{pattern:/\b-?(0b((0|1))*(y|uy)?)\b/g},{pattern:/\b-?(\d*\.(f|\d)?\d*(f|F|m|M|((E|e)(\+|-)?\d*))?)\b/g},{pattern:/\b-?(\d{1,}(y|uy|s|us|l|u|ul|L|UL|I)?)\b/g}]});
\ No newline at end of file
diff --git a/examples.js b/examples.js
index 74c5aaf..43bffd7 100644
--- a/examples.js
+++ b/examples.js
@@ -6,7 +6,7 @@
 
 var examples = {};
 
-var treeURL = 'https://api.github.com/repos/LeaVerou/prism/git/trees/gh-pages?recursive=1';
+var treeURL = 'https://api.github.com/repos/simonreynolds7/prism/git/trees/fsharp-support?recursive=1';
 var treePromise = new Promise(function (resolve) {
 	$u.xhr({
 		url: treeURL,
diff --git a/examples/prism-fsharp.html b/examples/prism-fsharp.html
index 2f3c795..4815b2c 100644
--- a/examples/prism-fsharp.html
+++ b/examples/prism-fsharp.html
@@ -13,6 +13,46 @@ comment *)</code></pre>
 """Alternate "verbatim" strings"""
 </code></pre>
 
+<h2>Numbers</h2>
+<pre><code>
+//8 bit Int
+86y
+0b00000101y
+//Unsigned 8 bit Int
+86uy
+0b00000101uy
+//16 bit Int
+86s
+//Unsigned 16 bit Int
+86us
+//Int
+86
+86l
+//Unsigned Int
+86u
+86ul
+//unativeint
+0x00002D3Fun
+//Long
+86L
+//Unsigned Long
+86UL
+//Float
+4.14F
+4.14f
+//Double
+4.14
+2.3E+32
+2.3e+32
+2.3e32
+0x0000000000000000LF
+//BigInt
+9999999999999999999999999999I
+//Decimal
+0.7833M
+0.7833m
+</code></pre>
+
 <h2>Full example</h2>
 <pre><code>// The declaration creates a constructor that takes two values, name and age. 
 type Person(name:string, age:int) =
@@ -52,4 +92,4 @@ type Person(name:string, age:int) =
 </p>
 
 <h3>Comment-like substrings</h3>
-<pre><code>"foo /* bar */ baz"; "foo // bar";</code></pre>
\ No newline at end of file
+<pre><code>"foo (* bar *) baz"; "foo // bar";</code></pre>
\ No newline at end of file