Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Perlito5 - perl6 - while; <>
  • Loading branch information
fglock committed Oct 15, 2013
1 parent 2120983 commit 3ce38e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 5 additions & 2 deletions perlito5.pl
Expand Up @@ -12643,6 +12643,9 @@ package Perlito5::AST::Apply;
if (($code eq 'shift' || $code eq 'pop') && !@{$self->{'arguments'}}) {
return(['apply' => '(', $code, '@_'])
}
if ($code eq 'glob' && ref($self->{'arguments'}->[0]) eq 'Perlito5::AST::Val::Buf' && $self->{'arguments'}->[0]->{'buf'} eq '') {
return(['apply' => '(', ['keyword' => 'lines']])
}
if ($code eq 'infix:<x>') {
my $arg = $self->{'arguments'}->[0];
if (ref($arg) eq 'Perlito5::AST::Apply' && $arg->{'code'} eq 'circumfix:<( )>') {
Expand Down Expand Up @@ -12745,7 +12748,7 @@ package Perlito5::AST::When;
{
sub Perlito5::AST::When::emit_perl6 {
my $self = $_[0];
return(['stmt' => ['keyword' => 'when'], ['paren' => '(', $self->{'cond'}->emit_perl6()], Perlito5::Perl6::emit_perl6_block($self->{'body'}->stmts())])
return(['stmt' => ['keyword' => 'when'], $self->{'cond'}->emit_perl6(), Perlito5::Perl6::emit_perl6_block($self->{'body'}->stmts())])
}
}
package Perlito5::AST::While;
Expand All @@ -12758,7 +12761,7 @@ package Perlito5::AST::While;
if ($self->{'body'} && ref($self->{'body'}) ne 'Perlito5::AST::Lit::Block') {
return(@out, ['stmt_modifier' => $self->{'body'}->emit_perl6(), ['stmt' => ['keyword' => 'while'], $self->{'cond'}->emit_perl6()]])
}
push(@out, ['stmt' => ['keyword' => 'while'], ['paren' => '(', $self->{'cond'}->emit_perl6()], Perlito5::Perl6::emit_perl6_block($self->{'body'}->stmts())]);
push(@out, ['stmt' => ['keyword' => 'while'], $self->{'cond'}->emit_perl6(), Perlito5::Perl6::emit_perl6_block($self->{'body'}->stmts())]);
if ($self->{'continue'} && @{$self->{'continue'}->{'stmts'}}) {
push(@out, ['stmt' => ['keyword' => 'continue'], Perlito5::Perl6::emit_perl6_block($self->{'continue'}->{'stmts'})])
}
Expand Down
12 changes: 10 additions & 2 deletions src5/lib/Perlito5/Perl6/Emitter.pm
Expand Up @@ -417,6 +417,14 @@ package Perlito5::AST::Apply;
# TODO - @ARGV instead of @_ depending on context
return [ apply => '(', $code, '@_' ];
}
if ( $code eq 'glob'
&& ref($self->{arguments}[0]) eq 'Perlito5::AST::Val::Buf'
&& $self->{arguments}[0]{buf} eq ''
)
{
# TODO - glob or <> depending on context
return [ apply => '(', [ keyword => 'lines' ], ];
}

if ($code eq 'infix:<x>' ) {
my $arg = $self->{arguments}->[0];
Expand Down Expand Up @@ -554,7 +562,7 @@ package Perlito5::AST::When;
sub emit_perl6 {
my $self = $_[0];
return [ stmt => [ keyword => 'when' ],
[ paren => '(', $self->{cond}->emit_perl6() ],
$self->{cond}->emit_perl6(),
Perlito5::Perl6::emit_perl6_block($self->{body}->stmts)
];
}
Expand All @@ -574,7 +582,7 @@ package Perlito5::AST::While;
[ stmt => [ keyword => 'while' ], $self->{cond}->emit_perl6() ] ];
}
push @out, [ stmt => [ keyword => 'while' ],
[ paren => '(', $self->{cond}->emit_perl6() ],
$self->{cond}->emit_perl6(),
Perlito5::Perl6::emit_perl6_block($self->{body}->stmts)
];
if ($self->{continue} && @{ $self->{continue}{stmts} }) {
Expand Down

0 comments on commit 3ce38e5

Please sign in to comment.