shBrushFSharp.js 2.1 KB

123456789101112131415161718192021222324252627282930313233
  1. // WTFPL licensed
  2. // scratching the surface of research microsoft com/fsharp/manual/spec2.aspx#_Toc207785562
  3. // omits reserved-ident-formats, reserved-symbolic-sequence, quote-op-*, symbolic-op, ...
  4. SyntaxHighlighter.brushes.FSharp = function()
  5. {
  6. var keywords = 'abstract and as assert base begin class default delegate do done ' +
  7. 'downcast downto elif else end exception extern false finally for '+
  8. 'fun function if in inherit inline interface internal lazy let ' +
  9. 'match member module mutable namespace new null of open or '+
  10. 'override private public rec return static struct then to '+
  11. 'true try type upcast use val void when while with yield';
  12. var ocaml = 'asr land lor lsl lsr lxor mod sig';
  13. var reserved ='atomic break checked component const constraint constructor '+
  14. 'continue eager event external fixed functor global include '+
  15. 'method mixin object parallel process protected pure '+
  16. 'sealed tailcall trait virtual volatile';
  17. var symbolic = 'let! use! do! yield! return! \\| -> <- \\. : \\( \\) \\[ \\] \\[< >\\] \\[\\| \\|\\] '+
  18. '\\{ \\} \' # :\\?> :\\? ; ;; :> := _ \\.\\. ::';
  19. this.regexList = [
  20. { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments
  21. { regex: new RegExp('\\(\\*[\\s\\S]*?\\*\\)', 'gm'), css: 'comments' }, // multiline comments
  22. { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings
  23. { regex: new RegExp('^\\s*#.*', 'gm'), css: 'preprocessor' }, // preprocessor tags like #light
  24. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // f# keyword
  25. //{ regex: new RegExp(this.getKeywords(ocaml), 'gm'), css: 'color1' }, // caml keyword
  26. //{ regex: new RegExp(this.getKeywords(reserved), 'gm'), css: 'color2' }, // reserved keyword
  27. //{ regex: new RegExp(this.getKeywords(symbolic), 'gm'), css: 'color3' } // symbolic keyword
  28. ];
  29. }
  30. SyntaxHighlighter.brushes.FSharp.prototype = new SyntaxHighlighter.Highlighter();
  31. SyntaxHighlighter.brushes.FSharp.aliases = ['f#', 'f-sharp', 'fsharp'];