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.

235 lines
9.3 KiB

12 months ago
  1. ace.define("ace/mode/mips_assembler_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 = { start:
  7. [ { token: 'support.function.pseudo.mips',
  8. regex: '\\b(?:mul|abs|div|divu|mulo|mulou|neg|negu|not|rem|remu|rol|ror|li|seq|sge|sgeu|sgt|sgtu|sle|sleu|sne|b|beqz|bge|bgeu|bgt|bgtu|ble|bleu|blt|bltu|bnez|la|ld|ulh|ulhu|ulw|sd|ush|usw|move|mfc1\\.d|l\\.d|l\\.s|s\\.d|s\\.s)\\b',
  9. comment: 'ok actually this are instructions, but one also could call them funtions…' },
  10. { token: 'support.function.mips',
  11. regex: '\\b(?:abs\\.d|abs\\.s|add|add\\.d|add\\.s|addi|addiu|addu|and|andi|bc1f|bc1t|beq|bgez|bgezal|bgtz|blez|bltz|bltzal|bne|break|c\\.eq\\.d|c\\.eq\\.s|c\\.le\\.d|c\\.le\\.s|c\\.lt\\.d|c\\.lt\\.s|ceil\\.w\\.d|ceil\\.w\\.s|clo|clz|cvt\\.d\\.s|cvt\\.d\\.w|cvt\\.s\\.d|cvt\\.s\\.w|cvt\\.w\\.d|cvt\\.w\\.s|div|div\\.d|div\\.s|divu|eret|floor\\.w\\.d|floor\\.w\\.s|j|jal|jalr|jr|lb|lbu|lh|lhu|ll|lui|lw|lwc1|lwl|lwr|madd|maddu|mfc0|mfc1|mfhi|mflo|mov\\.d|mov\\.s|movf|movf\\.d|movf\\.s|movn|movn\\.d|movn\\.s|movt|movt\\.d|movt\\.s|movz|movz\\.d|movz\\.s|msub|mtc0|mtc1|mthi|mtlo|mul|mul\\.d|mul\\.s|mult|multu|neg\\.d|neg\\.s|nop|nor|or|ori|round\\.w\\.d|round\\.w\\.s|sb|sc|sdc1|sh|sll|sllv|slt|slti|sltiu|sltu|sqrt\\.d|sqrt\\.s|sra|srav|srl|srlv|sub|sub\\.d|sub\\.s|subu|sw|swc1|swl|swr|syscall|teq|teqi|tge|tgei|tgeiu|tgeu|tlt|tlti|tltiu|tltu|trunc\\.w\\.d|trunc\\.w\\.s|xor|xori)\\b' },
  12. { token: 'storage.type.mips',
  13. regex: '\\.(?:ascii|asciiz|byte|data|double|float|half|kdata|ktext|space|text|word|set\\s*(?:noat|at))\\b' },
  14. { token: 'storage.modifier.mips',
  15. regex: '\\.(?:align|extern||globl)\\b' },
  16. { token:
  17. [ 'entity.name.function.label.mips',
  18. 'meta.function.label.mips' ],
  19. regex: '\\b([A-Za-z0-9_]+)(:)' },
  20. { token:
  21. [ 'punctuation.definition.variable.mips',
  22. 'variable.other.register.usable.by-number.mips' ],
  23. regex: '(\\$)(0|[2-9]|1[0-9]|2[0-5]|2[89]|3[0-1])\\b' },
  24. { token:
  25. [ 'punctuation.definition.variable.mips',
  26. 'variable.other.register.usable.by-name.mips' ],
  27. regex: '(\\$)(zero|v[01]|a[0-3]|t[0-9]|s[0-7]|gp|sp|fp|ra)\\b' },
  28. { token:
  29. [ 'punctuation.definition.variable.mips',
  30. 'variable.other.register.reserved.mips' ],
  31. regex: '(\\$)(at|k[01]|1|2[67])\\b' },
  32. { token:
  33. [ 'punctuation.definition.variable.mips',
  34. 'variable.other.register.usable.floating-point.mips',
  35. 'variable.other.register.usable.floating-point.mips' ],
  36. regex: '(\\$)(f)([0-9]|1[0-9]|2[0-9]|3[0-1])\\b' },
  37. { token: 'constant.numeric.float.mips',
  38. regex: '\\b\\d+\\.\\d+\\b' },
  39. { token: 'constant.numeric.integer.mips',
  40. regex: '\\b(?:\\d+|0(?:x|X)[a-fA-F0-9]+)\\b' },
  41. { token: 'punctuation.definition.string.begin.mips',
  42. regex: '"',
  43. push:
  44. [ { token: 'punctuation.definition.string.end.mips',
  45. regex: '"',
  46. next: 'pop' },
  47. { token: 'constant.character.escape.mips',
  48. regex: '\\\\[rnt\\\\"]' },
  49. { defaultToken: 'string.quoted.double.mips' } ] },
  50. { token: 'punctuation.definition.comment.mips',
  51. regex: '#',
  52. push:
  53. [ { token: 'comment.line.number-sign.mips',
  54. regex: '$',
  55. next: 'pop' },
  56. { defaultToken: 'comment.line.number-sign.mips' } ] } ] }
  57. this.normalizeRules();
  58. };
  59. MIPSAssemblerHighlightRules.metaData = { fileTypes: [ 's', 'mips', 'spim', 'asm' ],
  60. keyEquivalent: '^~M',
  61. name: 'MIPS Assembler',
  62. scopeName: 'source.mips' }
  63. oop.inherits(MIPSAssemblerHighlightRules, TextHighlightRules);
  64. exports.MIPSAssemblerHighlightRules = MIPSAssemblerHighlightRules;
  65. });
  66. ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(acequire, exports, module) {
  67. "use strict";
  68. var oop = acequire("../../lib/oop");
  69. var Range = acequire("../../range").Range;
  70. var BaseFoldMode = acequire("./fold_mode").FoldMode;
  71. var FoldMode = exports.FoldMode = function(commentRegex) {
  72. if (commentRegex) {
  73. this.foldingStartMarker = new RegExp(
  74. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  75. );
  76. this.foldingStopMarker = new RegExp(
  77. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  78. );
  79. }
  80. };
  81. oop.inherits(FoldMode, BaseFoldMode);
  82. (function() {
  83. this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
  84. this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
  85. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  86. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  87. this.startRegionRe = /^\s*(\/\*|\/\/)#region\b/;
  88. this._getFoldWidgetBase = this.getFoldWidget;
  89. this.getFoldWidget = function(session, foldStyle, row) {
  90. var line = session.getLine(row);
  91. if (this.singleLineBlockCommentRe.test(line)) {
  92. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  93. return "";
  94. }
  95. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  96. if (!fw && this.startRegionRe.test(line))
  97. return "start"; // lineCommentRegionStart
  98. return fw;
  99. };
  100. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  101. var line = session.getLine(row);
  102. if (this.startRegionRe.test(line))
  103. return this.getCommentRegionBlock(session, line, row);
  104. var match = line.match(this.foldingStartMarker);
  105. if (match) {
  106. var i = match.index;
  107. if (match[1])
  108. return this.openingBracketBlock(session, match[1], row, i);
  109. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  110. if (range && !range.isMultiLine()) {
  111. if (forceMultiline) {
  112. range = this.getSectionRange(session, row);
  113. } else if (foldStyle != "all")
  114. range = null;
  115. }
  116. return range;
  117. }
  118. if (foldStyle === "markbegin")
  119. return;
  120. var match = line.match(this.foldingStopMarker);
  121. if (match) {
  122. var i = match.index + match[0].length;
  123. if (match[1])
  124. return this.closingBracketBlock(session, match[1], row, i);
  125. return session.getCommentFoldRange(row, i, -1);
  126. }
  127. };
  128. this.getSectionRange = function(session, row) {
  129. var line = session.getLine(row);
  130. var startIndent = line.search(/\S/);
  131. var startRow = row;
  132. var startColumn = line.length;
  133. row = row + 1;
  134. var endRow = row;
  135. var maxRow = session.getLength();
  136. while (++row < maxRow) {
  137. line = session.getLine(row);
  138. var indent = line.search(/\S/);
  139. if (indent === -1)
  140. continue;
  141. if (startIndent > indent)
  142. break;
  143. var subRange = this.getFoldWidgetRange(session, "all", row);
  144. if (subRange) {
  145. if (subRange.start.row <= startRow) {
  146. break;
  147. } else if (subRange.isMultiLine()) {
  148. row = subRange.end.row;
  149. } else if (startIndent == indent) {
  150. break;
  151. }
  152. }
  153. endRow = row;
  154. }
  155. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  156. };
  157. this.getCommentRegionBlock = function(session, line, row) {
  158. var startColumn = line.search(/\s*$/);
  159. var maxRow = session.getLength();
  160. var startRow = row;
  161. var re = /^\s*(?:\/\*|\/\/)#(end)?region\b/;
  162. var depth = 1;
  163. while (++row < maxRow) {
  164. line = session.getLine(row);
  165. var m = re.exec(line);
  166. if (!m) continue;
  167. if (m[1]) depth--;
  168. else depth++;
  169. if (!depth) break;
  170. }
  171. var endRow = row;
  172. if (endRow > startRow) {
  173. return new Range(startRow, startColumn, endRow, line.length);
  174. }
  175. };
  176. }).call(FoldMode.prototype);
  177. });
  178. ace.define("ace/mode/mips_assembler",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/mips_assembler_highlight_rules","ace/mode/folding/cstyle"], function(acequire, exports, module) {
  179. "use strict";
  180. var oop = acequire("../lib/oop");
  181. var TextMode = acequire("./text").Mode;
  182. var MIPSAssemblerHighlightRules = acequire("./mips_assembler_highlight_rules").MIPSAssemblerHighlightRules;
  183. var FoldMode = acequire("./folding/cstyle").FoldMode;
  184. var Mode = function() {
  185. this.HighlightRules = MIPSAssemblerHighlightRules;
  186. this.foldingRules = new FoldMode();
  187. };
  188. oop.inherits(Mode, TextMode);
  189. (function() {
  190. this.$id = "ace/mode/mips_assembler"
  191. }).call(Mode.prototype);
  192. exports.Mode = Mode;
  193. });