thrift.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. Language: Thrift
  3. Author: Oleg Efimov <efimovov@gmail.com>
  4. Description: Thrift message definition format
  5. Website: https://thrift.apache.org
  6. Category: protocols
  7. */
  8. function thrift(hljs) {
  9. const BUILT_IN_TYPES = 'bool byte i16 i32 i64 double string binary';
  10. return {
  11. name: 'Thrift',
  12. keywords: {
  13. keyword:
  14. 'namespace const typedef struct enum service exception void oneway set list map required optional',
  15. built_in:
  16. BUILT_IN_TYPES,
  17. literal:
  18. 'true false'
  19. },
  20. contains: [
  21. hljs.QUOTE_STRING_MODE,
  22. hljs.NUMBER_MODE,
  23. hljs.C_LINE_COMMENT_MODE,
  24. hljs.C_BLOCK_COMMENT_MODE,
  25. {
  26. className: 'class',
  27. beginKeywords: 'struct enum service exception',
  28. end: /\{/,
  29. illegal: /\n/,
  30. contains: [
  31. hljs.inherit(hljs.TITLE_MODE, {
  32. // hack: eating everything after the first title
  33. starts: {
  34. endsWithParent: true,
  35. excludeEnd: true
  36. }
  37. })
  38. ]
  39. },
  40. {
  41. begin: '\\b(set|list|map)\\s*<',
  42. end: '>',
  43. keywords: BUILT_IN_TYPES,
  44. contains: [ 'self' ]
  45. }
  46. ]
  47. };
  48. }
  49. module.exports = thrift;