| 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 |
var oop = require("../lib/oop"); |
| 4 |
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; |
| 5 |
var BatchFileHighlightRules = function () { |
| 6 |
this.$rules = { start: [{ token: 'keyword.command.dosbatch', |
| 7 |
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', |
| 8 |
caseInsensitive: true }, |
| 9 |
{ token: 'keyword.control.statement.dosbatch', |
| 10 |
regex: '\\b(?:goto|call|exit)\\b', |
| 11 |
caseInsensitive: true }, |
| 12 |
{ token: 'keyword.control.conditional.if.dosbatch', |
| 13 |
regex: '\\bif\\s+not\\s+(?:exist|defined|errorlevel|cmdextversion)\\b', |
| 14 |
caseInsensitive: true }, |
| 15 |
{ token: 'keyword.control.conditional.dosbatch', |
| 16 |
regex: '\\b(?:if|else)\\b', |
| 17 |
caseInsensitive: true }, |
| 18 |
{ token: 'keyword.control.repeat.dosbatch', |
| 19 |
regex: '\\bfor\\b', |
| 20 |
caseInsensitive: true }, |
| 21 |
{ token: 'keyword.operator.dosbatch', |
| 22 |
regex: '\\b(?:EQU|NEQ|LSS|LEQ|GTR|GEQ)\\b' }, |
| 23 |
{ token: ['doc.comment', 'comment'], |
| 24 |
regex: '(?:^|\\b)(rem)($|\\s.*$)', |
| 25 |
caseInsensitive: true }, |
| 26 |
{ token: 'comment.line.colons.dosbatch', |
| 27 |
regex: '::.*$' }, |
| 28 |
{ include: 'variable' }, |
| 29 |
{ token: 'punctuation.definition.string.begin.shell', |
| 30 |
regex: '"', |
| 31 |
push: [ |
| 32 |
{ token: 'punctuation.definition.string.end.shell', regex: '"', next: 'pop' }, |
| 33 |
{ include: 'variable' }, |
| 34 |
{ defaultToken: 'string.quoted.double.dosbatch' } |
| 35 |
] }, |
| 36 |
{ token: 'keyword.operator.pipe.dosbatch', regex: '[|]' }, |
| 37 |
{ token: 'keyword.operator.redirect.shell', |
| 38 |
regex: '&>|\\d*>&\\d*|\\d*(?:>>|>|<)|\\d*<&|\\d*<>' }], |
| 39 |
variable: [ |
| 40 |
{ token: 'constant.numeric', regex: '%%\\w+|%[*\\d]|%\\w+%' }, |
| 41 |
{ token: 'constant.numeric', regex: '%~\\d+' }, |
| 42 |
{ token: ['markup.list', 'constant.other', 'markup.list'], |
| 43 |
regex: '(%)(\\w+)(%?)' } |
| 44 |
] }; |
| 45 |
this.normalizeRules(); |
| 46 |
}; |
| 47 |
BatchFileHighlightRules.metaData = { name: 'Batch File', |
| 48 |
scopeName: 'source.dosbatch', |
| 49 |
fileTypes: ['bat'] }; |
| 50 |
oop.inherits(BatchFileHighlightRules, TextHighlightRules); |
| 51 |
exports.BatchFileHighlightRules = BatchFileHighlightRules; |
| 52 |
|
| 53 |
}); |
| 54 |
|
| 55 |
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"; |
| 56 |
var oop = require("../../lib/oop"); |
| 57 |
var Range = require("../../range").Range; |
| 58 |
var BaseFoldMode = require("./fold_mode").FoldMode; |
| 59 |
var FoldMode = exports.FoldMode = function (commentRegex) { |
| 60 |
if (commentRegex) { |
| 61 |
this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)); |
| 62 |
this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)); |
| 63 |
} |
| 64 |
}; |
| 65 |
oop.inherits(FoldMode, BaseFoldMode); |
| 66 |
(function () { |
| 67 |
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/; |
| 68 |
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/; |
| 69 |
this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/; |
| 70 |
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; |
| 71 |
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; |
| 72 |
this._getFoldWidgetBase = this.getFoldWidget; |
| 73 |
this.getFoldWidget = function (session, foldStyle, row) { |
| 74 |
var line = session.getLine(row); |
| 75 |
if (this.singleLineBlockCommentRe.test(line)) { |
| 76 |
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) |
| 77 |
return ""; |
| 78 |
} |
| 79 |
var fw = this._getFoldWidgetBase(session, foldStyle, row); |
| 80 |
if (!fw && this.startRegionRe.test(line)) |
| 81 |
return "start"; |
| 82 |
return fw; |
| 83 |
}; |
| 84 |
this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) { |
| 85 |
var line = session.getLine(row); |
| 86 |
if (this.startRegionRe.test(line)) |
| 87 |
return this.getCommentRegionBlock(session, line, row); |
| 88 |
var match = line.match(this.foldingStartMarker); |
| 89 |
if (match) { |
| 90 |
var i = match.index; |
| 91 |
if (match[1]) |
| 92 |
return this.openingBracketBlock(session, match[1], row, i); |
| 93 |
var range = session.getCommentFoldRange(row, i + match[0].length, 1); |
| 94 |
if (range && !range.isMultiLine()) { |
| 95 |
if (forceMultiline) { |
| 96 |
range = this.getSectionRange(session, row); |
| 97 |
} |
| 98 |
else if (foldStyle != "all") |
| 99 |
range = null; |
| 100 |
} |
| 101 |
return range; |
| 102 |
} |
| 103 |
if (foldStyle === "markbegin") |
| 104 |
return; |
| 105 |
var match = line.match(this.foldingStopMarker); |
| 106 |
if (match) { |
| 107 |
var i = match.index + match[0].length; |
| 108 |
if (match[1]) |
| 109 |
return this.closingBracketBlock(session, match[1], row, i); |
| 110 |
return session.getCommentFoldRange(row, i, -1); |
| 111 |
} |
| 112 |
}; |
| 113 |
this.getSectionRange = function (session, row) { |
| 114 |
var line = session.getLine(row); |
| 115 |
var startIndent = line.search(/\S/); |
| 116 |
var startRow = row; |
| 117 |
var startColumn = line.length; |
| 118 |
row = row + 1; |
| 119 |
var endRow = row; |
| 120 |
var maxRow = session.getLength(); |
| 121 |
while (++row < maxRow) { |
| 122 |
line = session.getLine(row); |
| 123 |
var indent = line.search(/\S/); |
| 124 |
if (indent === -1) |
| 125 |
continue; |
| 126 |
if (startIndent > indent) |
| 127 |
break; |
| 128 |
var subRange = this.getFoldWidgetRange(session, "all", row); |
| 129 |
if (subRange) { |
| 130 |
if (subRange.start.row <= startRow) { |
| 131 |
break; |
| 132 |
} |
| 133 |
else if (subRange.isMultiLine()) { |
| 134 |
row = subRange.end.row; |
| 135 |
} |
| 136 |
else if (startIndent == indent) { |
| 137 |
break; |
| 138 |
} |
| 139 |
} |
| 140 |
endRow = row; |
| 141 |
} |
| 142 |
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); |
| 143 |
}; |
| 144 |
this.getCommentRegionBlock = function (session, line, row) { |
| 145 |
var startColumn = line.search(/\s*$/); |
| 146 |
var maxRow = session.getLength(); |
| 147 |
var startRow = row; |
| 148 |
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; |
| 149 |
var depth = 1; |
| 150 |
while (++row < maxRow) { |
| 151 |
line = session.getLine(row); |
| 152 |
var m = re.exec(line); |
| 153 |
if (!m) |
| 154 |
continue; |
| 155 |
if (m[1]) |
| 156 |
depth--; |
| 157 |
else |
| 158 |
depth++; |
| 159 |
if (!depth) |
| 160 |
break; |
| 161 |
} |
| 162 |
var endRow = row; |
| 163 |
if (endRow > startRow) { |
| 164 |
return new Range(startRow, startColumn, endRow, line.length); |
| 165 |
} |
| 166 |
}; |
| 167 |
}).call(FoldMode.prototype); |
| 168 |
|
| 169 |
}); |
| 170 |
|
| 171 |
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){ |
| 172 |
|
| 173 |
|
| 174 |
"use strict"; |
| 175 |
var oop = require("../lib/oop"); |
| 176 |
var TextMode = require("./text").Mode; |
| 177 |
var BatchFileHighlightRules = require("./batchfile_highlight_rules").BatchFileHighlightRules; |
| 178 |
var FoldMode = require("./folding/cstyle").FoldMode; |
| 179 |
var Mode = function () { |
| 180 |
this.HighlightRules = BatchFileHighlightRules; |
| 181 |
this.foldingRules = new FoldMode(); |
| 182 |
this.$behaviour = this.$defaultBehaviour; |
| 183 |
}; |
| 184 |
oop.inherits(Mode, TextMode); |
| 185 |
(function () { |
| 186 |
this.lineCommentStart = "::"; |
| 187 |
this.blockComment = ""; |
| 188 |
this.$id = "ace/mode/batchfile"; |
| 189 |
}).call(Mode.prototype); |
| 190 |
exports.Mode = Mode; |
| 191 |
|
| 192 |
}); (function() { |
| 193 |
ace.require(["ace/mode/batchfile"], function(m) { |
| 194 |
if (typeof module == "object" && typeof exports == "object" && module) { |
| 195 |
module.exports = m; |
| 196 |
} |
| 197 |
}); |
| 198 |
})(); |
| 199 |
|