ceylon.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. Language: Ceylon
  3. Author: Lucas Werkmeister <mail@lucaswerkmeister.de>
  4. Website: https://ceylon-lang.org
  5. Category: system
  6. */
  7. /** @type LanguageFn */
  8. function ceylon(hljs) {
  9. // 2.3. Identifiers and keywords
  10. const KEYWORDS = [
  11. "assembly",
  12. "module",
  13. "package",
  14. "import",
  15. "alias",
  16. "class",
  17. "interface",
  18. "object",
  19. "given",
  20. "value",
  21. "assign",
  22. "void",
  23. "function",
  24. "new",
  25. "of",
  26. "extends",
  27. "satisfies",
  28. "abstracts",
  29. "in",
  30. "out",
  31. "return",
  32. "break",
  33. "continue",
  34. "throw",
  35. "assert",
  36. "dynamic",
  37. "if",
  38. "else",
  39. "switch",
  40. "case",
  41. "for",
  42. "while",
  43. "try",
  44. "catch",
  45. "finally",
  46. "then",
  47. "let",
  48. "this",
  49. "outer",
  50. "super",
  51. "is",
  52. "exists",
  53. "nonempty"
  54. ];
  55. // 7.4.1 Declaration Modifiers
  56. const DECLARATION_MODIFIERS = [
  57. "shared",
  58. "abstract",
  59. "formal",
  60. "default",
  61. "actual",
  62. "variable",
  63. "late",
  64. "native",
  65. "deprecated",
  66. "final",
  67. "sealed",
  68. "annotation",
  69. "suppressWarnings",
  70. "small"
  71. ];
  72. // 7.4.2 Documentation
  73. const DOCUMENTATION = [
  74. "doc",
  75. "by",
  76. "license",
  77. "see",
  78. "throws",
  79. "tagged"
  80. ];
  81. const SUBST = {
  82. className: 'subst',
  83. excludeBegin: true,
  84. excludeEnd: true,
  85. begin: /``/,
  86. end: /``/,
  87. keywords: KEYWORDS,
  88. relevance: 10
  89. };
  90. const EXPRESSIONS = [
  91. {
  92. // verbatim string
  93. className: 'string',
  94. begin: '"""',
  95. end: '"""',
  96. relevance: 10
  97. },
  98. {
  99. // string literal or template
  100. className: 'string',
  101. begin: '"',
  102. end: '"',
  103. contains: [ SUBST ]
  104. },
  105. {
  106. // character literal
  107. className: 'string',
  108. begin: "'",
  109. end: "'"
  110. },
  111. {
  112. // numeric literal
  113. className: 'number',
  114. begin: '#[0-9a-fA-F_]+|\\$[01_]+|[0-9_]+(?:\\.[0-9_](?:[eE][+-]?\\d+)?)?[kMGTPmunpf]?',
  115. relevance: 0
  116. }
  117. ];
  118. SUBST.contains = EXPRESSIONS;
  119. return {
  120. name: 'Ceylon',
  121. keywords: {
  122. keyword: KEYWORDS.concat(DECLARATION_MODIFIERS),
  123. meta: DOCUMENTATION
  124. },
  125. illegal: '\\$[^01]|#[^0-9a-fA-F]',
  126. contains: [
  127. hljs.C_LINE_COMMENT_MODE,
  128. hljs.COMMENT('/\\*', '\\*/', { contains: [ 'self' ] }),
  129. {
  130. // compiler annotation
  131. className: 'meta',
  132. begin: '@[a-z]\\w*(?::"[^"]*")?'
  133. }
  134. ].concat(EXPRESSIONS)
  135. };
  136. }
  137. export { ceylon as default };