nim.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. return {
  9. name: 'Nim',
  10. aliases: ['nim'],
  11. keywords: {
  12. keyword:
  13. 'addr and as asm bind block break case cast const continue converter ' +
  14. 'discard distinct div do elif else end enum except export finally ' +
  15. 'for from func generic if import in include interface is isnot iterator ' +
  16. 'let macro method mixin mod nil not notin object of or out proc ptr ' +
  17. 'raise ref return shl shr static template try tuple type using var ' +
  18. 'when while with without xor yield',
  19. literal:
  20. 'shared guarded stdin stdout stderr result true false',
  21. built_in:
  22. 'int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 float ' +
  23. 'float32 float64 bool char string cstring pointer expr stmt void ' +
  24. 'auto any range array openarray varargs seq set clong culong cchar ' +
  25. 'cschar cshort cint csize clonglong cfloat cdouble clongdouble ' +
  26. 'cuchar cushort cuint culonglong cstringarray semistatic'
  27. },
  28. contains: [ {
  29. className: 'meta', // Actually pragma
  30. begin: /{\./,
  31. end: /\.}/,
  32. relevance: 10
  33. }, {
  34. className: 'string',
  35. begin: /[a-zA-Z]\w*"/,
  36. end: /"/,
  37. contains: [{begin: /""/}]
  38. }, {
  39. className: 'string',
  40. begin: /([a-zA-Z]\w*)?"""/,
  41. end: /"""/
  42. },
  43. hljs.QUOTE_STRING_MODE,
  44. {
  45. className: 'type',
  46. begin: /\b[A-Z]\w+\b/,
  47. relevance: 0
  48. }, {
  49. className: 'number',
  50. relevance: 0,
  51. variants: [
  52. {begin: /\b(0[xX][0-9a-fA-F][_0-9a-fA-F]*)('?[iIuU](8|16|32|64))?/},
  53. {begin: /\b(0o[0-7][_0-7]*)('?[iIuUfF](8|16|32|64))?/},
  54. {begin: /\b(0(b|B)[01][_01]*)('?[iIuUfF](8|16|32|64))?/},
  55. {begin: /\b(\d[_\d]*)('?[iIuUfF](8|16|32|64))?/}
  56. ]
  57. },
  58. hljs.HASH_COMMENT_MODE
  59. ]
  60. }
  61. }
  62. module.exports = nim;