Not Quite Perl Not Quite Perl - A lightweight Perl 6 #7

What NQP is really good for

Parse rule:

rule statement_control:sym<if> {
    'if' <EXPR> <block>
    [ 'else' <else=.block> ]?
}

Transform to AST:

method statement_control:sym<if>($/) {
    my $past := PAST::Op.new( :pasttype('if'),
                    $<EXPR>.ast, $<block>.ast );
    if $<else> { $past.push( $<else>[0].ast }
    make $past;
}
Copyright © 2010
http://www.pmichaud.com/2010/pres/