Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@perlpilot
Created February 21, 2010 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perlpilot/13afc5a984d7399803ef to your computer and use it in GitHub Desktop.
Save perlpilot/13afc5a984d7399803ef to your computer and use it in GitHub Desktop.
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