capnproto.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. Language: Cap’n Proto
  3. Author: Oleg Efimov <efimovov@gmail.com>
  4. Description: Cap’n Proto message definition format
  5. Website: https://capnproto.org/capnp-tool.html
  6. Category: protocols
  7. */
  8. /** @type LanguageFn */
  9. function capnproto(hljs) {
  10. return {
  11. name: 'Cap’n Proto',
  12. aliases: ['capnp'],
  13. keywords: {
  14. keyword:
  15. 'struct enum interface union group import using const annotation extends in of on as with from fixed',
  16. built_in:
  17. 'Void Bool Int8 Int16 Int32 Int64 UInt8 UInt16 UInt32 UInt64 Float32 Float64 ' +
  18. 'Text Data AnyPointer AnyStruct Capability List',
  19. literal:
  20. 'true false'
  21. },
  22. contains: [
  23. hljs.QUOTE_STRING_MODE,
  24. hljs.NUMBER_MODE,
  25. hljs.HASH_COMMENT_MODE,
  26. {
  27. className: 'meta',
  28. begin: /@0x[\w\d]{16};/,
  29. illegal: /\n/
  30. },
  31. {
  32. className: 'symbol',
  33. begin: /@\d+\b/
  34. },
  35. {
  36. className: 'class',
  37. beginKeywords: 'struct enum',
  38. end: /\{/,
  39. illegal: /\n/,
  40. contains: [hljs.inherit(hljs.TITLE_MODE, {
  41. starts: {
  42. endsWithParent: true,
  43. excludeEnd: true
  44. } // hack: eating everything after the first title
  45. })]
  46. },
  47. {
  48. className: 'class',
  49. beginKeywords: 'interface',
  50. end: /\{/,
  51. illegal: /\n/,
  52. contains: [hljs.inherit(hljs.TITLE_MODE, {
  53. starts: {
  54. endsWithParent: true,
  55. excludeEnd: true
  56. } // hack: eating everything after the first title
  57. })]
  58. }
  59. ]
  60. };
  61. }
  62. module.exports = capnproto;