9405408bc4c1c18469c1eefd766f06b9.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. ace.define("ace/mode/elm_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){// TODO check with https://github.com/deadfoxygrandpa/Elm.tmLanguage
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  5. var ElmHighlightRules = function () {
  6. var keywordMapper = this.createKeywordMapper({
  7. "keyword": "as|case|class|data|default|deriving|do|else|export|foreign|" +
  8. "hiding|jsevent|if|import|in|infix|infixl|infixr|instance|let|" +
  9. "module|newtype|of|open|then|type|where|_|port|\u03BB"
  10. }, "identifier");
  11. var escapeRe = /\\(\d+|['"\\&trnbvf])/;
  12. var smallRe = /[a-z_]/.source;
  13. var largeRe = /[A-Z]/.source;
  14. var idRe = /[a-z_A-Z0-9']/.source;
  15. this.$rules = {
  16. start: [{
  17. token: "string.start",
  18. regex: '"',
  19. next: "string"
  20. }, {
  21. token: "string.character",
  22. regex: "'(?:" + escapeRe.source + "|.)'?"
  23. }, {
  24. regex: /0(?:[xX][0-9A-Fa-f]+|[oO][0-7]+)|\d+(\.\d+)?([eE][-+]?\d*)?/,
  25. token: "constant.numeric"
  26. }, {
  27. token: "comment",
  28. regex: "--.*"
  29. }, {
  30. token: "keyword",
  31. regex: /\.\.|\||:|=|\\|"|->|<-|\u2192/
  32. }, {
  33. token: "keyword.operator",
  34. regex: /[-!#$%&*+.\/<=>?@\\^|~:\u03BB\u2192]+/
  35. }, {
  36. token: "operator.punctuation",
  37. regex: /[,;`]/
  38. }, {
  39. regex: largeRe + idRe + "+\\.?",
  40. token: function (value) {
  41. if (value[value.length - 1] == ".")
  42. return "entity.name.function";
  43. return "constant.language";
  44. }
  45. }, {
  46. regex: "^" + smallRe + idRe + "+",
  47. token: function (value) {
  48. return "constant.language";
  49. }
  50. }, {
  51. token: keywordMapper,
  52. regex: "[\\w\\xff-\\u218e\\u2455-\\uffff]+\\b"
  53. }, {
  54. regex: "{-#?",
  55. token: "comment.start",
  56. onMatch: function (value, currentState, stack) {
  57. this.next = value.length == 2 ? "blockComment" : "docComment";
  58. return this.token;
  59. }
  60. }, {
  61. token: "variable.language",
  62. regex: /\[markdown\|/,
  63. next: "markdown"
  64. }, {
  65. token: "paren.lparen",
  66. regex: /[\[({]/
  67. }, {
  68. token: "paren.rparen",
  69. regex: /[\])}]/
  70. }],
  71. markdown: [{
  72. regex: /\|\]/,
  73. next: "start"
  74. }, {
  75. defaultToken: "string"
  76. }],
  77. blockComment: [{
  78. regex: "{-",
  79. token: "comment.start",
  80. push: "blockComment"
  81. }, {
  82. regex: "-}",
  83. token: "comment.end",
  84. next: "pop"
  85. }, {
  86. defaultToken: "comment"
  87. }],
  88. docComment: [{
  89. regex: "{-",
  90. token: "comment.start",
  91. push: "docComment"
  92. }, {
  93. regex: "-}",
  94. token: "comment.end",
  95. next: "pop"
  96. }, {
  97. defaultToken: "doc.comment"
  98. }],
  99. string: [{
  100. token: "constant.language.escape",
  101. regex: escapeRe
  102. }, {
  103. token: "text",
  104. regex: /\\(\s|$)/,
  105. next: "stringGap"
  106. }, {
  107. token: "string.end",
  108. regex: '"',
  109. next: "start"
  110. }, {
  111. defaultToken: "string"
  112. }],
  113. stringGap: [{
  114. token: "text",
  115. regex: /\\/,
  116. next: "string"
  117. }, {
  118. token: "error",
  119. regex: "",
  120. next: "start"
  121. }]
  122. };
  123. this.normalizeRules();
  124. };
  125. oop.inherits(ElmHighlightRules, TextHighlightRules);
  126. exports.ElmHighlightRules = ElmHighlightRules;
  127. });
  128. 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";
  129. var oop = require("../../lib/oop");
  130. var Range = require("../../range").Range;
  131. var BaseFoldMode = require("./fold_mode").FoldMode;
  132. var FoldMode = exports.FoldMode = function (commentRegex) {
  133. if (commentRegex) {
  134. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  135. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  136. }
  137. };
  138. oop.inherits(FoldMode, BaseFoldMode);
  139. (function () {
  140. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  141. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  142. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  143. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  144. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  145. this._getFoldWidgetBase = this.getFoldWidget;
  146. this.getFoldWidget = function (session, foldStyle, row) {
  147. var line = session.getLine(row);
  148. if (this.singleLineBlockCommentRe.test(line)) {
  149. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  150. return "";
  151. }
  152. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  153. if (!fw && this.startRegionRe.test(line))
  154. return "start"; // lineCommentRegionStart
  155. return fw;
  156. };
  157. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  158. var line = session.getLine(row);
  159. if (this.startRegionRe.test(line))
  160. return this.getCommentRegionBlock(session, line, row);
  161. var match = line.match(this.foldingStartMarker);
  162. if (match) {
  163. var i = match.index;
  164. if (match[1])
  165. return this.openingBracketBlock(session, match[1], row, i);
  166. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  167. if (range && !range.isMultiLine()) {
  168. if (forceMultiline) {
  169. range = this.getSectionRange(session, row);
  170. }
  171. else if (foldStyle != "all")
  172. range = null;
  173. }
  174. return range;
  175. }
  176. if (foldStyle === "markbegin")
  177. return;
  178. var match = line.match(this.foldingStopMarker);
  179. if (match) {
  180. var i = match.index + match[0].length;
  181. if (match[1])
  182. return this.closingBracketBlock(session, match[1], row, i);
  183. return session.getCommentFoldRange(row, i, -1);
  184. }
  185. };
  186. this.getSectionRange = function (session, row) {
  187. var line = session.getLine(row);
  188. var startIndent = line.search(/\S/);
  189. var startRow = row;
  190. var startColumn = line.length;
  191. row = row + 1;
  192. var endRow = row;
  193. var maxRow = session.getLength();
  194. while (++row < maxRow) {
  195. line = session.getLine(row);
  196. var indent = line.search(/\S/);
  197. if (indent === -1)
  198. continue;
  199. if (startIndent > indent)
  200. break;
  201. var subRange = this.getFoldWidgetRange(session, "all", row);
  202. if (subRange) {
  203. if (subRange.start.row <= startRow) {
  204. break;
  205. }
  206. else if (subRange.isMultiLine()) {
  207. row = subRange.end.row;
  208. }
  209. else if (startIndent == indent) {
  210. break;
  211. }
  212. }
  213. endRow = row;
  214. }
  215. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  216. };
  217. this.getCommentRegionBlock = function (session, line, row) {
  218. var startColumn = line.search(/\s*$/);
  219. var maxRow = session.getLength();
  220. var startRow = row;
  221. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  222. var depth = 1;
  223. while (++row < maxRow) {
  224. line = session.getLine(row);
  225. var m = re.exec(line);
  226. if (!m)
  227. continue;
  228. if (m[1])
  229. depth--;
  230. else
  231. depth++;
  232. if (!depth)
  233. break;
  234. }
  235. var endRow = row;
  236. if (endRow > startRow) {
  237. return new Range(startRow, startColumn, endRow, line.length);
  238. }
  239. };
  240. }).call(FoldMode.prototype);
  241. });
  242. ace.define("ace/mode/elm",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/elm_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){/*
  243. THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
  244. */
  245. "use strict";
  246. var oop = require("../lib/oop");
  247. var TextMode = require("./text").Mode;
  248. var HighlightRules = require("./elm_highlight_rules").ElmHighlightRules;
  249. var FoldMode = require("./folding/cstyle").FoldMode;
  250. var Mode = function () {
  251. this.HighlightRules = HighlightRules;
  252. this.foldingRules = new FoldMode();
  253. this.$behaviour = this.$defaultBehaviour;
  254. };
  255. oop.inherits(Mode, TextMode);
  256. (function () {
  257. this.lineCommentStart = "--";
  258. this.blockComment = { start: "{-", end: "-}", nestable: true };
  259. this.$id = "ace/mode/elm";
  260. }).call(Mode.prototype);
  261. exports.Mode = Mode;
  262. }); (function() {
  263. ace.require(["ace/mode/elm"], function(m) {
  264. if (typeof module == "object" && typeof exports == "object" && module) {
  265. module.exports = m;
  266. }
  267. });
  268. })();