]> luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/n1ql.js
Initial commit.
[flow-web.git] / static / highlight / languages / n1ql.js
1 /*! `n1ql` grammar compiled for Highlight.js 11.11.1 */
2 (function(){
3 var hljsGrammar = (function () {
4 'use strict';
5
6 /*
7 Language: N1QL
8 Author: Andres Täht <andres.taht@gmail.com>
9 Contributors: Rene Saarsoo <nene@triin.net>
10 Description: Couchbase query language
11 Website: https://www.couchbase.com/products/n1ql
12 Category: database
13 */
14
15 function n1ql(hljs) {
16 // Taken from http://developer.couchbase.com/documentation/server/current/n1ql/n1ql-language-reference/reservedwords.html
17 const KEYWORDS = [
18 "all",
19 "alter",
20 "analyze",
21 "and",
22 "any",
23 "array",
24 "as",
25 "asc",
26 "begin",
27 "between",
28 "binary",
29 "boolean",
30 "break",
31 "bucket",
32 "build",
33 "by",
34 "call",
35 "case",
36 "cast",
37 "cluster",
38 "collate",
39 "collection",
40 "commit",
41 "connect",
42 "continue",
43 "correlate",
44 "cover",
45 "create",
46 "database",
47 "dataset",
48 "datastore",
49 "declare",
50 "decrement",
51 "delete",
52 "derived",
53 "desc",
54 "describe",
55 "distinct",
56 "do",
57 "drop",
58 "each",
59 "element",
60 "else",
61 "end",
62 "every",
63 "except",
64 "exclude",
65 "execute",
66 "exists",
67 "explain",
68 "fetch",
69 "first",
70 "flatten",
71 "for",
72 "force",
73 "from",
74 "function",
75 "grant",
76 "group",
77 "gsi",
78 "having",
79 "if",
80 "ignore",
81 "ilike",
82 "in",
83 "include",
84 "increment",
85 "index",
86 "infer",
87 "inline",
88 "inner",
89 "insert",
90 "intersect",
91 "into",
92 "is",
93 "join",
94 "key",
95 "keys",
96 "keyspace",
97 "known",
98 "last",
99 "left",
100 "let",
101 "letting",
102 "like",
103 "limit",
104 "lsm",
105 "map",
106 "mapping",
107 "matched",
108 "materialized",
109 "merge",
110 "minus",
111 "namespace",
112 "nest",
113 "not",
114 "number",
115 "object",
116 "offset",
117 "on",
118 "option",
119 "or",
120 "order",
121 "outer",
122 "over",
123 "parse",
124 "partition",
125 "password",
126 "path",
127 "pool",
128 "prepare",
129 "primary",
130 "private",
131 "privilege",
132 "procedure",
133 "public",
134 "raw",
135 "realm",
136 "reduce",
137 "rename",
138 "return",
139 "returning",
140 "revoke",
141 "right",
142 "role",
143 "rollback",
144 "satisfies",
145 "schema",
146 "select",
147 "self",
148 "semi",
149 "set",
150 "show",
151 "some",
152 "start",
153 "statistics",
154 "string",
155 "system",
156 "then",
157 "to",
158 "transaction",
159 "trigger",
160 "truncate",
161 "under",
162 "union",
163 "unique",
164 "unknown",
165 "unnest",
166 "unset",
167 "update",
168 "upsert",
169 "use",
170 "user",
171 "using",
172 "validate",
173 "value",
174 "valued",
175 "values",
176 "via",
177 "view",
178 "when",
179 "where",
180 "while",
181 "with",
182 "within",
183 "work",
184 "xor"
185 ];
186 // Taken from http://developer.couchbase.com/documentation/server/4.5/n1ql/n1ql-language-reference/literals.html
187 const LITERALS = [
188 "true",
189 "false",
190 "null",
191 "missing|5"
192 ];
193 // Taken from http://developer.couchbase.com/documentation/server/4.5/n1ql/n1ql-language-reference/functions.html
194 const BUILT_INS = [
195 "array_agg",
196 "array_append",
197 "array_concat",
198 "array_contains",
199 "array_count",
200 "array_distinct",
201 "array_ifnull",
202 "array_length",
203 "array_max",
204 "array_min",
205 "array_position",
206 "array_prepend",
207 "array_put",
208 "array_range",
209 "array_remove",
210 "array_repeat",
211 "array_replace",
212 "array_reverse",
213 "array_sort",
214 "array_sum",
215 "avg",
216 "count",
217 "max",
218 "min",
219 "sum",
220 "greatest",
221 "least",
222 "ifmissing",
223 "ifmissingornull",
224 "ifnull",
225 "missingif",
226 "nullif",
227 "ifinf",
228 "ifnan",
229 "ifnanorinf",
230 "naninf",
231 "neginfif",
232 "posinfif",
233 "clock_millis",
234 "clock_str",
235 "date_add_millis",
236 "date_add_str",
237 "date_diff_millis",
238 "date_diff_str",
239 "date_part_millis",
240 "date_part_str",
241 "date_trunc_millis",
242 "date_trunc_str",
243 "duration_to_str",
244 "millis",
245 "str_to_millis",
246 "millis_to_str",
247 "millis_to_utc",
248 "millis_to_zone_name",
249 "now_millis",
250 "now_str",
251 "str_to_duration",
252 "str_to_utc",
253 "str_to_zone_name",
254 "decode_json",
255 "encode_json",
256 "encoded_size",
257 "poly_length",
258 "base64",
259 "base64_encode",
260 "base64_decode",
261 "meta",
262 "uuid",
263 "abs",
264 "acos",
265 "asin",
266 "atan",
267 "atan2",
268 "ceil",
269 "cos",
270 "degrees",
271 "e",
272 "exp",
273 "ln",
274 "log",
275 "floor",
276 "pi",
277 "power",
278 "radians",
279 "random",
280 "round",
281 "sign",
282 "sin",
283 "sqrt",
284 "tan",
285 "trunc",
286 "object_length",
287 "object_names",
288 "object_pairs",
289 "object_inner_pairs",
290 "object_values",
291 "object_inner_values",
292 "object_add",
293 "object_put",
294 "object_remove",
295 "object_unwrap",
296 "regexp_contains",
297 "regexp_like",
298 "regexp_position",
299 "regexp_replace",
300 "contains",
301 "initcap",
302 "length",
303 "lower",
304 "ltrim",
305 "position",
306 "repeat",
307 "replace",
308 "rtrim",
309 "split",
310 "substr",
311 "title",
312 "trim",
313 "upper",
314 "isarray",
315 "isatom",
316 "isboolean",
317 "isnumber",
318 "isobject",
319 "isstring",
320 "type",
321 "toarray",
322 "toatom",
323 "toboolean",
324 "tonumber",
325 "toobject",
326 "tostring"
327 ];
328
329 return {
330 name: 'N1QL',
331 case_insensitive: true,
332 contains: [
333 {
334 beginKeywords:
335 'build create index delete drop explain infer|10 insert merge prepare select update upsert|10',
336 end: /;/,
337 keywords: {
338 keyword: KEYWORDS,
339 literal: LITERALS,
340 built_in: BUILT_INS
341 },
342 contains: [
343 {
344 className: 'string',
345 begin: '\'',
346 end: '\'',
347 contains: [ hljs.BACKSLASH_ESCAPE ]
348 },
349 {
350 className: 'string',
351 begin: '"',
352 end: '"',
353 contains: [ hljs.BACKSLASH_ESCAPE ]
354 },
355 {
356 className: 'symbol',
357 begin: '`',
358 end: '`',
359 contains: [ hljs.BACKSLASH_ESCAPE ]
360 },
361 hljs.C_NUMBER_MODE,
362 hljs.C_BLOCK_COMMENT_MODE
363 ]
364 },
365 hljs.C_BLOCK_COMMENT_MODE
366 ]
367 };
368 }
369
370 return n1ql;
371
372 })();
373
374 hljs.registerLanguage('n1ql', hljsGrammar);
375 })();