Debian Codegraph @

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

raw symbols SCIP
1 ace.define("ace/mode/csound_preprocessor_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 CsoundPreprocessorHighlightRules = function (embeddedRulePrefix) {
5 this.embeddedRulePrefix = embeddedRulePrefix === undefined ? "" : embeddedRulePrefix;
6 this.semicolonComments = {
7 token: "comment.line.semicolon.csound",
8 regex: ";.*$"
9 };
10 this.comments = [
11 {
12 token: "punctuation.definition.comment.begin.csound",
13 regex: "/\\*",
14 push: [
15 {
16 token: "punctuation.definition.comment.end.csound",
17 regex: "\\*/",
18 next: "pop"
19 }, {
20 defaultToken: "comment.block.csound"
21 }
22 ]
23 }, {
24 token: "comment.line.double-slash.csound",
25 regex: "//.*$"
26 },
27 this.semicolonComments
28 ];
29 this.macroUses = [
30 {
31 token: ["entity.name.function.preprocessor.csound", "punctuation.definition.macro-parameter-value-list.begin.csound"],
32 regex: /(\$[A-Z_a-z]\w*\.?)(\()/,
33 next: "macro parameter value list"
34 }, {
35 token: "entity.name.function.preprocessor.csound",
36 regex: /\$[A-Z_a-z]\w*(?:\.|\b)/
37 }
38 ];
39 this.numbers = [
40 {
41 token: "constant.numeric.float.csound",
42 regex: /(?:\d+[Ee][+-]?\d+)|(?:\d+\.\d*|\d*\.\d+)(?:[Ee][+-]?\d+)?/
43 }, {
44 token: ["storage.type.number.csound", "constant.numeric.integer.hexadecimal.csound"],
45 regex: /(0[Xx])([0-9A-Fa-f]+)/
46 }, {
47 token: "constant.numeric.integer.decimal.csound",
48 regex: /\d+/
49 }
50 ];
51 this.bracedStringContents = [
52 {
53 token: "constant.character.escape.csound",
54 regex: /\\(?:[\\abnrt"]|[0-7]{1,3})/
55 },
56 {
57 token: "constant.character.placeholder.csound",
58 regex: /%[#0\- +]*\d*(?:\.\d+)?[diuoxXfFeEgGaAcs]/
59 }, {
60 token: "constant.character.escape.csound",
61 regex: /%%/
62 }
63 ];
64 this.quotedStringContents = [
65 this.macroUses,
66 this.bracedStringContents
67 ];
68 var start = [
69 this.comments,
70 {
71 token: "keyword.preprocessor.csound",
72 regex: /#(?:e(?:nd(?:if)?|lse)\b|##)|@@?[ \t]*\d+/
73 }, {
74 token: "keyword.preprocessor.csound",
75 regex: /#include/,
76 push: [
77 this.comments,
78 {
79 token: "string.csound",
80 regex: /([^ \t])(?:.*?\1)/,
81 next: "pop"
82 }
83 ]
84 }, {
85 token: "keyword.preprocessor.csound",
86 regex: /#includestr/,
87 push: [
88 this.comments,
89 {
90 token: "string.csound",
91 regex: /([^ \t])(?:.*?\1)/,
92 next: "pop"
93 }
94 ]
95 }, {
96 token: "keyword.preprocessor.csound",
97 regex: /#[ \t]*define/,
98 next: "define directive"
99 }, {
100 token: "keyword.preprocessor.csound",
101 regex: /#(?:ifn?def|undef)\b/,
102 next: "macro directive"
103 },
104 this.macroUses
105 ];
106 this.$rules = {
107 "start": start,
108 "define directive": [
109 this.comments,
110 {
111 token: "entity.name.function.preprocessor.csound",
112 regex: /[A-Z_a-z]\w*/
113 }, {
114 token: "punctuation.definition.macro-parameter-name-list.begin.csound",
115 regex: /\(/,
116 next: "macro parameter name list"
117 }, {
118 token: "punctuation.definition.macro.begin.csound",
119 regex: /#/,
120 next: "macro body"
121 }
122 ],
123 "macro parameter name list": [
124 {
125 token: "variable.parameter.preprocessor.csound",
126 regex: /[A-Z_a-z]\w*/
127 }, {
128 token: "punctuation.definition.macro-parameter-name-list.end.csound",
129 regex: /\)/,
130 next: "define directive"
131 }
132 ],
133 "macro body": [
134 {
135 token: "constant.character.escape.csound",
136 regex: /\\#/
137 }, {
138 token: "punctuation.definition.macro.end.csound",
139 regex: /#/,
140 next: "start"
141 },
142 start
143 ],
144 "macro directive": [
145 this.comments,
146 {
147 token: "entity.name.function.preprocessor.csound",
148 regex: /[A-Z_a-z]\w*/,
149 next: "start"
150 }
151 ],
152 "macro parameter value list": [
153 {
154 token: "punctuation.definition.macro-parameter-value-list.end.csound",
155 regex: /\)/,
156 next: "start"
157 }, {
158 token: "punctuation.definition.string.begin.csound",
159 regex: /"/,
160 next: "macro parameter value quoted string"
161 }, this.pushRule({
162 token: "punctuation.macro-parameter-value-parenthetical.begin.csound",
163 regex: /\(/,
164 next: "macro parameter value parenthetical"
165 }), {
166 token: "punctuation.macro-parameter-value-separator.csound",
167 regex: "[#']"
168 }
169 ],
170 "macro parameter value quoted string": [
171 {
172 token: "constant.character.escape.csound",
173 regex: /\\[#'()]/
174 }, {
175 token: "invalid.illegal.csound",
176 regex: /[#'()]/
177 }, {
178 token: "punctuation.definition.string.end.csound",
179 regex: /"/,
180 next: "macro parameter value list"
181 },
182 this.quotedStringContents,
183 {
184 defaultToken: "string.quoted.csound"
185 }
186 ],
187 "macro parameter value parenthetical": [
188 {
189 token: "constant.character.escape.csound",
190 regex: /\\\)/
191 }, this.popRule({
192 token: "punctuation.macro-parameter-value-parenthetical.end.csound",
193 regex: /\)/
194 }), this.pushRule({
195 token: "punctuation.macro-parameter-value-parenthetical.begin.csound",
196 regex: /\(/,
197 next: "macro parameter value parenthetical"
198 }),
199 start
200 ]
201 };
202 };
203 oop.inherits(CsoundPreprocessorHighlightRules, TextHighlightRules);
204 (function () {
205 this.pushRule = function (params) {
206 if (Array.isArray(params.next)) {
207 for (var i = 0; i < params.next.length; i++) {
208 params.next[i] = this.embeddedRulePrefix + params.next[i];
209 }
210 }
211 return {
212 regex: params.regex, onMatch: function (value, currentState, stack, line) {
213 if (stack.length === 0)
214 stack.push(currentState);
215 if (Array.isArray(params.next)) {
216 for (var i = 0; i < params.next.length; i++) {
217 stack.push(params.next[i]);
218 }
219 }
220 else {
221 stack.push(params.next);
222 }
223 this.next = stack[stack.length - 1];
224 return params.token;
225 },
226 get next() { return Array.isArray(params.next) ? params.next[params.next.length - 1] : params.next; },
227 set next(next) {
228 if (!Array.isArray(params.next)) {
229 params.next = next;
230 }
231 },
232 get token() { return params.token; }
233 };
234 };
235 this.popRule = function (params) {
236 if (params.next) {
237 params.next = this.embeddedRulePrefix + params.next;
238 }
239 return {
240 regex: params.regex, onMatch: function (value, currentState, stack, line) {
241 stack.pop();
242 if (params.next) {
243 stack.push(params.next);
244 this.next = stack[stack.length - 1];
245 }
246 else {
247 this.next = stack.length > 1 ? stack[stack.length - 1] : stack.pop();
248 }
249 return params.token;
250 }
251 };
252 };
253 }).call(CsoundPreprocessorHighlightRules.prototype);
254 exports.CsoundPreprocessorHighlightRules = CsoundPreprocessorHighlightRules;
255
256 });
257
258 ace.define("ace/mode/csound_score_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/csound_preprocessor_highlight_rules"], function(require, exports, module){"use strict";
259 var oop = require("../lib/oop");
260 var CsoundPreprocessorHighlightRules = require("./csound_preprocessor_highlight_rules").CsoundPreprocessorHighlightRules;
261 var CsoundScoreHighlightRules = function (embeddedRulePrefix) {
262 CsoundPreprocessorHighlightRules.call(this, embeddedRulePrefix);
263 this.quotedStringContents.push({
264 token: "invalid.illegal.csound-score",
265 regex: /[^"]*$/
266 });
267 var start = this.$rules.start;
268 start.push({
269 token: "keyword.control.csound-score",
270 regex: /[aBbCdefiqstvxy]/
271 }, {
272 token: "invalid.illegal.csound-score",
273 regex: /w/
274 }, {
275 token: "constant.numeric.language.csound-score",
276 regex: /z/
277 }, {
278 token: ["keyword.control.csound-score", "constant.numeric.integer.decimal.csound-score"],
279 regex: /([nNpP][pP])(\d+)/
280 }, {
281 token: "keyword.other.csound-score",
282 regex: /[mn]/,
283 push: [
284 {
285 token: "empty",
286 regex: /$/,
287 next: "pop"
288 },
289 this.comments,
290 {
291 token: "entity.name.label.csound-score",
292 regex: /[A-Z_a-z]\w*/
293 }
294 ]
295 }, {
296 token: "keyword.preprocessor.csound-score",
297 regex: /r\b/,
298 next: "repeat section"
299 }, this.numbers, {
300 token: "keyword.operator.csound-score",
301 regex: "[!+\\-*/^%&|<>#~.]"
302 }, this.pushRule({
303 token: "punctuation.definition.string.begin.csound-score",
304 regex: /"/,
305 next: "quoted string"
306 }), this.pushRule({
307 token: "punctuation.braced-loop.begin.csound-score",
308 regex: /{/,
309 next: "loop after left brace"
310 }));
311 this.addRules({
312 "repeat section": [
313 {
314 token: "empty",
315 regex: /$/,
316 next: "start"
317 },
318 this.comments,
319 {
320 token: "constant.numeric.integer.decimal.csound-score",
321 regex: /\d+/,
322 next: "repeat section before label"
323 }
324 ],
325 "repeat section before label": [
326 {
327 token: "empty",
328 regex: /$/,
329 next: "start"
330 },
331 this.comments,
332 {
333 token: "entity.name.label.csound-score",
334 regex: /[A-Z_a-z]\w*/,
335 next: "start"
336 }
337 ],
338 "quoted string": [
339 this.popRule({
340 token: "punctuation.definition.string.end.csound-score",
341 regex: /"/
342 }),
343 this.quotedStringContents,
344 {
345 defaultToken: "string.quoted.csound-score"
346 }
347 ],
348 "loop after left brace": [
349 this.popRule({
350 token: "constant.numeric.integer.decimal.csound-score",
351 regex: /\d+/,
352 next: "loop after repeat count"
353 }),
354 this.comments,
355 {
356 token: "invalid.illegal.csound",
357 regex: /\S.*/
358 }
359 ],
360 "loop after repeat count": [
361 this.popRule({
362 token: "entity.name.function.preprocessor.csound-score",
363 regex: /[A-Z_a-z]\w*\b/,
364 next: "loop after macro name"
365 }),
366 this.comments,
367 {
368 token: "invalid.illegal.csound",
369 regex: /\S.*/
370 }
371 ],
372 "loop after macro name": [
373 start,
374 this.popRule({
375 token: "punctuation.braced-loop.end.csound-score",
376 regex: /}/
377 })
378 ]
379 });
380 this.normalizeRules();
381 };
382 oop.inherits(CsoundScoreHighlightRules, CsoundPreprocessorHighlightRules);
383 exports.CsoundScoreHighlightRules = CsoundScoreHighlightRules;
384
385 });
386
387 ace.define("ace/mode/csound_score",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/csound_score_highlight_rules"], function(require, exports, module){"use strict";
388 var oop = require("../lib/oop");
389 var TextMode = require("./text").Mode;
390 var CsoundScoreHighlightRules = require("./csound_score_highlight_rules").CsoundScoreHighlightRules;
391 var Mode = function () {
392 this.HighlightRules = CsoundScoreHighlightRules;
393 };
394 oop.inherits(Mode, TextMode);
395 (function () {
396 this.lineCommentStart = ";";
397 this.blockComment = { start: "/*", end: "*/" };
398 this.$id = "ace/mode/csound_score";
399 }).call(Mode.prototype);
400 exports.Mode = Mode;
401
402 }); (function() {
403 ace.require(["ace/mode/csound_score"], function(m) {
404 if (typeof module == "object" && typeof exports == "object" && module) {
405 module.exports = m;
406 }
407 });
408 })();
409