Debian Codegraph @

extensions/CodeEditor/modules/lib/ace/mode-red.js

raw symbols SCIP
1 ace.define("ace/mode/red_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
2 var oop = require("../lib/oop");
3 var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
4 var RedHighlightRules = function () {
5 var compoundKeywords = "";
6 this.$rules = {
7 "start": [
8 { token: "keyword.operator",
9 regex: /\s([\-+%/=<>*]|(?:\*\*\|\/\/|==|>>>?|<>|<<|=>|<=|=\?))(\s|(?=:))/ },
10 { token: "string.email", regex: /\w[-\w._]*\@\w[-\w._]*/ },
11 { token: "value.time", regex: /\b\d+:\d+(:\d+)?/ },
12 { token: "string.url", regex: /\w[-\w_]*\:(\/\/)?\w[-\w._]*(:\d+)?/ },
13 { token: "value.date", regex: /(\b\d{1,4}[-/]\d{1,2}[-/]\d{1,2}|\d{1,2}[-/]\d{1,2}[-/]\d{1,4})\b/ },
14 { token: "value.tuple", regex: /\b\d{1,3}\.\d{1,3}\.\d{1,3}(\.\d{1,3}){0,9}/ },
15 { token: "value.pair", regex: /[+-]?\d+x[-+]?\d+/ },
16 { token: "value.binary", regex: /\b2#{([01]{8})+}/ },
17 { token: "value.binary", regex: /\b64#{([\w/=+])+}/ },
18 { token: "value.binary", regex: /(16)?#{([\dabcdefABCDEF][\dabcdefABCDEF])*}/ },
19 { token: "value.issue", regex: /#\w[-\w'*.]*/ },
20 { token: "value.numeric", regex: /[+-]?\d['\d]*(?:\.\d+)?e[-+]?\d{1,3}\%?(?!\w)/ },
21 { token: "invalid.illegal", regex: /[+-]?\d['\d]*(?:\.\d+)?\%?[a-zA-Z]/ },
22 { token: "value.numeric", regex: /[+-]?\d['\d]*(?:\.\d+)?\%?(?![a-zA-Z])/ },
23 { token: "value.character", regex: /#"(\^[-@/_~^"HKLM\[]|.)"/ },
24 { token: "string.file", regex: /%[-\w\.\/]+/ },
25 { token: "string.tag", regex: /</, next: "tag" },
26 { token: "string", regex: /"/, next: "string" },
27 { token: "string.other", regex: "{", next: "string.other" },
28 { token: "comment", regex: "comment [{]", next: "comment" },
29 { token: "comment", regex: /;.+$/ },
30 { token: "paren.map-start", regex: "#\\(" },
31 { token: "paren.block-start", regex: "[\\[]" },
32 { token: "paren.block-end", regex: "[\\]]" },
33 { token: "paren.parens-start", regex: "[(]" },
34 { token: "paren.parens-end", regex: "\\)" },
35 { token: "keyword", regex: "/local|/external" },
36 { token: "keyword.preprocessor", regex: "#(if|either|" +
37 "switch|case|include|do|macrolocal|reset|process|trace)" },
38 { token: "constant.datatype!", regex: "(?:datatype|unset|none|logic|block|paren|string|" +
39 "file|url|char|integer|float|word|set-word|lit-word|" +
40 "get-word|refinement|issue|native|action|op|function|" +
41 "path|lit-path|set-path|get-path|routine|bitset|point|" +
42 "object|typeset|error|vector|hash|pair|percent|tuple|" +
43 "map|binary|time|tag|email|handle|date|image|event|" +
44 "series|any-type|number|any-object|scalar|" +
45 "any-string|any-word|any-function|any-block|any-list|" +
46 "any-path|immediate|all-word|internal|external|default)!(?![-!?\\w~])" },
47 { token: "keyword.function", regex: "\\b(?:collect|quote|on-parse-event|math|last|source|expand|" +
48 "show|context|object|input|quit|dir|make-dir|cause-error|" +
49 "error\\?|none\\?|block\\?|any-list\\?|word\\?|char\\?|" +
50 "any-string\\?|series\\?|binary\\?|attempt|url\\?|" +
51 "string\\?|suffix\\?|file\\?|object\\?|body-of|first|" +
52 "second|third|mod|clean-path|dir\\?|to-red-file|" +
53 "normalize-dir|list-dir|pad|empty\\?|dirize|offset\\?|" +
54 "what-dir|expand-directives|load|split-path|change-dir|" +
55 "to-file|path-thru|save|load-thru|View|float\\?|to-float|" +
56 "charset|\\?|probe|set-word\\?|q|words-of|replace|repend|" +
57 "react|function\\?|spec-of|unset\\?|halt|op\\?|" +
58 "any-function\\?|to-paren|tag\\?|routine|class-of|" +
59 "size-text|draw|handle\\?|link-tabs-to-parent|" +
60 "link-sub-to-parent|on-face-deep-change*|" +
61 "update-font-faces|do-actor|do-safe|do-events|pair\\?|" +
62 "foreach-face|hex-to-rgb|issue\\?|alter|path\\?|" +
63 "typeset\\?|datatype\\?|set-flag|layout|extract|image\\?|" +
64 "get-word\\?|to-logic|to-set-word|to-block|center-face|" +
65 "dump-face|request-font|request-file|request-dir|rejoin|" +
66 "ellipsize-at|any-block\\?|any-object\\?|map\\?|keys-of|" +
67 "a-an|also|parse-func-spec|help-string|what|routine\\?|" +
68 "action\\?|native\\?|refinement\\?|common-substr|" +
69 "red-complete-file|red-complete-path|unview|comment|\\?\\?|" +
70 "fourth|fifth|values-of|bitset\\?|email\\?|get-path\\?|" +
71 "hash\\?|integer\\?|lit-path\\?|lit-word\\?|logic\\?|" +
72 "paren\\?|percent\\?|set-path\\?|time\\?|tuple\\?|date\\?|" +
73 "vector\\?|any-path\\?|any-word\\?|number\\?|immediate\\?|" +
74 "scalar\\?|all-word\\?|to-bitset|to-binary|to-char|to-email|" +
75 "to-get-path|to-get-word|to-hash|to-integer|to-issue|" +
76 "to-lit-path|to-lit-word|to-map|to-none|to-pair|to-path|" +
77 "to-percent|to-refinement|to-set-path|to-string|to-tag|" +
78 "to-time|to-typeset|to-tuple|to-unset|to-url|to-word|" +
79 "to-image|to-date|parse-trace|modulo|eval-set-path|" +
80 "extract-boot-args|flip-exe-flag|split|do-file|" +
81 "exists-thru\\?|read-thru|do-thru|cos|sin|tan|acos|asin|" +
82 "atan|atan2|sqrt|clear-reactions|dump-reactions|react\\?|" +
83 "within\\?|overlap\\?|distance\\?|face\\?|metrics\\?|" +
84 "get-scroller|insert-event-func|remove-event-func|" +
85 "set-focus|help|fetch-help|about|ls|ll|pwd|cd|" +
86 "red-complete-input|matrix)(?![-!?\\w~])" },
87 { token: "keyword.action", regex: "\\b(?:to|remove|copy|insert|change|clear|move|poke|put|" +
88 "random|reverse|sort|swap|take|trim|add|subtract|" +
89 "divide|multiply|make|reflect|form|mold|modify|" +
90 "absolute|negate|power|remainder|round|even\\?|odd\\?|" +
91 "and~|complement|or~|xor~|append|at|back|find|skip|" +
92 "tail|head|head\\?|index\\?|length\\?|next|pick|" +
93 "select|tail\\?|delete|read|write)(?![-_!?\\w~])"
94 },
95 { token: "keyword.native", regex: "\\b(?:not|any|set|uppercase|lowercase|checksum|" +
96 "try|catch|browse|throw|all|as|" +
97 "remove-each|func|function|does|has|do|reduce|" +
98 "compose|get|print|prin|equal\\?|not-equal\\?|" +
99 "strict-equal\\?|lesser\\?|greater\\?|lesser-or-equal\\?|" +
100 "greater-or-equal\\?|same\\?|type\\?|stats|bind|in|parse|" +
101 "union|unique|intersect|difference|exclude|" +
102 "complement\\?|dehex|negative\\?|positive\\?|max|min|" +
103 "shift|to-hex|sine|cosine|tangent|arcsine|arccosine|" +
104 "arctangent|arctangent2|NaN\\?|zero\\?|log-2|log-10|log-e|" +
105 "exp|square-root|construct|value\\?|as-pair|" +
106 "extend|debase|enbase|to-local-file|" +
107 "wait|unset|new-line|new-line\\?|context\\?|set-env|" +
108 "get-env|list-env|now|sign\\?|call|size\\?)(?![-!?\\w~])"
109 },
110 { token: "keyword", regex: "\\b(?:Red(?=\\s+\\[)|object|context|make|self|keep)(?![-!?\\w~])"
111 },
112 { token: "variable.language", regex: "this" },
113 { token: "keyword.control", regex: "(?:while|if|return|case|unless|either|until|loop|repeat|" +
114 "forever|foreach|forall|switch|break|continue|exit)(?![-!?\\w~])" },
115 { token: "constant.language", regex: "\\b(?:true|false|on|off|yes|none|no)(?![-!?\\w~])" },
116 { token: "constant.numeric", regex: /\bpi(?![^-_])/ },
117 { token: "constant.character", regex: "\\b(space|tab|newline|cr|lf)(?![-!?\\w~])" },
118 { token: "keyword.operator", regex: "\s(or|and|xor|is)\s" },
119 { token: "variable.get-path", regex: /:\w[-\w'*.?!]*(\/\w[-\w'*.?!]*)(\/\w[-\w'*.?!]*)*/ },
120 { token: "variable.set-path", regex: /\w[-\w'*.?!]*(\/\w[-\w'*.?!]*)(\/\w[-\w'*.?!]*)*:/ },
121 { token: "variable.lit-path", regex: /'\w[-\w'*.?!]*(\/\w[-\w'*.?!]*)(\/\w[-\w'*.?!]*)*/ },
122 { token: "variable.path", regex: /\w[-\w'*.?!]*(\/\w[-\w'*.?!]*)(\/\w[-\w'*.?!]*)*/ },
123 { token: "variable.refinement", regex: /\/\w[-\w'*.?!]*/ },
124 { token: "keyword.view.style", regex: "\\b(?:window|base|button|text|field|area|check|" +
125 "radio|progress|slider|camera|text-list|" +
126 "drop-list|drop-down|panel|group-box|" +
127 "tab-panel|h1|h2|h3|h4|h5|box|image|init)(?![-!?\\w~])" },
128 { token: "keyword.view.event", regex: "\\b(?:detect|on-detect|time|on-time|drawing|on-drawing|" +
129 "scroll|on-scroll|down|on-down|up|on-up|mid-down|" +
130 "on-mid-down|mid-up|on-mid-up|alt-down|on-alt-down|" +
131 "alt-up|on-alt-up|aux-down|on-aux-down|aux-up|" +
132 "on-aux-up|wheel|on-wheel|drag-start|on-drag-start|" +
133 "drag|on-drag|drop|on-drop|click|on-click|dbl-click|" +
134 "on-dbl-click|over|on-over|key|on-key|key-down|" +
135 "on-key-down|key-up|on-key-up|ime|on-ime|focus|" +
136 "on-focus|unfocus|on-unfocus|select|on-select|" +
137 "change|on-change|enter|on-enter|menu|on-menu|close|" +
138 "on-close|move|on-move|resize|on-resize|moving|" +
139 "on-moving|resizing|on-resizing|zoom|on-zoom|pan|" +
140 "on-pan|rotate|on-rotate|two-tap|on-two-tap|" +
141 "press-tap|on-press-tap|create|on-create|created|on-created)(?![-!?\\w~])" },
142 { token: "keyword.view.option", regex: "\\b(?:all-over|center|color|default|disabled|down|" +
143 "flags|focus|font|font-color|font-name|" +
144 "font-size|hidden|hint|left|loose|name|" +
145 "no-border|now|rate|react|select|size|space)(?![-!?\\w~])" },
146 { token: "constant.other.colour", regex: "\\b(?:Red|white|transparent|" +
147 "black|gray|aqua|beige|blue|brick|brown|coal|coffee|" +
148 "crimson|cyan|forest|gold|green|ivory|khaki|leaf|linen|" +
149 "magenta|maroon|mint|navy|oldrab|olive|orange|papaya|" +
150 "pewter|pink|purple|reblue|rebolor|sienna|silver|sky|" +
151 "snow|tanned|teal|violet|water|wheat|yello|yellow|glass)(?![-!?\\w~])" },
152 { token: "variable.get-word", regex: /\:\w[-\w'*.?!]*/ },
153 { token: "variable.set-word", regex: /\w[-\w'*.?!]*\:/ },
154 { token: "variable.lit-word", regex: /'\w[-\w'*.?!]*/ },
155 { token: "variable.word", regex: /\b\w+[-\w'*.!?]*/ },
156 { caseInsensitive: true }
157 ],
158 "string": [
159 { token: "string", regex: /"/, next: "start" },
160 { defaultToken: "string" }
161 ],
162 "string.other": [
163 { token: "string.other", regex: /}/, next: "start" },
164 { defaultToken: "string.other" }
165 ],
166 "tag": [
167 { token: "string.tag", regex: />/, next: "start" },
168 { defaultToken: "string.tag" }
169 ],
170 "comment": [
171 { token: "comment", regex: /}/, next: "start" },
172 { defaultToken: "comment" }
173 ]
174 };
175 };
176 oop.inherits(RedHighlightRules, TextHighlightRules);
177 exports.RedHighlightRules = RedHighlightRules;
178
179 });
180
181 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";
182 var oop = require("../../lib/oop");
183 var Range = require("../../range").Range;
184 var BaseFoldMode = require("./fold_mode").FoldMode;
185 var FoldMode = exports.FoldMode = function (commentRegex) {
186 if (commentRegex) {
187 this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
188 this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
189 }
190 };
191 oop.inherits(FoldMode, BaseFoldMode);
192 (function () {
193 this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
194 this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
195 this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
196 this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
197 this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
198 this._getFoldWidgetBase = this.getFoldWidget;
199 this.getFoldWidget = function (session, foldStyle, row) {
200 var line = session.getLine(row);
201 if (this.singleLineBlockCommentRe.test(line)) {
202 if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
203 return "";
204 }
205 var fw = this._getFoldWidgetBase(session, foldStyle, row);
206 if (!fw && this.startRegionRe.test(line))
207 return "start"; // lineCommentRegionStart
208 return fw;
209 };
210 this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
211 var line = session.getLine(row);
212 if (this.startRegionRe.test(line))
213 return this.getCommentRegionBlock(session, line, row);
214 var match = line.match(this.foldingStartMarker);
215 if (match) {
216 var i = match.index;
217 if (match[1])
218 return this.openingBracketBlock(session, match[1], row, i);
219 var range = session.getCommentFoldRange(row, i + match[0].length, 1);
220 if (range && !range.isMultiLine()) {
221 if (forceMultiline) {
222 range = this.getSectionRange(session, row);
223 }
224 else if (foldStyle != "all")
225 range = null;
226 }
227 return range;
228 }
229 if (foldStyle === "markbegin")
230 return;
231 var match = line.match(this.foldingStopMarker);
232 if (match) {
233 var i = match.index + match[0].length;
234 if (match[1])
235 return this.closingBracketBlock(session, match[1], row, i);
236 return session.getCommentFoldRange(row, i, -1);
237 }
238 };
239 this.getSectionRange = function (session, row) {
240 var line = session.getLine(row);
241 var startIndent = line.search(/\S/);
242 var startRow = row;
243 var startColumn = line.length;
244 row = row + 1;
245 var endRow = row;
246 var maxRow = session.getLength();
247 while (++row < maxRow) {
248 line = session.getLine(row);
249 var indent = line.search(/\S/);
250 if (indent === -1)
251 continue;
252 if (startIndent > indent)
253 break;
254 var subRange = this.getFoldWidgetRange(session, "all", row);
255 if (subRange) {
256 if (subRange.start.row <= startRow) {
257 break;
258 }
259 else if (subRange.isMultiLine()) {
260 row = subRange.end.row;
261 }
262 else if (startIndent == indent) {
263 break;
264 }
265 }
266 endRow = row;
267 }
268 return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
269 };
270 this.getCommentRegionBlock = function (session, line, row) {
271 var startColumn = line.search(/\s*$/);
272 var maxRow = session.getLength();
273 var startRow = row;
274 var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
275 var depth = 1;
276 while (++row < maxRow) {
277 line = session.getLine(row);
278 var m = re.exec(line);
279 if (!m)
280 continue;
281 if (m[1])
282 depth--;
283 else
284 depth++;
285 if (!depth)
286 break;
287 }
288 var endRow = row;
289 if (endRow > startRow) {
290 return new Range(startRow, startColumn, endRow, line.length);
291 }
292 };
293 }).call(FoldMode.prototype);
294
295 });
296
297 ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
298 var Range = require("../range").Range;
299 var MatchingBraceOutdent = function () { };
300 (function () {
301 this.checkOutdent = function (line, input) {
302 if (!/^\s+$/.test(line))
303 return false;
304 return /^\s*\}/.test(input);
305 };
306 this.autoOutdent = function (doc, row) {
307 var line = doc.getLine(row);
308 var match = line.match(/^(\s*\})/);
309 if (!match)
310 return 0;
311 var column = match[1].length;
312 var openBracePos = doc.findMatchingBracket({ row: row, column: column });
313 if (!openBracePos || openBracePos.row == row)
314 return 0;
315 var indent = this.$getIndent(doc.getLine(openBracePos.row));
316 doc.replace(new Range(row, 0, row, column - 1), indent);
317 };
318 this.$getIndent = function (line) {
319 return line.match(/^\s*/)[0];
320 };
321 }).call(MatchingBraceOutdent.prototype);
322 exports.MatchingBraceOutdent = MatchingBraceOutdent;
323
324 });
325
326 ace.define("ace/mode/red",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/red_highlight_rules","ace/mode/folding/cstyle","ace/mode/matching_brace_outdent","ace/range"], function(require, exports, module){"use strict";
327 var oop = require("../lib/oop");
328 var TextMode = require("./text").Mode;
329 var RedHighlightRules = require("./red_highlight_rules").RedHighlightRules;
330 var RedFoldMode = require("./folding/cstyle").FoldMode;
331 var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
332 var Range = require("../range").Range;
333 var Mode = function () {
334 this.HighlightRules = RedHighlightRules;
335 this.foldingRules = new RedFoldMode();
336 this.$outdent = new MatchingBraceOutdent();
337 this.$behaviour = this.$defaultBehaviour;
338 };
339 oop.inherits(Mode, TextMode);
340 (function () {
341 this.lineCommentStart = ";";
342 this.blockComment = { start: "comment {", end: "}" };
343 this.getNextLineIndent = function (state, line, tab) {
344 var indent = this.$getIndent(line);
345 var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
346 var tokens = tokenizedLine.tokens;
347 var endState = tokenizedLine.state;
348 if (tokens.length && tokens[tokens.length - 1].type == "comment") {
349 return indent;
350 }
351 if (state == "start") {
352 var match = line.match(/^.*[\{\[\(]\s*$/);
353 if (match) {
354 indent += tab;
355 }
356 }
357 else if (state == "doc-start") {
358 if (endState == "start") {
359 return "";
360 }
361 var match = line.match(/^\s*(\/?)\*/);
362 if (match) {
363 if (match[1]) {
364 indent += " ";
365 }
366 indent += "* ";
367 }
368 }
369 return indent;
370 };
371 this.checkOutdent = function (state, line, input) {
372 return this.$outdent.checkOutdent(line, input);
373 };
374 this.autoOutdent = function (state, doc, row) {
375 this.$outdent.autoOutdent(doc, row);
376 };
377 this.$id = "ace/mode/red";
378 }).call(Mode.prototype);
379 exports.Mode = Mode;
380
381 }); (function() {
382 ace.require(["ace/mode/red"], function(m) {
383 if (typeof module == "object" && typeof exports == "object" && module) {
384 module.exports = m;
385 }
386 });
387 })();
388