Skip to content

Commit

Permalink
Implement given statement modifier.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Apr 1, 2010
1 parent 4384e1b commit 5a74e09
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/Perl6/Actions.pm
Expand Up @@ -134,13 +134,27 @@ method statement($/, $key?) {
}
if $ml {
my $cond := $ml<smexpr>.ast;
if ~$ml<sym> eq 'for' {
if ~$ml<sym> eq 'given' {
$past := PAST::Op.new(
:pasttype('call'),
PAST::Block.new(
:blocktype('declaration'),
PAST::Var.new( :name('$_'), :scope('parameter'), :isdecl(1) ),
$past
),
$cond
);
}
elsif ~$ml<sym> eq 'for' {
$past := PAST::Block.new( :blocktype('immediate'),
PAST::Var.new( :name('$_'), :scope('parameter'), :isdecl(1) ),
$past);
$cond := PAST::Op.new(:name('&eager'), $cond);
$past := PAST::Op.new($cond, $past, :pasttype(~$ml<sym>), :node($/) );
}
else {
$past := PAST::Op.new($cond, $past, :pasttype(~$ml<sym>), :node($/) );
}
$past := PAST::Op.new($cond, $past, :pasttype(~$ml<sym>), :node($/) );
}
}
elsif $<statement_control> { $past := $<statement_control>.ast; }
Expand Down Expand Up @@ -546,6 +560,7 @@ method statement_mod_cond:sym<unless>($/) { make $<cond>.ast; }
method statement_mod_loop:sym<while>($/) { make $<smexpr>.ast; }
method statement_mod_loop:sym<until>($/) { make $<smexpr>.ast; }
method statement_mod_loop:sym<for>($/) { make $<smexpr>.ast; }
method statement_mod_loop:sym<given>($/) { make $<smexpr>.ast; }

## Terms

Expand Down
1 change: 1 addition & 0 deletions src/Perl6/Grammar.pm
Expand Up @@ -454,6 +454,7 @@ proto token statement_mod_loop { <...> }
token statement_mod_loop:sym<while> { <sym> :s <smexpr=.EXPR> }
token statement_mod_loop:sym<until> { <sym> :s <smexpr=.EXPR> }
token statement_mod_loop:sym<for> { <sym> :s <smexpr=.EXPR> }
token statement_mod_loop:sym<given> { <sym> :s <smexpr=.EXPR> }

## Terms

Expand Down

0 comments on commit 5a74e09

Please sign in to comment.