UNPKG

2.44 kBJavaScriptView Raw
1/*
2Language: Ceylon
3Author: Lucas Werkmeister <mail@lucaswerkmeister.de>
4Website: https://ceylon-lang.org
5*/
6
7/** @type LanguageFn */
8function 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
120 return {
121 name: 'Ceylon',
122 keywords: {
123 keyword: KEYWORDS.concat(DECLARATION_MODIFIERS),
124 meta: DOCUMENTATION
125 },
126 illegal: '\\$[^01]|#[^0-9a-fA-F]',
127 contains: [
128 hljs.C_LINE_COMMENT_MODE,
129 hljs.COMMENT('/\\*', '\\*/', {
130 contains: ['self']
131 }),
132 {
133 // compiler annotation
134 className: 'meta',
135 begin: '@[a-z]\\w*(?::"[^"]*")?'
136 }
137 ].concat(EXPRESSIONS)
138 };
139}
140
141export { ceylon as default };