; ABC 1.6 with extensions in BNF format ; According to BNF as described in http://ds.internic.net/rfc/rfc822.txt. ; There is also a short description of BNF as used here at the end of this file. ; By Henrik Norbeck 3 October 1997. ; Also available in html format: http://home1.swipnet.se/~w-11382/abcbnfx.htm This is a specification of Abc 1.6, plus extensions implemented by different programs. There is a comment after each extension about which programs implement this extension. Extensions that have only been proposed on the abc developers list, but not yet implemented, are commented with "; proposed". Most of the extensions here will probably be part of the Abc 1.7 standard. A text description of all the proposed extensions is available in http://home1.swipnet.se/~w-11382/abcext.txt abc-file ::= *(abc-tune / comment / linefeed / tex-command / file-fields / text-line) ; All programs? text-line ::= text end-of-line ; All programs? This is not official yet, but I think all programs ; allow uncommented text between tunes. file-fields ::= (field-file / field-book / field-group / field-history / field-information / field-meter / field-origin / field-rhythm) end-of-line field-file ::= "F:" text abc-tune ::= abc-header abc-music abc-header ::= field-number end-of-line *comment 1*(field-title end-of-line) *(other-fields end-of-line) field-key end-of-line ; In practice, many tunes are e-mailed without field-number, ; so those wishing to implement an abc parser should treat this ; field as optional. field-number ::= "X:" 1*DIGIT field-title ::= "T:" text other-fields ::= field-area / field-book / field-composer / field-discography / field-elemskip / field-group / field-history / field-information / field-default-length / field-meter / field-notes / field-origin / field-parts / field-tempo / field-rhythm / field-source / field-transcrnotes / comment / field-voice ; proposed ; field-file and field-words may not be in header (?) field-area ::= "A:" text ; maybe some of these field definitions should include an optional space: ; field-area ::= "A:" [" "] text field-book ::= "B:" text field-composer ::= "C:" text field-discography ::= "D:" text field-elemskip ::= "E:" text ; Used by abc2ps and abc2mtex for special purposes field-group ::= "G:" text field-history ::= "H:" *(text end-of-line) text field-information ::= "I:" text ; Only used by a few programs. field-default-length ::= "L:" note-length-strict field-meter ::= "M:" meter field-notes ::= "N:" text field-origin ::= "O:" text field-parts ::= "P:" parts field-tempo ::= "Q:" tempo field-rhythm ::= "R:" text field-source ::= "S:" text field-voice ::= "V:" 1*DIGIT ; Abc2midi [" name=" <"> text <">] [" clef=" clef-spec] ; proposed [" merge=" 1*DIGIT] [" stems=" ("up" / "down")] ; proposed [" transpose=" ["-"] 1*DIGIT] ; proposed field-transcrnotes ::= "Z:" field-key ::= "K:" key key ::= key-spec / "HP" / "Hp" key-spec ::= keynote [mode-spec] *(" " global-accidental) keynote ::= basenote [key-accidental] key-accidental ::= "#" / "b" mode-spec ::= [" "] mode [extratext] mode ::= mode-minor / mode-major / mode-lydian / mode-ionian / mode-mixolydian / mode-dorian / mode-aeolian / mode-phrygian / mode-locrian extratext ::= *ALPHA global-accidental ::= accidental basenote mode-minor ::= ("m"/"M") [("i"/"I") ("n"/"N")] mode-major ::= ("m"/"M") ("a"/"A") ("j"/"J") mode-lydian ::= ("l"/"L") ("y"/"Y") ("d"/"D") mode-ionian ::= ("i"/"I") ("o"/"O") ("n"/"N") mode-mixolydian ::= ("m"/"M") ("i"/"I") ("x"/"X") mode-dorian ::= ("d"/"D") ("o"/"O") ("r"/"R") mode-aeolian ::= ("a"/"A") ("e"/"E") ("o"/"O") mode-phrygian ::= ("p"/"P") ("h"/"H") ("r"/"R") mode-locrian ::= ("l"/"L") ("o"/"O") ("c"/"C") meter ::= "C" / "C|" / meter-fraction meter-fraction ::= 1*DIGIT *("+" 1*DIGIT) "/" 1*DIGIT ; Complex time signatures: Abcmus ; The old definition is as follows: ; meter-fraction ::= 1*DIGIT "/" 1*DIGIT tempo ::= 1*DIGIT / ("C" [note-length] "=" 1*DIGIT) / (note-length-strict "=" 1*DIGIT) note-length-strict ::= 1*DIGIT "/" 1*DIGIT parts ::= 1*part-spec part-spec ::= (part / ( "(" 1*part-spec ")" ) ) *DIGIT part ::= "A" / "B" / "C" / "D" / "E" / "F" / "G" / "H" / "I" / "J" / "K" / "L" / "M" / "N" / "O" / "P" / "Q" / "R" / "S" / "T" / "U" / "V" / "X" / "Y" / "Z" clef-spec ::= "treble" / "bass" / "treble-8" / "treble+8" ; proposed / "bass-8" / "alto" / "tenor" ; proposed end-of-line ::= *(" " / HTAB) ["%" text] linefeed ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; abc-music ::= 1*abc-line linefeed abc-line ::= (1*element line-ender) / tex-command / mid-tune-field / comment / private-setting ; Abc2midi element ::= note-element / tuplet-element / barline / nth-repeat / begin-slur / end-slur / space / user-defined / inline-field ; Abcmus, Abc2ps / text-above-staff ; Abcmus 1.1 / nullify-whitespace ; proposed line-ender ::= comment / linefeed / line-break / no-line-break tuplet-element ::= tuplet-spec 1*note-element tuplet-spec ::= "(" DIGIT [":" [DIGIT] [":" [DIGIT]]] note-element ::= note-stem [broken-rhythm] note-stem ::= [guitar-chord] [grace-notes] *gracings (note / multi-note) multi-note ::= "[" 1*note "]" note ::= note-or-rest [note-length] [tie] note-or-rest ::= pitch / rest pitch ::= [accidental] basenote [octave] octave ::= (1*"'") / (1*",") note-length ::= [1*DIGIT] ["/" [1*DIGIT]] accidental ::= "^" / "^^" / "_" / "__" / "=" basenote ::= "C" / "D" / "E" / "F" / "G" / "A" / "B" / "c" / "d" / "e" / "f" / "g" / "a" / "b" rest ::= "z" broken-rhythm ::= 1*"<" / 1*">" tie ::= "-" gracings ::= "~" / "." / "v" / "u" ; maybe also "J" / "R" / "L" / "H" grace-notes ::= "{" 1*pitch "}" guitar-chord ::= <"> (formal-chord / text) <"> formal-chord ::= basenote [chord-type] ["/" basenote] chord-type ::= "m" / "7" / "m7" / "0" / "o" / "+" / "mb5" / "sus" / "sus4" / "maj7" / "mmaj7" / "7sus4" / "dim" / "dim7" / "7b5" / "m7b5" / "6" / "b6" / "m6" / "mb6" / "46" / "maj9" / "9" / "add9" / "7b9" / "m9" ; There are more chord types that could be understood text-above-staff ::= "!" text "!" ; Abcmus 1.1 barline ::= "|" / "||" / "[|" / "|]" / ":|" / "|:" / "::" nth-repeat ::= "[1" / "[2" / "|1" / ":|2" begin-slur ::= "(" end-slur ::= ")" inline-field ::= "[" tune-field "]" ; Abcmus, Abc2ps mid-tune-field ::= tune-field end-of-line tune-field ::= field-elemskip / field-key / field-default-length / field-meter / field-part / field-tempo / field-title / field-words / field-rhythm ; Proposed / field-voice ; Abc2midi / field-aligned-words ; Abc2ps field-part ::= "P:" part field-words ::= "W:" text field-aligned-words ::= "w:" [1*DIGIT ".~" ] *(1*ALPHA / "|" / "*" ; Abc2ps / "-"/ "_" / "~" / "\-" / "\\" / " ") ; Abc2ps user-defined ::= "H" / "I" / "J" / "K" / "I" / "J" / "K" / "L" / "M" / "N" / "O" / "P" / "Q" / "R" / "S" / "T" / "U" / "V" / "W" / "X" / "Y" / "Z" ; Some of these have meanings in some programs: ; J = slide up to note (Abc2ps) ; H = hold, fermata (Abc2ps, Abcmus) ; L = > mark (Abc2ps) ; M = mordent (proposed) bar, emphasis (Abc2ps) ; P = pralltriller, inverted mordent (proposed) ; R = roll (Abc2ps) ; T = trill (Abc2ps) private-setting ::= "%%" text linefeed ; Abc2midi, Abc2ps ; Other programs will simply treat this as a comment. tex-command ::= "\" text linefeed space ::= " " / HTAB comment ::= "%" text (linefeed / line-break / no-line-break) line-break ::= "!" linefeed no-line-break ::= "\" linefeed linefeed ::= CRLF / LF text ::= *text-char text-char ::= ALPHA / DIGIT / " " / HTAB / <"> / "!" / "#" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / "-" / "." / "/" / ":" / ";" / "<" / "=" / ">" / "?" / "@" / "[" / "\" / "]" / "^" / "_" / "`" / "{" / "|" / "}" / "~" ; "%" is not included here (on purpose)! ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; BNF format BNF (Backus-Naur Format) is a way to describe the syntax of file formats. It consists of definitions of the form identifier ::= definition The identifier is a word which describes this part of the syntax. The ::= should be interpreted as "consists of". The definition is a list of what this part of the syntax may contain. This may be other identifiers, or literal strings (enclosed in ""). For example, a simple sentence may be defined as simple-sentence ::= (thenoun / pronoun) " " verb [ " " adverb] "." thenoun ::= "The" noun noun ::= "cat" / "dog" pronoun ::= "He" / "She" / "It" verb ::= "runs" / "bites" adverb ::= "quickly" / "fast" * before an element means that it can be repeated 0 or more times. 1* before an element means that it can be repeated 1 or more times. [] around an element means that it is optional. / between elements mean that you may choose any of the elements. () can be used to group elements. So legal "simple sentences" according to the definition above are, for example, "The cat runs.", "It bites quickly.", "He runs fast.", "The dog bites.". Some special words are pre-defined: DIGIT Any digit 0-9 ALPHA Any letter a-z, A-Z HTAB A horizontal tab character CRLF Carriage return character + linefeed character LF Linefeed character There is also a special case of literal string: If you want a quote mark, you have to write <"> A more complete description of BNF can be found at http://ds.internic.net/rfc/rfc822.txt.