| 1 |
ace.define("ace/mode/doc_comment_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 DocCommentHighlightRules = function () { |
| 5 |
this.$rules = { |
| 6 |
"start": [ |
| 7 |
{ |
| 8 |
token: "comment.doc.tag", |
| 9 |
regex: "@\\w+(?=\\s|$)" |
| 10 |
}, DocCommentHighlightRules.getTagRule(), { |
| 11 |
defaultToken: "comment.doc", |
| 12 |
caseInsensitive: true |
| 13 |
} |
| 14 |
] |
| 15 |
}; |
| 16 |
}; |
| 17 |
oop.inherits(DocCommentHighlightRules, TextHighlightRules); |
| 18 |
DocCommentHighlightRules.getTagRule = function (start) { |
| 19 |
return { |
| 20 |
token: "comment.doc.tag.storage.type", |
| 21 |
regex: "\\b(?:TODO|FIXME|XXX|HACK)\\b" |
| 22 |
}; |
| 23 |
}; |
| 24 |
DocCommentHighlightRules.getStartRule = function (start) { |
| 25 |
return { |
| 26 |
token: "comment.doc", |
| 27 |
regex: "\\/\\*(?=\\*)", |
| 28 |
next: start |
| 29 |
}; |
| 30 |
}; |
| 31 |
DocCommentHighlightRules.getEndRule = function (start) { |
| 32 |
return { |
| 33 |
token: "comment.doc", |
| 34 |
regex: "\\*\\/", |
| 35 |
next: start |
| 36 |
}; |
| 37 |
}; |
| 38 |
exports.DocCommentHighlightRules = DocCommentHighlightRules; |
| 39 |
|
| 40 |
}); |
| 41 |
|
| 42 |
ace.define("ace/mode/d_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict"; |
| 43 |
var oop = require("../lib/oop"); |
| 44 |
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; |
| 45 |
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; |
| 46 |
var DHighlightRules = function () { |
| 47 |
var keywords = ("this|super|import|module|body|mixin|__traits|invariant|alias|asm|delete|" + |
| 48 |
"typeof|typeid|sizeof|cast|new|in|is|typedef|__vector|__parameters"); |
| 49 |
var keywordControls = ("break|case|continue|default|do|else|for|foreach|foreach_reverse|goto|if|" + |
| 50 |
"return|switch|while|catch|try|throw|finally|version|assert|unittest|with"); |
| 51 |
var types = ("auto|bool|char|dchar|wchar|byte|ubyte|float|double|real|" + |
| 52 |
"cfloat|creal|cdouble|cent|ifloat|ireal|idouble|" + |
| 53 |
"int|long|short|void|uint|ulong|ushort|ucent|" + |
| 54 |
"function|delegate|string|wstring|dstring|size_t|ptrdiff_t|hash_t|Object"); |
| 55 |
var modifiers = ("abstract|align|debug|deprecated|export|extern|const|final|in|inout|out|" + |
| 56 |
"ref|immutable|lazy|nothrow|override|package|pragma|private|protected|" + |
| 57 |
"public|pure|scope|shared|__gshared|synchronized|static|volatile"); |
| 58 |
var storages = ("class|struct|union|template|interface|enum|macro"); |
| 59 |
var stringEscapesSeq = { |
| 60 |
token: "constant.language.escape", |
| 61 |
regex: "\\\\(?:(?:x[0-9A-F]{2})|(?:[0-7]{1,3})|(?:['\"\\?0abfnrtv\\\\])|" + |
| 62 |
"(?:u[0-9a-fA-F]{4})|(?:U[0-9a-fA-F]{8}))" |
| 63 |
}; |
| 64 |
var builtinConstants = ("null|true|false|" + |
| 65 |
"__DATE__|__EOF__|__TIME__|__TIMESTAMP__|__VENDOR__|__VERSION__|" + |
| 66 |
"__FILE__|__MODULE__|__LINE__|__FUNCTION__|__PRETTY_FUNCTION__"); |
| 67 |
var operators = ("/|/\\=|&|&\\=|&&|\\|\\|\\=|\\|\\||\\-|\\-\\=|\\-\\-|\\+|" + |
| 68 |
"\\+\\=|\\+\\+|\\<|\\<\\=|\\<\\<|\\<\\<\\=|\\<\\>|\\<\\>\\=|\\>|\\>\\=|\\>\\>\\=|" + |
| 69 |
"\\>\\>\\>\\=|\\>\\>|\\>\\>\\>|\\!|\\!\\=|\\!\\<\\>|\\!\\<\\>\\=|\\!\\<|\\!\\<\\=|" + |
| 70 |
"\\!\\>|\\!\\>\\=|\\?|\\$|\\=|\\=\\=|\\*|\\*\\=|%|%\\=|" + |
| 71 |
"\\^|\\^\\=|\\^\\^|\\^\\^\\=|~|~\\=|\\=\\>|#"); |
| 72 |
var keywordMapper = this.$keywords = this.createKeywordMapper({ |
| 73 |
"keyword.modifier": modifiers, |
| 74 |
"keyword.control": keywordControls, |
| 75 |
"keyword.type": types, |
| 76 |
"keyword": keywords, |
| 77 |
"keyword.storage": storages, |
| 78 |
"punctation": "\\.|\\,|;|\\.\\.|\\.\\.\\.", |
| 79 |
"keyword.operator": operators, |
| 80 |
"constant.language": builtinConstants |
| 81 |
}, "identifier"); |
| 82 |
var identifierRe = "[a-zA-Z_\u00a1-\uffff][a-zA-Z\\d_\u00a1-\uffff]*\\b"; |
| 83 |
this.$rules = { |
| 84 |
"start": [ |
| 85 |
{ |
| 86 |
token: "comment", |
| 87 |
regex: "\\/\\/.*$" |
| 88 |
}, |
| 89 |
DocCommentHighlightRules.getStartRule("doc-start"), |
| 90 |
{ |
| 91 |
token: "comment", |
| 92 |
regex: "\\/\\*", |
| 93 |
next: "star-comment" |
| 94 |
}, { |
| 95 |
token: "comment.shebang", |
| 96 |
regex: "^\\s*#!.*" |
| 97 |
}, { |
| 98 |
token: "comment", |
| 99 |
regex: "\\/\\+", |
| 100 |
next: "plus-comment" |
| 101 |
}, { |
| 102 |
onMatch: function (value, currentState, state) { |
| 103 |
state.unshift(this.next, value.substr(2)); |
| 104 |
return "string"; |
| 105 |
}, |
| 106 |
regex: 'q"(?:[\\[\\(\\{\\<]+)', |
| 107 |
next: 'operator-heredoc-string' |
| 108 |
}, { |
| 109 |
onMatch: function (value, currentState, state) { |
| 110 |
state.unshift(this.next, value.substr(2)); |
| 111 |
return "string"; |
| 112 |
}, |
| 113 |
regex: 'q"(?:[a-zA-Z_]+)$', |
| 114 |
next: 'identifier-heredoc-string' |
| 115 |
}, { |
| 116 |
token: "string", |
| 117 |
regex: '[xr]?"', |
| 118 |
next: "quote-string" |
| 119 |
}, { |
| 120 |
token: "string", |
| 121 |
regex: '[xr]?`', |
| 122 |
next: "backtick-string" |
| 123 |
}, { |
| 124 |
token: "string", |
| 125 |
regex: "[xr]?['](?:(?:\\\\.)|(?:[^'\\\\]))*?['][cdw]?" |
| 126 |
}, { |
| 127 |
token: ["keyword", "text", "paren.lparen"], |
| 128 |
regex: /(asm)(\s*)({)/, |
| 129 |
next: "d-asm" |
| 130 |
}, { |
| 131 |
token: ["keyword", "text", "paren.lparen", "constant.language"], |
| 132 |
regex: "(__traits)(\\s*)(\\()(" + identifierRe + ")" |
| 133 |
}, { |
| 134 |
token: ["keyword", "text", "variable.module"], |
| 135 |
regex: "(import|module)(\\s+)((?:" + identifierRe + "\\.?)*)" |
| 136 |
}, { |
| 137 |
token: ["keyword.storage", "text", "entity.name.type"], |
| 138 |
regex: "(" + storages + ")(\\s*)(" + identifierRe + ")" |
| 139 |
}, { |
| 140 |
token: ["keyword", "text", "variable.storage", "text"], |
| 141 |
regex: "(alias|typedef)(\\s*)(" + identifierRe + ")(\\s*)" |
| 142 |
}, { |
| 143 |
token: "constant.numeric", |
| 144 |
regex: "0[xX][0-9a-fA-F_]+(l|ul|u|f|F|L|U|UL)?\\b" |
| 145 |
}, { |
| 146 |
token: "constant.numeric", |
| 147 |
regex: "[+-]?\\d[\\d_]*(?:(?:\\.[\\d_]*)?(?:[eE][+-]?[\\d_]+)?)?(l|ul|u|f|F|L|U|UL)?\\b" |
| 148 |
}, { |
| 149 |
token: "entity.other.attribute-name", |
| 150 |
regex: "@" + identifierRe |
| 151 |
}, { |
| 152 |
token: keywordMapper, |
| 153 |
regex: "[a-zA-Z_][a-zA-Z0-9_]*\\b" |
| 154 |
}, { |
| 155 |
token: "keyword.operator", |
| 156 |
regex: operators |
| 157 |
}, { |
| 158 |
token: "punctuation.operator", |
| 159 |
regex: "\\?|\\:|\\,|\\;|\\.|\\:" |
| 160 |
}, { |
| 161 |
token: "paren.lparen", |
| 162 |
regex: "[[({]" |
| 163 |
}, { |
| 164 |
token: "paren.rparen", |
| 165 |
regex: "[\\])}]" |
| 166 |
}, { |
| 167 |
token: "text", |
| 168 |
regex: "\\s+" |
| 169 |
} |
| 170 |
], |
| 171 |
"star-comment": [ |
| 172 |
{ |
| 173 |
token: "comment", |
| 174 |
regex: "\\*\\/", |
| 175 |
next: "start" |
| 176 |
}, { |
| 177 |
defaultToken: 'comment' |
| 178 |
} |
| 179 |
], |
| 180 |
"plus-comment": [ |
| 181 |
{ |
| 182 |
token: "comment", |
| 183 |
regex: "\\+\\/", |
| 184 |
next: "start" |
| 185 |
}, { |
| 186 |
defaultToken: 'comment' |
| 187 |
} |
| 188 |
], |
| 189 |
"quote-string": [ |
| 190 |
stringEscapesSeq, |
| 191 |
{ |
| 192 |
token: "string", |
| 193 |
regex: '"[cdw]?', |
| 194 |
next: "start" |
| 195 |
}, { |
| 196 |
defaultToken: 'string' |
| 197 |
} |
| 198 |
], |
| 199 |
"backtick-string": [ |
| 200 |
stringEscapesSeq, |
| 201 |
{ |
| 202 |
token: "string", |
| 203 |
regex: '`[cdw]?', |
| 204 |
next: "start" |
| 205 |
}, { |
| 206 |
defaultToken: 'string' |
| 207 |
} |
| 208 |
], |
| 209 |
"operator-heredoc-string": [ |
| 210 |
{ |
| 211 |
onMatch: function (value, currentState, state) { |
| 212 |
value = value.substring(value.length - 2, value.length - 1); |
| 213 |
var map = { '>': '<', ']': '[', ')': '(', '}': '{' }; |
| 214 |
if (Object.keys(map).indexOf(value) != -1) |
| 215 |
value = map[value]; |
| 216 |
if (value != state[1]) |
| 217 |
return "string"; |
| 218 |
state.shift(); |
| 219 |
state.shift(); |
| 220 |
return "string"; |
| 221 |
}, |
| 222 |
regex: '(?:[\\]\\)}>]+)"', |
| 223 |
next: 'start' |
| 224 |
}, { |
| 225 |
token: 'string', |
| 226 |
regex: '[^\\]\\)}>]+' |
| 227 |
} |
| 228 |
], |
| 229 |
"identifier-heredoc-string": [ |
| 230 |
{ |
| 231 |
onMatch: function (value, currentState, state) { |
| 232 |
value = value.substring(0, value.length - 1); |
| 233 |
if (value != state[1]) |
| 234 |
return "string"; |
| 235 |
state.shift(); |
| 236 |
state.shift(); |
| 237 |
return "string"; |
| 238 |
}, |
| 239 |
regex: '^(?:[A-Za-z_][a-zA-Z0-9]+)"', |
| 240 |
next: 'start' |
| 241 |
}, { |
| 242 |
token: 'string', |
| 243 |
regex: '[^\\]\\)}>]+' |
| 244 |
} |
| 245 |
], |
| 246 |
"d-asm": [ |
| 247 |
{ |
| 248 |
token: "paren.rparen", |
| 249 |
regex: "\\}", |
| 250 |
next: "start" |
| 251 |
}, { |
| 252 |
token: 'keyword.instruction', |
| 253 |
regex: '[a-zA-Z]+', |
| 254 |
next: 'd-asm-instruction' |
| 255 |
}, { |
| 256 |
token: "text", |
| 257 |
regex: "\\s+" |
| 258 |
} |
| 259 |
], |
| 260 |
'd-asm-instruction': [ |
| 261 |
{ |
| 262 |
token: 'constant.language', |
| 263 |
regex: /AL|AH|AX|EAX|BL|BH|BX|EBX|CL|CH|CX|ECX|DL|DH|DX|EDX|BP|EBP|SP|ESP|DI|EDI|SI|ESI/i |
| 264 |
}, { |
| 265 |
token: 'identifier', |
| 266 |
regex: '[a-zA-Z]+' |
| 267 |
}, { |
| 268 |
token: 'string', |
| 269 |
regex: '"[^"]*"' |
| 270 |
}, { |
| 271 |
token: 'comment', |
| 272 |
regex: '//.*$' |
| 273 |
}, { |
| 274 |
token: 'constant.numeric', |
| 275 |
regex: '[0-9.xA-F]+' |
| 276 |
}, { |
| 277 |
token: 'punctuation.operator', |
| 278 |
regex: '\\,' |
| 279 |
}, { |
| 280 |
token: 'punctuation.operator', |
| 281 |
regex: ';', |
| 282 |
next: 'd-asm' |
| 283 |
}, { |
| 284 |
token: 'text', |
| 285 |
regex: '\\s+' |
| 286 |
} |
| 287 |
] |
| 288 |
}; |
| 289 |
this.embedRules(DocCommentHighlightRules, "doc-", [DocCommentHighlightRules.getEndRule("start")]); |
| 290 |
}; |
| 291 |
DHighlightRules.metaData = { |
| 292 |
comment: 'D language', |
| 293 |
fileTypes: ['d', 'di'], |
| 294 |
firstLineMatch: '^#!.*\\b[glr]?dmd\\b.', |
| 295 |
foldingStartMarker: '(?x)/\\*\\*(?!\\*)|^(?![^{]*?//|[^{]*?/\\*(?!.*?\\*/.*?\\{)).*?\\{\\s*($|//|/\\*(?!.*?\\*/.*\\S))', |
| 296 |
foldingStopMarker: '(?<!\\*)\\*\\*/|^\\s*\\}', |
| 297 |
keyEquivalent: '^~D', |
| 298 |
name: 'D', |
| 299 |
scopeName: 'source.d' |
| 300 |
}; |
| 301 |
oop.inherits(DHighlightRules, TextHighlightRules); |
| 302 |
exports.DHighlightRules = DHighlightRules; |
| 303 |
|
| 304 |
}); |
| 305 |
|
| 306 |
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"; |
| 307 |
var oop = require("../../lib/oop"); |
| 308 |
var Range = require("../../range").Range; |
| 309 |
var BaseFoldMode = require("./fold_mode").FoldMode; |
| 310 |
var FoldMode = exports.FoldMode = function (commentRegex) { |
| 311 |
if (commentRegex) { |
| 312 |
this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)); |
| 313 |
this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)); |
| 314 |
} |
| 315 |
}; |
| 316 |
oop.inherits(FoldMode, BaseFoldMode); |
| 317 |
(function () { |
| 318 |
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/; |
| 319 |
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/; |
| 320 |
this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/; |
| 321 |
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; |
| 322 |
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; |
| 323 |
this._getFoldWidgetBase = this.getFoldWidget; |
| 324 |
this.getFoldWidget = function (session, foldStyle, row) { |
| 325 |
var line = session.getLine(row); |
| 326 |
if (this.singleLineBlockCommentRe.test(line)) { |
| 327 |
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) |
| 328 |
return ""; |
| 329 |
} |
| 330 |
var fw = this._getFoldWidgetBase(session, foldStyle, row); |
| 331 |
if (!fw && this.startRegionRe.test(line)) |
| 332 |
return "start"; |
| 333 |
return fw; |
| 334 |
}; |
| 335 |
this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) { |
| 336 |
var line = session.getLine(row); |
| 337 |
if (this.startRegionRe.test(line)) |
| 338 |
return this.getCommentRegionBlock(session, line, row); |
| 339 |
var match = line.match(this.foldingStartMarker); |
| 340 |
if (match) { |
| 341 |
var i = match.index; |
| 342 |
if (match[1]) |
| 343 |
return this.openingBracketBlock(session, match[1], row, i); |
| 344 |
var range = session.getCommentFoldRange(row, i + match[0].length, 1); |
| 345 |
if (range && !range.isMultiLine()) { |
| 346 |
if (forceMultiline) { |
| 347 |
range = this.getSectionRange(session, row); |
| 348 |
} |
| 349 |
else if (foldStyle != "all") |
| 350 |
range = null; |
| 351 |
} |
| 352 |
return range; |
| 353 |
} |
| 354 |
if (foldStyle === "markbegin") |
| 355 |
return; |
| 356 |
var match = line.match(this.foldingStopMarker); |
| 357 |
if (match) { |
| 358 |
var i = match.index + match[0].length; |
| 359 |
if (match[1]) |
| 360 |
return this.closingBracketBlock(session, match[1], row, i); |
| 361 |
return session.getCommentFoldRange(row, i, -1); |
| 362 |
} |
| 363 |
}; |
| 364 |
this.getSectionRange = function (session, row) { |
| 365 |
var line = session.getLine(row); |
| 366 |
var startIndent = line.search(/\S/); |
| 367 |
var startRow = row; |
| 368 |
var startColumn = line.length; |
| 369 |
row = row + 1; |
| 370 |
var endRow = row; |
| 371 |
var maxRow = session.getLength(); |
| 372 |
while (++row < maxRow) { |
| 373 |
line = session.getLine(row); |
| 374 |
var indent = line.search(/\S/); |
| 375 |
if (indent === -1) |
| 376 |
continue; |
| 377 |
if (startIndent > indent) |
| 378 |
break; |
| 379 |
var subRange = this.getFoldWidgetRange(session, "all", row); |
| 380 |
if (subRange) { |
| 381 |
if (subRange.start.row <= startRow) { |
| 382 |
break; |
| 383 |
} |
| 384 |
else if (subRange.isMultiLine()) { |
| 385 |
row = subRange.end.row; |
| 386 |
} |
| 387 |
else if (startIndent == indent) { |
| 388 |
break; |
| 389 |
} |
| 390 |
} |
| 391 |
endRow = row; |
| 392 |
} |
| 393 |
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); |
| 394 |
}; |
| 395 |
this.getCommentRegionBlock = function (session, line, row) { |
| 396 |
var startColumn = line.search(/\s*$/); |
| 397 |
var maxRow = session.getLength(); |
| 398 |
var startRow = row; |
| 399 |
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; |
| 400 |
var depth = 1; |
| 401 |
while (++row < maxRow) { |
| 402 |
line = session.getLine(row); |
| 403 |
var m = re.exec(line); |
| 404 |
if (!m) |
| 405 |
continue; |
| 406 |
if (m[1]) |
| 407 |
depth--; |
| 408 |
else |
| 409 |
depth++; |
| 410 |
if (!depth) |
| 411 |
break; |
| 412 |
} |
| 413 |
var endRow = row; |
| 414 |
if (endRow > startRow) { |
| 415 |
return new Range(startRow, startColumn, endRow, line.length); |
| 416 |
} |
| 417 |
}; |
| 418 |
}).call(FoldMode.prototype); |
| 419 |
|
| 420 |
}); |
| 421 |
|
| 422 |
ace.define("ace/mode/d",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/d_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){ |
| 423 |
|
| 424 |
|
| 425 |
"use strict"; |
| 426 |
var oop = require("../lib/oop"); |
| 427 |
var TextMode = require("./text").Mode; |
| 428 |
var DHighlightRules = require("./d_highlight_rules").DHighlightRules; |
| 429 |
var FoldMode = require("./folding/cstyle").FoldMode; |
| 430 |
var Mode = function () { |
| 431 |
this.HighlightRules = DHighlightRules; |
| 432 |
this.foldingRules = new FoldMode(); |
| 433 |
this.$behaviour = this.$defaultBehaviour; |
| 434 |
}; |
| 435 |
oop.inherits(Mode, TextMode); |
| 436 |
(function () { |
| 437 |
this.lineCommentStart = "//"; |
| 438 |
this.blockComment = { start: "/*", end: "*/" }; |
| 439 |
this.$id = "ace/mode/d"; |
| 440 |
}).call(Mode.prototype); |
| 441 |
exports.Mode = Mode; |
| 442 |
|
| 443 |
}); (function() { |
| 444 |
ace.require(["ace/mode/d"], function(m) { |
| 445 |
if (typeof module == "object" && typeof exports == "object" && module) { |
| 446 |
module.exports = m; |
| 447 |
} |
| 448 |
}); |
| 449 |
})(); |
| 450 |
|