Parrot Parrot Compiler Toolkit #43

calc example -- src/parser/actions.pm

class Calc::Grammar::Actions;

method TOP($/) {
    make PAST::Op.new( $($<statement>), :name('say') );
}

method statement($/) {
    make PAST::Op.new( $($<term>[0]),
                       $($<term>[1]),
                       :pirop('n_add')
                     );
}

method term($/) {
    make PAST::Val.new( :value(+$/) );
}
Copyright © 2008 Patrick R. Michaud
http://www.pmichaud.com/2008/pres/