mode-sql.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. define("ace/mode/sql_highlight_rules",["ace_require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(ace_require, exports, module) {
  2. "use strict";
  3. var oop = ace_require("../lib/oop");
  4. var TextHighlightRules = ace_require("./text_highlight_rules").TextHighlightRules;
  5. var SqlHighlightRules = function() {
  6. var keywords = (
  7. "select|insert|update|delete|from|where|and|or|group|by|order|limit|offset|having|as|case|" +
  8. "when|then|else|end|type|left|right|join|on|outer|desc|asc|union|create|table|primary|key|if|" +
  9. "foreign|not|references|default|null|inner|cross|natural|database|drop|grant"
  10. );
  11. var builtinConstants = (
  12. "true|false"
  13. );
  14. var builtinFunctions = (
  15. "avg|count|first|last|max|min|sum|ucase|lcase|mid|len|round|rank|now|format|" +
  16. "coalesce|ifnull|isnull|nvl"
  17. );
  18. var dataTypes = (
  19. "int|numeric|decimal|date|varchar|char|bigint|float|double|bit|binary|text|set|timestamp|" +
  20. "money|real|number|integer"
  21. );
  22. var keywordMapper = this.createKeywordMapper({
  23. "support.function": builtinFunctions,
  24. "keyword": keywords,
  25. "constant.language": builtinConstants,
  26. "storage.type": dataTypes
  27. }, "identifier", true);
  28. this.$rules = {
  29. "start" : [ {
  30. token : "comment",
  31. regex : "--.*$"
  32. }, {
  33. token : "comment",
  34. start : "/\\*",
  35. end : "\\*/"
  36. }, {
  37. token : "string", // " string
  38. regex : '".*?"'
  39. }, {
  40. token : "string", // ' string
  41. regex : "'.*?'"
  42. }, {
  43. token : "string", // ` string (apache drill)
  44. regex : "`.*?`"
  45. }, {
  46. token : "constant.numeric", // float
  47. regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  48. }, {
  49. token : keywordMapper,
  50. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  51. }, {
  52. token : "keyword.operator",
  53. regex : "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="
  54. }, {
  55. token : "paren.lparen",
  56. regex : "[\\(]"
  57. }, {
  58. token : "paren.rparen",
  59. regex : "[\\)]"
  60. }, {
  61. token : "text",
  62. regex : "\\s+"
  63. } ]
  64. };
  65. this.normalizeRules();
  66. };
  67. oop.inherits(SqlHighlightRules, TextHighlightRules);
  68. exports.SqlHighlightRules = SqlHighlightRules;
  69. });
  70. define("ace/mode/sql",["ace_require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/sql_highlight_rules"], function(ace_require, exports, module) {
  71. "use strict";
  72. var oop = ace_require("../lib/oop");
  73. var TextMode = ace_require("./text").Mode;
  74. var SqlHighlightRules = ace_require("./sql_highlight_rules").SqlHighlightRules;
  75. var Mode = function() {
  76. this.HighlightRules = SqlHighlightRules;
  77. this.$behaviour = this.$defaultBehaviour;
  78. };
  79. oop.inherits(Mode, TextMode);
  80. (function() {
  81. this.lineCommentStart = "--";
  82. this.$id = "ace/mode/sql";
  83. this.snippetFileId = "ace/snippets/sql";
  84. }).call(Mode.prototype);
  85. exports.Mode = Mode;
  86. }); (function() {
  87. window.ace_require(["ace/mode/sql"], function(m) {
  88. if (typeof module == "object" && typeof exports == "object" && module) {
  89. module.exports = m;
  90. }
  91. });
  92. })();