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