Navigation Menu

Skip to content

Commit

Permalink
simplify statement_mod_loop logic a little
Browse files Browse the repository at this point in the history
  • Loading branch information
perlpilot committed Feb 21, 2010
1 parent ed656df commit 68bb56b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
13 changes: 5 additions & 8 deletions src/Perl6/Actions.pm
Expand Up @@ -132,14 +132,11 @@ method statement($/, $key?) {
}
if $ml {
if ~$ml<sym> eq 'for' {
my $block := PAST::Block.new( :blocktype('immediate'),
$past := 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($/) );
}
$past := PAST::Op.new($ml<smexpr>.ast, $past, :pasttype(~$ml<sym>), :node($/) );
}
}
elsif $<statement_control> { $past := $<statement_control>.ast; }
Expand Down Expand Up @@ -464,9 +461,9 @@ sub add_phaser($/, $bank) {
method statement_mod_cond:sym<if>($/) { make $<cond>.ast; }
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; }
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; }

## Terms

Expand Down
6 changes: 3 additions & 3 deletions src/Perl6/Grammar.pm
Expand Up @@ -423,9 +423,9 @@ token statement_mod_cond:sym<unless> { <sym> :s <cond=.EXPR> }

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> }
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> }

## Terms

Expand Down

0 comments on commit 68bb56b

Please sign in to comment.