summaryrefslogtreecommitdiff
path: root/src/sheet/sheet grammar.abnf
blob: 3076f6b20fcfeedf19ffb74f57cdbf3b2287c839 (plain)
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
; This file documents the custom formal grammar used for the sheet.
;
; This grammar is subject to changes in the future, by the way.

; The sheet consists of a sequence of blocks, or if there is only one
; block, a sequence of groups.
sheet = 1*block / 1* group

; A block consists of a sequence of groups enclosed in curly braces.
block = "{" 1*group "}"

; A group either has several units enclosed in patentheses or one unit
; alone.
group = "(" 1*unit ")" cram-repetition / unit

; A unit is either an instruction or a note.
unit = instruction / note

; An instruction is either a volume changing one, a bpm changing one,
; or an instrument changing one.
instruction = "i" ( volume / bpm / instrument )

; A volume changing instruction follows "v"
volume = "v" 1*DIGIT *1("." 1*DIGIT)

; A bpm changing instruction is similar to a volume changing
; instruction.
bpm = "b" 1*DIGIT

; An instrument changing instruction follows "i"
instrument = "i" ( "piano" / "violin" )

; A note has three parts: octave, tone, and duration.
note = tone *("/" tone) *1duration

tone = *1octave ( "a" / "b" / "c" / "d" / "e" / "f" / "g" ) *1tone-shift

octave = "o" 1*DIGIT / 1*">" / 1*"<"

; Shifts the tone by some number of semitones
tone-shift = 1*"+" / 1*"-"

; A duration is either in the standard sheet notation or a precise
; duration.
;
; There are no overlaps between the two variants.
duration =  *DIGIT *"." / "p" 1*DIGIT *1("." 1* DIGIT)

cram-repetition = *1cram *1repetition

cram = duration

repetition = "*" 1*DIGIT