r.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. module.exports = function(hljs) {
  2. var IDENT_RE = '([a-zA-Z]|\\.[a-zA-Z.])[a-zA-Z0-9._]*';
  3. return {
  4. contains: [
  5. hljs.HASH_COMMENT_MODE,
  6. {
  7. begin: IDENT_RE,
  8. lexemes: IDENT_RE,
  9. keywords: {
  10. keyword:
  11. 'function if in break next repeat else for return switch while try tryCatch ' +
  12. 'stop warning require library attach detach source setMethod setGeneric ' +
  13. 'setGroupGeneric setClass ...',
  14. literal:
  15. 'NULL NA TRUE FALSE T F Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 ' +
  16. 'NA_complex_|10'
  17. },
  18. relevance: 0
  19. },
  20. {
  21. // hex value
  22. className: 'number',
  23. begin: "0[xX][0-9a-fA-F]+[Li]?\\b",
  24. relevance: 0
  25. },
  26. {
  27. // explicit integer
  28. className: 'number',
  29. begin: "\\d+(?:[eE][+\\-]?\\d*)?L\\b",
  30. relevance: 0
  31. },
  32. {
  33. // number with trailing decimal
  34. className: 'number',
  35. begin: "\\d+\\.(?!\\d)(?:i\\b)?",
  36. relevance: 0
  37. },
  38. {
  39. // number
  40. className: 'number',
  41. begin: "\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d*)?i?\\b",
  42. relevance: 0
  43. },
  44. {
  45. // number with leading decimal
  46. className: 'number',
  47. begin: "\\.\\d+(?:[eE][+\\-]?\\d*)?i?\\b",
  48. relevance: 0
  49. },
  50. {
  51. // escaped identifier
  52. begin: '`',
  53. end: '`',
  54. relevance: 0
  55. },
  56. {
  57. className: 'string',
  58. contains: [hljs.BACKSLASH_ESCAPE],
  59. variants: [
  60. {begin: '"', end: '"'},
  61. {begin: "'", end: "'"}
  62. ]
  63. }
  64. ]
  65. };
  66. };