Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Perlito5 - simple perl6 eval($str, :$lang<perl5>) works!
  • Loading branch information
fglock committed May 26, 2012
1 parent 91820ec commit 9ea3cc4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
27 changes: 23 additions & 4 deletions perl6-eval.p6
Expand Up @@ -8,11 +8,30 @@ multi eval($str, :$lang! where 'perl5') {
$fh.close;
shell "perl perlito5.pl -Isrc5/lib -Cperl6 $inp_file > $out_file";
my $p6_str = slurp $out_file;
say "[[$p6_str]]";
eval($p6_str, :lang<perl6>);
# say "[[$p6_str]]";
$p6_str.eval;
}

my $p5_str = "say 'hello, World!'";
#eval $p5_str;
my $p5_str = '
my @x;
$x[1] = 2+2;
say "got $x[1]";
';
eval($p5_str, :lang<perl5>);


=begin comments
If I define multi eval($str, :$lang! where 'perl5')
then rakudo can't find eval :lang<perl6> anymore
because eval is declared as an only sub
This is a workaround (by moritz++):
proto eval(|$) {*};
multi sub eval($str) {
$str.eval;
}
=end comments

1 change: 0 additions & 1 deletion perlito5.pl
Expand Up @@ -9699,7 +9699,6 @@ package Perlito5::AST::CompUnit;
sub Perlito5::AST::CompUnit::emit_perl6_program {
((my $comp_units) = shift());
((my $str) = '');
($str = ($str . 'use Perlito5::Perl6::Runtime;' . chr(10)));
for my $comp_unit (@{$comp_units}) {
($str = ($str . $comp_unit->emit_perl6() . chr(10)))
};
Expand Down
2 changes: 1 addition & 1 deletion src5/lib/Perlito5/Perl6/Emitter.pm
Expand Up @@ -207,7 +207,7 @@ package Perlito5::AST::CompUnit;
sub emit_perl6_program {
my $comp_units = shift;
my $str = '';
$str .= "use Perlito5::Perl6::Runtime;\n";
# $str .= "use Perlito5::Perl6::Runtime;\n";
for my $comp_unit ( @$comp_units ) {
$str = $str . $comp_unit->emit_perl6() . "\n";
}
Expand Down

0 comments on commit 9ea3cc4

Please sign in to comment.