]> luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/protobuf.js
Initial commit.
[flow-web.git] / static / highlight / es / languages / protobuf.js
1 /*! `protobuf` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar = (function () {
3 'use strict';
4
5 /*
6 Language: Protocol Buffers
7 Author: Dan Tao <daniel.tao@gmail.com>
8 Description: Protocol buffer message definition format
9 Website: https://developers.google.com/protocol-buffers/docs/proto3
10 Category: protocols
11 */
12
13 function protobuf(hljs) {
14 const KEYWORDS = [
15 "package",
16 "import",
17 "option",
18 "optional",
19 "required",
20 "repeated",
21 "group",
22 "oneof"
23 ];
24 const TYPES = [
25 "double",
26 "float",
27 "int32",
28 "int64",
29 "uint32",
30 "uint64",
31 "sint32",
32 "sint64",
33 "fixed32",
34 "fixed64",
35 "sfixed32",
36 "sfixed64",
37 "bool",
38 "string",
39 "bytes"
40 ];
41 const CLASS_DEFINITION = {
42 match: [
43 /(message|enum|service)\s+/,
44 hljs.IDENT_RE
45 ],
46 scope: {
47 1: "keyword",
48 2: "title.class"
49 }
50 };
51
52 return {
53 name: 'Protocol Buffers',
54 aliases: ['proto'],
55 keywords: {
56 keyword: KEYWORDS,
57 type: TYPES,
58 literal: [
59 'true',
60 'false'
61 ]
62 },
63 contains: [
64 hljs.QUOTE_STRING_MODE,
65 hljs.NUMBER_MODE,
66 hljs.C_LINE_COMMENT_MODE,
67 hljs.C_BLOCK_COMMENT_MODE,
68 CLASS_DEFINITION,
69 {
70 className: 'function',
71 beginKeywords: 'rpc',
72 end: /[{;]/,
73 excludeEnd: true,
74 keywords: 'rpc returns'
75 },
76 { // match enum items (relevance)
77 // BLAH = ...;
78 begin: /^\s*[A-Z_]+(?=\s*=[^\n]+;$)/ }
79 ]
80 };
81 }
82
83 return protobuf;
84
85 })();
86 ;
87 export default hljsGrammar;