70f9578a3a4e83be56a998aacc7fac80.js 16 KB

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