ceylon.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. var 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. var DECLARATION_MODIFIERS =
  16. 'shared abstract formal default actual variable late native deprecated ' +
  17. 'final sealed annotation suppressWarnings small';
  18. // 7.4.2 Documentation
  19. var DOCUMENTATION =
  20. 'doc by license see throws tagged';
  21. var SUBST = {
  22. className: 'subst', excludeBegin: true, excludeEnd: true,
  23. begin: /``/, end: /``/,
  24. keywords: KEYWORDS,
  25. relevance: 10
  26. };
  27. var EXPRESSIONS = [
  28. {
  29. // verbatim string
  30. className: 'string',
  31. begin: '"""',
  32. end: '"""',
  33. relevance: 10
  34. },
  35. {
  36. // string literal or template
  37. className: 'string',
  38. begin: '"', end: '"',
  39. contains: [SUBST]
  40. },
  41. {
  42. // character literal
  43. className: 'string',
  44. begin: "'",
  45. end: "'"
  46. },
  47. {
  48. // numeric literal
  49. className: 'number',
  50. begin: '#[0-9a-fA-F_]+|\\$[01_]+|[0-9_]+(?:\\.[0-9_](?:[eE][+-]?\\d+)?)?[kMGTPmunpf]?',
  51. relevance: 0
  52. }
  53. ];
  54. SUBST.contains = EXPRESSIONS;
  55. return {
  56. name: 'Ceylon',
  57. keywords: {
  58. keyword: KEYWORDS + ' ' + DECLARATION_MODIFIERS,
  59. meta: DOCUMENTATION
  60. },
  61. illegal: '\\$[^01]|#[^0-9a-fA-F]',
  62. contains: [
  63. hljs.C_LINE_COMMENT_MODE,
  64. hljs.COMMENT('/\\*', '\\*/', {contains: ['self']}),
  65. {
  66. // compiler annotation
  67. className: 'meta',
  68. begin: '@[a-z]\\w*(?:\\:\"[^\"]*\")?'
  69. }
  70. ].concat(EXPRESSIONS)
  71. };
  72. }
  73. module.exports = ceylon;