mode-lucene.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. ace.define("ace/mode/lucene_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 LuceneHighlightRules = function() {
  6. this.$rules = {
  7. "start" : [
  8. {
  9. token: "constant.language.escape",
  10. regex: /\\[\-+&|!(){}\[\]^"~*?:\\]/
  11. }, {
  12. token: "constant.character.negation",
  13. regex: "\\-"
  14. }, {
  15. token: "constant.character.interro",
  16. regex: "\\?"
  17. }, {
  18. token: "constant.character.required",
  19. regex: "\\+"
  20. }, {
  21. token: "constant.character.asterisk",
  22. regex: "\\*"
  23. }, {
  24. token: 'constant.character.proximity',
  25. regex: '~(?:0\\.[0-9]+|[0-9]+)?'
  26. }, {
  27. token: 'keyword.operator',
  28. regex: '(AND|OR|NOT|TO)\\b'
  29. }, {
  30. token: "paren.lparen",
  31. regex: "[\\(\\{\\[]"
  32. }, {
  33. token: "paren.rparen",
  34. regex: "[\\)\\}\\]]"
  35. }, {
  36. token: "keyword.operator",
  37. regex: /[><=^]/
  38. }, {
  39. token: "constant.numeric",
  40. regex: /\d[\d.-]*/
  41. }, {
  42. token: "string",
  43. regex: /"(?:\\"|[^"])*"/
  44. }, {
  45. token: "keyword",
  46. regex: /(?:\\.|[^\s\-+&|!(){}\[\]^"~*?:\\])+:/,
  47. next: "maybeRegex"
  48. }, {
  49. token: "term",
  50. regex: /\w+/
  51. }, {
  52. token: "text",
  53. regex: /\s+/
  54. }
  55. ],
  56. "maybeRegex": [{
  57. token: "text",
  58. regex: /\s+/
  59. }, {
  60. token: "string.regexp.start",
  61. regex: "/",
  62. next: "regex"
  63. }, {
  64. regex: "",
  65. next: "start"
  66. }],
  67. "regex": [
  68. {
  69. token: "regexp.keyword.operator",
  70. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  71. }, {
  72. token: "string.regexp.end",
  73. regex: "/[sxngimy]*",
  74. next: "no_regex"
  75. }, {
  76. token : "invalid",
  77. regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
  78. }, {
  79. token : "constant.language.escape",
  80. regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
  81. }, {
  82. token: "constant.language.escape",
  83. regex: "<\d+-\d+>|[~&@]"
  84. }, {
  85. token : "constant.language.delimiter",
  86. regex: /\|/
  87. }, {
  88. token: "constant.language.escape",
  89. regex: /\[\^?/,
  90. next: "regex_character_class"
  91. }, {
  92. token: "empty",
  93. regex: "$",
  94. next: "no_regex"
  95. }, {
  96. defaultToken: "string.regexp"
  97. }
  98. ],
  99. "regex_character_class": [
  100. {
  101. token: "regexp.charclass.keyword.operator",
  102. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  103. }, {
  104. token: "constant.language.escape",
  105. regex: "]",
  106. next: "regex"
  107. }, {
  108. token: "constant.language.escape",
  109. regex: "-"
  110. }, {
  111. token: "empty",
  112. regex: "$",
  113. next: "no_regex"
  114. }, {
  115. defaultToken: "string.regexp.charachterclass"
  116. }
  117. ]
  118. };
  119. };
  120. oop.inherits(LuceneHighlightRules, TextHighlightRules);
  121. exports.LuceneHighlightRules = LuceneHighlightRules;
  122. });
  123. ace.define("ace/mode/lucene",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/lucene_highlight_rules"], function(require, exports, module) {
  124. 'use strict';
  125. var oop = require("../lib/oop");
  126. var TextMode = require("./text").Mode;
  127. var LuceneHighlightRules = require("./lucene_highlight_rules").LuceneHighlightRules;
  128. var Mode = function() {
  129. this.HighlightRules = LuceneHighlightRules;
  130. this.$behaviour = this.$defaultBehaviour;
  131. };
  132. oop.inherits(Mode, TextMode);
  133. (function() {
  134. this.$id = "ace/mode/lucene";
  135. }).call(Mode.prototype);
  136. exports.Mode = Mode;
  137. }); (function() {
  138. ace.require(["ace/mode/lucene"], function(m) {
  139. if (typeof module == "object" && typeof exports == "object" && module) {
  140. module.exports = m;
  141. }
  142. });
  143. })();