-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBraille.sublime-syntax
476 lines (436 loc) · 16 KB
/
Braille.sublime-syntax
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
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
file_extensions:
- brm.txt
- brm
- txt
- out
- PU0
scope: text.braille
variables:
## Common Braille signs
# Buchstaben ohne nationale Besonderheiten ("western")
char_western: '[a-z]'
# deutsche Basis-/ Vollschriftzeichen (+Umlaute ß au eu äu st sch)
char_de_base: '{{char_western}}|[~`98]'
char_de: '{{char_western}}|[0-5~`98\|}]'
# andere Zeichen mit Punkten 1-3
other123: '[6\+\?\(\)&7#\*,;/={]'
digit: '[a-j]'
lower_digit: '[,;:/\?\+=\(\*\)]'
number: '#{{digit}}+'
lower_number: '#{{lower_digit}}+'
fraction: '{{number}}{{lower_digit}}+'
bracket: '(?:\.)?''?=' #(eckige)? Klammer
paren: '''\.'
bracket_open: '\!\.'
bracket_close: ''','
dash: "'-"
########## Braille Music definitions ########################
## Meta Information
section: ({{number}}\s)(#{{lower_digit}}+\.?\-{{lower_digit}}+\.?)(?=\s)
music_prefix: '''\.'
staff_prefix: (_`|\$`|>`|\'`)
short_prefix: '`(?:{{char_de}}){,3}'
clef: '(?:`(#|\|)(l|k)(#(h|\())?)'
key: '[123]{1,3}|#{{digit}}[123]'
c_time: '\$c|_c' #"C" oder "Alla Breve"
key_time: '(({{key}})?({{c_time}}|{{fraction}}))|({{key}})(?:\s)|({{key}})$'
##Barline, Endings, Repeats
bar_end: '2k\.?'
fermate: '2l'
repeat_start: '2='
repeat_end: '2;'
volta_1: '#({{lower_digit}})((\-|\+#){{lower_digit}})?'
goback_repeat: '({{number}}){1,2}'
measure_repeat: '=({{number}})?'
section_repeat: ({{number}})({{lower_digit}}+\.?\-{{lower_digit}}+\.?)(?:{{pedal_off}})?(?:{{bar_end}})?(?=\s)
## Tuples
triplet: ';;?'
xtole: '_(?:[;:/\?\+=\(\*\)]){1,2}\.'
## Ornaments + Accents
mordent: '!\+l|<\+L'
trill: '[!<]?\+'
grace: '!?\?'
turnaround: '''?[123]?/'
ornament: '{{mordent}}|{{trill}}|''/l?|{{grace}}|{{turnaround}}'
# marc.||ten.||mezzostacc.||martellato||stacc....
accent: '(?:{{paren}})?(?:[\$_!''<])?\((?:{{paren}})?'
value_sign: '''2,|>2,' #Wertscheidungs- oder Gruppierungszeichen
octave : '"{1,2}(?!c)|>|_|\!|\$|\<|''{1,2}'
accidental: '(?:{{paren}}|{{bracket_open}})?(?:'')?(?:3{1,2}|2{1,2}|1)(?:{{paren}}|{{bracket_close}})?'
## Notes + Rests ################################
eigth_128 : '[defghij]'
quarter_64 : '[456789w]'
half_32 : '[nopqrst]'
whole_16: '[yz\&\%\{\~\}]'
# All together
note: '{{eigth_128}}|{{quarter_64}}|{{half_32}}|{{whole_16}}'
rest: '[xvum]'
## note_prefix
note_prefix: ({{value_sign}})?({{phrase_start}})?({{ornament}}){,2}({{pedal_on}})?((?:{{accent}})+)?''?({{accidental}})?(?:({{octave}}){,2})?
smaller_notes: '''\?(?:\?)?'
## Slurs, ties, phrases
tie: '_?"c'
chord_tie: '\$c' #Arp. Akk. Herausg. abgeh.
bow_after: '''\.cc?''\.|''?cc|{{tie}}|{{chord_tie}}|>c|<c|''?c|!cc?|!l''?cc?|_cc?'
slur_start: '(?:''|>)?cc|c'
slur_in: '\$?(?:_|!)?cc|c'
phrase_start: '<b'
phrase_end: '>;'
## Fingering
finger: '[abl,k]'
change_finger: '{{finger}}c{{finger}}'
glissando: '"a'
## Saitennummer bei Gitarre
string_number: '3[abl,k;\.]'
interval: '(?:(?:\$?!?c)?(?:{{string_number}})?(?:{{accidental}})?(?:\!\-|\||[0#\*\):\-])(?:{{finger}}){,2}(?:{{bow_after}}){,2}(?:{{glissando}})?)'
## Dynamics and other word sign stuff
# Es dürfen keine Zeichen folgen, welche die Punkte 1-3 enthalten (Punkt 3 davor)
dynamics: (sfz|fp|mp|mf|sf|fz|p{1,3}|f{1,3}|c|d)(?!{{char_de}}-`|{{other123}})
# Abs. Dynamik mit Anweisung als Text dahinter
dynamics2: (sfz|fp|mp|mf|sf|fz|p{1,3}|f{1,3}|c|d)\s+({{bracket}}?(({{char_de}}|\s)*){{bracket}}?)(?=(\n)|(`\s))
# (de)cresc. Winkel
cresc: '`[cd:/]'
cresc_end: '`:'
decresc_end: '`/'
# Chord Symbols
chord_symbol: '`\$[cdefgab]([32])?(m|maj|dim)?'
## Piano Sustain Pedal
# Ped.|*Ped.|Ped. nach Akk.los|Halbped.
pedal_on: '!?2c|12c|!1c'
pedal_off: '1c'
## Stimmzeichen: Ganztakt|Teilstimme|Teiltakt
voice_sign: '2`|!,|\$k'
# Einklangzeichen
one_tune: '_[\.kabl,]'
contexts:
# The prototype context is prepended to all contexts but those setting
# meta_include_prototype: false.
prototype:
- include: numbers
- match: '{{lower_number}}'
scope: constant.numeric.braille
main:
- meta_include_prototype: false
# The main context is the initial starting point of our syntax.
# Include other contexts from here (or specify them directly).
#- include: quoted
- include: staff
- include: lyrics
- include: section
- include: directive
- include: footnote
# - include: title
staff:
- meta_include_prototype: false
# - meta_scope: sublimelinter.mark.error.staff.braille
# Note that blackslashes don't need to be escaped within single quoted
# strings in YAML. When using single quoted strings, only single quotes
# need to be escaped: this is done by using two single quotes next to each
# other.
#TODO!!!! set anstelle von push für octave oder . (sonst mark.error.braille)
- match: '(?:({{char_de}}|\.|>|=)+(?:\s+))?(?:{{music_prefix}})({{clef}})?(?!{{note}}|\s)'
#(?={{octave}}|{{rest}}|`|#|{{accidental}}|{{note_prefix}})
scope: keyword.control.staff.start.braille
captures:
1: storage.modifier.instrument.braille
2: keyword.control.staff_prefix.braille
3: keyword.control.clef.braille
push: inside_staff
- match: '(?:({{char_de}}|\.)+)?(?:\s+)(?:{{staff_prefix}})({{clef}})?(?={{octave}}|(?:\.|`)|")'
scope: keyword.control.staff.start.braille
captures:
1: storage.modifier.instrument.braille
2: keyword.control.staff_prefix.braille
3: keyword.control.clef.braille
push: inside_staff
#short prefix without staff_prefix
- match: '(?:({{short_prefix}})(?:\.))(?={{rest}}|{{octave}}|`)'
scope: keyword.control.staff.start.braille
captures:
1: storage.modifier.instrument.braille
push: inside_staff
inside_staff:
- meta_scope: sublimelinter.mark.error.staff.braille
- meta_include_prototype: false
- include: directive
## short music
#- match: ('\.)
# scope: constant.language.staff.end.braille
# push: short_music
- match: '\.'
scope: comment.escape.braille
# . if char after music prefix contains points 1-3
- match: '!:(?:\s)' #black print page turn
scope: comment.page_turn.braille
# inmeasure simile at measure start forbidden
- match: '=(?!({{number}}|({{bow_after}}){,2})|\s|=)'
scope: invalid.simile.braille
pop: true
#full measure simile
- match: '(?=({{pedal_on}})?({{octave}})?{{measure_repeat}}({{bow_after}}){,2}({{repeat_end}})?({{bar_end}})?\s)'
scope: comment.measure.repeat.braille
push: whole_measure_simile
# guitar pima fingering
- match: '^[ pimaq]+(?=(\n))'
scope: comment.finger_line.braille
push: finger_line
# else: measure starts after first non whitespace char
- match: (?=\S) #((?:^[^\s]*)(?=\s))|((?:\s)(?=[^\s]*))
# scope: constant.character.braille
push: measure
# exit staff condition
- match: (?=(\n)|(^\s\s{{staff_prefix}}|\s\s<;))|(?=^\s{4,}{{section}})|('\.)
scope: constant.language.staff.end.braille
pop: true
finger_line:
- match: \n
scope: comment.finger_line.braille
pop: true
short_music:
- match: \s|('\.)
scope: comment.short_music.braille
pop: true
in_measure_simile:
- include: simile
- match: (?=\s)
scope: constant.measure.end.braille
pop: true
- match: \1
pop: true
simile:
- match: '{{pedal_on}}'
scope: comment.pedal.start.braille
- match: '{{bow_after}}'
scope: comment.slur_tie.braille
- match: \.
scope: storage.modifier.repeat.seperator.braille
whole_measure_simile:
- meta_scope: comment.measure.repeat.braille
- include: simile
#whole measure simile end
- match: \s
scope: constant.measure.end.braille
pop: true
measure:
- meta_include_prototype: false
- meta_scope: constant.language.measure.braille
# section reference (repeat)
- match: '{{section_repeat}}'
scope: comment.section.repeat.braille
# key/time
- match: '{{key_time}}'
scope: constant.numeric.key_time.braille
# voice sign
- match: '{{voice_sign}}'
scope: invalid.measure.voice.braille
- match: '`\?\*(?:{{number}})?'
scope: comment.footnote.braille
- match: _`|\$`
scope: keyword.control.change_hand.braille
# smaller/ bigger notes
# - match: '{{smaller_notes}}'
# scope: comment.smaller_notes.braille
# line break
- match: '!$'
scope: invalid.measure.break.braille
- match: '!(?=\s)'
scope: invalid.measure.separator.braille
# repeats
- match: '({{volta_1}})\.?'
scope: comment.volta.braille
- match: '{{repeat_start}}'
scope: comment.bar_repeat.start.braille
- match: '{{number}}m'
scope: comment.whole_rest.repeat.braille
- match: '((?:{{pedal_on}})?{{goback_repeat}}(?={{repeat_end}})?(?={{bar_end}})?)'
scope: comment.goback.repeat.braille
- match: '(?:(?:{{pedal_on}})?(?:{{measure_repeat}})(?:{{bow_after}}{,2})?)'
scope: comment.inmeasure.repeat.braille
push: in_measure_simile
# captures:
# 1: comment.pedal.start.braille
# 2: comment.slur_tie.braille
# 3: comment.repeat.end.braille
# 4: comment.bar.end.braille
# segno, coda
- match: '0l'
scope: constant.coda.braille
- match: '0'
scope: constant.segno.braille
- match: '{{cresc_end}}'
scope: punctuation.crescendo.end.braille
- match: '{{decresc_end}}'
scope: punctuation.decrescendo.end.braille
- match: '{{phrase_start}}'
scope: comment.phrase.start.braille
- match: '{{phrase_end}}'
scope: comment.phrase.end.braille
# barlines
- match: '(`?{{repeat_end}})?({{bar_end}})?({{fermate}})?' #barline/repeats
captures:
1: comment.measure.repeat_end.braille
2: comment.measure.barline.braille
3: comment.measure.fermate.braille
# notes incl. prefix (accid., bow_start, ornaments),
# postfix (finger, slurs, intervals)... TODO(?<!`)
# TODO: make multiple occur. items non capturing or push
- match: '(?x:({{value_sign}})?({{triplet}})?({{phrase_start}})?
({{slur_in}})?({{string_number}})?
((?:{{ornament}}){,2})?({{pedal_on}})?((?:{{accent}})+)?
''?({{accidental}})?
(?:({{octave}}){,2})?({{note}})(\.{,2})
((?:{{change_finger}}|{{finger}})+)?
((?:{{bow_after}}){,2})?({{glissando}})?
((?:{{interval}})+)?
({{fermate}})?({{phrase_end}})?
((?:{{paren}})?(?:{{pedal_off}})(?:{{paren}})?)?)'
scope: entity.name.note.braille
captures:
1: comment.value_sign.braille
2: comment.triplet.braille
3: comment.phrase_start.braille
4: comment.slur_tie.braille
5: variable.string_number.braille
6: invalid.deprecated.ornament.braille
# 5: invalid.deprecated.accent.braille
7: string.pedal.braille
8: invalid.deprecated.accents.braille
9: comment.accidental.braille
10: support.class.octave.braille
11: entity.name.note_name.braille
12: entity.dots.braille
13: variable.note.finger.braille
14: comment.slur_tie.braille
15: string.quoted.glissando.braille
16: meta.diff.interval.braille
17: comment.fermate.braille
18: comment.phrase.end.braille
#12: markup.inserted.interval.accidental.braille
# 13: markup.inserted.interval.interval.braille
# 17: markup.inserted.interval.finger.braille
19: string.inserted.pedal_off.braille
- match: '({{value_sign}})?({{triplet}})?({{pedal_on}})?{{rest}}(\.{,2})'
scope: entity.name.rest.braille
captures:
1: comment.value_sign.braille
2: comment.triplet.braille
3: string.pedal.braille
4: entity.dots.braille
- match: '({{ornament}})?({{pedal_on}})?((?:{{accent}})+)?''?({{accidental}})?({{octave}})?({{one_tune}})(\.{,2})((?:{{finger}})+)?((?:{{bow_after}}){,2})?'
scope: keyword.one_tune.braille
- match: '`({{bracket}})?({{dynamics2}}|{{dynamics}})({{bracket}})?'
scope: punctuation.dynamics.braille
- match: '!?`k{1,2}' #(?!{{char_de}}-`|{{other123}})
scope: punctuation.arpeggio.braille
- match: '`>[a-z](?={{octave }})'
scope: invalid.rehearsal_mark.braille
- match: '{{chord_symbol}}'
scope: punctuation.chord_symbol.braille
# push:
# - match: '\1(\.)?'
# captures:
# 1: punctuation.dynamics.end.braille
# pop: true
# directive texts
- match: '(`(?!{{bar_end}})({{dash}}|{{bracket}})?(>?#{{digit}}|#{{lower_digit}}|{{char_de_base}}-`|=|\.)*\.?)'
#'`({{bracket}})?(({{char_de}}-`)|\s|\.)+{{bracket}}?'
scope: string.quoted.word.braille
# can be multiline-> push!
push: word
# measure end condition = whitespace or newline
- match: \s|(?=.'\.)
scope: constant.measure.end.braille
pop: true
#Wortzeichen
word:
- meta_scope: string.quoted.word.braille
- match: ((#{{digit}}|#{{lower_digit}}|>|{{char_de_base}}-`|\s|(\.\s))*(({{dash}})|({{bracket}}))?(?=\.\(|(`\s|`2k|2k|2;|{{octave}}))) #|(\.\.{{rest}})
# scope: constant.language.end.braille
pop: true
numbers:
- match: '#{{digit}}+'
scope: constant.numeric.braille
paren:
- match: '''\.'
push:
- match: '''\.'
pop: true
quoted:
- match: '''\..*''\.'
scope: punctuation.definition.comment.braille
directive:
# Rhythm directive like note=ca.bpm
- match: '(?:''\.)?({{note}})=(ca.)?({{number}})(?=\s)'
scope: constant.language.rhythm.braille
captures:
1: constant.language.rhythm.note.braille
2: constant.language.rhythm.circa.braille
3: constant.language.rhythm.bpm.braille
# Key and Time
- match: '(?:\s\s){{key_time}}(?:\s)'
scope: variable.parameter.directive.braille
captures:
1: constant.numeric.key_time.braille
2: constant.numeric.key.braille
3: constant.numeric.time.braille
4: constant.numeric.key.braille
5: constant.numeric.key.braille
# - match: '(^\s{4})(({{char_de}}|,)*(?=\s)){1,4}'
# scope: constant.language.directive.braille
#- match: '^(\s)*(?:\s)({{char_de}})+(?:\s)'
# push:
# - match: \1\s+(?={{section}})
# scope: constant.language.directive.braille
# pop: true
## Footnote text below score
footnote:
- match: '\s{5}`\?\*\s\S.*'
scope: comment.footnote.braille
set:
- match: '^(\s{4}\S.*)'
scope: comment.footnote.braille
- match: '^(?!\s{4}\S)'
pop: true
section:
- meta_include_prototype: false
- match: '{{section}}'
scope: meta.diff.section.braille
captures:
1: meta.diff.section.number.braille
2: meta.diff.section.measure_range.braille
title:
- meta_include_prototype: false
# match underlines only (?)
- match: '\s*({{number}}|{{lower_number}}(?=\s+))?(["|\$|>]?({{char_de}}|{{other123}}){1,100}|\s|\-)+' #'\(?\>?\$?[a-z0-9`,~''"\}\*\-\$]+\)?\s' #(:{6,7}|={6,7})
scope: comment.title.braille
captures:
1 : constant.numeric.braille
lyrics:
# lyrics start with lyrics prefix
- match: '\s\s<;'
scope: keyword.control.lyrics.braille
push: inside_lyrics
inside_lyrics:
- meta_scope: string.lyrics.braille
# - meta_include_prototype: false
# Lyrics repeats
- match: '`\?\*(?:{{number}})?'
scope: comment.footnote.braille
- match: '(?!\`\?)\*{1,2}'
scope: comment.lyrics.repeat.braille
push:
- match: '\(.*\)'
# mehrere Silben auf einer Note
scope: variable.lyrics.melisma.braille
- match: '\*{1,2}'
scope: comment.lyrics.repeat.braille
pop: true
- match: '\(.*\)'
scope: variable.lyrics.melisma.braille
# exit condition: double space, not next verse
- match: (?=(^\s\s(?!#|\s\S))|{{short_prefix}}|('\.\S)|(?:\s\s{{section}}))
scope: punctuation.definition.string.end.braille
pop: true