source: node_modules/refractor/lang/moonscript.js@ d24f17c

main
Last change on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 2.7 KB
RevLine 
[d24f17c]1'use strict'
2
3module.exports = moonscript
4moonscript.displayName = 'moonscript'
5moonscript.aliases = ['moon']
6function moonscript(Prism) {
7 Prism.languages.moonscript = {
8 comment: /--.*/,
9 string: [
10 {
11 pattern: /'[^']*'|\[(=*)\[[\s\S]*?\]\1\]/,
12 greedy: true
13 },
14 {
15 pattern: /"[^"]*"/,
16 greedy: true,
17 inside: {
18 interpolation: {
19 pattern: /#\{[^{}]*\}/,
20 inside: {
21 moonscript: {
22 pattern: /(^#\{)[\s\S]+(?=\})/,
23 lookbehind: true,
24 inside: null // see beow
25 },
26 'interpolation-punctuation': {
27 pattern: /#\{|\}/,
28 alias: 'punctuation'
29 }
30 }
31 }
32 }
33 }
34 ],
35 'class-name': [
36 {
37 pattern: /(\b(?:class|extends)[ \t]+)\w+/,
38 lookbehind: true
39 }, // class-like names start with a capital letter
40 /\b[A-Z]\w*/
41 ],
42 keyword:
43 /\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/,
44 variable: /@@?\w*/,
45 property: {
46 pattern: /\b(?!\d)\w+(?=:)|(:)(?!\d)\w+/,
47 lookbehind: true
48 },
49 function: {
50 pattern:
51 /\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/,
52 inside: {
53 punctuation: /\./
54 }
55 },
56 boolean: /\b(?:false|true)\b/,
57 number:
58 /(?:\B\.\d+|\b\d+\.\d+|\b\d+(?=[eE]))(?:[eE][-+]?\d+)?\b|\b(?:0x[a-fA-F\d]+|\d+)(?:U?LL)?\b/,
59 operator:
60 /\.{3}|[-=]>|~=|(?:[-+*/%<>!=]|\.\.)=?|[:#^]|\b(?:and|or)\b=?|\b(?:not)\b/,
61 punctuation: /[.,()[\]{}\\]/
62 }
63 Prism.languages.moonscript.string[1].inside.interpolation.inside.moonscript.inside =
64 Prism.languages.moonscript
65 Prism.languages.moon = Prism.languages.moonscript
66}
Note: See TracBrowser for help on using the repository browser.