Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
First whack at (;;) and [;;] producing LoL
It works for those constructs, but breaks other stuff subtly.
  • Loading branch information
TimToady committed Aug 17, 2014
1 parent b52ef05 commit 0f01a5d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 44 deletions.
62 changes: 19 additions & 43 deletions src/Perl6/Actions.nqp
Expand Up @@ -822,14 +822,24 @@ class Perl6::Actions is HLL::Actions does STDActions {

# Should produce a LoL, with most uses converted to actually statementlist
method semilist($/) {
my $past := QAST::Stmts.new( :node($/) );
my $past := QAST::Stmts.new( :node($/) );
if $<statement> {
for $<statement> { $past.push($_.ast) if $_.ast; }
}
unless +@($past) {
$past.push( QAST::Op.new( :op('call'), :name('&infix:<,>') ) );
if $<statement> > 1 {
my $l := QAST::Op.new( :name('&infix:<,>'), :op('call'));
for $<statement> {
$l.push($_.ast);
}
$past.push(QAST::Op.new( :name('lol'), :op('callmethod'), $l));
}
else {
$past.push($<statement>[0].ast);
}
}
make $past;
unless +@($past) {
$past := QAST::Op.new( :op('call'), :name('&infix:<,>') );
}

make $past;
}

method statement($/, $key?) {
Expand Down Expand Up @@ -4635,19 +4645,7 @@ class Perl6::Actions is HLL::Actions does STDActions {
method term:sym<value>($/) { make $<value>.ast; }

method circumfix:sym<( )>($/) {
my $past := $<semilist>.ast;
my $size := +$past.list;
if $size == 0 {
$past := QAST::Op.new( :op('call'), :name('&infix:<,>') );
}
else {
my $last := $past[ $size - 1 ];
$past.returns($last.returns);
if nqp::istype($last, QAST::Block) {
$past.arity($last.arity);
}
}
make $past;
make $<semilist>.ast;
}

method circumfix:sym<ang>($/) { make $<nibble>.ast; }
Expand Down Expand Up @@ -5520,35 +5518,13 @@ class Perl6::Actions is HLL::Actions does STDActions {

method postcircumfix:sym<[ ]>($/) {
my $past := QAST::Op.new( :name('&postcircumfix:<[ ]>'), :op('call'), :node($/) );
# Should eventually be $past.push($<semilist>.ast) if $<semilist><statement>
if $<semilist><statement> {
if $<semilist><statement> > 1 {
my $l := QAST::Op.new( :name('&infix:<,>'), :op('call'));
for $<semilist><statement> {
$l.push($_.ast);
}
$past.push(QAST::Op.new( :name('lol'), :op('callmethod'), $l));
} else {
$past.push($<semilist>.ast);
}
}
$past.push($<semilist>.ast);
make $past;
}

method postcircumfix:sym<{ }>($/) {
my $past := QAST::Op.new( :name('&postcircumfix:<{ }>'), :op('call'), :node($/) );
# Should eventually be $past.push($<semilist>.ast) if $<semilist><statement>
if $<semilist><statement> {
if $<semilist><statement> > 1 {
my $l := QAST::Op.new( :name('&infix:<,>'), :op('call'));
for $<semilist><statement> {
$l.push($_.ast);
}
$past.push(QAST::Op.new( :name('lol'), :op('callmethod'), $l));
} else {
$past.push($<semilist>.ast);
}
}
$past.push($<semilist>.ast);
make $past;
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/GatherIter.pm
Expand Up @@ -21,7 +21,7 @@ class GatherIter is Iterator {
}
$state := {
nqp::handle( $block().eager(),
'TAKE', ($takings := nqp::getpayload(nqp::exception()); yield(); nqp::resume(nqp::exception())));
'TAKE', do { $takings := nqp::getpayload(nqp::exception()); yield(); nqp::resume(nqp::exception())});
$takings := $SENTINEL; yield();
};
my $coro := { nqp::continuationreset($GATHER_PROMPT, $state); $takings };
Expand Down

0 comments on commit 0f01a5d

Please sign in to comment.