de03b970a689d024ab3383991180d48d.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. ace.define("ace/mode/logiql_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){/* THIS FILE WAS AUTOGENERATED FROM tool\LogicBlox.tmbundle\Syntaxes\LogicBlox.tmLanguage (UUID: 59bf5022-e261-453f-b1cb-9f9fa0712413) */
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  5. var LogiQLHighlightRules = function () {
  6. this.$rules = { start: [{ token: 'comment.block',
  7. regex: '/\\*',
  8. push: [{ token: 'comment.block', regex: '\\*/', next: 'pop' },
  9. { defaultToken: 'comment.block' }]
  10. },
  11. { token: 'comment.single',
  12. regex: '//.*'
  13. },
  14. { token: 'constant.numeric',
  15. regex: '\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?[fd]?'
  16. },
  17. { token: 'string',
  18. regex: '"',
  19. push: [{ token: 'string', regex: '"', next: 'pop' },
  20. { defaultToken: 'string' }]
  21. },
  22. { token: 'constant.language',
  23. regex: '\\b(true|false)\\b'
  24. },
  25. { token: 'entity.name.type.logicblox',
  26. regex: '`[a-zA-Z_:]+(\\d|\\a)*\\b'
  27. },
  28. { token: 'keyword.start', regex: '->', comment: 'Constraint' },
  29. { token: 'keyword.start', regex: '-->', comment: 'Level 1 Constraint' },
  30. { token: 'keyword.start', regex: '<-', comment: 'Rule' },
  31. { token: 'keyword.start', regex: '<--', comment: 'Level 1 Rule' },
  32. { token: 'keyword.end', regex: '\\.', comment: 'Terminator' },
  33. { token: 'keyword.other', regex: '!', comment: 'Negation' },
  34. { token: 'keyword.other', regex: ',', comment: 'Conjunction' },
  35. { token: 'keyword.other', regex: ';', comment: 'Disjunction' },
  36. { token: 'keyword.operator', regex: '<=|>=|!=|<|>', comment: 'Equality' },
  37. { token: 'keyword.other', regex: '@', comment: 'Equality' },
  38. { token: 'keyword.operator', regex: '\\+|-|\\*|/', comment: 'Arithmetic operations' },
  39. { token: 'keyword', regex: '::', comment: 'Colon colon' },
  40. { token: 'support.function',
  41. regex: '\\b(agg\\s*<<)',
  42. push: [{ include: '$self' },
  43. { token: 'support.function',
  44. regex: '>>',
  45. next: 'pop' }]
  46. },
  47. { token: 'storage.modifier',
  48. regex: '\\b(lang:[\\w:]*)'
  49. },
  50. { token: ['storage.type', 'text'],
  51. regex: '(export|sealed|clauses|block|alias|alias_all)(\\s*\\()(?=`)'
  52. },
  53. { token: 'entity.name',
  54. regex: '[a-zA-Z_][a-zA-Z_0-9:]*(@prev|@init|@final)?(?=(\\(|\\[))'
  55. },
  56. { token: 'variable.parameter',
  57. regex: '([a-zA-Z][a-zA-Z_0-9]*|_)\\s*(?=(,|\\.|<-|->|\\)|\\]|=))'
  58. }] };
  59. this.normalizeRules();
  60. };
  61. oop.inherits(LogiQLHighlightRules, TextHighlightRules);
  62. exports.LogiQLHighlightRules = LogiQLHighlightRules;
  63. });
  64. ace.define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module){"use strict";
  65. var oop = require("../../lib/oop");
  66. var BaseFoldMode = require("./fold_mode").FoldMode;
  67. var Range = require("../../range").Range;
  68. var FoldMode = exports.FoldMode = function () { };
  69. oop.inherits(FoldMode, BaseFoldMode);
  70. (function () {
  71. this.getFoldWidgetRange = function (session, foldStyle, row) {
  72. var range = this.indentationBlock(session, row);
  73. if (range)
  74. return range;
  75. var re = /\S/;
  76. var line = session.getLine(row);
  77. var startLevel = line.search(re);
  78. if (startLevel == -1 || line[startLevel] != "#")
  79. return;
  80. var startColumn = line.length;
  81. var maxRow = session.getLength();
  82. var startRow = row;
  83. var endRow = row;
  84. while (++row < maxRow) {
  85. line = session.getLine(row);
  86. var level = line.search(re);
  87. if (level == -1)
  88. continue;
  89. if (line[level] != "#")
  90. break;
  91. endRow = row;
  92. }
  93. if (endRow > startRow) {
  94. var endColumn = session.getLine(endRow).length;
  95. return new Range(startRow, startColumn, endRow, endColumn);
  96. }
  97. };
  98. this.getFoldWidget = function (session, foldStyle, row) {
  99. var line = session.getLine(row);
  100. var indent = line.search(/\S/);
  101. var next = session.getLine(row + 1);
  102. var prev = session.getLine(row - 1);
  103. var prevIndent = prev.search(/\S/);
  104. var nextIndent = next.search(/\S/);
  105. if (indent == -1) {
  106. session.foldWidgets[row - 1] = prevIndent != -1 && prevIndent < nextIndent ? "start" : "";
  107. return "";
  108. }
  109. if (prevIndent == -1) {
  110. if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
  111. session.foldWidgets[row - 1] = "";
  112. session.foldWidgets[row + 1] = "";
  113. return "start";
  114. }
  115. }
  116. else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
  117. if (session.getLine(row - 2).search(/\S/) == -1) {
  118. session.foldWidgets[row - 1] = "start";
  119. session.foldWidgets[row + 1] = "";
  120. return "";
  121. }
  122. }
  123. if (prevIndent != -1 && prevIndent < indent)
  124. session.foldWidgets[row - 1] = "start";
  125. else
  126. session.foldWidgets[row - 1] = "";
  127. if (indent < nextIndent)
  128. return "start";
  129. else
  130. return "";
  131. };
  132. }).call(FoldMode.prototype);
  133. });
  134. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
  135. var Range = require("../range").Range;
  136. var MatchingBraceOutdent = function () { };
  137. (function () {
  138. this.checkOutdent = function (line, input) {
  139. if (!/^\s+$/.test(line))
  140. return false;
  141. return /^\s*\}/.test(input);
  142. };
  143. this.autoOutdent = function (doc, row) {
  144. var line = doc.getLine(row);
  145. var match = line.match(/^(\s*\})/);
  146. if (!match)
  147. return 0;
  148. var column = match[1].length;
  149. var openBracePos = doc.findMatchingBracket({ row: row, column: column });
  150. if (!openBracePos || openBracePos.row == row)
  151. return 0;
  152. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  153. doc.replace(new Range(row, 0, row, column - 1), indent);
  154. };
  155. this.$getIndent = function (line) {
  156. return line.match(/^\s*/)[0];
  157. };
  158. }).call(MatchingBraceOutdent.prototype);
  159. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  160. });
  161. ace.define("ace/mode/logiql",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/logiql_highlight_rules","ace/mode/folding/coffee","ace/token_iterator","ace/range","ace/mode/behaviour/cstyle","ace/mode/matching_brace_outdent"], function(require, exports, module){"use strict";
  162. var oop = require("../lib/oop");
  163. var TextMode = require("./text").Mode;
  164. var LogiQLHighlightRules = require("./logiql_highlight_rules").LogiQLHighlightRules;
  165. var FoldMode = require("./folding/coffee").FoldMode;
  166. var TokenIterator = require("../token_iterator").TokenIterator;
  167. var Range = require("../range").Range;
  168. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  169. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  170. var Mode = function () {
  171. this.HighlightRules = LogiQLHighlightRules;
  172. this.foldingRules = new FoldMode();
  173. this.$outdent = new MatchingBraceOutdent();
  174. this.$behaviour = new CstyleBehaviour();
  175. };
  176. oop.inherits(Mode, TextMode);
  177. (function () {
  178. this.lineCommentStart = "//";
  179. this.blockComment = { start: "/*", end: "*/" };
  180. this.getNextLineIndent = function (state, line, tab) {
  181. var indent = this.$getIndent(line);
  182. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  183. var tokens = tokenizedLine.tokens;
  184. var endState = tokenizedLine.state;
  185. if (/comment|string/.test(endState))
  186. return indent;
  187. if (tokens.length && tokens[tokens.length - 1].type == "comment.single")
  188. return indent;
  189. var match = line.match();
  190. if (/(-->|<--|<-|->|{)\s*$/.test(line))
  191. indent += tab;
  192. return indent;
  193. };
  194. this.checkOutdent = function (state, line, input) {
  195. if (this.$outdent.checkOutdent(line, input))
  196. return true;
  197. if (input !== "\n" && input !== "\r\n")
  198. return false;
  199. if (!/^\s+/.test(line))
  200. return false;
  201. return true;
  202. };
  203. this.autoOutdent = function (state, doc, row) {
  204. if (this.$outdent.autoOutdent(doc, row))
  205. return;
  206. var prevLine = doc.getLine(row);
  207. var match = prevLine.match(/^\s+/);
  208. var column = prevLine.lastIndexOf(".") + 1;
  209. if (!match || !row || !column)
  210. return 0;
  211. var line = doc.getLine(row + 1);
  212. var startRange = this.getMatching(doc, { row: row, column: column });
  213. if (!startRange || startRange.start.row == row)
  214. return 0;
  215. column = match[0].length;
  216. var indent = this.$getIndent(doc.getLine(startRange.start.row));
  217. doc.replace(new Range(row + 1, 0, row + 1, column), indent);
  218. };
  219. this.getMatching = function (session, row, column) {
  220. if (row == undefined)
  221. row = session.selection.lead;
  222. if (typeof row == "object") {
  223. column = row.column;
  224. row = row.row;
  225. }
  226. var startToken = session.getTokenAt(row, column);
  227. var KW_START = "keyword.start", KW_END = "keyword.end";
  228. var tok;
  229. if (!startToken)
  230. return;
  231. if (startToken.type == KW_START) {
  232. var it = new TokenIterator(session, row, column);
  233. it.step = it.stepForward;
  234. }
  235. else if (startToken.type == KW_END) {
  236. var it = new TokenIterator(session, row, column);
  237. it.step = it.stepBackward;
  238. }
  239. else
  240. return;
  241. while (tok = it.step()) {
  242. if (tok.type == KW_START || tok.type == KW_END)
  243. break;
  244. }
  245. if (!tok || tok.type == startToken.type)
  246. return;
  247. var col = it.getCurrentTokenColumn();
  248. var row = it.getCurrentTokenRow();
  249. return new Range(row, col, row, col + tok.value.length);
  250. };
  251. this.$id = "ace/mode/logiql";
  252. }).call(Mode.prototype);
  253. exports.Mode = Mode;
  254. }); (function() {
  255. ace.require(["ace/mode/logiql"], function(m) {
  256. if (typeof module == "object" && typeof exports == "object" && module) {
  257. module.exports = m;
  258. }
  259. });
  260. })();