You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

196 lines
6.1 KiB

12 months ago
  1. ace.define("ace/mode/mipsassembler_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(acequire, exports, module) {
  2. "use strict";
  3. var oop = acequire("../lib/oop");
  4. var TextHighlightRules = acequire("./text_highlight_rules").TextHighlightRules;
  5. var mipsassemblerHighlightRules = function() {
  6. this.$rules = {
  7. start: [{
  8. token: "string.start",
  9. regex: '"',
  10. next: "qstring"
  11. }],
  12. qstring: [{
  13. token: "escape",
  14. regex: /\\./,
  15. }, {
  16. token: "string.end",
  17. regex: '"',
  18. next: "start"
  19. }],
  20. }
  21. this.normalizeRules();
  22. };
  23. mipsassemblerHighlightRules.metaData =
  24. oop.inherits(mipsassemblerHighlightRules, TextHighlightRules);
  25. exports.mipsassemblerHighlightRules = mipsassemblerHighlightRules;
  26. });
  27. ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(acequire, exports, module) {
  28. "use strict";
  29. var oop = acequire("../../lib/oop");
  30. var Range = acequire("../../range").Range;
  31. var BaseFoldMode = acequire("./fold_mode").FoldMode;
  32. var FoldMode = exports.FoldMode = function(commentRegex) {
  33. if (commentRegex) {
  34. this.foldingStartMarker = new RegExp(
  35. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  36. );
  37. this.foldingStopMarker = new RegExp(
  38. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  39. );
  40. }
  41. };
  42. oop.inherits(FoldMode, BaseFoldMode);
  43. (function() {
  44. this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
  45. this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
  46. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  47. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  48. this.startRegionRe = /^\s*(\/\*|\/\/)#region\b/;
  49. this._getFoldWidgetBase = this.getFoldWidget;
  50. this.getFoldWidget = function(session, foldStyle, row) {
  51. var line = session.getLine(row);
  52. if (this.singleLineBlockCommentRe.test(line)) {
  53. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  54. return "";
  55. }
  56. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  57. if (!fw && this.startRegionRe.test(line))
  58. return "start"; // lineCommentRegionStart
  59. return fw;
  60. };
  61. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  62. var line = session.getLine(row);
  63. if (this.startRegionRe.test(line))
  64. return this.getCommentRegionBlock(session, line, row);
  65. var match = line.match(this.foldingStartMarker);
  66. if (match) {
  67. var i = match.index;
  68. if (match[1])
  69. return this.openingBracketBlock(session, match[1], row, i);
  70. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  71. if (range && !range.isMultiLine()) {
  72. if (forceMultiline) {
  73. range = this.getSectionRange(session, row);
  74. } else if (foldStyle != "all")
  75. range = null;
  76. }
  77. return range;
  78. }
  79. if (foldStyle === "markbegin")
  80. return;
  81. var match = line.match(this.foldingStopMarker);
  82. if (match) {
  83. var i = match.index + match[0].length;
  84. if (match[1])
  85. return this.closingBracketBlock(session, match[1], row, i);
  86. return session.getCommentFoldRange(row, i, -1);
  87. }
  88. };
  89. this.getSectionRange = function(session, row) {
  90. var line = session.getLine(row);
  91. var startIndent = line.search(/\S/);
  92. var startRow = row;
  93. var startColumn = line.length;
  94. row = row + 1;
  95. var endRow = row;
  96. var maxRow = session.getLength();
  97. while (++row < maxRow) {
  98. line = session.getLine(row);
  99. var indent = line.search(/\S/);
  100. if (indent === -1)
  101. continue;
  102. if (startIndent > indent)
  103. break;
  104. var subRange = this.getFoldWidgetRange(session, "all", row);
  105. if (subRange) {
  106. if (subRange.start.row <= startRow) {
  107. break;
  108. } else if (subRange.isMultiLine()) {
  109. row = subRange.end.row;
  110. } else if (startIndent == indent) {
  111. break;
  112. }
  113. }
  114. endRow = row;
  115. }
  116. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  117. };
  118. this.getCommentRegionBlock = function(session, line, row) {
  119. var startColumn = line.search(/\s*$/);
  120. var maxRow = session.getLength();
  121. var startRow = row;
  122. var re = /^\s*(?:\/\*|\/\/)#(end)?region\b/;
  123. var depth = 1;
  124. while (++row < maxRow) {
  125. line = session.getLine(row);
  126. var m = re.exec(line);
  127. if (!m) continue;
  128. if (m[1]) depth--;
  129. else depth++;
  130. if (!depth) break;
  131. }
  132. var endRow = row;
  133. if (endRow > startRow) {
  134. return new Range(startRow, startColumn, endRow, line.length);
  135. }
  136. };
  137. }).call(FoldMode.prototype);
  138. });
  139. ace.define("ace/mode/mipsassembler",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/mipsassembler_highlight_rules","ace/mode/folding/cstyle"], function(acequire, exports, module) {
  140. "use strict";
  141. var oop = acequire("../lib/oop");
  142. var TextMode = acequire("./text").Mode;
  143. var HighlightRules = acequire("./mipsassembler_highlight_rules").HighlightRules;
  144. var FoldMode = acequire("./folding/cstyle").FoldMode;
  145. var Mode = function() {
  146. this.HighlightRules = HighlightRules;
  147. this.foldingRules = new FoldMode();
  148. };
  149. oop.inherits(Mode, TextMode);
  150. (function() {
  151. this.$id = "ace/mode/mipsassembler"
  152. }).call(Mode.prototype);
  153. exports.Mode = Mode;
  154. });