Last active
August 29, 2015 13:55
-
-
Save zecl/8784470 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SyntaxHighlighter.brushes.FSharp = function() { | |
var keywords = | |
'abstract and as assert base begin class default delegate do done ' + | |
'downcast downto elif else end exception extern false finally for ' + | |
'fun function if in inherit inline interface internal lazy let ' + | |
'match member module mutable namespace new null of open or ' + | |
'override private public rec return sig static struct then to ' + | |
'true try type upcast use val void when while with yield ' + | |
'asr land lor lsl lsr lxor mod '; | |
var reserved = | |
'atomic break checked component const constraint constructor ' + | |
'continue eager fixed fori functor global include method mixin ' + | |
'object parallel params process protected pure sealed tailcall ' + | |
'trait virtual volatile ' ; | |
var modules = | |
'Array Array2D Array3D Array4D ComparisonIdentity HashIdentity List ' + | |
'Map Seq SequenceExpressionHelpers Set CommonExtensions Event ' + | |
'ExtraTopLevelOperators LanguagePrimitives NumericLiterals Operators ' + | |
'OptimizedClosures Option String NativePtr Printf' ; | |
var functions = | |
'abs acos asin atan atan2 ceil cos cosh exp ' + | |
'floor log log10 pown printf printfn round sign sin sinh sqrt tan tanh ' + | |
'fst snd KeyValue not min max ' + | |
'ignore stdin stdout stderr sprintf sprintfn' ; | |
var objectTransformations = | |
'box hash sizeof typeof typedefof unbox' | |
var exceptions = | |
'failwith failwithf invalidArg invalidOp raise rethrow' ; | |
var constants = '__LINE__ __SOURCE_DIRECTORY__ __SOURCE_FILE__'; | |
var datatypes = | |
'bool byref byte char decimal double exn float float32 ' + | |
'FuncConvert ilsigptr int int16 int32 int64 int8 ' + | |
'nativeint nativeptr obj option ref sbyte single string uint16 ' + | |
'uint32 uint64 uint8 unativeint unit enum async seq dict ' ; | |
function fixComments(match, regexInfo) { | |
var css = (match[0].indexOf("///") == 0) ? 'color1' : 'comments'; | |
return [new SyntaxHighlighter.Match(match[0], match.index, css)]; | |
} | |
this.regexList = [ | |
{ regex: /\s*#\b(light|if|else|endif|indent|nowarn|r(eference)?|I|include|load|time|help|q(uit)?)/gm, css: 'preprocessor' }, | |
// comments | |
{ regex: SyntaxHighlighter.regexLib.singleLineCComments, css:'comments' }, | |
{ regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, | |
{ regex: /\s*\(\*[\s\S]*?\*\)/gm, css: 'comments' }, | |
// string | |
{ regex: /'[^']?'/gm, css: 'string' }, | |
{ regex: /@"(?:[^"]|"")*"/g, css: 'string' }, // @-quoted strings | |
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings | |
// keyword | |
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, | |
{ regex: /\s*(do|let|yield|return)*\!/gm, css: 'keyword' }, | |
{ regex: new RegExp(this.getKeywords(reserved), 'gm'), css: 'keyword' }, | |
{ regex: new RegExp(this.getKeywords(datatypes), 'gm'), css: 'keyword' }, | |
{ regex: new RegExp(this.getKeywords(objectTransformations), 'gm'), css: 'keyword' }, | |
{ regex: new RegExp(this.getKeywords(exceptions), 'gm'), css: 'keyword' }, | |
// paren | |
{ regex: /\[\<|\>\]/gm, css: 'color1' }, // attribute | |
{ regex: /(\(|\)|\{|\})/gm, css: 'color1' }, // paren | |
// functions | |
{ regex: new RegExp(this.getKeywords(functions), 'gm'), css: 'functions' }, | |
{ regex: /(\->)/gm, css: 'color1' }, // arrow | |
{ regex: /(>>|<<|:)/gm, css: 'functions' }, // functions | |
{ regex: /(\|>|<\|\|\|>|<\|\||\|\|>|<\|\|\|)/gm, css: 'functions' }, // pipeline operators | |
{ regex: /(\?>=|\?>|\?<=|\?<|\?=|\?<>|\?\+|\?\-|\?\*|\?\/|\?%)/gm, css: 'functions' }, // nullable operators. on left | |
{ regex: /(>=\?|>\?|<=\?|<\?|=\?|<>\?|\+\?|\-\?|\*\?|\/\?|%\?)/gm, css: 'functions' }, // nullable operators. on right | |
{ regex: /(\?>=\?|\?>\?|\?<=\?|\?<\?|\?=\?|\?<>\?|\?\+\?|\?\-\?|\?\*\?|\?\/\?|\?%\?)/gm, css: 'functions' }, // nullable operators. both sides nullable | |
{ regex: /\(\|[\s\S]*?\|\)/gm, css: 'functions' }, // active patterns | |
// Monad | |
{ regex: /(>>=|=<<)/gm, css: 'functions' }, // functions | |
// FParsec | |
{ regex: /(>>.|.>>.|.>>|%<\|>|<\|>%|<\|>|<\?>)/gm, css: 'functions' }, // functions | |
// others | |
{ regex: /(:=)/gm, css: 'color1' }, // | |
{ regex: /\'[a-zA-Z]*/gm, css: 'genericsType' }, | |
{ regex: new RegExp(this.getKeywords(modules), 'gm'), css: 'modules' }, | |
{ regex: new RegExp(this.getKeywords(constants), 'gm'), css: 'constants' } | |
]; | |
this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags); | |
}; | |
SyntaxHighlighter.brushes.FSharp.prototype = new SyntaxHighlighter.Highlighter(); | |
SyntaxHighlighter.brushes.FSharp.aliases = ['f#', 'f-sharp', 'fsharp']; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment