mode-sql.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. define("ace/mode/sql_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 SqlHighlightRules = function() {
  6. var keywords = (
  7. "abort|action|all|and|as|asc|ast|attach|auth|avg|begin|between|case|cli|update|clusters|columns|compile|cross|cube|default|define|in|" +
  8. "delete|desc|describe|distinct|discard|do|drop|else|end|exclusion|explain|fields|file|from|full|join|get|if|for|evaluate|" +
  9. "group|by|grouping|having|help|history|inner|insert|into|is|join|left|limitmeta|" +
  10. "not|null|offset|on|only|open|operations|optimize|or|order|by|parallel|parse|pragma|preview|process|" +
  11. "progress|put|queries|query|quickstart|reduce|remove|replace|into|restart|result|results|right|join|rollup|run|running|" +
  12. "schema|scheme|select|semi|set|sets|show|status|stream|subquery|table|tables|then|union|use|using|validate|values|version|when|where|limit|" +
  13. "with|yamr|yt|null|revert|ignore|upsert|erase|presort|assume|any|without|window|partition|rows|range|groups|" +
  14. "unbounded|following|preceding|current|row|sample|tablesample|flatten|view|bernoulli|system|repeatable|over|return"
  15. );
  16. var builtinConstants = (
  17. "true|false"
  18. );
  19. var builtinFunctions = (
  20. "avg|cast|coalesce|likely|random|randomnumber|filecontent|filepath|length|max|median|count|count_if|" +
  21. "grouping|min|percentile|sum|min_by|max_by|min_of|max_of|stddev|variance|" +
  22. "stddev_sample|stddev_population|variance_sample|variance_population|" +
  23. "bool_and|bool_or|bit_and|bit_or|bit_xor|some|list|unique|sakura|betula|banach|smith|hegel|aristotle|plato|quine|marx|freud|hahn|cedar"
  24. );
  25. var dataTypes = (
  26. "string|byte|double|float|int32|uint32|int64|uint64|bool"
  27. );
  28. var keywordMapper = this.createKeywordMapper({
  29. "keyword.operator": builtinFunctions,
  30. "keyword": keywords,
  31. "constant.language": builtinConstants,
  32. "storage.type": dataTypes
  33. }, "identifier", true);
  34. this.$rules = {
  35. "start" : [ {
  36. token : "comment",
  37. regex : "--.*$"
  38. }, {
  39. token : "comment",
  40. start : "/\\*",
  41. end : "\\*/"
  42. }, {
  43. token : "string", // " string
  44. regex : '".*?"'
  45. }, {
  46. token : "string", // ' string
  47. regex : "'.*?'"
  48. }, {
  49. token : "keyword.operator",
  50. start: "\\[",
  51. end: "\\][:a-zA-Z0-9_]*"
  52. }, {
  53. token : "constant.numeric", // float
  54. regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  55. }, {
  56. token : "support.function",
  57. regex : "[a-zA-Z0-9_]+::[a-zA-Z0-9_]+"
  58. }, {
  59. token : keywordMapper,
  60. regex : "[a-zA-Z_][a-zA-Z0-9_$]*\\b"
  61. }, {
  62. token : "keyword.operator",
  63. regex : "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="
  64. }, {
  65. token : "paren.lparen",
  66. regex : "[\\(]"
  67. }, {
  68. token : "paren.rparen",
  69. regex : "[\\)]"
  70. }, {
  71. token : "text",
  72. regex : "\\s+"
  73. }, {
  74. token : "variable",
  75. regex : "[$][a-zA-Z0-9_$]*\\b"
  76. }, {
  77. token : "string", // multiline string
  78. regex : '@@',
  79. next : "multiline"
  80. } ],
  81. "multiline": [ {
  82. token : "string",
  83. regex: "[^@]+"
  84. }, {
  85. token : "string",
  86. regex : "[@]{2}",
  87. next : "start"
  88. } ]
  89. };
  90. this.normalizeRules();
  91. };
  92. oop.inherits(SqlHighlightRules, TextHighlightRules);
  93. exports.SqlHighlightRules = SqlHighlightRules;
  94. });
  95. define("ace/mode/sql",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/sql_highlight_rules","ace/range"], function(require, exports, module) {
  96. "use strict";
  97. var oop = require("../lib/oop");
  98. var TextMode = require("./text").Mode;
  99. var SqlHighlightRules = require("./sql_highlight_rules").SqlHighlightRules;
  100. var Range = require("../range").Range;
  101. var Mode = function() {
  102. this.HighlightRules = SqlHighlightRules;
  103. };
  104. oop.inherits(Mode, TextMode);
  105. (function() {
  106. this.lineCommentStart = "--";
  107. this.$id = "ace/mode/sql";
  108. }).call(Mode.prototype);
  109. exports.Mode = Mode;
  110. });