-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
source.dune.js
194 lines (192 loc) · 6.23 KB
/
source.dune.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/maelvls/vscode-dune>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: [],
names: ['dune'],
patterns: [
{include: '#comments'},
{
begin:
'\\(\\s*(lang|using|library|rule|executable|executables|rule|ocamllex|ocamlyacc|menhir|install|alias|copy_files|copy_files#|jbuild_version|include)\\s',
beginCaptures: {1: {name: 'meta.class.stanza.dune'}},
end: '\\)',
name: 'meta.stanza.dune',
patterns: [{include: '$self'}]
},
{
begin:
'\\(\\s*(name|public_name|synopsis|install_c_headers|ppx_runtime_libraries|c_flags|cxx_flags|c_names|cxx_names|library_flags|c_library_flags|virtual_deps|modes|kind|wrapped|optional|self_build_stubs_archive|no_dynlink|ppx\\.driver)\\s',
beginCaptures: {1: {name: 'keyword.other.dune'}},
end: '\\)',
name: 'meta.stanza.library.field.dune',
patterns: [{include: '$self'}]
},
{
begin: '\\(\\s*(targets|deps|locks|loc|mode|action)\\s',
beginCaptures: {1: {name: 'keyword.other.dune'}},
end: '\\)',
name: 'meta.stanza.rule.dune',
patterns: [{include: '$self'}]
},
{
captures: {1: {name: 'keyword.other.dune'}},
match: '\\(\\s*(fallback|optional)\\s*\\)',
name: 'meta.mono-sexp.dune'
},
{
begin:
'\\(\\s*(run|chdir|setenv|with-stdout-to|with-stderr-to|with-outputs-to|ignore-stdout|ignore-stderr|ignore-outputs|progn|echo|cat|copy|copy#|system|bash|write-file|diff|diff\\?)\\s',
beginCaptures: {1: {name: 'entity.name.function.action.dune'}},
end: '\\)',
name: 'meta.stanza.rule.action.dune',
patterns: [{include: '$self'}]
},
{
begin: '\\(\\s*(section)\\s',
beginCaptures: {1: {name: 'keyword.other.dune'}},
end: '\\)',
name: 'meta.stanza.install.dune',
patterns: [
{
match:
'\\b(lib|libexec|bin|sbin|toplevel|share|share_root|etc|doc|stublibs|man|misc)\\b',
name: 'constant.language.rule.mode.dune'
}
]
},
{
begin: '\\(\\s*(files)\\s',
beginCaptures: {1: {name: 'keyword.other.dune'}},
end: '\\)',
name: 'meta.stanza.install.dune',
patterns: [{include: '$self'}]
},
{
begin: '\\(\\s*(normal|ppx_deriver|ppx_rewriter)\\s',
beginCaptures: {1: {name: 'constant.language.rule.mode.dune'}},
end: '\\)',
name: 'meta.library.kind.dune'
},
{
begin: '\\(\\s*(name|link_executables|link_flags|modes)\\s',
beginCaptures: {1: {name: 'keyword.other.dune'}},
end: '\\)',
name: 'meta.stanza.executables.dune',
patterns: [{include: '$self'}]
},
{
begin:
'\\(\\s*(preprocess|preprocessor_deps|lint|modules|modules_without_implementation|libraries|flags|ocamlc_flags|ocamlopt_flags|js_of_ocaml|allow_overlapping_dependencies|per_module)\\s',
beginCaptures: {1: {name: 'keyword.other.dune'}},
end: '\\)',
name: 'meta.stanza.lib-or-exec.buildable.dune',
patterns: [{include: '$self'}]
},
{
begin: '\\(\\s*(no_preprocessing|action|pps)\\s',
beginCaptures: {1: {name: 'keyword.other.dune'}},
end: '\\)',
name: 'meta.stanza.lib-or-exec.buildable.preprocess.dune',
patterns: [{include: '$self'}]
},
{
begin: '\\(\\s*(file|alias|alias_rec|glob_files|files_recursively_in)\\s',
beginCaptures: {1: {name: 'keyword.other.dune'}},
end: '\\)',
name: 'meta.stanza.lib-or-exec.buildable.preprocess_deps.dune',
patterns: [{include: '$self'}]
},
{
begin: '\\(\\s*(select)\\s',
beginCaptures: {1: {name: 'keyword.other.dune'}},
end: '\\)',
name: 'meta.stanza.lib-or-exec.buildable.libraries.dune',
patterns: [{include: '$self'}]
},
{match: '\\b\\d+\\b', name: 'constant.numeric.dune'},
{match: '(true|false)', name: 'constant.language.dune'},
{match: '\\s(as|from|->)\\s', name: 'keyword.other.dune'},
{match: '(\\!)', name: 'keyword.other.dune'},
{match: '(:\\w+)\\b', name: 'constant.language.flag.dune'},
{
match: '\\b(standard|fallback|promote|promote-until-then)\\b',
name: 'constant.language.rule.mode.dune'
},
{include: '#string'},
{include: '#variable'},
{include: '#list'},
{include: '#atom'}
],
repository: {
atom: {patterns: [{match: '\\b[^\\s]+\\b', name: 'meta.atom.dune'}]},
'comment-inner': {
patterns: [
{
begin: '\\(',
end: '\\)',
name: 'comment.sexp.inner.dune',
patterns: [{include: '#comment-inner'}]
}
]
},
comments: {
patterns: [
{
begin: '#\\|',
beginCaptures: {
0: {name: 'punctuation.definition.comment.begin.dune'}
},
end: '\\|#',
endCaptures: {0: {name: 'punctuation.definition.comment.end.dune'}},
name: 'comment.block.dune',
patterns: [{include: '#comments'}]
},
{
begin: '#;\\s*\\(',
end: '\\)',
name: 'comment.sexp.dune',
patterns: [{include: '#comment-inner'}]
},
{match: ';.*$', name: 'comment.line.dune'}
]
},
list: {
patterns: [
{
begin: '(\\()',
captures: {1: {name: 'entity.tag.list.parenthesis.dune'}},
end: '(\\))',
name: 'meta.list.dune',
patterns: [{include: '$self'}]
}
]
},
string: {
patterns: [
{
begin: '(?=[^\\\\])(")',
beginCaptures: {
1: {name: 'punctuation.definition.string.begin.dune'}
},
end: '(")',
endCaptures: {1: {name: 'punctuation.definition.string.end.dune'}},
name: 'string.quoted.double.dune',
patterns: [
{match: '\\\\"', name: 'constant.character.string.escape.dune'},
{include: '#variable'}
]
}
]
},
variable: {patterns: [{match: '\\${[^}]*}', name: 'variable.other.dune'}]}
},
scopeName: 'source.dune'
}
export default grammar