| 1 |
ace.define("ace/mode/julia_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){ |
| 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 |
}); |
| 109 |
|
| 110 |
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"; |
| 111 |
var oop = require("../../lib/oop"); |
| 112 |
var Range = require("../../range").Range; |
| 113 |
var BaseFoldMode = require("./fold_mode").FoldMode; |
| 114 |
var FoldMode = exports.FoldMode = function (commentRegex) { |
| 115 |
if (commentRegex) { |
| 116 |
this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)); |
| 117 |
this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)); |
| 118 |
} |
| 119 |
}; |
| 120 |
oop.inherits(FoldMode, BaseFoldMode); |
| 121 |
(function () { |
| 122 |
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/; |
| 123 |
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/; |
| 124 |
this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/; |
| 125 |
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; |
| 126 |
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; |
| 127 |
this._getFoldWidgetBase = this.getFoldWidget; |
| 128 |
this.getFoldWidget = function (session, foldStyle, row) { |
| 129 |
var line = session.getLine(row); |
| 130 |
if (this.singleLineBlockCommentRe.test(line)) { |
| 131 |
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) |
| 132 |
return ""; |
| 133 |
} |
| 134 |
var fw = this._getFoldWidgetBase(session, foldStyle, row); |
| 135 |
if (!fw && this.startRegionRe.test(line)) |
| 136 |
return "start"; |
| 137 |
return fw; |
| 138 |
}; |
| 139 |
this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) { |
| 140 |
var line = session.getLine(row); |
| 141 |
if (this.startRegionRe.test(line)) |
| 142 |
return this.getCommentRegionBlock(session, line, row); |
| 143 |
var match = line.match(this.foldingStartMarker); |
| 144 |
if (match) { |
| 145 |
var i = match.index; |
| 146 |
if (match[1]) |
| 147 |
return this.openingBracketBlock(session, match[1], row, i); |
| 148 |
var range = session.getCommentFoldRange(row, i + match[0].length, 1); |
| 149 |
if (range && !range.isMultiLine()) { |
| 150 |
if (forceMultiline) { |
| 151 |
range = this.getSectionRange(session, row); |
| 152 |
} |
| 153 |
else if (foldStyle != "all") |
| 154 |
range = null; |
| 155 |
} |
| 156 |
return range; |
| 157 |
} |
| 158 |
if (foldStyle === "markbegin") |
| 159 |
return; |
| 160 |
var match = line.match(this.foldingStopMarker); |
| 161 |
if (match) { |
| 162 |
var i = match.index + match[0].length; |
| 163 |
if (match[1]) |
| 164 |
return this.closingBracketBlock(session, match[1], row, i); |
| 165 |
return session.getCommentFoldRange(row, i, -1); |
| 166 |
} |
| 167 |
}; |
| 168 |
this.getSectionRange = function (session, row) { |
| 169 |
var line = session.getLine(row); |
| 170 |
var startIndent = line.search(/\S/); |
| 171 |
var startRow = row; |
| 172 |
var startColumn = line.length; |
| 173 |
row = row + 1; |
| 174 |
var endRow = row; |
| 175 |
var maxRow = session.getLength(); |
| 176 |
while (++row < maxRow) { |
| 177 |
line = session.getLine(row); |
| 178 |
var indent = line.search(/\S/); |
| 179 |
if (indent === -1) |
| 180 |
continue; |
| 181 |
if (startIndent > indent) |
| 182 |
break; |
| 183 |
var subRange = this.getFoldWidgetRange(session, "all", row); |
| 184 |
if (subRange) { |
| 185 |
if (subRange.start.row <= startRow) { |
| 186 |
break; |
| 187 |
} |
| 188 |
else if (subRange.isMultiLine()) { |
| 189 |
row = subRange.end.row; |
| 190 |
} |
| 191 |
else if (startIndent == indent) { |
| 192 |
break; |
| 193 |
} |
| 194 |
} |
| 195 |
endRow = row; |
| 196 |
} |
| 197 |
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); |
| 198 |
}; |
| 199 |
this.getCommentRegionBlock = function (session, line, row) { |
| 200 |
var startColumn = line.search(/\s*$/); |
| 201 |
var maxRow = session.getLength(); |
| 202 |
var startRow = row; |
| 203 |
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; |
| 204 |
var depth = 1; |
| 205 |
while (++row < maxRow) { |
| 206 |
line = session.getLine(row); |
| 207 |
var m = re.exec(line); |
| 208 |
if (!m) |
| 209 |
continue; |
| 210 |
if (m[1]) |
| 211 |
depth--; |
| 212 |
else |
| 213 |
depth++; |
| 214 |
if (!depth) |
| 215 |
break; |
| 216 |
} |
| 217 |
var endRow = row; |
| 218 |
if (endRow > startRow) { |
| 219 |
return new Range(startRow, startColumn, endRow, line.length); |
| 220 |
} |
| 221 |
}; |
| 222 |
}).call(FoldMode.prototype); |
| 223 |
|
| 224 |
}); |
| 225 |
|
| 226 |
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){ |
| 227 |
|
| 228 |
|
| 229 |
"use strict"; |
| 230 |
var oop = require("../lib/oop"); |
| 231 |
var TextMode = require("./text").Mode; |
| 232 |
var JuliaHighlightRules = require("./julia_highlight_rules").JuliaHighlightRules; |
| 233 |
var FoldMode = require("./folding/cstyle").FoldMode; |
| 234 |
var Mode = function () { |
| 235 |
this.HighlightRules = JuliaHighlightRules; |
| 236 |
this.foldingRules = new FoldMode(); |
| 237 |
this.$behaviour = this.$defaultBehaviour; |
| 238 |
}; |
| 239 |
oop.inherits(Mode, TextMode); |
| 240 |
(function () { |
| 241 |
this.lineCommentStart = "#"; |
| 242 |
this.blockComment = ""; |
| 243 |
this.$id = "ace/mode/julia"; |
| 244 |
}).call(Mode.prototype); |
| 245 |
exports.Mode = Mode; |
| 246 |
|
| 247 |
}); (function() { |
| 248 |
ace.require(["ace/mode/julia"], function(m) { |
| 249 |
if (typeof module == "object" && typeof exports == "object" && module) { |
| 250 |
module.exports = m; |
| 251 |
} |
| 252 |
}); |
| 253 |
})(); |
| 254 |
|