-
-
Save perlpilot/13afc5a984d7399803ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/Perl6/Actions.pm b/src/Perl6/Actions.pm | |
index 63ebdab..b41bd44 100644 | |
--- a/src/Perl6/Actions.pm | |
+++ b/src/Perl6/Actions.pm | |
@@ -131,12 +131,16 @@ method statement($/, $key?) { | |
:pasttype(~$mc<sym>), :node($/) ); | |
} | |
if $ml { | |
- if ~$ml<sym> eq 'for' { | |
+ if ~$ml<sym> eq 'for' || ~$ml<sym> eq 'given' { | |
$past := PAST::Block.new( :blocktype('immediate'), | |
PAST::Var.new( :name('$_'), :scope('parameter'), :isdecl(1) ), | |
$past); | |
} | |
$past := PAST::Op.new($ml<smexpr>.ast, $past, :pasttype(~$ml<sym>), :node($/) ); | |
+ if ~$ml<sym> eq 'given' { | |
+ $past.push($past.shift); | |
+ $past.pasttype('call'); | |
+ } | |
} | |
} | |
elsif $<statement_control> { $past := $<statement_control>.ast; } | |
@@ -464,6 +468,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 | |
diff --git a/src/Perl6/Grammar.pm b/src/Perl6/Grammar.pm | |
index 680bd0e..f923c2c 100644 | |
--- a/src/Perl6/Grammar.pm | |
+++ b/src/Perl6/Grammar.pm | |
@@ -426,6 +426,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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment