Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add current tune progress to ABC::Actions.current-tune, which greatly…

… simplifies finding errors in ABC files.
  • Loading branch information...
commit 95126c93d019511a73c81faf8774c4ad3ce10246 1 parent 9e4e1b3
@colomon authored
Showing with 8 additions and 2 deletions.
  1. +3 −2 bin/abc2ly.pl
  2. +5 −0 lib/ABC/Actions.pm
View
5 bin/abc2ly.pl
@@ -393,8 +393,9 @@ (ABC::Header $header, $out)
}
sub TuneStreamToLilypondStream($in, $out) {
- my $match = ABC::Grammar.parse($in.slurp, :rule<tune_file>, :actions(ABC::Actions.new));
- die "Did not match ABC grammar" unless $match;
+ my $actions = ABC::Actions.new;
+ my $match = ABC::Grammar.parse($in.slurp, :rule<tune_file>, :$actions);
+ die "Did not match ABC grammar: last tune understood:\n { $actions.current-tune }" unless $match;
$out.say: '\\version "2.12.3"';
$out.say: "#(set-default-paper-size \"{$paper-size}\")";
View
5 lib/ABC/Actions.pm
@@ -12,9 +12,12 @@ use ABC::LongRest;
use ABC::GraceNotes;
class ABC::Actions {
+ has $.current-tune = "";
+
method header_field($/) {
if $<header_field_name> eq "T" {
$*ERR.say: "Parsing " ~ $<header_field_data>;
+ $.current-tune = $<header_field_data> ~ "\n";
}
make ~$<header_field_name> => ~$<header_field_data>;
@@ -153,6 +156,7 @@ class ABC::Actions {
}
method bar($/) {
+ $.current-tune ~= ~$/;
my @bar = @( $<element> )>>.ast;
if $<barline> {
@bar.push($<barline>>>.ast);
@@ -172,6 +176,7 @@ class ABC::Actions {
}
}
@line.push("endline" => "");
+ $.current-tune ~= "\n";
make @line;
}
Please sign in to comment.
Something went wrong with that request. Please try again.