1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | function thrift(hljs) {
|
10 | const TYPES = [
|
11 | "bool",
|
12 | "byte",
|
13 | "i16",
|
14 | "i32",
|
15 | "i64",
|
16 | "double",
|
17 | "string",
|
18 | "binary"
|
19 | ];
|
20 | const KEYWORDS = [
|
21 | "namespace",
|
22 | "const",
|
23 | "typedef",
|
24 | "struct",
|
25 | "enum",
|
26 | "service",
|
27 | "exception",
|
28 | "void",
|
29 | "oneway",
|
30 | "set",
|
31 | "list",
|
32 | "map",
|
33 | "required",
|
34 | "optional"
|
35 | ];
|
36 | return {
|
37 | name: 'Thrift',
|
38 | keywords: {
|
39 | keyword: KEYWORDS,
|
40 | type: TYPES,
|
41 | literal: 'true false'
|
42 | },
|
43 | contains: [
|
44 | hljs.QUOTE_STRING_MODE,
|
45 | hljs.NUMBER_MODE,
|
46 | hljs.C_LINE_COMMENT_MODE,
|
47 | hljs.C_BLOCK_COMMENT_MODE,
|
48 | {
|
49 | className: 'class',
|
50 | beginKeywords: 'struct enum service exception',
|
51 | end: /\{/,
|
52 | illegal: /\n/,
|
53 | contains: [
|
54 | hljs.inherit(hljs.TITLE_MODE, {
|
55 |
|
56 | starts: {
|
57 | endsWithParent: true,
|
58 | excludeEnd: true
|
59 | }
|
60 | })
|
61 | ]
|
62 | },
|
63 | {
|
64 | begin: '\\b(set|list|map)\\s*<',
|
65 | keywords: {
|
66 | type: [...TYPES, "set", "list", "map"]
|
67 | },
|
68 | end: '>',
|
69 | contains: [ 'self' ]
|
70 | }
|
71 | ]
|
72 | };
|
73 | }
|
74 |
|
75 | export { thrift as default };
|