]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/coffeescript.js
1 /*! `coffeescript` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar
= (function () {
36 // JS handles these with a special rule
47 // It's reached stage 3, which is "recommended for implementation":
59 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects
61 // Fundamental objects
74 // Indexed collections
98 // Control abstraction objects
106 // Internationalization
112 const ERROR_TYPES
= [
123 const BUILT_IN_GLOBALS
= [
138 "decodeURIComponent",
140 "encodeURIComponent",
145 const BUILT_INS
= [].concat(
152 Language: CoffeeScript
153 Author: Dmytrii Nagirniak <dnagir@gmail.com>
154 Contributors: Oleg Efimov <efimovov@gmail.com>, Cédric Néhémie <cedric.nehemie@gmail.com>
155 Description: CoffeeScript is a programming language that transcompiles to JavaScript. For info about language see http://coffeescript.org/
157 Website: https://coffeescript.org
161 /** @type LanguageFn */
162 function coffeescript(hljs
) {
163 const COFFEE_BUILT_INS
= [
167 const COFFEE_LITERALS
= [
173 const COFFEE_KEYWORDS
= [
186 const NOT_VALID_KEYWORDS
= [
193 const excluding
= (list
) =>
194 (kw
) => !list
.includes(kw
);
196 keyword: KEYWORDS
.concat(COFFEE_KEYWORDS
).filter(excluding(NOT_VALID_KEYWORDS
)),
197 literal: LITERALS
.concat(COFFEE_LITERALS
),
198 built_in: BUILT_INS
.concat(COFFEE_BUILT_INS
)
200 const JS_IDENT_RE
= '[A-Za-z$_][0-9A-Za-z$_]*';
207 const EXPRESSIONS
= [
208 hljs
.BINARY_NUMBER_MODE
,
209 hljs
.inherit(hljs
.C_NUMBER_MODE
, { starts: {
212 } }), // a number tries to eat the following slash to prevent treating it as a regexp
219 contains: [ hljs
.BACKSLASH_ESCAPE
]
224 contains: [ hljs
.BACKSLASH_ESCAPE
]
230 hljs
.BACKSLASH_ESCAPE
,
238 hljs
.BACKSLASH_ESCAPE
,
252 hljs
.HASH_COMMENT_MODE
256 begin: '//[gim]{0,3}(?=\\W)',
260 // regex can't start with space to parse x / 2 / 3 as two divisions
261 // regex can't start with *, and it supports an "illegal" in the main mode
262 begin: /\/(?![ *]).*?(?![\\]).\/[gim]{0,3}(?=\W)/ }
265 { begin: '@' + JS_IDENT_RE
// relevance booster
268 subLanguage: 'javascript',
283 SUBST
.contains
= EXPRESSIONS
;
285 const TITLE
= hljs
.inherit(hljs
.TITLE_MODE
, { begin: JS_IDENT_RE
});
286 const POSSIBLE_PARAMS_RE
= '(\\(.*\\)\\s*)?\\B[-=]>';
291 /* We need another contained nameless mode to not have every nested
292 pair of parens to be called "params" */
297 keywords: KEYWORDS
$1,
298 contains: [ 'self' ].concat(EXPRESSIONS
)
303 const CLASS_DEFINITION
= {
318 4: "title.class.inherited"
324 name: 'CoffeeScript',
330 keywords: KEYWORDS
$1,
334 hljs
.COMMENT('###', '###'),
335 hljs
.HASH_COMMENT_MODE
,
337 className: 'function',
338 begin: '^\\s*' + JS_IDENT_RE
+ '\\s*=\\s*' + POSSIBLE_PARAMS_RE
,
347 // anonymous function start
352 className: 'function',
353 begin: POSSIBLE_PARAMS_RE
,
362 begin: JS_IDENT_RE
+ ':',
376 export default hljsGrammar
;