Parrot Parrot Compiler Toolkit #40

Example: if_stmt (cont'd)

rule if_stmt { 'if' <expression> 'then' <statement> {*} }

...

method if_stmt($/) {
    my $past := PAST::Op.new( $<expression>.ast,
                              $<statement>.ast,
                              :pasttype('if') );
    make $past;
}

$<expression> is the parse tree for <expression> in the rule

$<expression>.ast is its AST representation

(same for $<statement> and $<statement>.ast )

Copyright © 2009
http://www.pmichaud.com/2009/pres/