capnproto.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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', end: /\{/,
  38. illegal: /\n/,
  39. contains: [
  40. hljs.inherit(hljs.TITLE_MODE, {
  41. starts: {endsWithParent: true, excludeEnd: true} // hack: eating everything after the first title
  42. })
  43. ]
  44. },
  45. {
  46. className: 'class',
  47. beginKeywords: 'interface', end: /\{/,
  48. illegal: /\n/,
  49. contains: [
  50. hljs.inherit(hljs.TITLE_MODE, {
  51. starts: {endsWithParent: true, excludeEnd: true} // hack: eating everything after the first title
  52. })
  53. ]
  54. }
  55. ]
  56. };
  57. }
  58. module.exports = capnproto;