e85d326b81c95df9bb7325c6468b61ba.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. ace.define("ace/mode/basic_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 BasicHighlightRules = function () {
  5. var keywordMapper = this.createKeywordMapper({
  6. "keyword.control": "FOR|TO|NEXT|GOSUB|RETURN|IF|THEN|ELSE|GOTO|ON|WHILE|WEND|TRON|TROFF",
  7. "entity.name": "Auto|Call|Chain|Clear|Close|Common|Cont|Data|MERGE|ALL|Delete|DIM|EDIT|END|ERASE|ERROR|FIELD|"
  8. + "GET|INPUT|KILL|LET|LIST|LLIST|LOAD|LSET|RSET|MERGE|NEW|NULL|OPEN|OUT|POKE|PRINT|PUT|RANDOMIZE|READ|"
  9. + "RENUM|RESTORE|RESUME|RUN|SAVE|STOP|SWAP|WAIT|WIDTH",
  10. "keyword.operator": "Mod|And|Not|Or|Xor|Eqv|Imp",
  11. "support.function": "ABS|ASC|ATN|CDBL|CINT|COS|CSNG|CVI|CVS|CVD|EOF|EXP|FIX|FRE|INP|INSTR|INT|LEN|LOC|LOG|LPOS|"
  12. + "PEEK|POS|RND|SGN|SIN|SPC|SQR|TAB|TAN|USR|VAL|VARPTR"
  13. }, "identifier", true);
  14. this.$rules = {
  15. "start": [
  16. {
  17. token: "string",
  18. regex: /"(?:\\.|[^"\\])*"/
  19. },
  20. {
  21. token: "support.function",
  22. regex: /(HEX|CHR|INPUT|LEFT|MID|MKI|MKS|MKD|OCT|RIGHT|SPACE|STR|STRING)\$/
  23. }, {
  24. token: "entity.name",
  25. regex: /(?:DEF\s(?:SEG|USR|FN[a-zA-Z]+)|LINE\sINPUT|L?PRINT#?(?:\sUSING)?|MID\$|ON\sERROR\sGOTO|OPTION\sBASE|WRITE#?|DATE\$|INKEY\$|TIME\$)/
  26. }, {
  27. token: "variable",
  28. regex: /[a-zA-Z][a-zA-Z0-9_]{0,38}[$%!#]?(?=\s*=)/
  29. }, {
  30. token: "keyword.operator",
  31. regex: /\\|=|\^|\*|\/|\+|\-|<|>|-/
  32. }, {
  33. token: "paren.lparen",
  34. regex: /[([]/
  35. }, {
  36. token: "paren.rparen",
  37. regex: /[\)\]]/
  38. }, {
  39. token: "constant.numeric",
  40. regex: /[+-]?\d+(\.\d+)?([ED][+-]?\d+)?(?:[!#])?/
  41. }, {
  42. token: "constant.numeric", //hexal, octal
  43. regex: /&[HO]?[0-9A-F]+/
  44. }, {
  45. token: "comment",
  46. regex: /REM\s+.*$/
  47. }, {
  48. regex: "\\w+",
  49. token: keywordMapper
  50. }, {
  51. token: "punctiation",
  52. regex: /[,;]/
  53. }
  54. ]
  55. };
  56. this.normalizeRules();
  57. };
  58. oop.inherits(BasicHighlightRules, TextHighlightRules);
  59. exports.BasicHighlightRules = BasicHighlightRules;
  60. });
  61. ace.define("ace/mode/folding/basic",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range","ace/token_iterator"], function(require, exports, module){"use strict";
  62. var oop = require("../../lib/oop");
  63. var BaseFoldMode = require("./fold_mode").FoldMode;
  64. var Range = require("../../range").Range;
  65. var TokenIterator = require("../../token_iterator").TokenIterator;
  66. var FoldMode = exports.FoldMode = function () { };
  67. oop.inherits(FoldMode, BaseFoldMode);
  68. (function () {
  69. this.indentKeywords = {
  70. "tron": 1,
  71. "while": 1,
  72. "for": 1,
  73. "troff": -1,
  74. "wend": -1,
  75. "next": -1
  76. };
  77. this.foldingStartMarker = /(?:\s|^)(tron|while|for)\b/i;
  78. this.foldingStopMarker = /(?:\b)(troff|next|wend)\b/i;
  79. this.getFoldWidgetRange = function (session, foldStyle, row) {
  80. var line = session.getLine(row);
  81. var isStart = this.foldingStartMarker.test(line);
  82. var isEnd = this.foldingStopMarker.test(line);
  83. if (isStart || isEnd) {
  84. var match = (isEnd) ? this.foldingStopMarker.exec(line) : this.foldingStartMarker.exec(line);
  85. var keyword = match && match[1].toLowerCase();
  86. if (keyword) {
  87. var type = session.getTokenAt(row, match.index + 2).type;
  88. if (type === "keyword.control")
  89. return this.basicBlock(session, row, match.index + 2);
  90. }
  91. }
  92. };
  93. this.getFoldWidget = function (session, foldStyle, row) {
  94. var line = session.getLine(row);
  95. var isStart = this.foldingStartMarker.test(line);
  96. var isEnd = this.foldingStopMarker.test(line);
  97. if (isStart && !isEnd) {
  98. var match = this.foldingStartMarker.exec(line);
  99. var keyword = match && match[1].toLowerCase();
  100. if (keyword) {
  101. var type = session.getTokenAt(row, match.index + 2).type;
  102. if (type == "keyword.control") {
  103. return "start";
  104. }
  105. }
  106. }
  107. if (foldStyle != "markbeginend" || !isEnd || isStart && isEnd)
  108. return "";
  109. var match = line.match(this.foldingStopMarker);
  110. var keyword = match && match[1].toLowerCase();
  111. if (this.indentKeywords[keyword]) {
  112. if (session.getTokenAt(row, match.index + 2).type === "keyword.control")
  113. return "end";
  114. }
  115. return "";
  116. };
  117. this.basicBlock = function (session, row, column, tokenRange) {
  118. var stream = new TokenIterator(session, row, column);
  119. var token = stream.getCurrentToken();
  120. if (!token || token.type != "keyword.control")
  121. return;
  122. var val = token.value.toLowerCase();
  123. var stack = [val];
  124. var dir = this.indentKeywords[val];
  125. if (!dir)
  126. return;
  127. var startColumn = dir === -1 ? stream.getCurrentTokenColumn() : session.getLine(row).length;
  128. var startRow = row;
  129. stream.step = dir === -1 ? stream.stepBackward : stream.stepForward;
  130. while (token = stream.step()) {
  131. val = token.value.toLowerCase();
  132. if (token.type !== "keyword.control" || !this.indentKeywords[val])
  133. continue;
  134. var level = dir * this.indentKeywords[val];
  135. if (level > 0) {
  136. stack.unshift(val);
  137. }
  138. else if (level <= 0) {
  139. stack.shift();
  140. }
  141. if (stack.length === 0) {
  142. break;
  143. }
  144. }
  145. if (!token)
  146. return null;
  147. if (tokenRange)
  148. return stream.getCurrentTokenRange();
  149. var row = stream.getCurrentTokenRow();
  150. if (dir === -1)
  151. return new Range(row, session.getLine(row).length, startRow, startColumn);
  152. else
  153. return new Range(startRow, startColumn, row, stream.getCurrentTokenColumn());
  154. };
  155. }).call(FoldMode.prototype);
  156. });
  157. ace.define("ace/mode/basic",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/basic_highlight_rules","ace/mode/folding/basic"], function(require, exports, module){"use strict";
  158. var oop = require("../lib/oop");
  159. var TextMode = require("./text").Mode;
  160. var BasicHighlightRules = require("./basic_highlight_rules").BasicHighlightRules;
  161. var FoldMode = require("./folding/basic").FoldMode;
  162. var Mode = function () {
  163. this.HighlightRules = BasicHighlightRules;
  164. this.foldingRules = new FoldMode();
  165. this.$behaviour = this.$defaultBehaviour;
  166. this.indentKeywords = this.foldingRules.indentKeywords;
  167. };
  168. oop.inherits(Mode, TextMode);
  169. (function () {
  170. this.lineCommentStart = ["REM"];
  171. this.getMatching = function (session, row, column, tokenRange) {
  172. if (row == undefined) {
  173. var pos = session.selection.lead;
  174. column = pos.column;
  175. row = pos.row;
  176. }
  177. if (tokenRange == undefined)
  178. tokenRange = true;
  179. var startToken = session.getTokenAt(row, column);
  180. if (startToken) {
  181. var val = startToken.value.toLowerCase();
  182. if (val in this.indentKeywords)
  183. return this.foldingRules.basicBlock(session, row, column, tokenRange);
  184. }
  185. };
  186. this.$id = "ace/mode/basic";
  187. }).call(Mode.prototype);
  188. exports.Mode = Mode;
  189. }); (function() {
  190. ace.require(["ace/mode/basic"], function(m) {
  191. if (typeof module == "object" && typeof exports == "object" && module) {
  192. module.exports = m;
  193. }
  194. });
  195. })();