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