Projekt

Obecné

Profil

Stáhnout (13.2 KB) Statistiky
| Větev: | Tag: | Revize:
1
ace.define("ace/mode/sh_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 reservedKeywords = exports.reservedKeywords = (
8
        '!|{|}|case|do|done|elif|else|'+
9
        'esac|fi|for|if|in|then|until|while|'+
10
        '&|;|export|local|read|typeset|unset|'+
11
        'elif|select|set|function|declare|readonly'
12
    );
13

    
14
var languageConstructs = exports.languageConstructs = (
15
    '[|]|alias|bg|bind|break|builtin|'+
16
     'cd|command|compgen|complete|continue|'+
17
     'dirs|disown|echo|enable|eval|exec|'+
18
     'exit|fc|fg|getopts|hash|help|history|'+
19
     'jobs|kill|let|logout|popd|printf|pushd|'+
20
     'pwd|return|set|shift|shopt|source|'+
21
     'suspend|test|times|trap|type|ulimit|'+
22
     'umask|unalias|wait'
23
);
24

    
25
var ShHighlightRules = function() {
26
    var keywordMapper = this.createKeywordMapper({
27
        "keyword": reservedKeywords,
28
        "support.function.builtin": languageConstructs,
29
        "invalid.deprecated": "debugger"
30
    }, "identifier");
31

    
32
    var integer = "(?:(?:[1-9]\\d*)|(?:0))";
33

    
34
    var fraction = "(?:\\.\\d+)";
35
    var intPart = "(?:\\d+)";
36
    var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))";
37
    var exponentFloat = "(?:(?:" + pointFloat + "|" +  intPart + ")" + ")";
38
    var floatNumber = "(?:" + exponentFloat + "|" + pointFloat + ")";
39
    var fileDescriptor = "(?:&" + intPart + ")";
40

    
41
    var variableName = "[a-zA-Z_][a-zA-Z0-9_]*";
42
    var variable = "(?:" + variableName + "(?==))";
43

    
44
    var builtinVariable = "(?:\\$(?:SHLVL|\\$|\\!|\\?))";
45

    
46
    var func = "(?:" + variableName + "\\s*\\(\\))";
