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