protobuf.js (1280B)
1 /* 2 Language: Protocol Buffers 3 Author: Dan Tao <daniel.tao@gmail.com> 4 Description: Protocol buffer message definition format 5 Website: https://developers.google.com/protocol-buffers/docs/proto3 6 Category: protocols 7 */ 8 9 function protobuf(hljs) { 10 return { 11 name: 'Protocol Buffers', 12 keywords: { 13 keyword: 'package import option optional required repeated group oneof', 14 built_in: 'double float int32 int64 uint32 uint64 sint32 sint64 ' + 15 'fixed32 fixed64 sfixed32 sfixed64 bool string bytes', 16 literal: 'true false' 17 }, 18 contains: [ 19 hljs.QUOTE_STRING_MODE, 20 hljs.NUMBER_MODE, 21 hljs.C_LINE_COMMENT_MODE, 22 hljs.C_BLOCK_COMMENT_MODE, 23 { 24 className: 'class', 25 beginKeywords: 'message enum service', end: /\{/, 26 illegal: /\n/, 27 contains: [ 28 hljs.inherit(hljs.TITLE_MODE, { 29 starts: {endsWithParent: true, excludeEnd: true} // hack: eating everything after the first title 30 }) 31 ] 32 }, 33 { 34 className: 'function', 35 beginKeywords: 'rpc', 36 end: /[{;]/, excludeEnd: true, 37 keywords: 'rpc returns' 38 }, 39 { 40 begin: /^\s*[A-Z_]+/, 41 end: /\s*=/, excludeEnd: true 42 } 43 ] 44 }; 45 } 46 47 module.exports = protobuf;