Skip to content
Browse files

Make <spacing> do horizontal spacing everywhere. Add <music>.

  • Loading branch information...
1 parent 8cf49a2 commit 97a6ca1ad7e750c8d92f522fe1eafa55f683c8de @LastOfTheCarelessMen committed Dec 20, 2009
Showing with 14 additions and 1 deletion.
  1. +3 −1 lib/ABC.pm
  2. +11 −0 t/01-regexes.t
View
4 lib/ABC.pm
@@ -21,7 +21,7 @@ grammar ABC
regex gracing { '+' <alpha>+ '+' }
- regex spacing { \s+ }
+ regex spacing { \h+ }
regex broken_rhythm_bracket { ['<'+ | '>'+] }
regex broken_rhythm { <note> <g1=gracing>* <broken_rhythm_bracket> <g2=gracing>* <note> }
@@ -33,6 +33,8 @@ grammar ABC
regex bar { <element>+ <barline>? }
regex line_of_music { <barline>? <bar>+ }
+
+ regex music { [<line_of_music> \s*\n?]+ }
}
class ABCHeader
View
11 t/01-regexes.t
@@ -183,4 +183,15 @@ for ':|:', '|:', '|', ':|', '::'
# say $match<ABC::line_of_music>.perl;
}
+{
+ my $music = q«A/B/c/A/ +trill+c>d e>deg | GG +trill+B>c d/B/A/G/ B/c/d/B/ |
+ A/B/c/A/ c>d e>deg | dB/A/ gB +trill+A2 +trill+e2 ::
+ g>ecg ec e/f/g/e/ | d/c/B/A/ Gd BG B/c/d/B/ |
+ g/f/e/d/ c/d/e/f/ gc e/f/g/e/ | dB/A/ gB +trill+A2 +trill+e2 :|»;
+ my $match = $music ~~ m/ <ABC::music> /;
+ isa_ok $match, Match, 'music recognized';
+ is $match<ABC::music><line_of_music>.elems, 4, "Four lines matched";
+ say $match<ABC::music>;
+}
+
done_testing;

0 comments on commit 97a6ca1

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