f233af729cc30f9b3af99d3e9a0a2409.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. ace.define("ace/mode/maze_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 MazeHighlightRules = function () {
  5. this.$rules = {
  6. start: [{
  7. token: "keyword.control",
  8. regex: /##|``/,
  9. comment: "Wall"
  10. }, {
  11. token: "entity.name.tag",
  12. regex: /\.\./,
  13. comment: "Path"
  14. }, {
  15. token: "keyword.control",
  16. regex: /<>/,
  17. comment: "Splitter"
  18. }, {
  19. token: "entity.name.tag",
  20. regex: /\*[\*A-Za-z0-9]/,
  21. comment: "Signal"
  22. }, {
  23. token: "constant.numeric",
  24. regex: /[0-9]{2}/,
  25. comment: "Pause"
  26. }, {
  27. token: "keyword.control",
  28. regex: /\^\^/,
  29. comment: "Start"
  30. }, {
  31. token: "keyword.control",
  32. regex: /\(\)/,
  33. comment: "Hole"
  34. }, {
  35. token: "support.function",
  36. regex: />>/,
  37. comment: "Out"
  38. }, {
  39. token: "support.function",
  40. regex: />\//,
  41. comment: "Ln Out"
  42. }, {
  43. token: "support.function",
  44. regex: /<</,
  45. comment: "In"
  46. }, {
  47. token: "keyword.control",
  48. regex: /--/,
  49. comment: "One use"
  50. }, {
  51. token: "constant.language",
  52. regex: /%[LRUDNlrudn]/,
  53. comment: "Direction"
  54. }, {
  55. token: [
  56. "entity.name.function",
  57. "keyword.other",
  58. "keyword.operator",
  59. "keyword.other",
  60. "keyword.operator",
  61. "constant.numeric",
  62. "keyword.operator",
  63. "keyword.other",
  64. "keyword.operator",
  65. "constant.numeric",
  66. "string.quoted.double",
  67. "string.quoted.single"
  68. ],
  69. regex: /([A-Za-z][A-Za-z0-9])( *-> *)(?:([-+*\/]=)( *)((?:-)?)([0-9]+)|(=)( *)(?:((?:-)?)([0-9]+)|("[^"]*")|('[^']*')))/,
  70. comment: "Assignment function"
  71. }, {
  72. token: [
  73. "entity.name.function",
  74. "keyword.other",
  75. "keyword.control",
  76. "keyword.other",
  77. "keyword.operator",
  78. "keyword.other",
  79. "keyword.operator",
  80. "constant.numeric",
  81. "entity.name.tag",
  82. "keyword.other",
  83. "keyword.control",
  84. "keyword.other",
  85. "constant.language",
  86. "keyword.other",
  87. "keyword.control",
  88. "keyword.other",
  89. "constant.language"
  90. ],
  91. regex: /([A-Za-z][A-Za-z0-9])( *-> *)(IF|if)( *)(?:([<>]=?|==)( *)((?:-)?)([0-9]+)|(\*[\*A-Za-z0-9]))( *)(THEN|then)( *)(%[LRUDNlrudn])(?:( *)(ELSE|else)( *)(%[LRUDNlrudn]))?/,
  92. comment: "Equality Function"
  93. }, {
  94. token: "entity.name.function",
  95. regex: /[A-Za-z][A-Za-z0-9]/,
  96. comment: "Function cell"
  97. }, {
  98. token: "comment.line.double-slash",
  99. regex: / *\/\/.*/,
  100. comment: "Comment"
  101. }]
  102. };
  103. this.normalizeRules();
  104. };
  105. MazeHighlightRules.metaData = {
  106. fileTypes: ["mz"],
  107. name: "Maze",
  108. scopeName: "source.maze"
  109. };
  110. oop.inherits(MazeHighlightRules, TextHighlightRules);
  111. exports.MazeHighlightRules = MazeHighlightRules;
  112. });
  113. 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";
  114. var oop = require("../../lib/oop");
  115. var Range = require("../../range").Range;
  116. var BaseFoldMode = require("./fold_mode").FoldMode;
  117. var FoldMode = exports.FoldMode = function (commentRegex) {
  118. if (commentRegex) {
  119. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  120. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  121. }
  122. };
  123. oop.inherits(FoldMode, BaseFoldMode);
  124. (function () {
  125. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  126. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  127. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  128. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  129. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  130. this._getFoldWidgetBase = this.getFoldWidget;
  131. this.getFoldWidget = function (session, foldStyle, row) {
  132. var line = session.getLine(row);
  133. if (this.singleLineBlockCommentRe.test(line)) {
  134. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  135. return "";
  136. }
  137. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  138. if (!fw && this.startRegionRe.test(line))
  139. return "start"; // lineCommentRegionStart
  140. return fw;
  141. };
  142. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  143. var line = session.getLine(row);
  144. if (this.startRegionRe.test(line))
  145. return this.getCommentRegionBlock(session, line, row);
  146. var match = line.match(this.foldingStartMarker);
  147. if (match) {
  148. var i = match.index;
  149. if (match[1])
  150. return this.openingBracketBlock(session, match[1], row, i);
  151. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  152. if (range && !range.isMultiLine()) {
  153. if (forceMultiline) {
  154. range = this.getSectionRange(session, row);
  155. }
  156. else if (foldStyle != "all")
  157. range = null;
  158. }
  159. return range;
  160. }
  161. if (foldStyle === "markbegin")
  162. return;
  163. var match = line.match(this.foldingStopMarker);
  164. if (match) {
  165. var i = match.index + match[0].length;
  166. if (match[1])
  167. return this.closingBracketBlock(session, match[1], row, i);
  168. return session.getCommentFoldRange(row, i, -1);
  169. }
  170. };
  171. this.getSectionRange = function (session, row) {
  172. var line = session.getLine(row);
  173. var startIndent = line.search(/\S/);
  174. var startRow = row;
  175. var startColumn = line.length;
  176. row = row + 1;
  177. var endRow = row;
  178. var maxRow = session.getLength();
  179. while (++row < maxRow) {
  180. line = session.getLine(row);
  181. var indent = line.search(/\S/);
  182. if (indent === -1)
  183. continue;
  184. if (startIndent > indent)
  185. break;
  186. var subRange = this.getFoldWidgetRange(session, "all", row);
  187. if (subRange) {
  188. if (subRange.start.row <= startRow) {
  189. break;
  190. }
  191. else if (subRange.isMultiLine()) {
  192. row = subRange.end.row;
  193. }
  194. else if (startIndent == indent) {
  195. break;
  196. }
  197. }
  198. endRow = row;
  199. }
  200. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  201. };
  202. this.getCommentRegionBlock = function (session, line, row) {
  203. var startColumn = line.search(/\s*$/);
  204. var maxRow = session.getLength();
  205. var startRow = row;
  206. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  207. var depth = 1;
  208. while (++row < maxRow) {
  209. line = session.getLine(row);
  210. var m = re.exec(line);
  211. if (!m)
  212. continue;
  213. if (m[1])
  214. depth--;
  215. else
  216. depth++;
  217. if (!depth)
  218. break;
  219. }
  220. var endRow = row;
  221. if (endRow > startRow) {
  222. return new Range(startRow, startColumn, endRow, line.length);
  223. }
  224. };
  225. }).call(FoldMode.prototype);
  226. });
  227. ace.define("ace/mode/maze",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/maze_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
  228. var oop = require("../lib/oop");
  229. var TextMode = require("./text").Mode;
  230. var MazeHighlightRules = require("./maze_highlight_rules").MazeHighlightRules;
  231. var FoldMode = require("./folding/cstyle").FoldMode;
  232. var Mode = function () {
  233. this.HighlightRules = MazeHighlightRules;
  234. this.foldingRules = new FoldMode();
  235. this.$behaviour = this.$defaultBehaviour;
  236. };
  237. oop.inherits(Mode, TextMode);
  238. (function () {
  239. this.lineCommentStart = "//";
  240. this.$id = "ace/mode/maze";
  241. this.snippetFileId = "ace/snippets/maze";
  242. }).call(Mode.prototype);
  243. exports.Mode = Mode;
  244. }); (function() {
  245. ace.require(["ace/mode/maze"], function(m) {
  246. if (typeof module == "object" && typeof exports == "object" && module) {
  247. module.exports = m;
  248. }
  249. });
  250. })();