]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/moonscript.js
1 /*! `moonscript` grammar compiled for Highlight.js 11.11.1 */
3 var hljsGrammar
= (function () {
8 Author: Billy Quith <chinbillybilbo@gmail.com>
9 Description: MoonScript is a programming language that transcompiles to Lua.
10 Origin: coffeescript.js
11 Website: http://moonscript.org/
15 function moonscript(hljs
) {
18 // Moonscript keywords
19 'if then not for in while do return else elseif break continue switch and or '
20 + 'unless when class extends super local import export from using',
24 '_G _VERSION assert collectgarbage dofile error getfenv getmetatable ipairs load '
25 + 'loadfile loadstring module next pairs pcall print rawequal rawget rawset require '
26 + 'select setfenv setmetatable tonumber tostring type unpack xpcall coroutine debug '
27 + 'io math os package string table'
29 const JS_IDENT_RE
= '[A-Za-z$_][0-9A-Za-z$_]*';
37 hljs
.inherit(hljs
.C_NUMBER_MODE
,
41 } }), // a number tries to eat the following slash to prevent treating it as a regexp
48 contains: [ hljs
.BACKSLASH_ESCAPE
]
54 hljs
.BACKSLASH_ESCAPE
,
61 className: 'built_in',
62 begin: '@__' + hljs
.IDENT_RE
64 { begin: '@' + hljs
.IDENT_RE
// relevance booster on par with CoffeeScript
66 { begin: hljs
.IDENT_RE
+ '\\\\' + hljs
.IDENT_RE
// inst\method
69 SUBST
.contains
= EXPRESSIONS
;
71 const TITLE
= hljs
.inherit(hljs
.TITLE_MODE
, { begin: JS_IDENT_RE
});
72 const POSSIBLE_PARAMS_RE
= '(\\(.*\\)\\s*)?\\B[-=]>';
77 /* We need another contained nameless mode to not have every nested
78 pair of parens to be called "params" */
84 contains: [ 'self' ].concat(EXPRESSIONS
)
94 contains: EXPRESSIONS
.concat([
95 hljs
.COMMENT('--', '$'),
97 className: 'function', // function: -> =>
98 begin: '^\\s*' + JS_IDENT_RE
+ '\\s*=\\s*' + POSSIBLE_PARAMS_RE
,
107 begin: /[\(,:=]\s*/, // anonymous function start
111 className: 'function',
112 begin: POSSIBLE_PARAMS_RE
,
121 beginKeywords: 'class',
123 illegal: /[:="\[\]]/,
126 beginKeywords: 'extends',
127 endsWithParent: true,
128 illegal: /[:="\[\]]/,
135 className: 'name', // table
136 begin: JS_IDENT_RE
+ ':',
150 hljs
.registerLanguage('moonscript', hljsGrammar
);