Skip to content

Commit

Permalink
add support for unless+else constructs
Browse files Browse the repository at this point in the history
  • Loading branch information
FROGGS committed Mar 28, 2013
1 parent b2e16c8 commit aecb96f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/Perl6/P5Actions.pm
Expand Up @@ -798,6 +798,11 @@ class Perl6::P5Actions is HLL::Actions does STDActions {
method statement_control:sym<unless>($/) {
my $past := xblock_immediate( $<xblock>.ast );
$past.op('unless');
# push the else block if any
$past.push( $<else>
?? pblock_immediate( $<else>[0].ast )
!! QAST::Var.new(:name('Nil'), :scope('lexical'))
);
make $past;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Perl6/P5Grammar.pm
Expand Up @@ -1423,7 +1423,7 @@ grammar Perl6::P5Grammar is HLL::Grammar does STD5 {
rule statement_control:sym<unless> {
<sym>
<xblock>
[ <!before 'else'> || <.typed_panic: 'X::Syntax::UnlessElse'> ]
[ 'else' <else=.sblock> ]?
}

rule statement_control:sym<while> {
Expand Down

0 comments on commit aecb96f

Please sign in to comment.