mode-mysql.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. define("ace/mode/doc_comment_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 DocCommentHighlightRules = function() {
  6. this.$rules = {
  7. "start" : [ {
  8. token : "comment.doc.tag",
  9. regex : "@[\\w\\d_]+" // TODO: fix email addresses
  10. },
  11. DocCommentHighlightRules.getTagRule(),
  12. {
  13. defaultToken : "comment.doc",
  14. caseInsensitive: true
  15. }]
  16. };
  17. };
  18. oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  19. DocCommentHighlightRules.getTagRule = function(start) {
  20. return {
  21. token : "comment.doc.tag.storage.type",
  22. regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
  23. };
  24. };
  25. DocCommentHighlightRules.getStartRule = function(start) {
  26. return {
  27. token : "comment.doc", // doc comment
  28. regex : "\\/\\*(?=\\*)",
  29. next : start
  30. };
  31. };
  32. DocCommentHighlightRules.getEndRule = function (start) {
  33. return {
  34. token : "comment.doc", // closing comment
  35. regex : "\\*\\/",
  36. next : start
  37. };
  38. };
  39. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  40. });
  41. define("ace/mode/mysql_highlight_rules",["ace_require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(ace_require, exports, module) {
  42. var oop = ace_require("../lib/oop");
  43. var lang = ace_require("../lib/lang");
  44. var DocCommentHighlightRules = ace_require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  45. var TextHighlightRules = ace_require("./text_highlight_rules").TextHighlightRules;
  46. var MysqlHighlightRules = function() {
  47. var mySqlKeywords = /*sql*/ "alter|and|as|asc|between|count|create|delete|desc|distinct|drop|from|having|in|insert|into|is|join|like|not|on|or|order|select|set|table|union|update|values|where" + "|accessible|action|add|after|algorithm|all|analyze|asensitive|at|authors|auto_increment|autocommit|avg|avg_row_length|before|binary|binlog|both|btree|cache|call|cascade|cascaded|case|catalog_name|chain|change|changed|character|check|checkpoint|checksum|class_origin|client_statistics|close|coalesce|code|collate|collation|collations|column|columns|comment|commit|committed|completion|concurrent|condition|connection|consistent|constraint|contains|continue|contributors|convert|cross|current_date|current_time|current_timestamp|current_user|cursor|data|database|databases|day_hour|day_microsecond|day_minute|day_second|deallocate|dec|declare|default|delay_key_write|delayed|delimiter|des_key_file|describe|deterministic|dev_pop|dev_samp|deviance|directory|disable|discard|distinctrow|div|dual|dumpfile|each|elseif|enable|enclosed|end|ends|engine|engines|enum|errors|escape|escaped|even|event|events|every|execute|exists|exit|explain|extended|fast|fetch|field|fields|first|flush|for|force|foreign|found_rows|full|fulltext|function|general|global|grant|grants|group|groupby_concat|handler|hash|help|high_priority|hosts|hour_microsecond|hour_minute|hour_second|if|ignore|ignore_server_ids|import|index|index_statistics|infile|inner|innodb|inout|insensitive|insert_method|install|interval|invoker|isolation|iterate|key|keys|kill|language|last|leading|leave|left|level|limit|linear|lines|list|load|local|localtime|localtimestamp|lock|logs|low_priority|master|master_heartbeat_period|master_ssl_verify_server_cert|masters|match|max|max_rows|maxvalue|message_text|middleint|migrate|min|min_rows|minute_microsecond|minute_second|mod|mode|modifies|modify|mutex|mysql_errno|natural|next|no|no_write_to_binlog|offline|offset|one|online|open|optimize|option|optionally|out|outer|outfile|pack_keys|parser|partition|partitions|password|phase|plugin|plugins|prepare|preserve|prev|primary|privileges|procedure|processlist|profile|profiles|purge|query|quick|range|read|read_write|reads|real|rebuild|recover|references|regexp|relaylog|release|remove|rename|reorganize|repair|repeatable|replace|ace_require|resignal|restrict|resume|return|returns|revoke|right|rlike|rollback|rollup|row|row_format|rtree|savepoint|schedule|schema|schema_name|schemas|second_microsecond|security|sensitive|separator|serializable|server|session|share|show|signal|slave|slow|smallint|snapshot|soname|spatial|specific|sql|sql_big_result|sql_buffer_result|sql_cache|sql_calc_found_rows|sql_no_cache|sql_small_result|sqlexception|sqlstate|sqlwarning|ssl|start|starting|starts|status|std|stddev|stddev_pop|stddev_samp|storage|straight_join|subclass_origin|sum|suspend|table_name|table_statistics|tables|tablespace|temporary|terminated|to|trailing|transaction|trigger|triggers|truncate|uncommitted|undo|uninstall|unique|unlock|upgrade|usage|use|use_frm|user|user_resources|user_statistics|using|utc_date|utc_time|utc_timestamp|value|variables|varying|view|views|warnings|when|while|with|work|write|xa|xor|year_month|zerofill|begin|do|then|else|loop|repeat";
  48. var builtins = "by|bool|boolean|bit|blob|decimal|double|enum|float|long|longblob|longtext|medium|mediumblob|mediumint|mediumtext|time|timestamp|tinyblob|tinyint|tinytext|text|bigint|int|int1|int2|int3|int4|int8|integer|float|float4|float8|double|char|varbinary|varchar|varcharacter|precision|date|datetime|year|unsigned|signed|numeric|ucase|lcase|mid|len|round|rank|now|format|coalesce|ifnull|isnull|nvl";
  49. var variable = "charset|clear|connect|edit|ego|exit|go|help|nopager|notee|nowarning|pager|print|prompt|quit|rehash|source|status|system|tee";
  50. var keywordMapper = this.createKeywordMapper({
  51. "support.function": builtins,
  52. "keyword": mySqlKeywords,
  53. "constant": "false|true|null|unknown|date|time|timestamp|ODBCdotTable|zerolessFloat",
  54. "variable.language": variable
  55. }, "identifier", true);
  56. function string(rule) {
  57. var start = rule.start;
  58. var escapeSeq = rule.escape;
  59. return {
  60. token: "string.start",
  61. regex: start,
  62. next: [
  63. {token: "constant.language.escape", regex: escapeSeq},
  64. {token: "string.end", next: "start", regex: start},
  65. {defaultToken: "string"}
  66. ]
  67. };
  68. }
  69. this.$rules = {
  70. "start" : [ {
  71. token : "comment", regex : "(?:-- |#).*$"
  72. },
  73. string({start: '"', escape: /\\[0'"bnrtZ\\%_]?/}),
  74. string({start: "'", escape: /\\[0'"bnrtZ\\%_]?/}),
  75. DocCommentHighlightRules.getStartRule("doc-start"),
  76. {
  77. token : "comment", // multi line comment
  78. regex : /\/\*/,
  79. next : "comment"
  80. }, {
  81. token : "constant.numeric", // hex
  82. regex : /0[xX][0-9a-fA-F]+|[xX]'[0-9a-fA-F]+'|0[bB][01]+|[bB]'[01]+'/
  83. }, {
  84. token : "constant.numeric", // float
  85. regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  86. }, {
  87. token : keywordMapper,
  88. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  89. }, {
  90. token : "constant.class",
  91. regex : "@@?[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  92. }, {
  93. token : "constant.buildin",
  94. regex : "`[^`]*`"
  95. }, {
  96. token : "keyword.operator",
  97. regex : "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="
  98. }, {
  99. token : "paren.lparen",
  100. regex : "[\\(]"
  101. }, {
  102. token : "paren.rparen",
  103. regex : "[\\)]"
  104. }, {
  105. token : "text",
  106. regex : "\\s+"
  107. } ],
  108. "comment" : [
  109. {token : "comment", regex : "\\*\\/", next : "start"},
  110. {defaultToken : "comment"}
  111. ]
  112. };
  113. this.embedRules(DocCommentHighlightRules, "doc-", [ DocCommentHighlightRules.getEndRule("start") ]);
  114. this.normalizeRules();
  115. };
  116. oop.inherits(MysqlHighlightRules, TextHighlightRules);
  117. exports.MysqlHighlightRules = MysqlHighlightRules;
  118. });
  119. define("ace/mode/mysql",["ace_require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/mysql_highlight_rules"], function(ace_require, exports, module) {
  120. var oop = ace_require("../lib/oop");
  121. var TextMode = ace_require("../mode/text").Mode;
  122. var MysqlHighlightRules = ace_require("./mysql_highlight_rules").MysqlHighlightRules;
  123. var Mode = function() {
  124. this.HighlightRules = MysqlHighlightRules;
  125. this.$behaviour = this.$defaultBehaviour;
  126. };
  127. oop.inherits(Mode, TextMode);
  128. (function() {
  129. this.lineCommentStart = ["--", "#"]; // todo space
  130. this.blockComment = {start: "/*", end: "*/"};
  131. this.$id = "ace/mode/mysql";
  132. }).call(Mode.prototype);
  133. exports.Mode = Mode;
  134. }); (function() {
  135. window.ace_require(["ace/mode/mysql"], function(m) {
  136. if (typeof module == "object" && typeof exports == "object" && module) {
  137. module.exports = m;
  138. }
  139. });
  140. })();