1
/* ***** BEGIN LICENSE BLOCK *****
2
* Distributed under the BSD license:
4
* Copyright (c) 2012, Ajax.org B.V.
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are met:
9
* * Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
* * Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
14
* * Neither the name of Ajax.org B.V. nor the
15
* names of its contributors may be used to endorse or promote products
16
* derived from this software without specific prior written permission.
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
22
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
* ***** END LICENSE BLOCK ***** */
36
define('ace/mode/makefile', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/makefile_highlight_rules', 'ace/mode/folding/coffee'], function(require, exports, module) {
39
var oop = require("../lib/oop");
40
var TextMode = require("./text").Mode;
41
var Tokenizer = require("../tokenizer").Tokenizer;
42
var MakefileHighlightRules = require("./makefile_highlight_rules").MakefileHighlightRules;
43
var FoldMode = require("./folding/coffee").FoldMode;
45
var Mode = function() {
46
var highlighter = new MakefileHighlightRules();
47
this.foldingRules = new FoldMode();
49
this.$tokenizer = new Tokenizer(highlighter.getRules());
51
oop.inherits(Mode, TextMode);
55
this.lineCommentStart = "#";
56
}).call(Mode.prototype);
59
});define('ace/mode/makefile_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules', 'ace/mode/sh_highlight_rules'], function(require, exports, module) {
62
var oop = require("../lib/oop");
63
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
65
var ShHighlightFile = require("./sh_highlight_rules");
67
var MakefileHighlightRules = function() {
69
var keywordMapper = this.createKeywordMapper({
70
"keyword": ShHighlightFile.reservedKeywords,
71
"support.function.builtin": ShHighlightFile.languageConstructs,
72
"invalid.deprecated": "debugger"
79
token: "string.interpolated.backtick.makefile",
84
token: "punctuation.definition.comment.makefile",
89
token: [ "keyword.control.makefile"],
90
regex: "^(?:\\s*\\b)(\\-??include|ifeq|ifneq|ifdef|ifndef|else|endif|vpath|export|unexport|define|endef|override)(?:\\b)"
92
{// ^([^\t ]+(\s[^\t ]+)*:(?!\=))\s*.*
93
token: ["entity.name.function.makefile", "text"],
94
regex: "^([^\\t ]+(?:\\s[^\\t ]+)*:)(\\s*.*)"
99
token : "punctuation.definition.comment.makefile",
103
token : "punctuation.definition.comment.makefile",
110
token: keywordMapper,
111
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
118
token : "string.interpolated.backtick.makefile",
127
oop.inherits(MakefileHighlightRules, TextHighlightRules);
129
exports.MakefileHighlightRules = MakefileHighlightRules;
132
define('ace/mode/sh_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
135
var oop = require("../lib/oop");
136
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
138
var reservedKeywords = exports.reservedKeywords = (
139
'!|{|}|case|do|done|elif|else|'+
140
'esac|fi|for|if|in|then|until|while|'+
141
'&|;|export|local|read|typeset|unset|'+
145
var languageConstructs = exports.languageConstructs = (
146
'[|]|alias|bg|bind|break|builtin|'+
147
'cd|command|compgen|complete|continue|'+
148
'dirs|disown|echo|enable|eval|exec|'+
149
'exit|fc|fg|getopts|hash|help|history|'+
150
'jobs|kill|let|logout|popd|printf|pushd|'+
151
'pwd|return|set|shift|shopt|source|'+
152
'suspend|test|times|trap|type|ulimit|'+
156
var ShHighlightRules = function() {
157
var keywordMapper = this.createKeywordMapper({
158
"keyword": reservedKeywords,
159
"support.function.builtin": languageConstructs,
160
"invalid.deprecated": "debugger"
163
var integer = "(?:(?:[1-9]\\d*)|(?:0))";
165
var fraction = "(?:\\.\\d+)";
166
var intPart = "(?:\\d+)";
167
var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))";
168
var exponentFloat = "(?:(?:" + pointFloat + "|" + intPart + ")" + ")";
169
var floatNumber = "(?:" + exponentFloat + "|" + pointFloat + ")";
170
var fileDescriptor = "(?:&" + intPart + ")";
172
var variableName = "[a-zA-Z][a-zA-Z0-9_]*";
173
var variable = "(?:(?:\\$" + variableName + ")|(?:" + variableName + "=))";
175
var builtinVariable = "(?:\\$(?:SHLVL|\\$|\\!|\\?))";
177
var func = "(?:" + variableName + "\\s*\\(\\))";
181
token : ["text", "comment"],
182
regex : /(^|\s)(#.*)$/
184
token : "string", // " string
185
regex : '"(?:[^\\\\]|\\\\.)*?"'
187
token : "variable.language",
188
regex : builtinVariable
193
token : "support.function",
196
token : "support.function",
197
regex : fileDescriptor
199
token : "string", // ' string
200
regex : "'(?:[^\\\\]|\\\\.)*?'"
202
token : "constant.numeric", // float
205
token : "constant.numeric", // integer
206
regex : integer + "\\b"
208
token : keywordMapper,
209
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
211
token : "keyword.operator",
212
regex : "\\+|\\-|\\*|\\*\\*|\\/|\\/\\/|~|<|>|<=|=>|=|!="
214
token : "paren.lparen",
215
regex : "[\\[\\(\\{]"
217
token : "paren.rparen",
218
regex : "[\\]\\)\\}]"
223
oop.inherits(ShHighlightRules, TextHighlightRules);
225
exports.ShHighlightRules = ShHighlightRules;
228
define('ace/mode/folding/coffee', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode', 'ace/range'], function(require, exports, module) {
231
var oop = require("../../lib/oop");
232
var BaseFoldMode = require("./fold_mode").FoldMode;
233
var Range = require("../../range").Range;
235
var FoldMode = exports.FoldMode = function() {};
236
oop.inherits(FoldMode, BaseFoldMode);
240
this.getFoldWidgetRange = function(session, foldStyle, row) {
241
var range = this.indentationBlock(session, row);
246
var line = session.getLine(row);
247
var startLevel = line.search(re);
248
if (startLevel == -1 || line[startLevel] != "#")
251
var startColumn = line.length;
252
var maxRow = session.getLength();
256
while (++row < maxRow) {
257
line = session.getLine(row);
258
var level = line.search(re);
263
if (line[level] != "#")
269
if (endRow > startRow) {
270
var endColumn = session.getLine(endRow).length;
271
return new Range(startRow, startColumn, endRow, endColumn);
274
this.getFoldWidget = function(session, foldStyle, row) {
275
var line = session.getLine(row);
276
var indent = line.search(/\S/);
277
var next = session.getLine(row + 1);
278
var prev = session.getLine(row - 1);
279
var prevIndent = prev.search(/\S/);
280
var nextIndent = next.search(/\S/);
283
session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : "";
286
if (prevIndent == -1) {
287
if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
288
session.foldWidgets[row - 1] = "";
289
session.foldWidgets[row + 1] = "";
292
} else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
293
if (session.getLine(row - 2).search(/\S/) == -1) {
294
session.foldWidgets[row - 1] = "start";
295
session.foldWidgets[row + 1] = "";
300
if (prevIndent!= -1 && prevIndent < indent)
301
session.foldWidgets[row - 1] = "start";
303
session.foldWidgets[row - 1] = "";
305
if (indent < nextIndent)
311
}).call(FoldMode.prototype);