fsharp.min.js 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*! `fsharp` grammar compiled for Highlight.js 11.7.0 */
  2. var hljsGrammar=(()=>{"use strict";function e(e){
  3. return RegExp(e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),"m")}function n(e){
  4. return e?"string"==typeof e?e:e.source:null}function t(e){return i("(?=",e,")")}
  5. function i(...e){return e.map((e=>n(e))).join("")}function a(...e){const t=(e=>{
  6. const n=e[e.length-1]
  7. ;return"object"==typeof n&&n.constructor===Object?(e.splice(e.length-1,1),n):{}
  8. })(e);return"("+(t.capture?"":"?:")+e.map((e=>n(e))).join("|")+")"}return n=>{
  9. const r={scope:"keyword",match:/\b(yield|return|let|do|match|use)!/
  10. },o=["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","Result"],s={
  11. 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"],
  12. literal:["true","false","null","Some","None","Ok","Error","infinity","infinityf","nan","nanf"],
  13. built_in:["not","ref","raise","reraise","dict","readOnlyDict","set","get","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"],
  14. "variable.constant":["__LINE__","__SOURCE_DIRECTORY__","__SOURCE_FILE__"]},c={
  15. variants:[n.COMMENT(/\(\*(?!\))/,/\*\)/,{contains:["self"]
  16. }),n.C_LINE_COMMENT_MODE]},l={scope:"variable",begin:/``/,end:/``/
  17. },u=/\B('|\^)/,p={scope:"symbol",variants:[{match:i(u,/``.*?``/)},{
  18. match:i(u,n.UNDERSCORE_IDENT_RE)}],relevance:0},f=({includeEqual:n})=>{let r
  19. ;r=n?"!%&*+-/<=>@^|~?":"!%&*+-/<>@^|~?"
  20. ;const o=i("[",...Array.from(r).map(e),"]"),s=a(o,/\./),c=i(s,t(s)),l=a(i(c,s,"*"),i(o,"+"))
  21. ;return{scope:"operator",match:a(l,/:\?>/,/:\?/,/:>/,/:=/,/::?/,/\$/),
  22. relevance:0}},d=f({includeEqual:!0}),b=f({includeEqual:!1}),m=(e,r)=>({
  23. begin:i(e,t(i(/\s*/,a(/\w/,/'/,/\^/,/#/,/``/,/\(/,/{\|/)))),beginScope:r,
  24. end:t(a(/\n/,/=/)),relevance:0,keywords:n.inherit(s,{type:o}),
  25. contains:[c,p,n.inherit(l,{scope:null}),b]
  26. }),g=m(/:/,"operator"),h=m(/\bof\b/,"keyword"),y={
  27. begin:[/(^|\s+)/,/type/,/\s+/,/[a-zA-Z_](\w|')*/],beginScope:{2:"keyword",
  28. 4:"title.class"},end:t(/\(|=|$/),keywords:s,contains:[c,n.inherit(l,{scope:null
  29. }),p,{scope:"operator",match:/<|>/},g]},E={scope:"computation-expression",
  30. match:/\b[_a-z]\w*(?=\s*\{)/},_={
  31. begin:[/^\s*/,i(/#/,a("if","else","endif","line","nowarn","light","r","i","I","load","time","help","quit")),/\b/],
  32. beginScope:{2:"meta"},end:t(/\s|$/)},v={
  33. variants:[n.BINARY_NUMBER_MODE,n.C_NUMBER_MODE]},w={scope:"string",begin:/"/,
  34. end:/"/,contains:[n.BACKSLASH_ESCAPE]},A={scope:"string",begin:/@"/,end:/"/,
  35. contains:[{match:/""/},n.BACKSLASH_ESCAPE]},S={scope:"string",begin:/"""/,
  36. end:/"""/,relevance:2},C={scope:"subst",begin:/\{/,end:/\}/,keywords:s},O={
  37. scope:"string",begin:/\$"/,end:/"/,contains:[{match:/\{\{/},{match:/\}\}/
  38. },n.BACKSLASH_ESCAPE,C]},x={scope:"string",begin:/(\$@|@\$)"/,end:/"/,
  39. contains:[{match:/\{\{/},{match:/\}\}/},{match:/""/},n.BACKSLASH_ESCAPE,C]},R={
  40. scope:"string",begin:/\$"""/,end:/"""/,contains:[{match:/\{\{/},{match:/\}\}/
  41. },C],relevance:2},k={scope:"string",
  42. match:i(/'/,a(/[^\\']/,/\\(?:.|\d{3}|x[a-fA-F\d]{2}|u[a-fA-F\d]{4}|U[a-fA-F\d]{8})/),/'/)
  43. };return C.contains=[x,O,A,w,k,r,c,l,g,E,_,v,p,d],{name:"F#",
  44. aliases:["fs","f#"],keywords:s,illegal:/\/\*/,classNameAliases:{
  45. "computation-expression":"keyword"},contains:[r,{variants:[R,x,O,S,A,w,k]
  46. },c,l,y,{scope:"meta",begin:/\[</,end:/>\]/,relevance:2,contains:[l,S,A,w,k,v]
  47. },h,g,E,_,v,p,d]}}})();export default hljsGrammar;