]> luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/capnproto.js
Initial commit.
[flow-web.git] / static / highlight / languages / capnproto.js
1 /*! `capnproto` grammar compiled for Highlight.js 11.11.1 */
2 (function(){
3 var hljsGrammar = (function () {
4 'use strict';
5
6 /*
7 Language: Cap’n Proto
8 Author: Oleg Efimov <efimovov@gmail.com>
9 Description: Cap’n Proto message definition format
10 Website: https://capnproto.org/capnp-tool.html
11 Category: protocols
12 */
13
14 /** @type LanguageFn */
15 function capnproto(hljs) {
16 const KEYWORDS = [
17 "struct",
18 "enum",
19 "interface",
20 "union",
21 "group",
22 "import",
23 "using",
24 "const",
25 "annotation",
26 "extends",
27 "in",
28 "of",
29 "on",
30 "as",
31 "with",
32 "from",
33 "fixed"
34 ];
35 const TYPES = [
36 "Void",
37 "Bool",
38 "Int8",
39 "Int16",
40 "Int32",
41 "Int64",
42 "UInt8",
43 "UInt16",
44 "UInt32",
45 "UInt64",
46 "Float32",
47 "Float64",
48 "Text",
49 "Data",
50 "AnyPointer",
51 "AnyStruct",
52 "Capability",
53 "List"
54 ];
55 const LITERALS = [
56 "true",
57 "false"
58 ];
59 const CLASS_DEFINITION = {
60 variants: [
61 { match: [
62 /(struct|enum|interface)/,
63 /\s+/,
64 hljs.IDENT_RE
65 ] },
66 { match: [
67 /extends/,
68 /\s*\(/,
69 hljs.IDENT_RE,
70 /\s*\)/
71 ] }
72 ],
73 scope: {
74 1: "keyword",
75 3: "title.class"
76 }
77 };
78 return {
79 name: 'Cap’n Proto',
80 aliases: [ 'capnp' ],
81 keywords: {
82 keyword: KEYWORDS,
83 type: TYPES,
84 literal: LITERALS
85 },
86 contains: [
87 hljs.QUOTE_STRING_MODE,
88 hljs.NUMBER_MODE,
89 hljs.HASH_COMMENT_MODE,
90 {
91 className: 'meta',
92 begin: /@0x[\w\d]{16};/,
93 illegal: /\n/
94 },
95 {
96 className: 'symbol',
97 begin: /@\d+\b/
98 },
99 CLASS_DEFINITION
100 ]
101 };
102 }
103
104 return capnproto;
105
106 })();
107
108 hljs.registerLanguage('capnproto', hljsGrammar);
109 })();