73869ae87d1a0bf48fdcf5f45e86b070.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. ace.define("ace/mode/jack_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
  2. var oop = require("../lib/oop");
  3. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  4. var JackHighlightRules = function () {
  5. this.$rules = {
  6. "start": [
  7. {
  8. token: "string",
  9. regex: '"',
  10. next: "string2"
  11. }, {
  12. token: "string",
  13. regex: "'",
  14. next: "string1"
  15. }, {
  16. token: "constant.numeric",
  17. regex: "-?0[xX][0-9a-fA-F]+\\b"
  18. }, {
  19. token: "constant.numeric",
  20. regex: "(?:0|[-+]?[1-9][0-9]*)\\b"
  21. }, {
  22. token: "constant.binary",
  23. regex: "<[0-9A-Fa-f][0-9A-Fa-f](\\s+[0-9A-Fa-f][0-9A-Fa-f])*>"
  24. }, {
  25. token: "constant.language.boolean",
  26. regex: "(?:true|false)\\b"
  27. }, {
  28. token: "constant.language.null",
  29. regex: "null\\b"
  30. }, {
  31. token: "storage.type",
  32. regex: "(?:Integer|Boolean|Null|String|Buffer|Tuple|List|Object|Function|Coroutine|Form)\\b"
  33. }, {
  34. token: "keyword",
  35. regex: "(?:return|abort|vars|for|delete|in|is|escape|exec|split|and|if|elif|else|while)\\b"
  36. }, {
  37. token: "language.builtin",
  38. regex: "(?:lines|source|parse|read-stream|interval|substr|parseint|write|print|range|rand|inspect|bind|i-values|i-pairs|i-map|i-filter|i-chunk|i-all\\?|i-any\\?|i-collect|i-zip|i-merge|i-each)\\b"
  39. }, {
  40. token: "comment",
  41. regex: "--.*$"
  42. }, {
  43. token: "paren.lparen",
  44. regex: "[[({]"
  45. }, {
  46. token: "paren.rparen",
  47. regex: "[\\])}]"
  48. }, {
  49. token: "storage.form",
  50. regex: "@[a-z]+"
  51. }, {
  52. token: "constant.other.symbol",
  53. regex: ':+[a-zA-Z_]([-]?[a-zA-Z0-9_])*[?!]?'
  54. }, {
  55. token: "variable",
  56. regex: '[a-zA-Z_]([-]?[a-zA-Z0-9_])*[?!]?'
  57. }, {
  58. token: "keyword.operator",
  59. regex: "\\|\\||\\^\\^|&&|!=|==|<=|<|>=|>|\\+|-|\\*|\\/|\\^|\\%|\\#|\\!"
  60. }, {
  61. token: "text",
  62. regex: "\\s+"
  63. }
  64. ],
  65. "string1": [
  66. {
  67. token: "constant.language.escape",
  68. regex: /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|['"\\\/bfnrt])/
  69. }, {
  70. token: "string",
  71. regex: "[^'\\\\]+"
  72. }, {
  73. token: "string",
  74. regex: "'",
  75. next: "start"
  76. }, {
  77. token: "string",
  78. regex: "",
  79. next: "start"
  80. }
  81. ],
  82. "string2": [
  83. {
  84. token: "constant.language.escape",
  85. regex: /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|['"\\\/bfnrt])/
  86. }, {
  87. token: "string",
  88. regex: '[^"\\\\]+'
  89. }, {
  90. token: "string",
  91. regex: '"',
  92. next: "start"
  93. }, {
  94. token: "string",
  95. regex: "",
  96. next: "start"
  97. }
  98. ]
  99. };
  100. };
  101. oop.inherits(JackHighlightRules, TextHighlightRules);
  102. exports.JackHighlightRules = JackHighlightRules;
  103. });
  104. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
  105. var Range = require("../range").Range;
  106. var MatchingBraceOutdent = function () { };
  107. (function () {
  108. this.checkOutdent = function (line, input) {
  109. if (!/^\s+$/.test(line))
  110. return false;
  111. return /^\s*\}/.test(input);
  112. };
  113. this.autoOutdent = function (doc, row) {
  114. var line = doc.getLine(row);
  115. var match = line.match(/^(\s*\})/);
  116. if (!match)
  117. return 0;
  118. var column = match[1].length;
  119. var openBracePos = doc.findMatchingBracket({ row: row, column: column });
  120. if (!openBracePos || openBracePos.row == row)
  121. return 0;
  122. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  123. doc.replace(new Range(row, 0, row, column - 1), indent);
  124. };
  125. this.$getIndent = function (line) {
  126. return line.match(/^\s*/)[0];
  127. };
  128. }).call(MatchingBraceOutdent.prototype);
  129. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  130. });
  131. ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict";
  132. var oop = require("../../lib/oop");
  133. var Range = require("../../range").Range;
  134. var BaseFoldMode = require("./fold_mode").FoldMode;
  135. var FoldMode = exports.FoldMode = function (commentRegex) {
  136. if (commentRegex) {
  137. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  138. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  139. }
  140. };
  141. oop.inherits(FoldMode, BaseFoldMode);
  142. (function () {
  143. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  144. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  145. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  146. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  147. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  148. this._getFoldWidgetBase = this.getFoldWidget;
  149. this.getFoldWidget = function (session, foldStyle, row) {
  150. var line = session.getLine(row);
  151. if (this.singleLineBlockCommentRe.test(line)) {
  152. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  153. return "";
  154. }
  155. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  156. if (!fw && this.startRegionRe.test(line))
  157. return "start"; // lineCommentRegionStart
  158. return fw;
  159. };
  160. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  161. var line = session.getLine(row);
  162. if (this.startRegionRe.test(line))
  163. return this.getCommentRegionBlock(session, line, row);
  164. var match = line.match(this.foldingStartMarker);
  165. if (match) {
  166. var i = match.index;
  167. if (match[1])
  168. return this.openingBracketBlock(session, match[1], row, i);
  169. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  170. if (range && !range.isMultiLine()) {
  171. if (forceMultiline) {
  172. range = this.getSectionRange(session, row);
  173. }
  174. else if (foldStyle != "all")
  175. range = null;
  176. }
  177. return range;
  178. }
  179. if (foldStyle === "markbegin")
  180. return;
  181. var match = line.match(this.foldingStopMarker);
  182. if (match) {
  183. var i = match.index + match[0].length;
  184. if (match[1])
  185. return this.closingBracketBlock(session, match[1], row, i);
  186. return session.getCommentFoldRange(row, i, -1);
  187. }
  188. };
  189. this.getSectionRange = function (session, row) {
  190. var line = session.getLine(row);
  191. var startIndent = line.search(/\S/);
  192. var startRow = row;
  193. var startColumn = line.length;
  194. row = row + 1;
  195. var endRow = row;
  196. var maxRow = session.getLength();
  197. while (++row < maxRow) {
  198. line = session.getLine(row);
  199. var indent = line.search(/\S/);
  200. if (indent === -1)
  201. continue;
  202. if (startIndent > indent)
  203. break;
  204. var subRange = this.getFoldWidgetRange(session, "all", row);
  205. if (subRange) {
  206. if (subRange.start.row <= startRow) {
  207. break;
  208. }
  209. else if (subRange.isMultiLine()) {
  210. row = subRange.end.row;
  211. }
  212. else if (startIndent == indent) {
  213. break;
  214. }
  215. }
  216. endRow = row;
  217. }
  218. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  219. };
  220. this.getCommentRegionBlock = function (session, line, row) {
  221. var startColumn = line.search(/\s*$/);
  222. var maxRow = session.getLength();
  223. var startRow = row;
  224. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  225. var depth = 1;
  226. while (++row < maxRow) {
  227. line = session.getLine(row);
  228. var m = re.exec(line);
  229. if (!m)
  230. continue;
  231. if (m[1])
  232. depth--;
  233. else
  234. depth++;
  235. if (!depth)
  236. break;
  237. }
  238. var endRow = row;
  239. if (endRow > startRow) {
  240. return new Range(startRow, startColumn, endRow, line.length);
  241. }
  242. };
  243. }).call(FoldMode.prototype);
  244. });
  245. ace.define("ace/mode/jack",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/jack_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
  246. var oop = require("../lib/oop");
  247. var TextMode = require("./text").Mode;
  248. var HighlightRules = require("./jack_highlight_rules").JackHighlightRules;
  249. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  250. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  251. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  252. var Mode = function () {
  253. this.HighlightRules = HighlightRules;
  254. this.$outdent = new MatchingBraceOutdent();
  255. this.$behaviour = new CstyleBehaviour();
  256. this.foldingRules = new CStyleFoldMode();
  257. };
  258. oop.inherits(Mode, TextMode);
  259. (function () {
  260. this.lineCommentStart = "--";
  261. this.getNextLineIndent = function (state, line, tab) {
  262. var indent = this.$getIndent(line);
  263. if (state == "start") {
  264. var match = line.match(/^.*[\{\(\[]\s*$/);
  265. if (match) {
  266. indent += tab;
  267. }
  268. }
  269. return indent;
  270. };
  271. this.checkOutdent = function (state, line, input) {
  272. return this.$outdent.checkOutdent(line, input);
  273. };
  274. this.autoOutdent = function (state, doc, row) {
  275. this.$outdent.autoOutdent(doc, row);
  276. };
  277. this.$id = "ace/mode/jack";
  278. }).call(Mode.prototype);
  279. exports.Mode = Mode;
  280. }); (function() {
  281. ace.require(["ace/mode/jack"], function(m) {
  282. if (typeof module == "object" && typeof exports == "object" && module) {
  283. module.exports = m;
  284. }
  285. });
  286. })();