2024-01-16 21:26:16 +08:00
|
|
|
/*
|
|
|
|
Language: Ceylon
|
|
|
|
Author: Lucas Werkmeister <mail@lucaswerkmeister.de>
|
|
|
|
Website: https://ceylon-lang.org
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @type LanguageFn */
|
|
|
|
function ceylon(hljs) {
|
2023-12-18 13:12:25 +08:00
|
|
|
// 2.3. Identifiers and keywords
|
2024-01-16 21:26:16 +08:00
|
|
|
const KEYWORDS =
|
2023-12-18 13:12:25 +08:00
|
|
|
'assembly module package import alias class interface object given value ' +
|
|
|
|
'assign void function new of extends satisfies abstracts in out return ' +
|
|
|
|
'break continue throw assert dynamic if else switch case for while try ' +
|
|
|
|
'catch finally then let this outer super is exists nonempty';
|
|
|
|
// 7.4.1 Declaration Modifiers
|
2024-01-16 21:26:16 +08:00
|
|
|
const DECLARATION_MODIFIERS =
|
|
|
|
'shared abstract formal default actual variable late native deprecated ' +
|
2023-12-18 13:12:25 +08:00
|
|
|
'final sealed annotation suppressWarnings small';
|
|
|
|
// 7.4.2 Documentation
|
2024-01-16 21:26:16 +08:00
|
|
|
const DOCUMENTATION =
|
2023-12-18 13:12:25 +08:00
|
|
|
'doc by license see throws tagged';
|
2024-01-16 21:26:16 +08:00
|
|
|
const SUBST = {
|
|
|
|
className: 'subst',
|
|
|
|
excludeBegin: true,
|
|
|
|
excludeEnd: true,
|
|
|
|
begin: /``/,
|
|
|
|
end: /``/,
|
2023-12-18 13:12:25 +08:00
|
|
|
keywords: KEYWORDS,
|
|
|
|
relevance: 10
|
|
|
|
};
|
2024-01-16 21:26:16 +08:00
|
|
|
const EXPRESSIONS = [
|
2023-12-18 13:12:25 +08:00
|
|
|
{
|
|
|
|
// verbatim string
|
|
|
|
className: 'string',
|
|
|
|
begin: '"""',
|
|
|
|
end: '"""',
|
|
|
|
relevance: 10
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// string literal or template
|
|
|
|
className: 'string',
|
2024-01-16 21:26:16 +08:00
|
|
|
begin: '"',
|
|
|
|
end: '"',
|
2023-12-18 13:12:25 +08:00
|
|
|
contains: [SUBST]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// character literal
|
|
|
|
className: 'string',
|
|
|
|
begin: "'",
|
|
|
|
end: "'"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// numeric literal
|
|
|
|
className: 'number',
|
|
|
|
begin: '#[0-9a-fA-F_]+|\\$[01_]+|[0-9_]+(?:\\.[0-9_](?:[eE][+-]?\\d+)?)?[kMGTPmunpf]?',
|
|
|
|
relevance: 0
|
|
|
|
}
|
|
|
|
];
|
|
|
|
SUBST.contains = EXPRESSIONS;
|
|
|
|
|
|
|
|
return {
|
2024-01-16 21:26:16 +08:00
|
|
|
name: 'Ceylon',
|
2023-12-18 13:12:25 +08:00
|
|
|
keywords: {
|
|
|
|
keyword: KEYWORDS + ' ' + DECLARATION_MODIFIERS,
|
|
|
|
meta: DOCUMENTATION
|
|
|
|
},
|
|
|
|
illegal: '\\$[^01]|#[^0-9a-fA-F]',
|
|
|
|
contains: [
|
|
|
|
hljs.C_LINE_COMMENT_MODE,
|
2024-01-16 21:26:16 +08:00
|
|
|
hljs.COMMENT('/\\*', '\\*/', {
|
|
|
|
contains: ['self']
|
|
|
|
}),
|
2023-12-18 13:12:25 +08:00
|
|
|
{
|
|
|
|
// compiler annotation
|
|
|
|
className: 'meta',
|
2024-01-16 21:26:16 +08:00
|
|
|
begin: '@[a-z]\\w*(?::"[^"]*")?'
|
2023-12-18 13:12:25 +08:00
|
|
|
}
|
|
|
|
].concat(EXPRESSIONS)
|
|
|
|
};
|
2024-01-16 21:26:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = ceylon;
|