0645227e6c2479f7aefed1fdd23ac733.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. ace.define("ace/mode/tex_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"], function(require, exports, module){/*
  2. * tex_highlight_rules.js
  3. *
  4. * Copyright (C) 2009-11 by RStudio, Inc.
  5. *
  6. * The Initial Developer of the Original Code is
  7. * Ajax.org B.V.
  8. * Portions created by the Initial Developer are Copyright (C) 2010
  9. * the Initial Developer. All Rights Reserved.
  10. *
  11. * Distributed under the BSD license:
  12. *
  13. * Copyright (c) 2010, Ajax.org B.V.
  14. * All rights reserved.
  15. *
  16. * Redistribution and use in source and binary forms, with or without
  17. * modification, are permitted provided that the following conditions are met:
  18. * * Redistributions of source code must retain the above copyright
  19. * notice, this list of conditions and the following disclaimer.
  20. * * Redistributions in binary form must reproduce the above copyright
  21. * notice, this list of conditions and the following disclaimer in the
  22. * documentation and/or other materials provided with the distribution.
  23. * * Neither the name of Ajax.org B.V. nor the
  24. * names of its contributors may be used to endorse or promote products
  25. * derived from this software without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  28. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  29. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  30. * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
  31. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  32. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  33. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  34. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  35. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  36. *
  37. */
  38. "use strict";
  39. var oop = require("../lib/oop");
  40. var lang = require("../lib/lang");
  41. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  42. var TexHighlightRules = function (textClass) {
  43. if (!textClass)
  44. textClass = "text";
  45. this.$rules = {
  46. "start": [
  47. {
  48. token: "comment",
  49. regex: "%.*$"
  50. }, {
  51. token: textClass,
  52. regex: "\\\\[$&%#\\{\\}]"
  53. }, {
  54. token: "keyword",
  55. regex: "\\\\(?:documentclass|usepackage|newcounter|setcounter|addtocounter|value|arabic|stepcounter|newenvironment|renewenvironment|ref|vref|eqref|pageref|label|cite[a-zA-Z]*|tag|begin|end|bibitem)\\b",
  56. next: "nospell"
  57. }, {
  58. token: "keyword",
  59. regex: "\\\\(?:[a-zA-Z0-9]+|[^a-zA-Z0-9])"
  60. }, {
  61. token: "paren.keyword.operator",
  62. regex: "[[({]"
  63. }, {
  64. token: "paren.keyword.operator",
  65. regex: "[\\])}]"
  66. }, {
  67. token: textClass,
  68. regex: "\\s+"
  69. }
  70. ],
  71. "nospell": [
  72. {
  73. token: "comment",
  74. regex: "%.*$",
  75. next: "start"
  76. }, {
  77. token: "nospell." + textClass,
  78. regex: "\\\\[$&%#\\{\\}]"
  79. }, {
  80. token: "keyword",
  81. regex: "\\\\(?:documentclass|usepackage|newcounter|setcounter|addtocounter|value|arabic|stepcounter|newenvironment|renewenvironment|ref|vref|eqref|pageref|label|cite[a-zA-Z]*|tag|begin|end|bibitem)\\b"
  82. }, {
  83. token: "keyword",
  84. regex: "\\\\(?:[a-zA-Z0-9]+|[^a-zA-Z0-9])",
  85. next: "start"
  86. }, {
  87. token: "paren.keyword.operator",
  88. regex: "[[({]"
  89. }, {
  90. token: "paren.keyword.operator",
  91. regex: "[\\])]"
  92. }, {
  93. token: "paren.keyword.operator",
  94. regex: "}",
  95. next: "start"
  96. }, {
  97. token: "nospell." + textClass,
  98. regex: "\\s+"
  99. }, {
  100. token: "nospell." + textClass,
  101. regex: "\\w+"
  102. }
  103. ]
  104. };
  105. };
  106. oop.inherits(TexHighlightRules, TextHighlightRules);
  107. exports.TexHighlightRules = TexHighlightRules;
  108. });
  109. ace.define("ace/mode/r_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules","ace/mode/tex_highlight_rules"], function(require, exports, module){/*
  110. * r_highlight_rules.js
  111. *
  112. * Copyright (C) 2009-11 by RStudio, Inc.
  113. *
  114. * The Initial Developer of the Original Code is
  115. * Ajax.org B.V.
  116. * Portions created by the Initial Developer are Copyright (C) 2010
  117. * the Initial Developer. All Rights Reserved.
  118. *
  119. * Distributed under the BSD license:
  120. *
  121. * Copyright (c) 2010, Ajax.org B.V.
  122. * All rights reserved.
  123. *
  124. * Redistribution and use in source and binary forms, with or without
  125. * modification, are permitted provided that the following conditions are met:
  126. * * Redistributions of source code must retain the above copyright
  127. * notice, this list of conditions and the following disclaimer.
  128. * * Redistributions in binary form must reproduce the above copyright
  129. * notice, this list of conditions and the following disclaimer in the
  130. * documentation and/or other materials provided with the distribution.
  131. * * Neither the name of Ajax.org B.V. nor the
  132. * names of its contributors may be used to endorse or promote products
  133. * derived from this software without specific prior written permission.
  134. *
  135. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  136. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  137. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  138. * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
  139. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  140. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  141. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  142. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  143. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  144. *
  145. */
  146. var oop = require("../lib/oop");
  147. var lang = require("../lib/lang");
  148. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  149. var TexHighlightRules = require("./tex_highlight_rules").TexHighlightRules;
  150. var RHighlightRules = function () {
  151. var keywords = lang.arrayToMap(("function|if|in|break|next|repeat|else|for|return|switch|while|try|tryCatch|stop|warning|require|library|attach|detach|source|setMethod|setGeneric|setGroupGeneric|setClass")
  152. .split("|"));
  153. var buildinConstants = lang.arrayToMap(("NULL|NA|TRUE|FALSE|T|F|Inf|NaN|NA_integer_|NA_real_|NA_character_|" +
  154. "NA_complex_").split("|"));
  155. this.$rules = {
  156. "start": [
  157. {
  158. token: "comment.sectionhead",
  159. regex: "#+(?!').*(?:----|====|####)\\s*$"
  160. },
  161. {
  162. token: "comment",
  163. regex: "#+'",
  164. next: "rd-start"
  165. },
  166. {
  167. token: "comment",
  168. regex: "#.*$"
  169. },
  170. {
  171. token: "string",
  172. regex: '["]',
  173. next: "qqstring"
  174. },
  175. {
  176. token: "string",
  177. regex: "[']",
  178. next: "qstring"
  179. },
  180. {
  181. token: "constant.numeric",
  182. regex: "0[xX][0-9a-fA-F]+[Li]?\\b"
  183. },
  184. {
  185. token: "constant.numeric",
  186. regex: "\\d+L\\b"
  187. },
  188. {
  189. token: "constant.numeric",
  190. regex: "\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d*)?i?\\b"
  191. },
  192. {
  193. token: "constant.numeric",
  194. regex: "\\.\\d+(?:[eE][+\\-]?\\d*)?i?\\b"
  195. },
  196. {
  197. token: "constant.language.boolean",
  198. regex: "(?:TRUE|FALSE|T|F)\\b"
  199. },
  200. {
  201. token: "identifier",
  202. regex: "`.*?`"
  203. },
  204. {
  205. onMatch: function (value) {
  206. if (keywords[value])
  207. return "keyword";
  208. else if (buildinConstants[value])
  209. return "constant.language";
  210. else if (value == '...' || value.match(/^\.\.\d+$/))
  211. return "variable.language";
  212. else
  213. return "identifier";
  214. },
  215. regex: "[a-zA-Z.][a-zA-Z0-9._]*\\b"
  216. },
  217. {
  218. token: "keyword.operator",
  219. regex: "%%|>=|<=|==|!=|\\->|<\\-|\\|\\||&&|=|\\+|\\-|\\*|/|\\^|>|<|!|&|\\||~|\\$|:"
  220. },
  221. {
  222. token: "keyword.operator",
  223. regex: "%.*?%"
  224. },
  225. {
  226. token: "paren.keyword.operator",
  227. regex: "[[({]"
  228. },
  229. {
  230. token: "paren.keyword.operator",
  231. regex: "[\\])}]"
  232. },
  233. {
  234. token: "text",
  235. regex: "\\s+"
  236. }
  237. ],
  238. "qqstring": [
  239. {
  240. token: "string",
  241. regex: '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
  242. next: "start"
  243. },
  244. {
  245. token: "string",
  246. regex: '.+'
  247. }
  248. ],
  249. "qstring": [
  250. {
  251. token: "string",
  252. regex: "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
  253. next: "start"
  254. },
  255. {
  256. token: "string",
  257. regex: '.+'
  258. }
  259. ]
  260. };
  261. var rdRules = new TexHighlightRules("comment").getRules();
  262. for (var i = 0; i < rdRules["start"].length; i++) {
  263. rdRules["start"][i].token += ".virtual-comment";
  264. }
  265. this.addRules(rdRules, "rd-");
  266. this.$rules["rd-start"].unshift({
  267. token: "text",
  268. regex: "^",
  269. next: "start"
  270. });
  271. this.$rules["rd-start"].unshift({
  272. token: "keyword",
  273. regex: "@(?!@)[^ ]*"
  274. });
  275. this.$rules["rd-start"].unshift({
  276. token: "comment",
  277. regex: "@@"
  278. });
  279. this.$rules["rd-start"].push({
  280. token: "comment",
  281. regex: "[^%\\\\[({\\])}]+"
  282. });
  283. };
  284. oop.inherits(RHighlightRules, TextHighlightRules);
  285. exports.RHighlightRules = RHighlightRules;
  286. });
  287. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
  288. var Range = require("../range").Range;
  289. var MatchingBraceOutdent = function () { };
  290. (function () {
  291. this.checkOutdent = function (line, input) {
  292. if (!/^\s+$/.test(line))
  293. return false;
  294. return /^\s*\}/.test(input);
  295. };
  296. this.autoOutdent = function (doc, row) {
  297. var line = doc.getLine(row);
  298. var match = line.match(/^(\s*\})/);
  299. if (!match)
  300. return 0;
  301. var column = match[1].length;
  302. var openBracePos = doc.findMatchingBracket({ row: row, column: column });
  303. if (!openBracePos || openBracePos.row == row)
  304. return 0;
  305. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  306. doc.replace(new Range(row, 0, row, column - 1), indent);
  307. };
  308. this.$getIndent = function (line) {
  309. return line.match(/^\s*/)[0];
  310. };
  311. }).call(MatchingBraceOutdent.prototype);
  312. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  313. });
  314. ace.define("ace/mode/r",["require","exports","module","ace/unicode","ace/range","ace/lib/oop","ace/mode/text","ace/mode/text_highlight_rules","ace/mode/r_highlight_rules","ace/mode/matching_brace_outdent"], function(require, exports, module){/*
  315. * r.js
  316. *
  317. * Copyright (C) 2009-11 by RStudio, Inc.
  318. *
  319. * The Initial Developer of the Original Code is
  320. * Ajax.org B.V.
  321. * Portions created by the Initial Developer are Copyright (C) 2010
  322. * the Initial Developer. All Rights Reserved.
  323. *
  324. * Distributed under the BSD license:
  325. *
  326. * Copyright (c) 2010, Ajax.org B.V.
  327. * All rights reserved.
  328. *
  329. * Redistribution and use in source and binary forms, with or without
  330. * modification, are permitted provided that the following conditions are met:
  331. * * Redistributions of source code must retain the above copyright
  332. * notice, this list of conditions and the following disclaimer.
  333. * * Redistributions in binary form must reproduce the above copyright
  334. * notice, this list of conditions and the following disclaimer in the
  335. * documentation and/or other materials provided with the distribution.
  336. * * Neither the name of Ajax.org B.V. nor the
  337. * names of its contributors may be used to endorse or promote products
  338. * derived from this software without specific prior written permission.
  339. *
  340. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  341. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  342. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  343. * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
  344. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  345. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  346. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  347. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  348. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  349. *
  350. */
  351. "use strict";
  352. var unicode = require("../unicode");
  353. var Range = require("../range").Range;
  354. var oop = require("../lib/oop");
  355. var TextMode = require("./text").Mode;
  356. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  357. var RHighlightRules = require("./r_highlight_rules").RHighlightRules;
  358. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  359. var Mode = function () {
  360. this.HighlightRules = RHighlightRules;
  361. this.$outdent = new MatchingBraceOutdent();
  362. this.$behaviour = this.$defaultBehaviour;
  363. };
  364. oop.inherits(Mode, TextMode);
  365. (function () {
  366. this.lineCommentStart = "#";
  367. this.tokenRe = new RegExp("^[" + unicode.wordChars + "._]+", "g");
  368. this.nonTokenRe = new RegExp("^(?:[^" + unicode.wordChars + "._]|\s])+", "g");
  369. this.$id = "ace/mode/r";
  370. this.snippetFileId = "ace/snippets/r";
  371. }).call(Mode.prototype);
  372. exports.Mode = Mode;
  373. }); (function() {
  374. ace.require(["ace/mode/r"], function(m) {
  375. if (typeof module == "object" && typeof exports == "object" && module) {
  376. module.exports = m;
  377. }
  378. });
  379. })();