Debian Codegraph @

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

raw symbols SCIP
1 ace.define("ace/mode/nasal_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){/* ***** BEGIN LICENSE BLOCK *****
2 * Distributed under the BSD license:
3 *
4 * Copyright (c) 2012, Ajax.org B.V.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of Ajax.org B.V. nor the
15 * names of its contributors may be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * ***** END LICENSE BLOCK ***** */
30 "use strict";
31 var oop = require("../lib/oop");
32 var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
33 var NasalHighlightRules = function () {
34 this.$rules = {
35 start: [{
36 token: "constant.other.allcaps.nasal",
37 regex: /\b[[:upper:]_][[:upper:][:digit:]_]*\b(?![\.\(\'\"])/,
38 comment: "Match identifiers in ALL_CAPS as constants, except when followed by `.`, `(`, `'`, or `\"`."
39 }, {
40 todo: {
41 token: [
42 "support.class.nasal",
43 "meta.function.nasal",
44 "entity.name.function.nasal",
45 "meta.function.nasal",
46 "keyword.operator.nasal",
47 "meta.function.nasal",
48 "storage.type.function.nasal",
49 "meta.function.nasal",
50 "punctuation.definition.parameters.begin.nasal"
51 ],
52 regex: /([a-zA-Z_?.$][\w?.$]*)(\.)([a-zA-Z_?.$][\w?.$]*)(\s*)(=)(\s*)(func)(\s*)(\()/,
53 push: [{
54 token: "punctuation.definition.parameters.end.nasal",
55 regex: /\)/,
56 next: "pop"
57 }, {
58 include: "$self"
59 }, {
60 token: "variable.parameter.nasal",
61 regex: /\w/
62 }, {
63 defaultToken: "meta.function.nasal"
64 }]
65 },
66 comment: "match stuff like: Sound.play = func() { … }"
67 }, {
68 todo: {
69 token: [
70 "entity.name.function.nasal",
71 "meta.function.nasal",
72 "keyword.operator.nasal",
73 "meta.function.nasal",
74 "storage.type.function.nasal",
75 "meta.function.nasal",
76 "punctuation.definition.parameters.begin.nasal"
77 ],
78 regex: /([a-zA-Z_?$][\w?$]*)(\s*)(=)(\s*)(func)(\s*)(\()/,
79 push: [{
80 token: "punctuation.definition.parameters.end.nasal",
81 regex: /\)/,
82 next: "pop"
83 }, {
84 include: "$self"
85 }, {
86 token: "variable.parameter.nasal",
87 regex: /\w/
88 }, {
89 defaultToken: "meta.function.nasal"
90 }]
91 },
92 comment: "match stuff like: play = func() { … }"
93 }, {
94 todo: {
95 token: [
96 "entity.name.function.nasal",
97 "meta.function.nasal",
98 "keyword.operator.nasal",
99 "meta.function.nasal",
100 "storage.type.function.nasal",
101 "meta.function.nasal",
102 "punctuation.definition.parameters.begin.nasal"
103 ],
104 regex: /([a-zA-Z_?$][\w?$]*)(\s*)(=)(\s*\(\s*)(func)(\s*)(\()/,
105 push: [{
106 token: "punctuation.definition.parameters.end.nasal",
107 regex: /\)/,
108 next: "pop"
109 }, {
110 include: "$self"
111 }, {
112 token: "variable.parameter.nasal",
113 regex: /\w/
114 }, {
115 defaultToken: "meta.function.nasal"
116 }]
117 },
118 comment: "match stuff like: play = (func() { … }"
119 }, {
120 todo: {
121 token: [
122 "entity.name.function.nasal",
123 "meta.function.hash.nasal",
124 "storage.type.function.nasal",
125 "meta.function.hash.nasal",
126 "punctuation.definition.parameters.begin.nasal"
127 ],
128 regex: /\b([a-zA-Z_?.$][\w?.$]*)(\s*:\s*\b)(func)(\s*)(\()/,
129 push: [{
130 token: "punctuation.definition.parameters.end.nasal",
131 regex: /\)/,
132 next: "pop"
133 }, {
134 include: "$self"
135 }, {
136 token: "variable.parameter.nasal",
137 regex: /\w/
138 }, {
139 defaultToken: "meta.function.hash.nasal"
140 }]
141 },
142 comment: "match stuff like: foobar: func() { … }"
143 }, {
144 todo: {
145 token: [
146 "storage.type.function.nasal",
147 "meta.function.nasal",
148 "punctuation.definition.parameters.begin.nasal"
149 ],
150 regex: /\b(func)(\s*)(\()/,
151 push: [{
152 token: "punctuation.definition.parameters.end.nasal",
153 regex: /\)/,
154 next: "pop"
155 }, {
156 include: "$self"
157 }, {
158 token: "variable.parameter.nasal",
159 regex: /\w/
160 }, {
161 defaultToken: "meta.function.nasal"
162 }]
163 },
164 comment: "match stuff like: func() { … }"
165 }, {
166 token: [
167 "keyword.operator.new.nasal",
168 "meta.class.instance.constructor",
169 "entity.name.type.instance.nasal"
170 ],
171 regex: /(new)(\s+)(\w+(?:\.\w*)?)/
172 }, {
173 token: "keyword.control.nasal",
174 regex: /\b(?:if|else|elsif|while|for|foreach|forindex)\b/
175 }, {
176 token: "keyword.control.nasal",
177 regex: /\b(?:break(?:\s+[A-Z]{2,16})?(?=\s*(?:;|\}))|continue(?:\s+[A-Z]{2,16})?(?=\s*(?:;|\}))|[A-Z]{2,16}(?=\s*;(?:[^\)#;]*?;){0,2}[^\)#;]*?\)))\b/
178 }, {
179 token: "keyword.operator.nasal",
180 regex: /!|\*|\-|\+|~|\/|==|=|!=|<=|>=|<|>|!|\?|\:|\*=|\/=|\+=|\-=|~=|\.\.\.|\b(?:and|or)\b/
181 }, {
182 token: "variable.language.nasal",
183 regex: /\b(?:me|arg|parents|obj)\b/
184 }, {
185 token: "storage.type.nasal",
186 regex: /\b(?:return|var)\b/
187 }, {
188 token: "constant.language.nil.nasal",
189 regex: /\bnil\b/
190 }, {
191 token: "punctuation.definition.string.begin.nasal",
192 regex: /'/,
193 push: [{
194 token: "punctuation.definition.string.end.nasal",
195 regex: /'/,
196 next: "pop"
197 }, {
198 token: "constant.character.escape.nasal",
199 regex: /\\'/
200 }, {
201 defaultToken: "string.quoted.single.nasal"
202 }],
203 comment: "Single quoted strings"
204 }, {
205 token: "punctuation.definition.string.begin.nasal",
206 regex: /"/,
207 push: [{
208 token: "punctuation.definition.string.end.nasal",
209 regex: /"/,
210 next: "pop"
211 }, {
212 token: "constant.character.escape.nasal",
213 regex: /\\(?:x[\da-fA-F]{2}|[0-2][0-7]{,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|r|n|t|\\|")/
214 }, {
215 token: "constant.character.escape.nasal",
216 regex: /%(?:%|(?:\d+\$)?[+-]?(?:[ 0]|'.{1})?-?\d*(?:\.\d+)?[bcdeEufFgGosxX])/
217 }, {
218 defaultToken: "string.quoted.double.nasal"
219 }],
220 comment: "Double quoted strings"
221 }, {
222 token: [
223 "punctuation.definition.string.begin.nasal",
224 "string.other",
225 "punctuation.definition.string.end.nasal"
226 ],
227 regex: /(`)(.)(`)/,
228 comment: "Single-byte ASCII character constants"
229 }, {
230 token: [
231 "punctuation.definition.comment.nasal",
232 "comment.line.hash.nasal"
233 ],
234 regex: /(#)(.*$)/,
235 comment: "Comments"
236 }, {
237 token: "constant.numeric.nasal",
238 regex: /(?:(?:\b[0-9]+)?\.)?\b[0-9]+(?:[eE][-+]?[0-9]+)?\b/,
239 comment: "Integers, floats, and scientific format"
240 }, {
241 token: "constant.numeric.nasal",
242 regex: /0[x|X][0-9a-fA-F]+/,
243 comment: "Hex codes"
244 }, {
245 token: "punctuation.terminator.statement.nasal",
246 regex: /\;/
247 }, {
248 token: [
249 "punctuation.section.scope.begin.nasal",
250 "punctuation.section.scope.end.nasal"
251 ],
252 regex: /(\[)(\])/
253 }, {
254 todo: {
255 token: "punctuation.section.scope.begin.nasal",
256 regex: /\{/,
257 push: [{
258 token: "punctuation.section.scope.end.nasal",
259 regex: /\}/,
260 next: "pop"
261 }, {
262 include: "$self"
263 }]
264 }
265 }, {
266 todo: {
267 token: "punctuation.section.scope.begin.nasal",
268 regex: /\(/,
269 push: [{
270 token: "punctuation.section.scope.end.nasal",
271 regex: /\)/,
272 next: "pop"
273 }, {
274 include: "$self"
275 }]
276 }
277 }, {
278 token: "invalid.illegal",
279 regex: /%|\$|@|&|\^|\||\\|`/,
280 comment: "Illegal characters"
281 }, {
282 todo: {
283 comment: "TODO: Symbols in hash keys"
284 },
285 comment: "TODO: Symbols in hash keys"
286 }, {
287 token: "variable.language.nasal",
288 regex: /\b(?:append|bind|call|caller|chr|closure|cmp|compile|contains|delete|die|find|ghosttype|id|int|keys|left|num|pop|right|setsize|size|sort|split|sprintf|streq|substr|subvec|typeof|readline)\b/,
289 comment: "Core functions"
290 }, {
291 token: "variable.language.nasal",
292 regex: /\b(?:abort|abs|aircraftToCart|addcommand|airportinfo|airwaysRoute|assert|carttogeod|cmdarg|courseAndDistance|createDiscontinuity|createViaTo|createWP|createWPFrom|defined|directory|fgcommand|findAirportsByICAO|findAirportsWithinRange|findFixesByID|findNavaidByFrequency|findNavaidsByFrequency|findNavaidsByID|findNavaidsWithinRange|finddata|flightplan|geodinfo|geodtocart|get_cart_ground_intersection|getprop|greatCircleMove|interpolate|isa|logprint|magvar|maketimer|start|stop|restart|maketimestamp|md5|navinfo|parse_markdown|parsexml|print|printf|printlog|rand|registerFlightPlanDelegate|removecommand|removelistener|resolvepath|setlistener|_setlistener|setprop|srand|systime|thisfunc|tileIndex|tilePath|values)\b/,
293 comment: "FG ext core functions"
294 }, {
295 token: "variable.language.nasal",
296 regex: /\b(?:singleShot|isRunning|simulatedTime)\b/,
297 comment: "FG ext core functions"
298 }, {
299 token: "constant.language.nasal",
300 regex: /\b(?:D2R|FPS2KT|FT2M|GAL2L|IN2M|KG2LB|KT2FPS|KT2MPS|LG2GAL|LB2KG|M2FT|M2IN|M2NM|MPS2KT|NM2M|R2D)\b/,
301 comment: "FG ext core constants"
302 }, {
303 token: "support.function.nasal",
304 regex: /\b(?:addChild|addChildren|alias|clearValue|equals|getAliasTarget|getAttribute|getBoolValue|getChild|getChildren|getIndex|getName|getNode|getParent|getPath|getType|getValue|getValues|initNode|remove|removeAllChildren|removeChild|removeChildren|setAttribute|setBoolValue|setDoubleValue|setIntValue|setValue|setValues|unalias|compileCondition|condition|copy|dump|getNode|nodeList|runBinding|setAll|wrap|wrapNode)\b/,
305 comment: "FG func props"
306 }, {
307 token: "support.class.nasal",
308 regex: /\bNode\b/,
309 comment: "FG node class"
310 }, {
311 token: "variable.language.nasal",
312 regex: /\b(?:props|globals)\b/,
313 comment: "FG func props variables"
314 }, {
315 todo: {
316 token: [
317 "support.function.nasal",
318 "punctuation.definition.arguments.begin.nasal"
319 ],
320 regex: /\b([a-zA-Z_?$][\w?$]*)(\()/,
321 push: [{
322 token: "punctuation.definition.arguments.end.nasal",
323 regex: /\)/,
324 next: "pop"
325 }, {
326 include: "$self"
327 }, {
328 defaultToken: "meta.function-call.nasal"
329 }]
330 },
331 comment: "function call"
332 }]
333 };
334 this.normalizeRules();
335 };
336 NasalHighlightRules.metaData = {
337 fileTypes: ["nas"],
338 name: "Nasal",
339 scopeName: "source.nasal"
340 };
341 oop.inherits(NasalHighlightRules, TextHighlightRules);
342 exports.NasalHighlightRules = NasalHighlightRules;
343
344 });
345
346 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";
347 var oop = require("../../lib/oop");
348 var Range = require("../../range").Range;
349 var BaseFoldMode = require("./fold_mode").FoldMode;
350 var FoldMode = exports.FoldMode = function (commentRegex) {
351 if (commentRegex) {
352 this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
353 this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
354 }
355 };
356 oop.inherits(FoldMode, BaseFoldMode);
357 (function () {
358 this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
359 this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
360 this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
361 this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
362 this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
363 this._getFoldWidgetBase = this.getFoldWidget;
364 this.getFoldWidget = function (session, foldStyle, row) {
365 var line = session.getLine(row);
366 if (this.singleLineBlockCommentRe.test(line)) {
367 if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
368 return "";
369 }
370 var fw = this._getFoldWidgetBase(session, foldStyle, row);
371 if (!fw && this.startRegionRe.test(line))
372 return "start"; // lineCommentRegionStart
373 return fw;
374 };
375 this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
376 var line = session.getLine(row);
377 if (this.startRegionRe.test(line))
378 return this.getCommentRegionBlock(session, line, row);
379 var match = line.match(this.foldingStartMarker);
380 if (match) {
381 var i = match.index;
382 if (match[1])
383 return this.openingBracketBlock(session, match[1], row, i);
384 var range = session.getCommentFoldRange(row, i + match[0].length, 1);
385 if (range && !range.isMultiLine()) {
386 if (forceMultiline) {
387 range = this.getSectionRange(session, row);
388 }
389 else if (foldStyle != "all")
390 range = null;
391 }
392 return range;
393 }
394 if (foldStyle === "markbegin")
395 return;
396 var match = line.match(this.foldingStopMarker);
397 if (match) {
398 var i = match.index + match[0].length;
399 if (match[1])
400 return this.closingBracketBlock(session, match[1], row, i);
401 return session.getCommentFoldRange(row, i, -1);
402 }
403 };
404 this.getSectionRange = function (session, row) {
405 var line = session.getLine(row);
406 var startIndent = line.search(/\S/);
407 var startRow = row;
408 var startColumn = line.length;
409 row = row + 1;
410 var endRow = row;
411 var maxRow = session.getLength();
412 while (++row < maxRow) {
413 line = session.getLine(row);
414 var indent = line.search(/\S/);
415 if (indent === -1)
416 continue;
417 if (startIndent > indent)
418 break;
419 var subRange = this.getFoldWidgetRange(session, "all", row);
420 if (subRange) {
421 if (subRange.start.row <= startRow) {
422 break;
423 }
424 else if (subRange.isMultiLine()) {
425 row = subRange.end.row;
426 }
427 else if (startIndent == indent) {
428 break;
429 }
430 }
431 endRow = row;
432 }
433 return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
434 };
435 this.getCommentRegionBlock = function (session, line, row) {
436 var startColumn = line.search(/\s*$/);
437 var maxRow = session.getLength();
438 var startRow = row;
439 var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
440 var depth = 1;
441 while (++row < maxRow) {
442 line = session.getLine(row);
443 var m = re.exec(line);
444 if (!m)
445 continue;
446 if (m[1])
447 depth--;
448 else
449 depth++;
450 if (!depth)
451 break;
452 }
453 var endRow = row;
454 if (endRow > startRow) {
455 return new Range(startRow, startColumn, endRow, line.length);
456 }
457 };
458 }).call(FoldMode.prototype);
459
460 });
461
462 ace.define("ace/mode/nasal",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/nasal_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){/* ***** BEGIN LICENSE BLOCK *****
463 * Distributed under the BSD license:
464 *
465 * Copyright (c) 2012, Ajax.org B.V.
466 * All rights reserved.
467 *
468 * Redistribution and use in source and binary forms, with or without
469 * modification, are permitted provided that the following conditions are met:
470 * * Redistributions of source code must retain the above copyright
471 * notice, this list of conditions and the following disclaimer.
472 * * Redistributions in binary form must reproduce the above copyright
473 * notice, this list of conditions and the following disclaimer in the
474 * documentation and/or other materials provided with the distribution.
475 * * Neither the name of Ajax.org B.V. nor the
476 * names of its contributors may be used to endorse or promote products
477 * derived from this software without specific prior written permission.
478 *
479 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
480 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
481 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
482 * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
483 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
484 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
485 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
486 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
487 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
488 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
489 *
490 * ***** END LICENSE BLOCK ***** */
491 "use strict";
492 var oop = require("../lib/oop");
493 var TextMode = require("./text").Mode;
494 var NasalHighlightRules = require("./nasal_highlight_rules").NasalHighlightRules;
495 var FoldMode = require("./folding/cstyle").FoldMode;
496 var Mode = function () {
497 this.HighlightRules = NasalHighlightRules;
498 this.foldingRules = new FoldMode();
499 };
500 oop.inherits(Mode, TextMode);
501 (function () {
502 this.$id = "ace/mode/nasal";
503 }).call(Mode.prototype);
504 exports.Mode = Mode;
505
506 }); (function() {
507 ace.require(["ace/mode/nasal"], function(m) {
508 if (typeof module == "object" && typeof exports == "object" && module) {
509 module.exports = m;
510 }
511 });
512 })();
513