[OCaml] Mobile-friendly clone of cgit.
1
{
2
"name":"Protocol Buffer 3",
3
"scopeName":"source.proto",
4
"fileTypes":["proto"],
5
6
"patterns":[
7
{"include":"#comments"},
8
{"include":"#syntax"},
9
{"include":"#package"},
10
{"include":"#import"},
11
{"include":"#optionStmt"},
12
{"include":"#message"},
13
{"include":"#enum"},
14
{"include":"#service"}
15
],
16
17
"repository":{
18
"comments":{
19
"patterns":[
20
{
21
"name":"comment.block.proto",
22
"begin":"/\\*",
23
"end":"\\*/"
24
},
25
{
26
"name":"comment.line.double-slash.proto",
27
"begin":"//",
28
"end":"$\\n?"
29
}
30
]
31
},
32
"syntax":{
33
"match":"\\s*(syntax)\\s*(=)\\s*(\"proto[23]\")\\s*(;)",
34
"captures":{
35
"1":{"name":"keyword.other.proto"},
36
"2":{"name":"keyword.operator.assignment.proto"},
37
"3":{"name":"string.quoted.double.proto.syntax"},
38
"4":{"name":"punctuation.terminator.proto"}
39
}
40
},
41
"package":{
42
"match":"\\s*(package)\\s+([\\w.]+)\\s*(;)",
43
"captures":{
44
"1":{"name":"keyword.other.proto"},
45
"2":{"name":"string.unquoted.proto.package"},
46
"3":{"name":"punctuation.terminator.proto"}
47
}
48
},
49
"import":{
50
"match":"\\s*(import)\\s+(weak|public)?\\s*(\"[^\"]+\")\\s*(;)",
51
"captures":{
52
"1":{"name":"keyword.other.proto"},
53
"2":{"name":"keyword.other.proto"},
54
"3":{"name":"string.quoted.double.proto.import"},
55
"4":{"name":"punctuation.terminator.proto"}
56
}
57
},
58
"optionStmt":{
59
"begin":"(option)\\s+(\\w+|\\(\\w+(\\.\\w+)*\\))(\\.\\w+)*\\s*(=)",
60
"beginCaptures":{
61
"1":{"name":"keyword.other.proto"},
62
"2":{"name":"support.other.proto"},
63
"3":{"name":"support.other.proto"},
64
"4":{"name":"support.other.proto"},
65
"5":{"name":"keyword.operator.assignment.proto"}
66
},
67
"end":"(;)",
68
"endCaptures":{
69
"1":{"name":"punctuation.terminator.proto"}
70
},
71
"patterns":[
72
{"include":"#constants"},
73
{"include":"#number"},
74
{"include":"#string"},
75
{"include":"#subMsgOption"}
76
]
77
},
78
"subMsgOption":{
79
"begin":"\\{",
80
"end":"\\}",
81
"patterns":[{"include":"#kv"},{"include":"#comments"}]
82
},
83
"kv":{
84
"begin":"(\\w+)\\s*(:)",
85
"beginCaptures":{
86
"1":{"name":"keyword.other.proto"},
87
"2":{"name":"punctuation.separator.key-value.proto"}
88
},
89
"end":"(;)|,|(?=[}/_a-zA-Z])",
90
"endCaptures":{
91
"1":{"name":"punctuation.terminator.proto"}
92
},
93
"patterns":[
94
{"include":"#constants"},
95
{"include":"#number"},
96
{"include":"#string"},
97
{"include":"#subMsgOption"}
98
]
99
},
100
"fieldOptions":{
101
"begin":"\\[",
102
"end":"\\]",
103
"patterns":[
104
{"include":"#constants"},
105
{"include":"#number"},
106
{"include":"#string"},
107
{"include":"#subMsgOption"},
108
{"include":"#optionName"}
109
]
110
},
111
"optionName":{
112
"match":"(\\w+|\\(\\w+(\\.\\w+)*\\))(\\.\\w+)*",
113
"captures":{
114
"1":{"name":"support.other.proto"},
115
"2":{"name":"support.other.proto"},
116
"3":{"name":"support.other.proto"}
117
}
118
},
119
"message":{
120
"begin":"(message|extend)(\\s+)([A-Za-z_][A-Za-z0-9_.]*)(\\s*)(\\{)?",
121
"beginCaptures":{
122
"1":{"name":"keyword.other.proto"},
123
"3":{"name":"entity.name.class.message.proto"}
124
},
125
"end":"\\}",
126
"patterns":[
127
{"include":"#reserved"},
128
{"include":"$self"},
129
{"include":"#enum"},
130
{"include":"#optionStmt"},
131
{"include":"#comments"},
132
{"include":"#oneof"},
133
{"include":"#field"},
134
{"include":"#mapfield"}
135
]
136
},
137
"reserved":{
138
"begin":"(reserved)\\s+",
139
"beginCaptures":{
140
"1":{"name":"keyword.other.proto"}
141
},
142
"end":"(;)",
143
"endCaptures":{
144
"1":{"name":"punctuation.terminator.proto"}
145
},
146
"patterns":[
147
{
148
"match":"(\\d+)(\\s+(to)\\s+(\\d+))?",
149
"captures":{
150
"1":{"name":"constant.numeric.proto"},
151
"3":{"name":"keyword.other.proto"},
152
"4":{"name":"constant.numeric.proto"}
153
}
154
},
155
{"include":"#string"}
156
]
157
},
158
"field":{
159
"begin":"\\s*(optional|repeated|required)?\\s*(\\.?[\\w.]+)\\s+(\\w+)\\s*(=)\\s*(0[xX][0-9a-fA-F]+|[0-9]+)",
160
"beginCaptures":{
161
"1":{"name":"storage.modifier.proto"},
162
"2":{"name":"storage.type.proto"},
163
"3":{"name":"variable.other.proto"},
164
"4":{"name":"keyword.operator.assignment.proto"},
165
"5":{"name":"constant.numeric.proto"}
166
},
167
"end":"(;)",
168
"endCaptures":{
169
"1":{"name":"punctuation.terminator.proto"}
170
},
171
"patterns":[{"include":"#fieldOptions"}]
172
},
173
"mapfield":{
174
"begin":"\\s*(map)\\s*(<)\\s*(\\.?[\\w.]+)\\s*,\\s*(\\.?[\\w.]+)\\s*(>)\\s+(\\w+)\\s*(=)\\s*(\\d+)",
175
"beginCaptures":{
176
"1":{"name":"storage.type.proto"},
177
"2":{"name":"punctuation.definition.typeparameters.begin.proto"},
178
"3":{"name":"storage.type.proto"},
179
"4":{"name":"storage.type.proto"},
180
"5":{"name":"punctuation.definition.typeparameters.end.proto"},
181
"6":{"name":"variable.other.proto"},
182
"7":{"name":"keyword.operator.assignment.proto"},
183
"8":{"name":"constant.numeric.proto"}
184
},
185
"end":"(;)",
186
"endCaptures":{
187
"1":{"name":"punctuation.terminator.proto"}
188
},
189
"patterns":[{"include":"#fieldOptions"}]
190
},
191
"oneof":{
192
"begin":"(oneof)\\s+([A-Za-z][A-Za-z0-9_]*)\\s*\\{?",
193
"beginCaptures":{
194
"1":{"name":"keyword.other.proto"},
195
"2":{"name":"variable.other.proto"}
196
},
197
"end":"\\}",
198
"patterns":[
199
{"include":"#optionStmt"},
200
{"include":"#comments"},
201
{"include":"#field"}
202
]
203
},
204
"enum":{
205
"begin":"(enum)(\\s+)([A-Za-z][A-Za-z0-9_]*)(\\s*)(\\{)?",
206
"beginCaptures":{
207
"1":{"name":"keyword.other.proto"},
208
"3":{"name":"entity.name.class.proto"}
209
},
210
"end":"\\}",
211
"patterns":[
212
{"include":"#reserved"},
213
{"include":"#optionStmt"},
214
{"include":"#comments"},
215
{
216
"begin":"([A-Za-z][A-Za-z0-9_]*)\\s*(=)\\s*(-?0[xX][0-9a-fA-F]+|-?[0-9]+)",
217
"beginCaptures":{
218
"1":{"name":"variable.other.proto"},
219
"2":{"name":"keyword.operator.assignment.proto"},
220
"3":{"name":"constant.numeric.proto"}
221
},
222
"end":"(;)",
223
"endCaptures":{
224
"1":{"name":"punctuation.terminator.proto"}
225
},
226
"patterns":[{"include":"#fieldOptions"}]
227
}
228
]
229
},
230
"service":{
231
"begin":"(service)\\s+([A-Za-z][A-Za-z0-9_.]*)\\s*\\{?",
232
"beginCaptures":{
233
"1":{"name":"keyword.other.proto"},
234
"2":{"name":"entity.name.class.message.proto"}
235
},
236
"end":"\\}",
237
"patterns":[
238
{"include":"#comments"},
239
{"include":"#optionStmt"},
240
{"include":"#method"}
241
]
242
},
243
"method":{
244
"begin":"(rpc)\\s+([A-Za-z][A-Za-z0-9_]*)",
245
"beginCaptures":{
246
"1":{"name":"keyword.other.proto"},
247
"2":{"name":"entity.name.function"}
248
},
249
"end":"\\}|(;)",
250
"endCaptures":{
251
"1":{"name":"punctuation.terminator.proto"}
252
},
253
"patterns":[
254
{"include":"#comments"},
255
{"include":"#optionStmt"},
256
{"include":"#rpcKeywords"},
257
{"include":"#ident"}
258
]
259
},
260
"rpcKeywords":{
261
"match":"\\b(stream|returns)\\b",
262
"name":"keyword.other.proto"
263
},
264
"ident":{
265
"match":"\\.?[A-Za-z][A-Za-z0-9_.]*",
266
"name":"entity.name.class.proto"
267
},
268
"constants":{
269
"match":"\\b(true|false|max|[A-Z_]+)\\b",
270
"name":"constant.language.proto"
271
},
272
"storagetypes":{
273
"match":"\\b(double|float|int32|int64|uint32|uint64|sint32|sint64|fixed32|fixed64|sfixed32|sfixed64|bool|string|bytes)\\b",
274
"name":"storage.type.proto"
275
},
276
"string":{
277
"match":"([\"'])(?:\\\\.|[^\\\\])*?\\1",
278
"name":"string.quoted.double.proto"
279
},
280
"number":{
281
"name":"constant.numeric.proto",
282
"match":"\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)\\b"
283
}
284
}
285
}
286