8ac889e60c5693eb83a35e6d30582578.js 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. ace.define("ace/mode/applescript_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 AppleScriptHighlightRules = function () {
  5. var keywords = ("about|above|after|against|and|around|as|at|back|before|beginning|" +
  6. "behind|below|beneath|beside|between|but|by|considering|" +
  7. "contain|contains|continue|copy|div|does|eighth|else|end|equal|" +
  8. "equals|error|every|exit|fifth|first|for|fourth|from|front|" +
  9. "get|given|global|if|ignoring|in|into|is|it|its|last|local|me|" +
  10. "middle|mod|my|ninth|not|of|on|onto|or|over|prop|property|put|ref|" +
  11. "reference|repeat|returning|script|second|set|seventh|since|" +
  12. "sixth|some|tell|tenth|that|the|then|third|through|thru|" +
  13. "timeout|times|to|transaction|try|until|where|while|whose|with|without");
  14. var builtinConstants = ("AppleScript|false|linefeed|return|pi|quote|result|space|tab|true");
  15. var builtinFunctions = ("activate|beep|count|delay|launch|log|offset|read|round|run|say|" +
  16. "summarize|write");
  17. var builtinTypes = ("alias|application|boolean|class|constant|date|file|integer|list|" +
  18. "number|real|record|string|text|character|characters|contents|day|" +
  19. "frontmost|id|item|length|month|name|paragraph|paragraphs|rest|" +
  20. "reverse|running|time|version|weekday|word|words|year");
  21. var keywordMapper = this.createKeywordMapper({
  22. "support.function": builtinFunctions,
  23. "constant.language": builtinConstants,
  24. "support.type": builtinTypes,
  25. "keyword": keywords
  26. }, "identifier");
  27. this.$rules = {
  28. "start": [
  29. {
  30. token: "comment",
  31. regex: "--.*$"
  32. },
  33. {
  34. token: "comment",
  35. regex: "\\(\\*",
  36. next: "comment"
  37. },
  38. {
  39. token: "string",
  40. regex: '".*?"'
  41. },
  42. {
  43. token: "support.type",
  44. regex: '\\b(POSIX file|POSIX path|(date|time) string|quoted form)\\b'
  45. },
  46. {
  47. token: "support.function",
  48. regex: '\\b(clipboard info|the clipboard|info for|list (disks|folder)|' +
  49. 'mount volume|path to|(close|open for) access|(get|set) eof|' +
  50. 'current date|do shell script|get volume settings|random number|' +
  51. 'set volume|system attribute|system info|time to GMT|' +
  52. '(load|run|store) script|scripting components|' +
  53. 'ASCII (character|number)|localized string|' +
  54. 'choose (application|color|file|file name|' +
  55. 'folder|from list|remote application|URL)|' +
  56. 'display (alert|dialog))\\b|^\\s*return\\b'
  57. },
  58. {
  59. token: "constant.language",
  60. regex: '\\b(text item delimiters|current application|missing value)\\b'
  61. },
  62. {
  63. token: "keyword",
  64. regex: '\\b(apart from|aside from|instead of|out of|greater than|' +
  65. "isn't|(doesn't|does not) (equal|come before|come after|contain)|" +
  66. '(greater|less) than( or equal)?|(starts?|ends|begins?) with|' +
  67. 'contained by|comes (before|after)|a (ref|reference))\\b'
  68. },
  69. {
  70. token: keywordMapper,
  71. regex: "[a-zA-Z][a-zA-Z0-9_]*\\b"
  72. }
  73. ],
  74. "comment": [
  75. {
  76. token: "comment",
  77. regex: "\\*\\)",
  78. next: "start"
  79. }, {
  80. defaultToken: "comment"
  81. }
  82. ]
  83. };
  84. this.normalizeRules();
  85. };
  86. oop.inherits(AppleScriptHighlightRules, TextHighlightRules);
  87. exports.AppleScriptHighlightRules = AppleScriptHighlightRules;
  88. });
  89. 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";
  90. var oop = require("../../lib/oop");
  91. var Range = require("../../range").Range;
  92. var BaseFoldMode = require("./fold_mode").FoldMode;
  93. var FoldMode = exports.FoldMode = function (commentRegex) {
  94. if (commentRegex) {
  95. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  96. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  97. }
  98. };
  99. oop.inherits(FoldMode, BaseFoldMode);
  100. (function () {
  101. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  102. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  103. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  104. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  105. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  106. this._getFoldWidgetBase = this.getFoldWidget;
  107. this.getFoldWidget = function (session, foldStyle, row) {
  108. var line = session.getLine(row);
  109. if (this.singleLineBlockCommentRe.test(line)) {
  110. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  111. return "";
  112. }
  113. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  114. if (!fw && this.startRegionRe.test(line))
  115. return "start"; // lineCommentRegionStart
  116. return fw;
  117. };
  118. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  119. var line = session.getLine(row);
  120. if (this.startRegionRe.test(line))
  121. return this.getCommentRegionBlock(session, line, row);
  122. var match = line.match(this.foldingStartMarker);
  123. if (match) {
  124. var i = match.index;
  125. if (match[1])
  126. return this.openingBracketBlock(session, match[1], row, i);
  127. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  128. if (range && !range.isMultiLine()) {
  129. if (forceMultiline) {
  130. range = this.getSectionRange(session, row);
  131. }
  132. else if (foldStyle != "all")
  133. range = null;
  134. }
  135. return range;
  136. }
  137. if (foldStyle === "markbegin")
  138. return;
  139. var match = line.match(this.foldingStopMarker);
  140. if (match) {
  141. var i = match.index + match[0].length;
  142. if (match[1])
  143. return this.closingBracketBlock(session, match[1], row, i);
  144. return session.getCommentFoldRange(row, i, -1);
  145. }
  146. };
  147. this.getSectionRange = function (session, row) {
  148. var line = session.getLine(row);
  149. var startIndent = line.search(/\S/);
  150. var startRow = row;
  151. var startColumn = line.length;
  152. row = row + 1;
  153. var endRow = row;
  154. var maxRow = session.getLength();
  155. while (++row < maxRow) {
  156. line = session.getLine(row);
  157. var indent = line.search(/\S/);
  158. if (indent === -1)
  159. continue;
  160. if (startIndent > indent)
  161. break;
  162. var subRange = this.getFoldWidgetRange(session, "all", row);
  163. if (subRange) {
  164. if (subRange.start.row <= startRow) {
  165. break;
  166. }
  167. else if (subRange.isMultiLine()) {
  168. row = subRange.end.row;
  169. }
  170. else if (startIndent == indent) {
  171. break;
  172. }
  173. }
  174. endRow = row;
  175. }
  176. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  177. };
  178. this.getCommentRegionBlock = function (session, line, row) {
  179. var startColumn = line.search(/\s*$/);
  180. var maxRow = session.getLength();
  181. var startRow = row;
  182. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  183. var depth = 1;
  184. while (++row < maxRow) {
  185. line = session.getLine(row);
  186. var m = re.exec(line);
  187. if (!m)
  188. continue;
  189. if (m[1])
  190. depth--;
  191. else
  192. depth++;
  193. if (!depth)
  194. break;
  195. }
  196. var endRow = row;
  197. if (endRow > startRow) {
  198. return new Range(startRow, startColumn, endRow, line.length);
  199. }
  200. };
  201. }).call(FoldMode.prototype);
  202. });
  203. ace.define("ace/mode/applescript",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/applescript_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
  204. var oop = require("../lib/oop");
  205. var TextMode = require("./text").Mode;
  206. var AppleScriptHighlightRules = require("./applescript_highlight_rules").AppleScriptHighlightRules;
  207. var FoldMode = require("./folding/cstyle").FoldMode;
  208. var Mode = function () {
  209. this.HighlightRules = AppleScriptHighlightRules;
  210. this.foldingRules = new FoldMode();
  211. this.$behaviour = this.$defaultBehaviour;
  212. };
  213. oop.inherits(Mode, TextMode);
  214. (function () {
  215. this.lineCommentStart = "--";
  216. this.blockComment = { start: "(*", end: "*)" };
  217. this.$id = "ace/mode/applescript";
  218. }).call(Mode.prototype);
  219. exports.Mode = Mode;
  220. }); (function() {
  221. ace.require(["ace/mode/applescript"], function(m) {
  222. if (typeof module == "object" && typeof exports == "object" && module) {
  223. module.exports = m;
  224. }
  225. });
  226. })();