Acme-Gosub
view release on metacpan or search on metacpan
lib/Acme/Gosub.pm view on Meta::CPAN
{
my $pos_source = pos($source);
# This is an Evil hack that meant to get Text::Balanced to do
# what we want. What happens is that we put an initial ";"
# so the end of the statement will be a ";" too.
my $source_for_text_balanced = ";" .
substr($source, $pos_source);
pos($source_for_text_balanced) = 0;
@pos = Text::Balanced::_match_codeblock(\$source_for_text_balanced,qr/\s*/,qr/;/,qr/;/,qr/[[{(<]/,qr/[]})>]/,undef)
or do {
die "Bad gosub statement (problem in the parentheses?) near $Acme::Gosub::file line ", line(substr($source_for_text_balanced,0,pos $source_for_text_balanced),$line), "\n";
};
my $future_pos_source = $pos_source + pos($source_for_text_balanced);
print join(",",@pos), "\n";
$arg = filter_blocks(substr($source_for_text_balanced,1,$pos[4]-$pos[0]),line(substr($source_for_text_balanced,0,1),$line));
print "\$arg = $arg\n";
pos($source) = $future_pos_source;
}
my $next_ret_label = "__G_O_S_U_B_RET_LABEL_" .
($next_label_idx++);
( run in 0.699 second using v1.01-cache-2.11-cpan-4d50c553e7e )