pony.js 2.1 KB

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