From 87325ea0711efb0f9dbd56e35f37b1f5c92aabe8 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Sat, 27 Aug 2022 16:48:47 +0800 Subject: Add an ABNF specification for the grammar of the sheet. --- src/sheet/sheet grammar.abnf | 54 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/sheet/sheet grammar.abnf (limited to 'src') 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 + -- cgit v1.2.3-18-g5258