basant307/AI_Governance_Project
048
1/*2Language: MoonScript3Author: Billy Quith <chinbillybilbo@gmail.com>4Description: MoonScript is a programming language that transcompiles to Lua.5Origin: coffeescript.js6Website: http://moonscript.org/7Category: scripting8*/9 10function moonscript(hljs) {11 const KEYWORDS = {12 keyword:13 // Moonscript keywords14 'if then not for in while do return else elseif break continue switch and or '15 + 'unless when class extends super local import export from using',16 literal:17 'true false nil',18 built_in:19 '_G _VERSION assert collectgarbage dofile error getfenv getmetatable ipairs load '20 + 'loadfile loadstring module next pairs pcall print rawequal rawget rawset require '21 + 'select setfenv setmetatable tonumber tostring type unpack xpcall coroutine debug '22 + 'io math os package string table'23 };24 const JS_IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*';25 const SUBST = {26 className: 'subst',27 begin: /#\{/,28 end: /\}/,29 keywords: KEYWORDS30 };31 const EXPRESSIONS = [32 hljs.inherit(hljs.C_NUMBER_MODE,33 { starts: {34 end: '(\\s*/)?',35 relevance: 036 } }), // a number tries to eat the following slash to prevent treating it as a regexp37 {38 className: 'string',39 variants: [40 {41 begin: /'/,42 end: /'/,43 contains: [ hljs.BACKSLASH_ESCAPE ]44 },45 {46 begin: /"/,47 end: /"/,48 contains: [49 hljs.BACKSLASH_ESCAPE,50 SUBST51 ]52 }53 ]54 },55 {56 className: 'built_in',57 begin: '@__' + hljs.IDENT_RE58 },59 { begin: '@' + hljs.IDENT_RE // relevance booster on par with CoffeeScript60 },61 { begin: hljs.IDENT_RE + '\\\\' + hljs.IDENT_RE // inst\method62 }63 ];64 SUBST.contains = EXPRESSIONS;65 66 const TITLE = hljs.inherit(hljs.TITLE_MODE, { begin: JS_IDENT_RE });67 const POSSIBLE_PARAMS_RE = '(\\(.*\\)\\s*)?\\B[-=]>';68 const PARAMS = {69 className: 'params',70 begin: '\\([^\\(]',71 returnBegin: true,72 /* We need another contained nameless mode to not have every nested73 pair of parens to be called "params" */74 contains: [75 {76 begin: /\(/,77 end: /\)/,78 keywords: KEYWORDS,79 contains: [ 'self' ].concat(EXPRESSIONS)80 }81 ]82 };83 84 return {85 name: 'MoonScript',86 aliases: [ 'moon' ],87 keywords: KEYWORDS,88 illegal: /\/\*/,89 contains: EXPRESSIONS.concat([90 hljs.COMMENT('--', '$'),91 {92 className: 'function', // function: -> =>93 begin: '^\\s*' + JS_IDENT_RE + '\\s*=\\s*' + POSSIBLE_PARAMS_RE,94 end: '[-=]>',95 returnBegin: true,96 contains: [97 TITLE,98 PARAMS99 ]100 },101 {102 begin: /[\(,:=]\s*/, // anonymous function start103 relevance: 0,104 contains: [105 {106 className: 'function',107 begin: POSSIBLE_PARAMS_RE,108 end: '[-=]>',109 returnBegin: true,110 contains: [ PARAMS ]111 }112 ]113 },114 {115 className: 'class',116 beginKeywords: 'class',117 end: '$',118 illegal: /[:="\[\]]/,119 contains: [120 {121 beginKeywords: 'extends',122 endsWithParent: true,123 illegal: /[:="\[\]]/,124 contains: [ TITLE ]125 },126 TITLE127 ]128 },129 {130 className: 'name', // table131 begin: JS_IDENT_RE + ':',132 end: ':',133 returnBegin: true,134 returnEnd: true,135 relevance: 0136 }137 ])138 };139}140 141export { moonscript as default };142 