Permalink
Browse files

Perlito5 - perl6 - while; <>

  • Loading branch information...
1 parent 2120983 commit 3ce38e59d4d8e76a263532f260c46d337b4791d0 @fglock committed Oct 15, 2013
Showing with 15 additions and 4 deletions.
  1. +5 −2 perlito5.pl
  2. +10 −2 src5/lib/Perlito5/Perl6/Emitter.pm
View
@@ -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:<( )>') {
@@ -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;
@@ -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'})])
}
@@ -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];
@@ -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)
];
}
@@ -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} }) {

0 comments on commit 3ce38e5

Please sign in to comment.