a77f254bc934c3d69dd51902da56f6f1.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. ace.define("ace/mode/perl_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 PerlHighlightRules = function () {
  5. var keywords = ("base|constant|continue|else|elsif|for|foreach|format|goto|if|last|local|my|next|" +
  6. "no|package|parent|redo|require|scalar|sub|unless|until|while|use|vars");
  7. var buildinConstants = ("ARGV|ENV|INC|SIG");
  8. var builtinFunctions = ("getprotobynumber|getprotobyname|getservbyname|gethostbyaddr|" +
  9. "gethostbyname|getservbyport|getnetbyaddr|getnetbyname|getsockname|" +
  10. "getpeername|setpriority|getprotoent|setprotoent|getpriority|" +
  11. "endprotoent|getservent|setservent|endservent|sethostent|socketpair|" +
  12. "getsockopt|gethostent|endhostent|setsockopt|setnetent|quotemeta|" +
  13. "localtime|prototype|getnetent|endnetent|rewinddir|wantarray|getpwuid|" +
  14. "closedir|getlogin|readlink|endgrent|getgrgid|getgrnam|shmwrite|" +
  15. "shutdown|readline|endpwent|setgrent|readpipe|formline|truncate|" +
  16. "dbmclose|syswrite|setpwent|getpwnam|getgrent|getpwent|ucfirst|sysread|" +
  17. "setpgrp|shmread|sysseek|sysopen|telldir|defined|opendir|connect|" +
  18. "lcfirst|getppid|binmode|syscall|sprintf|getpgrp|readdir|seekdir|" +
  19. "waitpid|reverse|unshift|symlink|dbmopen|semget|msgrcv|rename|listen|" +
  20. "chroot|msgsnd|shmctl|accept|unpack|exists|fileno|shmget|system|" +
  21. "unlink|printf|gmtime|msgctl|semctl|values|rindex|substr|splice|" +
  22. "length|msgget|select|socket|return|caller|delete|alarm|ioctl|index|" +
  23. "undef|lstat|times|srand|chown|fcntl|close|write|umask|rmdir|study|" +
  24. "sleep|chomp|untie|print|utime|mkdir|atan2|split|crypt|flock|chmod|" +
  25. "BEGIN|bless|chdir|semop|shift|reset|link|stat|chop|grep|fork|dump|" +
  26. "join|open|tell|pipe|exit|glob|warn|each|bind|sort|pack|eval|push|" +
  27. "keys|getc|kill|seek|sqrt|send|wait|rand|tied|read|time|exec|recv|" +
  28. "eof|chr|int|ord|exp|pos|pop|sin|log|abs|oct|hex|tie|cos|vec|END|ref|" +
  29. "map|die|uc|lc|do");
  30. var keywordMapper = this.createKeywordMapper({
  31. "keyword": keywords,
  32. "constant.language": buildinConstants,
  33. "support.function": builtinFunctions
  34. }, "identifier");
  35. this.$rules = {
  36. "start": [
  37. {
  38. token: "comment.doc",
  39. regex: "^=(?:begin|item)\\b",
  40. next: "block_comment"
  41. }, {
  42. token: "string.regexp",
  43. regex: "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
  44. }, {
  45. token: "string",
  46. regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  47. }, {
  48. token: "string",
  49. regex: '["].*\\\\$',
  50. next: "qqstring"
  51. }, {
  52. token: "string",
  53. regex: "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  54. }, {
  55. token: "string",
  56. regex: "['].*\\\\$",
  57. next: "qstring"
  58. }, {
  59. token: "constant.numeric",
  60. regex: "0x[0-9a-fA-F]+\\b"
  61. }, {
  62. token: "constant.numeric",
  63. regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  64. }, {
  65. token: keywordMapper,
  66. regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  67. }, {
  68. token: "keyword.operator",
  69. regex: "%#|\\$#|\\.\\.\\.|\\|\\|=|>>=|<<=|<=>|&&=|=>|!~|\\^=|&=|\\|=|\\.=|x=|%=|\\/=|\\*=|\\-=|\\+=|=~|\\*\\*|\\-\\-|\\.\\.|\\|\\||&&|\\+\\+|\\->|!=|==|>=|<=|>>|<<|,|=|\\?\\:|\\^|\\||x|%|\\/|\\*|<|&|\\\\|~|!|>|\\.|\\-|\\+|\\-C|\\-b|\\-S|\\-u|\\-t|\\-p|\\-l|\\-d|\\-f|\\-g|\\-s|\\-z|\\-k|\\-e|\\-O|\\-T|\\-B|\\-M|\\-A|\\-X|\\-W|\\-c|\\-R|\\-o|\\-x|\\-w|\\-r|\\b(?:and|cmp|eq|ge|gt|le|lt|ne|not|or|xor)"
  70. }, {
  71. token: "comment",
  72. regex: "#.*$"
  73. }, {
  74. token: "lparen",
  75. regex: "[[({]"
  76. }, {
  77. token: "rparen",
  78. regex: "[\\])}]"
  79. }, {
  80. token: "text",
  81. regex: "\\s+"
  82. }
  83. ],
  84. "qqstring": [
  85. {
  86. token: "string",
  87. regex: '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
  88. next: "start"
  89. }, {
  90. token: "string",
  91. regex: '.+'
  92. }
  93. ],
  94. "qstring": [
  95. {
  96. token: "string",
  97. regex: "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
  98. next: "start"
  99. }, {
  100. token: "string",
  101. regex: '.+'
  102. }
  103. ],
  104. "block_comment": [
  105. {
  106. token: "comment.doc",
  107. regex: "^=cut\\b",
  108. next: "start"
  109. },
  110. {
  111. defaultToken: "comment.doc"
  112. }
  113. ]
  114. };
  115. };
  116. oop.inherits(PerlHighlightRules, TextHighlightRules);
  117. exports.PerlHighlightRules = PerlHighlightRules;
  118. });
  119. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
  120. var Range = require("../range").Range;
  121. var MatchingBraceOutdent = function () { };
  122. (function () {
  123. this.checkOutdent = function (line, input) {
  124. if (!/^\s+$/.test(line))
  125. return false;
  126. return /^\s*\}/.test(input);
  127. };
  128. this.autoOutdent = function (doc, row) {
  129. var line = doc.getLine(row);
  130. var match = line.match(/^(\s*\})/);
  131. if (!match)
  132. return 0;
  133. var column = match[1].length;
  134. var openBracePos = doc.findMatchingBracket({ row: row, column: column });
  135. if (!openBracePos || openBracePos.row == row)
  136. return 0;
  137. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  138. doc.replace(new Range(row, 0, row, column - 1), indent);
  139. };
  140. this.$getIndent = function (line) {
  141. return line.match(/^\s*/)[0];
  142. };
  143. }).call(MatchingBraceOutdent.prototype);
  144. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  145. });
  146. 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";
  147. var oop = require("../../lib/oop");
  148. var Range = require("../../range").Range;
  149. var BaseFoldMode = require("./fold_mode").FoldMode;
  150. var FoldMode = exports.FoldMode = function (commentRegex) {
  151. if (commentRegex) {
  152. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  153. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  154. }
  155. };
  156. oop.inherits(FoldMode, BaseFoldMode);
  157. (function () {
  158. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  159. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  160. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  161. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  162. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  163. this._getFoldWidgetBase = this.getFoldWidget;
  164. this.getFoldWidget = function (session, foldStyle, row) {
  165. var line = session.getLine(row);
  166. if (this.singleLineBlockCommentRe.test(line)) {
  167. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  168. return "";
  169. }
  170. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  171. if (!fw && this.startRegionRe.test(line))
  172. return "start"; // lineCommentRegionStart
  173. return fw;
  174. };
  175. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  176. var line = session.getLine(row);
  177. if (this.startRegionRe.test(line))
  178. return this.getCommentRegionBlock(session, line, row);
  179. var match = line.match(this.foldingStartMarker);
  180. if (match) {
  181. var i = match.index;
  182. if (match[1])
  183. return this.openingBracketBlock(session, match[1], row, i);
  184. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  185. if (range && !range.isMultiLine()) {
  186. if (forceMultiline) {
  187. range = this.getSectionRange(session, row);
  188. }
  189. else if (foldStyle != "all")
  190. range = null;
  191. }
  192. return range;
  193. }
  194. if (foldStyle === "markbegin")
  195. return;
  196. var match = line.match(this.foldingStopMarker);
  197. if (match) {
  198. var i = match.index + match[0].length;
  199. if (match[1])
  200. return this.closingBracketBlock(session, match[1], row, i);
  201. return session.getCommentFoldRange(row, i, -1);
  202. }
  203. };
  204. this.getSectionRange = function (session, row) {
  205. var line = session.getLine(row);
  206. var startIndent = line.search(/\S/);
  207. var startRow = row;
  208. var startColumn = line.length;
  209. row = row + 1;
  210. var endRow = row;
  211. var maxRow = session.getLength();
  212. while (++row < maxRow) {
  213. line = session.getLine(row);
  214. var indent = line.search(/\S/);
  215. if (indent === -1)
  216. continue;
  217. if (startIndent > indent)
  218. break;
  219. var subRange = this.getFoldWidgetRange(session, "all", row);
  220. if (subRange) {
  221. if (subRange.start.row <= startRow) {
  222. break;
  223. }
  224. else if (subRange.isMultiLine()) {
  225. row = subRange.end.row;
  226. }
  227. else if (startIndent == indent) {
  228. break;
  229. }
  230. }
  231. endRow = row;
  232. }
  233. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  234. };
  235. this.getCommentRegionBlock = function (session, line, row) {
  236. var startColumn = line.search(/\s*$/);
  237. var maxRow = session.getLength();
  238. var startRow = row;
  239. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  240. var depth = 1;
  241. while (++row < maxRow) {
  242. line = session.getLine(row);
  243. var m = re.exec(line);
  244. if (!m)
  245. continue;
  246. if (m[1])
  247. depth--;
  248. else
  249. depth++;
  250. if (!depth)
  251. break;
  252. }
  253. var endRow = row;
  254. if (endRow > startRow) {
  255. return new Range(startRow, startColumn, endRow, line.length);
  256. }
  257. };
  258. }).call(FoldMode.prototype);
  259. });
  260. ace.define("ace/mode/perl",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/perl_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
  261. var oop = require("../lib/oop");
  262. var TextMode = require("./text").Mode;
  263. var PerlHighlightRules = require("./perl_highlight_rules").PerlHighlightRules;
  264. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  265. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  266. var Mode = function () {
  267. this.HighlightRules = PerlHighlightRules;
  268. this.$outdent = new MatchingBraceOutdent();
  269. this.foldingRules = new CStyleFoldMode({ start: "^=(begin|item)\\b", end: "^=(cut)\\b" });
  270. this.$behaviour = this.$defaultBehaviour;
  271. };
  272. oop.inherits(Mode, TextMode);
  273. (function () {
  274. this.lineCommentStart = "#";
  275. this.blockComment = [
  276. { start: "=begin", end: "=cut", lineStartOnly: true },
  277. { start: "=item", end: "=cut", lineStartOnly: true }
  278. ];
  279. this.getNextLineIndent = function (state, line, tab) {
  280. var indent = this.$getIndent(line);
  281. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  282. var tokens = tokenizedLine.tokens;
  283. if (tokens.length && tokens[tokens.length - 1].type == "comment") {
  284. return indent;
  285. }
  286. if (state == "start") {
  287. var match = line.match(/^.*[\{\(\[:]\s*$/);
  288. if (match) {
  289. indent += tab;
  290. }
  291. }
  292. return indent;
  293. };
  294. this.checkOutdent = function (state, line, input) {
  295. return this.$outdent.checkOutdent(line, input);
  296. };
  297. this.autoOutdent = function (state, doc, row) {
  298. this.$outdent.autoOutdent(doc, row);
  299. };
  300. this.$id = "ace/mode/perl";
  301. this.snippetFileId = "ace/snippets/perl";
  302. }).call(Mode.prototype);
  303. exports.Mode = Mode;
  304. }); (function() {
  305. ace.require(["ace/mode/perl"], function(m) {
  306. if (typeof module == "object" && typeof exports == "object" && module) {
  307. module.exports = m;
  308. }
  309. });
  310. })();