47

    
48
    this.$rules = {
49
        "start" : [{
50
            token : "constant",
51
            regex : /\\./
52
        }, {
53
            token : ["text", "comment"],
54
            regex : /(^|\s)(#.*)$/
55
        }, {
56
            token : "string.start",
57
            regex : '"',
58
            push : [{
59
                token : "constant.language.escape",
60
                regex : /\\(?:[$`"\\]|$)/
61
            }, {
62
                include : "variables"
63
            }, {
64
                token : "keyword.operator",
65
                regex : /`/ // TODO highlight `
66
            }, {
67
                token : "string.end",
68
                regex : '"',
69
                next: "pop"
70
            }, {
71
                defaultToken: "string"
72
            }]
73
        }, {
74
            token : "string",
75
            regex : "\\$'",
76
            push : [{
77
                token : "constant.language.escape",
78
                regex : /\\(?:[abeEfnrtv\\'"]|x[a-fA-F\d]{1,2}|u[a-fA-F\d]{4}([a-fA-F\d]{4})?|c.|\d{1,3})/
79
            }, {
80
                token : "string",
81
                regex : "'",
82
                next: "pop"
83
            }, {
84
                defaultToken: "string"
85
            }]
86
        }, {
87
            regex : "<<<",
88
            token : "keyword.operator"
89
        }, {
90
            stateName: "heredoc",
91
            regex : "(<<-?)(\\s*)(['\"`]?)([\\w\\-]+)(['\"`]?)",
92
            onMatch : function(value, currentState, stack) {
93
                var next = value[2] == '-' ? "indentedHeredoc" : "heredoc";
94
                var tokens = value.split(this.splitRegex);
95
                stack.push(next, tokens[4]);
96
                return [
97
                    {type:"constant", value: tokens[1]},
98
                    {type:"text", value: tokens[2]},
99
                    {type:"string", value: tokens[3]},
100
                    {type:"support.class", value: tokens[4]},
101
                    {type:"string", value: tokens[5]}
102
                ];
103
            },
104
            rules: {
105
                heredoc: [{
106
                    onMatch:  function(value, currentState, stack) {
107
                        if (value === stack[1]) {
108
                            stack.shift();
109
                            stack.shift();
110
                            this.next = stack[0] || "start";
111
                            return "support.class";
112
                        }
113
                        this.next = "";
114
                        return "string";
115
                    },
116
                    regex: ".*$",
117
                    next: "start"
118
                }],
119
                indentedHeredoc: [{
120
                    token: "string",
121
                    regex: "^\t+"
122
                }, {
123
                    onMatch:  function(value, currentState, stack) {
124
                        if (value === stack[1]) {
125
                            stack.shift();
126
                            stack.shift();
127
                            this.next = stack[0] || "start";
128
                            return "support.class";
129
                        }
130
                        this.next = "";
131
                        return "string";
132
                    },
133
                    regex: ".*$",
134
                    next: "start"
135
                }]
136
            }
137
        }, {
138
            regex : "$",
139
            token : "empty",
140
            next : function(currentState, stack) {
141
                if (stack[0] === "heredoc" || stack[0] === "indentedHeredoc")
142
                    return stack[0];
143
                return currentState;
144
            }
145
        }, {
146
            token : ["keyword", "text", "text", "text", "variable"],
147
            regex : /(declare|local|readonly)(\s+)(?:(-[fixar]+)(\s+))?([a-zA-Z_][a-zA-Z0-9_]*\b)/
148
        }, {
149
            token : "variable.language",
150
            regex : builtinVariable
151
        }, {
152
            token : "variable",
153
            regex : variable
154
        }, {
155
            include : "variables"
156
        }, {
157
            token : "support.function",
158
            regex : func
159
        }, {
160
            token : "support.function",
161
            regex : fileDescriptor
162
        }, {
163
            token : "string",           // ' string
164
            start : "'", end : "'"
165
        }, {
166
            token : "constant.numeric", // float
167
            regex : floatNumber
168
        }, {
169
            token : "constant.numeric", // integer
170
            regex : integer + "\\b"
171
        }, {
172
            token : keywordMapper,
173
            regex : "[a-zA-Z_][a-zA-Z0-9_]*\\b"
174
        }, {
175
            token : "keyword.operator",
176
            regex : "\\+|\\-|\\*|\\*\\*|\\/|\\/\\/|~|<|>|<=|=>|=|!=|[%&|`]"
177
        }, {
178
            token : "punctuation.operator",
179
            regex : ";"
180
        }, {
181
            token : "paren.lparen",
182
            regex : "[\\[\\(\\{]"
183
        }, {
184
            token : "paren.rparen",
185
            regex : "[\\]]"
186
        }, {
187
            token : "paren.rparen",
188
            regex : "[\\)\\}]",
189
            next : "pop"
190
        }],
191
        variables: [{
192
            token : "variable",
193
            regex : /(\$)(\w+)/
194
        }, {
195
            token : ["variable", "paren.lparen"],
196
            regex : /(\$)(\()/,
197
            push : "start"
198
        }, {
199
            token : ["variable", "paren.lparen", "keyword.operator", "variable", "keyword.operator"],
200
            regex : /(\$)(\{)([#!]?)(\w+|[*@#?\-$!0_])(:[?+\-=]?|##?|%%?|,,?\/|\^\^?)?/,
201
            push : "start"
202
        }, {
203
            token : "variable",
204
            regex : /\$[*@#?\-$!0_]/
205
        }, {
206
            token : ["variable", "paren.lparen"],
207
            regex : /(\$)(\{)/,
208
            push : "start"
209
        }]
210
    };
211
    
212
    this.normalizeRules();
213
};
214

    
215
oop.inherits(ShHighlightRules, TextHighlightRules);
216

    
217
exports.ShHighlightRules = ShHighlightRules;
218
});
219

    
220
ace.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) {
221
"use strict";
222

    
223
var oop = require("../lib/oop");
224
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
225

    
226
var ShHighlightFile = require("./sh_highlight_rules");
227

    
228
var MakefileHighlightRules = function() {
229

    
230
    var keywordMapper = this.createKeywordMapper({
231
        "keyword": ShHighlightFile.reservedKeywords,
232
        "support.function.builtin": ShHighlightFile.languageConstructs,
233
        "invalid.deprecated": "debugger"
234
    }, "string");
235

    
236
    this.$rules = 
237
        {
238
    "start": [
239
        {
240
            token: "string.interpolated.backtick.makefile",
241
            regex: "`",
242
            next: "shell-start"
243
        },
244
        {
245
            token: "punctuation.definition.comment.makefile",
246
            regex: /#(?=.)/,
247
            next: "comment"
248
        },
249
        {
250
            token: [ "keyword.control.makefile"],
251
            regex: "^(?:\\s*\\b)(\\-??include|ifeq|ifneq|ifdef|ifndef|else|endif|vpath|export|unexport|define|endef|override)(?:\\b)"
252
        },
253
        {// ^([^\t ]+(\s[^\t ]+)*:(?!\=))\s*.*
254
            token: ["entity.name.function.makefile", "text"],
255
            regex: "^([^\\t ]+(?:\\s[^\\t ]+)*:)(\\s*.*)"
256
        }
257
    ],
258
    "comment": [
259
        {
260
            token : "punctuation.definition.comment.makefile",
261
            regex : /.+\\/
262
        },
263
        {
264
            token : "punctuation.definition.comment.makefile",
265
            regex : ".+",
266
            next  : "start"
267
        }
268
    ],
269
    "shell-start": [
270
        {
271
            token: keywordMapper,
272
            regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
273
        }, 
274
        {
275
            token: "string",
276
            regex : "\\w+"
277
        }, 
278
        {
279
            token : "string.interpolated.backtick.makefile",
280
            regex : "`",
281
            next  : "start"
282
        }
283
    ]
284
};
285

    
286
};
287

    
288
oop.inherits(MakefileHighlightRules, TextHighlightRules);
289

    
290
exports.MakefileHighlightRules = MakefileHighlightRules;
291
});
292

    
293
ace.define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module) {
294
"use strict";
295

    
296
var oop = require("../../lib/oop");
297
var BaseFoldMode = require("./fold_mode").FoldMode;
298
var Range = require("../../range").Range;
299

    
300
var FoldMode = exports.FoldMode = function() {};
301
oop.inherits(FoldMode, BaseFoldMode);
302

    
303
(function() {
304

    
305
    this.getFoldWidgetRange = function(session, foldStyle, row) {
306
        var range = this.indentationBlock(session, row);
307
        if (range)
308
            return range;
309

    
310
        var re = /\S/;
311
        var line = session.getLine(row);
312
        var startLevel = line.search(re);
313
        if (startLevel == -1 || line[startLevel] != "#")
314
            return;
315

    
316
        var startColumn = line.length;
317
        var maxRow = session.getLength();
318
        var startRow = row;
319
        var endRow = row;
320

    
321
        while (++row < maxRow) {
322
            line = session.getLine(row);
323
            var level = line.search(re);
324

    
325
            if (level == -1)
326
                continue;
327

    
328
            if (line[level] != "#")
329
                break;
330

    
331
            endRow = row;
332
        }
333

    
334
        if (endRow > startRow) {
335
            var endColumn = session.getLine(endRow).length;
336
            return new Range(startRow, startColumn, endRow, endColumn);
337
        }
338
    };
339
    this.getFoldWidget = function(session, foldStyle, row) {
340
        var line = session.getLine(row);
341
        var indent = line.search(/\S/);
342
        var next = session.getLine(row + 1);
343
        var prev = session.getLine(row - 1);
344
        var prevIndent = prev.search(/\S/);
345
        var nextIndent = next.search(/\S/);
346

    
347
        if (indent == -1) {
348
            session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : "";
349
            return "";
350
        }
351
        if (prevIndent == -1) {
352
            if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
353
                session.foldWidgets[row - 1] = "";
354
                session.foldWidgets[row + 1] = "";
355
                return "start";
356
            }
357
        } else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
358
            if (session.getLine(row - 2).search(/\S/) == -1) {
359
                session.foldWidgets[row - 1] = "start";
360
                session.foldWidgets[row + 1] = "";
361
                return "";
362
            }
363
        }
364

    
365
        if (prevIndent!= -1 && prevIndent < indent)
366
            session.foldWidgets[row - 1] = "start";
367
        else
368
            session.foldWidgets[row - 1] = "";
369

    
370
        if (indent < nextIndent)
371
            return "start";
372
        else
373
            return "";
374
    };
375

    
376
}).call(FoldMode.prototype);
377

    
378
});
379

    
380
ace.define("ace/mode/makefile",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/makefile_highlight_rules","ace/mode/folding/coffee"], function(require, exports, module) {
381
"use strict";
382

    
383
var oop = require("../lib/oop");
384
var TextMode = require("./text").Mode;
385
var MakefileHighlightRules = require("./makefile_highlight_rules").MakefileHighlightRules;
386
var FoldMode = require("./folding/coffee").FoldMode;
387

    
388
var Mode = function() {
389
    this.HighlightRules = MakefileHighlightRules;
390
    this.foldingRules = new FoldMode();
391
    this.$behaviour = this.$defaultBehaviour;
392
};
393
oop.inherits(Mode, TextMode);
394

    
395
(function() {
396
       
397
    this.lineCommentStart = "#";    
398
    this.$indentWithTabs = true;
399
    
400
    this.$id = "ace/mode/makefile";
401
    this.snippetFileId = "ace/snippets/makefile";
402
}).call(Mode.prototype);
403

    
404
exports.Mode = Mode;
405
});                (function() {
406
                    ace.require(["ace/mode/makefile"], function(m) {
407
                        if (typeof module == "object" && typeof exports == "object" && module) {
408
                            module.exports = m;
409
                        }
410
                    });
411
                })();
412
            
(116-116/244)