Parrot Parrot Compiler Toolkit #39

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;
}

PAST::Op nodes represent operations

:pasttype('if') represents a conditional operation

(other :pasttype values include 'while', 'repeat_while', 'bind', 'call', 'callmethod', 'copy', 'try', etc.)

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