d37f0f78c06e883be0e04a3be861fb68.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. ace.define("ace/mode/fsharp_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 FSharpHighlightRules = function () {
  5. var keywordMapper = this.createKeywordMapper({
  6. "variable": "this",
  7. "keyword": 'abstract|assert|base|begin|class|default|delegate|done|downcast|downto|elif\
  8. |else|exception|extern|false|finally|function|global|inherit|inline|interface|internal|lazy|match\
  9. |member|module|mutable|namespace|open|or|override|private|public|rec|return|return!|select|static\
  10. |struct|then|to|true|try|typeof|upcast|use|use!|val|void|when|while|with|yield|yield!|__SOURCE_DIRECTORY__\
  11. |as|asr|land|lor|lsl|lsr|lxor|mod|sig|atomic|break|checked|component|const|constraint|constructor|continue\
  12. |eager|event|external|fixed|functor|include|method|mixin|object|parallel|process|protected|pure|sealed|tailcall\
  13. |trait|virtual|volatile|and|do|end|for|fun|if|in|let|let!|new|not|null|of|endif',
  14. "constant": "true|false"
  15. }, "identifier");
  16. var floatNumber = "(?:(?:(?:(?:(?:(?:\\d+)?(?:\\.\\d+))|(?:(?:\\d+)\\.))|(?:\\d+))(?:[eE][+-]?\\d+))|(?:(?:(?:\\d+)?(?:\\.\\d+))|(?:(?:\\d+)\\.)))";
  17. this.$rules = {
  18. "start": [
  19. {
  20. token: "variable.classes",
  21. regex: '\\[\\<[.]*\\>\\]'
  22. },
  23. {
  24. token: "comment",
  25. regex: '//.*$'
  26. },
  27. {
  28. token: "comment.start",
  29. regex: /\(\*(?!\))/,
  30. push: "blockComment"
  31. },
  32. {
  33. token: "string",
  34. regex: "'.'"
  35. },
  36. {
  37. token: "string",
  38. regex: '"""',
  39. next: [{
  40. token: "constant.language.escape",
  41. regex: /\\./,
  42. next: "qqstring"
  43. }, {
  44. token: "string",
  45. regex: '"""',
  46. next: "start"
  47. }, {
  48. defaultToken: "string"
  49. }]
  50. },
  51. {
  52. token: "string",
  53. regex: '"',
  54. next: [{
  55. token: "constant.language.escape",
  56. regex: /\\./,
  57. next: "qqstring"
  58. }, {
  59. token: "string",
  60. regex: '"',
  61. next: "start"
  62. }, {
  63. defaultToken: "string"
  64. }]
  65. },
  66. {
  67. token: ["verbatim.string", "string"],
  68. regex: '(@?)(")',
  69. stateName: "qqstring",
  70. next: [{
  71. token: "constant.language.escape",
  72. regex: '""'
  73. }, {
  74. token: "string",
  75. regex: '"',
  76. next: "start"
  77. }, {
  78. defaultToken: "string"
  79. }]
  80. },
  81. {
  82. token: "constant.float",
  83. regex: "(?:" + floatNumber + "|\\d+)[jJ]\\b"
  84. },
  85. {
  86. token: "constant.float",
  87. regex: floatNumber
  88. },
  89. {
  90. token: "constant.integer",
  91. regex: "(?:(?:(?:[1-9]\\d*)|(?:0))|(?:0[oO]?[0-7]+)|(?:0[xX][\\dA-Fa-f]+)|(?:0[bB][01]+))\\b"
  92. },
  93. {
  94. token: ["keyword.type", "variable"],
  95. regex: "(type\\s)([a-zA-Z0-9_$\-]*\\b)"
  96. },
  97. {
  98. token: keywordMapper,
  99. regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  100. },
  101. {
  102. token: "keyword.operator",
  103. regex: "\\+\\.|\\-\\.|\\*\\.|\\/\\.|#|;;|\\+|\\-|\\*|\\*\\*\\/|\\/\\/|%|<<|>>|&|\\||\\^|~|<|>|<=|=>|==|!=|<>|<-|=|\\(\\*\\)"
  104. },
  105. {
  106. token: "paren.lparen",
  107. regex: "[[({]"
  108. },
  109. {
  110. token: "paren.rparen",
  111. regex: "[\\])}]"
  112. }
  113. ],
  114. blockComment: [{
  115. regex: /\(\*\)/,
  116. token: "comment"
  117. }, {
  118. regex: /\(\*(?!\))/,
  119. token: "comment.start",
  120. push: "blockComment"
  121. }, {
  122. regex: /\*\)/,
  123. token: "comment.end",
  124. next: "pop"
  125. }, {
  126. defaultToken: "comment"
  127. }]
  128. };
  129. this.normalizeRules();
  130. };
  131. oop.inherits(FSharpHighlightRules, TextHighlightRules);
  132. exports.FSharpHighlightRules = FSharpHighlightRules;
  133. });
  134. 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";
  135. var oop = require("../../lib/oop");
  136. var Range = require("../../range").Range;
  137. var BaseFoldMode = require("./fold_mode").FoldMode;
  138. var FoldMode = exports.FoldMode = function (commentRegex) {
  139. if (commentRegex) {
  140. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  141. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  142. }
  143. };
  144. oop.inherits(FoldMode, BaseFoldMode);
  145. (function () {
  146. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  147. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  148. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  149. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  150. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  151. this._getFoldWidgetBase = this.getFoldWidget;
  152. this.getFoldWidget = function (session, foldStyle, row) {
  153. var line = session.getLine(row);
  154. if (this.singleLineBlockCommentRe.test(line)) {
  155. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  156. return "";
  157. }
  158. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  159. if (!fw && this.startRegionRe.test(line))
  160. return "start"; // lineCommentRegionStart
  161. return fw;
  162. };
  163. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  164. var line = session.getLine(row);
  165. if (this.startRegionRe.test(line))
  166. return this.getCommentRegionBlock(session, line, row);
  167. var match = line.match(this.foldingStartMarker);
  168. if (match) {
  169. var i = match.index;
  170. if (match[1])
  171. return this.openingBracketBlock(session, match[1], row, i);
  172. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  173. if (range && !range.isMultiLine()) {
  174. if (forceMultiline) {
  175. range = this.getSectionRange(session, row);
  176. }
  177. else if (foldStyle != "all")
  178. range = null;
  179. }
  180. return range;
  181. }
  182. if (foldStyle === "markbegin")
  183. return;
  184. var match = line.match(this.foldingStopMarker);
  185. if (match) {
  186. var i = match.index + match[0].length;
  187. if (match[1])
  188. return this.closingBracketBlock(session, match[1], row, i);
  189. return session.getCommentFoldRange(row, i, -1);
  190. }
  191. };
  192. this.getSectionRange = function (session, row) {
  193. var line = session.getLine(row);
  194. var startIndent = line.search(/\S/);
  195. var startRow = row;
  196. var startColumn = line.length;
  197. row = row + 1;
  198. var endRow = row;
  199. var maxRow = session.getLength();
  200. while (++row < maxRow) {
  201. line = session.getLine(row);
  202. var indent = line.search(/\S/);
  203. if (indent === -1)
  204. continue;
  205. if (startIndent > indent)
  206. break;
  207. var subRange = this.getFoldWidgetRange(session, "all", row);
  208. if (subRange) {
  209. if (subRange.start.row <= startRow) {
  210. break;
  211. }
  212. else if (subRange.isMultiLine()) {
  213. row = subRange.end.row;
  214. }
  215. else if (startIndent == indent) {
  216. break;
  217. }
  218. }
  219. endRow = row;
  220. }
  221. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  222. };
  223. this.getCommentRegionBlock = function (session, line, row) {
  224. var startColumn = line.search(/\s*$/);
  225. var maxRow = session.getLength();
  226. var startRow = row;
  227. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  228. var depth = 1;
  229. while (++row < maxRow) {
  230. line = session.getLine(row);
  231. var m = re.exec(line);
  232. if (!m)
  233. continue;
  234. if (m[1])
  235. depth--;
  236. else
  237. depth++;
  238. if (!depth)
  239. break;
  240. }
  241. var endRow = row;
  242. if (endRow > startRow) {
  243. return new Range(startRow, startColumn, endRow, line.length);
  244. }
  245. };
  246. }).call(FoldMode.prototype);
  247. });
  248. ace.define("ace/mode/fsharp",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/fsharp_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
  249. var oop = require("../lib/oop");
  250. var TextMode = require("./text").Mode;
  251. var FSharpHighlightRules = require("./fsharp_highlight_rules").FSharpHighlightRules;
  252. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  253. var Mode = function () {
  254. TextMode.call(this);
  255. this.HighlightRules = FSharpHighlightRules;
  256. this.foldingRules = new CStyleFoldMode();
  257. };
  258. oop.inherits(Mode, TextMode);
  259. (function () {
  260. this.lineCommentStart = "//";
  261. this.blockComment = { start: "(*", end: "*)", nestable: true };
  262. this.$id = "ace/mode/fsharp";
  263. }).call(Mode.prototype);
  264. exports.Mode = Mode;
  265. }); (function() {
  266. ace.require(["ace/mode/fsharp"], function(m) {
  267. if (typeof module == "object" && typeof exports == "object" && module) {
  268. module.exports = m;
  269. }
  270. });
  271. })();