]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/fsharp.min.js
1 /*! `fsharp` grammar compiled for Highlight.js 11.11.1 */
2 (()=>{var e
=(()=>{"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
=>{
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}),g
=(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 }),m
=g(/:/,"operator"),h=g(/\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:/<|>/},m
]},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
]},R
={scope:"string",begin:/(\$@|@\$)"/,end:/"/,
39 contains:[{match:/\{\{/},{match:/\}\}/},{match:/""/},n.BACKSLASH_ESCAPE,C]},k={
40 scope:"string
",begin:/\$"""/,end:/"""/,contains:[{match:/\{\{/},{match:/\}\}/
41 },C
],relevance:2},x
={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
=[R
,O
,A
,w
,x
,r
,c
,l
,m
,E
,_
,v
,p
,d
],{name:"F#",
44 aliases:["fs","f#"],keywords:s
,illegal:/\/\*/,classNameAliases:{
45 "computation-expression":"keyword"},contains:[r
,{variants:[k
,R
,O
,S
,A
,w
,x
]
46 },c
,l
,y
,{scope:"meta",begin:/\[</,end:/>\]/,relevance:2,contains:[l
,S
,A
,w
,x
,v
]
47 },h
,m
,E
,_
,v
,p
,d
]}}})();hljs
.registerLanguage("fsharp",e
)})();