Skip to content

Commit 0f2d476

Browse files
Transform fsharp
1 parent a0ef907 commit 0f2d476

File tree

1 file changed

+50
-49
lines changed

1 file changed

+50
-49
lines changed

src/languages/fsharp.js

Lines changed: 50 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,11 @@
1-
import { insertBefore } from '../util/language-util.js';
21
import clike from './clike.js';
32

43
/** @type {import('../types.d.ts').LanguageProto<'fsharp'>} */
54
export default {
65
id: 'fsharp',
76
base: clike,
87
optional: 'xml-doc',
9-
grammar ({ base, getOptionalLanguage }) {
10-
insertBefore(base, 'keyword', {
11-
'preprocessor': {
12-
pattern: /(^[\t ]*)#.*/m,
13-
lookbehind: true,
14-
alias: 'property',
15-
inside: {
16-
'directive': {
17-
pattern: /(^#)\b(?:else|endif|if|light|line|nowarn)\b/,
18-
lookbehind: true,
19-
alias: 'keyword',
20-
},
21-
},
22-
},
23-
});
24-
insertBefore(base, 'punctuation', {
25-
'computation-expression': {
26-
pattern: /\b[_a-z]\w*(?=\s*\{)/i,
27-
alias: 'keyword',
28-
},
29-
});
30-
insertBefore(base, 'string', {
31-
'annotation': {
32-
pattern: /\[<.+?>\]/,
33-
greedy: true,
34-
inside: {
35-
'punctuation': /^\[<|>\]$/,
36-
'class-name': {
37-
pattern: /^\w+$|(^|;\s*)[A-Z]\w*(?=\()/,
38-
lookbehind: true,
39-
},
40-
'annotation-content': {
41-
pattern: /[\s\S]+/,
42-
inside: 'fsharp',
43-
},
44-
},
45-
},
46-
'char': {
47-
pattern:
48-
/'(?:[^\\']|\\(?:.|\d{3}|x[a-fA-F\d]{2}|u[a-fA-F\d]{4}|U[a-fA-F\d]{8}))'B?/,
49-
greedy: true,
50-
},
51-
});
52-
53-
insertBefore(base, 'comment', {
54-
'doc-comment': getOptionalLanguage('xml-doc')?.slash,
55-
});
56-
8+
grammar ({ getOptionalLanguage }) {
579
return {
5810
'comment': [
5911
{
@@ -90,6 +42,55 @@ export default {
9042
],
9143
'operator':
9244
/([<>~&^])\1\1|([*.:<>&])\2|<-|->|[!=:]=|<?\|{1,3}>?|\??(?:<=|>=|<>|[-+*/%=<>])\??|[!?^&]|~[+~-]|:>|:\?>?/,
45+
$insert: {
46+
'preprocessor': {
47+
$before: 'keyword',
48+
pattern: /(^[\t ]*)#.*/m,
49+
lookbehind: true,
50+
alias: 'property',
51+
inside: {
52+
'directive': {
53+
pattern: /(^#)\b(?:else|endif|if|light|line|nowarn)\b/,
54+
lookbehind: true,
55+
alias: 'keyword',
56+
},
57+
},
58+
},
59+
'computation-expression': {
60+
$before: 'punctuation',
61+
pattern: /\b[_a-z]\w*(?=\s*\{)/i,
62+
alias: 'keyword',
63+
},
64+
'annotation': {
65+
$before: 'string',
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: 'fsharp',
77+
},
78+
},
79+
},
80+
'char': {
81+
$before: 'string',
82+
pattern:
83+
/'(?:[^\\']|\\(?:.|\d{3}|x[a-fA-F\d]{2}|u[a-fA-F\d]{4}|U[a-fA-F\d]{8}))'B?/,
84+
greedy: true,
85+
},
86+
},
87+
$insertBefore: {
88+
'comment': {
89+
'doc-comment': /** @type {import('../types.d.ts').GrammarTokens} */ (
90+
getOptionalLanguage('xml-doc')
91+
)?.slash,
92+
},
93+
},
9394
};
9495
},
9596
};

0 commit comments

Comments
 (0)