monkey.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. Language: Monkey
  3. Description: Monkey2 is an easy to use, cross platform, games oriented programming language from Blitz Research.
  4. Author: Arthur Bikmullin <devolonter@gmail.com>
  5. Website: https://blitzresearch.itch.io/monkey2
  6. Category: gaming
  7. */
  8. function monkey(hljs) {
  9. const NUMBER = {
  10. className: 'number',
  11. relevance: 0,
  12. variants: [
  13. { begin: '[$][a-fA-F0-9]+' },
  14. hljs.NUMBER_MODE
  15. ]
  16. };
  17. const FUNC_DEFINITION = {
  18. variants: [
  19. { match: [
  20. /(function|method)/,
  21. /\s+/,
  22. hljs.UNDERSCORE_IDENT_RE,
  23. ] },
  24. ],
  25. scope: {
  26. 1: "keyword",
  27. 3: "title.function"
  28. }
  29. };
  30. const CLASS_DEFINITION = {
  31. variants: [
  32. { match: [
  33. /(class|interface|extends|implements)/,
  34. /\s+/,
  35. hljs.UNDERSCORE_IDENT_RE,
  36. ] },
  37. ],
  38. scope: {
  39. 1: "keyword",
  40. 3: "title.class"
  41. }
  42. };
  43. const BUILT_INS = [
  44. "DebugLog",
  45. "DebugStop",
  46. "Error",
  47. "Print",
  48. "ACos",
  49. "ACosr",
  50. "ASin",
  51. "ASinr",
  52. "ATan",
  53. "ATan2",
  54. "ATan2r",
  55. "ATanr",
  56. "Abs",
  57. "Abs",
  58. "Ceil",
  59. "Clamp",
  60. "Clamp",
  61. "Cos",
  62. "Cosr",
  63. "Exp",
  64. "Floor",
  65. "Log",
  66. "Max",
  67. "Max",
  68. "Min",
  69. "Min",
  70. "Pow",
  71. "Sgn",
  72. "Sgn",
  73. "Sin",
  74. "Sinr",
  75. "Sqrt",
  76. "Tan",
  77. "Tanr",
  78. "Seed",
  79. "PI",
  80. "HALFPI",
  81. "TWOPI"
  82. ];
  83. const LITERALS = [
  84. "true",
  85. "false",
  86. "null"
  87. ];
  88. const KEYWORDS = [
  89. "public",
  90. "private",
  91. "property",
  92. "continue",
  93. "exit",
  94. "extern",
  95. "new",
  96. "try",
  97. "catch",
  98. "eachin",
  99. "not",
  100. "abstract",
  101. "final",
  102. "select",
  103. "case",
  104. "default",
  105. "const",
  106. "local",
  107. "global",
  108. "field",
  109. "end",
  110. "if",
  111. "then",
  112. "else",
  113. "elseif",
  114. "endif",
  115. "while",
  116. "wend",
  117. "repeat",
  118. "until",
  119. "forever",
  120. "for",
  121. "to",
  122. "step",
  123. "next",
  124. "return",
  125. "module",
  126. "inline",
  127. "throw",
  128. "import",
  129. // not positive, but these are not literals
  130. "and",
  131. "or",
  132. "shl",
  133. "shr",
  134. "mod"
  135. ];
  136. return {
  137. name: 'Monkey',
  138. case_insensitive: true,
  139. keywords: {
  140. keyword: KEYWORDS,
  141. built_in: BUILT_INS,
  142. literal: LITERALS
  143. },
  144. illegal: /\/\*/,
  145. contains: [
  146. hljs.COMMENT('#rem', '#end'),
  147. hljs.COMMENT(
  148. "'",
  149. '$',
  150. { relevance: 0 }
  151. ),
  152. FUNC_DEFINITION,
  153. CLASS_DEFINITION,
  154. {
  155. className: 'variable.language',
  156. begin: /\b(self|super)\b/
  157. },
  158. {
  159. className: 'meta',
  160. begin: /\s*#/,
  161. end: '$',
  162. keywords: { keyword: 'if else elseif endif end then' }
  163. },
  164. {
  165. match: [
  166. /^\s*/,
  167. /strict\b/
  168. ],
  169. scope: { 2: "meta" }
  170. },
  171. {
  172. beginKeywords: 'alias',
  173. end: '=',
  174. contains: [ hljs.UNDERSCORE_TITLE_MODE ]
  175. },
  176. hljs.QUOTE_STRING_MODE,
  177. NUMBER
  178. ]
  179. };
  180. }
  181. export { monkey as default };