41251dac588b04bea51a664d331ff40a.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. ace.define("ace/mode/praat_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 PraatHighlightRules = function () {
  5. var keywords = ("if|then|else|elsif|elif|endif|fi|" +
  6. "endfor|endproc|" + // related keywords specified below
  7. "while|endwhile|" +
  8. "repeat|until|" +
  9. "select|plus|minus|" +
  10. "assert|asserterror");
  11. var predefinedVariables = ("macintosh|windows|unix|" +
  12. "praatVersion|praatVersion\\$" +
  13. "pi|undefined|" +
  14. "newline\\$|tab\\$|" +
  15. "shellDirectory\\$|homeDirectory\\$|preferencesDirectory\\$|" +
  16. "temporaryDirectory\\$|defaultDirectory\\$");
  17. var directives = ("clearinfo|endSendPraat");
  18. var functions = (
  19. "writeInfo|writeInfoLine|appendInfo|appendInfoLine|info\\$|" +
  20. "writeFile|writeFileLine|appendFile|appendFileLine|" +
  21. "abs|round|floor|ceiling|min|max|imin|imax|" +
  22. "sqrt|sin|cos|tan|arcsin|arccos|arctan|arctan2|sinc|sincpi|" +
  23. "exp|ln|lnBeta|lnGamma|log10|log2|" +
  24. "sinh|cosh|tanh|arcsinh|arccosh|arctanh|" +
  25. "sigmoid|invSigmoid|erf|erfc|" +
  26. "random(?:Uniform|Integer|Gauss|Poisson|Binomial)|" +
  27. "gaussP|gaussQ|invGaussQ|incompleteGammaP|incompleteBeta|" +
  28. "chiSquareP|chiSquareQ|invChiSquareQ|studentP|studentQ|invStudentQ|" +
  29. "fisherP|fisherQ|invFisherQ|" +
  30. "binomialP|binomialQ|invBinomialP|invBinomialQ|" +
  31. "hertzToBark|barkToHerz|" +
  32. "hertzToMel|melToHertz|" +
  33. "hertzToSemitones|semitonesToHerz|" +
  34. "erb|hertzToErb|erbToHertz|" +
  35. "phonToDifferenceLimens|differenceLimensToPhon|" +
  36. "soundPressureToPhon|" +
  37. "beta|beta2|besselI|besselK|" +
  38. "numberOfColumns|numberOfRows|" +
  39. "selected|selected\\$|numberOfSelected|variableExists|" +
  40. "index|rindex|startsWith|endsWith|" +
  41. "index_regex|rindex_regex|replace_regex\\$|" +
  42. "length|extractWord\\$|extractLine\\$|extractNumber|" +
  43. "left\\$|right\\$|mid\\$|replace\\$|" +
  44. "date\\$|fixed\\$|percent\\$|" +
  45. "zero#|linear#|randomUniform#|randomInteger#|randomGauss#|" +
  46. "beginPause|endPause|" +
  47. "demoShow|demoWindowTitle|demoInput|demoWaitForInput|" +
  48. "demoClicked|demoClickedIn|demoX|demoY|" +
  49. "demoKeyPressed|demoKey\\$|" +
  50. "demoExtraControlKeyPressed|demoShiftKeyPressed|" +
  51. "demoCommandKeyPressed|demoOptionKeyPressed|" +
  52. "environment\\$|chooseReadFile\\$|" +
  53. "chooseDirectory\\$|createDirectory|fileReadable|deleteFile|" +
  54. "selectObject|removeObject|plusObject|minusObject|" +
  55. "runScript|exitScript|" +
  56. "beginSendPraat|endSendPraat|" +
  57. "objectsAreIdentical");
  58. var objectTypes = ("Activation|AffineTransform|AmplitudeTier|Art|Artword|Autosegment|" +
  59. "BarkFilter|CCA|Categories|Cepstrum|Cepstrumc|ChebyshevSeries|" +
  60. "ClassificationTable|Cochleagram|Collection|Configuration|" +
  61. "Confusion|ContingencyTable|Corpus|Correlation|Covariance|" +
  62. "CrossCorrelationTable|CrossCorrelationTables|DTW|Diagonalizer|" +
  63. "Discriminant|Dissimilarity|Distance|Distributions|DurationTier|" +
  64. "EEG|ERP|ERPTier|Eigen|Excitation|Excitations|ExperimentMFC|FFNet|" +
  65. "FeatureWeights|Formant|FormantFilter|FormantGrid|FormantPoint|" +
  66. "FormantTier|GaussianMixture|HMM|HMM_Observation|" +
  67. "HMM_ObservationSequence|HMM_State|HMM_StateSequence|Harmonicity|" +
  68. "ISpline|Index|Intensity|IntensityTier|IntervalTier|KNN|KlattGrid|" +
  69. "KlattTable|LFCC|LPC|Label|LegendreSeries|LinearRegression|" +
  70. "LogisticRegression|LongSound|Ltas|MFCC|MSpline|ManPages|" +
  71. "Manipulation|Matrix|MelFilter|MixingMatrix|Movie|Network|" +
  72. "OTGrammar|OTHistory|OTMulti|PCA|PairDistribution|ParamCurve|" +
  73. "Pattern|Permutation|Pitch|PitchTier|PointProcess|Polygon|" +
  74. "Polynomial|Procrustes|RealPoint|RealTier|ResultsMFC|Roots|SPINET|" +
  75. "SSCP|SVD|Salience|ScalarProduct|Similarity|SimpleString|" +
  76. "SortedSetOfString|Sound|Speaker|Spectrogram|Spectrum|SpectrumTier|" +
  77. "SpeechSynthesizer|SpellingChecker|Strings|StringsIndex|Table|" +
  78. "TableOfReal|TextGrid|TextInterval|TextPoint|TextTier|Tier|" +
  79. "Transition|VocalTract|Weight|WordList");
  80. this.$rules = {
  81. "start": [
  82. {
  83. token: "string.interpolated",
  84. regex: /'((?:\.?[a-z][a-zA-Z0-9_.]*)(?:\$|#|:[0-9]+)?)'/
  85. }, {
  86. token: ["text", "text", "keyword.operator", "text", "keyword"],
  87. regex: /(^\s*)(?:(\.?[a-z][a-zA-Z0-9_.]*\$?\s+)(=)(\s+))?(stopwatch)/
  88. }, {
  89. token: ["text", "keyword", "text", "string"],
  90. regex: /(^\s*)(print(?:line|tab)?|echo|exit|pause|send(?:praat|socket)|include|execute|system(?:_nocheck)?)(\s+)(.*)/
  91. }, {
  92. token: ["text", "keyword"],
  93. regex: "(^\\s*)(" + directives + ")$"
  94. }, {
  95. token: ["text", "keyword.operator", "text"],
  96. regex: /(\s+)((?:\+|-|\/|\*|<|>)=?|==?|!=|%|\^|\||and|or|not)(\s+)/
  97. }, {
  98. token: ["text", "text", "keyword.operator", "text", "keyword", "text", "keyword"],
  99. regex: /(^\s*)(?:(\.?[a-z][a-zA-Z0-9_.]*\$?\s+)(=)(\s+))?(?:((?:no)?warn|(?:unix_)?nocheck|noprogress)(\s+))?((?:[A-Z][^.:"]+)(?:$|(?:\.{3}|:)))/
  100. }, {
  101. token: ["text", "keyword", "text", "keyword"],
  102. regex: /(^\s*)((?:no(?:warn|check))?)(\s*)(\b(?:editor(?::?)|endeditor)\b)/
  103. }, {
  104. token: ["text", "keyword", "text", "keyword"],
  105. regex: /(^\s*)(?:(demo)?(\s+))((?:[A-Z][^.:"]+)(?:$|(?:\.{3}|:)))/
  106. }, {
  107. token: ["text", "keyword", "text", "keyword"],
  108. regex: /^(\s*)(?:(demo)(\s+))?(10|12|14|16|24)$/
  109. }, {
  110. token: ["text", "support.function", "text"],
  111. regex: /(\s*)(do\$?)(\s*:\s*|\s*\(\s*)/
  112. }, {
  113. token: "entity.name.type",
  114. regex: "(" + objectTypes + ")"
  115. }, {
  116. token: "variable.language",
  117. regex: "(" + predefinedVariables + ")"
  118. }, {
  119. token: ["support.function", "text"],
  120. regex: "((?:" + functions + ")\\$?)(\\s*(?::|\\())"
  121. }, {
  122. token: "keyword",
  123. regex: /(\bfor\b)/,
  124. next: "for"
  125. }, {
  126. token: "keyword",
  127. regex: "(\\b(?:" + keywords + ")\\b)"
  128. }, {
  129. token: "string",
  130. regex: /"[^"]*"/
  131. }, {
  132. token: "string",
  133. regex: /"[^"]*$/,
  134. next: "brokenstring"
  135. }, {
  136. token: ["text", "keyword", "text", "entity.name.section"],
  137. regex: /(^\s*)(\bform\b)(\s+)(.*)/,
  138. next: "form"
  139. }, {
  140. token: "constant.numeric",
  141. regex: /\b[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
  142. }, {
  143. token: ["keyword", "text", "entity.name.function"],
  144. regex: /(procedure)(\s+)([^:\s]+)/
  145. }, {
  146. token: ["entity.name.function", "text"],
  147. regex: /(@\S+)(:|\s*\()/
  148. }, {
  149. token: ["text", "keyword", "text", "entity.name.function"],
  150. regex: /(^\s*)(call)(\s+)(\S+)/
  151. }, {
  152. token: "comment",
  153. regex: /(^\s*#|;).*$/
  154. }, {
  155. token: "text",
  156. regex: /\s+/
  157. }
  158. ],
  159. "form": [
  160. {
  161. token: ["keyword", "text", "constant.numeric"],
  162. regex: /((?:optionmenu|choice)\s+)(\S+:\s+)([0-9]+)/
  163. }, {
  164. token: ["keyword", "constant.numeric"],
  165. regex: /((?:option|button)\s+)([+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b)/
  166. }, {
  167. token: ["keyword", "string"],
  168. regex: /((?:option|button)\s+)(.*)/
  169. }, {
  170. token: ["keyword", "text", "string"],
  171. regex: /((?:sentence|text)\s+)(\S+\s*)(.*)/
  172. }, {
  173. token: ["keyword", "text", "string", "invalid.illegal"],
  174. regex: /(word\s+)(\S+\s*)(\S+)?(\s.*)?/
  175. }, {
  176. token: ["keyword", "text", "constant.language"],
  177. regex: /(boolean\s+)(\S+\s*)(0|1|"?(?:yes|no)"?)/
  178. }, {
  179. token: ["keyword", "text", "constant.numeric"],
  180. regex: /((?:real|natural|positive|integer)\s+)(\S+\s*)([+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b)/
  181. }, {
  182. token: ["keyword", "string"],
  183. regex: /(comment\s+)(.*)/
  184. }, {
  185. token: "keyword",
  186. regex: 'endform',
  187. next: "start"
  188. }
  189. ],
  190. "for": [
  191. {
  192. token: ["keyword", "text", "constant.numeric", "text"],
  193. regex: /(from|to)(\s+)([+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?)(\s*)/
  194. }, {
  195. token: ["keyword", "text"],
  196. regex: /(from|to)(\s+\S+\s*)/
  197. }, {
  198. token: "text",
  199. regex: /$/,
  200. next: "start"
  201. }
  202. ],
  203. "brokenstring": [
  204. {
  205. token: ["text", "string"],
  206. regex: /(\s*\.{3})([^"]*)/
  207. }, {
  208. token: "string",
  209. regex: /"/,
  210. next: "start"
  211. }
  212. ]
  213. };
  214. };
  215. oop.inherits(PraatHighlightRules, TextHighlightRules);
  216. exports.PraatHighlightRules = PraatHighlightRules;
  217. });
  218. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
  219. var Range = require("../range").Range;
  220. var MatchingBraceOutdent = function () { };
  221. (function () {
  222. this.checkOutdent = function (line, input) {
  223. if (!/^\s+$/.test(line))
  224. return false;
  225. return /^\s*\}/.test(input);
  226. };
  227. this.autoOutdent = function (doc, row) {
  228. var line = doc.getLine(row);
  229. var match = line.match(/^(\s*\})/);
  230. if (!match)
  231. return 0;
  232. var column = match[1].length;
  233. var openBracePos = doc.findMatchingBracket({ row: row, column: column });
  234. if (!openBracePos || openBracePos.row == row)
  235. return 0;
  236. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  237. doc.replace(new Range(row, 0, row, column - 1), indent);
  238. };
  239. this.$getIndent = function (line) {
  240. return line.match(/^\s*/)[0];
  241. };
  242. }).call(MatchingBraceOutdent.prototype);
  243. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  244. });
  245. 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";
  246. var oop = require("../../lib/oop");
  247. var Range = require("../../range").Range;
  248. var BaseFoldMode = require("./fold_mode").FoldMode;
  249. var FoldMode = exports.FoldMode = function (commentRegex) {
  250. if (commentRegex) {
  251. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  252. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  253. }
  254. };
  255. oop.inherits(FoldMode, BaseFoldMode);
  256. (function () {
  257. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  258. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  259. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  260. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  261. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  262. this._getFoldWidgetBase = this.getFoldWidget;
  263. this.getFoldWidget = function (session, foldStyle, row) {
  264. var line = session.getLine(row);
  265. if (this.singleLineBlockCommentRe.test(line)) {
  266. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  267. return "";
  268. }
  269. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  270. if (!fw && this.startRegionRe.test(line))
  271. return "start"; // lineCommentRegionStart
  272. return fw;
  273. };
  274. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  275. var line = session.getLine(row);
  276. if (this.startRegionRe.test(line))
  277. return this.getCommentRegionBlock(session, line, row);
  278. var match = line.match(this.foldingStartMarker);
  279. if (match) {
  280. var i = match.index;
  281. if (match[1])
  282. return this.openingBracketBlock(session, match[1], row, i);
  283. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  284. if (range && !range.isMultiLine()) {
  285. if (forceMultiline) {
  286. range = this.getSectionRange(session, row);
  287. }
  288. else if (foldStyle != "all")
  289. range = null;
  290. }
  291. return range;
  292. }
  293. if (foldStyle === "markbegin")
  294. return;
  295. var match = line.match(this.foldingStopMarker);
  296. if (match) {
  297. var i = match.index + match[0].length;
  298. if (match[1])
  299. return this.closingBracketBlock(session, match[1], row, i);
  300. return session.getCommentFoldRange(row, i, -1);
  301. }
  302. };
  303. this.getSectionRange = function (session, row) {
  304. var line = session.getLine(row);
  305. var startIndent = line.search(/\S/);
  306. var startRow = row;
  307. var startColumn = line.length;
  308. row = row + 1;
  309. var endRow = row;
  310. var maxRow = session.getLength();
  311. while (++row < maxRow) {
  312. line = session.getLine(row);
  313. var indent = line.search(/\S/);
  314. if (indent === -1)
  315. continue;
  316. if (startIndent > indent)
  317. break;
  318. var subRange = this.getFoldWidgetRange(session, "all", row);
  319. if (subRange) {
  320. if (subRange.start.row <= startRow) {
  321. break;
  322. }
  323. else if (subRange.isMultiLine()) {
  324. row = subRange.end.row;
  325. }
  326. else if (startIndent == indent) {
  327. break;
  328. }
  329. }
  330. endRow = row;
  331. }
  332. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  333. };
  334. this.getCommentRegionBlock = function (session, line, row) {
  335. var startColumn = line.search(/\s*$/);
  336. var maxRow = session.getLength();
  337. var startRow = row;
  338. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  339. var depth = 1;
  340. while (++row < maxRow) {
  341. line = session.getLine(row);
  342. var m = re.exec(line);
  343. if (!m)
  344. continue;
  345. if (m[1])
  346. depth--;
  347. else
  348. depth++;
  349. if (!depth)
  350. break;
  351. }
  352. var endRow = row;
  353. if (endRow > startRow) {
  354. return new Range(startRow, startColumn, endRow, line.length);
  355. }
  356. };
  357. }).call(FoldMode.prototype);
  358. });
  359. ace.define("ace/mode/praat",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/praat_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
  360. var oop = require("../lib/oop");
  361. var TextMode = require("./text").Mode;
  362. var PraatHighlightRules = require("./praat_highlight_rules").PraatHighlightRules;
  363. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  364. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  365. var Mode = function () {
  366. this.HighlightRules = PraatHighlightRules;
  367. this.$outdent = new MatchingBraceOutdent();
  368. this.foldingRules = new CStyleFoldMode();
  369. this.$behaviour = this.$defaultBehaviour;
  370. };
  371. oop.inherits(Mode, TextMode);
  372. (function () {
  373. this.lineCommentStart = "#";
  374. this.getNextLineIndent = function (state, line, tab) {
  375. var indent = this.$getIndent(line);
  376. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  377. var tokens = tokenizedLine.tokens;
  378. if (tokens.length && tokens[tokens.length - 1].type == "comment") {
  379. return indent;
  380. }
  381. if (state == "start") {
  382. var match = line.match(/^.*[\{\(\[:]\s*$/);
  383. if (match) {
  384. indent += tab;
  385. }
  386. }
  387. return indent;
  388. };
  389. this.checkOutdent = function (state, line, input) {
  390. return this.$outdent.checkOutdent(line, input);
  391. };
  392. this.autoOutdent = function (state, doc, row) {
  393. this.$outdent.autoOutdent(doc, row);
  394. };
  395. this.$id = "ace/mode/praat";
  396. }).call(Mode.prototype);
  397. exports.Mode = Mode;
  398. }); (function() {
  399. ace.require(["ace/mode/praat"], function(m) {
  400. if (typeof module == "object" && typeof exports == "object" && module) {
  401. module.exports = m;
  402. }
  403. });
  404. })();