Skip to content
Browse files

Use an alias to distinguish between the first and second <gracing> ca…

…ptures. Add (untested) barline and line_of_music regexes.
  • Loading branch information...
1 parent 46f0793 commit 479f3deeb33fbe35632ecdafa0290228350c658b @LastOfTheCarelessMen committed Dec 17, 2009
Showing with 10 additions and 5 deletions.
  1. +6 −1 lib/ABC.pm
  2. +4 −4 t/01-regexes.t
View
7 lib/ABC.pm
@@ -22,10 +22,15 @@ grammar ABC
regex gracing { '+' <alpha>+ '+' }
regex broken_rhythm_bracket { ['<'+ | '>'+] }
- regex broken_rhythm { <note> <gracing>* <broken_rhythm_bracket> <gracing>* <note> }
+ regex broken_rhythm { <note> <gracing>* <broken_rhythm_bracket> <g2=gracing>* <note> }
regex element { <note> | <broken_rhythm> | <rest> | <gracing> }
+ regex barline { '|' | ':|' | '|:' | ':|:' | '::' }
+
+ regex line_of_music { <barline> | [<barline>? <element>+ [<barline> <element>+]* <barline>?] }
+
+
}
class ABCHeader
View
8 t/01-regexes.t
@@ -121,15 +121,15 @@ plan *;
}
{
- my $match = "d'<<<+accent+_B" ~~ m/ <ABC::broken_rhythm> /;
- isa_ok $match, Match, '"d<<<+accent+_B" is a broken rhythm';
+ my $match = "d'+p+<<<+accent+_B" ~~ m/ <ABC::broken_rhythm> /;
+ isa_ok $match, Match, '"d+p+<<<+accent+_B" is a broken rhythm';
is $match<ABC::broken_rhythm><note>[0]<pitch><basenote>, "d", 'first note is d';
is $match<ABC::broken_rhythm><note>[0]<pitch><octave>, "'", 'first note has an octave tick';
is $match<ABC::broken_rhythm><note>[0]<pitch><accidental>, "", 'first note has no accidental';
is $match<ABC::broken_rhythm><note>[0]<note_length>, "", 'first note has no length';
+ is $match<ABC::broken_rhythm><gracing>[0], "+p+", 'first gracing is +p+';
is $match<ABC::broken_rhythm><broken_rhythm_bracket>, "<<<", 'angle is <<<';
- # how to know first gracing pattern versus second?
- is $match<ABC::broken_rhythm><gracing>[0], "+accent+", 'second gracing is +accent+';
+ is $match<ABC::broken_rhythm><g2>[0], "+accent+", 'second gracing is +accent+';
is $match<ABC::broken_rhythm><note>[1]<pitch><basenote>, "B", 'second note is B';
is $match<ABC::broken_rhythm><note>[1]<pitch><octave>, "", 'second note has no octave';
is $match<ABC::broken_rhythm><note>[1]<pitch><accidental>, "_", 'second note is flat';

0 comments on commit 479f3de

Please sign in to comment.
Something went wrong with that request. Please try again.