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