Parrot Parrot Compiler Toolkit #37

Example: if_stmt (cont'd)

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

...

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

Method name matches rule name ('if_stmt')

{*} in parse rule indicates when action method should be invoked

Copyright © 2008 Patrick R. Michaud
http://www.pmichaud.com/2008/pres/