summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2022-08-27 16:48:47 +0800
committerJSDurand <mmemmew@gmail.com>2022-08-27 16:48:47 +0800
commit87325ea0711efb0f9dbd56e35f37b1f5c92aabe8 (patch)
tree11e01866a118f4b928068c355a1ca828b00e9e74
parentb7e0fa06ca5454314f1341a63148001f497ff018 (diff)
Add an ABNF specification for the grammar of the sheet.
-rw-r--r--src/sheet/sheet grammar.abnf54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/sheet/sheet grammar.abnf b/src/sheet/sheet grammar.abnf
new file mode 100644
index 0000000..b7b842e
--- /dev/null
+++ b/src/sheet/sheet grammar.abnf
@@ -0,0 +1,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 = *1octave tone *1duration
+
+octave = "o" 1*DIGIT
+
+tone = ( "a" / "b" / "c" / "d" "e" / "f" / "g" ) *tone-shift
+
+; Shifts the tone by some number of semitones
+tone-shift = "+" / "-"
+
+; A duration is either in the standard sheet notation or a precise
+; duration.
+;
+; There are no overlaps between the two variants.
+duration = 1*DIGIT *"." / "p" 1*DIGIT *1("." 1* DIGIT)
+
+cram-repetition = *1cram *1repetition
+
+cram = duration
+
+repetition = "*" 1*DIGIT
+