Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Get white space working.

  • Loading branch information...
commit 702bdff71e582440a38060eef1702550b93a36e4 1 parent 925e301
@LastOfTheCarelessMen authored
Showing with 18 additions and 13 deletions.
  1. +3 −1 lib/ABC.pm
  2. +15 −12 t/01-regexes.t
View
4 lib/ABC.pm
@@ -21,10 +21,12 @@ grammar ABC
regex gracing { '+' <alpha>+ '+' }
+ regex spacing { \s+ }
+
regex broken_rhythm_bracket { ['<'+ | '>'+] }
regex broken_rhythm { <note> <g1=gracing>* <broken_rhythm_bracket> <g2=gracing>* <note> }
- regex element { <broken_rhythm> | <note> | <rest> | <gracing> }
+ regex element { <broken_rhythm> | <note> | <rest> | <gracing> | <spacing> }
regex barline { ':|:' | '|:' | '|' | ':|' | '::' }
View
27 t/01-regexes.t
@@ -154,17 +154,20 @@ for ':|:', '|:', '|', ':|', '::'
is $match<ABC::bar><barline>, "|", "Barline was matched";
}
-# {
-# my $match = "g>ecg ec e/f/g/e/ |" ~~ m/ <ABC::bar> /;
-# isa_ok $match, Match, 'bar recognized';
-# say $match<ABC::bar>.perl;
-# say $match<ABC::bar>;
-# }
-
-# {
-# my $match = "g>ecg ec e/f/g/e/ | d/c/B/A/ Gd BG B/c/d/B/ |" ~~ m/ <ABC::line_of_music> /;
-# isa_ok $match, Match, 'line of music recognized';
-# say $match<ABC::line_of_music>.perl;
-# }
+{
+ my $match = "g>ecg ec e/f/g/e/ |" ~~ m/ <ABC::bar> /;
+ isa_ok $match, Match, 'bar recognized';
+ is $match<ABC::bar>, "g>ecg ec e/f/g/e/ |", "Entire bar was matched";
+ is $match<ABC::bar><element>.map(~*), "g>e c g e c e/ f/ g/ e/ ", "Each element was matched";
+ is $match<ABC::bar><barline>, "|", "Barline was matched";
+}
+
+{
+ my $line = "g>ecg ec e/f/g/e/ | d/c/B/A/ Gd BG B/c/d/B/ |";
+ my $match = $line ~~ m/ <ABC::line_of_music> /;
+ isa_ok $match, Match, 'line of music recognized';
+ is $match<ABC::line_of_music>, $line, "Entire line was matched";
+ say $match<ABC::line_of_music>.perl;
+}
done_testing;
Please sign in to comment.
Something went wrong with that request. Please try again.