n1ql.js 4.1 KB

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