Projekt

Obecné

Profil

Stáhnout (17.6 KB) Statistiky
| Větev: | Tag: | Revize:
1
ace.define("ace/mode/praat_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
2
"use strict";
3

    
4
var oop = require("../lib/oop");
5
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
6

    
7
var PraatHighlightRules = function() {
8

    
9
    var keywords = (
10
        "if|then|else|elsif|elif|endif|fi|" +
11
        "endfor|endproc|" + // related keywords specified below
12
        "while|endwhile|" +
13
        "repeat|until|" +
14
        "select|plus|minus|" +
15
        "assert|asserterror"
16
    );
17

    
18
    var predefinedVariables = (
19
        "macintosh|windows|unix|" +
20
        "praatVersion|praatVersion\\$" +
21
        "pi|undefined|" +
22
        "newline\\$|tab\\$|" +
23
        "shellDirectory\\$|homeDirectory\\$|preferencesDirectory\\$|" +
24
        "temporaryDirectory\\$|defaultDirectory\\$"
25
    );
26
    var directives = (
27
        "clearinfo|endSendPraat"
28
    );
29

    
30
    var functions = (
31
        "writeInfo|writeInfoLine|appendInfo|appendInfoLine|info\\$|" +
32
        "writeFile|writeFileLine|appendFile|appendFileLine|" +
33
        "abs|round|floor|ceiling|min|max|imin|imax|" +
34
        "sqrt|sin|cos|tan|arcsin|arccos|arctan|arctan2|sinc|sincpi|" +
35
        "exp|ln|lnBeta|lnGamma|log10|log2|" +
36
        "sinh|cosh|tanh|arcsinh|arccosh|arctanh|" +
37
        "sigmoid|invSigmoid|erf|erfc|" +
38
        "random(?:Uniform|Integer|Gauss|Poisson|Binomial)|" +
39
        "gaussP|gaussQ|invGaussQ|incompleteGammaP|incompleteBeta|" +
40
        "chiSquareP|chiSquareQ|invChiSquareQ|studentP|studentQ|invStudentQ|" +
41
        "fisherP|fisherQ|invFisherQ|" +
42
        "binomialP|binomialQ|invBinomialP|invBinomialQ|" +
43
        "hertzToBark|barkToHerz|" +
44
        "hertzToMel|melToHertz|" +
45
        "hertzToSemitones|semitonesToHerz|" +
46
        "erb|hertzToErb|erbToHertz|" +
47
        "phonToDifferenceLimens|differenceLimensToPhon|" +
48
        "soundPressureToPhon|" +
49
        "beta|beta2|besselI|besselK|" +
50
        "numberOfColumns|numberOfRows|" +
51
        "selected|selected\\$|numberOfSelected|variableExists|"+
52
        "index|rindex|startsWith|endsWith|"+
53
        "index_regex|rindex_regex|replace_regex\\$|"+
54
        "length|extractWord\\$|extractLine\\$|extractNumber|" +
55
        "left\\$|right\\$|mid\\$|replace\\$|" +
56
        "date\\$|fixed\\$|percent\\$|" +
57
        "zero#|linear#|randomUniform#|randomInteger#|randomGauss#|" +
58
        "beginPause|endPause|" +
59
        "demoShow|demoWindowTitle|demoInput|demoWaitForInput|" +
60
        "demoClicked|demoClickedIn|demoX|demoY|" +
61
        "demoKeyPressed|demoKey\\$|" +
62
        "demoExtraControlKeyPressed|demoShiftKeyPressed|"+
63
        "demoCommandKeyPressed|demoOptionKeyPressed|" +
64
        "environment\\$|chooseReadFile\\$|" +
65
        "chooseDirectory\\$|createDirectory|fileReadable|deleteFile|" +
66
        "selectObject|removeObject|plusObject|minusObject|" +
67
        "runScript|exitScript|" +
68
        "beginSendPraat|endSendPraat|" +
69
        "objectsAreIdentical"
70
    );
71

    
72
    var objectTypes = (
73
        "Activation|AffineTransform|AmplitudeTier|Art|Artword|Autosegment|"  +
74
        "BarkFilter|CCA|Categories|Cepstrum|Cepstrumc|ChebyshevSeries|"      +
75
        "ClassificationTable|Cochleagram|Collection|Configuration|"          +
76
        "Confusion|ContingencyTable|Corpus|Correlation|Covariance|"          +
77
        "CrossCorrelationTable|CrossCorrelationTables|DTW|Diagonalizer|"     +
78
        "Discriminant|Dissimilarity|Distance|Distributions|DurationTier|"    +
79
        "EEG|ERP|ERPTier|Eigen|Excitation|Excitations|ExperimentMFC|FFNet|"  +
80
        "FeatureWeights|Formant|FormantFilter|FormantGrid|FormantPoint|"     +
81
        "FormantTier|GaussianMixture|HMM|HMM_Observation|"                   +
82
        "HMM_ObservationSequence|HMM_State|HMM_StateSequence|Harmonicity|"   +
83
        "ISpline|Index|Intensity|IntensityTier|IntervalTier|KNN|KlattGrid|"  +
84
        "KlattTable|LFCC|LPC|Label|LegendreSeries|LinearRegression|"         +
85
        "LogisticRegression|LongSound|Ltas|MFCC|MSpline|ManPages|"           +
86
        "Manipulation|Matrix|MelFilter|MixingMatrix|Movie|Network|"          +
87
        "OTGrammar|OTHistory|OTMulti|PCA|PairDistribution|ParamCurve|"       +
88
        "Pattern|Permutation|Pitch|PitchTier|PointProcess|Polygon|"          +
89
        "Polynomial|Procrustes|RealPoint|RealTier|ResultsMFC|Roots|SPINET|"  +
90
        "SSCP|SVD|Salience|ScalarProduct|Similarity|SimpleString|"           +
91
        "SortedSetOfString|Sound|Speaker|Spectrogram|Spectrum|SpectrumTier|" +
92
        "SpeechSynthesizer|SpellingChecker|Strings|StringsIndex|Table|"      +
93
        "TableOfReal|TextGrid|TextInterval|TextPoint|TextTier|Tier|"         +
94
        "Transition|VocalTract|Weight|WordList"
95
    );
96

    
97
    this.$rules = {
98
        "start" : [
99
            {
100
                token : "string.interpolated",
101
                regex : /'((?:\.?[a-z][a-zA-Z0-9_.]*)(?:\$|#|:[0-9]+)?)'/
102
            }, {
103
                token : ["text", "text", "keyword.operator", "text", "keyword"],
104
                regex : /(^\s*)(?:(\.?[a-z][a-zA-Z0-9_.]*\$?\s+)(=)(\s+))?(stopwatch)/
105
            }, {
106
                token : ["text", "keyword", "text", "string"],
107
                regex : /(^\s*)(print(?:line|tab)?|echo|exit|pause|send(?:praat|socket)|include|execute|system(?:_nocheck)?)(\s+)(.*)/
108
            }, {
109
                token : ["text", "keyword"],
110
                regex : "(^\\s*)(" + directives + ")$"
111
            }, {
112
                token : ["text", "keyword.operator", "text"],
113
                regex : /(\s+)((?:\+|-|\/|\*|<|>)=?|==?|!=|%|\^|\||and|or|not)(\s+)/
114
            }, {
115
                token : ["text", "text", "keyword.operator", "text", "keyword", "text", "keyword"],
116
                regex : /(^\s*)(?:(\.?[a-z][a-zA-Z0-9_.]*\$?\s+)(=)(\s+))?(?:((?:no)?warn|(?:unix_)?nocheck|noprogress)(\s+))?((?:[A-Z][^.:"]+)(?:$|(?:\.{3}|:)))/
117
            }, {
118
                token : ["text", "keyword", "text", "keyword"],
119
                regex : /(^\s*)((?:no(?:warn|check))?)(\s*)(\b(?:editor(?::?)|endeditor)\b)/
120
            }, {
121
                token : ["text", "keyword", "text", "keyword"],
122
                regex : /(^\s*)(?:(demo)?(\s+))((?:[A-Z][^.:"]+)(?:$|(?:\.{3}|:)))/
123
            }, {
124
                token : ["text", "keyword", "text", "keyword"],
125
                regex : /^(\s*)(?:(demo)(\s+))?(10|12|14|16|24)$/
126
            }, {
127
                token : ["text", "support.function", "text"],
128
                regex : /(\s*)(do\$?)(\s*:\s*|\s*\(\s*)/
129
            }, {
130
                token : "entity.name.type",
131
                regex : "(" + objectTypes + ")"
132
            }, {
133
                token : "variable.language",
134
                regex : "(" + predefinedVariables + ")"
135
            }, {
136
                token : ["support.function", "text"],
137
                regex : "((?:" + functions + ")\\$?)(\\s*(?::|\\())"
138
            }, {
139
                token : "keyword",
140
                regex : /(\bfor\b)/,
141
                next : "for"
142
            }, {
143
                token : "keyword",
144
                regex : "(\\b(?:" + keywords + ")\\b)"
145
            }, {
146
                token : "string",
147
                regex : /"[^"]*"/
148
            }, {
149
                token : "string",
150
                regex : /"[^"]*$/,
151
                next : "brokenstring"
152
            }, {
153
                token : ["text", "keyword", "text", "entity.name.section"],
154
                regex : /(^\s*)(\bform\b)(\s+)(.*)/,
155
                next : "form"
156
            }, {
157
                token : "constant.numeric",
158
                regex : /\b[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
159
            }, {
160
                token : ["keyword", "text", "entity.name.function"],
161
                regex : /(procedure)(\s+)([^:\s]+)/
162
            }, {
163
                token : ["entity.name.function", "text"],
164
                regex : /(@\S+)(:|\s*\()/
165
            }, {
166
                token : ["text", "keyword", "text", "entity.name.function"],
167
                regex : /(^\s*)(call)(\s+)(\S+)/
168
            }, {
169
                token : "comment",
170
                regex : /(^\s*#|;).*$/
171
            }, {
172
                token : "text",
173
                regex : /\s+/
174
            }
175
        ],
176
        "form" : [
177
            {
178
                token : ["keyword", "text", "constant.numeric"],
179
                regex : /((?:optionmenu|choice)\s+)(\S+:\s+)([0-9]+)/
180
            }, {
181
                token : ["keyword", "constant.numeric"],
182
                regex : /((?:option|button)\s+)([+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b)/
183
            }, {
184
                token : ["keyword", "string"],
185
                regex : /((?:option|button)\s+)(.*)/
186
            }, {
187
                token : ["keyword", "text", "string"],
188
                regex : /((?:sentence|text)\s+)(\S+\s*)(.*)/
189
            }, {
190
                token : ["keyword", "text", "string", "invalid.illegal"],
191
                regex : /(word\s+)(\S+\s*)(\S+)?(\s.*)?/
192
            }, {
193
                token : ["keyword", "text", "constant.language"],
194
                regex : /(boolean\s+)(\S+\s*)(0|1|"?(?:yes|no)"?)/
195
            }, {
196
                token : ["keyword", "text", "constant.numeric"],
197
                regex : /((?:real|natural|positive|integer)\s+)(\S+\s*)([+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b)/
198
            }, {
199
                token : ["keyword", "string"],
200
                regex : /(comment\s+)(.*)/
201
            }, {
202
                token : "keyword",
203
                regex : 'endform',
204
                next : "start"
205
            }
206
        ],
207
        "for" : [
208
            {
209
                token : ["keyword", "text", "constant.numeric", "text"],
210
                regex : /(from|to)(\s+)([+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?)(\s*)/
211
            }, {
212
                token : ["keyword", "text"],
213
                regex : /(from|to)(\s+\S+\s*)/
214
            }, {
215
                token : "text",
216
                regex : /$/,
217
                next : "start"
218
            }
219
        ],
220
        "brokenstring" : [
221
            {
222
                token : ["text", "string"],
223
                regex : /(\s*\.{3})([^"]*)/
224
            }, {
225
                token : "string",
226
                regex : /"/,
227
                next : "start"
228
            }
229
        ]
230
    };
231
};
232

    
233
oop.inherits(PraatHighlightRules, TextHighlightRules);
234

    
235
exports.PraatHighlightRules = PraatHighlightRules;
236
});
237

    
238
ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
239
"use strict";
240

    
241
var Range = require("../range").Range;
242

    
243
var MatchingBraceOutdent = function() {};
244

    
245
(function() {
246

    
247
    this.checkOutdent = function(line, input) {
248
        if (! /^\s+$/.test(line))
249
            return false;
250

    
251
        return /^\s*\}/.test(input);
252
    };
253

    
254
    this.autoOutdent = function(doc, row) {
255
        var line = doc.getLine(row);
256
        var match = line.match(/^(\s*\})/);
257

    
258
        if (!match) return 0;
259

    
260
        var column = match[1].length;
261
        var openBracePos = doc.findMatchingBracket({row: row, column: column});
262

    
263
        if (!openBracePos || openBracePos.row == row) return 0;
264

    
265
        var indent = this.$getIndent(doc.getLine(openBracePos.row));
266
        doc.replace(new Range(row, 0, row, column-1), indent);
267
    };
268

    
269
    this.$getIndent = function(line) {
270
        return line.match(/^\s*/)[0];
271
    };
272

    
273
}).call(MatchingBraceOutdent.prototype);
274

    
275
exports.MatchingBraceOutdent = MatchingBraceOutdent;
276
});
277

    
278
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
279
"use strict";
280

    
281
var oop = require("../../lib/oop");
282
var Range = require("../../range").Range;
283
var BaseFoldMode = require("./fold_mode").FoldMode;
284

    
285
var FoldMode = exports.FoldMode = function(commentRegex) {
286
    if (commentRegex) {
287
        this.foldingStartMarker = new RegExp(
288
            this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
289
        );
290
        this.foldingStopMarker = new RegExp(
291
            this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
292
        );
293
    }
294
};
295
oop.inherits(FoldMode, BaseFoldMode);
296

    
297
(function() {
298
    
299
    this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
300
    this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
301
    this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
302
    this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
303
    this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
304
    this._getFoldWidgetBase = this.getFoldWidget;
305
    this.getFoldWidget = function(session, foldStyle, row) {
306
        var line = session.getLine(row);
307
    
308
        if (this.singleLineBlockCommentRe.test(line)) {
309
            if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
310
                return "";
311
        }
312
    
313
        var fw = this._getFoldWidgetBase(session, foldStyle, row);
314
    
315
        if (!fw && this.startRegionRe.test(line))
316
            return "start"; // lineCommentRegionStart
317
    
318
        return fw;
319
    };
320

    
321
    this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
322
        var line = session.getLine(row);
323
        
324
        if (this.startRegionRe.test(line))
325
            return this.getCommentRegionBlock(session, line, row);
326
        
327
        var match = line.match(this.foldingStartMarker);
328
        if (match) {
329
            var i = match.index;
330

    
331
            if (match[1])
332
                return this.openingBracketBlock(session, match[1], row, i);
333
                
334
            var range = session.getCommentFoldRange(row, i + match[0].length, 1);
335
            
336
            if (range && !range.isMultiLine()) {
337
                if (forceMultiline) {
338
                    range = this.getSectionRange(session, row);
339
                } else if (foldStyle != "all")
340
                    range = null;
341
            }
342
            
343
            return range;
344
        }
345

    
346
        if (foldStyle === "markbegin")
347
            return;
348

    
349
        var match = line.match(this.foldingStopMarker);
350
        if (match) {
351
            var i = match.index + match[0].length;
352

    
353
            if (match[1])
354
                return this.closingBracketBlock(session, match[1], row, i);
355

    
356
            return session.getCommentFoldRange(row, i, -1);
357
        }
358
    };
359
    
360
    this.getSectionRange = function(session, row) {
361
        var line = session.getLine(row);
362
        var startIndent = line.search(/\S/);
363
        var startRow = row;
364
        var startColumn = line.length;
365
        row = row + 1;
366
        var endRow = row;
367
        var maxRow = session.getLength();
368
        while (++row < maxRow) {
369
            line = session.getLine(row);
370
            var indent = line.search(/\S/);
371
            if (indent === -1)
372
                continue;
373
            if  (startIndent > indent)
374
                break;
375
            var subRange = this.getFoldWidgetRange(session, "all", row);
376
            
377
            if (subRange) {
378
                if (subRange.start.row <= startRow) {
379
                    break;
380
                } else if (subRange.isMultiLine()) {
381
                    row = subRange.end.row;
382
                } else if (startIndent == indent) {
383
                    break;
384
                }
385
            }
386
            endRow = row;
387
        }
388
        
389
        return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
390
    };
391
    this.getCommentRegionBlock = function(session, line, row) {
392
        var startColumn = line.search(/\s*$/);
393
        var maxRow = session.getLength();
394
        var startRow = row;
395
        
396
        var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
397
        var depth = 1;
398
        while (++row < maxRow) {
399
            line = session.getLine(row);
400
            var m = re.exec(line);
401
            if (!m) continue;
402
            if (m[1]) depth--;
403
            else depth++;
404

    
405
            if (!depth) break;
406
        }
407

    
408
        var endRow = row;
409
        if (endRow > startRow) {
410
            return new Range(startRow, startColumn, endRow, line.length);
411
        }
412
    };
413

    
414
}).call(FoldMode.prototype);
415

    
416
});
417

    
418
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) {
419
"use strict";
420

    
421
var oop = require("../lib/oop");
422
var TextMode = require("./text").Mode;
423
var PraatHighlightRules = require("./praat_highlight_rules").PraatHighlightRules;
424
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
425
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
426

    
427
var Mode = function() {
428
    this.HighlightRules = PraatHighlightRules;
429
    this.$outdent = new MatchingBraceOutdent();
430
    this.foldingRules = new CStyleFoldMode();
431
    this.$behaviour = this.$defaultBehaviour;
432
};
433
oop.inherits(Mode, TextMode);
434

    
435
(function() {
436

    
437
    this.lineCommentStart = "#";
438

    
439
    this.getNextLineIndent = function(state, line, tab) {
440
        var indent = this.$getIndent(line);
441

    
442
        var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
443
        var tokens = tokenizedLine.tokens;
444

    
445
        if (tokens.length && tokens[tokens.length-1].type == "comment") {
446
            return indent;
447
        }
448

    
449
        if (state == "start") {
450
            var match = line.match(/^.*[\{\(\[:]\s*$/);
451
            if (match) {
452
                indent += tab;
453
            }
454
        }
455

    
456
        return indent;
457
    };
458

    
459
    this.checkOutdent = function(state, line, input) {
460
        return this.$outdent.checkOutdent(line, input);
461
    };
462

    
463
    this.autoOutdent = function(state, doc, row) {
464
        this.$outdent.autoOutdent(doc, row);
465
    };
466

    
467
    this.$id = "ace/mode/praat";
468
}).call(Mode.prototype);
469

    
470
exports.Mode = Mode;
471
});                (function() {
472
                    ace.require(["ace/mode/praat"], function(m) {
473
                        if (typeof module == "object" && typeof exports == "object" && module) {
474
                            module.exports = m;
475
                        }
476
                    });
477
                })();
478
            
(142-142/244)