-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
protobuf.js
77 lines (75 loc) · 1.39 KB
/
protobuf.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
/*
Language: Protocol Buffers
Author: Dan Tao <daniel.tao@gmail.com>
Description: Protocol buffer message definition format
Website: https://developers.google.com/protocol-buffers/docs/proto3
Category: protocols
*/
export default function(hljs) {
const KEYWORDS = [
"package",
"import",
"option",
"optional",
"required",
"repeated",
"group",
"oneof"
];
const TYPES = [
"double",
"float",
"int32",
"int64",
"uint32",
"uint64",
"sint32",
"sint64",
"fixed32",
"fixed64",
"sfixed32",
"sfixed64",
"bool",
"string",
"bytes"
];
const CLASS_DEFINITION = {
match: [
/(message|enum|service)\s+/,
hljs.IDENT_RE
],
scope: {
1: "keyword",
2: "title.class"
}
};
return {
name: 'Protocol Buffers',
aliases: ['proto'],
keywords: {
keyword: KEYWORDS,
type: TYPES,
literal: [
'true',
'false'
]
},
contains: [
hljs.QUOTE_STRING_MODE,
hljs.NUMBER_MODE,
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
CLASS_DEFINITION,
{
className: 'function',
beginKeywords: 'rpc',
end: /[{;]/,
excludeEnd: true,
keywords: 'rpc returns'
},
{ // match enum items (relevance)
// BLAH = ...;
begin: /^\s*[A-Z_]+(?=\s*=[^\n]+;$)/ }
]
};
}