-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
source.praat.js
445 lines (443 loc) · 18.8 KB
/
source.praat.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/orhunulusahin/praatvscode>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.praat'],
names: ['praat'],
patterns: [{include: '#language'}, {include: '#paren-expression'}],
repository: {
assignment: {match: '=', name: 'keyword.operator.key.praat'},
'class-builtin': {
match:
'\\b((Long)?Sound|Text(Grid|Tier)|Formant(Grid)?|Strings|all|Intensity(Tier)?|Pitch(Tier)?|PointProcess|Table(OfReal)?|Matrix|Polygon|Distributions|PairDistribution|Permutation|ParamCurve|Harmonicity|Electroglottogram|Spectrum|Ltas|LPC|Cepstrum|(LF|MF)?CC|Excitation(s)?|Cochleagram|Manipulation|Duration(Tier)?|Speaker|Articulation|VocalTract|FFNet|PatternList|Categories|Eigen|Polynomial|Roots|ChebyshevSeries|LegendreSeries|(I|M)Spline|Covariance|Confusion|Discriminant|ExperimentMFC|PCA|Correlation|ClassificationTable|SSCP|DTW|Configuration|Dissimilarity|Similarity|Distance|ScalarProduct|ContingencyTable|OTGrammar|WordList|SpellingChecker)\\b',
name: 'support.class.builtin.praat'
},
comments: {
begin: '(^|\\s|\\t|\\b)(#|;)',
beginCaptures: {0: {name: 'punctuation.definition.comment.praat'}},
end: '$',
name: 'comment.line.number-sign.praat'
},
console: {
patterns: [
{
captures: {
1: {name: 'support.function.praat'},
2: {name: 'keyword.variable.language.praat'}
},
match: '\\b(write|append)((Info|File)(Line)?)\\b',
name: 'support.function.praat'
},
{
begin: '\\b(clear)',
beginCaptures: {1: {name: 'support.function.praat'}},
end: '(info)\\b',
endCaptures: {1: {name: 'keyword.variable.language.praat'}},
name: 'support.function.praat'
},
{match: '\\b(echo|printline)\\b', name: 'support.function.praat'}
]
},
control: {
match:
'\\b(for|while|end(for|while|if|form|proc|editor)|from|to|repeat|until|if|then|fi|else|elsif|elif|nowarn|noprogress|nocheck|assert|form|call|procedure|Edit|editor)\\b',
name: 'keyword.control.praat'
},
'file-function': {
match:
'(\\s)*?\\b(fileReadable|readFile(\\$)?|createFolder|deleteFile|fileNames\\$\\#)(\\b|\\s)',
name: 'support.function.string.praat'
},
import: {
match: '(?i)\\b(include)\\s',
name: 'keyword.control.import.include.praat'
},
'interface-function': {
patterns: [
{
match: '\\b(pauseScript|beginPause|endPause|runSystem(_nocheck)?)\\b',
name: 'support.function.praat'
},
{
begin: '(\\s)*?\\b(printline|exit|pause|echo|print|exitScript[:])\\s',
beginCaptures: {0: {name: 'support.function.praat'}},
end: '(.)*?$',
endCaptures: {0: {name: 'string.punctuation.praat'}}
},
{
begin: '(\\s)*?\\bform\\s',
beginCaptures: {0: {name: 'keyword.control.praat'}},
end: '(.)*?$',
endCaptures: {0: {name: 'string.punctuation.praat'}}
},
{
begin: '(\\s)*?\\bcomment\\s',
beginCaptures: {0: {name: 'storage.type.praat'}},
end: '(.)*?$',
endCaptures: {0: {name: 'string.punctuation.praat'}}
}
]
},
interpolation: {
patterns: [
{
match: '\\\\[0-7]{1,3}',
name: 'constant.character.escape.octal.praat'
},
{
match: '\\\\x[0-9A-Fa-f]{1,2}',
name: 'constant.character.escape.hex.praat'
},
{
match: '\\\\u{[0-9A-Fa-f]+}',
name: 'constant.character.escape.unicode.praat'
},
{match: '\\\\[nrtvef$\\\\]', name: 'constant.character.escape.praat'}
]
},
language: {
patterns: [
{include: '#comments'},
{include: '#predefined-numeric'},
{include: '#predefined-string'},
{include: '#sound-function'},
{include: '#string-function'},
{include: '#file-function'},
{include: '#interface-function'},
{include: '#open-menu-function'},
{include: '#new-menu-function'},
{include: '#sound-save-function'},
{include: '#other-save-function'},
{include: '#textgrid-query-function'},
{include: '#textgrid-gui-function'},
{include: '#textgrid-tabulate-function'},
{include: '#textgrid-analyse-function'},
{include: '#textgrid-synthesize-function'},
{include: '#textgrid-sound-function'},
{include: '#sound-draw-function'},
{include: '#sound-query-function'},
{include: '#sound-modify-function'},
{include: '#sound-annotate-function'},
{include: '#sound-periodicity-function'},
{include: '#sound-spectrum-function'},
{include: '#sound-convert-function'},
{include: '#sound-filter-function'},
{include: '#sound-combine-function'},
{include: '#strings-function'},
{include: '#select-function'},
{include: '#math-function'},
{include: '#proc-declaration'},
{include: '#string-variables'},
{include: '#strings'},
{include: '#operators'},
{include: '#console'},
{include: '#import'},
{include: '#control'},
{include: '#class-builtin'},
{include: '#types-builtin'},
{include: '#textgrid-function'},
{include: '#numeric-variables'},
{include: '#numbers'}
]
},
math: {
patterns: [
{
match: '\\-|\\^|\\*|\\/|\\+|(\\<\\>)|\\<|\\>|(\\<\\=)|(\\>\\=)',
name: 'keyword.operator.key.praat'
},
{
match:
'\\b(abs|round|floor|ceiling|sqrt|min|max|imin|imax|sin(c(pi)?|h)?|cos(h)?|tan(h)?|arcsin(h)?|arccos(h)?|arctan(h|2)?|exp|ln|log(10|2)|sigmoid|invSigmoid|erf(c)?|random(Uniform|Integer|Gauss|Poisson|Gamma|_initilialize(WithSeedUnsafelyButPredictably|SafelyAndUnpredictably))|Gauss(P|Q)|lnGamma|invGaussQ|chiSquare(P|Q)|invChiSquareQ|student(P|Q)|fisher(P|Q)|invFisherQ|binomial(P|Q)|incBinomial(P|Q)|hertzTo(Bark|Mel|Semitomes|Erb)|barkToHertz|melToHertz|semitonesToHertz|erb(ToHertz)?|phonToDifferenceLimens|differenceLimensToPhon|beta|bessel(I|K))\\b',
name: 'support.function.math.praat'
}
]
},
'new-menu-function': {
match:
'(\\s)*?\\b(Record (mono|stereo) Sound|Create (Sound (from formula|as (pure tone|tone complex|gammatone|Shepard tone)|from VowelEditor)|(simple )?Matrix( from values)?|(simple )? Photo|Table with(out)? column names|simple (Confusion|Covariance|Correlation)|empty EditCostsTable|empty PointProcess|Poisson process|(Pitch|Intensity|Duration|Amplitude|Real)Tier|FormantGrid|TextGrid|Corpus|Strings (as file list|as folder list|from tokens)|Articulation|Speaker|Artword|Vocal Tract from phone|Permutation|SpeechSynthesizer))\\b',
name: 'support.function.praat'
},
numbers: {
match:
'\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)\\b',
name: 'constant.numeric.praat'
},
'numeric-variables': {
captures: {
1: {name: 'variable.other.praat'},
2: {name: 'variable.other.praat'},
3: {name: 'variable.other.praat'},
4: {name: 'keyword.operator.praat'}
},
match: '^(\\b|\\s|\\t)*?([a-z])(?i)((?:_?[a-z0-9_]+))?(\\b|\\s)*?\\='
},
'open-menu-function': {
match:
'(\\s)*?\\b(Read (from file|Sound (Alaw file|16\\-bit (Little|Big) Endian file)|separate channels from sound file|Matrix from raw text file|TableOfReal from headerless spreadsheet file|Table from (tab|comma|semicolon|whitespace)\\-separated file|Strings from raw text file|(Text|Interval)Tier from Xwaves)|Open long sound file)\\b',
name: 'support.function.string.praat'
},
operators: {
patterns: [
{
match: '\\.\\.\\.\\s|\\b(\\:\\s|not|and|or|div|mod|yes|no|self)\\b',
name: 'constant.language.operator.praat'
},
{include: '#math'},
{include: '#assignment'}
]
},
'other-save-function': {
match:
'(\\s)*?\\b((Save as|Write to) ((short |chronological |matrix )?text|binary|headerless spreadsheet) file)\\b',
name: 'support.function.string.praat'
},
'paren-expression': {
begin: '\\(',
beginCaptures: {0: {name: 'punctuation.paren.open.praat'}},
end: '\\)',
endCaptures: {0: {name: 'punctuation.paren.close.praat'}},
name: 'expression.group',
patterns: [{include: '#language'}]
},
'predefined-numeric': {
match:
'\\b(macintosh|windows|unix|praatVersion|pi|e|undefined|stopwatch)\\b',
name: 'constant.language.praat'
},
'predefined-string': {
match: '\\s*(newline|tab|shellDirectory|environment)\\$\\s*',
name: 'constant.language.praat'
},
'proc-declaration': {
patterns: [
{
captures: {
2: {name: 'keyword.control.praat'},
3: {name: 'support.function.praat'},
4: {name: 'support.function.praat'}
},
match:
'(\\b|\\s|\\t)*?(procedure)\\s([a-z][a-zA-Z0-9_]+)(\\:)?(\\b|\\s)?'
}
]
},
'regex-double-quoted': {
begin: '(?x)"/ (?= (\\\\.|[^"/])++/[imsxeADSUXu]*" )',
beginCaptures: {0: {name: 'punctuation.definition.string.begin.praat'}},
end: '(/)([imsxeADSUXu]*)(")',
endCaptures: {0: {name: 'punctuation.definition.string.end.praat'}},
name: 'string.regexp.double-quoted.praat',
patterns: [
{
match: '(\\\\){1,2}[.$^\\[\\]{}]',
name: 'constant.character.escape.regex.praat'
},
{include: '#interpolation'},
{
captures: {
1: {name: 'punctuation.definition.arbitrary-repetition.praat'},
3: {name: 'punctuation.definition.arbitrary-repetition.praat'}
},
match: '(\\{)\\d+(,\\d+)?(\\})',
name: 'string.regexp.arbitrary-repetition.praat'
},
{
begin: '\\[(?:\\^?\\])?',
captures: {0: {name: 'punctuation.definition.character-class.praat'}},
end: '\\]',
name: 'string.regexp.character-class.praat',
patterns: [{include: '#interpolation'}]
},
{match: '[$^+*]', name: 'keyword.operator.regexp.praat'}
]
},
'regex-single-quoted': {
begin:
"(?x)'/ (?= ( \\\\ (?: \\\\ (?: \\\\ [\\\\']? | [^'] ) | . ) | [^'/] )++/[imsxeADSUXu]*' )",
beginCaptures: {0: {name: 'punctuation.definition.string.begin.praat'}},
end: "(/)([imsxeADSUXu]*)(')",
endCaptures: {0: {name: 'punctuation.definition.string.end.praat'}},
name: 'string.regexp.single-quoted.praat',
patterns: [
{
captures: {
1: {name: 'punctuation.definition.arbitrary-repetition.praat'},
3: {name: 'punctuation.definition.arbitrary-repetition.praat'}
},
match: '(\\{)\\d+(,\\d+)?(\\})',
name: 'string.regexp.arbitrary-repetition.praat'
},
{
begin: '\\[(?:\\^?\\])?',
captures: {0: {name: 'punctuation.definition.character-class.praat'}},
end: '\\]',
name: 'string.regexp.character-class.praat',
patterns: [{include: '#single_quote_regex_escape'}]
},
{match: '[$^+*]', name: 'keyword.operator.regexp.praat'},
{include: '#single_quote_regex_escape'}
],
repository: {
single_quote_regex_escape: {
match: "(?x) \\\\ (?: \\\\ (?: \\\\ [\\\\']? | [^'] ) | . )",
name: 'constant.character.escape.praat'
}
}
},
'select-function': {
captures: {2: {name: 'support.function.praat'}},
match:
'(\\s)*?\\b(select(Object| all)?|plus(Object)?|minus(Object)?|Remove|removeObject|Concatenate|Rename|Selected(\\$)?|Info|Inspect|Copy)\\b'
},
'sound-annotate-function': {
match: '(\\s)*?\\b(To TextGrid( \\((silences|voice activity)\\))?)',
name: 'support.function.praat'
},
'sound-combine-function': {
match:
'(\\s)*?\\b(Combine (to stereo|into Sound(List|Set))|Concatenate( recoverably| with overlap)?|Convolve|Cross\\-correlate|To (CrossCorrelationTable \\(combined\\)|DTW|ParamCurve))',
name: 'support.function.praat'
},
'sound-convert-function': {
match:
'(\\s)*?\\b(Convert to (mono|stereo)|Extract (all channels|one channel|channels|part( for overlap)?|Electroglottogram)|Resample|To (Sound \\((white channels|bss)\\)|CrossCorrelationTable)|Lengthen \\(overlap-add\\)|Deepen band modulation|Change gender|Down to Matrix)',
name: 'support.function.praat'
},
'sound-draw-function': {
match: '\\b(Draw( where)?|Paint (where|enclosed))\\b',
name: 'support.function.praat'
},
'sound-filter-function': {
match:
'(\\s)*?\\b(Filter \\((pass Hann band|stop Hann band|formula|one formant|pre\\-emphasis|de\\-emphasis|gammatone|inverse)\\)|Reduce noise)',
name: 'support.function.praat'
},
'sound-function': {
match: '\\b(Play|To Intensity|Down to)\\b',
name: 'support.function.praat'
},
'sound-modify-function': {
match:
'\\b(Shift times (by|to)|Scale (peak|intensity|times (by|to))|Reverse|Formula( \\(part\\))?|Add|Subtract mean|Multiply( by window)?|Set (value at sample number|part to zero)|Override sampling frequency|Pre-emphasize \\(in-place\\)|De-emphasize \\(in-place\\))',
name: 'support.function.praat'
},
'sound-periodicity-function': {
match:
'(\\s)*?\\b(To (Manipulation|Pitch( \\((ac|cc|SPINET|shs)\\))?|PointProcess \\((periodic\\, cc|periodic\\, peaks|extrema|zeroes)\\)|Harmonicity \\(cc|ac|gne\\)|PowerCepstrogram)|Autocorrelate)',
name: 'support.function.praat'
},
'sound-query-function': {
match:
'\\b(Get (start time|end time|total duration|number of channels|number of samples|sampling period|sampling frequency|time from sample number|sample number from time|value at (time|sample number)|minimum|maximum|time of (minimum|maximum)|absolute extremum|nearest (zero crossing|level crossing)|mean|root-mean-square|standard deviation|energy( in air)?|power( in air)?|intensity \\(dB\\))|List all sample times)',
name: 'support.function.praat'
},
'sound-save-function': {
captures: {2: {name: 'support.function.praat'}},
match:
'(\\s)*?\\b((Save as|Write to) ((short)? text|binary|((24|32)\\-bit )?WAV|AIFF|AIFC|Next\\/Sun|NIST|FLAC|Kay|raw (8\\-bit (un)?signed|(16|24|32)\\-bit (big|little)\\-endian)) file|Append to existing sound file)\\b'
},
'sound-spectrum-function': {
match:
'\\b(To (Spectrum|Ltas( \\(pitch-corrected\\))?|Spectrogram( \\(pitch-dependent\\))?|Cochleagram|BarkSpectrogram|MelSpectrogram|Formant \\((burg|keep all|sl|robust)\\)|FormantPath( \\(burg\\))?|LPC \\((autocorrelation|covariance|burg|marple)\\)|MFCC))',
name: 'support.function.praat'
},
'string-double-quoted': {
begin: '"',
beginCaptures: {0: {name: 'punctuation.definition.string.begin.praat'}},
contentName: 'meta.string-contents.quoted.double.praat',
end: '("|$)',
endCaptures: {0: {name: 'punctuation.definition.string.end.praat'}},
name: 'string.quoted.double.praat',
patterns: [
{include: '#interpolation'},
{include: '#string-variables'},
{include: '#string-single-quoted'}
]
},
'string-function': {
match:
'(\\s)*?\\b(length|left\\$|right\\$|mid\\$|index(_regex)?|rindex(_regex)?|startsWith|endsWith|replace\\$|replace_regex(\\$)?|string\\$|fixed\\$|percent\\$|number|date\\$|unicode\\$|extract(Number|Word\\$|Line\\$)|backslashTrigraphsToUnicode\\$)(\\s)?',
name: 'support.function.string.praat'
},
'string-single-quoted': {
begin: "'",
beginCaptures: {0: {name: 'punctuation.definition.string.begin.praat'}},
contentName: 'meta.string-contents.quoted.single.praat',
end: "('|$)",
endCaptures: {0: {name: 'punctuation.definition.string.end.praat'}},
name: 'variable.string.quoted.single.praat',
patterns: [
{match: "\\\\[\\\\']", name: 'constant.character.escape.praat'}
]
},
'string-variables': {
patterns: [
{
match: '(\\b|\\s|\\t)*?[a-z](?i)(?:_?[a-z0-9_]+)\\$(\\b|\\s)?',
name: 'variable.other.praat'
},
{
captures: {1: {name: 'punctuation.definition.variable.praat'}},
match: '\\b(this)\\b',
name: 'variable.language.this.praat'
}
]
},
strings: {
patterns: [
{include: '#string-variables'},
{include: '#predefined-string'},
{include: '#string-single-quoted'},
{include: '#regex-double-quoted'},
{include: '#string-double-quoted'},
{include: '#regex-single-quoted'}
]
},
'strings-function': {
match:
'(\\s)*?\\b(Get (number of strings|string)|List all strings|(Set|Insert|Remove) string|Randomize|Sort|Convert to (backslash trigraphs|Unicode)|Replace all|To (Distributions|Permutation|WordList|Categories)|Append)\\b',
name: 'support.function.praat'
},
'textgrid-analyse-function': {
match:
'(\\s)*?\\b(Extract (one tier|part)|To Table \\(text alignment\\)|Get (starting|centre|end) points|Get points \\((preceded|followed)\\))',
name: 'support.function.praat'
},
'textgrid-gui-function': {
match: '(\\s)*?\\b(View \\& Edit alone)',
name: 'support.function.praat'
},
'textgrid-query-function': {
match:
'(\\s)*?\\b(Get (start time( of interval)?|end time( of interval)?|total duration( of interval)?|(maximum )?number of (tiers|intervals|points)|tier name|(start|end) time of (interval|point)|label of (interval|point)|(low |high )?interval at time|interval (edge|boundary) from time|total dutaion of intervals where|(low|high|nearest) index from time)|Is interval tier|Count (intervals|points) where)',
name: 'support.function.praat'
},
'textgrid-sound-function': {
match:
'(\\s)*?\\b(View \\& Edit|Draw|Extract (all|non\\-empty) intervals|Extract intervals where|Scale times|Close time domain)',
name: 'support.function.praat'
},
'textgrid-synthesize-function': {
match: '(\\s)*?\\b(Merge|Concatenate|To DurationTier)',
name: 'support.function.praat'
},
'textgrid-tabulate-function': {
match: '(\\s)*?\\b(Down to table|List|Tabulate occurrences)',
name: 'support.function.praat'
},
'types-builtin': {
match:
'\\b(real|positive|integer|natural|word|sentence|text|boolean|choice|button|comment|(in|out)file|folder|option(menu)?|(?i)hertz|(?i)mono|(?i)stereo)\\b',
name: 'storage.type.praat'
}
},
scopeName: 'source.praat'
}
export default grammar