Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add regex bar, working test for bar (without whitespaces).

  • Loading branch information...
commit 925e301605f7c45afcc6b35997f34d9bc1d94dbf 1 parent 3d558f6
@LastOfTheCarelessMen authored
Showing with 23 additions and 6 deletions.
  1. +4 −2 lib/ABC.pm
  2. +19 −4 t/01-regexes.t
View
6 lib/ABC.pm
@@ -24,11 +24,13 @@ grammar ABC
regex broken_rhythm_bracket { ['<'+ | '>'+] }
regex broken_rhythm { <note> <g1=gracing>* <broken_rhythm_bracket> <g2=gracing>* <note> }
- regex element { <note> | <broken_rhythm> | <rest> | <gracing> }
+ regex element { <broken_rhythm> | <note> | <rest> | <gracing> }
regex barline { ':|:' | '|:' | '|' | ':|' | '::' }
- regex line_of_music { <barline> | [<barline>? <element>+ [<barline> <element>+]* <barline>?] }
+ regex bar { <element>+ <barline>? }
+
+ regex line_of_music { <barline> $$ | <barline>? <element>+ $$ }
}
class ABCHeader
View
23 t/01-regexes.t
@@ -147,9 +147,24 @@ for ':|:', '|:', '|', ':|', '::'
}
{
- 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>ecgece/f/g/e/|" ~~ m/ <ABC::bar> /;
+ isa_ok $match, Match, 'bar recognized';
+ is $match<ABC::bar>, "g>ecgece/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 $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;
+# }
done_testing;
Please sign in to comment.
Something went wrong with that request. Please try again.