groovy.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. module.exports = function(hljs) {
  2. return {
  3. keywords: {
  4. literal : 'true false null',
  5. keyword:
  6. 'byte short char int long boolean float double void ' +
  7. // groovy specific keywords
  8. 'def as in assert trait ' +
  9. // common keywords with Java
  10. 'super this abstract static volatile transient public private protected synchronized final ' +
  11. 'class interface enum if else for while switch case break default continue ' +
  12. 'throw throws try catch finally implements extends new import package return instanceof'
  13. },
  14. contains: [
  15. hljs.COMMENT(
  16. '/\\*\\*',
  17. '\\*/',
  18. {
  19. relevance : 0,
  20. contains : [
  21. {
  22. // eat up @'s in emails to prevent them to be recognized as doctags
  23. begin: /\w+@/, relevance: 0
  24. },
  25. {
  26. className : 'doctag',
  27. begin : '@[A-Za-z]+'
  28. }
  29. ]
  30. }
  31. ),
  32. hljs.C_LINE_COMMENT_MODE,
  33. hljs.C_BLOCK_COMMENT_MODE,
  34. {
  35. className: 'string',
  36. begin: '"""', end: '"""'
  37. },
  38. {
  39. className: 'string',
  40. begin: "'''", end: "'''"
  41. },
  42. {
  43. className: 'string',
  44. begin: "\\$/", end: "/\\$",
  45. relevance: 10
  46. },
  47. hljs.APOS_STRING_MODE,
  48. {
  49. className: 'regexp',
  50. begin: /~?\/[^\/\n]+\//,
  51. contains: [
  52. hljs.BACKSLASH_ESCAPE
  53. ]
  54. },
  55. hljs.QUOTE_STRING_MODE,
  56. {
  57. className: 'meta',
  58. begin: "^#!/usr/bin/env", end: '$',
  59. illegal: '\n'
  60. },
  61. hljs.BINARY_NUMBER_MODE,
  62. {
  63. className: 'class',
  64. beginKeywords: 'class interface trait enum', end: '{',
  65. illegal: ':',
  66. contains: [
  67. {beginKeywords: 'extends implements'},
  68. hljs.UNDERSCORE_TITLE_MODE
  69. ]
  70. },
  71. hljs.C_NUMBER_MODE,
  72. {
  73. className: 'meta', begin: '@[A-Za-z]+'
  74. },
  75. {
  76. // highlight map keys and named parameters as strings
  77. className: 'string', begin: /[^\?]{0}[A-Za-z0-9_$]+ *:/
  78. },
  79. {
  80. // catch middle element of the ternary operator
  81. // to avoid highlight it as a label, named parameter, or map key
  82. begin: /\?/, end: /\:/
  83. },
  84. {
  85. // highlight labeled statements
  86. className: 'symbol', begin: '^\\s*[A-Za-z0-9_$]+:',
  87. relevance: 0
  88. }
  89. ],
  90. illegal: /#|<\//
  91. }
  92. };