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