34f52a56877a14fbb7e9d37469ebbf15.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. ace.define("ace/mode/julia_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){/* This file was autogenerated from https://raw.github.com/JuliaLang/julia/master/contrib/Julia.tmbundle/Syntaxes/Julia.tmLanguage (uuid: ) */
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  5. var JuliaHighlightRules = function () {
  6. this.$rules = { start: [{ include: '#function_decl' },
  7. { include: '#function_call' },
  8. { include: '#type_decl' },
  9. { include: '#keyword' },
  10. { include: '#operator' },
  11. { include: '#number' },
  12. { include: '#string' },
  13. { include: '#comment' }],
  14. '#bracket': [{ token: 'keyword.bracket.julia',
  15. regex: '\\(|\\)|\\[|\\]|\\{|\\}|,' }],
  16. '#comment': [{ token: ['punctuation.definition.comment.julia',
  17. 'comment.line.number-sign.julia'],
  18. regex: '(#)(?!\\{)(.*$)' }],
  19. '#function_call': [{ token: ['support.function.julia', 'text'],
  20. regex: '([a-zA-Z0-9_]+!?)([\\w\\xff-\\u218e\\u2455-\\uffff]*\\()' }],
  21. '#function_decl': [{ token: ['keyword.other.julia', 'meta.function.julia',
  22. 'entity.name.function.julia', 'meta.function.julia', 'text'],
  23. regex: '(function|macro)(\\s*)([a-zA-Z0-9_\\{]+!?)([\\w\\xff-\\u218e\\u2455-\\uffff]*)([(\\\\{])' }],
  24. '#keyword': [{ token: 'keyword.other.julia',
  25. regex: '\\b(?:function|type|immutable|macro|quote|abstract|bitstype|typealias|module|baremodule|new)\\b' },
  26. { token: 'keyword.control.julia',
  27. regex: '\\b(?:if|else|elseif|while|for|in|begin|let|end|do|try|catch|finally|return|break|continue)\\b' },
  28. { token: 'storage.modifier.variable.julia',
  29. regex: '\\b(?:global|local|const|export|import|importall|using)\\b' },
  30. { token: 'variable.macro.julia', regex: '@[\\w\\xff-\\u218e\\u2455-\\uffff]+\\b' }],
  31. '#number': [{ token: 'constant.numeric.julia',
  32. regex: '\\b0(?:x|X)[0-9a-fA-F]*|(?:\\b[0-9]+\\.?[0-9]*|\\.[0-9]+)(?:(?:e|E)(?:\\+|-)?[0-9]*)?(?:im)?|\\bInf(?:32)?\\b|\\bNaN(?:32)?\\b|\\btrue\\b|\\bfalse\\b' }],
  33. '#operator': [{ token: 'keyword.operator.update.julia',
  34. regex: '=|:=|\\+=|-=|\\*=|/=|//=|\\.//=|\\.\\*=|\\\\=|\\.\\\\=|^=|\\.^=|%=|\\|=|&=|\\$=|<<=|>>=' },
  35. { token: 'keyword.operator.ternary.julia', regex: '\\?|:' },
  36. { token: 'keyword.operator.boolean.julia',
  37. regex: '\\|\\||&&|!' },
  38. { token: 'keyword.operator.arrow.julia', regex: '->|<-|-->' },
  39. { token: 'keyword.operator.relation.julia',
  40. regex: '>|<|>=|<=|==|!=|\\.>|\\.<|\\.>=|\\.>=|\\.==|\\.!=|\\.=|\\.!|<:|:>' },
  41. { token: 'keyword.operator.range.julia', regex: ':' },
  42. { token: 'keyword.operator.shift.julia', regex: '<<|>>' },
  43. { token: 'keyword.operator.bitwise.julia', regex: '\\||\\&|~' },
  44. { token: 'keyword.operator.arithmetic.julia',
  45. regex: '\\+|-|\\*|\\.\\*|/|\\./|//|\\.//|%|\\.%|\\\\|\\.\\\\|\\^|\\.\\^' },
  46. { token: 'keyword.operator.isa.julia', regex: '::' },
  47. { token: 'keyword.operator.dots.julia',
  48. regex: '\\.(?=[a-zA-Z])|\\.\\.+' },
  49. { token: 'keyword.operator.interpolation.julia',
  50. regex: '\\$#?(?=.)' },
  51. { token: ['variable', 'keyword.operator.transposed-variable.julia'],
  52. regex: '([\\w\\xff-\\u218e\\u2455-\\uffff]+)((?:\'|\\.\')*\\.?\')' },
  53. { token: 'text',
  54. regex: '\\[|\\(' },
  55. { token: ['text', 'keyword.operator.transposed-matrix.julia'],
  56. regex: "([\\]\\)])((?:'|\\.')*\\.?')" }],
  57. '#string': [{ token: 'punctuation.definition.string.begin.julia',
  58. regex: '\'',
  59. push: [{ token: 'punctuation.definition.string.end.julia',
  60. regex: '\'',
  61. next: 'pop' },
  62. { include: '#string_escaped_char' },
  63. { defaultToken: 'string.quoted.single.julia' }] },
  64. { token: 'punctuation.definition.string.begin.julia',
  65. regex: '"',
  66. push: [{ token: 'punctuation.definition.string.end.julia',
  67. regex: '"',
  68. next: 'pop' },
  69. { include: '#string_escaped_char' },
  70. { defaultToken: 'string.quoted.double.julia' }] },
  71. { token: 'punctuation.definition.string.begin.julia',
  72. regex: '\\b[\\w\\xff-\\u218e\\u2455-\\uffff]+"',
  73. push: [{ token: 'punctuation.definition.string.end.julia',
  74. regex: '"[\\w\\xff-\\u218e\\u2455-\\uffff]*',
  75. next: 'pop' },
  76. { include: '#string_custom_escaped_char' },
  77. { defaultToken: 'string.quoted.custom-double.julia' }] },
  78. { token: 'punctuation.definition.string.begin.julia',
  79. regex: '`',
  80. push: [{ token: 'punctuation.definition.string.end.julia',
  81. regex: '`',
  82. next: 'pop' },
  83. { include: '#string_escaped_char' },
  84. { defaultToken: 'string.quoted.backtick.julia' }] }],
  85. '#string_custom_escaped_char': [{ token: 'constant.character.escape.julia', regex: '\\\\"' }],
  86. '#string_escaped_char': [{ token: 'constant.character.escape.julia',
  87. regex: '\\\\(?:\\\\|[0-3]\\d{,2}|[4-7]\\d?|x[a-fA-F0-9]{,2}|u[a-fA-F0-9]{,4}|U[a-fA-F0-9]{,8}|.)' }],
  88. '#type_decl': [{ token: ['keyword.control.type.julia',
  89. 'meta.type.julia',
  90. 'entity.name.type.julia',
  91. 'entity.other.inherited-class.julia',
  92. 'punctuation.separator.inheritance.julia',
  93. 'entity.other.inherited-class.julia'],
  94. regex: '(type|immutable)(\\s+)([a-zA-Z0-9_]+)(?:(\\s*)(<:)(\\s*[.a-zA-Z0-9_:]+))?' },
  95. { token: ['other.typed-variable.julia', 'support.type.julia'],
  96. regex: '([a-zA-Z0-9_]+)(::[a-zA-Z0-9_{}]+)' }] };
  97. this.normalizeRules();
  98. };
  99. JuliaHighlightRules.metaData = { fileTypes: ['jl'],
  100. firstLineMatch: '^#!.*\\bjulia\\s*$',
  101. foldingStartMarker: '^\\s*(?:if|while|for|begin|function|macro|module|baremodule|type|immutable|let)\\b(?!.*\\bend\\b).*$',
  102. foldingStopMarker: '^\\s*(?:end)\\b.*$',
  103. name: 'Julia',
  104. scopeName: 'source.julia' };
  105. oop.inherits(JuliaHighlightRules, TextHighlightRules);
  106. exports.JuliaHighlightRules = JuliaHighlightRules;
  107. });
  108. 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";
  109. var oop = require("../../lib/oop");
  110. var Range = require("../../range").Range;
  111. var BaseFoldMode = require("./fold_mode").FoldMode;
  112. var FoldMode = exports.FoldMode = function (commentRegex) {
  113. if (commentRegex) {
  114. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  115. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  116. }
  117. };
  118. oop.inherits(FoldMode, BaseFoldMode);
  119. (function () {
  120. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  121. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  122. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  123. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  124. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  125. this._getFoldWidgetBase = this.getFoldWidget;
  126. this.getFoldWidget = function (session, foldStyle, row) {
  127. var line = session.getLine(row);
  128. if (this.singleLineBlockCommentRe.test(line)) {
  129. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  130. return "";
  131. }
  132. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  133. if (!fw && this.startRegionRe.test(line))
  134. return "start"; // lineCommentRegionStart
  135. return fw;
  136. };
  137. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  138. var line = session.getLine(row);
  139. if (this.startRegionRe.test(line))
  140. return this.getCommentRegionBlock(session, line, row);
  141. var match = line.match(this.foldingStartMarker);
  142. if (match) {
  143. var i = match.index;
  144. if (match[1])
  145. return this.openingBracketBlock(session, match[1], row, i);
  146. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  147. if (range && !range.isMultiLine()) {
  148. if (forceMultiline) {
  149. range = this.getSectionRange(session, row);
  150. }
  151. else if (foldStyle != "all")
  152. range = null;
  153. }
  154. return range;
  155. }
  156. if (foldStyle === "markbegin")
  157. return;
  158. var match = line.match(this.foldingStopMarker);
  159. if (match) {
  160. var i = match.index + match[0].length;
  161. if (match[1])
  162. return this.closingBracketBlock(session, match[1], row, i);
  163. return session.getCommentFoldRange(row, i, -1);
  164. }
  165. };
  166. this.getSectionRange = function (session, row) {
  167. var line = session.getLine(row);
  168. var startIndent = line.search(/\S/);
  169. var startRow = row;
  170. var startColumn = line.length;
  171. row = row + 1;
  172. var endRow = row;
  173. var maxRow = session.getLength();
  174. while (++row < maxRow) {
  175. line = session.getLine(row);
  176. var indent = line.search(/\S/);
  177. if (indent === -1)
  178. continue;
  179. if (startIndent > indent)
  180. break;
  181. var subRange = this.getFoldWidgetRange(session, "all", row);
  182. if (subRange) {
  183. if (subRange.start.row <= startRow) {
  184. break;
  185. }
  186. else if (subRange.isMultiLine()) {
  187. row = subRange.end.row;
  188. }
  189. else if (startIndent == indent) {
  190. break;
  191. }
  192. }
  193. endRow = row;
  194. }
  195. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  196. };
  197. this.getCommentRegionBlock = function (session, line, row) {
  198. var startColumn = line.search(/\s*$/);
  199. var maxRow = session.getLength();
  200. var startRow = row;
  201. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  202. var depth = 1;
  203. while (++row < maxRow) {
  204. line = session.getLine(row);
  205. var m = re.exec(line);
  206. if (!m)
  207. continue;
  208. if (m[1])
  209. depth--;
  210. else
  211. depth++;
  212. if (!depth)
  213. break;
  214. }
  215. var endRow = row;
  216. if (endRow > startRow) {
  217. return new Range(startRow, startColumn, endRow, line.length);
  218. }
  219. };
  220. }).call(FoldMode.prototype);
  221. });
  222. ace.define("ace/mode/julia",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/julia_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){/*
  223. THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
  224. */
  225. "use strict";
  226. var oop = require("../lib/oop");
  227. var TextMode = require("./text").Mode;
  228. var JuliaHighlightRules = require("./julia_highlight_rules").JuliaHighlightRules;
  229. var FoldMode = require("./folding/cstyle").FoldMode;
  230. var Mode = function () {
  231. this.HighlightRules = JuliaHighlightRules;
  232. this.foldingRules = new FoldMode();
  233. this.$behaviour = this.$defaultBehaviour;
  234. };
  235. oop.inherits(Mode, TextMode);
  236. (function () {
  237. this.lineCommentStart = "#";
  238. this.blockComment = "";
  239. this.$id = "ace/mode/julia";
  240. }).call(Mode.prototype);
  241. exports.Mode = Mode;
  242. }); (function() {
  243. ace.require(["ace/mode/julia"], function(m) {
  244. if (typeof module == "object" && typeof exports == "object" && module) {
  245. module.exports = m;
  246. }
  247. });
  248. })();