thrift.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. var 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', end: /\{/,
  28. illegal: /\n/,
  29. contains: [
  30. hljs.inherit(hljs.TITLE_MODE, {
  31. starts: {endsWithParent: true, excludeEnd: true} // hack: eating everything after the first title
  32. })
  33. ]
  34. },
  35. {
  36. begin: '\\b(set|list|map)\\s*<', end: '>',
  37. keywords: BUILT_IN_TYPES,
  38. contains: ['self']
  39. }
  40. ]
  41. };
  42. }
  43. module.exports = thrift;