1
|
ace.define("ace/mode/batchfile_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 BatchFileHighlightRules = function() {
|
8
|
|
9
|
this.$rules = { start:
|
10
|
[ { token: 'keyword.command.dosbatch',
|
11
|
regex: '\\b(?:append|assoc|at|attrib|break|cacls|cd|chcp|chdir|chkdsk|chkntfs|cls|cmd|color|comp|compact|convert|copy|date|del|dir|diskcomp|diskcopy|doskey|echo|endlocal|erase|fc|find|findstr|format|ftype|graftabl|help|keyb|label|md|mkdir|mode|more|move|path|pause|popd|print|prompt|pushd|rd|recover|ren|rename|replace|restore|rmdir|set|setlocal|shift|sort|start|subst|time|title|tree|type|ver|verify|vol|xcopy)\\b',
|
12
|
caseInsensitive: true },
|
13
|
{ token: 'keyword.control.statement.dosbatch',
|
14
|
regex: '\\b(?:goto|call|exit)\\b',
|
15
|
caseInsensitive: true },
|
16
|
{ token: 'keyword.control.conditional.if.dosbatch',
|
17
|
regex: '\\bif\\s+not\\s+(?:exist|defined|errorlevel|cmdextversion)\\b',
|
18
|
caseInsensitive: true },
|
19
|
{ token: 'keyword.control.conditional.dosbatch',
|
20
|
regex: '\\b(?:if|else)\\b',
|
21
|
caseInsensitive: true },
|
22
|
{ token: 'keyword.control.repeat.dosbatch',
|
23
|
regex: '\\bfor\\b',
|
24
|
caseInsensitive: true },
|
25
|
{ token: 'keyword.operator.dosbatch',
|
26
|
regex: '\\b(?:EQU|NEQ|LSS|LEQ|GTR|GEQ)\\b' },
|
27
|
{ token: ['doc.comment', 'comment'],
|
28
|
regex: '(?:^|\\b)(rem)($|\\s.*$)',
|
29
|
caseInsensitive: true },
|
30
|
{ token: 'comment.line.colons.dosbatch',
|
31
|
regex: '::.*$' },
|
32
|
{ include: 'variable' },
|
33
|
{ token: 'punctuation.definition.string.begin.shell',
|
34
|
regex: '"',
|
35
|
push: [
|
36
|
{ token: 'punctuation.definition.string.end.shell', regex: '"', next: 'pop' },
|
37
|
{ include: 'variable' },
|
38
|
{ defaultToken: 'string.quoted.double.dosbatch' } ] },
|
39
|
{ token: 'keyword.operator.pipe.dosbatch', regex: '[|]' },
|
40
|
{ token: 'keyword.operator.redirect.shell',
|
41
|
regex: '&>|\\d*>&\\d*|\\d*(?:>>|>|<)|\\d*<&|\\d*<>' } ],
|
42
|
variable: [
|
43
|
{ token: 'constant.numeric', regex: '%%\\w+|%[*\\d]|%\\w+%'},
|
44
|
{ token: 'constant.numeric', regex: '%~\\d+'},
|
45
|
{ token: ['markup.list', 'constant.other', 'markup.list'],
|
46
|
regex: '(%)(\\w+)(%?)' }]};
|
47
|
|
48
|
this.normalizeRules();
|
49
|
};
|
50
|
|
51
|
BatchFileHighlightRules.metaData = { name: 'Batch File',
|
52
|
scopeName: 'source.dosbatch',
|
53
|
fileTypes: [ 'bat' ] };
|
54
|
|
55
|
|
56
|
oop.inherits(BatchFileHighlightRules, TextHighlightRules);
|
57
|
|
58
|
exports.BatchFileHighlightRules = BatchFileHighlightRules;
|
59
|
});
|
60
|
|
61
|
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
62
|
"use strict";
|
63
|
|
64
|
var oop = require("../../lib/oop");
|
65
|
var Range = require("../../range").Range;
|
66
|
var BaseFoldMode = require("./fold_mode").FoldMode;
|
67
|
|
68
|
var FoldMode = exports.FoldMode = function(commentRegex) {
|
69
|
if (commentRegex) {
|
70
|
this.foldingStartMarker = new RegExp(
|
71
|
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
72
|
);
|
73
|
this.foldingStopMarker = new RegExp(
|
74
|
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
75
|
);
|
76
|
}
|
77
|
};
|
78
|
oop.inherits(FoldMode, BaseFoldMode);
|
79
|
|
80
|
(function() {
|
81
|
|
82
|
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
83
|
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
84
|
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
85
|
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
86
|
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
87
|
this._getFoldWidgetBase = this.getFoldWidget;
|
88
|
this.getFoldWidget = function(session, foldStyle, row) {
|
89
|
var line = session.getLine(row);
|
90
|
|
91
|
if (this.singleLineBlockCommentRe.test(line)) {
|
92
|
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
93
|
return "";
|
94
|
}
|
95
|
|
96
|
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
97
|
|
98
|
if (!fw && this.startRegionRe.test(line))
|
99
|
return "start"; // lineCommentRegionStart
|
100
|
|
101
|
return fw;
|
102
|
};
|
103
|
|
104
|
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
105
|
var line = session.getLine(row);
|
106
|
|
107
|
if (this.startRegionRe.test(line))
|
108
|
return this.getCommentRegionBlock(session, line, row);
|
109
|
|
110
|
var match = line.match(this.foldingStartMarker);
|
111
|
if (match) {
|
112
|
var i = match.index;
|
113
|
|
114
|
if (match[1])
|
115
|
return this.openingBracketBlock(session, match[1], row, i);
|
116
|
|
117
|
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
118
|
|
119
|
if (range && !range.isMultiLine()) {
|
120
|
if (forceMultiline) {
|
121
|
range = this.getSectionRange(session, row);
|
122
|
} else if (foldStyle != "all")
|
123
|
range = null;
|
124
|
}
|
125
|
|
126
|
return range;
|
127
|
}
|
128
|
|
129
|
if (foldStyle === "markbegin")
|
130
|
return;
|
131
|
|
132
|
var match = line.match(this.foldingStopMarker);
|
133
|
if (match) {
|
134
|
var i = match.index + match[0].length;
|
135
|
|
136
|
if (match[1])
|
137
|
return this.closingBracketBlock(session, match[1], row, i);
|
138
|
|
139
|
return session.getCommentFoldRange(row, i, -1);
|
140
|
}
|
141
|
};
|
142
|
|
143
|
this.getSectionRange = function(session, row) {
|
144
|
var line = session.getLine(row);
|
145
|
var startIndent = line.search(/\S/);
|
146
|
var startRow = row;
|
147
|
var startColumn = line.length;
|
148
|
row = row + 1;
|
149
|
var endRow = row;
|
150
|
var maxRow = session.getLength();
|
151
|
while (++row < maxRow) {
|
152
|
line = session.getLine(row);
|
153
|
var indent = line.search(/\S/);
|
154
|
if (indent === -1)
|
155
|
continue;
|
156
|
if (startIndent > indent)
|
157
|
break;
|
158
|
var subRange = this.getFoldWidgetRange(session, "all", row);
|
159
|
|
160
|
if (subRange) {
|
161
|
if (subRange.start.row <= startRow) {
|
162
|
break;
|
163
|
} else if (subRange.isMultiLine()) {
|
164
|
row = subRange.end.row;
|
165
|
} else if (startIndent == indent) {
|
166
|
break;
|
167
|
}
|
168
|
}
|
169
|
endRow = row;
|
170
|
}
|
171
|
|
172
|
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
173
|
};
|
174
|
this.getCommentRegionBlock = function(session, line, row) {
|
175
|
var startColumn = line.search(/\s*$/);
|
176
|
var maxRow = session.getLength();
|
177
|
var startRow = row;
|
178
|
|
179
|
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
180
|
var depth = 1;
|
181
|
while (++row < maxRow) {
|
182
|
line = session.getLine(row);
|
183
|
var m = re.exec(line);
|
184
|
if (!m) continue;
|
185
|
if (m[1]) depth--;
|
186
|
else depth++;
|
187
|
|
188
|
if (!depth) break;
|
189
|
}
|
190
|
|
191
|
var endRow = row;
|
192
|
if (endRow > startRow) {
|
193
|
return new Range(startRow, startColumn, endRow, line.length);
|
194
|
}
|
195
|
};
|
196
|
|
197
|
}).call(FoldMode.prototype);
|
198
|
|
199
|
});
|
200
|
|
201
|
ace.define("ace/mode/batchfile",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/batchfile_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module) {
|
202
|
"use strict";
|
203
|
|
204
|
var oop = require("../lib/oop");
|
205
|
var TextMode = require("./text").Mode;
|
206
|
var BatchFileHighlightRules = require("./batchfile_highlight_rules").BatchFileHighlightRules;
|
207
|
var FoldMode = require("./folding/cstyle").FoldMode;
|
208
|
|
209
|
var Mode = function() {
|
210
|
this.HighlightRules = BatchFileHighlightRules;
|
211
|
this.foldingRules = new FoldMode();
|
212
|
this.$behaviour = this.$defaultBehaviour;
|
213
|
};
|
214
|
oop.inherits(Mode, TextMode);
|
215
|
|
216
|
(function() {
|
217
|
this.lineCommentStart = "::";
|
218
|
this.blockComment = "";
|
219
|
this.$id = "ace/mode/batchfile";
|
220
|
}).call(Mode.prototype);
|
221
|
|
222
|
exports.Mode = Mode;
|
223
|
}); (function() {
|
224
|
ace.require(["ace/mode/batchfile"], function(m) {
|
225
|
if (typeof module == "object" && typeof exports == "object" && module) {
|
226
|
module.exports = m;
|
227
|
}
|
228
|
});
|
229
|
})();
|
230
|
|