Skip to content

Commit

Permalink
Simple statement modifier for loop
Browse files Browse the repository at this point in the history
Just iterates; doesn't return values
  • Loading branch information
perlpilot committed Feb 21, 2010
1 parent ec47f33 commit e904536
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Perl6/Actions.pm
Expand Up @@ -131,7 +131,15 @@ method statement($/, $key?) {
:pasttype(~$mc<sym>), :node($/) );
}
if $ml {
$past := PAST::Op.new($ml<cond>.ast, $past, :pasttype(~$ml<sym>), :node($/) );
if ~$ml<sym> eq 'for' {
my $block := PAST::Block.new( :blocktype('immediate'),
PAST::Var.new( :name('$_'), :scope('parameter'), :isdecl(1) ),
$past);
$past := PAST::Op.new($ml<EXPR>.ast, $block, :pasttype(~$ml<sym>), :node($/) );
}
else {
$past := PAST::Op.new($ml<cond>.ast, $past, :pasttype(~$ml<sym>), :node($/) );
}
}
}
elsif $<statement_control> { $past := $<statement_control>.ast; }
Expand Down Expand Up @@ -458,6 +466,7 @@ method statement_mod_cond:sym<unless>($/) { make $<cond>.ast; }

method statement_mod_loop:sym<while>($/) { make $<cond>.ast; }
method statement_mod_loop:sym<until>($/) { make $<cond>.ast; }
method statement_mod_loop:sym<for>($/) { make $<EXPR>.ast; }

## Terms

Expand Down
1 change: 1 addition & 0 deletions src/Perl6/Grammar.pm
Expand Up @@ -425,6 +425,7 @@ proto token statement_mod_loop { <...> }

token statement_mod_loop:sym<while> { <sym> :s <cond=.EXPR> }
token statement_mod_loop:sym<until> { <sym> :s <cond=.EXPR> }
token statement_mod_loop:sym<for> { <sym> :s <EXPR> }

## Terms

Expand Down

0 comments on commit e904536

Please sign in to comment.