]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/livescript.js
1 /*! `livescript` 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(
154 Author: Taneli Vatanen <taneli.vatanen@gmail.com>
155 Contributors: Jen Evers-Corvina <jen@sevvie.net>
156 Origin: coffeescript.js
157 Description: LiveScript is a programming language that transcompiles to JavaScript. For info about language see http://livescript.net/
158 Website: https://livescript.net
163 function livescript(hljs
) {
164 const LIVESCRIPT_BUILT_INS
= [
168 const LIVESCRIPT_LITERALS
= [
177 const LIVESCRIPT_KEYWORDS
= [
209 keyword: KEYWORDS
.concat(LIVESCRIPT_KEYWORDS
),
210 literal: LITERALS
.concat(LIVESCRIPT_LITERALS
),
211 built_in: BUILT_INS
.concat(LIVESCRIPT_BUILT_INS
)
213 const JS_IDENT_RE
= '[A-Za-z$_](?:-[0-9A-Za-z$_]|[0-9A-Za-z$_])*';
214 const TITLE
= hljs
.inherit(hljs
.TITLE_MODE
, { begin: JS_IDENT_RE
});
221 const SUBST_SIMPLE
= {
223 begin: /#[A-Za-z$_]/,
224 end: /(?:-[0-9A-Za-z$_]|[0-9A-Za-z$_])*/,
227 const EXPRESSIONS
= [
228 hljs
.BINARY_NUMBER_MODE
,
231 begin: '(\\b0[xX][a-fA-F0-9_]+)|(\\b\\d(\\d|_\\d)*(\\.(\\d(\\d|_\\d)*)?)?(_*[eE]([-+]\\d(_\\d|\\d)*)?)?[_a-z]*)',
236 } // a number tries to eat the following slash to prevent treating it as a regexp
244 contains: [ hljs
.BACKSLASH_ESCAPE
]
249 contains: [ hljs
.BACKSLASH_ESCAPE
]
255 hljs
.BACKSLASH_ESCAPE
,
264 hljs
.BACKSLASH_ESCAPE
,
284 hljs
.HASH_COMMENT_MODE
288 // regex can't start with space to parse x / 2 / 3 as two divisions
289 // regex can't start with *, and it supports an "illegal" in the main mode
290 begin: /\/(?![ *])(\\.|[^\\\n])*?\/[gim]*(?=\W)/ }
293 { begin: '@' + JS_IDENT_RE
},
299 subLanguage: 'javascript'
302 SUBST
.contains
= EXPRESSIONS
;
308 /* We need another contained nameless mode to not have every nested
309 pair of parens to be called "params" */
314 keywords: KEYWORDS
$1,
315 contains: [ 'self' ].concat(EXPRESSIONS
)
320 const SYMBOLS
= { begin: '(#=>|=>|\\|>>|-?->|!->)' };
322 const CLASS_DEFINITION
= {
337 4: "title.class.inherited"
345 keywords: KEYWORDS
$1,
347 contains: EXPRESSIONS
.concat([
348 hljs
.COMMENT('\\/\\*', '\\*\\/'),
349 hljs
.HASH_COMMENT_MODE
,
350 SYMBOLS
, // relevance booster
352 className: 'function',
360 begin: '(' + JS_IDENT_RE
+ '\\s*(?:=|:=)\\s*)?(\\(.*\\)\\s*)?\\B->\\*?',
364 begin: '(' + JS_IDENT_RE
+ '\\s*(?:=|:=)\\s*)?!?(\\(.*\\)\\s*)?\\B[-~]{1,2}>\\*?',
365 end: '[-~]{1,2}>\\*?'
368 begin: '(' + JS_IDENT_RE
+ '\\s*(?:=|:=)\\s*)?(\\(.*\\)\\s*)?\\B!?[-~]{1,2}>\\*?',
369 end: '!?[-~]{1,2}>\\*?'
375 begin: JS_IDENT_RE
+ ':',
389 hljs
.registerLanguage('livescript', hljsGrammar
);