mode-aql.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. ace.define("ace/mode/aql_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  5. var AqlHighlightRules = function() {
  6. var keywords = (
  7. "for|search|outbound|inbound|any|graph|prune|options|shortest_path|to|in|return|filter|sort|limit|let|collect|remove|update|replace|insers|upsert|with"
  8. );
  9. var builtinConstants = (
  10. "true|false"
  11. );
  12. var builtinFunctions = (
  13. "append|contains_array|count|count_distinct|count_unique|first|flatten|intersection|last|length|minus|nth|outersection|pop|position|push|remove_nth|remove_value|remove_values|reverse|shift|slice|sorted|sorted_unique|union|union_distinct|unique|unshift|" +
  14. "date_now|date_iso8601|date_timestamp|is_datestring|date_dayofweek|date_year|date_month|date_day|date_hour|date_minute|date_second|date_millisecond|date_dayofyear|date_isoweek|date_leapyear|date_quarter|date_days_in_month|date_trunc|date_format|date_add|date_subtract|date_diff|date_compare|" +
  15. "attributes|count|has|is_same_collection|keep|length|matches|merge|merge_recursive|parse_identifier|translate|unset|unset_recursive|values|zip|" +
  16. "fulltext|" +
  17. "distance|geo_contains|geo_distance|geo_equals|geo_intersects|is_in_polygon|" +
  18. "not_null|first_list|first_document|check_document|collection_count|collections|count|current_user|document|length|hash|apply|assert|/ warn|call|fail|noopt|passthru|sleep|v8|version|" +
  19. "abs|acos|asin|atan|atan2|average|avg|ceil|cos|degrees|exp|exp2|floor|log|log2|log10|max|median|min|percentile|pi|pow|radians|rand|range|round|sin|sqrt|stddev_population|stddev_sample|stddev|sum|tan|variance_population|variance_sample|variance|" +
  20. "char_length|concat|concat_separator|contains|count|encode_uri_component|find_first|find_last|json_parse|json_stringify|left|length|levenshtein_distance|like|lower|ltrim|md5|random_token|regex_matches|regex_split|regex_test|regex_replace|reverse|right|rtrim|sha1|sha512|split|soundex|substitute|substring|tokens|to_base64|to_hex|trim|upper|uuid|" +
  21. "to_bool|to_number|to_string|to_array|to_list|is_null|is_bool|is_number|is_string|is_array|is_list|is_object|is_document|is_datestring|is_key|typename|"
  22. );
  23. var keywordMapper = this.createKeywordMapper({
  24. "support.function": builtinFunctions,
  25. "keyword": keywords,
  26. "constant.language": builtinConstants
  27. }, "identifier", true);
  28. this.$rules = {
  29. "start" : [ {
  30. token : "comment",
  31. regex : "//.*$"
  32. }, {
  33. token : "string", // " string
  34. regex : '".*?"'
  35. }, {
  36. token : "string", // ' string
  37. regex : "'.*?'"
  38. }, {
  39. token : "constant.numeric", // float
  40. regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  41. }, {
  42. token : keywordMapper,
  43. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  44. }, {
  45. token : "keyword.operator",
  46. regex : "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="
  47. }, {
  48. token : "paren.lparen",
  49. regex : "[\\(]"
  50. }, {
  51. token : "paren.rparen",
  52. regex : "[\\)]"
  53. }, {
  54. token : "text",
  55. regex : "\\s+"
  56. } ]
  57. };
  58. this.normalizeRules();
  59. };
  60. oop.inherits(AqlHighlightRules, TextHighlightRules);
  61. exports.AqlHighlightRules = AqlHighlightRules;
  62. });
  63. ace.define("ace/mode/aql",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/aql_highlight_rules"], function(require, exports, module) {
  64. "use strict";
  65. var oop = require("../lib/oop");
  66. var TextMode = require("./text").Mode;
  67. var AqlHighlightRules = require("./aql_highlight_rules").AqlHighlightRules;
  68. var Mode = function() {
  69. this.HighlightRules = AqlHighlightRules;
  70. this.$behaviour = this.$defaultBehaviour;
  71. };
  72. oop.inherits(Mode, TextMode);
  73. (function() {
  74. this.lineCommentStart = "//";
  75. this.$id = "ace/mode/aql";
  76. }).call(Mode.prototype);
  77. exports.Mode = Mode;
  78. }); (function() {
  79. ace.require(["ace/mode/aql"], function(m) {
  80. if (typeof module == "object" && typeof exports == "object" && module) {
  81. module.exports = m;
  82. }
  83. });
  84. })();