Debian Codegraph @

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

raw symbols SCIP
1 ace.define("ace/mode/doc_comment_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 DocCommentHighlightRules = function () {
5 this.$rules = {
6 "start": [
7 {
8 token: "comment.doc.tag",
9 regex: "@\\w+(?=\\s|$)"
10 }, DocCommentHighlightRules.getTagRule(), {
11 defaultToken: "comment.doc",
12 caseInsensitive: true
13 }
14 ]
15 };
16 };
17 oop.inherits(DocCommentHighlightRules, TextHighlightRules);
18 DocCommentHighlightRules.getTagRule = function (start) {
19 return {
20 token: "comment.doc.tag.storage.type",
21 regex: "\\b(?:TODO|FIXME|XXX|HACK)\\b"
22 };
23 };
24 DocCommentHighlightRules.getStartRule = function (start) {
25 return {
26 token: "comment.doc", // doc comment
27 regex: "\\/\\*(?=\\*)",
28 next: start
29 };
30 };
31 DocCommentHighlightRules.getEndRule = function (start) {
32 return {
33 token: "comment.doc", // closing comment
34 regex: "\\*\\/",
35 next: start
36 };
37 };
38 exports.DocCommentHighlightRules = DocCommentHighlightRules;
39
40 });
41
42 ace.define("ace/mode/odin_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module){var __read = (this && this.__read) || function (o, n) {
43 var m = typeof Symbol === "function" && o[Symbol.iterator];
44 if (!m) return o;
45 var i = m.call(o), r, ar = [], e;
46 try {
47 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
48 }
49 catch (error) { e = { error: error }; }
50 finally {
51 try {
52 if (r && !r.done && (m = i["return"])) m.call(i);
53 }
54 finally { if (e) throw e.error; }
55 }
56 return ar;
57 };
58 var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
59 if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
60 if (ar || !(i in from)) {
61 if (!ar) ar = Array.prototype.slice.call(from, 0, i);
62 ar[i] = from[i];
63 }
64 }
65 return to.concat(ar || Array.prototype.slice.call(from));
66 };
67 var oop = require("../lib/oop");
68 var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
69 var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
70 var OdinHighlightRules = function () {
71 var keywords = "using|transmute|cast|distinct|opaque|where|" +
72 "struct|enum|union|bit_field|bit_set|" +
73 "if|when|else|do|switch|case|break|fallthrough|" +
74 "size_of|offset_of|type_info_if|typeid_of|type_of|align_of|" +
75 "or_return|or_else|inline|no_inline|" +
76 "import|package|foreign|defer|auto_cast|map|matrix|proc|" +
77 "for|continue|not_in|in";
78 var cartesian = function () {
79 var a = [];
80 for (var _i = 0; _i < arguments.length; _i++) {
81 a[_i] = arguments[_i];
82 }
83 return a
84 .reduce(function (a, b) { return a.flatMap(function (d) { return b.map(function (e) { return [d, e].flat(); }); }); })
85 .map(function (parts) { return parts.join(""); });
86 };
87 var builtinTypes = __spreadArray(__spreadArray(__spreadArray(__spreadArray([
88 "int",
89 "uint",
90 "uintptr",
91 "typeid",
92 "rawptr",
93 "string",
94 "cstring",
95 "i8",
96 "u8",
97 "any",
98 "byte",
99 "rune",
100 "bool",
101 "b8",
102 "b16",
103 "b32",
104 "b64"
105 ], __read(cartesian(["i", "u"], ["16", "32", "64", "128"], ["", "le", "be"])), false), __read(cartesian(["f"], ["16", "32", "64"], ["", "le", "be"])), false), __read(cartesian(["complex"], ["32", "64", "128"])), false), __read(cartesian(["quaternion"], ["64", "128", "256"])), false).join("|");
106 var operators = [
107 "\\*",
108 "/",
109 "%",
110 "%%",
111 "<<",
112 ">>",
113 "&",
114 "&~",
115 "\\+",
116 "\\-",
117 "~",
118 "\\|",
119 ">",
120 "<",
121 "<=",
122 ">=",
123 "==",
124 "!="
125 ]
126 .concat(":")
127 .map(function (operator) { return operator + "="; })
128 .concat("=", ":=", "::", "->", "\\^", "&", ":")
129 .join("|");
130 var builtinFunctions = "new|cap|copy|panic|len|make|delete|append|free";
131 var builtinConstants = "nil|true|false";
132 var keywordMapper = this.createKeywordMapper({
133 keyword: keywords,
134 "constant.language": builtinConstants,
135 "support.function": builtinFunctions,
136 "support.type": builtinTypes
137 }, "");
138 var stringEscapeRe = "\\\\(?:[0-7]{3}|x\\h{2}|u{4}|U\\h{6}|[abfnrtv'\"\\\\])".replace(/\\h/g, "[a-fA-F\\d]");
139 this.$rules = {
140 start: [
141 {
142 token: "comment",
143 regex: /\/\/.*$/
144 },
145 DocCommentHighlightRules.getStartRule("doc-start"),
146 {
147 token: "comment.start", // multi line comment
148 regex: "\\/\\*",
149 next: "comment"
150 },
151 {
152 token: "string", // single line
153 regex: /"(?:[^"\\]|\\.)*?"/
154 },
155 {
156 token: "string", // raw
157 regex: "`",
158 next: "bqstring"
159 },
160 {
161 token: "support.constant",
162 regex: /#[a-z_]+/
163 },
164 {
165 token: "constant.numeric", // rune
166 regex: "'(?:[^\\'\uD800-\uDBFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|" +
167 stringEscapeRe.replace('"', "") +
168 ")'"
169 },
170 {
171 token: "constant.numeric", // hex
172 regex: "0[xX][0-9a-fA-F]+\\b"
173 },
174 {
175 token: "constant.numeric", // float
176 regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
177 },
178 {
179 token: [
180 "entity.name.function",
181 "text",
182 "keyword.operator",
183 "text",
184 "keyword"
185 ],
186 regex: "([a-zA-Z_$][a-zA-Z0-9_$]*)(\\s+)(::)(\\s+)(proc)\\b"
187 },
188 {
189 token: function (val) {
190 if (val[val.length - 1] == "(") {
191 return [
192 {
193 type: keywordMapper(val.slice(0, -1)) || "support.function",
194 value: val.slice(0, -1)
195 },
196 {
197 type: "paren.lparen",
198 value: val.slice(-1)
199 }
200 ];
201 }
202 return keywordMapper(val) || "identifier";
203 },
204 regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b\\(?"
205 },
206 {
207 token: "keyword.operator",
208 regex: operators
209 },
210 {
211 token: "punctuation.operator",
212 regex: "\\?|\\,|\\;|\\."
213 },
214 {
215 token: "paren.lparen",
216 regex: "[[({]"
217 },
218 {
219 token: "paren.rparen",
220 regex: "[\\])}]"
221 },
222 {
223 token: "text",
224 regex: "\\s+"
225 }
226 ],
227 comment: [
228 {
229 token: "comment.end",
230 regex: "\\*\\/",
231 next: "start"
232 },
233 {
234 defaultToken: "comment"
235 }
236 ],
237 bqstring: [
238 {
239 token: "string",
240 regex: "`",
241 next: "start"
242 },
243 {
244 defaultToken: "string"
245 }
246 ]
247 };
248 this.embedRules(DocCommentHighlightRules, "doc-", [
249 DocCommentHighlightRules.getEndRule("start")
250 ]);
251 };
252 oop.inherits(OdinHighlightRules, TextHighlightRules);
253 exports.OdinHighlightRules = OdinHighlightRules;
254
255 });
256
257 ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
258 var Range = require("../range").Range;
259 var MatchingBraceOutdent = function () { };
260 (function () {
261 this.checkOutdent = function (line, input) {
262 if (!/^\s+$/.test(line))
263 return false;
264 return /^\s*\}/.test(input);
265 };
266 this.autoOutdent = function (doc, row) {
267 var line = doc.getLine(row);
268 var match = line.match(/^(\s*\})/);
269 if (!match)
270 return 0;
271 var column = match[1].length;
272 var openBracePos = doc.findMatchingBracket({ row: row, column: column });
273 if (!openBracePos || openBracePos.row == row)
274 return 0;
275 var indent = this.$getIndent(doc.getLine(openBracePos.row));
276 doc.replace(new Range(row, 0, row, column - 1), indent);
277 };
278 this.$getIndent = function (line) {
279 return line.match(/^\s*/)[0];
280 };
281 }).call(MatchingBraceOutdent.prototype);
282 exports.MatchingBraceOutdent = MatchingBraceOutdent;
283
284 });
285
286 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";
287 var oop = require("../../lib/oop");
288 var Range = require("../../range").Range;
289 var BaseFoldMode = require("./fold_mode").FoldMode;
290 var FoldMode = exports.FoldMode = function (commentRegex) {
291 if (commentRegex) {
292 this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
293 this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
294 }
295 };
296 oop.inherits(FoldMode, BaseFoldMode);
297 (function () {
298 this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
299 this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
300 this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
301 this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
302 this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
303 this._getFoldWidgetBase = this.getFoldWidget;
304 this.getFoldWidget = function (session, foldStyle, row) {
305 var line = session.getLine(row);
306 if (this.singleLineBlockCommentRe.test(line)) {
307 if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
308 return "";
309 }
310 var fw = this._getFoldWidgetBase(session, foldStyle, row);
311 if (!fw && this.startRegionRe.test(line))
312 return "start"; // lineCommentRegionStart
313 return fw;
314 };
315 this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
316 var line = session.getLine(row);
317 if (this.startRegionRe.test(line))
318 return this.getCommentRegionBlock(session, line, row);
319 var match = line.match(this.foldingStartMarker);
320 if (match) {
321 var i = match.index;
322 if (match[1])
323 return this.openingBracketBlock(session, match[1], row, i);
324 var range = session.getCommentFoldRange(row, i + match[0].length, 1);
325 if (range && !range.isMultiLine()) {
326 if (forceMultiline) {
327 range = this.getSectionRange(session, row);
328 }
329 else if (foldStyle != "all")
330 range = null;
331 }
332 return range;
333 }
334 if (foldStyle === "markbegin")
335 return;
336 var match = line.match(this.foldingStopMarker);
337 if (match) {
338 var i = match.index + match[0].length;
339 if (match[1])
340 return this.closingBracketBlock(session, match[1], row, i);
341 return session.getCommentFoldRange(row, i, -1);
342 }
343 };
344 this.getSectionRange = function (session, row) {
345 var line = session.getLine(row);
346 var startIndent = line.search(/\S/);
347 var startRow = row;
348 var startColumn = line.length;
349 row = row + 1;
350 var endRow = row;
351 var maxRow = session.getLength();
352 while (++row < maxRow) {
353 line = session.getLine(row);
354 var indent = line.search(/\S/);
355 if (indent === -1)
356 continue;
357 if (startIndent > indent)
358 break;
359 var subRange = this.getFoldWidgetRange(session, "all", row);
360 if (subRange) {
361 if (subRange.start.row <= startRow) {
362 break;
363 }
364 else if (subRange.isMultiLine()) {
365 row = subRange.end.row;
366 }
367 else if (startIndent == indent) {
368 break;
369 }
370 }
371 endRow = row;
372 }
373 return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
374 };
375 this.getCommentRegionBlock = function (session, line, row) {
376 var startColumn = line.search(/\s*$/);
377 var maxRow = session.getLength();
378 var startRow = row;
379 var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
380 var depth = 1;
381 while (++row < maxRow) {
382 line = session.getLine(row);
383 var m = re.exec(line);
384 if (!m)
385 continue;
386 if (m[1])
387 depth--;
388 else
389 depth++;
390 if (!depth)
391 break;
392 }
393 var endRow = row;
394 if (endRow > startRow) {
395 return new Range(startRow, startColumn, endRow, line.length);
396 }
397 };
398 }).call(FoldMode.prototype);
399
400 });
401
402 ace.define("ace/mode/odin",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/odin_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/cstyle"], function(require, exports, module){var oop = require("../lib/oop");
403 var TextMode = require("./text").Mode;
404 var OdinHighlightRules = require("./odin_highlight_rules").OdinHighlightRules;
405 var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
406 var CStyleFoldMode = require("./folding/cstyle").FoldMode;
407 var Mode = function () {
408 this.HighlightRules = OdinHighlightRules;
409 this.$outdent = new MatchingBraceOutdent();
410 this.foldingRules = new CStyleFoldMode();
411 this.$behaviour = this.$defaultBehaviour;
412 };
413 oop.inherits(Mode, TextMode);
414 (function () {
415 this.lineCommentStart = "//";
416 this.blockComment = { start: "/*", end: "*/" };
417 this.getNextLineIndent = function (state, line, tab) {
418 var indent = this.$getIndent(line);
419 var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
420 var tokens = tokenizedLine.tokens;
421 if (tokens.length && tokens[tokens.length - 1].type == "comment") {
422 return indent;
423 }
424 if (state == "start") {
425 var match = line.match(/^.*[\{\(\[:]\s*$/);
426 if (match) {
427 indent += tab;
428 }
429 }
430 return indent;
431 }; //end getNextLineIndent
432 this.checkOutdent = function (state, line, input) {
433 return this.$outdent.checkOutdent(line, input);
434 };
435 this.autoOutdent = function (state, doc, row) {
436 this.$outdent.autoOutdent(doc, row);
437 };
438 this.$id = "ace/mode/odin";
439 }).call(Mode.prototype);
440 exports.Mode = Mode;
441
442 }); (function() {
443 ace.require(["ace/mode/odin"], function(m) {
444 if (typeof module == "object" && typeof exports == "object" && module) {
445 module.exports = m;
446 }
447 });
448 })();
449