ceylon.js 1.8 KB

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