UNPKG

2.39 kBJavaScriptView Raw
1Prism.languages.moonscript = {
2 'comment': /--.*/,
3 'string': [
4 {
5 pattern: /'[^']*'|\[(=*)\[[\s\S]*?\]\1\]/,
6 greedy: true
7 },
8 {
9 pattern: /"[^"]*"/,
10 greedy: true,
11 inside: {
12 'interpolation': {
13 pattern: /#\{[^{}]*\}/,
14 inside: {
15 'moonscript': {
16 pattern: /(^#\{)[\s\S]+(?=\})/,
17 lookbehind: true,
18 inside: null // see beow
19 },
20 'interpolation-punctuation': {
21 pattern: /#\{|\}/,
22 alias: 'punctuation'
23 }
24 }
25 }
26 }
27 }
28 ],
29 'class-name': [
30 {
31 pattern: /(\b(?:class|extends)[ \t]+)\w+/,
32 lookbehind: true
33 },
34 // class-like names start with a capital letter
35 /\b[A-Z]\w*/
36 ],
37 'keyword': /\b(?:class|continue|do|else|elseif|export|extends|for|from|if|import|in|local|nil|return|self|super|switch|then|unless|using|when|while|with)\b/,
38 'variable': /@@?\w*/,
39 'property': {
40 pattern: /\b(?!\d)\w+(?=:)|(:)(?!\d)\w+/,
41 lookbehind: true
42 },
43 'function': {
44 pattern: /\b(?:_G|_VERSION|assert|collectgarbage|coroutine\.(?:create|resume|running|status|wrap|yield)|debug\.(?:debug|getfenv|gethook|getinfo|getlocal|getmetatable|getregistry|getupvalue|setfenv|sethook|setlocal|setmetatable|setupvalue|traceback)|dofile|error|getfenv|getmetatable|io\.(?:close|flush|input|lines|open|output|popen|read|stderr|stdin|stdout|tmpfile|type|write)|ipairs|load|loadfile|loadstring|math\.(?:abs|acos|asin|atan|atan2|ceil|cos|cosh|deg|exp|floor|fmod|frexp|ldexp|log|log10|max|min|modf|pi|pow|rad|random|randomseed|sin|sinh|sqrt|tan|tanh)|module|next|os\.(?:clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)|package\.(?:cpath|loaded|loadlib|path|preload|seeall)|pairs|pcall|print|rawequal|rawget|rawset|require|select|setfenv|setmetatable|string\.(?:byte|char|dump|find|format|gmatch|gsub|len|lower|match|rep|reverse|sub|upper)|table\.(?:concat|insert|maxn|remove|sort)|tonumber|tostring|type|unpack|xpcall)\b/,
45 inside: {
46 'punctuation': /\./
47 }
48 },
49 'boolean': /\b(?:false|true)\b/,
50 'number': /(?:\B\.\d+|\b\d+\.\d+|\b\d+(?=[eE]))(?:[eE][-+]?\d+)?\b|\b(?:0x[a-fA-F\d]+|\d+)(?:U?LL)?\b/,
51 'operator': /\.{3}|[-=]>|~=|(?:[-+*/%<>!=]|\.\.)=?|[:#^]|\b(?:and|or)\b=?|\b(?:not)\b/,
52 'punctuation': /[.,()[\]{}\\]/
53};
54
55Prism.languages.moonscript.string[1].inside.interpolation.inside.moonscript.inside = Prism.languages.moonscript;
56
57Prism.languages.moon = Prism.languages.moonscript;