Debian Codegraph @

extensions/CodeEditor/modules/lib/ace/mode-r.js

raw symbols SCIP
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, // non-command
52 regex: "\\\\[$&%#\\{\\}]"
53 }, {
54 token: "keyword", // command
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", // command
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, // non-command
78 regex: "\\\\[$&%#\\{\\}]"
79 }, {
80 token: "keyword", // command
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", // command
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 });
110
111 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){/*
112 * r_highlight_rules.js
113 *
114 * Copyright (C) 2009-11 by RStudio, Inc.
115 *
116 * The Initial Developer of the Original Code is
117 * Ajax.org B.V.
118 * Portions created by the Initial Developer are Copyright (C) 2010
119 * the Initial Developer. All Rights Reserved.
120 *
121 * Distributed under the BSD license:
122 *
123 * Copyright (c) 2010, Ajax.org B.V.
124 * All rights reserved.
125 *
126 * Redistribution and use in source and binary forms, with or without
127 * modification, are permitted provided that the following conditions are met:
128 * * Redistributions of source code must retain the above copyright
129 * notice, this list of conditions and the following disclaimer.
130 * * Redistributions in binary form must reproduce the above copyright
131 * notice, this list of conditions and the following disclaimer in the
132 * documentation and/or other materials provided with the distribution.
133 * * Neither the name of Ajax.org B.V. nor the
134 * names of its contributors may be used to endorse or promote products
135 * derived from this software without specific prior written permission.
136 *
137 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
138 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
139 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
140 * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
141 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
142 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
143 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
144 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
145 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
146 *
147 */
148 var oop = require("../lib/oop");
149 var lang = require("../lib/lang");
150 var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
151 var TexHighlightRules = require("./tex_highlight_rules").TexHighlightRules;
152 var RHighlightRules = function () {
153 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")
154 .split("|"));
155 var buildinConstants = lang.arrayToMap(("NULL|NA|TRUE|FALSE|T|F|Inf|NaN|NA_integer_|NA_real_|NA_character_|" +
156 "NA_complex_").split("|"));
157 this.$rules = {
158 "start": [
159 {
160 token: "comment.sectionhead",
161 regex: "#+(?!').*(?:----|====|####)\\s*$"
162 },
163 {
164 token: "comment",
165 regex: "#+'",
166 next: "rd-start"
167 },
168 {
169 token: "comment",
170 regex: "#.*$"
171 },
172 {
173 token: "string", // multi line string start
174 regex: '["]',
175 next: "qqstring"
176 },
177 {
178 token: "string", // multi line string start
179 regex: "[']",
180 next: "qstring"
181 },
182 {
183 token: "constant.numeric", // hex
184 regex: "0[xX][0-9a-fA-F]+[Li]?\\b"
185 },
186 {
187 token: "constant.numeric", // explicit integer
188 regex: "\\d+L\\b"
189 },
190 {
191 token: "constant.numeric", // number
192 regex: "\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d*)?i?\\b"
193 },
194 {
195 token: "constant.numeric", // number with leading decimal
196 regex: "\\.\\d+(?:[eE][+\\-]?\\d*)?i?\\b"
197 },
198 {
199 token: "constant.language.boolean",
200 regex: "(?:TRUE|FALSE|T|F)\\b"
201 },
202 {
203 token: "identifier",
204 regex: "`.*?`"
205 },
206 {
207 onMatch: function (value) {
208 if (keywords[value])
209 return "keyword";
210 else if (buildinConstants[value])
211 return "constant.language";
212 else if (value == '...' || value.match(/^\.\.\d+$/))
213 return "variable.language";
214 else
215 return "identifier";
216 },
217 regex: "[a-zA-Z.][a-zA-Z0-9._]*\\b"
218 },
219 {
220 token: "keyword.operator",
221 regex: "%%|>=|<=|==|!=|\\->|<\\-|\\|\\||&&|=|\\+|\\-|\\*|/|\\^|>|<|!|&|\\||~|\\$|:"
222 },
223 {
224 token: "keyword.operator", // infix operators
225 regex: "%.*?%"
226 },
227 {
228 token: "paren.keyword.operator",
229 regex: "[[({]"
230 },
231 {
232 token: "paren.keyword.operator",
233 regex: "[\\])}]"
234 },
235 {
236 token: "text",
237 regex: "\\s+"
238 }
239 ],
240 "qqstring": [
241 {
242 token: "string",
243 regex: '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
244 next: "start"
245 },
246 {
247 token: "string",
248 regex: '.+'
249 }
250 ],
251 "qstring": [
252 {
253 token: "string",
254 regex: "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
255 next: "start"
256 },
257 {
258 token: "string",
259 regex: '.+'
260 }
261 ]
262 };
263 var rdRules = new TexHighlightRules("comment").getRules();
264 for (var i = 0; i < rdRules["start"].length; i++) {
265 rdRules["start"][i].token += ".virtual-comment";
266 }
267 this.addRules(rdRules, "rd-");
268 this.$rules["rd-start"].unshift({
269 token: "text",
270 regex: "^",
271 next: "start"
272 });
273 this.$rules["rd-start"].unshift({
274 token: "keyword",
275 regex: "@(?!@)[^ ]*"
276 });
277 this.$rules["rd-start"].unshift({
278 token: "comment",
279 regex: "@@"
280 });
281 this.$rules["rd-start"].push({
282 token: "comment",
283 regex: "[^%\\\\[({\\])}]+"
284 });
285 };
286 oop.inherits(RHighlightRules, TextHighlightRules);
287 exports.RHighlightRules = RHighlightRules;
288
289 });
290
291 ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
292 var Range = require("../range").Range;
293 var MatchingBraceOutdent = function () { };
294 (function () {
295 this.checkOutdent = function (line, input) {
296 if (!/^\s+$/.test(line))
297 return false;
298 return /^\s*\}/.test(input);
299 };
300 this.autoOutdent = function (doc, row) {
301 var line = doc.getLine(row);
302 var match = line.match(/^(\s*\})/);
303 if (!match)
304 return 0;
305 var column = match[1].length;
306 var openBracePos = doc.findMatchingBracket({ row: row, column: column });
307 if (!openBracePos || openBracePos.row == row)
308 return 0;
309 var indent = this.$getIndent(doc.getLine(openBracePos.row));
310 doc.replace(new Range(row, 0, row, column - 1), indent);
311 };
312 this.$getIndent = function (line) {
313 return line.match(/^\s*/)[0];
314 };
315 }).call(MatchingBraceOutdent.prototype);
316 exports.MatchingBraceOutdent = MatchingBraceOutdent;
317
318 });
319
320 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){/*
321 * r.js
322 *
323 * Copyright (C) 2009-11 by RStudio, Inc.
324 *
325 * The Initial Developer of the Original Code is
326 * Ajax.org B.V.
327 * Portions created by the Initial Developer are Copyright (C) 2010
328 * the Initial Developer. All Rights Reserved.
329 *
330 * Distributed under the BSD license:
331 *
332 * Copyright (c) 2010, Ajax.org B.V.
333 * All rights reserved.
334 *
335 * Redistribution and use in source and binary forms, with or without
336 * modification, are permitted provided that the following conditions are met:
337 * * Redistributions of source code must retain the above copyright
338 * notice, this list of conditions and the following disclaimer.
339 * * Redistributions in binary form must reproduce the above copyright
340 * notice, this list of conditions and the following disclaimer in the
341 * documentation and/or other materials provided with the distribution.
342 * * Neither the name of Ajax.org B.V. nor the
343 * names of its contributors may be used to endorse or promote products
344 * derived from this software without specific prior written permission.
345 *
346 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
347 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
348 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
349 * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
350 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
351 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
352 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
353 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
354 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
355 *
356 */
357 "use strict";
358 var unicode = require("../unicode");
359 var Range = require("../range").Range;
360 var oop = require("../lib/oop");
361 var TextMode = require("./text").Mode;
362 var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
363 var RHighlightRules = require("./r_highlight_rules").RHighlightRules;
364 var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
365 var Mode = function () {
366 this.HighlightRules = RHighlightRules;
367 this.$outdent = new MatchingBraceOutdent();
368 this.$behaviour = this.$defaultBehaviour;
369 };
370 oop.inherits(Mode, TextMode);
371 (function () {
372 this.lineCommentStart = "#";
373 this.tokenRe = new RegExp("^[" + unicode.wordChars + "._]+", "g");
374 this.nonTokenRe = new RegExp("^(?:[^" + unicode.wordChars + "._]|\s])+", "g");
375 this.$id = "ace/mode/r";
376 this.snippetFileId = "ace/snippets/r";
377 }).call(Mode.prototype);
378 exports.Mode = Mode;
379
380 }); (function() {
381 ace.require(["ace/mode/r"], function(m) {
382 if (typeof module == "object" && typeof exports == "object" && module) {
383 module.exports = m;
384 }
385 });
386 })();
387