Debian Codegraph @

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

raw symbols SCIP
1 ace.define("ace/mode/doc_comment_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 DocCommentHighlightRules = function () {
5 this.$rules = {
6 "start": [
7 {
8 token: "comment.doc.tag",
9 regex: "@\\w+(?=\\s|$)"
10 }, DocCommentHighlightRules.getTagRule(), {
11 defaultToken: "comment.doc",
12 caseInsensitive: true
13 }
14 ]
15 };
16 };
17 oop.inherits(DocCommentHighlightRules, TextHighlightRules);
18 DocCommentHighlightRules.getTagRule = function (start) {
19 return {
20 token: "comment.doc.tag.storage.type",
21 regex: "\\b(?:TODO|FIXME|XXX|HACK)\\b"
22 };
23 };
24 DocCommentHighlightRules.getStartRule = function (start) {
25 return {
26 token: "comment.doc", // doc comment
27 regex: "\\/\\*(?=\\*)",
28 next: start
29 };
30 };
31 DocCommentHighlightRules.getEndRule = function (start) {
32 return {
33 token: "comment.doc", // closing comment
34 regex: "\\*\\/",
35 next: start
36 };
37 };
38 exports.DocCommentHighlightRules = DocCommentHighlightRules;
39
40 });
41
42 ace.define("ace/mode/scad_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
43 var oop = require("../lib/oop");
44 var lang = require("../lib/lang");
45 var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
46 var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
47 var scadHighlightRules = function () {
48 var keywordMapper = this.createKeywordMapper({
49 "variable.language": "this",
50 "keyword": "module|if|else|for",
51 "constant.language": "NULL"
52 }, "identifier");
53 this.$rules = {
54 "start": [
55 {
56 token: "comment",
57 regex: "\\/\\/.*$"
58 },
59 DocCommentHighlightRules.getStartRule("start"),
60 {
61 token: "comment", // multi line comment
62 regex: "\\/\\*",
63 next: "comment"
64 }, {
65 token: "string", // single line
66 regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
67 }, {
68 token: "string", // multi line string start
69 regex: '["].*\\\\$',
70 next: "qqstring"
71 }, {
72 token: "string", // single line
73 regex: "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
74 }, {
75 token: "string", // multi line string start
76 regex: "['].*\\\\$",
77 next: "qstring"
78 }, {
79 token: "constant.numeric", // hex
80 regex: "0[xX][0-9a-fA-F]+\\b"
81 }, {
82 token: "constant.numeric", // float
83 regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
84 }, {
85 token: "constant", // <CONSTANT>
86 regex: "<[a-zA-Z0-9.]+>"
87 }, {
88 token: "keyword", // pre-compiler directivs
89 regex: "(?:use|include)"
90 }, {
91 token: keywordMapper,
92 regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
93 }, {
94 token: "keyword.operator",
95 regex: "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|new|delete|typeof|void)"
96 }, {
97 token: "paren.lparen",
98 regex: "[[({]"
99 }, {
100 token: "paren.rparen",
101 regex: "[\\])}]"
102 }, {
103 token: "text",
104 regex: "\\s+"
105 }
106 ],
107 "comment": [
108 {
109 token: "comment", // closing comment
110 regex: "\\*\\/",
111 next: "start"
112 }, {
113 defaultToken: "comment"
114 }
115 ],
116 "qqstring": [
117 {
118 token: "string",
119 regex: '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
120 next: "start"
121 }, {
122 token: "string",
123 regex: '.+'
124 }
125 ],
126 "qstring": [
127 {
128 token: "string",
129 regex: "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
130 next: "start"
131 }, {
132 token: "string",
133 regex: '.+'
134 }
135 ]
136 };
137 this.embedRules(DocCommentHighlightRules, "doc-", [DocCommentHighlightRules.getEndRule("start")]);
138 };
139 oop.inherits(scadHighlightRules, TextHighlightRules);
140 exports.scadHighlightRules = scadHighlightRules;
141
142 });
143
144 ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
145 var Range = require("../range").Range;
146 var MatchingBraceOutdent = function () { };
147 (function () {
148 this.checkOutdent = function (line, input) {
149 if (!/^\s+$/.test(line))
150 return false;
151 return /^\s*\}/.test(input);
152 };
153 this.autoOutdent = function (doc, row) {
154 var line = doc.getLine(row);
155 var match = line.match(/^(\s*\})/);
156 if (!match)
157 return 0;
158 var column = match[1].length;
159 var openBracePos = doc.findMatchingBracket({ row: row, column: column });
160 if (!openBracePos || openBracePos.row == row)
161 return 0;
162 var indent = this.$getIndent(doc.getLine(openBracePos.row));
163 doc.replace(new Range(row, 0, row, column - 1), indent);
164 };
165 this.$getIndent = function (line) {
166 return line.match(/^\s*/)[0];
167 };
168 }).call(MatchingBraceOutdent.prototype);
169 exports.MatchingBraceOutdent = MatchingBraceOutdent;
170
171 });
172
173 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";
174 var oop = require("../../lib/oop");
175 var Range = require("../../range").Range;
176 var BaseFoldMode = require("./fold_mode").FoldMode;
177 var FoldMode = exports.FoldMode = function (commentRegex) {
178 if (commentRegex) {
179 this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
180 this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
181 }
182 };
183 oop.inherits(FoldMode, BaseFoldMode);
184 (function () {
185 this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
186 this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
187 this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
188 this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
189 this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
190 this._getFoldWidgetBase = this.getFoldWidget;
191 this.getFoldWidget = function (session, foldStyle, row) {
192 var line = session.getLine(row);
193 if (this.singleLineBlockCommentRe.test(line)) {
194 if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
195 return "";
196 }
197 var fw = this._getFoldWidgetBase(session, foldStyle, row);
198 if (!fw && this.startRegionRe.test(line))
199 return "start"; // lineCommentRegionStart
200 return fw;
201 };
202 this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
203 var line = session.getLine(row);
204 if (this.startRegionRe.test(line))
205 return this.getCommentRegionBlock(session, line, row);
206 var match = line.match(this.foldingStartMarker);
207 if (match) {
208 var i = match.index;
209 if (match[1])
210 return this.openingBracketBlock(session, match[1], row, i);
211 var range = session.getCommentFoldRange(row, i + match[0].length, 1);
212 if (range && !range.isMultiLine()) {
213 if (forceMultiline) {
214 range = this.getSectionRange(session, row);
215 }
216 else if (foldStyle != "all")
217 range = null;
218 }
219 return range;
220 }
221 if (foldStyle === "markbegin")
222 return;
223 var match = line.match(this.foldingStopMarker);
224 if (match) {
225 var i = match.index + match[0].length;
226 if (match[1])
227 return this.closingBracketBlock(session, match[1], row, i);
228 return session.getCommentFoldRange(row, i, -1);
229 }
230 };
231 this.getSectionRange = function (session, row) {
232 var line = session.getLine(row);
233 var startIndent = line.search(/\S/);
234 var startRow = row;
235 var startColumn = line.length;
236 row = row + 1;
237 var endRow = row;
238 var maxRow = session.getLength();
239 while (++row < maxRow) {
240 line = session.getLine(row);
241 var indent = line.search(/\S/);
242 if (indent === -1)
243 continue;
244 if (startIndent > indent)
245 break;
246 var subRange = this.getFoldWidgetRange(session, "all", row);
247 if (subRange) {
248 if (subRange.start.row <= startRow) {
249 break;
250 }
251 else if (subRange.isMultiLine()) {
252 row = subRange.end.row;
253 }
254 else if (startIndent == indent) {
255 break;
256 }
257 }
258 endRow = row;
259 }
260 return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
261 };
262 this.getCommentRegionBlock = function (session, line, row) {
263 var startColumn = line.search(/\s*$/);
264 var maxRow = session.getLength();
265 var startRow = row;
266 var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
267 var depth = 1;
268 while (++row < maxRow) {
269 line = session.getLine(row);
270 var m = re.exec(line);
271 if (!m)
272 continue;
273 if (m[1])
274 depth--;
275 else
276 depth++;
277 if (!depth)
278 break;
279 }
280 var endRow = row;
281 if (endRow > startRow) {
282 return new Range(startRow, startColumn, endRow, line.length);
283 }
284 };
285 }).call(FoldMode.prototype);
286
287 });
288
289 ace.define("ace/mode/scad",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/scad_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
290 var oop = require("../lib/oop");
291 var TextMode = require("./text").Mode;
292 var scadHighlightRules = require("./scad_highlight_rules").scadHighlightRules;
293 var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
294 var CStyleFoldMode = require("./folding/cstyle").FoldMode;
295 var Mode = function () {
296 this.HighlightRules = scadHighlightRules;
297 this.$outdent = new MatchingBraceOutdent();
298 this.$behaviour = this.$defaultBehaviour;
299 this.foldingRules = new CStyleFoldMode();
300 };
301 oop.inherits(Mode, TextMode);
302 (function () {
303 this.lineCommentStart = "//";
304 this.blockComment = { start: "/*", end: "*/" };
305 this.getNextLineIndent = function (state, line, tab) {
306 var indent = this.$getIndent(line);
307 var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
308 var tokens = tokenizedLine.tokens;
309 var endState = tokenizedLine.state;
310 if (tokens.length && tokens[tokens.length - 1].type == "comment") {
311 return indent;
312 }
313 if (state == "start") {
314 var match = line.match(/^.*[\{\(\[]\s*$/);
315 if (match) {
316 indent += tab;
317 }
318 }
319 else if (state == "doc-start") {
320 if (endState == "start") {
321 return "";
322 }
323 var match = line.match(/^\s*(\/?)\*/);
324 if (match) {
325 if (match[1]) {
326 indent += " ";
327 }
328 indent += "* ";
329 }
330 }
331 return indent;
332 };
333 this.checkOutdent = function (state, line, input) {
334 return this.$outdent.checkOutdent(line, input);
335 };
336 this.autoOutdent = function (state, doc, row) {
337 this.$outdent.autoOutdent(doc, row);
338 };
339 this.$id = "ace/mode/scad";
340 }).call(Mode.prototype);
341 exports.Mode = Mode;
342
343 }); (function() {
344 ace.require(["ace/mode/scad"], function(m) {
345 if (typeof module == "object" && typeof exports == "object" && module) {
346 module.exports = m;
347 }
348 });
349 })();
350