nim.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. {
  30. className: 'meta', // Actually pragma
  31. begin: /\{\./,
  32. end: /\.\}/,
  33. relevance: 10
  34. },
  35. {
  36. className: 'string',
  37. begin: /[a-zA-Z]\w*"/,
  38. end: /"/,
  39. contains: [
  40. {
  41. begin: /""/
  42. }
  43. ]
  44. },
  45. {
  46. className: 'string',
  47. begin: /([a-zA-Z]\w*)?"""/,
  48. end: /"""/
  49. },
  50. hljs.QUOTE_STRING_MODE,
  51. {
  52. className: 'type',
  53. begin: /\b[A-Z]\w+\b/,
  54. relevance: 0
  55. },
  56. {
  57. className: 'number',
  58. relevance: 0,
  59. variants: [
  60. {
  61. begin: /\b(0[xX][0-9a-fA-F][_0-9a-fA-F]*)('?[iIuU](8|16|32|64))?/
  62. },
  63. {
  64. begin: /\b(0o[0-7][_0-7]*)('?[iIuUfF](8|16|32|64))?/
  65. },
  66. {
  67. begin: /\b(0(b|B)[01][_01]*)('?[iIuUfF](8|16|32|64))?/
  68. },
  69. {
  70. begin: /\b(\d[_\d]*)('?[iIuUfF](8|16|32|64))?/
  71. }
  72. ]
  73. },
  74. hljs.HASH_COMMENT_MODE
  75. ]
  76. };
  77. }
  78. module.exports = nim;