nim.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. Language: Nim
  3. Description: Nim is a statically typed compiled systems programming language.
  4. Website: https://nim-lang.org
  5. Category: system
  6. */
  7. function nim(hljs) {
  8. const TYPES = [
  9. "int",
  10. "int8",
  11. "int16",
  12. "int32",
  13. "int64",
  14. "uint",
  15. "uint8",
  16. "uint16",
  17. "uint32",
  18. "uint64",
  19. "float",
  20. "float32",
  21. "float64",
  22. "bool",
  23. "char",
  24. "string",
  25. "cstring",
  26. "pointer",
  27. "expr",
  28. "stmt",
  29. "void",
  30. "auto",
  31. "any",
  32. "range",
  33. "array",
  34. "openarray",
  35. "varargs",
  36. "seq",
  37. "set",
  38. "clong",
  39. "culong",
  40. "cchar",
  41. "cschar",
  42. "cshort",
  43. "cint",
  44. "csize",
  45. "clonglong",
  46. "cfloat",
  47. "cdouble",
  48. "clongdouble",
  49. "cuchar",
  50. "cushort",
  51. "cuint",
  52. "culonglong",
  53. "cstringarray",
  54. "semistatic"
  55. ];
  56. const KEYWORDS = [
  57. "addr",
  58. "and",
  59. "as",
  60. "asm",
  61. "bind",
  62. "block",
  63. "break",
  64. "case",
  65. "cast",
  66. "const",
  67. "continue",
  68. "converter",
  69. "discard",
  70. "distinct",
  71. "div",
  72. "do",
  73. "elif",
  74. "else",
  75. "end",
  76. "enum",
  77. "except",
  78. "export",
  79. "finally",
  80. "for",
  81. "from",
  82. "func",
  83. "generic",
  84. "guarded",
  85. "if",
  86. "import",
  87. "in",
  88. "include",
  89. "interface",
  90. "is",
  91. "isnot",
  92. "iterator",
  93. "let",
  94. "macro",
  95. "method",
  96. "mixin",
  97. "mod",
  98. "nil",
  99. "not",
  100. "notin",
  101. "object",
  102. "of",
  103. "or",
  104. "out",
  105. "proc",
  106. "ptr",
  107. "raise",
  108. "ref",
  109. "return",
  110. "shared",
  111. "shl",
  112. "shr",
  113. "static",
  114. "template",
  115. "try",
  116. "tuple",
  117. "type",
  118. "using",
  119. "var",
  120. "when",
  121. "while",
  122. "with",
  123. "without",
  124. "xor",
  125. "yield"
  126. ];
  127. const BUILT_INS = [
  128. "stdin",
  129. "stdout",
  130. "stderr",
  131. "result"
  132. ];
  133. const LITERALS = [
  134. "true",
  135. "false"
  136. ];
  137. return {
  138. name: 'Nim',
  139. keywords: {
  140. keyword: KEYWORDS,
  141. literal: LITERALS,
  142. type: TYPES,
  143. built_in: BUILT_INS
  144. },
  145. contains: [
  146. {
  147. className: 'meta', // Actually pragma
  148. begin: /\{\./,
  149. end: /\.\}/,
  150. relevance: 10
  151. },
  152. {
  153. className: 'string',
  154. begin: /[a-zA-Z]\w*"/,
  155. end: /"/,
  156. contains: [ { begin: /""/ } ]
  157. },
  158. {
  159. className: 'string',
  160. begin: /([a-zA-Z]\w*)?"""/,
  161. end: /"""/
  162. },
  163. hljs.QUOTE_STRING_MODE,
  164. {
  165. className: 'type',
  166. begin: /\b[A-Z]\w+\b/,
  167. relevance: 0
  168. },
  169. {
  170. className: 'number',
  171. relevance: 0,
  172. variants: [
  173. { begin: /\b(0[xX][0-9a-fA-F][_0-9a-fA-F]*)('?[iIuU](8|16|32|64))?/ },
  174. { begin: /\b(0o[0-7][_0-7]*)('?[iIuUfF](8|16|32|64))?/ },
  175. { begin: /\b(0(b|B)[01][_01]*)('?[iIuUfF](8|16|32|64))?/ },
  176. { begin: /\b(\d[_\d]*)('?[iIuUfF](8|16|32|64))?/ }
  177. ]
  178. },
  179. hljs.HASH_COMMENT_MODE
  180. ]
  181. };
  182. }
  183. export { nim as default };