/
source.ml.js
174 lines (173 loc) · 5.56 KB
/
source.ml.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/textmate/standard-ml.tmbundle>
// and licensed permissive.
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.fun', '.sig', '.sml'],
names: ['standard-ml', 'sml'],
patterns: [
{include: '#comments'},
{
match:
'\\b(val|datatype|signature|type|op|sharing|struct|as|let|in|abstype|local|where|case|of|fn|raise|exception|handle|ref|infix|infixr|before|end|structure|withtype)\\b',
name: 'keyword.other.ml'
},
{
begin: '\\b(let)\\b',
captures: {1: {name: 'keyword.other.ml'}, 2: {name: 'keyword.other.ml'}},
end: '\\b(end)\\b',
name: 'meta.exp.let.ml',
patterns: [{include: '$self'}]
},
{
begin: '\\b(sig)\\b',
captures: {
1: {name: 'keyword.other.delimiter.ml'},
2: {name: 'keyword.other.delimiter.ml'}
},
end: '\\b(end)\\b',
name: 'meta.module.sigdec.ml',
patterns: [{include: '#spec'}]
},
{match: '\\b(if|then|else)\\b', name: 'keyword.control.ml'},
{
begin: '\\b(fun|and)\\s+([\\w]+)\\b',
captures: {
1: {name: 'keyword.control.fun.ml'},
2: {name: 'entity.name.function.ml'}
},
end: '(?=val|type|eqtype|datatype|structure|local)',
name: 'meta.definition.fun.ml',
patterns: [{include: 'source.ml'}]
},
{
begin: '"',
beginCaptures: {0: {name: 'punctuation.definition.string.begin.ml'}},
end: '"',
endCaptures: {0: {name: 'punctuation.definition.string.end.ml'}},
name: 'string.quoted.double.ml',
patterns: [{match: '\\\\.', name: 'constant.character.escape.ml'}]
},
{
captures: {
1: {name: 'punctuation.definition.constant.ml'},
3: {name: 'punctuation.definition.constant.ml'}
},
match: '(#")(\\\\)?.(")',
name: 'constant.character.ml'
},
{match: '\\b\\d*\\.?\\d+\\b', name: 'constant.numeric.ml'},
{match: '\\b(andalso|orelse|not)\\b', name: 'keyword.operator.logical.ml'},
{
begin:
'(?x)\\b\n\t\t\t\t\t(functor|structure|signature|funsig)\\s+\n\t\t\t\t\t(\\w+)\\s* # identifier',
captures: {
1: {name: 'storage.type.module.binder.ml'},
2: {name: 'entity.name.type.module.ml'}
},
end: '(?==|:|\\()',
name: 'meta.module.dec.ml'
},
{match: '\\b(open)\\b', name: 'keyword.other.module.ml'},
{match: '\\b(nil|true|false|NONE|SOME)\\b', name: 'constant.language.ml'},
{
begin: '\\b(type|eqtype) .* =',
captures: {
1: {name: 'keyword.other.typeabbrev.ml'},
2: {name: 'variable.other.typename.ml'}
},
end: '$',
name: 'meta.typeabbrev.ml',
patterns: [
{match: '(([a-zA-Z0-9\\.\\* ]|(\\->))*)', name: 'meta.typeexp.ml'}
]
}
],
repository: {
comments: {
patterns: [
{
begin: '\\(\\*',
beginCaptures: {0: {name: 'punctuation.definition.comment.begin.ml'}},
end: '\\*\\)',
endCaptures: {0: {name: 'punctuation.definition.comment.end.ml'}},
name: 'comment.block.ml',
patterns: [{include: '#comments'}]
}
]
},
spec: {
patterns: [
{
captures: {
1: {name: 'keyword.other.ml'},
2: {name: 'entity.name.type.abbrev.ml'}
},
match: "\\b(exception|type)\\s+([a-zA-Z][a-zA-Z0-9'_]*)",
name: 'meta.spec.ml.type'
},
{
begin: "\\b(datatype)\\s+([a-zA-Z][a-zA-Z0-9'_]*)\\s*(?==)",
captures: {
1: {name: 'keyword.other.ml'},
2: {name: 'entity.name.type.datatype.ml'}
},
end: '(?=val|type|eqtype|datatype|structure|include|exception)',
name: 'meta.spec.ml.datatype',
patterns: [
{
captures: {
1: {name: 'keyword.other.ml'},
2: {name: 'entity.name.type.datatype.ml'}
},
match: "\\b(and)\\s+([a-zA-Z][a-zA-Z0-9'_]*)\\s*(?==)",
name: 'meta.spec.ml.datatype'
},
{
captures: {
1: {name: 'variable.other.dcon.ml'},
2: {name: 'keyword.other.ml'}
},
match:
"(?x)\n\t\t\t\t\t\t\t=\\s*([a-zA-Z][a-zA-Z0-9'_]*)(\\s+of)?",
name: 'meta.datatype.rule.main.ml'
},
{
captures: {
1: {name: 'variable.other.dcon.ml'},
2: {name: 'keyword.other.ml'}
},
match: "\\|\\s*([a-zA-Z][a-zA-Z0-9'_]*)(\\s+of)?",
name: 'meta.datatype.rule.other.ml'
}
]
},
{
captures: {1: {name: 'keyword.other.ml'}},
match: '\\b(val)\\s*([^:]+)\\s*:',
name: 'meta.spec.ml.val'
},
{
begin: '\\b(structure)\\s*(\\w+)\\s*:',
captures: {
1: {name: 'keyword.other.ml'},
2: {name: 'entity.name.type.module.ml'}
},
end: '(?=val|type|eqtype|datatype|structure|include)',
name: 'meta.spec.ml.structure',
patterns: [{match: '\\b(sharing)\\b', name: 'keyword.other.ml'}]
},
{
captures: {1: {name: 'keyword.other.ml'}},
match: '\\b(include)\\b',
name: 'meta.spec.ml.include'
},
{include: '#comments'}
]
}
},
scopeName: 'source.ml'
}
export default grammar