fsharp.min.js 3.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*! `fsharp` grammar compiled for Highlight.js 11.3.1 */
  2. (()=>{var e=(()=>{"use strict";function e(e){
  3. return e?"string"==typeof e?e:e.source:null}function n(e){return t("(?=",e,")")}
  4. function t(...n){return n.map((n=>e(n))).join("")}function i(...n){const t=(e=>{
  5. const n=e[e.length-1]
  6. ;return"object"==typeof n&&n.constructor===Object?(e.splice(e.length-1,1),n):{}
  7. })(n);return"("+(t.capture?"":"?:")+n.map((n=>e(n))).join("|")+")"}return e=>{
  8. const a={scope:"keyword",match:/\b(yield|return|let|do|match|use)!/},s={
  9. type:["bool","byte","sbyte","int8","int16","int32","uint8","uint16","uint32","int","uint","int64","uint64","nativeint","unativeint","decimal","float","double","float32","single","char","string","unit","bigint","option","voption","list","array","seq","byref","exn","inref","nativeptr","obj","outref","voidptr"],
  10. keyword:["abstract","and","as","assert","base","begin","class","default","delegate","do","done","downcast","downto","elif","else","end","exception","extern","finally","fixed","for","fun","function","global","if","in","inherit","inline","interface","internal","lazy","let","match","member","module","mutable","namespace","new","of","open","or","override","private","public","rec","return","static","struct","then","to","try","type","upcast","use","val","void","when","while","with","yield"],
  11. literal:["true","false","null","Some","None","Ok","Error","infinity","infinityf","nan","nanf"],
  12. built_in:["not","ref","raise","reraise","dict","readOnlyDict","set","enum","sizeof","typeof","typedefof","nameof","nullArg","invalidArg","invalidOp","id","fst","snd","ignore","lock","using","box","unbox","tryUnbox","printf","printfn","sprintf","eprintf","eprintfn","fprintf","fprintfn","failwith","failwithf"],
  13. "variable.constant":["__LINE__","__SOURCE_DIRECTORY__","__SOURCE_FILE__"]},r={
  14. variants:[e.COMMENT(/\(\*(?!\))/,/\*\)/,{contains:["self"]
  15. }),e.C_LINE_COMMENT_MODE]},o={match:t(/('|\^)/,e.UNDERSCORE_IDENT_RE),
  16. scope:"symbol",relevance:0},c={scope:"computation-expression",
  17. match:/\b[_a-z]\w*(?=\s*\{)/},l={
  18. begin:[/^\s*/,t(/#/,i("if","else","endif","line","nowarn","light","r","i","I","load","time","help","quit")),/\b/],
  19. beginScope:{2:"meta"},end:n(/\s|$/)},f={
  20. variants:[e.BINARY_NUMBER_MODE,e.C_NUMBER_MODE]},u={scope:"string",begin:/"/,
  21. end:/"/,contains:[e.BACKSLASH_ESCAPE]},p={scope:"string",begin:/@"/,end:/"/,
  22. contains:[{match:/""/},e.BACKSLASH_ESCAPE]},d={scope:"subst",begin:/\{/,
  23. end:/\}/,keywords:s},g={scope:"string",begin:/\$"/,end:/"/,contains:[{
  24. match:/\{\{/},{match:/\}\}/},e.BACKSLASH_ESCAPE,d]},b={scope:"string",
  25. begin:/(\$@|@\$)"/,end:/"/,contains:[{match:/\{\{/},{match:/\}\}/},{match:/""/
  26. },e.BACKSLASH_ESCAPE,d]},m={scope:"string",begin:/\$"""/,end:/"""/,contains:[{
  27. match:/\{\{/},{match:/\}\}/},d],relevance:2},_={scope:"string",
  28. match:t(/'/,i(/[^\\']/,/\\(?:.|\d{3}|x[a-fA-F\d]{2}|u[a-fA-F\d]{4}|U[a-fA-F\d]{8})/),/'/)
  29. };return d.contains=[b,g,p,u,_,a,r,c,l,f,o],{name:"F#",aliases:["fs","f#"],
  30. keywords:s,illegal:/\/\*/,classNameAliases:{"computation-expression":"keyword"},
  31. contains:[a,{variants:[m,b,g,{scope:"string",begin:/"""/,end:/"""/,relevance:2
  32. },p,u,_]},r,{begin:[/type/,/\s+/,e.UNDERSCORE_IDENT_RE],beginScope:{1:"keyword",
  33. 3:"title.class"},end:n(/\(|=|$/),contains:[o]},{scope:"meta",begin:/^\s*\[</,
  34. excludeBegin:!0,end:n(/>\]/),relevance:2,contains:[{scope:"string",begin:/"/,
  35. end:/"/},f]},c,l,f,o]}}})();hljs.registerLanguage("fsharp",e)})();