corrade-nucleus-nucleons – Blame information for rev 24
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
20 | office | 1 | 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 | define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) { |
||
221 | "use strict"; |
||
222 | |||
223 | var oop = require("../../lib/oop"); |
||
224 | var Range = require("../../range").Range; |
||
225 | var BaseFoldMode = require("./fold_mode").FoldMode; |
||
226 | |||
227 | var FoldMode = exports.FoldMode = function(commentRegex) { |
||
228 | if (commentRegex) { |
||
229 | this.foldingStartMarker = new RegExp( |
||
230 | this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start) |
||
231 | ); |
||
232 | this.foldingStopMarker = new RegExp( |
||
233 | this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end) |
||
234 | ); |
||
235 | } |
||
236 | }; |
||
237 | oop.inherits(FoldMode, BaseFoldMode); |
||
238 | |||
239 | (function() { |
||
240 | |||
241 | this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; |
||
242 | this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; |
||
243 | this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/; |
||
244 | this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; |
||
245 | this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; |
||
246 | this._getFoldWidgetBase = this.getFoldWidget; |
||
247 | this.getFoldWidget = function(session, foldStyle, row) { |
||
248 | var line = session.getLine(row); |
||
249 | |||
250 | if (this.singleLineBlockCommentRe.test(line)) { |
||
251 | if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) |
||
252 | return ""; |
||
253 | } |
||
254 | |||
255 | var fw = this._getFoldWidgetBase(session, foldStyle, row); |
||
256 | |||
257 | if (!fw && this.startRegionRe.test(line)) |
||
258 | return "start"; // lineCommentRegionStart |
||
259 | |||
260 | return fw; |
||
261 | }; |
||
262 | |||
263 | this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) { |
||
264 | var line = session.getLine(row); |
||
265 | |||
266 | if (this.startRegionRe.test(line)) |
||
267 | return this.getCommentRegionBlock(session, line, row); |
||
268 | |||
269 | var match = line.match(this.foldingStartMarker); |
||
270 | if (match) { |
||
271 | var i = match.index; |
||
272 | |||
273 | if (match[1]) |
||
274 | return this.openingBracketBlock(session, match[1], row, i); |
||
275 | |||
276 | var range = session.getCommentFoldRange(row, i + match[0].length, 1); |
||
277 | |||
278 | if (range && !range.isMultiLine()) { |
||
279 | if (forceMultiline) { |
||
280 | range = this.getSectionRange(session, row); |
||
281 | } else if (foldStyle != "all") |
||
282 | range = null; |
||
283 | } |
||
284 | |||
285 | return range; |
||
286 | } |
||
287 | |||
288 | if (foldStyle === "markbegin") |
||
289 | return; |
||
290 | |||
291 | var match = line.match(this.foldingStopMarker); |
||
292 | if (match) { |
||
293 | var i = match.index + match[0].length; |
||
294 | |||
295 | if (match[1]) |
||
296 | return this.closingBracketBlock(session, match[1], row, i); |
||
297 | |||
298 | return session.getCommentFoldRange(row, i, -1); |
||
299 | } |
||
300 | }; |
||
301 | |||
302 | this.getSectionRange = function(session, row) { |
||
303 | var line = session.getLine(row); |
||
304 | var startIndent = line.search(/\S/); |
||
305 | var startRow = row; |
||
306 | var startColumn = line.length; |
||
307 | row = row + 1; |
||
308 | var endRow = row; |
||
309 | var maxRow = session.getLength(); |
||
310 | while (++row < maxRow) { |
||
311 | line = session.getLine(row); |
||
312 | var indent = line.search(/\S/); |
||
313 | if (indent === -1) |
||
314 | continue; |
||
315 | if (startIndent > indent) |
||
316 | break; |
||
317 | var subRange = this.getFoldWidgetRange(session, "all", row); |
||
318 | |||
319 | if (subRange) { |
||
320 | if (subRange.start.row <= startRow) { |
||
321 | break; |
||
322 | } else if (subRange.isMultiLine()) { |
||
323 | row = subRange.end.row; |
||
324 | } else if (startIndent == indent) { |
||
325 | break; |
||
326 | } |
||
327 | } |
||
328 | endRow = row; |
||
329 | } |
||
330 | |||
331 | return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); |
||
332 | }; |
||
333 | this.getCommentRegionBlock = function(session, line, row) { |
||
334 | var startColumn = line.search(/\s*$/); |
||
335 | var maxRow = session.getLength(); |
||
336 | var startRow = row; |
||
337 | |||
338 | var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; |
||
339 | var depth = 1; |
||
340 | while (++row < maxRow) { |
||
341 | line = session.getLine(row); |
||
342 | var m = re.exec(line); |
||
343 | if (!m) continue; |
||
344 | if (m[1]) depth--; |
||
345 | else depth++; |
||
346 | |||
347 | if (!depth) break; |
||
348 | } |
||
349 | |||
350 | var endRow = row; |
||
351 | if (endRow > startRow) { |
||
352 | return new Range(startRow, startColumn, endRow, line.length); |
||
353 | } |
||
354 | }; |
||
355 | |||
356 | }).call(FoldMode.prototype); |
||
357 | |||
358 | }); |
||
359 | |||
360 | define("ace/mode/sh",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/sh_highlight_rules","ace/range","ace/mode/folding/cstyle","ace/mode/behaviour/cstyle"], function(require, exports, module) { |
||
361 | "use strict"; |
||
362 | |||
363 | var oop = require("../lib/oop"); |
||
364 | var TextMode = require("./text").Mode; |
||
365 | var ShHighlightRules = require("./sh_highlight_rules").ShHighlightRules; |
||
366 | var Range = require("../range").Range; |
||
367 | var CStyleFoldMode = require("./folding/cstyle").FoldMode; |
||
368 | var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; |
||
369 | |||
370 | var Mode = function() { |
||
371 | this.HighlightRules = ShHighlightRules; |
||
372 | this.foldingRules = new CStyleFoldMode(); |
||
373 | this.$behaviour = new CstyleBehaviour(); |
||
374 | }; |
||
375 | oop.inherits(Mode, TextMode); |
||
376 | |||
377 | (function() { |
||
378 | |||
379 | |||
380 | this.lineCommentStart = "#"; |
||
381 | |||
382 | this.getNextLineIndent = function(state, line, tab) { |
||
383 | var indent = this.$getIndent(line); |
||
384 | |||
385 | var tokenizedLine = this.getTokenizer().getLineTokens(line, state); |
||
386 | var tokens = tokenizedLine.tokens; |
||
387 | |||
388 | if (tokens.length && tokens[tokens.length-1].type == "comment") { |
||
389 | return indent; |
||
390 | } |
||
391 | |||
392 | if (state == "start") { |
||
393 | var match = line.match(/^.*[\{\(\[:]\s*$/); |
||
394 | if (match) { |
||
395 | indent += tab; |
||
396 | } |
||
397 | } |
||
398 | |||
399 | return indent; |
||
400 | }; |
||
401 | |||
402 | var outdents = { |
||
403 | "pass": 1, |
||
404 | "return": 1, |
||
405 | "raise": 1, |
||
406 | "break": 1, |
||
407 | "continue": 1 |
||
408 | }; |
||
409 | |||
410 | this.checkOutdent = function(state, line, input) { |
||
411 | if (input !== "\r\n" && input !== "\r" && input !== "\n") |
||
412 | return false; |
||
413 | |||
414 | var tokens = this.getTokenizer().getLineTokens(line.trim(), state).tokens; |
||
415 | |||
416 | if (!tokens) |
||
417 | return false; |
||
418 | do { |
||
419 | var last = tokens.pop(); |
||
420 | } while (last && (last.type == "comment" || (last.type == "text" && last.value.match(/^\s+$/)))); |
||
421 | |||
422 | if (!last) |
||
423 | return false; |
||
424 | |||
425 | return (last.type == "keyword" && outdents[last.value]); |
||
426 | }; |
||
427 | |||
428 | this.autoOutdent = function(state, doc, row) { |
||
429 | |||
430 | row += 1; |
||
431 | var indent = this.$getIndent(doc.getLine(row)); |
||
432 | var tab = doc.getTabString(); |
||
433 | if (indent.slice(-tab.length) == tab) |
||
434 | doc.remove(new Range(row, indent.length-tab.length, row, indent.length)); |
||
435 | }; |
||
436 | |||
437 | this.$id = "ace/mode/sh"; |
||
438 | }).call(Mode.prototype); |
||
439 | |||
440 | exports.Mode = Mode; |
||
441 | }); |