[d24f17c] | 1 | /*
|
---|
| 2 | Language: N1QL
|
---|
| 3 | Author: Andres Täht <andres.taht@gmail.com>
|
---|
| 4 | Contributors: Rene Saarsoo <nene@triin.net>
|
---|
| 5 | Description: Couchbase query language
|
---|
| 6 | Website: https://www.couchbase.com/products/n1ql
|
---|
| 7 | */
|
---|
| 8 |
|
---|
| 9 | function n1ql(hljs) {
|
---|
| 10 | return {
|
---|
| 11 | name: 'N1QL',
|
---|
| 12 | case_insensitive: true,
|
---|
| 13 | contains: [
|
---|
| 14 | {
|
---|
| 15 | beginKeywords:
|
---|
| 16 | 'build create index delete drop explain infer|10 insert merge prepare select update upsert|10',
|
---|
| 17 | end: /;/, endsWithParent: true,
|
---|
| 18 | keywords: {
|
---|
| 19 | // Taken from http://developer.couchbase.com/documentation/server/current/n1ql/n1ql-language-reference/reservedwords.html
|
---|
| 20 | keyword:
|
---|
| 21 | 'all alter analyze and any array as asc begin between binary boolean break bucket build by call ' +
|
---|
| 22 | 'case cast cluster collate collection commit connect continue correlate cover create database ' +
|
---|
| 23 | 'dataset datastore declare decrement delete derived desc describe distinct do drop each element ' +
|
---|
| 24 | 'else end every except exclude execute exists explain fetch first flatten for force from ' +
|
---|
| 25 | 'function grant group gsi having if ignore ilike in include increment index infer inline inner ' +
|
---|
| 26 | 'insert intersect into is join key keys keyspace known last left let letting like limit lsm map ' +
|
---|
| 27 | 'mapping matched materialized merge minus namespace nest not number object offset on ' +
|
---|
| 28 | 'option or order outer over parse partition password path pool prepare primary private privilege ' +
|
---|
| 29 | 'procedure public raw realm reduce rename return returning revoke right role rollback satisfies ' +
|
---|
| 30 | 'schema select self semi set show some start statistics string system then to transaction trigger ' +
|
---|
| 31 | 'truncate under union unique unknown unnest unset update upsert use user using validate value ' +
|
---|
| 32 | 'valued values via view when where while with within work xor',
|
---|
| 33 | // Taken from http://developer.couchbase.com/documentation/server/4.5/n1ql/n1ql-language-reference/literals.html
|
---|
| 34 | literal:
|
---|
| 35 | 'true false null missing|5',
|
---|
| 36 | // Taken from http://developer.couchbase.com/documentation/server/4.5/n1ql/n1ql-language-reference/functions.html
|
---|
| 37 | built_in:
|
---|
| 38 | 'array_agg array_append array_concat array_contains array_count array_distinct array_ifnull array_length ' +
|
---|
| 39 | 'array_max array_min array_position array_prepend array_put array_range array_remove array_repeat array_replace ' +
|
---|
| 40 | 'array_reverse array_sort array_sum avg count max min sum greatest least ifmissing ifmissingornull ifnull ' +
|
---|
| 41 | 'missingif nullif ifinf ifnan ifnanorinf naninf neginfif posinfif clock_millis clock_str date_add_millis ' +
|
---|
| 42 | 'date_add_str date_diff_millis date_diff_str date_part_millis date_part_str date_trunc_millis date_trunc_str ' +
|
---|
| 43 | 'duration_to_str millis str_to_millis millis_to_str millis_to_utc millis_to_zone_name now_millis now_str ' +
|
---|
| 44 | 'str_to_duration str_to_utc str_to_zone_name decode_json encode_json encoded_size poly_length base64 base64_encode ' +
|
---|
| 45 | 'base64_decode meta uuid abs acos asin atan atan2 ceil cos degrees e exp ln log floor pi power radians random ' +
|
---|
| 46 | 'round sign sin sqrt tan trunc object_length object_names object_pairs object_inner_pairs object_values ' +
|
---|
| 47 | 'object_inner_values object_add object_put object_remove object_unwrap regexp_contains regexp_like regexp_position ' +
|
---|
| 48 | 'regexp_replace contains initcap length lower ltrim position repeat replace rtrim split substr title trim upper ' +
|
---|
| 49 | 'isarray isatom isboolean isnumber isobject isstring type toarray toatom toboolean tonumber toobject tostring'
|
---|
| 50 | },
|
---|
| 51 | contains: [
|
---|
| 52 | {
|
---|
| 53 | className: 'string',
|
---|
| 54 | begin: '\'', end: '\'',
|
---|
| 55 | contains: [hljs.BACKSLASH_ESCAPE]
|
---|
| 56 | },
|
---|
| 57 | {
|
---|
| 58 | className: 'string',
|
---|
| 59 | begin: '"', end: '"',
|
---|
| 60 | contains: [hljs.BACKSLASH_ESCAPE]
|
---|
| 61 | },
|
---|
| 62 | {
|
---|
| 63 | className: 'symbol',
|
---|
| 64 | begin: '`', end: '`',
|
---|
| 65 | contains: [hljs.BACKSLASH_ESCAPE],
|
---|
| 66 | relevance: 2
|
---|
| 67 | },
|
---|
| 68 | hljs.C_NUMBER_MODE,
|
---|
| 69 | hljs.C_BLOCK_COMMENT_MODE
|
---|
| 70 | ]
|
---|
| 71 | },
|
---|
| 72 | hljs.C_BLOCK_COMMENT_MODE
|
---|
| 73 | ]
|
---|
| 74 | };
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | module.exports = n1ql;
|
---|