6ac188cc35ae0d38d3647a2eef17b2fc.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  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. 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";
  257. var oop = require("../lib/oop");
  258. var CsoundPreprocessorHighlightRules = require("./csound_preprocessor_highlight_rules").CsoundPreprocessorHighlightRules;
  259. var CsoundScoreHighlightRules = function (embeddedRulePrefix) {
  260. CsoundPreprocessorHighlightRules.call(this, embeddedRulePrefix);
  261. this.quotedStringContents.push({
  262. token: "invalid.illegal.csound-score",
  263. regex: /[^"]*$/
  264. });
  265. var start = this.$rules.start;
  266. start.push({
  267. token: "keyword.control.csound-score",
  268. regex: /[aBbCdefiqstvxy]/
  269. }, {
  270. token: "invalid.illegal.csound-score",
  271. regex: /w/
  272. }, {
  273. token: "constant.numeric.language.csound-score",
  274. regex: /z/
  275. }, {
  276. token: ["keyword.control.csound-score", "constant.numeric.integer.decimal.csound-score"],
  277. regex: /([nNpP][pP])(\d+)/
  278. }, {
  279. token: "keyword.other.csound-score",
  280. regex: /[mn]/,
  281. push: [
  282. {
  283. token: "empty",
  284. regex: /$/,
  285. next: "pop"
  286. },
  287. this.comments,
  288. {
  289. token: "entity.name.label.csound-score",
  290. regex: /[A-Z_a-z]\w*/
  291. }
  292. ]
  293. }, {
  294. token: "keyword.preprocessor.csound-score",
  295. regex: /r\b/,
  296. next: "repeat section"
  297. }, this.numbers, {
  298. token: "keyword.operator.csound-score",
  299. regex: "[!+\\-*/^%&|<>#~.]"
  300. }, this.pushRule({
  301. token: "punctuation.definition.string.begin.csound-score",
  302. regex: /"/,
  303. next: "quoted string"
  304. }), this.pushRule({
  305. token: "punctuation.braced-loop.begin.csound-score",
  306. regex: /{/,
  307. next: "loop after left brace"
  308. }));
  309. this.addRules({
  310. "repeat section": [
  311. {
  312. token: "empty",
  313. regex: /$/,
  314. next: "start"
  315. },
  316. this.comments,
  317. {
  318. token: "constant.numeric.integer.decimal.csound-score",
  319. regex: /\d+/,
  320. next: "repeat section before label"
  321. }
  322. ],
  323. "repeat section before label": [
  324. {
  325. token: "empty",
  326. regex: /$/,
  327. next: "start"
  328. },
  329. this.comments,
  330. {
  331. token: "entity.name.label.csound-score",
  332. regex: /[A-Z_a-z]\w*/,
  333. next: "start"
  334. }
  335. ],
  336. "quoted string": [
  337. this.popRule({
  338. token: "punctuation.definition.string.end.csound-score",
  339. regex: /"/
  340. }),
  341. this.quotedStringContents,
  342. {
  343. defaultToken: "string.quoted.csound-score"
  344. }
  345. ],
  346. "loop after left brace": [
  347. this.popRule({
  348. token: "constant.numeric.integer.decimal.csound-score",
  349. regex: /\d+/,
  350. next: "loop after repeat count"
  351. }),
  352. this.comments,
  353. {
  354. token: "invalid.illegal.csound",
  355. regex: /\S.*/
  356. }
  357. ],
  358. "loop after repeat count": [
  359. this.popRule({
  360. token: "entity.name.function.preprocessor.csound-score",
  361. regex: /[A-Z_a-z]\w*\b/,
  362. next: "loop after macro name"
  363. }),
  364. this.comments,
  365. {
  366. token: "invalid.illegal.csound",
  367. regex: /\S.*/
  368. }
  369. ],
  370. "loop after macro name": [
  371. start,
  372. this.popRule({
  373. token: "punctuation.braced-loop.end.csound-score",
  374. regex: /}/
  375. })
  376. ]
  377. });
  378. this.normalizeRules();
  379. };
  380. oop.inherits(CsoundScoreHighlightRules, CsoundPreprocessorHighlightRules);
  381. exports.CsoundScoreHighlightRules = CsoundScoreHighlightRules;
  382. });
  383. 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";
  384. var oop = require("../lib/oop");
  385. var TextMode = require("./text").Mode;
  386. var CsoundScoreHighlightRules = require("./csound_score_highlight_rules").CsoundScoreHighlightRules;
  387. var Mode = function () {
  388. this.HighlightRules = CsoundScoreHighlightRules;
  389. };
  390. oop.inherits(Mode, TextMode);
  391. (function () {
  392. this.lineCommentStart = ";";
  393. this.blockComment = { start: "/*", end: "*/" };
  394. this.$id = "ace/mode/csound_score";
  395. }).call(Mode.prototype);
  396. exports.Mode = Mode;
  397. }); (function() {
  398. ace.require(["ace/mode/csound_score"], function(m) {
  399. if (typeof module == "object" && typeof exports == "object" && module) {
  400. module.exports = m;
  401. }
  402. });
  403. })();