pony.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. module.exports = function(hljs) {
  2. var KEYWORDS = {
  3. keyword:
  4. 'actor addressof and as be break class compile_error compile_intrinsic ' +
  5. 'consume continue delegate digestof do else elseif embed end error ' +
  6. 'for fun if ifdef in interface is isnt lambda let match new not object ' +
  7. 'or primitive recover repeat return struct then trait try type until ' +
  8. 'use var where while with xor',
  9. meta:
  10. 'iso val tag trn box ref',
  11. literal:
  12. 'this false true'
  13. };
  14. var TRIPLE_QUOTE_STRING_MODE = {
  15. className: 'string',
  16. begin: '"""', end: '"""',
  17. relevance: 10
  18. };
  19. var QUOTE_STRING_MODE = {
  20. className: 'string',
  21. begin: '"', end: '"',
  22. contains: [hljs.BACKSLASH_ESCAPE]
  23. };
  24. var SINGLE_QUOTE_CHAR_MODE = {
  25. className: 'string',
  26. begin: '\'', end: '\'',
  27. contains: [hljs.BACKSLASH_ESCAPE],
  28. relevance: 0
  29. };
  30. var TYPE_NAME = {
  31. className: 'type',
  32. begin: '\\b_?[A-Z][\\w]*',
  33. relevance: 0
  34. };
  35. var PRIMED_NAME = {
  36. begin: hljs.IDENT_RE + '\'', relevance: 0
  37. };
  38. var NUMBER_MODE = {
  39. className: 'number',
  40. begin: '(-?)(\\b0[xX][a-fA-F0-9]+|\\b0[bB][01]+|(\\b\\d+(_\\d+)?(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)',
  41. relevance: 0
  42. };
  43. /**
  44. * The `FUNCTION` and `CLASS` modes were intentionally removed to simplify
  45. * highlighting and fix cases like
  46. * ```
  47. * interface Iterator[A: A]
  48. * fun has_next(): Bool
  49. * fun next(): A?
  50. * ```
  51. * where it is valid to have a function head without a body
  52. */
  53. return {
  54. keywords: KEYWORDS,
  55. contains: [
  56. TYPE_NAME,
  57. TRIPLE_QUOTE_STRING_MODE,
  58. QUOTE_STRING_MODE,
  59. SINGLE_QUOTE_CHAR_MODE,
  60. PRIMED_NAME,
  61. NUMBER_MODE,
  62. hljs.C_LINE_COMMENT_MODE,
  63. hljs.C_BLOCK_COMMENT_MODE
  64. ]
  65. };
  66. };