Debian Codegraph @

extensions/CodeEditor/modules/lib/ace/mode-sac.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/sac_highlight_rules",["require","exports","module","ace/lib/oop","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 DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
45 var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
46 var sacHighlightRules = function () {
47 var keywordControls = ("break|continue|do|else|for|if|" +
48 "return|with|while|use|class|all|void");
49 var storageType = ("bool|char|complex|double|float|" +
50 "byte|int|short|long|longlong|" +
51 "ubyte|uint|ushort|ulong|ulonglong|" +
52 "struct|typedef");
53 var storageModifiers = ("inline|external|specialize");
54 var keywordOperators = ("step|width");
55 var builtinConstants = ("true|false");
56 var keywordMapper = this.$keywords = this.createKeywordMapper({
57 "keyword.control": keywordControls,
58 "storage.type": storageType,
59 "storage.modifier": storageModifiers,
60 "keyword.operator": keywordOperators,
61 "constant.language": builtinConstants
62 }, "identifier");
63 var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
64 var escapeRe = /\\(?:['"?\\abfnrtv]|[0-7]{1,3}|x[a-fA-F\d]{2}|u[a-fA-F\d]{4}U[a-fA-F\d]{8}|.)/.source;
65 var formatRe = "%"
66 + /(\d+\$)?/.source // field (argument #)
67 + /[#0\- +']*/.source // flags
68 + /[,;:_]?/.source // separator character (AltiVec)
69 + /((-?\d+)|\*(-?\d+\$)?)?/.source // minimum field width
70 + /(\.((-?\d+)|\*(-?\d+\$)?)?)?/.source // precision
71 + /(hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)?/.source // length modifier
72 + /(\[[^"\]]+\]|[diouxXDOUeEfFgGaACcSspn%])/.source; // conversion type
73 this.$rules = {
74 "start": [
75 {
76 token: "comment",
77 regex: "//$",
78 next: "start"
79 }, {
80 token: "comment",
81 regex: "//",
82 next: "singleLineComment"
83 },
84 DocCommentHighlightRules.getStartRule("doc-start"),
85 {
86 token: "comment", // multi line comment
87 regex: "\\/\\*",
88 next: "comment"
89 }, {
90 token: "string", // character
91 regex: "'(?:" + escapeRe + "|.)?'"
92 }, {
93 token: "string.start",
94 regex: '"',
95 stateName: "qqstring",
96 next: [
97 { token: "string", regex: /\\\s*$/, next: "qqstring" },
98 { token: "constant.language.escape", regex: escapeRe },
99 { token: "constant.language.escape", regex: formatRe },
100 { token: "string.end", regex: '"|$', next: "start" },
101 { defaultToken: "string" }
102 ]
103 }, {
104 token: "string.start",
105 regex: 'R"\\(',
106 stateName: "rawString",
107 next: [
108 { token: "string.end", regex: '\\)"', next: "start" },
109 { defaultToken: "string" }
110 ]
111 }, {
112 token: "constant.numeric", // hex
113 regex: "0[xX][0-9a-fA-F]+(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b"
114 }, {
115 token: "constant.numeric", // float
116 regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b"
117 }, {
118 token: "keyword", // pre-compiler directives
119 regex: "#\\s*(?:include|import|pragma|line|define|undef)\\b",
120 next: "directive"
121 }, {
122 token: "keyword", // special case pre-compiler directive
123 regex: "#\\s*(?:endif|if|ifdef|else|elif|ifndef)\\b"
124 }, {
125 token: "support.function",
126 regex: "fold|foldfix|genarray|modarray|propagate"
127 }, {
128 token: keywordMapper,
129 regex: "[a-zA-Z_$][a-zA-Z0-9_$]*"
130 }, {
131 token: "keyword.operator",
132 regex: /--|\+\+|<<=|>>=|>>>=|<>|&&|\|\||\?:|[*%\/+\-&\^|~!<>=]=?/
133 }, {
134 token: "punctuation.operator",
135 regex: "\\?|\\:|\\,|\\;|\\."
136 }, {
137 token: "paren.lparen",
138 regex: "[[({]"
139 }, {
140 token: "paren.rparen",
141 regex: "[\\])}]"
142 }, {
143 token: "text",
144 regex: "\\s+"
145 }
146 ],
147 "comment": [
148 {
149 token: "comment", // closing comment
150 regex: "\\*\\/",
151 next: "start"
152 }, {
153 defaultToken: "comment"
154 }
155 ],
156 "singleLineComment": [
157 {
158 token: "comment",
159 regex: /\\$/,
160 next: "singleLineComment"
161 }, {
162 token: "comment",
163 regex: /$/,
164 next: "start"
165 }, {
166 defaultToken: "comment"
167 }
168 ],
169 "directive": [
170 {
171 token: "constant.other.multiline",
172 regex: /\\/
173 },
174 {
175 token: "constant.other.multiline",
176 regex: /.*\\/
177 },
178 {
179 token: "constant.other",
180 regex: "\\s*<.+?>",
181 next: "start"
182 },
183 {
184 token: "constant.other", // single line
185 regex: '\\s*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]',
186 next: "start"
187 },
188 {
189 token: "constant.other", // single line
190 regex: "\\s*['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']",
191 next: "start"
192 },
193 {
194 token: "constant.other",
195 regex: /[^\\\/]+/,
196 next: "start"
197 }
198 ]
199 };
200 this.embedRules(DocCommentHighlightRules, "doc-", [DocCommentHighlightRules.getEndRule("start")]);
201 this.normalizeRules();
202 };
203 oop.inherits(sacHighlightRules, TextHighlightRules);
204 exports.sacHighlightRules = sacHighlightRules;
205
206 });
207
208 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";
209 var oop = require("../../lib/oop");
210 var Range = require("../../range").Range;
211 var BaseFoldMode = require("./fold_mode").FoldMode;
212 var FoldMode = exports.FoldMode = function (commentRegex) {
213 if (commentRegex) {
214 this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
215 this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
216 }
217 };
218 oop.inherits(FoldMode, BaseFoldMode);
219 (function () {
220 this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
221 this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
222 this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
223 this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
224 this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
225 this._getFoldWidgetBase = this.getFoldWidget;
226 this.getFoldWidget = function (session, foldStyle, row) {
227 var line = session.getLine(row);
228 if (this.singleLineBlockCommentRe.test(line)) {
229 if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
230 return "";
231 }
232 var fw = this._getFoldWidgetBase(session, foldStyle, row);
233 if (!fw && this.startRegionRe.test(line))
234 return "start"; // lineCommentRegionStart
235 return fw;
236 };
237 this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
238 var line = session.getLine(row);
239 if (this.startRegionRe.test(line))
240 return this.getCommentRegionBlock(session, line, row);
241 var match = line.match(this.foldingStartMarker);
242 if (match) {
243 var i = match.index;
244 if (match[1])
245 return this.openingBracketBlock(session, match[1], row, i);
246 var range = session.getCommentFoldRange(row, i + match[0].length, 1);
247 if (range && !range.isMultiLine()) {
248 if (forceMultiline) {
249 range = this.getSectionRange(session, row);
250 }
251 else if (foldStyle != "all")
252 range = null;
253 }
254 return range;
255 }
256 if (foldStyle === "markbegin")
257 return;
258 var match = line.match(this.foldingStopMarker);
259 if (match) {
260 var i = match.index + match[0].length;
261 if (match[1])
262 return this.closingBracketBlock(session, match[1], row, i);
263 return session.getCommentFoldRange(row, i, -1);
264 }
265 };
266 this.getSectionRange = function (session, row) {
267 var line = session.getLine(row);
268 var startIndent = line.search(/\S/);
269 var startRow = row;
270 var startColumn = line.length;
271 row = row + 1;
272 var endRow = row;
273 var maxRow = session.getLength();
274 while (++row < maxRow) {
275 line = session.getLine(row);
276 var indent = line.search(/\S/);
277 if (indent === -1)
278 continue;
279 if (startIndent > indent)
280 break;
281 var subRange = this.getFoldWidgetRange(session, "all", row);
282 if (subRange) {
283 if (subRange.start.row <= startRow) {
284 break;
285 }
286 else if (subRange.isMultiLine()) {
287 row = subRange.end.row;
288 }
289 else if (startIndent == indent) {
290 break;
291 }
292 }
293 endRow = row;
294 }
295 return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
296 };
297 this.getCommentRegionBlock = function (session, line, row) {
298 var startColumn = line.search(/\s*$/);
299 var maxRow = session.getLength();
300 var startRow = row;
301 var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
302 var depth = 1;
303 while (++row < maxRow) {
304 line = session.getLine(row);
305 var m = re.exec(line);
306 if (!m)
307 continue;
308 if (m[1])
309 depth--;
310 else
311 depth++;
312 if (!depth)
313 break;
314 }
315 var endRow = row;
316 if (endRow > startRow) {
317 return new Range(startRow, startColumn, endRow, line.length);
318 }
319 };
320 }).call(FoldMode.prototype);
321
322 });
323
324 ace.define("ace/mode/sac",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/sac_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
325 var oop = require("../lib/oop");
326 var TextMode = require("./text").Mode;
327 var SaCHighlightRules = require("./sac_highlight_rules").sacHighlightRules;
328 var FoldMode = require("./folding/cstyle").FoldMode;
329 var Mode = function () {
330 this.HighlightRules = SaCHighlightRules;
331 this.foldingRules = new FoldMode();
332 this.$behaviour = this.$defaultBehaviour;
333 };
334 oop.inherits(Mode, TextMode);
335 (function () {
336 this.lineCommentStart = "//";
337 this.blockComment = { start: "/*", end: "*/" };
338 this.$id = "ace/mode/sac";
339 }).call(Mode.prototype);
340 exports.Mode = Mode;
341
342 }); (function() {
343 ace.require(["ace/mode/sac"], function(m) {
344 if (typeof module == "object" && typeof exports == "object" && module) {
345 module.exports = m;
346 }
347 });
348 })();
349