ceylon.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. Language: Ceylon
  3. Author: Lucas Werkmeister <mail@lucaswerkmeister.de>
  4. Website: https://ceylon-lang.org
  5. */
  6. /** @type LanguageFn */
  7. function ceylon(hljs) {
  8. // 2.3. Identifiers and keywords
  9. const KEYWORDS =
  10. 'assembly module package import alias class interface object given value ' +
  11. 'assign void function new of extends satisfies abstracts in out return ' +
  12. 'break continue throw assert dynamic if else switch case for while try ' +
  13. 'catch finally then let this outer super is exists nonempty';
  14. // 7.4.1 Declaration Modifiers
  15. const DECLARATION_MODIFIERS =
  16. 'shared abstract formal default actual variable late native deprecated ' +
  17. 'final sealed annotation suppressWarnings small';
  18. // 7.4.2 Documentation
  19. const DOCUMENTATION =
  20. 'doc by license see throws tagged';
  21. const SUBST = {
  22. className: 'subst',
  23. excludeBegin: true,
  24. excludeEnd: true,
  25. begin: /``/,
  26. end: /``/,
  27. keywords: KEYWORDS,
  28. relevance: 10
  29. };
  30. const EXPRESSIONS = [
  31. {
  32. // verbatim string
  33. className: 'string',
  34. begin: '"""',
  35. end: '"""',
  36. relevance: 10
  37. },
  38. {
  39. // string literal or template
  40. className: 'string',
  41. begin: '"',
  42. end: '"',
  43. contains: [SUBST]
  44. },
  45. {
  46. // character literal
  47. className: 'string',
  48. begin: "'",
  49. end: "'"
  50. },
  51. {
  52. // numeric literal
  53. className: 'number',
  54. begin: '#[0-9a-fA-F_]+|\\$[01_]+|[0-9_]+(?:\\.[0-9_](?:[eE][+-]?\\d+)?)?[kMGTPmunpf]?',
  55. relevance: 0
  56. }
  57. ];
  58. SUBST.contains = EXPRESSIONS;
  59. return {
  60. name: 'Ceylon',
  61. keywords: {
  62. keyword: KEYWORDS + ' ' + DECLARATION_MODIFIERS,
  63. meta: DOCUMENTATION
  64. },
  65. illegal: '\\$[^01]|#[^0-9a-fA-F]',
  66. contains: [
  67. hljs.C_LINE_COMMENT_MODE,
  68. hljs.COMMENT('/\\*', '\\*/', {
  69. contains: ['self']
  70. }),
  71. {
  72. // compiler annotation
  73. className: 'meta',
  74. begin: '@[a-z]\\w*(?::"[^"]*")?'
  75. }
  76. ].concat(EXPRESSIONS)
  77. };
  78. }
  79. module.exports = ceylon;