pony.js 2.1 KB

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