UNPKG

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