dts.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. module.exports = function(hljs) {
  2. var STRINGS = {
  3. className: 'string',
  4. variants: [
  5. hljs.inherit(hljs.QUOTE_STRING_MODE, { begin: '((u8?|U)|L)?"' }),
  6. {
  7. begin: '(u8?|U)?R"', end: '"',
  8. contains: [hljs.BACKSLASH_ESCAPE]
  9. },
  10. {
  11. begin: '\'\\\\?.', end: '\'',
  12. illegal: '.'
  13. }
  14. ]
  15. };
  16. var NUMBERS = {
  17. className: 'number',
  18. variants: [
  19. { begin: '\\b(\\d+(\\.\\d*)?|\\.\\d+)(u|U|l|L|ul|UL|f|F)' },
  20. { begin: hljs.C_NUMBER_RE }
  21. ],
  22. relevance: 0
  23. };
  24. var PREPROCESSOR = {
  25. className: 'meta',
  26. begin: '#', end: '$',
  27. keywords: {'meta-keyword': 'if else elif endif define undef ifdef ifndef'},
  28. contains: [
  29. {
  30. begin: /\\\n/, relevance: 0
  31. },
  32. {
  33. beginKeywords: 'include', end: '$',
  34. keywords: {'meta-keyword': 'include'},
  35. contains: [
  36. hljs.inherit(STRINGS, {className: 'meta-string'}),
  37. {
  38. className: 'meta-string',
  39. begin: '<', end: '>',
  40. illegal: '\\n'
  41. }
  42. ]
  43. },
  44. STRINGS,
  45. hljs.C_LINE_COMMENT_MODE,
  46. hljs.C_BLOCK_COMMENT_MODE
  47. ]
  48. };
  49. var DTS_REFERENCE = {
  50. className: 'variable',
  51. begin: '\\&[a-z\\d_]*\\b'
  52. };
  53. var DTS_KEYWORD = {
  54. className: 'meta-keyword',
  55. begin: '/[a-z][a-z\\d-]*/'
  56. };
  57. var DTS_LABEL = {
  58. className: 'symbol',
  59. begin: '^\\s*[a-zA-Z_][a-zA-Z\\d_]*:'
  60. };
  61. var DTS_CELL_PROPERTY = {
  62. className: 'params',
  63. begin: '<',
  64. end: '>',
  65. contains: [
  66. NUMBERS,
  67. DTS_REFERENCE
  68. ]
  69. };
  70. var DTS_NODE = {
  71. className: 'class',
  72. begin: /[a-zA-Z_][a-zA-Z\d_@]*\s{/,
  73. end: /[{;=]/,
  74. returnBegin: true,
  75. excludeEnd: true
  76. };
  77. var DTS_ROOT_NODE = {
  78. className: 'class',
  79. begin: '/\\s*{',
  80. end: '};',
  81. relevance: 10,
  82. contains: [
  83. DTS_REFERENCE,
  84. DTS_KEYWORD,
  85. DTS_LABEL,
  86. DTS_NODE,
  87. DTS_CELL_PROPERTY,
  88. hljs.C_LINE_COMMENT_MODE,
  89. hljs.C_BLOCK_COMMENT_MODE,
  90. NUMBERS,
  91. STRINGS
  92. ]
  93. };
  94. return {
  95. keywords: "",
  96. contains: [
  97. DTS_ROOT_NODE,
  98. DTS_REFERENCE,
  99. DTS_KEYWORD,
  100. DTS_LABEL,
  101. DTS_NODE,
  102. DTS_CELL_PROPERTY,
  103. hljs.C_LINE_COMMENT_MODE,
  104. hljs.C_BLOCK_COMMENT_MODE,
  105. NUMBERS,
  106. STRINGS,
  107. PREPROCESSOR,
  108. {
  109. begin: hljs.IDENT_RE + '::',
  110. keywords: ""
  111. }
  112. ]
  113. };
  114. };