Parrot Parrot Compiler Toolkit #36

Example: if_stmt

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

Add an action token to the rule:

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

Add method to src/parser/actions.pm to generate PAST:

method if_stmt($/) {
    my $past := PAST::Op.new( $($<expression>),
                              $($<statement>),
                              :pasttype('if') );
    make $past;
}
Copyright © 2008 Patrick R. Michaud
http://www.pmichaud.com/2008/pres/