BNF for abcDF
<sequence> := <staff> "@" <staff> | <staff>
<staff> := <line> | <line> "&" <staff>
<line> := <score_fingering> | <score_fingering> <line>
<score_fingering> := <ornamental> "/" <ornamental>
| <ornamental>
| <pedaled_fingering> "/" <pedaled_fingering>
| <pedaled_fingering>
| <pedaling> "/" <pedaling>
| <pedaling>
<ornamental> := "(" <pedaled_fingerings> ")"
<pedaled_fingering> := <soft> <fingering> <damper>
| <soft> <fingering>
| <fingering> <damper>
| <fingering>
<fingering> := <finger> "-" <finger>
| <finger>
<finger> := <hand> <digit> | <digit>
<pedaled_fingerings> := <pedaled_fingering>
| <pedaled_fingerings> <pedaled_fingerings>
<pedaling> := <soft> "x" <damper>
| <soft> "x"
| "x" <damper>
<damper> := "_" | "^"
<soft> := "p" | "f"
<hand> := "<" | ">"
<digit> := "1" | "2" | "3" | "4" | "5"
EBNF equivalent
sequence := staff ("@" staff)?
staff := line "&" staff | line | ""
line := (score_fingering)*
score_fingering := ornamental ("/" ornamental)? |
pedaled_fingering ("/" pedaled_fingering)? |
pedaling ("/" pedaling)?
ornamental := "(" (pedaled_fingering)+ ")"
pedaling := (soft)+ "x" (damper)+
pedaled_fingering := (soft)? fingering (damper)?
fingering := finger ("-" finger)?
finger := (hand)? digit
damper := "_" | "^"
soft := "p" | "f"
hand := "<" | ">"
digit := "1" | "2" | "3" | "4" | "5"
PEG.js recognizer
sequence = staff ("@" staff)?
staff = line "&" staff
/ line
/ ""
line = score_fingering*
score_fingering = ornamental "/" ornamental)?
/ pedaled_fingering ("/" pedaled_fingering)?
/ pedaling ("/" pedaling)?
ornamental = "(" pedaled_fingering+ ")"
pedaled_fingering = soft? fingering damper?
pedaling = soft? "x" damper?
fingering = finger ("-" finger)?
finger = hand? digit
damper = [_^]
soft = [pf]
hand = [<>]
digit = [1-5]
PEG.js transformer
sequence = upper:staff lower:("@" staff)? {
var map = {upper:upper};
if (lower) {
map['lower'] = lower[1];
}
return map;
}
staff = line "&" staff
/ line
/ ""
line = score_fingerings:score_fingering* {
return {score_fingerings:score_fingerings};
}
score_fingering = orn:ornamental alt_orn:("/" ornamental)? { var map = {first:orn, last:null}; if (alt_orn) {map.last = alt_orn[1];} return map;}
/ pf:pedaled_fingering alt_pf:("/" pedaled_fingering)? { var map = {first:pf, last:null}; if (alt_pf) {map.last = alt_pf[1];} return map;}
/ p:pedaling alt_p:("/" pedaling)? { var map = {first:p, last:null}; if (alt_p) {map.last = alt_p[1];} return map;}
ornamental = ornaments:("(" pedaled_fingering+ ")") {
ornaments.pop();
ornaments.shift();
return {ornaments:ornaments};
}
pedaled_fingering = soft:soft? fingering:fingering damper:damper? {
return {soft:soft, fingering:fingering, damper:damper};
}
pedaling = soft:soft? "x" damper:damper? {
var fingering = {strike:null, release:null};
return {soft:soft, fingering:fingering, damper:damper};
}
fingering = strike:finger release:(("-" finger)?) {
var map = {strike:strike, release:null};
if (release) {
map['release'] = release[1];
}
return map;
}
finger = hand:hand? digit:digit {return {hand:hand, digit:digit};}
damper = [_^]
soft = [pf]
hand = [<>]
digit = [1-5]