protobuf.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. function protobuf(hljs) {
  9. return {
  10. name: 'Protocol Buffers',
  11. keywords: {
  12. keyword: 'package import option optional required repeated group oneof',
  13. built_in: 'double float int32 int64 uint32 uint64 sint32 sint64 ' +
  14. 'fixed32 fixed64 sfixed32 sfixed64 bool string bytes',
  15. literal: 'true false'
  16. },
  17. contains: [
  18. hljs.QUOTE_STRING_MODE,
  19. hljs.NUMBER_MODE,
  20. hljs.C_LINE_COMMENT_MODE,
  21. hljs.C_BLOCK_COMMENT_MODE,
  22. {
  23. className: 'class',
  24. beginKeywords: 'message enum service', end: /\{/,
  25. illegal: /\n/,
  26. contains: [
  27. hljs.inherit(hljs.TITLE_MODE, {
  28. starts: {endsWithParent: true, excludeEnd: true} // hack: eating everything after the first title
  29. })
  30. ]
  31. },
  32. {
  33. className: 'function',
  34. beginKeywords: 'rpc',
  35. end: /[{;]/, excludeEnd: true,
  36. keywords: 'rpc returns'
  37. },
  38. { // match enum items (relevance)
  39. // BLAH = ...;
  40. begin: /^\s*[A-Z_]+(?=\s*=[^\n]+;$)/
  41. }
  42. ]
  43. };
  44. }
  45. module.exports = protobuf;