Skip to content

Commit

Permalink
Get white space working.
Browse files Browse the repository at this point in the history
  • Loading branch information
LastOfTheCarelessMen committed Dec 20, 2009
1 parent 925e301 commit 702bdff
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
4 changes: 3 additions & 1 deletion lib/ABC.pm
Expand Up @@ -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 { ':|:' | '|:' | '|' | ':|' | '::' }

Expand Down
27 changes: 15 additions & 12 deletions t/01-regexes.t
Expand Up @@ -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;

0 comments on commit 702bdff

Please sign in to comment.