]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/coffeescript.js
1 /*! `coffeescript` grammar compiled for Highlight.js 11.11.1 */
3 var hljsGrammar
= (function () {
37 // JS handles these with a special rule
48 // It's reached stage 3, which is "recommended for implementation":
60 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects
62 // Fundamental objects
75 // Indexed collections
99 // Control abstraction objects
107 // Internationalization
113 const ERROR_TYPES
= [
124 const BUILT_IN_GLOBALS
= [
139 "decodeURIComponent",
141 "encodeURIComponent",
146 const BUILT_INS
= [].concat(
153 Language: CoffeeScript
154 Author: Dmytrii Nagirniak <dnagir@gmail.com>
155 Contributors: Oleg Efimov <efimovov@gmail.com>, Cédric Néhémie <cedric.nehemie@gmail.com>
156 Description: CoffeeScript is a programming language that transcompiles to JavaScript. For info about language see http://coffeescript.org/
158 Website: https://coffeescript.org
162 /** @type LanguageFn */
163 function coffeescript(hljs
) {
164 const COFFEE_BUILT_INS
= [
168 const COFFEE_LITERALS
= [
174 const COFFEE_KEYWORDS
= [
187 const NOT_VALID_KEYWORDS
= [
194 const excluding
= (list
) =>
195 (kw
) => !list
.includes(kw
);
197 keyword: KEYWORDS
.concat(COFFEE_KEYWORDS
).filter(excluding(NOT_VALID_KEYWORDS
)),
198 literal: LITERALS
.concat(COFFEE_LITERALS
),
199 built_in: BUILT_INS
.concat(COFFEE_BUILT_INS
)
201 const JS_IDENT_RE
= '[A-Za-z$_][0-9A-Za-z$_]*';
208 const EXPRESSIONS
= [
209 hljs
.BINARY_NUMBER_MODE
,
210 hljs
.inherit(hljs
.C_NUMBER_MODE
, { starts: {
213 } }), // a number tries to eat the following slash to prevent treating it as a regexp
220 contains: [ hljs
.BACKSLASH_ESCAPE
]
225 contains: [ hljs
.BACKSLASH_ESCAPE
]
231 hljs
.BACKSLASH_ESCAPE
,
239 hljs
.BACKSLASH_ESCAPE
,
253 hljs
.HASH_COMMENT_MODE
257 begin: '//[gim]{0,3}(?=\\W)',
261 // regex can't start with space to parse x / 2 / 3 as two divisions
262 // regex can't start with *, and it supports an "illegal" in the main mode
263 begin: /\/(?![ *]).*?(?![\\]).\/[gim]{0,3}(?=\W)/ }
266 { begin: '@' + JS_IDENT_RE
// relevance booster
269 subLanguage: 'javascript',
284 SUBST
.contains
= EXPRESSIONS
;
286 const TITLE
= hljs
.inherit(hljs
.TITLE_MODE
, { begin: JS_IDENT_RE
});
287 const POSSIBLE_PARAMS_RE
= '(\\(.*\\)\\s*)?\\B[-=]>';
292 /* We need another contained nameless mode to not have every nested
293 pair of parens to be called "params" */
298 keywords: KEYWORDS
$1,
299 contains: [ 'self' ].concat(EXPRESSIONS
)
304 const CLASS_DEFINITION
= {
319 4: "title.class.inherited"
325 name: 'CoffeeScript',
331 keywords: KEYWORDS
$1,
335 hljs
.COMMENT('###', '###'),
336 hljs
.HASH_COMMENT_MODE
,
338 className: 'function',
339 begin: '^\\s*' + JS_IDENT_RE
+ '\\s*=\\s*' + POSSIBLE_PARAMS_RE
,
348 // anonymous function start
353 className: 'function',
354 begin: POSSIBLE_PARAMS_RE
,
363 begin: JS_IDENT_RE
+ ':',
377 hljs
.registerLanguage('coffeescript', hljsGrammar
);