1 | 'use strict'
|
---|
2 |
|
---|
3 | module.exports = fsharp
|
---|
4 | fsharp.displayName = 'fsharp'
|
---|
5 | fsharp.aliases = []
|
---|
6 | function fsharp(Prism) {
|
---|
7 | Prism.languages.fsharp = Prism.languages.extend('clike', {
|
---|
8 | comment: [
|
---|
9 | {
|
---|
10 | pattern: /(^|[^\\])\(\*(?!\))[\s\S]*?\*\)/,
|
---|
11 | lookbehind: true,
|
---|
12 | greedy: true
|
---|
13 | },
|
---|
14 | {
|
---|
15 | pattern: /(^|[^\\:])\/\/.*/,
|
---|
16 | lookbehind: true,
|
---|
17 | greedy: true
|
---|
18 | }
|
---|
19 | ],
|
---|
20 | string: {
|
---|
21 | pattern: /(?:"""[\s\S]*?"""|@"(?:""|[^"])*"|"(?:\\[\s\S]|[^\\"])*")B?/,
|
---|
22 | greedy: true
|
---|
23 | },
|
---|
24 | 'class-name': {
|
---|
25 | pattern:
|
---|
26 | /(\b(?:exception|inherit|interface|new|of|type)\s+|\w\s*:\s*|\s:\??>\s*)[.\w]+\b(?:\s*(?:->|\*)\s*[.\w]+\b)*(?!\s*[:.])/,
|
---|
27 | lookbehind: true,
|
---|
28 | inside: {
|
---|
29 | operator: /->|\*/,
|
---|
30 | punctuation: /\./
|
---|
31 | }
|
---|
32 | },
|
---|
33 | keyword:
|
---|
34 | /\b(?:let|return|use|yield)(?:!\B|\b)|\b(?:abstract|and|as|asr|assert|atomic|base|begin|break|checked|class|component|const|constraint|constructor|continue|default|delegate|do|done|downcast|downto|eager|elif|else|end|event|exception|extern|external|false|finally|fixed|for|fun|function|functor|global|if|in|include|inherit|inline|interface|internal|land|lazy|lor|lsl|lsr|lxor|match|member|method|mixin|mod|module|mutable|namespace|new|not|null|object|of|open|or|override|parallel|private|process|protected|public|pure|rec|sealed|select|sig|static|struct|tailcall|then|to|trait|true|try|type|upcast|val|virtual|void|volatile|when|while|with)\b/,
|
---|
35 | number: [
|
---|
36 | /\b0x[\da-fA-F]+(?:LF|lf|un)?\b/,
|
---|
37 | /\b0b[01]+(?:uy|y)?\b/,
|
---|
38 | /(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[fm]|e[+-]?\d+)?\b/i,
|
---|
39 | /\b\d+(?:[IlLsy]|UL|u[lsy]?)?\b/
|
---|
40 | ],
|
---|
41 | operator:
|
---|
42 | /([<>~&^])\1\1|([*.:<>&])\2|<-|->|[!=:]=|<?\|{1,3}>?|\??(?:<=|>=|<>|[-+*/%=<>])\??|[!?^&]|~[+~-]|:>|:\?>?/
|
---|
43 | })
|
---|
44 | Prism.languages.insertBefore('fsharp', 'keyword', {
|
---|
45 | preprocessor: {
|
---|
46 | pattern: /(^[\t ]*)#.*/m,
|
---|
47 | lookbehind: true,
|
---|
48 | alias: 'property',
|
---|
49 | inside: {
|
---|
50 | directive: {
|
---|
51 | pattern: /(^#)\b(?:else|endif|if|light|line|nowarn)\b/,
|
---|
52 | lookbehind: true,
|
---|
53 | alias: 'keyword'
|
---|
54 | }
|
---|
55 | }
|
---|
56 | }
|
---|
57 | })
|
---|
58 | Prism.languages.insertBefore('fsharp', 'punctuation', {
|
---|
59 | 'computation-expression': {
|
---|
60 | pattern: /\b[_a-z]\w*(?=\s*\{)/i,
|
---|
61 | alias: 'keyword'
|
---|
62 | }
|
---|
63 | })
|
---|
64 | Prism.languages.insertBefore('fsharp', 'string', {
|
---|
65 | annotation: {
|
---|
66 | pattern: /\[<.+?>\]/,
|
---|
67 | greedy: true,
|
---|
68 | inside: {
|
---|
69 | punctuation: /^\[<|>\]$/,
|
---|
70 | 'class-name': {
|
---|
71 | pattern: /^\w+$|(^|;\s*)[A-Z]\w*(?=\()/,
|
---|
72 | lookbehind: true
|
---|
73 | },
|
---|
74 | 'annotation-content': {
|
---|
75 | pattern: /[\s\S]+/,
|
---|
76 | inside: Prism.languages.fsharp
|
---|
77 | }
|
---|
78 | }
|
---|
79 | },
|
---|
80 | char: {
|
---|
81 | pattern:
|
---|
82 | /'(?:[^\\']|\\(?:.|\d{3}|x[a-fA-F\d]{2}|u[a-fA-F\d]{4}|U[a-fA-F\d]{8}))'B?/,
|
---|
83 | greedy: true
|
---|
84 | }
|
---|
85 | })
|
---|
86 | }
|
---|