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